good cop / naughty cop

naughty adventures in electroacoustic music

code ‘Piece for Two Bicycle Wheels, Two Guitars and Two Beamers’

// Supercollider code for master computer

(

SynthDef(\bikewheelVerb, { arg out = 0, analyOut, in, mix=0.35, room=0.7, damp=0.8, amp=1.0, pan = 0;

var sig;

sig = In.ar(in, 2);

sig = FreeVerb2.ar(sig[0], sig[1],mix,room,damp,amp);

Out.ar(out, Pan2.ar(sig, pan));

Out.ar(analyOut, Pan2.ar(sig, pan));

}).store;

 

SynthDef(\analysis, { arg in, ampvalOut, pitchvalOut;

var sig, ampFollow, freq, hasFreq;

sig = In.ar(in, 2);

ampFollow = Amplitude.kr(sig, 0.001, 0.01);

# freq, hasFreq = Pitch.kr(sig);

Out.kr(ampvalOut, ampFollow);

Out.kr(pitchvalOut, freq);

}).store;

 

 

SynthDef(\bikewheelDelay, { arg in, hpFreq = 717, amp = 0.25, cutfreq = 0.2, out = 0,del = 0.1, maxdel = 1.0, decay = 2.0;

var sig;

sig = In.ar(in ,2);

3.do({

sig = AllpassC.ar(sig, maxdel, del, decay, 0.5, sig);

});

 

sig = MoogFF.ar(sig, LFNoise1.kr(cutfreq).range(300, 3000), 1.5);

 

sig = HPF.ar(sig, hpFreq, 15, sig );

 

Out.ar(out, Pan2.ar(Limiter.ar(sig * amp, 1.0), LFNoise2.kr(0.5).range(-0.5, 0.5)));

}).store;

 

SynthDef(\bikeguitarFFTBUF, {

arg

in = 1, out1 = 0,out2 = 0,out3 = 0, //in & outputs

fftbufnum,bufnum, trate = 0,

amp = 0.5, ampOut2 = 0.5, ampOut3 = 0.5,

gate=1, envgate = 1,

phasorGate = 0, ringGate = 0, ringfreq = 10,

stresonGate = 0, stresonMax = 377,

amount = 0.5, distGate = 0,

eqFreq = 3000, rq = 0.6, db = 30,

trateDivider = 1;

 

var sig1, chain, onsets, thresh, bufrd1,bufrd2,bufrd3, sr,

trig1,trig2,trig3, env,mod,

amCoef;

 

env = EnvGen.kr(Env.asr(0.5,1.0,3.0),envgate, doneAction: 0);

 

sig1 = Limiter.ar(SoundIn.ar(in), 1) * gate;

thresh = 0.4;

 

chain = FFT(fftbufnum,sig1);

onsets = Onsets.kr(chain, thresh);

RecordBuf.ar(sig1, bufnum, loop:0, trigger: onsets);

 

trig1 = Impulse.kr(trate * trateDivider, 0.1);

trig2 = Impulse.kr( (trate*0.5) * trateDivider, 0.5);

trig3 = Impulse.kr( (trate*0.25) * trateDivider, 1.0);

sr = BufRateScale.kr(bufnum);

 

bufrd1 = BufRd.ar(1, bufnum, Phasor.ar(trig1, BufRateScale.kr(bufnum),0,BufFrames.kr(bufnum)),loop:1,interpolation:1);

bufrd1 = bufrd1 * env;

 

 

//chorus

bufrd2 = BufRd.ar(1, bufnum, Phasor.ar(trig2, BufRateScale.kr(bufnum),0,BufFrames.kr(bufnum)),loop:1,interpolation:1);

//bufrd2 = Streson.ar(bufrd2, LinExp.kr(LFCub.kr(0.1, 0.5 * pi), -1, 1, 280, stresonMax).reciprocal,0.9, stresonGate);

bufrd2 = bufrd2.distort * env;

 

//ringmod

bufrd3 = BufRd.ar(1, bufnum, Phasor.ar(trig3, BufRateScale.kr(bufnum),0,BufFrames.kr(bufnum)),loop:1,interpolation:1);

mod = SinOsc.ar(ringfreq);

//bufrd3 = ((bufrd3 * bufrd3 * mod) – (bufrd3 * mod * mod));

bufrd3 = bufrd3 * env;

 

amount = amount * distGate;

amCoef = 2*amount/(1-amount);

 

bufrd1 = MidEQ.ar(bufrd1, eqFreq, rq, db, 0.5);

bufrd2 = MidEQ.ar(bufrd2, eqFreq, rq, db, 0.5);

bufrd3 = MidEQ.ar(bufrd3, eqFreq, rq, db, 0.5);

 

bufrd1 = (bufrd1 * (1 – ringGate) ) + (bufrd2 ring4: Gendy1.ar(5) * ringGate);

bufrd2 = (bufrd2  * (1 – ringGate) ) + (bufrd2 ring4: Gendy1.ar(10)  * ringGate);

bufrd3 = (bufrd3  * (1 – ringGate) ) + (bufrd3 ring4: Gendy1.ar(50)  * ringGate);

 

 

 

Out.ar(out1, Pan2.ar(Limiter.ar(bufrd1 * amp,1.0), LFNoise1.kr(0.4).range(-0.5,0.5) ));

Out.ar(out2, Pan2.ar(Limiter.ar(bufrd2 *ampOut2,1.0), FSinOsc.kr(0.2).range(-1.0,0.0) ));

Out.ar(out3, Pan2.ar(Limiter.ar(bufrd3*ampOut3, 1.0), FSinOsc.kr(0.2).range(0.0, 1.0) ));

}).store;

)

 

