Here is the simplified version of implemented algorithm in function mididetector_check:
BEGIN
if (check is enabled && we had a played note to check)
if ( we got a g-state from the follower && a note-on has been played)
enable note error detection for next state
output(``note error'')
increment number of note errors
else /* pitch is ok, now check other errors */
if (we got a g-rest) /* skip rest error */
store error
Output (``Skip rest error'')
increment number of rhythm errors
else /* check time for other possible rhythm errors */
if (played time - followed time - offset > tolerance)
enable rhythm error checking for next state
output(``rhythm error'')
increment number of rhythm errors
else /* time is ok, check now velocity */
check dynamic errors
endif
endif
endif
new time offset calculation
endif
Reset flags
Re-arm alarm
END