mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MPE: Set the note-on time of MPESynthesiserVoice correctly
This commit is contained in:
parent
e7cf00e977
commit
32e6528508
4 changed files with 7 additions and 10 deletions
|
|
@ -42,13 +42,16 @@ MPESynthesiser::~MPESynthesiser()
|
|||
void MPESynthesiser::startVoice (MPESynthesiserVoice* voice, MPENote noteToStart)
|
||||
{
|
||||
jassert (voice != nullptr);
|
||||
|
||||
voice->currentlyPlayingNote = noteToStart;
|
||||
voice->noteOnTime = lastNoteOnCounter++;
|
||||
voice->noteStarted();
|
||||
}
|
||||
|
||||
void MPESynthesiser::stopVoice (MPESynthesiserVoice* voice, MPENote noteToStop, bool allowTailOff)
|
||||
{
|
||||
jassert (voice != nullptr);
|
||||
|
||||
voice->currentlyPlayingNote = noteToStop;
|
||||
voice->noteStopped (allowTailOff);
|
||||
}
|
||||
|
|
@ -197,7 +200,7 @@ MPESynthesiserVoice* MPESynthesiser::findVoiceToSteal (MPENote noteToStealVoiceF
|
|||
// compilers generating code containing heap allocations..
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ protected:
|
|||
private:
|
||||
//==============================================================================
|
||||
bool shouldStealVoices = false;
|
||||
uint32 lastNoteOnCounter = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ bool MPESynthesiserVoice::isPlayingButReleased() const noexcept
|
|||
return isActive() && currentlyPlayingNote.keyState == MPENote::off;
|
||||
}
|
||||
|
||||
bool MPESynthesiserVoice::wasStartedBefore (const MPESynthesiserVoice& other) const noexcept
|
||||
{
|
||||
return noteStartTime < other.noteStartTime;
|
||||
}
|
||||
|
||||
void MPESynthesiserVoice::clearCurrentNote() noexcept
|
||||
{
|
||||
currentlyPlayingNote = MPENote();
|
||||
|
|
|
|||
|
|
@ -156,9 +156,6 @@ public:
|
|||
*/
|
||||
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:
|
||||
//==============================================================================
|
||||
/** Resets the state of this voice after a sound has finished playing.
|
||||
|
|
@ -182,7 +179,8 @@ protected:
|
|||
private:
|
||||
//==============================================================================
|
||||
friend class MPESynthesiser;
|
||||
uint32 noteStartTime = 0;
|
||||
|
||||
uint32 noteOnTime = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiserVoice)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue