-
Notifications
You must be signed in to change notification settings - Fork 9
/
MIDI_demo.scd
55 lines (38 loc) · 1.06 KB
/
MIDI_demo.scd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// --------- //
// MIDI demo //
// --------- //
// 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 listen for a specific controller number
MIDIdef.cc(\someCC, {arg a, b; [a, b].postln});
// A Synth for quick tests
(
SynthDef("quick", {arg freq, amp;
Out.ar(0, SinOsc.ar(freq, 0, amp) * EnvGen.kr(Env.perc, doneAction: 0));
}).add;
)
// Play from a keyboard
(
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, 0.1),
\dur, 0.1
);
)
// test
a.play
// Trigger pattern from keyboard
MIDIdef.noteOn(\quneo, { arg vel, note; a.play });
// Listen only for cc #7 from channel 0
MIDIdef.cc(\someSpecificControl, {arg a, b; [a, b].postln}, ccNum: 7, chan: 0);
MIDIdef.cc(\quneoCCtyui, {arg value, ccNumber; "WOW".postln}, 22);