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

OpenShot Audio Library | OpenShotAudio 0.3.1

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
juce::MPESynthesiserVoice Class Referenceabstract

`#include <juce_MPESynthesiserVoice.h>`

## Public Member Functions
| MPESynthesiserVoice ()
virtual | ~MPESynthesiserVoice ()
MPENote | getCurrentlyPlayingNote () const noexcept
bool | isCurrentlyPlayingNote (MPENote note) const noexcept
virtual bool | isActive () const
bool | isPlayingButReleased () const noexcept
virtual void | noteStarted ()=0
virtual void | noteStopped (bool allowTailOff)=0
virtual void | notePressureChanged ()=0
virtual void | notePitchbendChanged ()=0
virtual void | noteTimbreChanged ()=0
virtual void | noteKeyStateChanged ()=0
virtual void | renderNextBlock (AudioBuffer< float > &outputBuffer, int startSample, int numSamples)=0
virtual void | renderNextBlock (AudioBuffer< double > &, int, int)
virtual void | setCurrentSampleRate (double newRate)
double | getSampleRate () const noexcept

## Public Attributes
uint32 | noteOnTime = 0

## Protected Member Functions
void | clearCurrentNote () noexcept

## Protected Attributes
double | currentSampleRate = 0.0
MPENote | currentlyPlayingNote

## Detailed Description

Represents an MPE voice that an MPESynthesiser can use to play a sound.

A voice plays a single sound at a time, and a synthesiser holds an array of voices so that it can play polyphonically.

See also
  MPESynthesiser, MPENote

Definition at line 37 of file juce_MPESynthesiserVoice.h.

## Constructor & Destructor Documentation

## ◆ MPESynthesiserVoice()

juce::MPESynthesiserVoice::MPESynthesiserVoice | ( |  | ) |

Constructor.

Definition at line 26 of file juce_MPESynthesiserVoice.cpp.

## ◆ ~MPESynthesiserVoice()

juce::MPESynthesiserVoice::~MPESynthesiserVoice | ( |  | ) |
| virtual

Destructor.

Definition at line 30 of file juce_MPESynthesiserVoice.cpp.

## Member Function Documentation

## ◆ clearCurrentNote()

void juce::MPESynthesiserVoice::clearCurrentNote | ( |  | ) |
| protectednoexcept

Resets the state of this voice after a sound has finished playing.

The subclass must call this when it finishes playing a note and becomes available to play new ones.

It must either call it in the stopNote() method, or if the voice is tailing off, then it should call it later during the renderNextBlock method, as soon as it finishes its tail-off.

It can also be called at any time during the render callback if the sound happens to have finished, e.g. if it's playing a sample and the sample finishes.

Definition at line 45 of file juce_MPESynthesiserVoice.cpp.

## ◆ getCurrentlyPlayingNote()

MPENote juce::MPESynthesiserVoice::getCurrentlyPlayingNote | ( |  | ) | const
| inlinenoexcept

Returns the MPENote that this voice is currently playing. Returns an invalid MPENote if no note is playing (you can check this using MPENote::isValid() or MPEVoice::isActive()).

Definition at line 51 of file juce_MPESynthesiserVoice.h.

Referenced by juce::MPESynthesiser::findVoiceToSteal().

## ◆ getSampleRate()

double juce::MPESynthesiserVoice::getSampleRate | ( |  | ) | const
| inlinenoexcept

Returns the current target sample rate at which rendering is being done. Subclasses may need to know this so that they can pitch things correctly.

Definition at line 157 of file juce_MPESynthesiserVoice.h.

## ◆ isActive()

virtual bool juce::MPESynthesiserVoice::isActive | ( |  | ) | const
| inlinevirtual

Returns true if this voice is currently busy playing a sound. By default this just checks whether getCurrentlyPlayingNote() returns a valid MPE note, but can be overridden for more advanced checking.

Definition at line 62 of file juce_MPESynthesiserVoice.h.

Referenced by isPlayingButReleased().

## ◆ isCurrentlyPlayingNote()

bool juce::MPESynthesiserVoice::isCurrentlyPlayingNote | ( | MPENote | note | ) | const
| noexcept

