Fix the fix.

This commit is contained in:
Francois Best 2014-05-21 09:01:29 +02:00
parent 97e2c554de
commit 9157f847ca
1 changed files with 14 additions and 5 deletions

View File

@ -18,12 +18,12 @@ MidiNoteList<sMaxNumNotes> midiNotes;
// -----------------------------------------------------------------------------
void handleGateChanged(bool inGateActive)
inline void handleGateChanged(bool inGateActive)
{
digitalWrite(sGatePin, inGateActive ? HIGH : LOW);
}
void pulseGate()
inline void pulseGate()
{
handleGateChanged(false);
delay(1);
@ -32,7 +32,7 @@ void pulseGate()
// -----------------------------------------------------------------------------
void handleNotesChanged()
void handleNotesChanged(bool isFirstNote = false)
{
if (midiNotes.empty())
{
@ -50,17 +50,26 @@ void handleNotesChanged()
if (midiNotes.getLast(currentNote))
{
tone(sAudioOutPin, sNotePitches[currentNote]);
if (isFirstNote)
{
handleGateChanged(true);
}
else
{
pulseGate(); // Retrigger envelopes. Remove for legato effect.
}
}
}
}
// -----------------------------------------------------------------------------
void handleNoteOn(byte inChannel, byte inNote, byte inVelocity)
{
const bool firstNote = midiNotes.empty();
midiNotes.add(MidiNote(inNote, inVelocity));
handleNotesChanged();
handleNotesChanged(firstNote);
}
void handleNoteOff(byte inChannel, byte inNote, byte inVelocity)