Browse Source

Added a method SynthesiserVoice::isVoiceActive()

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

+ 6
- 1
modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp View File

@@ -50,6 +50,11 @@ void SynthesiserVoice::setCurrentPlaybackSampleRate (const double newRate)
currentSampleRate = newRate;
}
bool SynthesiserVoice::isVoiceActive() const
{
return getCurrentlyPlayingNote() >= 0;
}
void SynthesiserVoice::clearCurrentNote()
{
currentlyPlayingNote = -1;
@@ -426,7 +431,7 @@ SynthesiserVoice* Synthesiser::findFreeVoice (SynthesiserSound* soundToPlay,
{
SynthesiserVoice* const voice = voices.getUnchecked (i);
if (voice->getCurrentlyPlayingNote() < 0 && voice->canPlaySound (soundToPlay))
if ((! voice->isVoiceActive()) && voice->canPlaySound (soundToPlay))
return voice;
}


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

@@ -140,6 +140,12 @@ public:
*/
virtual void stopNote (float velocity, bool allowTailOff) = 0;
/** Returns true if this voice is currently busy playing a sound.
By default this just checks the getCurrentlyPlayingNote() value, but can
be overridden for more advanced checking.
*/
virtual bool isVoiceActive() const;
/** Called to let the voice know that the pitch wheel has been moved.
This will be called during the rendering callback, so must be fast and thread-safe.
*/


Loading…
Cancel
Save