Page 1 of 2
Ruby resampling help
Posted: Sun Sep 03, 2017 9:14 pm
by adamszabo
Hey guys, I am trying to mimic the array resampling module with ruby, and I found something online but it doesnt really do the same thing. Can anyone with some expertise crack this?
Thank you!
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 1:38 am
by Youlean
adamszabo wrote:Hey guys, I am trying to mimic the array resampling module with ruby, and I found something online but it doesnt really do the same thing. Can anyone with some expertise crack this?
Thank you!
Why do you need that?
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 4:38 am
by Logado
it looks close, the code is ugly, I do not know Ruby very well ;(
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 8:26 am
by adamszabo
Thank you, looks interesting! I would need it because I would like to replace a whole green stuff with only ruby to make it nicer and more effective
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 11:42 am
by adamszabo
Logado, thanks to your help I could understand whats going on and I made a more Ruby-ish version. It works great! Now only if I knew how to make the cubic interpolation and that smoothing they use in the resampler module

Re: Ruby resampling help
Posted: Wed Sep 06, 2017 11:49 am
by nix
as far as I have gathered, linear is a good one, it's what I would set the resample to
- sorry I would struggle to help
edit- to smooth the end points, multiply by a faded array of points
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 2:56 pm
by Logado
I've never used a cubic interpolation, maybe you'll find the answer here.
I think we need to, hook more samples and use a
frac instead of a
t in formulas
https://www.ibiblio.org/e-notes/Splines/Intro.htm
Re: Ruby resampling help
Posted: Wed Sep 06, 2017 4:35 pm
by tulamide
I made several examples of cubic interpolation. A descripted version can be found in the module definition of my spline class.
http://flowstone.guru/downloads/ruby-for-flowstone-expansion-spline-class/But basically: You can derive cubic from linear, when omitting higher math.
lin = a + x * (b - a)
quad = lin1 + x * (lin2 - lin1)
cubic = quad1 + x * (quad2 - quad1)
cubic needs 4 poles and a position/time value
a, b, c, d
lin1 uses a,b
lin2 uses b,c
lin3 uses c,d
quad1 uses lin1, lin2
quad2 uses lin2, lin3
Happy programming (or copying from the spline class's module)

Re: Ruby resampling help
Posted: Thu Sep 07, 2017 1:50 pm
by Youlean
adamszabo wrote:Thank you, looks interesting! I would need it because I would like to replace a whole green stuff with only ruby to make it nicer and more effective
Well Ruby won't be much faster than green. You should use dll if you want speed. I could make dll for that if you need.
Re: Ruby resampling help
Posted: Tue Sep 12, 2017 11:52 pm
by adamszabo
tulamide wrote:lin = a + x * (b - a)
quad = lin1 + x * (lin2 - lin1)
cubic = quad1 + x * (quad2 - quad1)
cubic needs 4 poles and a position/time value
a, b, c, d
lin1 uses a,b
lin2 uses b,c
lin3 uses c,d
quad1 uses lin1, lin2
quad2 uses lin2, lin3
I tried my very best but I couldnt make it happen. Any examples?
