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 LiveInput.signal issues
Page Index Toggle Pages: 1
Sonia LiveInput.signal issues (Read 1041 times)
Sonia LiveInput.signal issues
Feb 24th, 2006, 5:53pm
 
I am having issues reading the signals from the LiveInput signal array in Sonia.Every value in the array is 0. I am not sure what I am doing wrong. I cant find much documentation concerning the array.

import pitaru.sonia_v2_9.*;

Sample mySample;  

int fft_bands;
float[] fft_spectrum;

String signal_str = "";

boolean once = false;

void setup(){
 size(200, 200);  
 ellipseMode(CENTER);
 rectMode(CENTER);
 noStroke();
   
 fft_bands = 16;  
 fft_spectrum = new float[fft_bands];

 Sonia.start(this);
 LiveInput.start(fft_bands);
 mySample = new Sample("hello.wav");  
 mySample.play(); // play the sample once.  
 mySample.connectLiveInput(true);

 //LiveInput.useEqualizer(true);
 //LiveInput.useEnvelope(true,1.5);    
}

void draw(){
 background(255);
 if(mySample.isPlaying()){
   updateSignal();
 }
 else if(!mySample.isPlaying()){
   if(!once) {
     String[] signal_strs = split(signal_str, ",");
     saveStrings("signal.txt", signal_strs);
     once = true;
   }
 }
}

void updateSignal() {
 for(int i = 0; i < LiveInput.signal.length; i++){
   signal_str += LiveInput.signal[i]+", ";
 }
}


public void stop() {
 Sonia.stop();
 super.stop();
}

Re: Sonia LiveInput.signal issues
Reply #1 - Feb 24th, 2006, 7:38pm
 
I fixed the issue. A getSpectrum() call is required before accessing the signal values. So I am assuming getSpectrum populates both the signal and spectrum array; something that should be documented.
Page Index Toggle Pages: 1