-
Notifications
You must be signed in to change notification settings - Fork 6
/
midi.scd
77 lines (61 loc) · 1.95 KB
/
midi.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// version 0.2
// first, initialize your midi device.
(
MIDIClient.init;
MIDIClient.list; // to check, which are there, you can query them
)
// create a midi out connection
~midiOut = MIDIOut.newByName("X18/XR18", "X18/XR18 MIDI 1"); // substitute your own device here
// you may want to adjust the latency here
~midiOut.latency = 0.0;
// define one instrument called "midi" (you may call it what you like)
// it uses the built in event type "midi" (this is predefined).
(
var p = (
type:\midi,
midiout: ~midiOut
);
~dirt.soundLibrary.addSynth(\midi,
(
play: {
var e = (
lag: ~lag + ~latency, // in the midi event, lag is used as latency
note: ~note ? 0,
sustain: ~sustain.value,
midicmd: ~midicmd ? \noteOn,
chan: ~midichan ? 0,
);
e.proto = p;
e.play;
}
)
);
)
// in tidal, define the following parameters:
(midicmd, midicmd_p) = pS "midicmd" (Nothing)
(chan, chan_p) = pF "chan" (Nothing)
(progNum, progNum_p) = pF "progNum" (Nothing)
(val, val_p) = pF "val" (Nothing)
(uid, uid_p) = pF "uid" (Nothing)
(array, array_p) = pF "array" (Nothing)
(frames, frames_p) = pF "frames" (Nothing)
(seconds, seconds_p) = pF "seconds" (Nothing)
(minutes, minutes_p) = pF "minutes" (Nothing)
(hours, hours_p) = pF "hours" (Nothing)
(frameRate, frameRate_p) = pF "frameRate" (Nothing)
(songPtr, songPtr_p) = pF "songPtr" (Nothing)
(ctlNum, ctlNum_p) = pF "ctlNum" (Nothing)
(control, control_p) = pF "control" (Nothing)
// the following midicmds and their parameters are then supported
// the usual note/freq and legato/sustain parameters are taken into account
polyTouch: chan, midinote, polyTouch
program: chan, progNum
bend: chan, val
sysex: uid, array
noteOn: chan, midinote, amp // default
allNotesOff: chan
smpte: frames, seconds, minutes, hours, frameRate
songPtr: songPtr
control: chan, ctlNum, control
touch: chan, val
noteOff: chan, midinote, amp // sent automatically, after sustain.