miditurtle - turtle-sound for manipulating MIDI data


 miditurtle in.mid - <<EOT | aplaymidi -
 playto 30.7 jump -3.2 c3cc74=30
 play 3.2 jump -3.2 c3cc74=70 pause 1.6
 pitch -200 play 1.6 pitch 0
 jump 3.5 filter -cha9
 playto 320 tempo 1.5 play 342 end

 perldoc miditurtle   # read the manual (even though it's in Lua!)


Remember turtle-graphics ? This script walks a turtle through a input-midi-file, generating an output-midi-file. It reads its turtle-commands from STDIN; the input-midi-file and output-midi-file are the two arguments. If the output-midi-file is - then the output is written to STDOUT, but the input-file must be specified by name, because STDIN is reserved for the turtle-commands.

TURTLE-COMMANDS :   jumpto,   jump,   playto,   play,   cc,   end,   pause,   filter,   pitch,   tempo

All times and delta-times are in seconds. All times refer to the input-file, in seconds after the start. The turtle's default behaviour is always to advance steadily through the input, copying events to the end of the output.

jumpto TIME
The turtle's position in the input will be moved to the time TIME (in seconds after the start).
The position in the input will be moved by the time-interval DELTATIME. It's like an incremental version of jumpto.
playto TIME
Events from the input will be copied to the output until the time TIME (in seconds after the start) is reached.
Events from the input will be copied to the output until the time-interval DELTATIME has passed. It's like an incremental version of playto.
Appends to the output a control_change event. In this example the Filter-Frequency for Channel 3 is set to 115 (0..127).
The output is written to the output-file and the program terminates.
Inserts a pause of DELTATIME seconds into the output. The turtle's position in the input is unchanged.
filter -cha9
filter +cha9
These commands respectively filter out, and restore back in, Channel 9 (the percussion channel). The Channels are numbered from 0 to 15.
pitch SHIFT
Changes the pitch (i.e. key but not tempo). SHIFT gives the pitch shift as positive or negative 'cents' (i.e. 100ths of a semitone). However, currently, all pitch-shifts are round to the nearest 100 cents, i.e. to the nearest semitone.
tempo FACTOR
Changes the tempo of the output. For example, tempo 1.5 makes the output one and a half times faster. The tempo changes are not cumulative, they are all relative to the tempo of the input-file.


Prints the Version


The current version of miditurtle is available by http at www.pjb.com.au/midi/free/miditurtle
To install miditurtle, save it to disc, move it into your $PATH, make it executable, and if necessary edit the first line to reflect where lua is installed on your system.

It is a Lua script, so you'll need to install Lua e.g.
    aptitude install lua luarocks
and you'll also need the MIDI module e.g.
    luarocks install MIDI


 20110804 1.0 tempo command seems to work
 20110804 output file can be - (stdout)
 20110803 add marker and cNccNN=NN
 20110801 use jumpto, jump, playto and play
 20110801 suppresses useless patch_changes
 20110731 first usefulness
 20110731 are play and jump working ?
 20110730 like 1D turtle-graphics through a MIDI file


Peter J Billam http://www.pjb.com.au/comp/contact.html


Based on the MIDI.lua Lua module.