Tree-Axis ``` Processing  


Back  
Class   AudioInput
   
Name  

sampleRate()

   
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 the sample rate - often only 44100 will work
  // so this may flag an error
   myInput.sampleRate(22050);

  // 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   Changes the sample rate of an AudioInput. IMPORTANT: Input sample rates other than 44.1kHz are rarely supported on Macintosh systems. Changing the sample rate is not recommended
   
Syntax  
input.sampleRate(rate)
   
Parameters  
input   any instance of AudioInput

rate   float: the new sample rate for the AudioInput

   
Returns   nothing
   
Usage   Web & Application
   
 
 






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


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