«Filter Explorer @ 1000 Hz of the Cutoff Frequency (Centre Frequency)» by prko

on 22 Apr'18 01:44 in filters

Special Thanks to Russell Johnston who gave an excellent solution to MouseLeaveAction issue via the sc-users list! Thanks to Fredrik Olofsson who mentioned to the related issue as well.

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
(
s.waitForBoot{
	var synth, srcs, snds, path, win, bnds, view, vIn, scope, h, w, v, iW, oW, btns, f, snd, flt, fltSel, fltTxts;
	
	fltSel = Bus.control(s,1);
	
	synth = {
		arg which, frq, mul;
		var in, src, rq;
		in = Saw.ar(200,0.3!2);
		srcs = [
			Decay.ar(
				Impulse.ar(LFGauss.kr(5, 0.5).range(2, 7)),
				0.1,
				in*MouseButton.kr(0, 1, 0.001)
			),
			WhiteNoise.ar(0.08!2),
			PinkNoise.ar(0.08!2),
			BrownNoise.ar(0.08!2),
			GrayNoise.ar(0.08!2),
			ClipNoise.ar(0.08!2),
			Impulse.ar(10!2),
			Dust.ar(10!2),
			Dust2.ar(10!2),
			Crackle.ar(1.5, 0.08!2)
		];
		src = Select.ar(which, srcs);
		
		rq = MouseY.kr(0.01, 10, 1);
		
		snds = [
			src,
			LPF.ar(src, frq),
			LPF.ar(LPF.ar(src, frq), frq),
			HPF.ar(src, frq),
			BRF.ar(src, frq, rq),
			BPF.ar(src, frq, rq),
			Resonz.ar(src, frq, rq),
			Resonz.ar(
				Resonz.ar(src, frq, rq),
				frq,
				rq
			),
			BBandPass.ar(src, frq, rq),
			RLPF.ar(src, frq, rq),
			RHPF.ar(src, frq, rq)
		];
		
		flt = Out.kr(fltSel, MouseX.kr(0, snds.size));
		
		Select.ar(In.kr(fltSel), snds) * mul
	};
	
	snd = synth.play(args:[frq:1000, mul:0, which:0]);
	
	bnds = Window.screenBounds;
	h = bnds.height;
	w = bnds.width;
	win = Window("control", Rect(0, 0, w, h)).fullScreen;
	win.onClose_{ snd.free };
	iW = w/srcs.size;
	oW = w/snds.size;
	
	StaticText(win, Rect(10, 10, 500, 30))
	.align_(\topLeft)
	.font_(Font("Arial", 24))
	.string_("Input Signal (Source) Seleciton:");
	
	btns = srcs.size.collect {
		|i|
		var x, inputs, outputs;
		inputs = [
			"decay",
			"whiteNoise",
			"pinkNoise",
			"brownNoise",
			"grayNoise",
			"clipNoise",
			"impulse",
			"dust",
			"dust2",
			"crackle"
		][i];
		Button(win, Rect(iW * i, 50, iW, 30))
		.states_([
			[inputs, Color.grey, Color.white],
			[inputs, Color.white, Color.grey]
		])
		.action_{ arg butt;
			if(butt.value == 1) {
				snd.set(\which, i);
				btns.size.do{|n|
					[n, i];
					if (n != i) { btns[n].value = 0 }
				}
			}
		}
		.value_(if(i==0) { 1 })
	};
	
	StaticText(win, Rect(10, 95, 2000, 60))
	.align_(\topLeft)
	.font_(Font("Arial", 24))
	.string_("Input Signal (Source) Seleciton: Select the output signal (filtered sound) by pressing the mouse button and dragging the mouse pointer across the columns. The vertical position of the 5th through 11th columns is related to the Q-factor.");
	
	view = UserView(win, Rect(0, 160, w, h-430));
	
	vIn = true;
	
	view
	.mouseDownAction_{ |view, x, y, modifiers, buttonNumber, clickCount|
		if(buttonNumber==0 && (clickCount==1)) { snd.set(\mul, 1) }
	}
	.mouseUpAction_{ |view, x, y, modifiers, buttonNumber, clickCount|
		if(buttonNumber==0) { snd.set(\mul, 0) }
	}
	.mouseLeaveAction_{ |view, x, y|
		snd.set(\mul, 0)
	}
	.mouseMoveAction_{ | view, x, y |
		if (view.bounds.containsPoint(x@(y + 160))) {
			vIn = true;
			snd.set(\mul, 1)
		} {
			if (vIn) {
				vIn = false;
				view.mouseLeaveAction.()
		} }
	}
	.animate_(true);
	
	fltTxts = snds.size.collect{
		|i|
		var outputs;
		outputs = [
			"S\nR\nC",
			"S\nR\nC\n\nL\nP\nF",
			"S\nR\nC\n\nL\nP\nF\n\nL\nP\nF",
			"S\nR\nC\n\nH\nP\nF",
			"S\nR\nC\n\nB\nR\nF",
			"S\nR\nC\n\nB\nP\nF",
			"S\nR\nC\n\nR\nE\nS\nO\nN\nZ",
			"S\nR\nC\n\nR\nE\nS\nO\nN\nZ\n\nR\nE\nS\nO\nN\nZ",
			"S\nR\nC\n\nB\nB\nA\nN\nD\nP\nA\nS\nS",
			"S\nR\nC\n\nR\nL\nP\nF",
			"S\nR\nC\n\nR\nH\nP\nF"
		][i];
		StaticText(view, Rect(oW * (i + 0.1), 10, 200, 500))
		.align_(\topLeft)
		.font_(Font("Arial", 24))
		.string_(outputs)
	};
	
	view.drawFunc = {
		snds.do {
			|which, i|
			Pen.strokeColor = Color.black;
			Pen.moveTo(0@0);
			Pen.lineTo(0@h);
			Pen.translate(oW, 0);
			Pen.stroke;
			
			fltTxts[i].stringColor_(
				if(fltSel.getSynchronous.asInteger==i) {
					Color.black
				}{
					Color.gray
				}
			)
		}
	};
	
	ServerMeterView.new(s, win, 10@(h-235), 0, 2);
	
	scope = UserView(win, Rect(90, h-257, 247, 247));
	Stethoscope(s, view:scope);
	
	FreqScopeView(win, Rect(350, h-255, w-360, 245))
	.active_(true)
	.freqMode_(1);
	
	win.front
}
)
raw 4185 chars (focus & ctrl+a+c to copy)
reception
comments