From baa59076685697431b32877a45a080f656691060 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Sep 2017 10:03:45 +0100 Subject: [PATCH] Added some setter methods to SynthesiserVoice --- .../synthesisers/juce_Synthesiser.cpp | 16 ++++++++-------- .../synthesisers/juce_Synthesiser.h | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 4df64603e0..fa12e84033 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -305,8 +305,8 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice, voice->noteOnTime = ++lastNoteOnCounter; voice->currentlyPlayingSound = sound; voice->setKeyDown (true); - voice->sostenutoPedalDown = false; - voice->sustainPedalDown = sustainPedalsDown[midiChannel]; + voice->setSostenutoPedalDown (false); + voice->setSustainPedalDown (sustainPedalsDown[midiChannel]); voice->startNote (midiNoteNumber, velocity, sound, lastPitchWheelValues [midiChannel - 1]); @@ -340,11 +340,11 @@ void Synthesiser::noteOff (const int midiChannel, if (sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) { - jassert (! voice->keyIsDown || voice->sustainPedalDown == sustainPedalsDown [midiChannel]); + jassert (! voice->keyIsDown || voice->isSustainPedalDown() == sustainPedalsDown [midiChannel]); voice->setKeyDown (false); - if (! (voice->sustainPedalDown || voice->sostenutoPedalDown)) + if (! (voice->isSustainPedalDown() || voice->isSostenutoPedalDown())) stopVoice (voice, velocity, allowTailOff); } } @@ -421,7 +421,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) for (auto* voice : voices) if (voice->isPlayingChannel (midiChannel) && voice->isKeyDown()) - voice->sustainPedalDown = true; + voice->setSustainPedalDown (true); } else { @@ -429,7 +429,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) { if (voice->isPlayingChannel (midiChannel)) { - voice->sustainPedalDown = false; + voice->setSustainPedalDown (false); if (! (voice->isKeyDown() || voice->isSostenutoPedalDown())) stopVoice (voice, 1.0f, true); @@ -450,8 +450,8 @@ void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown) if (voice->isPlayingChannel (midiChannel)) { if (isDown) - voice->sostenutoPedalDown = true; - else if (voice->sostenutoPedalDown) + voice->setSostenutoPedalDown (true); + else if (voice->isSostenutoPedalDown()) stopVoice (voice, 1.0f, true); } } diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h index cad5ac393f..1089960628 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.h @@ -224,9 +224,15 @@ public: /** Returns true if the sustain pedal is currently active for this voice. */ bool isSustainPedalDown() const noexcept { return sustainPedalDown; } + /** Modifies the sustain pedal flag. */ + void setSustainPedalDown (bool isNowDown) noexcept { sustainPedalDown = isNowDown; } + /** Returns true if the sostenuto pedal is currently active for this voice. */ bool isSostenutoPedalDown() const noexcept { return sostenutoPedalDown; } + /** Modifies the sostenuto pedal flag. */ + void setSostenutoPedalDown (bool isNowDown) noexcept { sostenutoPedalDown = isNowDown; } + /** Returns true if a voice is sounding in its release phase **/ bool isPlayingButReleased() const noexcept { @@ -514,15 +520,15 @@ public: with timestamps outside the specified region will be ignored. */ inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } inline void renderNextBlock (AudioBuffer& outputAudio, - const MidiBuffer& inputMidi, - int startSample, - int numSamples) + const MidiBuffer& inputMidi, + int startSample, + int numSamples) { processNextBlock (outputAudio, inputMidi, startSample, numSamples); } /** Returns the current target sample rate at which rendering is being done.