-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTestFilterUGens.sc
120 lines (107 loc) · 2.65 KB
/
TestFilterUGens.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
110
111
112
113
114
115
116
117
118
119
120
TestFilterUGens : UnitTest {
// check time invariance of all subClasses of Filter, particularly during the first 64 samples.
// Filter followed by delay should be the same as delay followed by filter.
// Only uses the filters' default arguments, but this should catch most initialisation errors.
test_time_invariance {
// a list of filters to test. Should basically be Filter.allsubclasses, minus a
// few odd ones like DetectSilence, plus anything that's supposed to behave like a filter
// but doesn't drive from Filter. Will ignore missing classes, so can include filters
// defined in extensions.
var filters = [
\CombFormlet,
\InsideOut,
\LagUD,
\Decay,
\OnePole,
\MoogFF,
\Integrator,
\RLPF,
\MedianTriggered,
\MidEQ,
\Slew,
\TwoPole,
\Formlet,
\BPF,
\LPF,
\LPZ2,
\Decay2,
\Resonz,
// \Friction, // fixme
\Lag,
\LPZ1,
\Ringz,
\FOS,
\MeanTriggered,
\LeakDC,
\Slope,
\SOS,
\Lag2UD,
\Lag3UD,
\OneZero,
\RHPF,
\TwoZero,
// \APF, // fixme
\BRF,
\HPF,
\HPZ2,
\BPZ2,
\BRZ2,
\Lag2,
// \Ramp, // fixme
\Lag3,
\HPZ1,
\BHiPass,
\BLowShelf,
\BPeakEQ,
\BBandPass,
\BBandStop,
\BAllPass,
\BHiShelf,
\BLowPass,
/*
\NestedAllpassN,
\NestedAllpassC,
\DoubleNestedAllpassN,
\DoubleNestedAllpassL,
\DoubleNestedAllpassC, // fix us
*/
\MoogLadder,
\RLPFD,
// \Streson, // fixme
].collect(_.asClass).reject(_.isNil);
var delay_times = [1,64]; // in samples
var testsIncomplete = delay_times.size * filters.size;
this.bootServer;
filters.do {
arg filter;
delay_times.do {
arg delay_samples;
var message = filter.asString ++ ".ar is time invariant when delayed by "
++ delay_samples ++ " sample(s).";
{
var deltime = delay_samples/SampleRate.ir;
// should be silent - FP rounding errors are ok.
DelayN.ar(filter.ar(Impulse.ar(0)), deltime, deltime)
- filter.ar(DelayN.ar(Impulse.ar(0), deltime, deltime));
}.loadToFloatArray(0.1, Server.default, {
arg data;
this.assertArrayFloatEquals(data, 0, message, within:1e-10, report:true);
testsIncomplete = testsIncomplete - 1;
});
rrand(0.012,0.035).wait;
}
};
this.wait(testsIncomplete == 0);
"".postln;
postln("Please note: the following subclasses of Filter are not included in TestFilterUgens.");
postln("Please consider adding them unless there is a good reason not to");
postln("(i.e. the class is not intended as a time invariant filter UGen).");
Filter.allSubclasses.do {
arg filter;
if (filters.includes(filter).not) {
filter.postln;
}
};
"".postln;
}
}