Page 1 of 1

how to get min/max from mem (audio data) directly?

PostPosted: Sat Oct 07, 2017 7:50 pm
by tester
Problem.

Loaded audio file is stored in mem,

In order to calculate min/max values - the simplest way is to convert mem to array and go from there.

But if loaded audio file is large (say 400-600MB), then in such cases I get a message, that there not enough memory (task manager confirms it), which is correct. So green arrays are not in the game.

Is there a way to get min/max values directly from mem connector, or in a way, that memory is not overloaded?

Re: how to get min/max from mem (audio data) directly?

PostPosted: Sun Oct 08, 2017 8:57 am
by martinvicanek
Here is a code version, takes about 2 seconds for an entire song here. Not sure about the max file size. If your file is too big to load and process in one go break it into pieces.

Re: how to get min/max from mem (audio data) directly?

PostPosted: Sun Oct 08, 2017 10:11 am
by tester
This is not going to fit in such raw form.

From what I see, 23.5MB wave file (2'20") eats 280MB of memory (38MB empty flowstone, and - 131MB after clearing the file; there is a memory issue related to releasing memory). This is because there are several places in greenery, where array of floats is created/duplicated (analyzers are the starting points). So with larger files, it will not load at all in this form.

Perhaps, loop based recalc, so that at each cycle
1) index is incresed by certain fixed amount (15 cycles per 30 mins in 2mins parts let say)
2) small fixed NS is used for analyzer (bonded with step size above)
3) all steps are queued, and max of them is sent output
4) single analyzer was used (global max for normalizing)
would to the job.

In the meantime my question is - can be the max value (for calculating normalize value) taken directly from mem connector, without pushing the whole file into green array of floats? So the output would be like a readout with blue S&H or something like it.

In FS there is a prim, for converting mem into smaller (via average) arrays of floats for creating graphs, so this indicates, that this is perhaps possible. BTW, such averaged smaller arrays from it can't be used as a normalizing baxe due to averaging.

Re: how to get min/max from mem (audio data) directly?

PostPosted: Mon Oct 09, 2017 8:48 pm
by tester
I think I have an idea.

Probably no analyzer needed.

1) Counter, with step set to play it at 1000x speed (will go at max CPU I guess)
2) Single playback limiter
3) waveread out connected to min/max modules directly on node 1, and via "1 sample delay" to node 2 (alternatively, output looped to node 2, I guess there is a 1 sample delay anyway). This approach will always send to output the maximum value of 2 points, resulting with maxpoint at the end
4) blue'ish sample and hold (maybe even not needed - greenery may hold it too) to store the final value.

So this is sample-by-sample approach, but at audio (free rendering) performance.