(

p = MyArduino.new(“/dev/tty.usbserial-A700fiBU”,

baudrate: 115200 );

 

~git1buf = Buffer.alloc(s, 44100 * 5, 1);

~git1fft = Buffer.alloc(s, 512 * 1);

 

 

)

 

(

var trateSpec, delaySpec, eqSpec,

ampFollow = 0, pitchFollow,

minTime, maxTime, magnetAmount = 4,

mappedTime1 = 100,

number1 = 100,

delMappedTime1,

synthState1 = 1,

movieState = 0,

onoffState = 0,

whatMoviesState1 = 0,

sceneState = 1;

 

 

minTime = 300 / magnetAmount;

maxTime = 6000 / 4;

 

~synthGroup = Group.new;

~effectGroup1 = Group.after(~synthGroup);

~effectGroup2 = Group.after(~effectGroup1);

~effectGroup3 = Group.after(~effectGroup2);

~analyGroup = Group.after(~effectGroup3);

 

/// buses guitar1

~reverbBus1 = Bus.audio(s, 2);

~delayBus1 = Bus.audio(s, 2);

~analyBus1 = Bus.audio(s, 2);

~ampOutBus = Bus.audio(s, 1);

~pitchOutBus = Bus.audio(s, 1);

 

trateSpec = [75, 0.01, \exp].asSpec;

delaySpec = [100, 0.01, \exp].asSpec;

eqSpec = [10, 9000, \linear].asSpec;

 

// guitar 1

~input1Synth = Synth(\bikeguitarFFTBUF, [\in, 0,\out1, ~reverbBus1, \out2, ~delayBus1, \out3, ~delayBus1, \bufnum, ~git1buf, \fftbufnum, ~git1fft,\trateDivider,1,\gate,1], ~synthGroup, \addToHead);

~delSynth1 = Synth(\bikewheelDelay, [\amp, 0.15, \in, ~delayBus1, \out, ~reverbBus1], ~effectGroup1, \addToHead);

~reverbSynth1 = Synth(\bikewheelVerb, [\in, ~reverbBus1, \out, 0, \analyOut, ~analyBus1 ], ~effectGroup3, \addToHead);

~analysisSynth = Synth(\analysis, [\in, ~analyBus1, \ampvalOut, ~ampOutBus, \pitchvalOut, ~pitchOutBus ], ~analyGroup, \addToHead);

 

 

// ISADORA net address

~izzy = NetAddr(“127.0.0.1”, 3000);

 

//MAC MINI address

~macMini = NetAddr(“169.254.240.190”, 57120);

 

// guitar 1

 

e = Task({

 

inf.do({ arg i;

 

~input1Synth.set(\trate, mappedTime1);

 

~izzy.sendMsg(“/isadora/10”, mappedTime1 / 7.5);

mappedTime1 = mappedTime1 – 0.1;

 

 

 

if ( mappedTime1 < 0.01 , { e.stop; ~input1Synth.set(\envgate, 0); synthState1 = 0;

 

if ( movieState == 1, { movieState = 0});

});

 

0.005.wait;

});

});

 

p.action = { arg data;

 

number1 = (data * [256, 1]).sum;

 

if ( number1 != 10, {

 

e.stop;

//(“number:”+number1).postln;

mappedTime1 = trateSpec.map( (number1 – minTime) / maxTime );

 

e.start;

 

switch(synthState1,

0, { if ( number1 < maxTime, { ~input1Synth.set(\envgate, 1); synthState1 = 1; }); },

1, { if ( number1 > maxTime, { ~input1Synth.set(\envgate, 0); synthState1 = 0; }); }

);

 

});

};

 

//ISADORA connection

 

~analysisTask1 = Task({

 

inf.do({

 

~ampOutBus.get({ arg val; ampFollow = val});

//ampFollow.postln;

 

~pitchOutBus.get({ arg val; pitchFollow = val});

 

 

if ( ampFollow > 0.01, {

 

~izzy.sendMsg(“/isadora/11”, ampFollow);

~izzy.sendMsg(“/isadora/12”, pitchFollow );

 

//pitchFollow.postln;

},

{ ~izzy.sendMsg(“/isadora/11”, 0);

 

 

});

 

0.1.wait;

});

}).play;

 

~movieonoffTask = Task({

inf.do({

if ( ampFollow > 0.01, {

if ( onoffState == 0, {

~izzy.sendMsg(“/isadora/14”, 1); onoffState = 1; }); },

{

if ( onoffState == 1, {

~izzy.sendMsg(“/isadora/14”, 0); onoffState = 0; }); });

0.01.wait;

});

}).play;

 

// scenes changing

 

~sceneChangeTask = Task({

 

15.do({ arg i; var waitingTime = 20, totalTime;

 

sceneState = i + 1;

 

case

// DARKNESS

{ i == 0 } {

 

waitingTime = 30 + 30.rand;

 

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState);

 

(“scene 1”).postln;

}

// NORMAL PLAYBACK

{ i == 1 } {

//totalTime = waitingTime;

waitingTime = 30 + 60.rand;

 

 

~macMini.sendMsg(“/sceneChange”, sceneState);

~izzy.sendMsg(“/isadora/15”, sceneState);

 

(“scene 2”).postln;  }

// DARKNESS

{ i == 2 } {

//totalTime = totalTime + waitingTime;

waitingTime = 30 + 20.rand;

 

~macMini.sendMsg(“/sceneChange”, sceneState);

~izzy.sendMsg(“/isadora/15”, sceneState);

 

(“scene 3”).postln;  }

// NORMAL PLAYBACK

{ i == 3 } {

//totalTime = totalTime + waitingTime;

waitingTime = 45 + 60.rand;

 

 

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 4”).postln;   }

// DARKNESS

{ i == 4 } {

//totalTime = totalTime + waitingTime;

waitingTime = 30 + 30.rand;

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 5”).postln; }

// ZOOMING

{ i == 5 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 20.rand;

 

~input1Synth.set(\ringGate, 0.25);

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 6”).postln; }

// DARKNESS

{ i == 6 } {

//totalTime = totalTime + waitingTime;

waitingTime = 30 + 20.rand;

 

~input1Synth.set(\ringGate, 0);

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 7”).postln; }

