LMMS
Loading...
Searching...
No Matches
sfzero::Voice Class Reference

#include <SFZVoice.h>

Inheritance diagram for sfzero::Voice:
water::SynthesiserVoice

Public Member Functions

 Voice ()
virtual ~Voice ()
bool canPlaySound (water::SynthesiserSound *sound) override
void startNote (int midiNoteNumber, float velocity, water::SynthesiserSound *sound, int currentPitchWheelPosition) override
void stopNote (float velocity, bool allowTailOff) override
void stopNoteForGroup ()
void stopNoteQuick ()
void pitchWheelMoved (int newValue) override
void controllerMoved (int controllerNumber, int newValue) override
void renderNextBlock (water::AudioSampleBuffer &outputBuffer, int startSample, int numSamples) override
bool isPlayingNoteDown ()
bool isPlayingOneShot ()
int getGroup ()
water::int64 getOffBy ()
void setRegion (Region *nextRegion)
water::String infoString ()
Public Member Functions inherited from water::SynthesiserVoice
 SynthesiserVoice ()
virtual ~SynthesiserVoice ()
int getCurrentlyPlayingNote () const noexcept
SynthesiserSound::Ptr getCurrentlyPlayingSound () const noexcept
virtual bool isVoiceActive () const
virtual void aftertouchChanged (int newAftertouchValue)
virtual void channelPressureChanged (int newChannelPressureValue)
virtual void setCurrentPlaybackSampleRate (double newRate)
virtual bool isPlayingChannel (int midiChannel) const
double getSampleRate () const noexcept
bool isKeyDown () const noexcept
bool isSustainPedalDown () const noexcept
bool isSostenutoPedalDown () const noexcept
bool isPlayingButReleased () const noexcept
bool wasStartedBefore (const SynthesiserVoice &other) const noexcept

Private Member Functions

void calcPitchRatio ()
void killNote ()
double fractionalMidiNoteInHz (double note, double freqOfA=440.0)

Private Attributes

Regionregion_
int curMidiNote_
int curPitchWheel_
double pitchRatio_
float noteGainLeft_
float noteGainRight_
double sourceSamplePosition_
EG ampeg_
water::int64 sampleEnd_
water::int64 loopStart_
water::int64 loopEnd_
int numLoops_
int curVelocity_

Additional Inherited Members

Protected Member Functions inherited from water::SynthesiserVoice
void clearCurrentNote ()

Constructor & Destructor Documentation

◆ Voice()

sfzero::Voice::Voice ( )

◆ ~Voice()

sfzero::Voice::~Voice ( )
virtual

Member Function Documentation

◆ calcPitchRatio()

void sfzero::Voice::calcPitchRatio ( )
private

◆ canPlaySound()

bool sfzero::Voice::canPlaySound ( water::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 water::SynthesiserVoice.

◆ controllerMoved()

void sfzero::Voice::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 water::SynthesiserVoice.

◆ fractionalMidiNoteInHz()

double sfzero::Voice::fractionalMidiNoteInHz ( double note,
double freqOfA = 440.0 )
private

◆ getGroup()

int sfzero::Voice::getGroup ( )

◆ getOffBy()

water::int64 sfzero::Voice::getOffBy ( )

◆ infoString()

water::String sfzero::Voice::infoString ( )

◆ isPlayingNoteDown()

bool sfzero::Voice::isPlayingNoteDown ( )

◆ isPlayingOneShot()

bool sfzero::Voice::isPlayingOneShot ( )

◆ killNote()

void sfzero::Voice::killNote ( )
private

◆ pitchWheelMoved()

void sfzero::Voice::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 water::SynthesiserVoice.

◆ renderNextBlock()

void sfzero::Voice::renderNextBlock ( water::AudioSampleBuffer & 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 water::SynthesiserVoice.

◆ setRegion()

void sfzero::Voice::setRegion ( Region * nextRegion)

◆ startNote()

void sfzero::Voice::startNote ( int midiNoteNumber,
float velocity,
water::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 water::SynthesiserVoice.

◆ stopNote()

void sfzero::Voice::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 water::SynthesiserVoice.

◆ stopNoteForGroup()

void sfzero::Voice::stopNoteForGroup ( )

◆ stopNoteQuick()

void sfzero::Voice::stopNoteQuick ( )

Member Data Documentation

◆ ampeg_

EG sfzero::Voice::ampeg_
private

◆ curMidiNote_

int sfzero::Voice::curMidiNote_
private

◆ curPitchWheel_

int sfzero::Voice::curPitchWheel_
private

◆ curVelocity_

int sfzero::Voice::curVelocity_
private

◆ loopEnd_

water::int64 sfzero::Voice::loopEnd_
private

◆ loopStart_

water::int64 sfzero::Voice::loopStart_
private

◆ noteGainLeft_

float sfzero::Voice::noteGainLeft_
private

◆ noteGainRight_

float sfzero::Voice::noteGainRight_
private

◆ numLoops_

int sfzero::Voice::numLoops_
private

◆ pitchRatio_

double sfzero::Voice::pitchRatio_
private

◆ region_

Region* sfzero::Voice::region_
private

◆ sampleEnd_

water::int64 sfzero::Voice::sampleEnd_
private

◆ sourceSamplePosition_

double sfzero::Voice::sourceSamplePosition_
private

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