1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added some setter methods to SynthesiserVoice

This commit is contained in:
jules 2017-09-05 10:03:45 +01:00
parent f65500ec7b
commit baa5907668
2 changed files with 20 additions and 14 deletions

View file

@ -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);
}
}

View file

@ -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<float>& outputAudio,
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
const MidiBuffer& inputMidi,
int startSample,
int numSamples)
{ processNextBlock (outputAudio, inputMidi, startSample, numSamples); }
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); }
/** Returns the current target sample rate at which rendering is being done.