// OTHER IMAGES – NORMAL PLAYBACK

{ i == 7 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 60.rand;

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 8”).postln; }

// DARKNESS

{ i == 8 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 60.rand;

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 9”).postln; }

// ZOOMING

{ i == 9 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 60.rand;

 

~input1Synth.set(\ringGate, 0.5);

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 10”).postln; }

// DARKNESS

{ i == 10 } {

//totalTime = totalTime + waitingTime;

waitingTime = 20 + 30.rand;

 

 

~input1Synth.set(\ringGate, 0);

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 11”).postln; }

 

// MIX VIDEO IMAGES / CHOP PIXELS – SOUND ALSO CHANGES

{ i == 11 } {

//totalTime = totalTime + waitingTime;

 

~input1Synth.set(\ringGate, 0.5);

 

waitingTime = 60 + 60.rand;

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 12”).postln; }

// LIMIT ZOOM

{ i == 12 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 60.rand;

 

~input1Synth.set(\ringGate, 0.6);

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

(“scene 13”).postln;  }

// RADICAL PROCESSING

{ i == 13 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 60.rand;

 

~input1Synth.set(\ringGate, 0.7);

~macMini.sendMsg(“/sceneChange”, sceneState);

~izzy.sendMsg(“/isadora/15”, sceneState);

 

(“scene 14”).postln; }

 

