JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions
SamplerVoice Class Reference

A subclass of SynthesiserVoice that can play a SamplerSound. More...

Inherits SynthesiserVoice.

List of all members.

Public Member Functions

 SamplerVoice ()
 Creates a SamplerVoice.
 ~SamplerVoice ()
 Destructor.
bool canPlaySound (SynthesiserSound *sound)
 Must return true if this voice object is capable of playing the given sound.
void startNote (const int midiNoteNumber, const float velocity, SynthesiserSound *sound, const int currentPitchWheelPosition)
 Called to start a new note.
void stopNote (const bool allowTailOff)
 Called to stop a note.
void pitchWheelMoved (const int newValue)
 Called to let the voice know that the pitch wheel has been moved.
void controllerMoved (const int controllerNumber, const int newValue)
 Called to let the voice know that a midi controller has been moved.
void renderNextBlock (AudioSampleBuffer &outputBuffer, int startSample, int numSamples)
 Renders the next block of data for this voice.

Detailed Description

A subclass of SynthesiserVoice that can play a SamplerSound.

To use it, create a Synthesiser, add some SamplerVoice objects to it, then give it some SampledSound objects to play.

See also:
SamplerSound, Synthesiser, SynthesiserVoice

Constructor & Destructor Documentation

Creates a SamplerVoice.

Destructor.


Member Function Documentation

bool SamplerVoice::canPlaySound ( SynthesiserSound sound) [virtual]

Must return true if this voice object is capable of playing the given sound.

If there are different classes of sound, and different classes of voice, a voice can choose which ones it wants to take on.

A typical implementation of this method may just return true if there's only one type of voice and sound, or it might check the type of the sound object passed-in and see if it's one that it understands.

Implements SynthesiserVoice.

void SamplerVoice::startNote ( const int  midiNoteNumber,
const float  velocity,
SynthesiserSound sound,
const int  currentPitchWheelPosition 
) [virtual]

Called to start a new note.

This will be called during the rendering callback, so must be fast and thread-safe.

Implements SynthesiserVoice.

void SamplerVoice::stopNote ( const bool  allowTailOff) [virtual]

Called to stop a note.

This will be called during the rendering callback, so must be fast and thread-safe.

If allowTailOff is false or the voice doesn't want to tail-off, then it must stop all sound immediately, and must call clearCurrentNote() to reset the state of this voice and allow the synth to reassign it another sound.

If allowTailOff is true and the voice decides to do a tail-off, then it's allowed to begin fading out its sound, and it can stop playing until it's finished. As soon as it finishes playing (during the rendering callback), it must make sure that it calls clearCurrentNote().

Implements SynthesiserVoice.

void SamplerVoice::pitchWheelMoved ( const int  newValue) [virtual]

Called to let the voice know that the pitch wheel has been moved.

This will be called during the rendering callback, so must be fast and thread-safe.

Implements SynthesiserVoice.

void SamplerVoice::controllerMoved ( const int  controllerNumber,
const int  newValue 
) [virtual]

Called to let the voice know that a midi controller has been moved.

This will be called during the rendering callback, so must be fast and thread-safe.

Implements SynthesiserVoice.

void SamplerVoice::renderNextBlock ( AudioSampleBuffer outputBuffer,
int  startSample,
int  numSamples 
) [virtual]

Renders the next block of data for this voice.

The output audio data must be added to the current contents of the buffer provided. Only the region of the buffer between startSample and (startSample + numSamples) should be altered by this method.

If the voice is currently silent, it should just return without doing anything.

If the sound that the voice is playing finishes during the course of this rendered block, it must call clearCurrentNote(), to tell the synthesiser that it has finished.

The size of the blocks that are rendered can change each time it is called, and may involve rendering as little as 1 sample at a time. In between rendering callbacks, the voice's methods will be called to tell it about note and controller events.

Implements SynthesiserVoice.


The documentation for this class was generated from the following file: