 |
 |
 |
Class |
|
Sample |
 |
|
|
Name |
|
read() |
 |
|
|
Examples |
|
// Populate the data[] array with sample data.
// Notes: Make sure to include the specified audio file in your project's 'data' folder.
Sample mySample;
float[] data;
void setup() {
size(100,100);
Sonia.start(this);
mySample = new Sample("sine.aiff");
data = new float[mySample.getNumFrames()]; //creates a new array the length of the sample
mySample.read(data);
}
public void stop(){
Sonia.stop();
super.stop();
}
|
|
|
Description |
|
Populates an array with the data from a mono sample (use readChannel() for stereo samples). The sample data comes in floats of -1.0 to 1.0 per frame. A 44.1 kHz sample has 44100 frames per second. |
 |
|
|
Syntax |
|
mySample.read(dataArray) // reads entire sample into the data array.
mySample.read(dataArray, firstDataFrame, firstSampleFrame, numFrames)
|
 |
|
|
Parameters |
|
dataArray |
|
float[]: an array that can hold float values
|
firstDataFrame |
|
int: First index element to populate in the data[] array
|
firstSampleFrame |
|
int: First sample frame to read
|
numFrames |
|
int: number of sample frames to read
|
|
 |
|
|
Returns |
|
None |
 |
|
|
Usage |
|
Web & Application |
 |
|
|
Related |
|
readChannel() write() writeChannel() |