Browse Source

Added some setter methods to SynthesiserVoice

tags/2021-05-28
jules 8 years ago
parent
commit
baa5907668
2 changed files with 20 additions and 14 deletions
  1. +8
    -8
      modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp
  2. +12
    -6
      modules/juce_audio_basics/synthesisers/juce_Synthesiser.h

+ 8
- 8
modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp View File

@@ -305,8 +305,8 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice,
voice->noteOnTime = ++lastNoteOnCounter; voice->noteOnTime = ++lastNoteOnCounter;
voice->currentlyPlayingSound = sound; voice->currentlyPlayingSound = sound;
voice->setKeyDown (true); voice->setKeyDown (true);
voice->sostenutoPedalDown = false;
voice->sustainPedalDown = sustainPedalsDown[midiChannel];
voice->setSostenutoPedalDown (false);
voice->setSustainPedalDown (sustainPedalsDown[midiChannel]);
voice->startNote (midiNoteNumber, velocity, sound, voice->startNote (midiNoteNumber, velocity, sound,
lastPitchWheelValues [midiChannel - 1]); lastPitchWheelValues [midiChannel - 1]);
@@ -340,11 +340,11 @@ void Synthesiser::noteOff (const int midiChannel,
if (sound->appliesToNote (midiNoteNumber) if (sound->appliesToNote (midiNoteNumber)
&& sound->appliesToChannel (midiChannel)) && sound->appliesToChannel (midiChannel))
{ {
jassert (! voice->keyIsDown || voice->sustainPedalDown == sustainPedalsDown [midiChannel]);
jassert (! voice->keyIsDown || voice->isSustainPedalDown() == sustainPedalsDown [midiChannel]);
voice->setKeyDown (false); voice->setKeyDown (false);
if (! (voice->sustainPedalDown || voice->sostenutoPedalDown))
if (! (voice->isSustainPedalDown() || voice->isSostenutoPedalDown()))
stopVoice (voice, velocity, allowTailOff); stopVoice (voice, velocity, allowTailOff);
} }
} }
@@ -421,7 +421,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown)
for (auto* voice : voices) for (auto* voice : voices)
if (voice->isPlayingChannel (midiChannel) && voice->isKeyDown()) if (voice->isPlayingChannel (midiChannel) && voice->isKeyDown())
voice->sustainPedalDown = true;
voice->setSustainPedalDown (true);
} }
else else
{ {
@@ -429,7 +429,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown)
{ {
if (voice->isPlayingChannel (midiChannel)) if (voice->isPlayingChannel (midiChannel))
{ {
voice->sustainPedalDown = false;
voice->setSustainPedalDown (false);
if (! (voice->isKeyDown() || voice->isSostenutoPedalDown())) if (! (voice->isKeyDown() || voice->isSostenutoPedalDown()))
stopVoice (voice, 1.0f, true); stopVoice (voice, 1.0f, true);
@@ -450,8 +450,8 @@ void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown)
if (voice->isPlayingChannel (midiChannel)) if (voice->isPlayingChannel (midiChannel))
{ {
if (isDown) if (isDown)
voice->sostenutoPedalDown = true;
else if (voice->sostenutoPedalDown)
voice->setSostenutoPedalDown (true);
else if (voice->isSostenutoPedalDown())
stopVoice (voice, 1.0f, true); stopVoice (voice, 1.0f, true);
} }
} }


+ 12
- 6
modules/juce_audio_basics/synthesisers/juce_Synthesiser.h View File

@@ -224,9 +224,15 @@ public:
/** Returns true if the sustain pedal is currently active for this voice. */ /** Returns true if the sustain pedal is currently active for this voice. */
bool isSustainPedalDown() const noexcept { return sustainPedalDown; } 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. */ /** Returns true if the sostenuto pedal is currently active for this voice. */
bool isSostenutoPedalDown() const noexcept { return sostenutoPedalDown; } 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 **/ /** Returns true if a voice is sounding in its release phase **/
bool isPlayingButReleased() const noexcept bool isPlayingButReleased() const noexcept
{ {
@@ -514,15 +520,15 @@ public:
with timestamps outside the specified region will be ignored. with timestamps outside the specified region will be ignored.
*/ */
inline void renderNextBlock (AudioBuffer<float>& outputAudio, inline void renderNextBlock (AudioBuffer<float>& outputAudio,
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
{ processNextBlock (outputAudio, inputMidi, startSample, numSamples); } { processNextBlock (outputAudio, inputMidi, startSample, numSamples); }
inline void renderNextBlock (AudioBuffer<double>& outputAudio, inline void renderNextBlock (AudioBuffer<double>& outputAudio,
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
{ processNextBlock (outputAudio, inputMidi, startSample, numSamples); } { processNextBlock (outputAudio, inputMidi, startSample, numSamples); }
/** Returns the current target sample rate at which rendering is being done. /** Returns the current target sample rate at which rendering is being done.


Loading…
Cancel
Save