--[[ Example Augustus Loop MIDI customisation script. By expertsleepers, 9/7/2008. 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. --]] -- you can use 'print' to help with debugging -- on Mac OS X, the output will appear in console.log - use the Console utility to view it -- if your script contains errors and cannot be run, an error message will appear in the same place print ( "Example Augustus Loop MIDI customisation script running at ", os.date() ) -- define the state variable local state = 0 -- get the parameter IDs that we want to control -- setParameter() will work with a parameter name, but it's more efficient to find the ID from the -- name here once, and then use the ID local paramID_TapRecord = getParameterID( "Tap Record" ) local paramID_InputLevel = getParameterID( "Input Level" ) -- define the functions that will handle events -- this function handles the main note on event, that will advance through the states local function handleEvent1( channel, noteNumber, velocity ) if state == 0 then state = 1 setParameter( paramID_InputLevel, 1.0 ) setParameter( paramID_TapRecord, 1.0 ) elseif state == 1 then state = 2 setParameter( paramID_TapRecord, 0.0 ) setParameter( paramID_InputLevel, 0.0 ) elseif state == 2 then state = 3 setParameter( paramID_InputLevel, 1.0 ) else state = 2 setParameter( paramID_InputLevel, 0.0 ) end end -- this function handles the secondary note on event, that will reset the state local function handleEvent2( channel, noteNumber, velocity ) state = 0 end -- finally, request that the functions above be called on the appropriate MIDI events requestNoteOn( 84, handleEvent1 ) requestNoteOn( 85, handleEvent2 )