Returns true if the voice is currently playing the given MPENote (as identified by the note's initial note number and MIDI channel).

Definition at line 35 of file juce_MPESynthesiserVoice.cpp.

## ◆ isPlayingButReleased()

bool juce::MPESynthesiserVoice::isPlayingButReleased | ( |  | ) | const
| noexcept

Returns true if a voice is sounding in its release phase.

Definition at line 40 of file juce_MPESynthesiserVoice.cpp.

Referenced by juce::MPESynthesiser::findVoiceToSteal().

## ◆ noteKeyStateChanged()

virtual void juce::MPESynthesiserVoice::noteKeyStateChanged | ( |  | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that its currently playing note has changed its key state. This typically happens when a sustain or sostenuto pedal is pressed or released (on an MPE channel relevant for this note), or if the note key is lifted while the sustained or sostenuto pedal is still held down. This will be called during the rendering callback, so must be fast and thread-safe.

## ◆ notePitchbendChanged()

virtual void juce::MPESynthesiserVoice::notePitchbendChanged | ( |  | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that its currently playing note has changed its pitchbend value. This will be called during the rendering callback, so must be fast and thread-safe.

Note: You can call currentlyPlayingNote.getFrequencyInHertz() to find out the effective frequency of the note, as a sum of the initial note number, the per-note pitchbend and the master pitchbend.

## ◆ notePressureChanged()

virtual void juce::MPESynthesiserVoice::notePressureChanged | ( |  | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that its currently playing note has changed its pressure value. This will be called during the rendering callback, so must be fast and thread-safe.

## ◆ noteStarted()

virtual void juce::MPESynthesiserVoice::noteStarted | ( |  | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that a new note has started on it. This will be called during the rendering callback, so must be fast and thread-safe.

Referenced by juce::MPESynthesiser::startVoice().

## ◆ noteStopped()

virtual void juce::MPESynthesiserVoice::noteStopped | ( | bool | allowTailOff | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that its currently playing note has stopped. 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().

Referenced by juce::MPESynthesiser::stopVoice().

## ◆ noteTimbreChanged()

virtual void juce::MPESynthesiserVoice::noteTimbreChanged | ( |  | ) |
| pure virtual

Called by the MPESynthesiser to let the voice know that its currently playing note has changed its timbre value. This will be called during the rendering callback, so must be fast and thread-safe.

## ◆ renderNextBlock() [1/2]

virtual void juce::MPESynthesiserVoice::renderNextBlock | ( | AudioBuffer< double > & | ,
|  | int | ,
|  | int |
| ) |  |
| inlinevirtual

Renders the next block of 64-bit data for this voice.

Support for 64-bit audio is optional. You can choose to not override this method if you don't need it (the default implementation simply does nothing).

Definition at line 140 of file juce_MPESynthesiserVoice.h.

## ◆ renderNextBlock() [2/2]

virtual void juce::MPESynthesiserVoice::renderNextBlock | ( | AudioBuffer< float > & | outputBuffer,
|  | int | startSample,
|  | int | numSamples
| ) |  |
| pure 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.

## ◆ setCurrentSampleRate()

virtual void juce::MPESynthesiserVoice::setCurrentSampleRate | ( | double | newRate | ) |
| inlinevirtual

Changes the voice's reference sample rate.

The rate is set so that subclasses know the output rate and can set their pitch accordingly.

This method is called by the synth, and subclasses can access the current rate with the currentSampleRate member.

Definition at line 152 of file juce_MPESynthesiserVoice.h.

Referenced by juce::MPESynthesiser::addVoice().

## Member Data Documentation

## ◆ currentlyPlayingNote

MPENote juce::MPESynthesiserVoice::currentlyPlayingNote
| protected

Definition at line 182 of file juce_MPESynthesiserVoice.h.

## ◆ currentSampleRate

double juce::MPESynthesiserVoice::currentSampleRate = 0.0
| protected

Definition at line 181 of file juce_MPESynthesiserVoice.h.

## ◆ noteOnTime

uint32 juce::MPESynthesiserVoice::noteOnTime = 0

This will be set to an incrementing counter value in MPESynthesiser::startVoice() and can be used to determine the order in which voices started.

Definition at line 162 of file juce_MPESynthesiserVoice.h.

Referenced by juce::MPESynthesiser::findVoiceToSteal(), and juce::MPESynthesiser::startVoice().

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

- juce_MPESynthesiserVoice.h
- juce_MPESynthesiserVoice.cpp