example by Expert Sleepers

Author: Expert Sleepers
Version: 1.0
For AL version: 2.0.0 and above

This example shows how to maintain a simple state machine so that repeated events (here, MIDI note on messages) cause different behaviour.
First event -> tap record start
Second event -> tap record end, input level to 0.0
Third event -> Input level to 1.0 (i.e. enter overdub mode)
Fourth event -> Input level to 0.0, and next event is treated as third event, and so on

A second MIDI event is defined to reset the state, so the next event is treated as the first event.

Download: example.lua