-
Notifications
You must be signed in to change notification settings - Fork 0
/
AudioFX.scd
55 lines (54 loc) · 1.6 KB
/
AudioFX.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
52
53
54
55
(
SynthDef(\whatever, {|bus = 0, freq = 440, mix = 0.5, atk = 3, set = 0, rel = 3, resonz=1.0, gain = 0.8|
var env, sound, output;
env = Slew.kr(set, atk, rel);
sound = Saw.ar(freq, mix) + WhiteNoise.ar(1.0 - mix);
output = Resonz.ar(env * sound, freq, resonz, gain * AmpCompA.kr(freq));
Out.ar(bus, output);
}).add;
~synthDict = Dictionary();
~processRelease = {|index|
if(~synthDict.includesKey(index),
{
~synthDict.at(index).set(\set, 0);
~synthDict.removeAt(index);
}
);
};
~processCreate = {|index, freq, mix, atk, release, res, force|
var set = 0;
"Index: ".post;
index.postln;
~processRelease.(index);
~synthDict.put(
index,
Synth.new(\whatever, [\mix, mix, \freq, freq, \rel, release, \atk, atk, \resonz, res, \set, set])
);
};
~processTouch = {|index, freq, mix, atk, release, res, force|
var set;
"Index: ".post;
index.postln;
set = force.linlin(0, 4, 0, 1);
atk = 1 / atk;
release = 1 / release;
set.postln;
~synthDict.at(index).set(\mix, mix, \freq, freq, \rel, release, \atk, atk, \resonz, res, \set, set);
};
//)
//(
~osc1 = OSCFunc.new({|msg, time, addr, recvPort|
var index = msg.at(1).asInteger;
msg.postln;
~processTouch.(index, msg.at(2).asFloat, msg.at(3).asFloat, msg.at(4).asFloat, msg.at(5).asFloat, msg.at(6).asFloat, msg.at(7).asFloat);
}, "/audio/touch");
~osc2 = OSCFunc.new({|msg, time, addr, recvPort|
var index = msg.at(1).asInteger;
msg.postln;
~processCreate.(index, msg.at(2).asFloat, msg.at(3).asFloat, msg.at(4).asFloat, msg.at(5).asFloat, msg.at(6).asFloat, msg.at(7).asFloat);
}, "/audio/create");
)
(~osc1.free; ~osc2.free;)
OSCFunc.trace(true);
s.boot;
s.quit