forked from davidgranstrom/ohs-071112_sc-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex3.scd
52 lines (43 loc) · 1.56 KB
/
ex3.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
// ===========================================================================
// SimpleGui demo
// ===========================================================================
s.boot;
// ----------------------------------------
// ex1: create a gui based on SynthDef args
// ----------------------------------------
(
SynthDef(\simplePartial, {|freq=110, amp=0.25, cfreq=2500, pan, out|
var o = RLPF.ar(
SinOsc.ar(freq+Rand(-0.5,0.5),SinOsc.ar(freq,0,4pi-(3pi*amp))),
cfreq,
0.75
);
Out.ar(out, Pan2.ar(o,pan,amp));
}, 0.1!4).add;
)
x = Synth(\simplePartial);
// SimpleGui will try and guess the appropriate ControlSpecs
// based on the SynthDefs NamedControl arguments
SimpleGui(x, freeOnClose: true);
// ------------------------------------------------------
// ex2: create a gui based on SynthDef args and metadata
// -----------------------------------------------------
(
// a SynthDef with metadata
~sdef = SynthDef(\simplePartial, {|freq=110, amp=0.25, cfreq=2500, pan, out|
var o = RLPF.ar(
SinOsc.ar(freq+Rand(-0.5,0.5),SinOsc.ar(freq,0,4pi-(3pi*amp))),
cfreq,
0.75
);
Out.ar(out, Pan2.ar(o,pan,amp));
}, 0.1!4, metadata: (
// add our own custom spec
freq: ControlSpec(55,555,\exp,0.01,110,"Hz"),
)).add;
// inspect
~sdef.metadata
)
// Synth().makeGui is a convenience method for creating a SimpleGui
// notice that the metadata is used for creating our 'freq' control
x = Synth(\simplePartial).makeGui(true);