program variables/flags: MODE = (PASS | RECORD | PLAYBACK) FRET = (ON | OFF) NOTE = [PITCH, VOLUME, DURATION] MEM_POINTER = memory address to get next note from or store to PREV_PITCH = the pitch of the last note recorded PREV_VOLUME = the volume of the last note recorded COUNTER = 0 main loop, executed every 100th of a second or so, called by timer interrupt: local variables: pitch, volume check record button if it's depressed, set MODE = RECORD if MODE previously was RECORD and record button is now not depressed, write current NOTE to memory followed by "stop" byte reset DURATION counter if MODE is now RECORD and was previously not RECORD, reset MEM_POINTER to beginning of memory area check playback button if it's depressed, set MODE = PLAYBACK if MODE is now PLAYBACK and previously wasn't, reset MEM_POINTER to beginning of memory area if neither record, nor playback buttons are depressed, set MODE = PASS check fret switch and set FRET to ON or OFF accordingly sample pitch and volume info from input if FRET = ON discretize pitch discretize volume if MODE = PASS NOTE.PITCH = pitch NOTE.VOLUME = volume if MODE = RECORD NOTE.PITCH = pitch NOTE.VOLUME = volume compare NOTE.PITCH to PREV_PITCH and NOTE.VOLUME to PREV_VOLUME if both are the same, increment NOTE.DURATION if either are different, write NOTE to location pointed to MEM_POINTER reset NOTE.DURATION to 1 increment MEM_POINTER PREV_PITCH = NOTE.PITCH PREV_VOLUME = NOTE.VOLUME if MODE = PLAYBACK increment COUNTER if COUNTER > NOTE.DURATION get new NOTE from location pointed to by MEM_POINTER reset COUNTER increment MEM_POINTER if location MEM_POINTER is "stop" byte, reset MEM_POINTER to beginning of memory area send NOTE.PITCH and NOTE.VOLUME to output