-
Notifications
You must be signed in to change notification settings - Fork 0
/
3d ambisonics half octahedron.scd
102 lines (78 loc) · 1.98 KB
/
3d ambisonics half octahedron.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
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
(
{
var p, a, b, c, d;
p = Dust.ar(2000); // source
// B-format encode
#w, x, y, z = PanB.ar(p,LFSaw.ar(0.5),LFSaw.ar(0.2), 0.3);
// B-format decode to cube / quad ([lfh, rfh, rrh, lrh, lfl, rfl, rrl, lrl])
// lfl = left fron high, lfl = left front low etc...
BFDecode1.ar(w, x, y, z,
[-0.25pi, 0.25pi,0.75pi, 1.25pi,0pi],
[0pi,0pi,0pi,0pi,-0.5pi]);
}.scope(5);
)
SerialPort.devices;
~port = SerialPort.new("COM3",115200);
~port.close;
(
x = [];
30.do{x=x.add(~port.read)};
x.collect(_.asAscii);
)
(
~charArray = [];
~getValues = Routine.new({
var ascii;
{
ascii = ~port.read.asAscii;
if(ascii.isDecDigit, {~charArray = ~charArray.add(ascii)});
if(ascii == $a,{
~val = ~charArray.collect(_.digit).convertDigits;
~charArray = [];
});
}.loop;
}).play;
)
(
SynthDef.new(\saw,{
arg cutoff = 1000,el;
var sig,audio;
sig = Saw.ar(50);
sig = RLPF.ar(sig,cutoff.lag(0.02),0.25,0.2);
#w, x, y, z = PanB.ar(sig,0,SinOsc.ar(el),0.3);
// B-format decode to cube / quad ([lfh, rfh, rrh, lrh, lfl, rfl, rrl, lrl])
// lfl = left fron high, lfl = left front low etc...
audio = BFDecode1.ar(w, x, y, z,
[-0.25pi, 0.25pi,0.75pi, 1.25pi,0pi],
[0pi,0pi,0pi,0pi,-0.5pi]);
Out.ar(0,audio);
}).add;
)
(
SynthDef.new(\saw2,{
arg cutoff = 1000,el;
var sig,audio;
sig = Saw.ar(51);
sig = RLPF.ar(sig,cutoff.lag(0.02),0.25,0.2);
#w, x, y, z = PanB.ar(sig,1,SinOsc.ar(el),0.3);
// B-format decode to cube / quad ([lfh, rfh, rrh, lrh, lfl, rfl, rrl, lrl])
// lfl = left fron high, lfl = left front low etc...
audio = BFDecode1.ar(w, x, y, z,
[-0.25pi, 0.25pi,0.75pi, 1.25pi,0pi],
[0pi,0pi,0pi,0pi,-0.5pi]);
Out.ar(0,audio);
}).add;
)
(
~synth = Synth.new(\saw,[\el,~val.linexp(0,1023,0.1,10)]);
~synth1 = Synth.new(\saw2,[\el,~val.linexp(0,1023,0.1,10)]);
)
(
~control = Routine.new({
{
~synth.set(\el,~val.linexp(0,1023,0.1,10));
~synth1.set(\el,~val.linexp(0,1023,0.25,5));
0.01.wait;
}.loop;
}).play;
)