From 403b5c10bc35e35914d5517a5a784a3bfe5629fa Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 10 Dec 2013 09:43:41 +0000 Subject: [PATCH] Added methods to SynthesiserVoice for checking key-down status. --- .../synthesisers/juce_Synthesiser.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index eb443cfd8c..65729e5f52 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -116,7 +116,6 @@ public: virtual bool canPlaySound (SynthesiserSound*) = 0; /** Called to start a new note. - This will be called during the rendering callback, so must be fast and thread-safe. */ virtual void startNote (int midiNoteNumber, @@ -186,6 +185,14 @@ public: */ void setCurrentPlaybackSampleRate (double newRate); + /** Returns true if the key that triggered this voice is still held down. + Note that the voice may still be playing after the key was released (e.g because the + sostenuto pedal is down). + */ + bool isKeyDown() const noexcept { return keyIsDown; } + + /** Returns true if the sostenuto pedal is currently active for this voice. */ + bool isSostenutoPedalDown() const noexcept { return sostenutoPedalDown; } protected: //============================================================================== @@ -218,8 +225,7 @@ private: int currentlyPlayingNote; uint32 noteOnTime; SynthesiserSound::Ptr currentlyPlayingSound; - bool keyIsDown; // the voice may still be playing when the key is not down (i.e. sustain pedal) - bool sostenutoPedalDown; + bool keyIsDown, sostenutoPedalDown; JUCE_LEAK_DETECTOR (SynthesiserVoice) };