Ruby resampling help

For general discussion related FlowStone
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Ruby resampling help

Post 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!
Attachments
ruby resample.fsm
(572 Bytes) Downloaded 1003 times
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Ruby resampling help

Post 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?
Logado
Posts: 62
Joined: Tue Jan 06, 2015 5:42 pm

Re: Ruby resampling help

Post by Logado »

it looks close, the code is ugly, I do not know Ruby very well ;(
Attachments
ruby resample.fsm
(4.22 KiB) Downloaded 953 times
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Ruby resampling help

Post 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
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Ruby resampling help

Post 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 :?
Attachments
ruby resampling.fsm
(627 Bytes) Downloaded 977 times
User avatar
nix
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Ruby resampling help

Post 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
Logado
Posts: 62
Joined: Tue Jan 06, 2015 5:42 pm

Re: Ruby resampling help

Post 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
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby resampling help

Post 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) :D
"There lies the dog buried" (German saying translated literally)
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Ruby resampling help

Post 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.
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Ruby resampling help

Post 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? :D
Post Reply