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[]
}