Class   LiveOutput


// Start the LiveOutput engine with a streamSize of 512 frames, and a streamBuffer twice the size. 
// Use the LiveOutputEvent(){} to update the[] 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[] array. 
void setup(){ 
  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(){ 
  // Draw the current sample information in the[] stream array. 
  for(int i = 0; i <; i++){ 
    line(i,height/2 -[i]*30,i+1,height/2 -[i+1]*30); 
// This event is automatically called when the system requests new data for the stream. 
void liveOutputEvent(){ 
// Populate the[] data array with a sine-wave. 
  for(int i = 0; i <; i++){ 
    float oneCycle = TWO_PI/streamSize; 
    int freq = (height - mouseY)/10; 
    float sinData = (freq*2) * oneCycle * i;[i] = sin(sinData); 
public void stop(){ 

Description   Starts the LiveOutput engine. The[] 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.
LiveOutput.start(streamSize, bufferSize)
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()