Back
Class   Sample
   
Name  

setRate()

   
Examples  
// Play a sample at a rate of 22050 per second. 
// If the original audio-file rate is 44100, the sample will play at half the speed in lower pitch. 
// Notes: - Make sure to include the specified audio file in your project's 'data' folder. 
 
 
Sample mySample; 
 
void setup() { 
  size(100,100); 
  Sonia.start(this); 
  mySample = new Sample("sine.aiff"); 
  mySample.setRate(22050); 
  mySample.repeat(); 
} 
 
public void stop(){ 
  Sonia.stop(); 
  super.stop(); 
} 

Description   Higher sample rates than that of the original will increase playback speed and pitch. Lower rates will produce lower pitch and slower playback. The top sample-rate is 88200, so a sample with an original rate of 44100 can play up to twice as fast, and a sample with an original rate of 22050 can play up to four times as fast.
   
Syntax  
mySample.setRate(rate)
mySample.setRate(rate, channel)
   
Parameters  
rate   float: between 0 and 88200

channel   0 or Sonia.LEFT for Left channel, 1 or Sonia.RIGHT for Right channel

   
Returns   None
   
Usage   Web & Application
   
Related   getRate()
getSpeed()
setSpeed()