Tree-Axis ``` Processing  


Back  
Class   AudioChannel
   
Name  

sampleRate()

   
Examples  
// Example by Krister Olsson

import krister.Ess.*;

AudioChannel myChannel;

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

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

  // load "cell.aif" into a new AudioChannel
  myChannel=new AudioChannel("cell.aif");

  // change the sample rate (changing pitch and duration)
  myChannel.sampleRate(11025,false);

  // change the sample rate (maintaining pitch and duration)
  myChannel.sampleRate(44100,true);

  // play
  myChannel.play();
}

void draw() {
}

// we are done, clean up Ess

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


Description   Changes the sample rate of an AudioChannel, either forcing a new rate and leaving the sample data untouched, or resampling the data to maintain pitch and duration at the new rate. Forcing a higher sample rate on an AudioChannel will make the sound shorter in duration and its pitch higher, while forcing a lower sample rate will make the sound longer in duration and its pitch lower. In both cases the actual size of the AudioChannel is not changed; this must be done manually with adjustBuffer()
   
Syntax  
channel.sampleRate(rate)
channel.sampleRate(rate, resample)
   
Parameters  
channel   any instance of AudioChannel

rate   float: the new sample rate for the AudioChannel

resample   boolean: whether or not to resample the AudioChannel's sample data to maintain pitch and duration. The default is false

   
Returns   nothing
   
Usage   Web & Application
   
 
 






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


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