{
   "code" : "(\r\n// create a MIDI file\r\nm = SimpleMIDIFile(\"~/output.mid\");\r\nm.init1;\r\nm.timeMode_( \\seconds ); // correct timeMode\r\n\r\n// add some random Notes \r\n((0,(1/8)..5)).do({ |starttime| \r\n\tm.addNote( 36 + 50.rand, 32 + 96.rand, starttime, [0.1,0.05].choose, 127, \r\n\t\ttrack: 1 )\r\n});\r\n\r\n// add some random  CCs\r\n((0,(1/8)..5)).do({ |starttime| \r\n\tm.addMIDITypeEvent(type: 'cc', args: [7, 128.rand], absTime: starttime, \r\n\t\ttrack: 1 )\r\n});\r\n\r\nm.adjustEndOfTrack; // may not be really needed, but nice if you want to do m.plot\r\n)\r\n\r\nMIDIClient.init;\r\n\r\n(\r\n~events = m.midiEvents;\r\n~midiout = MIDIOut(0);\r\n~routine = { \t \r\n\tvar lastTime = 0; \r\n\t\r\n\t~events.do({ |evt| \r\n\t\t(evt[1] - lastTime).wait; \r\n\t\tlastTime = evt[1]; \r\n\t\tswitch( evt[2].post,\r\n\t\t\t\\noteOn, { ~midiout.noteOn( *evt[3..].postln ); },\r\n\t\t\t\\noteOff, { ~midiout.noteOff( *evt[3..].postln ); },\r\n\t\t\t\\cc, { ~midiout.control( *evt[3..].postln ); }\r\n\t);       });\t\r\n}.fork; \r\n)",
   "is_private" : null,
   "id" : "1-574",
   "labels" : [
      "playback",
      "midi"
   ],
   "description" : "Play a midi file and include CC value changes. Code taken from sc-users mailinglist.\r\n\r\nhttp://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/simpleMIDIfile-play-via-MIDIOut-including-CC-td7632193.html",
   "ancestor_list" : [],
   "author" : "LFSaw",
   "name" : "MIDIFile player with CC capability"
}
