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 › Sonia FFT Frequency Spectrum for samples
Page Index Toggle Pages: 1
Sonia FFT Frequency Spectrum for samples (Read 1484 times)
Sonia FFT Frequency Spectrum for samples
Jan 17th, 2006, 2:33pm
 
Hello everybody,

I have just started playing with Sonia and I have a question regarding the getSpectrum function. While it seems that I can display the FFT Frequency Spectrum values for the LiveInput, I cannot do the same with a sample. I've searched a bit and found people using it in the past. It is even greyish in the examples at sonia.pitaru.com. Am I missing something?

Thanks in advance Smiley
Re: Sonia FFT Frequency Spectrum for samples
Reply #1 - Jan 17th, 2006, 3:12pm
 
Well...

searched a bit more to realize that this could be done with connectLiveInput()! BUT this doesn't work either (gives a Java.lang.NullPointerException error)! In "problems with Sonia's connectLiveInput()" topic they discuss exactly that... anyone found out what's going on?
Re: Sonia FFT Frequency Spectrum for samples
Reply #2 - Jan 17th, 2006, 3:37pm
 
Kind of stupid replying to myself, but I hope this may help someone in the future Smiley:

I FINALLY made it WORK like this:


import pitaru.sonia_v2_9.*;

Sample mySample;

void setup() {
 Sonia.start(this);
 LiveInput.start();
 mySample = new Sample("1fe.wav");
 mySample.repeat(); // play the sample once.
 mySample.connectLiveInput(true);
}

void draw()
{
 background(0,20,0);
 strokeWeight(0);
 stroke(0,230,0);

  LiveInput.getSpectrum();
  for ( int i = 0; i < LiveInput.spectrum.length; i++)
  {
  line(i*2, height, i*2, height - LiveInput.spectrum[i]/10);
  }  
}

Page Index Toggle Pages: 1