; the send command routes data to various audio destinations. one of ; the most common destinations is the Midi Port (mp). Here is how to ; send a fully specified midi note to the midi port send("mp:midi", 0, 1, 60, .5, 0) ; the first argument "mp:midi" is called the 'message' and it ; specifies what target will receive the data you send. the rest of ; the arguments define the data being sent. in the case of the ; "mp:midi" message up to 5 values can be sent: time, dur, key, amp, ; chan, where time and dur are in seconds, key is a midi key number 0 ; to 127, amp is a relative amplitude value 0.0 to 1.0 and chan is an ; integer midi channel 0 to 15. ; for example this plays a short, loud c5 two seconds after you send it: send("mp:midi", 2, .2, 72, .9, 0) ; this sends a random, soft, long, low note: send("mp:midi", 0, pick(2,3,4), between(20, 35), .2) ; each parameter has a "default value" you do not have to send all five values. ; the defaults for the parameters are time=0, dur=.5, key=60, amp=.5, chan=0 ; to specify only one or two values or to specify values in any order you ; can use provide thei keyword names: send("mp:midi", key: between(60,70)) send("mp:midi", key: between(60,70), dur: pick(.1, .2, .4)) ; ;; midi instrument assignment ; ; you can use the "mp:instruments" message to send program changes ; (instrument assignments) to upto 16 channels. this example sets up ; a string quintet on channels 0 to 4, where channel 0 and 1 get ; Violin (program 40), channel 2 gets viola (41) , channel 3 gets ; Cello (42) and channel 4 gets Double Bass (43): send("mp:instruments", 40, 40, 41, 42, 43) ; now send middle C to random instruments in the quintet send("mp:midi", key: 60, chan: pick(0,1,2,3,4)) ; now reset the five channels back to Grand Piano send("mp:instruments", 0, 0 , 0 ,0 ,0) ; for more information about program changes see: ; http://en.wikipedia.org/wiki/General_MIDI#Program_change_events ; note that the values you see listed in the URL's table are 1 based ; so you must always subtract 1 to get the true program value! ; ;; microntonal output ; ; the "mp:tuning" message lets you set the midi port to a tuning ; resolution 1-16, where 1 is standard tuning, 2 is quartertone and so send("mp:tuning", 2) ; if a microtonal resolution is set, then floating point key numbers kkk.cc are ; interpeted as the requency 'cc' cents above keynum 'kkk'. ; this will play Middle C send( "mp:midi", key: 60.0) ; this will play 50 cents above Middle C send( "mp:midi", key: 60.50) ; this will play middle D: send( "mp:midi", key: 61.0) ; this will play random quartertones in the middle C octave begin with k = between(60.0, 72.0) print( "playing ", k) send( "mp:midi", key: k) end ; if you set tuning back to semitone (1) then you wont hear microtones ; even if you send them because in semitonal tuning microtones are ; quantized to the nearest integer key number send( "mp:tuning", 1) begin with k = between(60.0, 72.0) print("playing ", k) send( "mp:midi", key: k) end