We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Sound Sample Spectrum in Sonia
Page Index Toggle Pages: 1
Sound Sample Spectrum in Sonia (Read 671 times)
Sound Sample Spectrum in Sonia
Feb 12th, 2008, 3:51pm
 
Hi!

I've got a quick late night question.  Wondering if it's possible to display the correct sound spectrum Information for a Sound Sample using Sonia?

eg :

Code:

Sonia.start(this);
mySample = new Sample("overandover.wav");
mySample.play();


So To Display the information for 'mySample' As far as I can see I've got two alternatives.  I can call 'getSpectrum' and get that information - or I can call 'readChannel' and use that information.  The problem is, neither of them realy look *right*.

Any other suggestions ?

Basically I want to have as accurate mapping of an imported file as is possible.
Re: Sound Sample Spectrum in Sonia
Reply #1 - Feb 19th, 2008, 12:30pm
 
Not sure if I realy made myself clear in that last post! Sorry!

So, Essentially what I'd like to do, is load up an external sound file, and display the spectral data for the complete file.  Similar to opening a audio file in a music / sound editor and getting this :

...

Currently I'm using Sonia, and I'm using the following code to recieve the data ... I assume this is the correct way to do it ?:

Code:

data = new float[mySample.getNumFrames()];
mySample.read(data);


( Either data or readChannel ).  This of course returns an array with the number of sound frames contained within the file, but my Processing width is only so big - So in order to actually *display* this, I either have to ignore a lot of the frames, or find an average.

Both turn out ... oddly though.

...

That version is drawn using the following code :

Code:

int avgVal = (data.length/width);
for (int i=0; i<width; i++){
line(i,middle,i,middle+(data[i*avgVal]*middle));
}

( where middleis the mid point of the y axis )

So is there any way to make my version look more like the above version ?

Thanks! Hope that makes more sense...
Re: Sound Sample Spectrum in Sonia
Reply #2 - Apr 17th, 2008, 4:09pm
 
Hello!
Is there a way to set the samplerate in sonia when calling ffthelper or liveinput?
thx
Page Index Toggle Pages: 1