Tree-Axis ``` Processing  


Back  
Class   AudioInput
   
Name  

bufferSize()

   
Examples  
// Example by Krister Olsson

import krister.Ess.*;

AudioStream myStream;
AudioInput myInput;

boolean inputReady=false;
float[] streamBuffer;

void setup() {
  size(256,200);

  // start up Ess
  Ess.start(this);

  // create a new AudioInput
  myInput=new AudioInput(); 

  // set our buffer size to 4k
  myInput.bufferSize(4*1024);
  
  // create a new AudioStream
  myStream=new AudioStream(myInput.size);
  streamBuffer=new float[myInput.size];

  // start
  myStream.start();
  myInput.start();
}

void draw() {
}

void audioStreamWrite(AudioStream theStream) {
  // block until we have some input
  while (!inputReady); 
  
  System.arraycopy(streamBuffer,0,myStream.buffer,0,streamBuffer.length);
   
  inputReady=false;
}

void audioInputData(AudioInput theInput) {
  System.arraycopy(myInput.buffer,0,streamBuffer,0,myInput.size);
  
  inputReady=true;
}

// we are done, clean up Ess

public void stop() {
  Ess.stop();
  super.stop();
}


Description   Sets the size of an AudioInput's input buffer. The size of the buffer determines the number of samples recorded by the sound recording engine at one time. Larger buffers record more smoothly, but there is greater delay before they are returned. Smaller buffers are more responsive, but prone to static
   
Syntax  
input.bufferSize(size)
   
Parameters  
input   any instance of AudioInput

size   int: the new size of the sample buffer in sample frames

   
Returns   nothing
   
Usage   Web & Application
   
 
 






   
 
Updated: Tue May 31 04:52:39 PDT 2006


 
  Questions, comments, corrections: e-mail Krister Olsson.