-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoxDot.sc
92 lines (65 loc) · 1.84 KB
/
FoxDot.sc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
FoxDot
{
classvar server;
classvar midiout;
*start
{ | remote = false |
server = Server.default;
server.options.memSize = 8192 * 16 * 8; // increase this if you get "alloc failed" messages
server.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"
server.options.numOutputBusChannels = 16; // set this to your hardware output channel size, if necessary
server.options.numInputBusChannels = 2; // set this to your hardware output channel size, if necessary
if (remote, {
server.options.bindAddress = "0.0.0.0"; // allow connections from any address
});
server.boot();
OSCFunc(
{
arg msg, time, addr, port;
var fn;
// Get local filename
fn = msg[1].asString;
// Print a message to the user
("Loading SynthDef from" + fn).postln;
// Add SynthDef to file
fn = File(fn, "r");
fn.readAllString.interpret;
fn.close;
},
'foxdot'
);
StageLimiter.activate(2);
"Listening for messages from FoxDot".postln;
}
*startRemote
{
this.start(true);
}
*midi
{
arg port=0;
MIDIClient.init;
midiout = MIDIOut(port);
OSCFunc(
{
arg msg, time, addr, port;
var note, vel, sus, channel, nudge, cc, value;
// listen for specific MIDI trigger messages from FoxDot
note = msg[2];
vel = msg[3];
sus = msg[4];
channel = msg[5];
nudge = msg[6];
cc = msg[7];
value = msg[8];
if ( cc==0, {
SystemClock.schedAbs(time + nudge, {midiout.noteOn(channel, note, vel)});
SystemClock.schedAbs(time + nudge + sus, {midiout.noteOff(channel, note, vel)});},{
SystemClock.schedAbs(time + nudge, {midiout.control(channel, cc, value)});} // crash mod
)
},
'foxdot_midi'
);
("Sending FoxDot MIDI messages to" + MIDIClient.destinations[port].name).postln;
}
}