42 jassert (voice !=
nullptr);
44 voice->currentlyPlayingNote = noteToStart;
51 jassert (voice !=
nullptr);
53 voice->currentlyPlayingNote = noteToStop;
70 for (
auto* voice : voices)
72 if (voice->isCurrentlyPlayingNote (changedNote))
74 voice->currentlyPlayingNote = changedNote;
75 voice->notePressureChanged();
84 for (
auto* voice : voices)
86 if (voice->isCurrentlyPlayingNote (changedNote))
88 voice->currentlyPlayingNote = changedNote;
89 voice->notePitchbendChanged();
98 for (
auto* voice : voices)
100 if (voice->isCurrentlyPlayingNote (changedNote))
102 voice->currentlyPlayingNote = changedNote;
103 voice->noteTimbreChanged();
112 for (
auto* voice : voices)
114 if (voice->isCurrentlyPlayingNote (changedNote))
116 voice->currentlyPlayingNote = changedNote;
117 voice->noteKeyStateChanged();
126 for (
auto i = voices.size(); --i >= 0;)
128 auto* voice = voices.getUnchecked (i);
130 if (voice->isCurrentlyPlayingNote (finishedNote))
143 for (
auto i = voices.size(); --i >= 0;)
144 voices.getUnchecked (i)->setCurrentSampleRate (newRate);
161 for (
auto* voice : voices)
163 if (! voice->isActive())
167 if (stealIfNoneAvailable)
181 jassert (voices.size() > 0);
193 usableVoicesToStealArray.clear();
195 for (
auto* voice : voices)
197 jassert (voice->isActive());
199 usableVoicesToStealArray.add (voice);
208 std::sort (usableVoicesToStealArray.begin(), usableVoicesToStealArray.end(), Sorter());
210 if (! voice->isPlayingButReleased())
212 auto noteNumber = voice->getCurrentlyPlayingNote().initialNote;
214 if (low ==
nullptr || noteNumber < low->getCurrentlyPlayingNote().initialNote)
228 if (noteToStealVoiceFor.
isValid())
229 for (
auto* voice : usableVoicesToStealArray)
230 if (voice->getCurrentlyPlayingNote().initialNote == noteToStealVoiceFor.
initialNote)
234 for (
auto* voice : usableVoicesToStealArray)
239 for (
auto* voice : usableVoicesToStealArray)
240 if (voice != low && voice != top
246 for (
auto* voice : usableVoicesToStealArray)
247 if (voice != low && voice != top)
251 jassert (low !=
nullptr);
266 voices.add (newVoice);
271 usableVoicesToStealArray.ensureStorageAllocated (voices.size() + 1);
284 return voices [index];
290 voices.remove (index);
296 jassert (newNumVoices >= 0);
300 while (voices.size() > newNumVoices)
303 voices.removeObject (voice);
316 for (
auto* voice : voices)
321 voice->noteStopped (allowTailOff);
334 for (
auto* voice : voices)
336 if (voice->isActive())
337 voice->renderNextBlock (buffer, startSample, numSamples);
345 for (
auto* voice : voices)
347 if (voice->isActive())
348 voice->renderNextBlock (buffer, startSample, numSamples);
virtual void setCurrentSampleRate(double newRate)
MPENote getCurrentlyPlayingNote() const noexcept
virtual void noteStarted()=0
virtual void noteStopped(bool allowTailOff)=0
bool isPlayingButReleased() const noexcept
void removeVoice(int index)
void reduceNumVoices(int newNumVoices)
virtual MPESynthesiserVoice * findFreeVoice(MPENote noteToFindVoiceFor, bool stealIfNoneAvailable) const
void stopVoice(MPESynthesiserVoice *voice, MPENote noteToStop, bool allowTailOff)
void setCurrentPlaybackSampleRate(double newRate) override
void startVoice(MPESynthesiserVoice *voice, MPENote noteToStart)
void notePressureChanged(MPENote changedNote) override
void noteReleased(MPENote finishedNote) override
void addVoice(MPESynthesiserVoice *newVoice)
~MPESynthesiser() override
virtual MPESynthesiserVoice * findVoiceToSteal(MPENote noteToStealVoiceFor=MPENote()) const
void noteTimbreChanged(MPENote changedNote) override
void noteAdded(MPENote newNote) override
MPESynthesiserVoice * getVoice(int index) const
void noteKeyStateChanged(MPENote changedNote) override
virtual void turnOffAllVoices(bool allowTailOff)
virtual void handleProgramChange(int, int)
void renderNextSubBlock(AudioBuffer< float > &outputAudio, int startSample, int numSamples) override
void notePitchbendChanged(MPENote changedNote) override
void handleMidiEvent(const MidiMessage &) override
virtual void handleController(int, int, int)
static MPEValue from7BitInt(int value) noexcept
int getChannel() const noexcept
bool isProgramChange() const noexcept
bool isController() const noexcept
int getControllerNumber() const noexcept
int getProgramChangeNumber() const noexcept
int getControllerValue() const noexcept
bool isValid() const noexcept
virtual void handleMidiEvent(const MidiMessage &)
MPEInstrument & instrument
virtual void setCurrentPlaybackSampleRate(double sampleRate)
double getSampleRate() const noexcept