 
 // -----------------------------------------------------------------------------
 
-void handleNotesChanged()
+void handleNotesChanged(bool isFirstNote = false)
 {
     if (midiNotes.empty())
     {

        if (midiNotes.getLast(currentNote))
        {
            tone(sAudioOutPin, sNotePitches[currentNote]);
            pulseGate(); // Retrigger envelopes. Remove for legato effect.
        }
    }
}


// -----------------------------------------------------------------------------

inline void handleGateChanged(bool inGateActive)
{
    digitalWrite(sGatePin, inGateActive ? HIGH : LOW);
}

inline void pulseGate()
{
    handleGateChanged(false);
    delay(1);
