 |
 |
 |
 |
| Class |
|
LiveOutput |
 |
|
|
| Name |
|
start() |
 |
|
|
| Examples |
|
// Start the LiveOutput engine with a streamSize of 512 frames, and a streamBuffer twice the size.
// Use the LiveOutputEvent(){} to update the LiveOutput.data[] array with Sine wave information.
// The Y value of the mouse will determine the Sine wave's frequency.
// Draw the current sound data on the stage.
int streamSize = 512; // holds the streamSize value for the liveOutput.data[] array.
void setup(){
size(512,200);
Sonia.start(this,11025); // Start Sonia at a lower sampling-rate for better performance.
LiveOutput.start(streamSize,streamSize*2); // Start LiveOutput with a buffer.
LiveOutput.startStream(); // Start the liveOutput stream, and activate the liveOutputEvent(){}
}
void loop(){
background(0);
stroke(255);
// Draw the current sample information in the LiveOutput.data[] stream array.
for(int i = 0; i < LiveOutput.data.length-1; i++){
line(i,height/2 - LiveOutput.data[i]*30,i+1,height/2 - LiveOutput.data[i+1]*30);
}
}
// This event is automatically called when the system requests new data for the stream.
void liveOutputEvent(){
// Populate the LiveOutput.data[] data array with a sine-wave.
for(int i = 0; i < LiveOutput.data.length; i++){
float oneCycle = TWO_PI/streamSize;
int freq = (height - mouseY)/10;
float sinData = (freq*2) * oneCycle * i;
LiveOutput.data[i] = sin(sinData);
}
}
public void stop(){
Sonia.stop();
super.stop();
}
|
|
|
| Description |
|
Starts the LiveOutput engine. The LiveOutput.data[] array will be created with the length specified by the StreamSize parameter. Any sound data placed in this data[] array will be streamed into the computer's sound card. When new information for the stream is needed, the LiveOutputEvent(){} will be called. In some cases the data will be requested faster than we can deliver. For this case, we can store 'extra' sound information in a Stream-Buffer. Use the streamBuffer parameter to define the buffer's size. A higher Stream-Buffer ensures that the sound card will always have 'fresh' data to play (eliminate 'pop-crack' sounds) yet at the same time increases latency. Experiment with various data[]/Stream-Buffer parameters for optimal performance. If your work may be shown on slower machines, add a Stream-Buffer to ensure smooth playback. The next version of Sonia will include a dynamic buffer that changes automatically depending on the machine's performance. |
 |
|
|
| Syntax |
|
LiveOutput.start(streamSize)
LiveOutput.start(streamSize, bufferSize)
|
 |
|
|
| Parameters |
|
| streamSize |
|
int: 32, 64, 128, 256, 512, 1024 (default) ..
|
| bufferSize |
|
int: streamSize * n, where n is an int between 1 and infinity.
|
|
 |
|
|
| Returns |
|
None |
 |
|
|
| Usage |
|
Web & Application |
 |
|
|
| Related |
|
stop() startStream() stopStream() |
|
|