// END

{ i == 14 } {

//totalTime = totalTime + waitingTime;

waitingTime = 60 + 30.rand;

 

~input1Synth.set(\ringGate, 0);

 

~macMini.sendMsg(“/sceneChange”, sceneState );

~izzy.sendMsg(“/isadora/15”, sceneState );

 

//(“TotalTime:”)++totalTime.postln;

(“end”).postln; };

 

waitingTime.wait;

 

 

 

 

 

});

});

 

// nanoKontrol for guitar 1

~tratedivResponder = CCResponder({  arg src, chan, num, value;

var eqSetting;

 

case

{ num == 33 } { ~input1Synth.set(\trateDivider, 0.2, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 1.0, \del, 3.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.9, \mix, 0.7);

}

{ num == 34 } { ~input1Synth.set(\trateDivider, 0.4, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 0.8, \del, 2.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.7, \mix, 0.6);

}

{ num == 35 } { ~input1Synth.set(\trateDivider, 0.6, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp,0.6, \del, 1.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.5, \mix, 0.5);

}

{ num == 36 } { ~input1Synth.set(\trateDivider, 0.8, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 0.4, \del, 0.5, \decay, 3.0);

~reverbSynth1.set(\room, 0.3, \mix, 0.4);

}

{ num == 37 } { ~input1Synth.set(\trateDivider, 1.0, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1 );

}

 

{ num == 38 } { ~input1Synth.set(\trateDivider, 2.5,\out2,~reverbBus1,\out3,~reverbBus1 );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 39 } { ~input1Synth.set(\trateDivider, 5.0,\out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 40 } { ~input1Synth.set(\trateDivider, 7.5, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 41 } { ~input1Synth.set(\trateDivider, 10.0, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

};

 

if ( num == 14, { ~input1Synth.set(\eqFreq, eqSpec.map( value/127 ) );  });

if ( num == 15, { ~input1Synth.set(\rq, value/127 + 0.01 ); });

if ( num == 16, { ~input1Synth.set(\db, ( value/127) * 40 );   });

 

if ( num == 17, { eqSetting = eqSpec.map( value/127);  ~delSynth1.set(\hpFreq, eqSetting );  });

 

if ( num == 45, {

if ( value == 127, { ~sceneChangeTask.play; }, { ~sceneChangeTask.stop; });

});

 

},

nil,nil,nil,nil);

 

 

)

p.close;

/// Supercollider code for slave computer

(

p = MyArduino.new(“/dev/tty.usbserial-A700fk0V”,

baudrate: 115200 );

 

~git1buf = Buffer.alloc(s, 44100 * 5, 1);

~git1fft = Buffer.alloc(s, 512 * 1);

 

)

(

var trateSpec, delaySpec, eqSpec,

ampFollow = 0, pitchFollow,

minTime, maxTime, magnetAmount = 4,

mappedTime1 = 100,

number1 = 100,

synthState1 = 1,

movieState = 0,

onoffState = 0,

whatMoviesState1 = 0,

sceneState = 1;

 

 

 

minTime = 300 / magnetAmount;

maxTime = 6000 / 4;

 

~synthGroup = Group.new;

~effectGroup1 = Group.after(~synthGroup);

~effectGroup2 = Group.after(~effectGroup1);

~effectGroup3 = Group.after(~effectGroup2);

~analyGroup = Group.after(~effectGroup3);

 

/// buses guitar1

~reverbBus1 = Bus.audio(s, 2);

~delayBus1 = Bus.audio(s, 2);

~analyBus1 = Bus.audio(s, 2);

~ampOutBus = Bus.audio(s, 1);

~pitchOutBus = Bus.audio(s, 1);

 

 

trateSpec = [75, 0.01, \exp].asSpec;

delaySpec = [100, 0.01, \exp].asSpec;

eqSpec = [10, 9000, \linear].asSpec;

 

// guitar 1

~input1Synth = Synth(\bikeguitarFFTBUF, [\in, 1,\out1, ~reverbBus1, \out2, ~delayBus1, \out3, ~delayBus1, \bufnum, ~git1buf, \fftbufnum, ~git1fft,\trateDivider,1,\gate,1], ~synthGroup, \addToHead);

~delSynth1 = Synth(\bikewheelDelay, [\amp, 0.15, \in, ~delayBus1, \out, ~reverbBus1], ~effectGroup1, \addToHead);

~reverbSynth1 = Synth(\bikewheelVerb, [\in, ~reverbBus1, \out, 0, \analyOut, ~analyBus1 ], ~effectGroup3, \addToHead);

~analysisSynth = Synth(\analysis, [\in, ~analyBus1, \ampvalOut, ~ampOutBus, \pitchvalOut, ~pitchOutBus ], ~analyGroup, \addToHead);

 

 

 

// nanoKontrol for guitar 1

~tratedivResponder = CCResponder({  arg src, chan, num, value;

var eqSetting;

 

case

{ num == 33 } { ~input1Synth.set(\trateDivider, 0.2, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 1.0, \del, 3.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.9, \mix, 0.7);

}

{ num == 34 } { ~input1Synth.set(\trateDivider, 0.4, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 0.8, \del, 2.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.7, \mix, 0.6);

}

{ num == 35 } { ~input1Synth.set(\trateDivider, 0.6, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp,0.6, \del, 1.0, \decay, 3.0);

~reverbSynth1.set(\room, 0.5, \mix, 0.5);

}

{ num == 36 } { ~input1Synth.set(\trateDivider, 0.8, \out2,~delayBus1,\out3,~delayBus1   );

~delSynth1.set(\amp, 0.4, \del, 0.5, \decay, 3.0);

~reverbSynth1.set(\room, 0.3, \mix, 0.4);

}

{ num == 37 } { ~input1Synth.set(\trateDivider, 1.0, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 38 } { ~input1Synth.set(\trateDivider, 2.5,\out2,~reverbBus1,\out3,~reverbBus1 );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 39 } { ~input1Synth.set(\trateDivider, 5.0,\out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 40 } { ~input1Synth.set(\trateDivider, 7.5, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

}

 

{ num == 41 } { ~input1Synth.set(\trateDivider, 10.0, \out2,~reverbBus1,\out3,~reverbBus1  );

~reverbSynth1.set(\room, 0.1, \mix, 0.1);

};

 

if ( num == 14, { ~input1Synth.set(\eqFreq, eqSpec.map( value/127 ) );  });

if ( num == 15, { ~input1Synth.set(\rq, value/127 + 0.01 ); });

if ( num == 16, { ~input1Synth.set(\db, ( value/127) * 40 );   });

 

if ( num == 17, { eqSetting = eqSpec.map( value/127);  ~delSynth1.set(\hpFreq, eqSetting ); eqSetting.postln;  });

 

if ( num == 45, {

if ( value == 127, { ~sceneChangeTask.play; }, { ~sceneChangeTask.stop; });

});

 

},

nil,nil,nil,nil);

 

 

// ISADORA net address

~izzy = NetAddr(“127.0.0.1”, 3000);

 

 

// guitar 1

 

e = Task({

 

inf.do({ arg i;

 

~input1Synth.set(\trate, mappedTime1);

 

~izzy.sendMsg(“/isadora/10”, mappedTime1 / 7.5);

mappedTime1 = mappedTime1 – 0.1;

 

 

if ( mappedTime1 < 0.01 , { e.stop; ~input1Synth.set(\envgate, 0); synthState1 = 0;

 

if ( movieState == 1, { movieState = 0});

});

 

0.01.wait;

});

});

 

p.action = { arg data;

 

number1 = (data * [256, 1]).sum;

 

if ( number1 != 10, {

 

e.stop;

//(“number:”+number1).postln;

mappedTime1 = trateSpec.map( (number1 – minTime) / maxTime );

 

e.start;

 

switch(synthState1,

0, { if ( number1 < maxTime, { ~input1Synth.set(\envgate, 1); synthState1 = 1; }); },

1, { if ( number1 > maxTime, { ~input1Synth.set(\envgate, 0); synthState1 = 0; }); }

);

 

});

};

 

//ISADORA connection

 

~analysisTask1 = Task({

 

inf.do({

 

~ampOutBus.get({ arg val; ampFollow = val});

//ampFollow.postln;

 

~pitchOutBus.get({ arg val; pitchFollow = val});

 

 

if ( ampFollow > 0.01, {

 

~izzy.sendMsg(“/isadora/11”, ampFollow);

~izzy.sendMsg(“/isadora/12”, pitchFollow );

 

//pitchFollow.postln;

},

{ ~izzy.sendMsg(“/isadora/11”, 0);

 

 

 

});

 

0.1.wait;

});

}).play;

 

~movieonoffTask = Task({

inf.do({

if ( ampFollow > 0.01, {

if ( onoffState == 0, {

~izzy.sendMsg(“/isadora/14”, 1); onoffState = 1; }); },

{

if ( onoffState == 1, {

~izzy.sendMsg(“/isadora/14”, 0); onoffState = 0; }); });

0.1.wait;

});

}).play;

 

// scenes changing

 

~sceneChangeResponder =

OSCresponderNode(nil, ‘/sceneChange’, { |t, r, msg|

 

 

msg[1].postln;

 

case

{ msg[1] == 1 } { sceneState = 1;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;

 

}

{ msg[1] == 2 } { sceneState = 2;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;

}

{ msg[1] == 3 } { sceneState = 3;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;    }

{ msg[1] == 4 } { sceneState = 4;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;    }

 

{ msg[1] == 5} { sceneState = 5;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 6 } { sceneState = 6;

 

~input1Synth.set(\ringGate, 0.25);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 7 } { sceneState = 7;

 

~input1Synth.set(\ringGate, 0);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;  }

 

{ msg[1] == 8 } { sceneState = 8;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 9 } { sceneState = 9;

 

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 10 } { sceneState = 10;

 

~input1Synth.set(\ringGate, 0.25);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;  }

 

{ msg[1] == 11 } { sceneState = 11;

 

~input1Synth.set(\ringGate, 0);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 12 } { sceneState = 12;

 

~input1Synth.set(\ringGate, 0.5);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 13 } { sceneState = 13;

 

~input1Synth.set(\ringGate, 0.6);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;  }

 

{ msg[1] == 14 } { sceneState = 14;

 

~input1Synth.set(\ringGate, 0.7);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

{ msg[1] == 15 } { sceneState = 15;

 

~input1Synth.set(\ringGate, 0);

~izzy.sendMsg(“/isadora/15”, sceneState);

(“scene”)++sceneState.postln;   }

 

 

}).add;

 

)

 

 

p.close;

 

// Arduino code
// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int timer1 = 0;
int timer2 = 0;
int timeTrig1; // time between triggers
int timeTrig2;
int state = 0;

#define ESC_CHAR ‘\\’
#define DEL_CHAR ‘\n’
#define CR ‘\r’

void sendData( char *p, int size) {
//Serial.print(CR, BYTE);
for(int i = 0; i < size; i++) slip(p[i]);
Serial.print(DEL_CHAR, BYTE);
}

void slip(char c) {
if((c==ESC_CHAR)||(c==DEL_CHAR)||(c==CR))
Serial.print(ESC_CHAR, BYTE);
Serial.print(c, BYTE);
}

 

void setup() {

// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// initialize serial communication:
Serial.begin(115200);
}

void loop(){
// only send when something happens to the button
if ( buttonState != digitalRead(buttonPin)) {

buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:

state = state + 1;
//Serial.println(state);

switch (state) {
case 0:
//state = state + 1;
break;
case 1: timer1 = millis();
timeTrig1 = timer1 – timer2;
//state = state + 1;
//Serial.println(map(timeTrig1, 350, 5000, 0, 255), BYTE);

if ( timeTrig1 > 75 ) {

char timeInBytesA[2];

timeInBytesA[0] = timeTrig1/256;
timeInBytesA[1] = timeTrig1%256;

sendData( timeInBytesA, 2);

}
else {

char timeInBytesA[2];

timeInBytesA[0] = 10/256;
timeInBytesA[1] = 10%256;

sendData(timeInBytesA, 2);

};

break;
case 2: timer2 = millis();
timeTrig2 = timer2 – timer1;
//Serial.println(map(timeTrig2, 350, 5000, 0, 255), BYTE);
if ( timeTrig2 > 75 ) {

char timeInBytesB[2];

timeInBytesB[0] = timeTrig2/256;
timeInBytesB[1] = timeTrig2%256;

sendData(timeInBytesB, 2);

}
else {
char timeInBytesB[2];

timeInBytesB[0] = 10/256;
timeInBytesB[1] = 10%256;

sendData(timeInBytesB, 2);

};
state = 0;
break;
default:
Serial.println(“shit”);
}

digitalWrite(ledPin, HIGH);

}
else {
// turn LED off:

digitalWrite(ledPin, LOW);

}
}

}

 

Advertisements