Page 1 of 1

storing samples

Posted: Fri Nov 30, 2012 3:59 pm
by jto1
Hi, could some one tell me is it posible to store samples in a array then
Compare them with samples from a wav sample or even a live stream?

Re: storing samples

Posted: Fri Nov 30, 2012 5:55 pm
by trogluddite
Certainly, yes.
The two components 'mem to float array' and 'float array to mem' let you translate between a standard float array and the raw wave data (a 'wav file for example); and the various flavours of 'mono to graph' let you grab a 'snapshot' of an incoming audio stream as a float array of sample values. They all use the same -1...+1 range for min/max audio level, so the values you get are directly comparable.
The 'load wave' and 'save wave' components also mean that it is easy to read and store the 'mem' data using standard wave files that are usable in other applications.
If you wanted to compare two long arrays of data like that, I'd suggest using a Ruby routine, but you could also do it by using an 'integer loop' to iterate over the arrays using "green" components. Ruby would also make it possible to use the 'frames' components to grab snapshots of the audio with much better timing accuracy - though the CPU load is pretty high if you want to grab frames more that a few times per second.
That all would work at a pretty low data rate, of course - fine for comparing two arrays of data "off-line". If you wanted to correlate a live audio stream with a 'template', you'd need to work using the DSP code or Assembler primitives in order to write a routine that was anything like fast enough. But that is really not an easy task, as there's no way so far to push array data into those modules in bulk - similar things have been done before, but only for relatively short arrays of a few dozen samples.

Re: storing samples

Posted: Sat Dec 01, 2012 6:19 am
by jto1
Thanks for your advice trogluddite. I did look at the ruby module for this, I will play around with it and
see what i come up with. Thanks again