accelerometer reintegrated

master
Rob Canning 2022-12-06 00:40:39 +01:00
parent 9a51a20a4f
commit 9505ba4a52
1 changed files with 46 additions and 19 deletions

63
gtr.scd
View File

@ -103,9 +103,14 @@ SynthDef.new(\mic, {
}).add; }).add;
SynthDef.new(\ptr, { SynthDef.new(\ptr, {
arg out=0, buf=0; arg out=0, buf=0, ptrMode=0;
var sig; var sig;
sig = Phasor.ar(0, BufRateScale.kr(buf), 0, BufFrames.kr(buf)); sig = Select.ar(ptrMode, [
Phasor.ar(0, BufRateScale.kr(buf), 0, BufFrames.kr(buf)),
LFNoise1.ar(100).exprange(10000, 1001)
//LFNoise1.ar(100).exprange(1/BufFrames.kr(buf), BufFrames.kr(buf))
]);
Out.ar(out, sig); Out.ar(out, sig);
}).add; }).add;
@ -122,7 +127,7 @@ SynthDef.new(\rec, {
SynthDef("recBuf",{ SynthDef("recBuf",{
arg micIn=0, out=0, ptrIn=0, bufnum=0, t_trig=0, l=0, overdub=0; arg micIn=0, out=0, ptrIn=0, bufnum=0, t_trig=0, l=0, overdub=0;
var sig, ptr, chain, onsets; var sig, ptr, chain, onsets;
sig = SoundIn.ar(micIn, 1); sig = In.ar(micIn, 1);
ptr = In.ar(ptrIn, 1); ptr = In.ar(ptrIn, 1);
// Onsets // Onsets
@ -196,8 +201,8 @@ r = Synth(\recBuf, [\ptrIn, ~ptrBus, \micIn, ~micBus, \buf, b, \t_trig, 0], ~re
Synth(\mic, [\in, 0, \out, ~micBus], ~micGrp); Synth(\mic, [\in, 0, \out, ~micBus], ~micGrp);
Synth(\ptr, [\buf, b, \out, ~ptrBus], ~ptrGrp); ~pointer = Synth(\ptr, [\buf, b, \out, ~ptrBus], ~ptrGrp);
Synth(\rec, [\ptrIn, ~ptrBus, \micIn, ~micBus, \buf, b], ~recGrp); //.Synth(\rec, [\ptrIn, ~ptrBus, \micIn, ~micBus, \buf, b], ~recGrp);
b.zero; b.zero;
@ -244,13 +249,13 @@ OSCFunc.trace(false); // Turn posting off
( // ---------------------------------------------------- ( // ----------------------------------------------------
~overdubMode= 0; ~pitchMode = 0; ~posMode = 0; ~impulseMode = 0; ~overdubMode= 0; ~pitchMode = 0; ~posMode = 0; ~impulseMode = 0;
~gdurMode=0; ~gpanMode=0; ~channelmode=0; ~gdurMode=0; ~gpanMode=0; ~channelmode=0; ~instrPanMode=0;
~instrPanMode=0;
/*
~btnstate = []; ~btnstate = [];
~btnsA = []; ~btnsA = [];
~btnsB = []; ~btnsB = [];
~btnsC = []; ~btnsC = [];*/
~btn0val = -1; ~btn1val = -1; ~btn2val = -1; ~btn3val = -1; ~btn0val = -1; ~btn1val = -1; ~btn2val = -1; ~btn3val = -1;
~btn4val = -1; ~btn5val = -1; ~btn6val = -1; ~btn7val = -1; ~btn4val = -1; ~btn5val = -1; ~btn6val = -1; ~btn7val = -1;
@ -259,6 +264,7 @@ OSCFunc.trace(false); // Turn posting off
~btn9val = -1; ~btn10val = -1; ~btn11val = -1; ~btn12val = -1; ~btn9val = -1; ~btn10val = -1; ~btn11val = -1; ~btn12val = -1;
~btn13val = -1; ~btn14val = -1; ~btn15val = -1; ~btn16val = -1; ~btn13val = -1; ~btn14val = -1; ~btn15val = -1; ~btn16val = -1;
//~pitchMode=7;
(( // accel gyro quaternion mapping /////////////////// (( // accel gyro quaternion mapping ///////////////////
@ -266,7 +272,27 @@ OSCFunc.trace(false); // Turn posting off
o = OSCdef(\test, { arg msg, time, addr, recvPort, rlow, rhigh; o = OSCdef(\test, { arg msg, time, addr, recvPort, rlow, rhigh;
~g.do({arg n; n.set(\rateRand, msg[2].linlin(0, 1, 1, 50); )}; ); if ( ~pitchMode == 7,
{
//"it's 7".postln;
msg.postln;
~g.do({arg n; n.set(
\rate, msg[2].linlin(-1, 1, 0.5, 2);
\rateRand, msg[3].linlin(0, -0.5, 1, 10);
)}; );
},
{"not 7".postln;} );
if ( ~posMode == 7,
{
//"it's 7".postln;
msg.postln;
~ptr.do({arg n; n.set(
//\ptrRandSamples, s.sampleRate * 0.125, \minPtrDelay, 1000, \ptrSampleDelay, s.sampleRate * msg[2].linlin(-0.3, 0.3, 0.1, 3) ;
//\sig, BufFrames.kr(b) * msg[2].linlin(-0.3, 0.3, 0.1, 1)
)}; );
},
{"not 7".postln;} );
}; , '/euler'); }; , '/euler');
@ -287,11 +313,11 @@ n = NetAddr("127.0.0.1", NetAddr.langPort);
p = OSCdef(\keys, { arg msg, time, addr, recvPort; p = OSCdef(\keys, { arg msg, time, addr, recvPort;
//msg[1].postln; //msg[1].postln;
~btnsA[~btn2val, ~btn3val]; /* ~btnsA[~btn2val, ~btn3val];
~btnsB[~btn4val, ~btn5val, ~btn6val, ~btn7val]; ~btnsB[~btn4val, ~btn5val, ~btn6val, ~btn7val];
~btnsC[~btn5val]; ~btnsC[~btn5val];*/
~btnstate = [~btnsA, ~btnsB, ~btnsC]; // ~btnstate = [~btnsA, ~btnsB, ~btnsC];
/// PRESETS !!!!!!!!!!!!!!!!!!!!!!! /// PRESETS !!!!!!!!!!!!!!!!!!!!!!!
@ -394,11 +420,11 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
{~pitchMode == 4 }{{~pitchModeGui.value_(4) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 5) }); } {~pitchMode == 4 }{{~pitchModeGui.value_(4) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 5) }); }
{~pitchMode == 5 }{{~pitchModeGui.value_(5) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 10) }); } {~pitchMode == 5 }{{~pitchModeGui.value_(5) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 10) }); }
{~pitchMode == 6 }{{~pitchModeGui.value_(6) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 100) }); } {~pitchMode == 6 }{{~pitchModeGui.value_(6) }.defer; ~g.do({arg n; n.set(\rate, 1, \rateRand, 100) }); }
{~pitchMode == 7 }{{~pitchModeGui.value_(7) }.defer; ~g.do({arg n; n.set(\rate, [0.5,1,2,].choose;) }); }; {~pitchMode == 7 }{{~pitchModeGui.value_(7) }.defer; ~g.do({arg n; n.set() }); };
case case
{~gdurMode == 0 }{{~durModeGui.value_(0) }.defer; ~g.do({arg n; n.set(\baseDur, 1, \durRand, 1)}); } {~gdurMode == 0 }{{~durModeGui.value_(0) }.defer; ~g.do({arg n; n.set(\baseDur, 1, \durRand, 1)}); }
{~gdurMode == 1 }{{~durModeGui.value_(1) }.defer; ~g.do({arg n; n.set(\baseDur, 2, \durRand, 1)}); } {~gdurMode == 1 }{{~durModeGui.value_(1) }.defer; ~g.do({arg n; n.set(\baseDur, 4, \durRand, 1)}); }
{~gdurMode == 2 }{{~durModeGui.value_(2) }.defer; ~g.do({arg n; n.set(\baseDur, 1/4, \durRand, 5)});} {~gdurMode == 2 }{{~durModeGui.value_(2) }.defer; ~g.do({arg n; n.set(\baseDur, 1/4, \durRand, 5)});}
{~gdurMode == 3 }{{~durModeGui.value_(3) }.defer; ~g.do({arg n; n.set(\baseDur, 1/8, \durRand, 100)});} {~gdurMode == 3 }{{~durModeGui.value_(3) }.defer; ~g.do({arg n; n.set(\baseDur, 1/8, \durRand, 100)});}
{~gdurMode == 4 }{{~durModeGui.value_(4) }.defer; ~g.do({arg n; n.set(\baseDur, 1/16, \durRand, 1)});} {~gdurMode == 4 }{{~durModeGui.value_(4) }.defer; ~g.do({arg n; n.set(\baseDur, 1/16, \durRand, 1)});}
@ -414,10 +440,10 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
\ptrRandSamples, s.sampleRate * 0.25, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); } \ptrRandSamples, s.sampleRate * 0.25, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); }
{~posMode == 2 }{{~posModeGui.value_(2) }.defer; ~g.do({arg n; n.set( {~posMode == 2 }{{~posModeGui.value_(2) }.defer; ~g.do({arg n; n.set(
\ptrRandSamples, s.sampleRate * 0.5, \minPtrDelay, 15000, \ptrSampleDelay, s.sampleRate * 1) }); } \ptrRandSamples, s.sampleRate * 0.5, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); }
{~posMode == 3 }{{~posModeGui.value_(3) }.defer; ~g.do({arg n; n.set( {~posMode == 3 }{{~posModeGui.value_(3) }.defer; ~g.do({arg n; n.set(
\ptrRandSamples, s.sampleRate * 1, \minPtrDelay, 15000, \ptrSampleDelay, s.sampleRate * 1) }); } \ptrRandSamples, s.sampleRate * 1, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); }
{~posMode == 4 }{{~posModeGui.value_(4) }.defer; ~g.do({arg n; n.set( {~posMode == 4 }{{~posModeGui.value_(4) }.defer; ~g.do({arg n; n.set(
\ptrRandSamples, s.sampleRate * 2, \ptrSampleDelay, s.sampleRate * 1) }); } \ptrRandSamples, s.sampleRate * 2, \ptrSampleDelay, s.sampleRate * 1) }); }
@ -428,8 +454,7 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
{~posMode == 6 }{{~posModeGui.value_(6) }.defer; ~g.do({arg n; n.set( {~posMode == 6 }{{~posModeGui.value_(6) }.defer; ~g.do({arg n; n.set(
\ptrRandSamples, s.sampleRate * 5, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); } \ptrRandSamples, s.sampleRate * 5, \minPtrDelay, 1500, \ptrSampleDelay, s.sampleRate * 1) }); }
{~posMode == 7 }{{~posModeGui.value_(7) }.defer; ~g.do({arg n; n.set( {~posMode == 7 }{{~posModeGui.value_(7) }.defer; ~g.do({arg n; n.set( ) }); }; //SENSOR MODE - SEE ABOVE
\ptrRandSamples, s.sampleRate * 1, \minPtrDelay, 15000; ) }); };
//[1,2,3].choose; //[1,2,3].choose;
@ -730,6 +755,8 @@ r.set(\overdub, 0.9); // overdub mode 0 - 0.99 - MAPPED TO SWITCH 4
~rec.set(\overdubLevel, 0.1); ~rec.set(\overdubLevel, 0.1);
~pointer.set(\ptrMode, 1);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
thisProcess.platform.recordingsDir;// find where the recordings are written to thisProcess.platform.recordingsDir;// find where the recordings are written to