2023-09-24 22:42:30 +02:00
|
|
|
/*RUN*/
|
2023-10-20 01:54:56 +02:00
|
|
|
|
|
|
|
// initial settings .....................................
|
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
s.options.numInputBusChannels = 2; // 4 for installation 2 for webstream
|
|
|
|
s.options.numOutputBusChannels = 2;
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
// create 8 control busses to pass data between synths
|
|
|
|
~ctrlBus = 8.collect({arg i; Bus.control(s,1); });
|
|
|
|
|
|
|
|
//~dataPath = "/home/rob/witw/data/"; // laptop
|
|
|
|
~dataPath = "/home/rizoma/witw/data/"; // installation computer
|
2023-10-19 23:04:42 +02:00
|
|
|
~devices = ["D7:80:BE:2C:63:BD", "F1:CC:C3:0B:7F:5C"];
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
// load and process the data source /////////////////////////////////
|
|
|
|
~csvFile=CSVFileReader.read(~dataPath ++ ~devices[0] ++ "/" ++ "sensor_data.csv",true,true);
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
// flatten ~data from 2D Array to regular array (per column);
|
|
|
|
~data = ( ~csvFile[0].size ).collect({ arg itt;
|
|
|
|
Array.fill( ~csvFile.size-1,{ arg i;
|
|
|
|
~csvFile.at(i+1).asArray.at(itt)}); // +1 to skip the column name
|
|
|
|
});
|
|
|
|
|
|
|
|
s.waitForBoot{
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-10-17 16:58:11 +02:00
|
|
|
// define synths
|
2023-10-19 23:04:42 +02:00
|
|
|
SynthDef(\sgrain, { | out=0, atk=0.01, dcy=0.01, freq=100, pan=0, amp=1|
|
2023-09-24 22:42:30 +02:00
|
|
|
var sig, env;
|
|
|
|
env = EnvGen.ar(Env.perc(atk, dcy), doneAction: 2);
|
|
|
|
sig = FSinOsc.ar(freq);
|
|
|
|
sig = sig * (env * amp);
|
|
|
|
sig = Pan2.ar(sig, pan);
|
|
|
|
Out.ar(out, sig);
|
2023-10-17 16:58:11 +02:00
|
|
|
Out.kr(~ctrlBus[0],freq);
|
2023-09-24 22:42:30 +02:00
|
|
|
}).add;
|
|
|
|
|
|
|
|
SynthDef(\sslew, {
|
2023-10-19 23:04:42 +02:00
|
|
|
| out = 0, freq=100, amp = 0.7, slewrate = 1|
|
2023-09-24 22:42:30 +02:00
|
|
|
var sig, z;
|
|
|
|
// add slew rate on frequency
|
|
|
|
z = Slew.kr(freq, slewrate, slewrate);
|
2023-10-19 23:04:42 +02:00
|
|
|
sig = BPF.ar(PinkNoise.ar(), z, 6 );
|
|
|
|
//sig = Blip.ar(z, 5, amp).dup;
|
2023-09-24 22:42:30 +02:00
|
|
|
Out.ar(out, sig)
|
|
|
|
}).add;
|
|
|
|
|
2023-10-19 23:04:42 +02:00
|
|
|
SynthDef.new(\sine, {
|
2023-11-15 13:43:06 +01:00
|
|
|
arg freq=440, modfreq=6, pmindex=3, modphase=0,
|
|
|
|
panfreq=1.3, panphase=0.5, rel=0.5, gate=0, amp=0.0001;
|
2023-10-21 10:10:10 +02:00
|
|
|
var sig, env;
|
|
|
|
sig = PMOsc.ar(freq, modfreq, pmindex, modphase);
|
|
|
|
//env = Env.perc(0.04,rel);
|
|
|
|
env = Env.new([ 0, 1, 0.3, 0], [ 0.01, rel ,1], [1,-1]);
|
|
|
|
sig = sig * EnvGen.kr(env, doneAction:2);
|
2023-11-15 13:43:06 +01:00
|
|
|
sig = Pan2.ar(sig, FSinOsc.kr(panfreq, modphase));
|
|
|
|
//sig = PanAz.ar(4, sig, LFSaw.kr(panfreq, modphase), width: 1, orientation: 0);
|
2023-10-19 23:04:42 +02:00
|
|
|
sig = sig * amp;
|
|
|
|
Out.ar(0, sig);
|
|
|
|
}).add;
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-10-21 10:10:10 +02:00
|
|
|
|
2023-09-24 22:42:30 +02:00
|
|
|
|
|
|
|
//start the slewing synth /////////////////////////////
|
2023-10-19 23:04:42 +02:00
|
|
|
|
|
|
|
//~sslew1 = Synth(\sslew,[\out,0,\freq,220,\amp,0,\slewrate,1000]);
|
2023-10-17 16:58:11 +02:00
|
|
|
//~sslew1.map(\freq, ~ctrlBus[0]); // map control bus to freq parameter
|
|
|
|
//o = OSCFunc({ |msg| msg.postln }, '/tr', s.addr);
|
2023-09-24 22:42:30 +02:00
|
|
|
|
2023-10-21 10:10:10 +02:00
|
|
|
//~ce = Array.new(maxSize: 20);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-10-20 01:54:56 +02:00
|
|
|
// first synth test /////////////////////
|
|
|
|
|
|
|
|
/* ( p = Pbind(\instrument, \sgrain,
|
2023-10-19 23:04:42 +02:00
|
|
|
\freq, Pseq(~freq.round(30),1),
|
|
|
|
\atk, Pseq(~atk,1).poll,
|
2023-09-24 22:42:30 +02:00
|
|
|
\dcy, Pseq(~dcy,1),
|
|
|
|
\pan, Pseq([0,1], inf),
|
|
|
|
\dur, Pseq(~dur,1),
|
2023-10-19 23:04:42 +02:00
|
|
|
\amp, Pseq(~level, 1),
|
|
|
|
\date, Pseq(~date, 1 )
|
|
|
|
).collect{ arg i; i.postln; });*/
|
|
|
|
|
2023-10-20 01:54:56 +02:00
|
|
|
// initial settings .....................................
|
|
|
|
|
2023-10-19 23:04:42 +02:00
|
|
|
~gr = Group.new;
|
|
|
|
~pitchset = [20,40,60,80].midicps;
|
|
|
|
|
2023-10-20 01:54:56 +02:00
|
|
|
// initial settings .....................................
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-10-21 10:10:10 +02:00
|
|
|
~dur = PatternProxy.new; // duration
|
|
|
|
~deg = PatternProxy.new; // carrier frequency
|
|
|
|
~mfr = PatternProxy.new; // modulation frequency
|
|
|
|
~pmi = PatternProxy.new; // pulse modulation index
|
|
|
|
~mph = PatternProxy.new; // modulation phase
|
|
|
|
~pfr = PatternProxy.new; // pan frequency
|
|
|
|
~oct = PatternProxy.new; // octave
|
|
|
|
~amp = PatternProxy.new; // amplitude
|
|
|
|
~sca = PatternProxy.new; // scale
|
|
|
|
~rel = PatternProxy.new; // release
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(2,2.5), rrand(0.98,0.99)).mirror,inf);
|
2023-10-21 10:10:10 +02:00
|
|
|
~deg.source = Prand([0,5,7],inf); // carrier frequency
|
|
|
|
~mfr.source = Pexprand(0.1,3, inf); // modulation frequency
|
|
|
|
~pmi.source = Pexprand(0.5,3, inf); // phase modulation index
|
|
|
|
~mph.source = Pwhite(-1,1, inf); // modulation phase
|
|
|
|
~pfr.source = Pexprand(0.1,1.5, inf); // pan freq
|
|
|
|
|
2023-10-19 23:04:42 +02:00
|
|
|
~oct.source = Prand([2,3,4],inf);
|
|
|
|
~voc.source = 4;
|
2023-11-15 13:43:06 +01:00
|
|
|
~amp.source = Pwhite(0.001, 0.02,inf);
|
2023-10-19 23:04:42 +02:00
|
|
|
~sca.source = Scale.harmonicMinor;
|
|
|
|
~rel.source = Pexprand(1.5,3.35, inf);
|
|
|
|
|
2023-10-20 01:54:56 +02:00
|
|
|
// initial settings .....................................
|
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
Pdef(\c, Pspawner({ | sp | 3.do { | i | sp.par( // 4 do for installation version
|
2023-10-19 23:04:42 +02:00
|
|
|
Pbind( *[
|
|
|
|
\instrument, \sine,
|
2023-10-21 10:10:10 +02:00
|
|
|
\dur, ~dur,
|
|
|
|
\scale, ~sca,
|
|
|
|
\degree, ~deg,
|
|
|
|
\octave, ~oct,
|
|
|
|
\modfreq, ~mfr,
|
|
|
|
\pmindex, ~pmi,
|
|
|
|
\modphase, ~mph,
|
2023-10-20 01:54:56 +02:00
|
|
|
//\freq, exprand(~pitchset[0],~pitchset[0]*80).round(100),
|
2023-10-21 10:10:10 +02:00
|
|
|
\panfreq, ~pfr,
|
|
|
|
\amp, ~amp,
|
|
|
|
\panphase, Pwhite(-1,1, inf),
|
|
|
|
\rel, ~rel,
|
|
|
|
\group, ~gr
|
2023-10-19 23:04:42 +02:00
|
|
|
]);
|
2023-10-21 10:10:10 +02:00
|
|
|
); sp.wait(10); }}); ).play;
|
2023-09-24 22:42:30 +02:00
|
|
|
|
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
s.sync;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
( // normalize data ranges or not ///////////////////////////
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~temperature=~data[2];//.asFloat; //.normalize(0, 11);
|
|
|
|
~dateTime=~data[0];
|
|
|
|
~windDirection=~data[13];
|
|
|
|
~windGust=~data[14]; // m/s
|
|
|
|
~windNorth=~data[16]; // m/s
|
|
|
|
~windEast=~data[18]; // m/s
|
2023-10-23 00:44:14 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
// data player ////////////////////////////////////////////
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~time = Routine {
|
|
|
|
arg inval; var t = 0;
|
|
|
|
// itterate through data at a fixed rate // data point every 15mins
|
|
|
|
// 4sec = 1 hr 24 * 96seconds = 1 day // 9.6 seconds = 1 day @ 0.1.wait
|
|
|
|
loop {
|
|
|
|
t = (t + 1) % (~csvFile.size - 1);
|
|
|
|
postln( t +
|
|
|
|
" " + ~dateTime[t] +
|
|
|
|
"C:" ++ ~temperature[t] +
|
|
|
|
"Wind Dir: " + ~windDirection[t] +
|
|
|
|
"Gust:" ++ ~windGust[t] +
|
|
|
|
"North: " + ~windNorth[t] +
|
|
|
|
"East: " + ~windEast[t]);
|
|
|
|
0.1.wait;
|
|
|
|
}}.play();
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
// temporal structure of wind controled layer ///////////
|
|
|
|
// ......................................................
|
|
|
|
// conditional logic goes here //////////////////////////
|
|
|
|
|
|
|
|
r = Routine { arg inval; var i = 0;
|
|
|
|
|
|
|
|
loop {
|
|
|
|
i = i + 1; // this loop itterator is not used?
|
|
|
|
postln(t); // only t the ~time counter
|
|
|
|
|
|
|
|
postf("beats: % seconds: % time: % \n",
|
|
|
|
thisThread.beats, thisThread.seconds, Main.elapsedTime );
|
2023-10-21 10:10:10 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~sca.source = Scale.harmonicMinor;
|
|
|
|
~deg.source = Prand([0,1,2,3,5,7],inf);
|
|
|
|
~oct.source = Prand([4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(2,4), rrand(0.96,0.97)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(2.1,5.5, inf);
|
|
|
|
~amp.source = Pwhite(0.05, 0.2,inf);
|
2023-10-21 10:10:10 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
|
|
|
postln("line 2");
|
|
|
|
~deg.source = Prand([0,3,5,7],inf);
|
|
|
|
~oct.source = Prand([3,4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(1,2.5), rrand(0.96,0.97)).mirror,inf);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-21 10:10:10 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 3");
|
|
|
|
~deg.source = Prand([0,3,5],inf);
|
|
|
|
~oct.source = Prand([3,4,5],inf);
|
|
|
|
~rel.source = Pexprand(1,3, inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(1,1.5), rrand(0.96,0.97)).mirror,inf);
|
2023-10-21 10:10:10 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 4");
|
|
|
|
~sca.source = Scale.chromatic;
|
|
|
|
~deg.source = Prand([0,2,4,6,8,10],inf);
|
|
|
|
~oct.source = Prand([3,4,5],inf);
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 5");
|
|
|
|
~deg.source = Prand([0,2,4,6,8,10],inf);
|
|
|
|
~oct.source = Prand([3,4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(0.5,0.6), rrand(0.98,0.99)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(0.5,3, inf);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 6");
|
|
|
|
~deg.source = Prand([0,7,5],inf);
|
|
|
|
~oct.source = Prand([2,3,4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(1.5,3.6), rrand(0.98,0.99)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(2,4, inf);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~sca.source = Scale.harmonicMinor;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 7");
|
|
|
|
~deg.source = Prand([0,7,5],inf);
|
|
|
|
~oct.source = Prand([2,3,4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(1,1.5), rrand(0.98,0.99)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(2,6, inf);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
50.wait;
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 8");
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
~deg.source = Prand([0,5,7,9],inf);
|
|
|
|
~oct.source = Prand([4,5,6],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(2,3.5), rrand(0.98,0.99)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(6,12, inf);
|
|
|
|
|
|
|
|
50.wait;
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
postln("line 9");
|
|
|
|
~deg.source = Prand([1,6,8,10],inf);
|
|
|
|
~oct.source = Prand([3, 4,5],inf);
|
|
|
|
~dur.source = Pseq(Array.geom(30, rrand(3,4.5), rrand(0.98,0.99)).mirror,inf);
|
|
|
|
~rel.source = Pexprand(4,12, inf);
|
|
|
|
|
|
|
|
50.wait;
|
2023-10-20 01:54:56 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
};
|
|
|
|
}.play;
|
2023-10-20 01:54:56 +02:00
|
|
|
);
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
}; // closes s.waitForBoot .....................................
|
2023-10-19 23:04:42 +02:00
|
|
|
|
2023-11-15 13:43:06 +01:00
|
|
|
r.stop;
|
|
|
|
~time.stop;
|