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 bug: readChannel() not working
Page Index Toggle Pages: 1
Sonia bug: readChannel() not working? (Read 569 times)
Sonia bug: readChannel() not working?
Nov 8th, 2006, 12:48am
 
Hello,

I'm trying to use sonia's readChannel() function,
but I keep getting arrayIndex Out of Bounds Exceptions.

There is a problem with the function : mySample.readChannel(channel, dataArray, firstDataFrame, firstSampleFrame, numFrames)

I should be able to choose arbitrary value for (firstSampleFrame), the position to start reading the soundfile from, but when (firstSampleFrame + numFrames) is greater than the size of (dataArray), it causes an error.  

As I understand it, the value of (numFrames) being less than or equal to the size of (dataArray), is all that should matter.  

Code:

import pitaru.sonia_v2_9.*; // automatically created when importing sonia using the processing menu.
Sample mySample;
int startframe;

float frame[]=new float[1470]; // 1470 audio samples per frame @ 30 fps


void setup(){
size(640,480);
Sonia.start(this); // Start Sonia engine.

mySample = new Sample("song.aif");
}




void draw(){

startframe=0;
//anything other than 0 causes out of bounds exceptions with the next line

mySample.readChannel(1, frame, 0, startframe, 1470);


background(0);
stroke(255);

for(int i=0;i<width;i++){
line(i,height,i,height-(frame[i]*200) ); } //draw contents of frame[]

}


Page Index Toggle Pages: 1