Bruno Ruviaro edited MIDI.tex  almost 10 years ago

Commit id: 177cf88515e175901267556fa68c173c6ac91486

deletions | additions      

       

An extended presentation of MIDI concepts and tricks is beyond the scope of this tutorial. The examples below assume some familiarity with MIDI devices, and are provided just to get you started.  \lstinputlisting[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]{code-midi-demo.scd} \begin{lstlisting}  // Quick way to connect all available devices to SC  MIDIIn.connectAll;  // Quick way to see all incoming MIDI messages  MIDIFunc.trace(true);  MIDIFunc.trace(false); // stop it  // Quick way to inspect all CC inputs  MIDIdef.cc(\someCC, {arg a, b; [a, b].postln});  // Get input only from cc 7, channel 0  MIDIdef.cc(\someSpecificControl, {arg a, b; [a, b].postln}, ccNum: 7, chan: 0);  // A SynthDef for quick tests  SynthDef("quick", {arg freq, amp; Out.ar(0, SinOsc.ar(freq) * Env.perc(level: amp).kr(2))}).add;  // Play from a keyboard or drum pad  (  MIDIdef.noteOn(\someKeyboard, { arg vel, note;  Synth("quick", [\freq, note.midicps, \amp, vel.linlin(0, 127, 0, 1)]);  });  )  // Create a pattern and play that from the keyboard  (  a = Pbind(  \instrument, "quick",  \degree, Pwhite(0, 10, 5),  \amp, Pwhite(0.05, 0.2),  \dur, 0.1  );  )  // test  a.play;  // Trigger pattern from pad or keyboard  MIDIdef.noteOn(\quneo, {arg vel, note; a.play});  \end{lstlisting}