Back
Name  

Sample

   
Examples  
// Create a new Sample object and load the audio file 'mySample.aiff' into it. 
// 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.play(); // play the sample once. 
} 
 
// safely stop the Sonia engine upon shutdown. 
public void stop(){ 
  Sonia.stop(); 
  super.stop(); 
} 

Description   Creates a new Sample Object. This Object can have an external .wav or .aif file loaded into it (Mono/Stereo, 16 Bit only). Alternatively, an empty Object can be made with a specified number of frames and/or sample rate.
   
Methods  
connectLiveInput()
  Routs the Sample's signal into the LiveInput engine for frequency analysis

getCurrentFrame()
  Returns the current frame of the Sample as it is playing.

getNumFrames()
  Returns the number of total available frames in the Sample.

getPan()
  Returns the Sample's pan.

getRate()
  Returns the Sampling-Rate of the Sample.

getSpeed()
  Returns the playback speed of the Sample.

getVolume()
  Returns the Sample's volume.

isPlaying()
  Returns TRUE if the Sample is playing and FALSE if it is not. .

play()
  Plays the Sample one time.

read()
  Reads the Sample's data (frames) into an array

readChannel()
  Reads one channel of a Stereo Sample's data (frames) into an array

repeat()
  Loops the Sample.

repeatNum()
  Loops the Sample a specified number of times.

setPan()
  Set the Sample's pan.

setRate()
  Sets the Sample's rate.

setSpeed()
  Sets the playback speed of the Sample

setVolume()
  Set the Sample's volume.

stop()
  Stops the Sample.

write()
  Writes data from an array into a Sample object.

writeChannel()
  Writes data from an array into the specified channel of a Sample object.

   
   
Constructors  
Sample mySample
Sample(soundFile)
Sample(sampleFrames)
Sample(sampleFrames, sampleRate)
   
Parameters  
soundFile   Any .wav or .aif sound file (Mono/Stereo, 16 Bit only).

sampleRate   int: From 0 to 88200 kHz.

sampleFrames   int: Specifies the number of empty Sample-frames for this Sample object.

   
Returns   None
   
Usage   Web & Application