Page 1 of 1

fast array resample in ruby?

Posted: Mon Jun 13, 2016 2:36 pm
by tester
Can someone help with ruby code for fast array resample?

Actually downsample, so for example input is "44100 x time" samples long and destination should be "600 x time" samples long. Since this is calculated many times per shot, it would be good to speed it up a little.

Re: fast array resample in ruby?

Posted: Mon Jun 13, 2016 3:09 pm
by TheOm
Why ruby? I doubt that you can get faster than the resample primitive with ruby. Maybe in ASM.
Also what kind of interpolation do you need?

Re: fast array resample in ruby?

Posted: Mon Jun 13, 2016 5:40 pm
by tester
I'm doing a statistical analyzer of audio textures. The signal path is similar to what is in attached file, with the exception that everything goes through analyzer prims, to produce arrays, that go through statistical analysis...

Basically, the concept is this. Signals goes through c.a. 900 filters (32 main filters and 20 + 7 filters per main slot in second order). Each filter produces an envelope at maximum rate around 200-250Hz, each about 10 seconds long. These envelopes are stored to memory via mem prims. So there are about 900 envelopes, each SR*t samples long. At 44.1k or more - this would take a lot of memory, plus statistical module would have too much of unnecessary work.

After filtered samples are stored to memory, serialized multiplexer just brings appropriate mems (various combinations), converts them back to arrays, and arrays are pushed through statistics. The statistics are generally wired, but there are still some trigger and normalization issues to deal with, but it's a second part. Third step (not touched yet) is a simple neural network, that learns from gathered statistics and produces identification ranges... :mrgreen:

Anyway. What I need at this point is a good way to resample these arrays (portions of filtered streamy signals), and it's possible that it could go with additional LP filters combined with resampler, to avoid aliasing (I assumed, that current filtration may do a decent job, but not tested it yet). Simple linear interpolatio should be enough.

BTW, filters are not optimized yet, I just experimentally selected which ones will do probably good job in such small ranges.

Re: fast array resample in ruby?

Posted: Tue Jun 14, 2016 11:02 am
by tester
I think I found another way to deal with resample/downsample stuff.

Following schematic is an example. To downsample by factor x100 it would just require 100 such modules as inside.

//edit: solved