| @@ -42,13 +42,16 @@ MPESynthesiser::~MPESynthesiser() | |||||
| void MPESynthesiser::startVoice (MPESynthesiserVoice* voice, MPENote noteToStart) | void MPESynthesiser::startVoice (MPESynthesiserVoice* voice, MPENote noteToStart) | ||||
| { | { | ||||
| jassert (voice != nullptr); | jassert (voice != nullptr); | ||||
| voice->currentlyPlayingNote = noteToStart; | voice->currentlyPlayingNote = noteToStart; | ||||
| voice->noteOnTime = lastNoteOnCounter++; | |||||
| voice->noteStarted(); | voice->noteStarted(); | ||||
| } | } | ||||
| void MPESynthesiser::stopVoice (MPESynthesiserVoice* voice, MPENote noteToStop, bool allowTailOff) | void MPESynthesiser::stopVoice (MPESynthesiserVoice* voice, MPENote noteToStop, bool allowTailOff) | ||||
| { | { | ||||
| jassert (voice != nullptr); | jassert (voice != nullptr); | ||||
| voice->currentlyPlayingNote = noteToStop; | voice->currentlyPlayingNote = noteToStop; | ||||
| voice->noteStopped (allowTailOff); | voice->noteStopped (allowTailOff); | ||||
| } | } | ||||
| @@ -197,7 +200,7 @@ MPESynthesiserVoice* MPESynthesiser::findVoiceToSteal (MPENote noteToStealVoiceF | |||||
| // compilers generating code containing heap allocations.. | // compilers generating code containing heap allocations.. | ||||
| struct Sorter | struct Sorter | ||||
| { | { | ||||
| bool operator() (const MPESynthesiserVoice* a, const MPESynthesiserVoice* b) const noexcept { return a->wasStartedBefore (*b); } | |||||
| bool operator() (const MPESynthesiserVoice* a, const MPESynthesiserVoice* b) const noexcept { return a->noteOnTime < b->noteOnTime; } | |||||
| }; | }; | ||||
| std::sort (usableVoices.begin(), usableVoices.end(), Sorter()); | std::sort (usableVoices.begin(), usableVoices.end(), Sorter()); | ||||
| @@ -304,6 +304,7 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| bool shouldStealVoices = false; | bool shouldStealVoices = false; | ||||
| uint32 lastNoteOnCounter = 0; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser) | ||||
| }; | }; | ||||
| @@ -42,11 +42,6 @@ bool MPESynthesiserVoice::isPlayingButReleased() const noexcept | |||||
| return isActive() && currentlyPlayingNote.keyState == MPENote::off; | return isActive() && currentlyPlayingNote.keyState == MPENote::off; | ||||
| } | } | ||||
| bool MPESynthesiserVoice::wasStartedBefore (const MPESynthesiserVoice& other) const noexcept | |||||
| { | |||||
| return noteStartTime < other.noteStartTime; | |||||
| } | |||||
| void MPESynthesiserVoice::clearCurrentNote() noexcept | void MPESynthesiserVoice::clearCurrentNote() noexcept | ||||
| { | { | ||||
| currentlyPlayingNote = MPENote(); | currentlyPlayingNote = MPENote(); | ||||
| @@ -156,9 +156,6 @@ public: | |||||
| */ | */ | ||||
| double getSampleRate() const noexcept { return currentSampleRate; } | double getSampleRate() const noexcept { return currentSampleRate; } | ||||
| /** Returns true if this voice started playing its current note before the other voice did. */ | |||||
| bool wasStartedBefore (const MPESynthesiserVoice& other) const noexcept; | |||||
| protected: | protected: | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Resets the state of this voice after a sound has finished playing. | /** Resets the state of this voice after a sound has finished playing. | ||||
| @@ -182,7 +179,8 @@ protected: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| friend class MPESynthesiser; | friend class MPESynthesiser; | ||||
| uint32 noteStartTime = 0; | |||||
| uint32 noteOnTime = 0; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice) | ||||
| }; | }; | ||||