OpenShot Audio Library | OpenShotAudio: juce::SamplerVoice Class Reference

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::SamplerVoice Class Reference

`#include <juce_Sampler.h>`

Inheritance diagram for juce::SamplerVoice:

## Public Member Functions
| SamplerVoice ()
| ~SamplerVoice () override
bool | canPlaySound (SynthesiserSound *) override
void | startNote (int midiNoteNumber, float velocity, SynthesiserSound *, int pitchWheel) override
void | stopNote (float velocity, bool allowTailOff) override
void | pitchWheelMoved (int newValue) override
void | controllerMoved (int controllerNumber, int newValue) override
void | renderNextBlock (AudioBuffer< float > &, int startSample, int numSamples) override
virtual void | renderNextBlock (AudioBuffer< float > &outputBuffer, int startSample, int numSamples)=0
virtual void | renderNextBlock (AudioBuffer< double > &outputBuffer, int startSample, int numSamples)
Public Member Functions inherited from juce::SynthesiserVoice
| SynthesiserVoice ()
virtual | ~SynthesiserVoice ()
int | getCurrentlyPlayingNote () const noexcept
SynthesiserSound::Ptr | getCurrentlyPlayingSound () const noexcept
virtual bool | canPlaySound (SynthesiserSound *)=0
virtual void | startNote (int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition)=0
virtual void | stopNote (float velocity, bool allowTailOff)=0
virtual bool | isVoiceActive () const
virtual void | pitchWheelMoved (int newPitchWheelValue)=0
virtual void | controllerMoved (int controllerNumber, int newControllerValue)=0
virtual void | aftertouchChanged (int newAftertouchValue)
virtual void | channelPressureChanged (int newChannelPressureValue)
virtual void | renderNextBlock (AudioBuffer< float > &outputBuffer, int startSample, int numSamples)=0
virtual void | renderNextBlock (AudioBuffer< double > &outputBuffer, int startSample, int numSamples)
virtual void | setCurrentPlaybackSampleRate (double newRate)
virtual bool | isPlayingChannel (int midiChannel) const
double | getSampleRate () const noexcept
bool | isKeyDown () const noexcept
void | setKeyDown (bool isNowDown) noexcept
bool | isSustainPedalDown () const noexcept
void | setSustainPedalDown (bool isNowDown) noexcept
bool | isSostenutoPedalDown () const noexcept
void | setSostenutoPedalDown (bool isNowDown) noexcept
bool | isPlayingButReleased () const noexcept
bool | wasStartedBefore (const SynthesiserVoice &other) const noexcept

## Additional Inherited Members
Protected Member Functions inherited from juce::SynthesiserVoice
void | clearCurrentNote ()

## 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

Definition at line 121 of file juce_Sampler.h.

## Constructor & Destructor Documentation

## ◆ SamplerVoice()

juce::SamplerVoice::SamplerVoice | ( |  | ) |

Creates a SamplerVoice.

Definition at line 71 of file juce_Sampler.cpp.

## ◆ ~SamplerVoice()

juce::SamplerVoice::~SamplerVoice | ( |  | ) |
| override

Destructor.

Definition at line 72 of file juce_Sampler.cpp.

## Member Function Documentation

## ◆ canPlaySound()

bool juce::SamplerVoice::canPlaySound | ( | SynthesiserSound * |  | ) |
| overridevirtual

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 juce::SynthesiserVoice.

Definition at line 74 of file juce_Sampler.cpp.

## ◆ controllerMoved()

void juce::SamplerVoice::controllerMoved | ( | int | controllerNumber,
|  | int | newControllerValue
| ) |  |
| overridevirtual

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 juce::SynthesiserVoice.

Definition at line 115 of file juce_Sampler.cpp.

## ◆ pitchWheelMoved()

void juce::SamplerVoice::pitchWheelMoved | ( | int | newPitchWheelValue | ) |
| overridevirtual

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 juce::SynthesiserVoice.

Definition at line 114 of file juce_Sampler.cpp.

## ◆ renderNextBlock() [1/3]

void juce::SynthesiserVoice::renderNextBlock | ( | AudioBuffer< double > & | outputBuffer,
|  | int | startSample,
|  | int | numSamples
| ) |  |
| virtual

A double-precision version of renderNextBlock()

Reimplemented from juce::SynthesiserVoice.

Definition at line 191 of file juce_Synthesiser.cpp.

## ◆ renderNextBlock() [2/3]

void juce::SamplerVoice::renderNextBlock | ( | AudioBuffer< float > & | outputBuffer,
|  | int | startSample,
|  | int | numSamples
| ) |  |
| overridevirtual

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 juce::SynthesiserVoice.

Definition at line 118 of file juce_Sampler.cpp.

## ◆ renderNextBlock() [3/3]

virtual void juce::SynthesiserVoice::renderNextBlock | ( | AudioBuffer< float > & | 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 juce::SynthesiserVoice.

## ◆ startNote()

void juce::SamplerVoice::startNote | ( | int | midiNoteNumber,
|  | float | velocity,
|  | SynthesiserSound * | sound,
|  | int | currentPitchWheelPosition
| ) |  |
| overridevirtual

Called to start a new note. This will be called during the rendering callback, so must be fast and thread-safe.

Implements juce::SynthesiserVoice.

Definition at line 79 of file juce_Sampler.cpp.

## ◆ stopNote()

void juce::SamplerVoice::stopNote | ( | float | velocity,
|  | bool | allowTailOff
| ) |  |
| overridevirtual

Called to stop a note.

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

The velocity indicates how quickly the note was released - 0 is slowly, 1 is quickly.

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 juce::SynthesiserVoice.

Definition at line 101 of file juce_Sampler.cpp.

Referenced by renderNextBlock().

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

- juce_Sampler.h
- juce_Sampler.cpp