-
Notifications
You must be signed in to change notification settings - Fork 0
/
Harmonizer.scd
132 lines (95 loc) · 3.01 KB
/
Harmonizer.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
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
// Settings per cambiare input audio
//Server.local.options.inDevice = "MME : Cuffie (Audio Bluetooth)";
//Server.local.options.outDevice = " MME : Cuffie (Audio Bluetooth)";
Server.local.options.inDevice = "[Scarlett 2i2 USB]";
Server.local.options.outDevice = "[Scarlett 2i2 USB]";
ServerOptions.outDevices
// Player
(
SynthDef(\harm,
{
// p1, p2, p3 sono gli argomenti per i pitch;
// g1, g2, g3 sono gli argomenti per i gain
//arg p1 = 1.0, p2 = 1.0, p3 = 1.0, g1 = 1.0, g2 = 1.0, g3 = 1.0;
//arg g1 =1.0, g2 = 1.0, g3 = 1.0, g4 = 1.0, g5 = 1.0;
arg g1 =0, g2 = 0, g3 = 0, g4 = 0, g5 = 0;
var wS=0.1;
var p1 =0.5, p2 = 0.75, p3 = 1.333333, p4 = 1.5, p5 = 2;
var out_signal;
// fai QUESTO se vuoi usare il file vocals (cambialo a seconda del tuo path assoluto
//var infile="/Users/Clara/Desktop/AirHarmonizer/vocals.wav";
//var b = Buffer.read(s, infile);
//var input=PlayBuf.ar(2,b.bufnum,BufRateScale.kr(b.bufnum),loop:1);
// decommenta questo se vuoi invece l'input del microfono
//var input=AudioIn.ar([1,2]);
var input=AudioIn.ar(1);
//var o1=PitchShift.ar(input,windowSize:wS,pitchRatio:p1);
//var o2=PitchShift.ar(input,windowSize:wS,pitchRatio:p2);
//var o3=PitchShift.ar(input,windowSize:wS,pitchRatio:p3);
var o1=PitchShift.ar(input,windowSize:wS,pitchRatio:p1);
var o2=PitchShift.ar(input,windowSize:wS,pitchRatio:p2);
var o3=PitchShift.ar(input,windowSize:wS,pitchRatio:p3);
var o4=PitchShift.ar(input,windowSize:wS,pitchRatio:p4);
var o5=PitchShift.ar(input,windowSize:wS,pitchRatio:p5);
//var out_signal=input+(o1*g1)+(o2*g2)+(o3*g3);//o1+o2+o3;//
out_signal=(input*0.2)+((o1*g1)+(o2*g2)+(o3*g3)+(o4*g4)+(o5*g5))*0.8;
//var out_signal=input*0.5+((o5*g5))*0.5;
//var out_signal = input + o*g;
Out.ar([0,1], out_signal);
}).add;
)
// prova Senza OSC
// (
// a = Synth(\harm);
// a.set(\p1, 0.5,\g1,1, \p2,1, \g2,0.5, \g3,0);
// )
// prova OSC
NetAddr("127.0.0.1",57120);
(
var song, freq, loud,pan;
a = Synth(\harm);
//a.set(\p1, 1,\p2,1, \p3,2);
OSCdef('OSCreceiver',
{
arg msg;
var gg1,gg2,gg3,gg4,gg5;
//var pp;
//var whichHarm = msg[1];
//var gg = msg[2];
//var gain;
//whichHarm.postln();
//pp = ratios[whichHarm];
//if(gg==0,{gain=0},{gain=(gg-400)/(40-400)});
//a.set(\p, pp);
msg.postln();
if(msg[1]==0,{gg1=0},{gg1 = (msg[1]-400)/(40-400)});
if(msg[2]==0,{gg2=0},{gg2 = (msg[2]-400)/(40-400)});
if(msg[3]==0,{gg3=0},{gg3 = (msg[3]-400)/(40-400)});
if(msg[4]==0,{gg4=0},{gg4 = (msg[4]-400)/(40-400)});
if(msg[5]==0,{gg5=0},{gg5 = (msg[5]-400)/(40-400)});
a.set(\g1, gg1);
a.set(\g2, gg2);
a.set(\g3, gg3);
a.set(\g4, gg4);
a.set(\g5, gg5);
'aaa'.postln();
gg1.postln();
gg2.postln();
gg3.postln();
gg4.postln();
gg5.postln();
/*var secondGrade=msg[1],
thirdGrade=msg[2],
fourthGrade=msg[3];
secondGrade.post();
' '.post();
thirdGrade.post();
' '.post();
fourthGrade.postln();
' '.postln();
a.set(\sG,secondGrade);
a.set(\tG,thirdGrade);
a.set(\fG,fourthGrade);*/
},
"/chord");
)