-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestEvent.sc
110 lines (85 loc) · 2.9 KB
/
TestEvent.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
TestEvent.run
UnitTest.gui
*/
TestEvent : UnitTest {
var prevMsg, prevLatency;
test_equality {
var a,b,c, x, y, keys, values;
a = (a: 100, b: 200, c: [1, 2, 3]);
b = (a: 100, b: 200, c: [1, 2, 3]);
c = (a: 100, b: 200, c: [1, 2, 4]);
this.assert( a == b, "2 identically specified Events should be equal");
this.assert( a != c, "2 different Events should not be equal");
this.assert( a == a, "an Events should equal itself");
x = ().putPairs([{ |i| ("key_" ++ i).asSymbol }.dup(80), 0].flop.flat);
keys = x.keys.asArray;
values = keys.collect { |key| x.at(key) };
this.assert(values.includes(nil).not, "an Event responds to all its keys");
x.use {
y = ().putPairs(keys.envirPairs);
};
this.assert(x == y, "an Event remains invariant under transformation to envirPairs");
}
test_server_messages {
// type note
var event = (
type: \note,
instrument: \xxx_test,
server: this,
note: 0,
octave: 6,
ctranspose: 1,
zzzz: 0,
latency: 0,
finish: { finishTest = true }
);
var i, msg1, finishTest = false;
var isPlaying;
SynthDef(\xxx_test, { |freq, zzzz, gate = 1|
}).add;
this.assert(SynthDescLib.global.at(\xxx_test).canFreeSynth.not,
"SynthDesc detects that Synth can't free itself");
SynthDef(\xxx_test, { |freq, zzzz, gate = 1|
EnvGen.kr(Env.asr, gate, doneAction:2)
}).add;
this.assert(SynthDescLib.global.at(\xxx_test).canFreeSynth,
"SynthDesc detects that Synth can free itself");
event.play;
0.5.wait;
msg1 = prevMsg[0];
i = msg1.indexOf(\freq);
this.assert(msg1[i+1].cpsmidi == 73, "note 0 octave 6 ctranspose 1 equals midinote 73");
this.assert(msg1[4] == 1, "synth created in root node");
this.assert(msg1.includes(\zzzz), "SynthDesc provides parameters to send in message");
this.assert(event[\hasGate] == true, "Event detects gate in SynthDesc");
this.assert(finishTest, "Event evaluates finish action");
this.assert(prevLatency == 0,
"latency specified in the event should override server latency");
prevMsg = nil;
prevLatency = nil;
/*
Server.default.boot;
this.wait({ Server.default.serverRunning }, "server failed to boot");
SynthDef(\xxx_test, { |gate = 1, doneAction = 0|
EnvGen.kr(Env.asr(0, 1, 0.1), gate, doneAction:doneAction)
}).memStore;
event = (instrument: \xxx_test, sustain: 200, server: Server.default, doneAction: 2);
event.play;
0.5.wait;
OSCresponderNode(addr, '/g_queryTree.reply', { arg time, responder, msg;
}).addOnce;
this.assert(synth.isPlaying, "event should play");
0.5.wait;
event.release;
0.5.wait;
this.assert(synth.isPlaying.not, "event should release");
*/
}
sendMsg { |... args| prevMsg = prevMsg.add(args) }
sendBundle { |latency, args| prevMsg = prevMsg.add(args); prevLatency = latency; }
nextNodeID { ^-1 }
latency { ^0.2 }
defaultGroupID { ^1 }
defaultGroup { ^Group.basicNew(nil, 1) }
}