gtr/gtr.scd

868 lines
31 KiB
Plaintext

// RUNME 0 =========================================
// todo countdown on density voices
( s.reboot{
s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples
s.options.sampleRate = 44100; // also tried with 44000 value
s.options.memSize = 8192 * 32; // increase this if you get "alloc failed" messages
s.options.numWireBufs = 64; // increase this if you get "exceeded number of interconnect buffers" messages
s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"
s.options.numInputBusChannels = 8;
s.options.numOutputBusChannels = 8;
})
// RUNME 1 =========================================
( // SETUP ---------------=--------------------------
// Allocate a 4 second mono buffer
b = Buffer.alloc(s, s.sampleRate * 4.0, 1);
~b1 = Buffer.alloc(s, s.sampleRate * 4.0, 1);
f = Buffer.alloc(s, s.sampleRate * 4.0, 1);
// load a test file
//f = Buffer.read(s, thisProcess.nowExecutingPath.dirname +/+ "sounds/Front_Left.wav");
//b = Buffer.read(s, "/usr/share/sounds/alsa/Front_Left.wav");
//b=f;
// Open port 57121 for ESP32 UDP OSC
thisProcess.openUDPPort(57121);
///////////////////////////////////////
~sourceGroup = Group.new;
~fxGroup = Group.after(~sourceGroup);
~reverbBus = Bus.audio(s, 1);
~ringModBus = Bus.audio(s, 1);
//load the gui
"/home/rob/gtr/gtr-gui-manual.scd".load;
);
s.plotTree;
// RUNME 2 ==========================================
// -------------------------------------------------
(( // DEFINE SYNTHS ---------------------------------
s.meter;
// -------------------------------------------------
( // direct signal + reverb -------------------------
SynthDef("dryIn", { arg in=0, instrPanModeIndex=0, out=0, sensorInstrPan=0, instrPitch=0.7, instrAmp=1;
var signal, dry, wet, instrPan, instrPanMode0, instrPanMode1, instrPanMode2, instrPanMode3, instrPanMode4, instrPanMode5;
instrPanMode0 = 0; //LFNoise1.kr(100).range(-0.2, 0.2);
instrPanMode1 = 1; //LFNoise1.kr(100).range(-0.2, 0.2);
instrPanMode2 = SinOsc.kr(0.33).range(-0.2, 0.2);
instrPanMode3 = LFNoise1.kr(10).range(-0.2, 0.2);
instrPanMode4 = LFSaw.kr(0.33).bipolar.range(-1,1);
instrPanMode5 = LFNoise1.kr(10).range(-1, 1);
instrPan = Select.kr(instrPanModeIndex,
[instrPanMode0, instrPanMode1, instrPanMode2, instrPanMode3,
instrPanMode4, instrPanMode5, sensorInstrPan]);
signal = SoundIn.ar(in);
//signal = PanAz.ar(4, signal, instrPan);
signal = signal * instrAmp;
//wet = PitchShift.ar(signal, pitchRatio: instrPitch, pitchDispersion: 0.3, timeDispersion: 0.1);
Out.ar(out, signal);
//Out.ar(0, Mix.ar( [signal, wet] ));
}).add;
);
(
SynthDef("freeVerb", {
arg in=0;
var signal, dry, wet;
dry = In.ar(in);
wet = FreeVerb.ar(dry, mix:0.5, room:0.99, damp:0.5,);
signal = wet * 0.9;
Out.ar(0, signal!2);
}).add;
);
SynthDef("ringModulator", {
arg in=0, modulator=300, mulrate=0.2;
var signal, rm , carrier, multiplier;
signal = In.ar(in);
multiplier = SinOsc.ar(mulrate);
rm = signal * SinOsc.ar(modulator, mul:multiplier);
signal = (rm + signal) * 0.5;
Out.ar(0, signal!2);
}).add;
);
// ---------~positionmode = 1; -------------------------------------------
( // Granulator --------------------------------------r.get(\in).postln;
// ----------------------------------------------------
// a custom envelope
//var winenv;
//winenv = Env([0, 1, 0], [0.5, 0.5], [8, -8]);
//z = Buffer.sendCollection(s, winenv.discretize, 1);
// ~rndpos = LFNoise2.kr(0.1).range(0, 1);
SynthDef(\buf_grain, { | out=0, gate = 1, amp = 0.5,
sndbuf, envbuf, pan=0, imp=50,
pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0,
positionmodeindex=0, gdurmodeindex=0, gpanmodeindex=0,
sensorposition=0, impulsemodeindex=0, sensorimpulse=0,
signalChannelIndex=1, dseqarrayIndex=1,
rlow= -1, rhigh=10 |
var signal, env, freqdev, pos,
pitchmode0, pitchmode1, pitchmode2,pitchmode3,pitchmode4,pitchmode5, pitchmode6, pitch,
gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, gdur,
gpanmode0, gpanmode1, gpanmode2,gpanmode3, gpanmode4, gpanmode5,gpanmode6, gpanmode7, gpanmode8, gpan,
positionmode0, positionmode1, positionmode2, positionmode3, position,
impulsemode0, impulsemode1, impulse,
xdseq, dseq_array1, dseq_array2, dseq_array3, dseq_array4, dseq_array5, dseq_array6,
stereosignal, quadsignalL, quadsignalR, quadsignal, signalchannels;
// grain duration mode -untransposed, random, or sensor controlled
gdurmode0 = 0.2;
gdurmode1 = 0.5;
gdurmode2 = LFNoise1.kr.range(0.1, 0.3);
gdurmode3 = LFNoise1.kr.range(0.1, 0.6);
gdurmode4 = LFNoise1.kr.range(1, 2);
gdurmode5 = LFNoise1.kr.range(1, 4);
gdurmode6 = LFNoise1.kr.range(4, 4);
gdur = Select.kr(gdurmodeindex,
[gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, sensorgdur]);
// grain pan mode STEREO, QUAD, ROTATING
gpanmode0 = 0; //LFNoise1.kr(100).range(-0.2, 0.2);
gpanmode1 = 1; //LFNoise1.kr(100).range(-0.2, 0.2);
gpanmode2 = SinOsc.kr(0.33).range(-0.2, 0.2);
gpanmode3 = LFNoise1.kr(10).range(-0.2, 0.2);
gpanmode4 = LFSaw.kr(0.33).bipolar.range(-1,1);
gpanmode5 = LFNoise1.kr(10).range(-1, 1);
gpanmode6 = LFNoise1.kr(10).range(-1, 1);
gpanmode7 = LFNoise1.kr(10).range(-1, 1);
gpanmode8 = LFNoise1.kr(10).range(-1, 1);
gdurmode6 = LFNoise1.kr.range(4, 4);
gdurmode6 = LFNoise1.kr.range(4, 4);
gpan = Select.kr(gpanmodeindex,
[gpanmode0, gpanmode1, gpanmode2, gpanmode3, gpanmode4, gpanmode5, gpanmode6, gpanmode7, gpanmode8, sensorgpan]);
// grain pitch mode -untransposed, random, or sensor controlled
pitchmode0 = 1;
//pitchmode1 = Demand.kr(Impulse.kr(imp), 0, Dseq([1,-1, 2, 1, -1.5, 1, 1.33, 1, -0.5, 1, 3, 1, 2.37, 1, -0.33, 1], inf));
pitchmode1 = Demand.kr(Impulse.kr(imp), 0, Drand([1,1, 1,1,1,1, 2, 3, 3, 0.5, 0.5], inf));
pitchmode2 = Demand.kr(Impulse.kr(imp), 0, Drand(Scale.minor.degrees.midiratio, inf) * Drand([0.5, 0.25,1,2], inf));
pitchmode3 = Demand.kr(Impulse.kr(imp), 0, Dseq([1,-1, -0.5, 1, 1.33, 1], inf));
pitchmode4 = Demand.kr(Impulse.kr(imp), 0, Drand([0.5, 0.25,1,2], inf));
pitchmode5 = Demand.kr(Impulse.kr(imp), 0, Drand(Scale.diminished.degrees.midiratio, inf));
pitchmode6 = LFNoise1.kr(imp).range(rlow, rhigh);
pitch = Select.kr(pitchmodeindex,
[pitchmode0, sensorpitch, pitchmode1, pitchmode2 ,pitchmode3, pitchmode4, pitchmode5, pitchmode6]);
// granular playhead mode - fixed random or sensor controlled
positionmode0 = 0.2;
positionmode1 = (Phasor.ar(0.01, 1 * BufRateScale.ir(b), 0, BufSamples.ir(b)) + LFNoise1.ar(100).bipolar(0.1 * SampleRate.ir) ) / BufSamples.ir(b);
positionmode2 = LFNoise1.kr.range(0.05, (BufSamples.ir(b)-1) - 1000 );
positionmode3 = LFNoise1.kr.range(0.1, 3.8 );
position = Select.kr(positionmodeindex,
[positionmode0, positionmode1, positionmode2, positionmode3, sensorposition]);
// grain impulse frequency mode - random, metric or sensor based impulse modes
impulsemode0 = Impulse.kr(imp);
impulsemode1 = Dust.kr(imp);
impulse = Select.kr(impulsemodeindex,
[impulsemode0, impulsemode1, sensorimpulse]);
env = EnvGen.kr( Env([0, 1, 0], [1, 1], \sin, 1), gate, levelScale: amp, doneAction: 2);
signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4) * env;
Out.ar(0, signal);
}).add;
);
(
~micBus = Bus.audio(s,1);
~ptrBus = Bus.audio(s,1);
);
(
SynthDef.new(\mic, {
arg in=0, out=0, amp=1;
var sig;
sig = SoundIn.ar(in) * amp;
Out.ar(out, sig);
}).add;
SynthDef.new(\ptr, {
arg out=0, buf=0;
var sig;
sig = Phasor.ar(0, BufRateScale.kr(buf), 0, BufFrames.kr(buf));
Out.ar(out, sig);
}).add;
SynthDef.new(\rec, {
arg ptrIn=0, micIn=0, buf=0;
var ptr, sig;
ptr = In.ar(ptrIn, 1);
sig = In.ar(micIn, 1);
BufWr.ar(sig, buf, ptr);
}).add;
( // mono buffer recorder ----------------------------
// with loop and overdub modes /////////////////////
SynthDef("recBuf",{
arg in=0, out=0, ptrIn=0, bufnum=0, t_trig=0, l=0, overdub=0;
var sig, ptr, chain, onsets;
sig = In.ar(in, 1);
ptr = In.ar(ptrIn, 1);
// Onsets
//chain = FFT(LocalBuf(512), sig);
//onsets = Onsets.kr(chain, MouseX.kr(0,1), \rcomplex);
RecordBuf.ar(sig, bufnum, loop:l,
preLevel: overdub,
doneAction: 0, trigger:t_trig, offset: ptr,);
}).add;
);
SynthDef.new(\gran, {
arg amp=0.5, out=0, buf=0,
atk=1, rel=1, gate=1,
sync=1, dens=40,
baseDur=0.05, durRand=1,
rate=1, rateRand=1,
pan=0, panRand=0,
grainEnv=(-1), ptrBus=0, ptrSampleDelay=20000,
ptrRandSamples=5000, minPtrDelay=1000;
var sig, env, densCtrl, durCtrl, rateCtrl, panCtrl, ptr, ptrRand, totalDelay, maxGrainDur;
env= EnvGen.kr(Env.asr(atk,1,rel),gate, doneAction:2);
densCtrl = Select.ar(sync, [Dust.ar(dens), Impulse.ar(dens)]);
durCtrl = baseDur * LFNoise1.ar(100).exprange(1/durRand, durRand);
rateCtrl = rate * LFNoise1.ar(100).exprange(1/rateRand, rateRand);
panCtrl = pan + LFNoise1.kr(100).bipolar(panRand);
ptrRand = LFNoise1.ar(100).bipolar(ptrRandSamples);
totalDelay = max(ptrSampleDelay - ptrRand, minPtrDelay); // make sure value doesnt go below this value, which would cross discontinuity point
ptr = In.ar(ptrBus, 1);
ptr = ptr - totalDelay; // how far ptr lags behind discontinuity point
ptr = ptr / BufFrames.kr(buf); //normalise to 0 - 1 range
maxGrainDur = (totalDelay / rateCtrl) / SampleRate.ir;
durCtrl = min(durCtrl, maxGrainDur);
sig = GrainBuf.ar(
2,
densCtrl,
durCtrl,
buf,
rateCtrl,
ptr,
2,
panCtrl,
grainEnv
);
sig = sig * env * amp;
Out.ar(out, sig);
}).add;
)
)
( // New Granulator --------------------------------------
SynthDef(\buf_grain, { | out=0, gate = 1, amp = 0.5,
sndbuf, envbuf, pan=0, imp=50,
pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0,
positionmodeindex=0, gdurmodeindex=0, gpanmodeindex=0,
sensorposition=0, impulsemodeindex=0, sensorimpulse=0,
signalChannelIndex=1, dseqarrayIndex=1,
rlow= -1, rhigh=10 |
var signal, env, freqdev, pos,
pitchmode0, pitchmode1, pitchmode2,pitchmode3,pitchmode4,pitchmode5, pitchmode6, pitch,
gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, gdur,
gpanmode0, gpanmode1, gpanmode2, gpan,
positionmode0, positionmode1, positionmode2, positionmode3, position,
impulsemode0, impulsemode1, impulse,
xdseq, dseq_array1, dseq_array2, dseq_array3, dseq_array4, dseq_array5, dseq_array6,
stereosignal, quadsignalL, quadsignalR, quadsignal, signalchannels;
// grain duration mode -untransposed, random, or sensor controlled
gdurmode0 = 0.2;
gdurmode1 = 0.5;
gdurmode2 = LFNoise1.kr.range(0.1, 0.3);
gdurmode3 = LFNoise1.kr.range(0.1, 0.6);
gdurmode4 = LFNoise1.kr.range(1, 2);
gdurmode5 = LFNoise1.kr.range(1, 4);
gdurmode6 = LFNoise1.kr.range(4, 4);
gdur = Select.kr(gdurmodeindex,
[gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, sensorgdur]);
// grain pan mode STEREO, QUAD, ROTATING
gpanmode0 = LFNoise1.kr(100).range(-0.2, 0.2);
gpanmode1 = LFSaw.kr(0.33).bipolar.range(-1,1);
gpanmode2 = LFNoise1.kr(100).range(-1, 1);
gpan = Select.kr(gpanmodeindex,
[gpanmode0, gpanmode1, gpanmode2, sensorgpan]);
// grain pitch mode -untransposed, random, or sensor controlled
pitchmode0 = 1;
//pitchmode1 = Demand.kr(Impulse.kr(imp), 0, Dseq([1,-1, 2, 1, -1.5, 1, 1.33, 1, -0.5, 1, 3, 1, 2.37, 1, -0.33, 1], inf));
pitchmode1 = Demand.kr(Impulse.kr(imp), 0, Drand([1,1, 1,1,1,1, 2, 3, 3, 0.5, 0.5], inf));
pitchmode2 = Demand.kr(Impulse.kr(imp), 0, Drand(Scale.minor.degrees.midiratio, inf) * Drand([0.5, 0.25,1,2], inf));
pitchmode3 = Demand.kr(Impulse.kr(imp), 0, Dseq([1,-1, -0.5, 1, 1.33, 1], inf));
pitchmode4 = Demand.kr(Impulse.kr(imp), 0, Drand([0.5, 0.25,1,2], inf));
pitchmode5 = Demand.kr(Impulse.kr(imp), 0, Drand(Scale.diminished.degrees.midiratio, inf));
pitchmode6 = LFNoise1.kr(imp).range(rlow, rhigh);
pitch = Select.kr(pitchmodeindex,
[pitchmode0, sensorpitch, pitchmode1, pitchmode2 ,pitchmode3, pitchmode4, pitchmode5, pitchmode6]);
// granular playhead mode - fixed random or sensor controlled
positionmode0 = 0.2;
positionmode1 = (Phasor.ar(0.01, 1 * BufRateScale.ir(b), 0, BufSamples.ir(b)) + LFNoise1.ar(100).bipolar(0.1 * SampleRate.ir) ) / BufSamples.ir(b);
positionmode2 = LFNoise1.kr.range(0.05, (BufSamples.ir(b)-1) - 1000 );
positionmode3 = LFNoise1.kr.range(0.1, 3.8 );
position = Select.kr(positionmodeindex,
[positionmode0, positionmode1, positionmode2, positionmode3, sensorposition]);
// grain impulse frequency mode - random, metric or sensor based impulse modes
impulsemode0 = Impulse.kr(imp);
impulsemode1 = Dust.kr(imp);
impulse = Select.kr(impulsemodeindex,
[impulsemode0, impulsemode1, sensorimpulse]);
env = EnvGen.kr( Env([0, 1, 0], [1, 1], \sin, 1), gate, levelScale: amp, doneAction: 2);
signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4) * env;
Out.ar(0, signal);
}).add;
)
(( // RUNME 3 ==========================================
// START SYNTHS ---------------------------------
// ----------------------------------------------------
r = Synth(\recBuf, [\in, 0, \out, 0, \bufnum, b, \t_trig, 0]); // recorder
~g1 = Synth(\buf_grain, [\sndbuf, b, \amp, 0.5, \envbuf, -1, \gate, 1, doneAction: 2, ], ~fxGroup); // granulate
~gtrIn = Synth(\dryIn, [\instrAmp, 1, \out, ~reverbBus], ~sourceGroup); // dry audio signaL
~reverbFX = Synth(\freeVerb, [\in, ~reverbBus], ~fxGroup);
~ringMod = Synth(\ringModulator, [\in, ~ringModBus], ~fxGroup);
));
r.get(\in).value;
//~ringMod.set(\in, 9);
//~gtrIn.set(\out, 0);
//~gtrIn.set(\out, ~ringModBus);
//~gtrIn.set(\out, ~reverbBus);
//~gtrIn.set(\out, [~reverbBus, ~ringModBus]);
~ringMod.set(\modulator, 0);
~ringMod.set(\mulrate, 0);
// RUNME 4 ==========================================
// ----------------------------------------------
OSCFunc.trace(true); // Turn posting on
OSCFunc.trace(false); // Turn posting off
(( // OSC Receivers // ENABLE SENSOR AND SWITCH VALUES <--
// ----------------------------------------------------
~overdubmode= 0; ~pitchmode = 0; ~positionmode = 0; ~impulsemode = 1;
~gdurmode=0; ~gpanmode=0; ~channelmode=0;
~instrPanMode=0;
~btnstate = [];
~btnsA = [];
~btnsB = [];
~btnsC = [];
~btn0val = -1; ~btn1val = -1; ~btn2val = -1; ~btn3val = -1;
~btn4val = -1; ~btn5val = -1; ~btn6val = -1; ~btn7val = -1;
~btn8val = -1; // shift buttons
~btn9val = -1; ~btn10val = -1; ~btn11val = -1; ~btn12val = -1;
~btn13val = -1; ~btn14val = -1; ~btn15val = -1; ~btn16val = -1;
( // accel gyro quaternion mapping ///////////////////
// msg[1] msg[2] msg[3] X Y Z ==> ROLL, PITCH, YAW
o = OSCdef(\test, { arg msg, time, addr, recvPort, rlow, rhigh;
// PAN ------- X Roll
~g1.set(\pan, msg[1].linlin(-0.3, 0.3, -1, 1));
~g1.set(\gpanmodeindex, ~gpanmode );
// PITCH ------- Y Pitch
~g1.set(\sensorpitch, msg[3]+1 * 2);
~g1.set(\pitchmodeindex, ~pitchmode );
// POSITION ------- Z Yaw
~g1.set(\sensorposition, msg[1].linlin(-0.2, 0.6, 0.05, 3.99));
~g1.set(\positionmodeindex, ~positionmode );
// RATE ------- X (roll [with PAN])
~g1.set(\sensorimpulse, msg[2].linlin(-1, 1, 5, 50));
~g1.set(\impulsemodeindex, ~impulsemode );
~g1.set(\sensorgdur, msg[2].linlin(-1, 1, 0.1, 1));
~g1.set(\gdurmodeindex, ~gdurmode );
~g1.set(\sensorgpan, msg[2]);
~g1.set(\gpanmodeindex, ~gpanmode );
//~g1.set(\sensorgpan, msg[2].linlin(-1, 1, -1, 1));
//~g1.set(\signalChannelIndex, ~channelmode );
~gtrIn.set(\sensorInstrPan, msg[2].wrap(0, 5).linlin(0, 5, -1, 1));
~gtrIn.set(\instrPanModeIndex, ~instrPanMode);
//msg.postln;
}; , '/euler');
);
// ----------------------------------------------------
// send message back to nodejs
m = NetAddr("127.0.0.1", 57100);
// on off osconoff accelerometer data
m.sendMsg("/xyzc", 1);
m.sendMsg("/xyzc", 0);
// ----------------------------------------------------
// button press mapping ///////////////////////////////
// ----------------------------------------------------
n = NetAddr("127.0.0.1", NetAddr.langPort);
//~switchArray = [0, 0, 0, 0 ,0 ,0 ,0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ];
//~switchArray.put(15, 1); ~switchArray.put(11, 1); ~switchArray.put(10, 1); ~switchArray.put(9, 1);
//j = List.new;
//j = ~switchArray.replace("[", "").replace("]", "");
//n.sendMsg("/keys", 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
//n.sendMsg("/keys",);
//n.sendMsg("/keys", 1,2,3,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
p = OSCdef(\keys, { arg msg, time, addr, recvPort;
//msg[1].postln;
~btnsA[~btn2val, ~btn3val];
~btnsB[~btn4val, ~btn5val, ~btn6val, ~btn7val];
~btnsC[~btn5val];
~btnstate = [~btnsA, ~btnsB, ~btnsC];
if (msg[9] == 1 && msg[10] == 1, {~btnstate.postln;});
//msg.println;
// ==============================
// BUTTON MAPPING
// ==============================
// TRIGGER BUTTONS (3) ------------------------------
// if SHIFT key is 0:
if (msg[9] == 0, {
// BUTTON X ----- TRIGGER ONESHOT BUFFER RECORD
if (msg[10] == 1, { r.set( \in, 0, \l, 0, \t_trig, 1);
"/////////// SAMPLING!".postln; { ~recTrigButton.value_(0) }.defer }, { { ~recTrigButton.value_(1) }.defer } );
// BUTTON X ----> LOOP RECORDING MODE ON/OFF
if (msg[11]==1,
{
( ~btn2val = (~btn2val + 1) % 3 ) ;
switch( ~btn2val,
0, { r.set(\l, 0); "RECORD LOOPING OFF".postln; { ~recModeGui.value_(0) }.defer },
1, { r.set(\l, 1); "RECORD LOOPING ON".postln; { ~recModeGui.value_(1) }.defer },
2, { r.set(\l, 1); "ONSET DETECTION ON".postln; { ~recModeGui.value_(2) }.defer },
);
});
// BUTTON X ----> OVERDUB RECORDING MODE ON/OFF
if (msg[12]==1,
{
( ~btn3val = (~btn3val + 1) % 6 ) ;
switch( ~btn3val,
0, { r.set(\overdub, 0); "SAMPLE OVERDUB OFF".postln; { ~overdubModeGui.value_(0) }.defer },
1, { r.set(\overdub, 0.3); "SAMPLE OVERDUB ON 30%".postln; { ~overdubModeGui.value_(1) }.defer },
2, { r.set(\overdub, 0.5); "SAMPLE OVERDUB ON 50%".postln; { ~overdubModeGui.value_(2) }.defer },
3, { r.set(\overdub, 0.75); "SAMPLE OVERDUB ON 75%".postln; { ~overdubModeGui.value_(3) }.defer },
4, { r.set(\overdub, 0.90); "SAMPLE OVERDUB ON 90%".postln; { ~overdubModeGui.value_(4) }.defer },
5, { r.set(\overdub, 1); "SAMPLE OVERDUB ON 100%".postln; { ~overdubModeGui.value_(5) }.defer },
)
});
case
{~gdurmode == 0 }{{~durModeGui.value_(0) }.defer}
{~gdurmode == 1 }{{~durModeGui.value_(1) }.defer}
{~gdurmode == 2 }{{~durModeGui.value_(2) }.defer}
{~gdurmode == 3 }{{~durModeGui.value_(3) }.defer}
{~gdurmode == 4 }{{~durModeGui.value_(4) }.defer}
{~gdurmode == 5 }{{~durModeGui.value_(5) }.defer}
{~gdurmode == 6 }{{~durModeGui.value_(6) }.defer}
{~gdurmode == 7 }{{~durModeGui.value_(7) }.defer};
case
{~pitchmode == 0 }{{~pitchModeGui.value_(0) }.defer}
{~pitchmode == 1 }{{~pitchModeGui.value_(1) }.defer}
{~pitchmode == 2 }{{~pitchModeGui.value_(2) }.defer}
{~pitchmode == 3 }{{~pitchModeGui.value_(3) }.defer}
{~pitchmode == 4 }{{~pitchModeGui.value_(4) }.defer}
{~pitchmode == 5 }{{~pitchModeGui.value_(5) }.defer}
{~pitchmode == 6 }{{~pitchModeGui.value_(6) }.defer}
{~pitchmode == 7 }{{~pitchModeGui.value_(7) }.defer};
case
{~durationmode == 0 }{{~durationModeGui.value_(0) }.defer}
{~durationmode == 1 }{{~durationModeGui.value_(1) }.defer}
{~durationmode == 2 }{{~durationModeGui.value_(2) }.defer}
{~durationmode == 3 }{{~durationModeGui.value_(3) }.defer}
{~durationmode == 4 }{{~durationModeGui.value_(4) }.defer}
{~durationmode == 5 }{{~durationModeGui.value_(5) }.defer}
{~durationmode == 6 }{{~durationModeGui.value_(6) }.defer}
{~durationmode == 7 }{{~durationModeGui.value_(7) }.defer};
case
{~positionmode == 0 }{{~positionModeGui.value_(0) }.defer}
{~positionmode == 1 }{{~positionModeGui.value_(1) }.defer}
{~positionmode == 2 }{{~positionModeGui.value_(2) }.defer}
{~positionmode == 3 }{{~positionModeGui.value_(3) }.defer}
{~positionmode == 4 }{{~positionModeGui.value_(4) }.defer}
{~positionmode == 5 }{{~positionModeGui.value_(5) }.defer}
{~positionmode == 6 }{{~positionModeGui.value_(6) }.defer}
{~positionmode == 7 }{{~positionModeGui.value_(7) }.defer};
case
{~gpanmode == 0 }{{~panModeGui.value_(0) }.defer}
{~gpanmode == 1 }{{~panModeGui.value_(1) }.defer}
{~gpanmode == 2 }{{~panModeGui.value_(2) }.defer}
{~gpanmode == 3 }{{~panModeGui.value_(3) }.defer}
{~gpanmode == 4 }{{~panModeGui.value_(4) }.defer}
{~gpanmode == 5 }{{~panModeGui.value_(5) }.defer}
{~gpanmode == 6 }{{~panModeGui.value_(6) }.defer}
{~gpanmode == 7 }{{~panModeGui.value_(7) }.defer};
case
{~instrPanMode == 0 }{{~instrPanModeGui.value_(0) }.defer}
{~instrPanMode == 1 }{{~instrPanModeGui.value_(1) }.defer}
{~instrPanMode == 2 }{{~instrPanModeGui.value_(2) }.defer}
{~instrPanMode == 3 }{{~instrPanModeGui.value_(3) }.defer}
{~instrPanMode == 4 }{{~instrPanModeGui.value_(4) }.defer}
{~instrPanMode == 5 }{{~instrPanModeGui.value_(5) }.defer}
{~instrPanMode == 6 }{{~instrPanModeGui.value_(6) }.defer}
{~instrPanMode == 7 }{{~instrPanModeGui.value_(7) }.defer};
case
{~impulsemode == 0 }{{~impulseModeGui.value_(0) }.defer}
{~impulsemode == 1 }{{~impulseModeGui.value_(1) }.defer}
{~impulsemode == 2 }{{~impulseModeGui.value_(2) }.defer}
// BUTTON X ----> toggle fx
if (msg[13]==1,
{
( ~btn4val = (~btn4val + 1) % 4 ) ;
switch( ~btn4val,
0, { r.set(\l, 0); "dry".postln; { ~gtrIn.set(\out, ~ringModBus); ~ringMod.set(\modulator, 0, \mulrate, 0); ~fxModeGui.value_(0) }.defer },
1, { r.set(\l, 1); "ring mod".postln; { ~gtrIn.set(\out, ~ringModBus); ~ringMod.set(\modulator, 77, \mulrate, 0.1); ~fxModeGui.value_(1) }.defer },
2, { r.set(\l, 1); "reverb".postln; { ~gtrIn.set(\out, ~reverbBus); ~fxModeGui.value_(2) }.defer },
3, { r.set(\l, 1); "reverb + ringmod".postln; { ~gtrIn.set(\out, [~reverbBus, ~ringModBus]); ~fxModeGui.value_(3) }.defer },
);
});
/////////////////// RESET RANDOM PITCH TO FIXED PITCH IN ONE TAP
if (msg[14]==1,
{
( ~btn5val = (~btn5val + 1) % 2 ) ;
switch( ~btn5val,
0, { ~pitchmode = 0; "PITCH RESET TO UNTRANSPOSED MODE".postln; { ~pitchModeGui.value_(0) }.defer },
1, { ~pitchmode = 1; "PITCH IN SENSOR MODE".postln; { ~pitchModeGui.value_(1) }.defer }
);
});
// INCREASE IMPULSE RATE ---------------------------------------
if (msg[15]==1,
{
( ~btn6val = (~btn6val + 1) % 8 ) ;
switch(~btn6val,
0, { ~g1.set(\imp, 1); "IMPULSE = 1".postln; { ~densityModeGui.value_(0) }.defer },
1, { ~g1.set(\imp, 2); "IMPULSE = 2".postln; { ~densityModeGui.value_(1) }.defer },
2, { ~g1.set(\imp, 4); "IMPULSE = 4".postln; { ~densityModeGui.value_(2) }.defer },
3, { ~g1.set(\imp, 8); "IMPULSE = 8".postln; { ~densityModeGui.value_(3) }.defer },
4, { ~g1.set(\imp, 16); "IMPULSE = 16".postln; { ~densityModeGui.value_(4) }.defer },
5, { ~g1.set(\imp, 32); "IMPULSE = 32".postln; { ~densityModeGui.value_(5) }.defer },
6, { ~g1.set(\imp, 64); "IMPULSE = 64".postln; { ~densityModeGui.value_(6) }.defer },
7, { ~g1.set(\imp, 64); "IMPULSE = 64".postln; { ~densityModeGui.value_(7) }.defer },
)
});
// BUTTON X ----- G PANNING MODE
// TODO FIX MAPPINGS - GUI AND REALITY DO NOT MATCH
if (msg[16]==1,
{
( ~btn7val = (~btn7val + 1) % 9 ) ;
switch( ~btn7val,
0, { ~gpanmode = 0 ; "SIGNAL OFF".postln; { ~gPanModeGui.value_(0)}.defer },
1, { ~gpanmode = 1 ; "DRY FRONT {STERE0}".postln; { ~gPanModeGui.value_(1)}.defer },
2, { ~gpanmode = 2 ; "DRY BACK {STERE0}".postln; { ~gPanModeGui.value_(2)}.defer },
3, { ~gpanmode = 3 ; "L/R PAN {STEREO}".postln; { ~gPanModeGui.value_(3)}.defer },
4, { ~gpanmode = 4 ; "DRY RaND {STEREO}".postln; { ~gPanModeGui.value_(4)}.defer },
5, { ~gpanmode = 5 ; "DRY ROTATE {QUAD}".postln; { ~gPanModeGui.value_(5)}.defer },
6, { ~gpanmode = 6 ; "DRY RaND {QUAD}".postln; { ~gPanModeGui.value_(6)}.defer },
7, { ~gpanmode = 7 ; "DRY SENSOR {QUAD}".postln; { ~gPanModeGui.value_(7)}.defer },
8, { ~gpanmode = 8 ; "PAN RANDOM QUAD".postln; { ~gPanModeGui.value_(8)}.defer },
)
});
}, /// SHIFT 0 LOGIC ENDS HERE --------------------------------------------
{
// SHIFT IN STATE 1 ======================= ..........................
// GTR INPUT =======================
if (msg[11]==1,
{
( ~btn10val = (~btn10val + 1) % 9 ) ;
switch(~btn10val,
0, { ~gtrIn.set(\instrAmp, 0 ); "DRY SIGNAL OFF".postln;{ ~instrPanModeGui.value_(0)}.defer },
1, { ~gtrIn.set(\in, 0, \instrAmp, 1 ); ~instrPanMode=0; "DRY FRONT {STERE0}".postln; { ~instrPanModeGui.value_(1)}.defer },
2, { ~gtrIn.set(\in, 0 ); ~instrPanMode=1; "DRY BACK {STERE0}".postln; { ~instrPanModeGui.value_(2)}.defer },
3, { ~gtrIn.set(\in, 0 ); ~instrPanMode=2; "DRY RaND {STEREO}".postln; { ~instrPanModeGui.value_(3)}.defer },
4, { ~gtrIn.set(\in, 0 ); ~instrPanMode=3; "L/R PAN {STEREO}".postln; { ~instrPanModeGui.value_(4)}.defer },
5, { ~gtrIn.set(\in, 0 ); ~instrPanMode=4; "DRY ROTATE {QUAD}".postln; { ~instrPanModeGui.value_(5)}.defer },
6, { ~gtrIn.set(\in, 0 ); ~instrPanMode=5; "DRY RaND {QUAD}".postln; { ~instrPanModeGui.value_(6)}.defer },
7, { ~gtrIn.set(\in, 0 ); ~instrPanMode=6; "DRY SENSOR {QUAD}".postln; { ~instrPanModeGui.value_(7)}.defer },
8, { ~gtrIn.set(\in, 0 ); ~instrPanMode=7; "DRY SENSOR {QUAD}".postln; { ~instrPanModeGui.value_(8)}.defer },
)
});
// BUTTON X && X RESET/ZERO SENSORS [in firmware just here for notificaton]
if (msg[12] == 1, { " ===== EULER ZEROED! =====".postln }, {});
// BUTTON X ----- GRANULAR POSITION MODE
if (msg[13]==1,
{
( ~btn12val = (~btn12val + 1) % 5 ) ;
switch(~btn12val,
0, { ~positionmode = 0; "PLAYHEAD MODE FIXED".postln; { ~positionModeGui.value_(0) }.defer },
1, { ~positionmode = 1; "PLAYHEAD MODE LOOPING".postln; { ~positionModeGui.value_(1) }.defer },
2, { ~positionmode = 2; "PLAYHEAD MODE RANDOM".postln; { ~positionModeGui.value_(2) }.defer },
3, { ~positionmode = 3; "PLAYHEAD CONSTRAINED RND".postln; { ~positionModeGui.value_(3) }.defer },
4, { ~positionmode = 4; "PLAYHEAD MODE SENSOR".postln; { ~positionModeGui.value_(4) }.defer },
)
});
// BUTTON X ----- GRANULAR PITCH MODE
if (msg[14]==1,
{
( ~btn13val = ((~btn13val + 1) % 9 ) ) ;
switch(~btn13val,
0, { ~pitchmode = 0; "pitch array 0".postln; { ~pitchModeGui.value_(0) }.defer },
1, { ~pitchmode = 1; "pitch array 1".postln; { ~pitchModeGui.value_(1) }.defer },
2, { ~pitchmode = 2; "pitch array 2".postln; { ~pitchModeGui.value_(2) }.defer },
3, { ~pitchmode = 3; "pitch array 3".postln; { ~pitchModeGui.value_(3) }.defer },
4, { ~pitchmode = 4; "pitch array 4".postln; { ~pitchModeGui.value_(4) }.defer },
5, { ~pitchmode = 5; "pitch array 5".postln; { ~pitchModeGui.value_(5) }.defer },
6, { ~pitchmode = 6; "pitch array 6".postln; { ~pitchModeGui.value_(6) }.defer },
7, { ~pitchmode = 7; ~g1.set(\rlow, -0.8 ); ~g1.set(\rhigh, 1.5);
"PITCH MODE RANDOM 4".postln; { ~pitchModeGui.value_(7) }.defer },
8, { ~pitchmode = 7; ~g1.set(\rlow, -3 ); ~g1.set(\rhigh, 3);
"PITCH MODE RANDOM 5".postln; { ~pitchModeGui.value_(8) }.defer },
9, { ~pitchmode = 7; ~g1.set(\rlow, -8 ); ~g1.set(\rhigh, 8);
"PITCH MODE RANDOM 6".postln; { ~pitchModeGui.value_(9) }.defer },
)
});
//~durBtn = 1;
// BUTTON X ----- GRAIN DURATION MODE
if (msg[15]==1,
{
( ~btn14val = (~btn14val + 1) % 8 ) ;
switch(~btn14val,
0, { ~gdurmode = 0; "DURATION MODE 0".postln; { ~durModeGui.value_(0) }.defer },
1, { ~gdurmode = 1; "DURATION MODE 1".postln; { ~durModeGui.value_(1) }.defer },
2, { ~gdurmode = 2; "DURATION MODE 2".postln; { ~durModeGui.value_(2) }.defer },
3, { ~gdurmode = 3; "DURATION MODE 3".postln; { ~durModeGui.value_(3) }.defer },
4, { ~gdurmode = 4; "DURATION MODE 4".postln; { ~durModeGui.value_(4) }.defer },
5, { ~gdurmode = 5; "DURATION MODE 5".postln; { ~durModeGui.value_(5) }.defer },
6, { ~gdurmode = 6; "DURATION MODE 6".postln; { ~durModeGui.value_(6) }.defer },
7, { ~gdurmode = 7; "DURATION MODE: SENSOR".postln; { ~durModeGui.value_(7) }.defer },
)
});
// BUTTON X ----- GRANULAR IMPULSE MODE
if (msg[16]==1,
{
( ~btn15val = (~btn15val + 1) % 3 ) ;
switch( ~btn15val,
0, { ~g1.set(\impulsemodeindex, 0 ); "IMPULSE MODE FIXED".postln; { ~impulseModeGui.value_(0) }.defer },
1, { ~g1.set(\impulsemodeindex, 1 ); "IMPULSE MODE DUST".postln; { ~impulseModeGui.value_(1) }.defer },
2, { ~g1.set(\impulsemodeindex, 2 ); "IMPULSE MODE SENSOR".postln; { ~impulseModeGui.value_(2) }.defer },
)
});
}); // SHIFT ONE LOGIC ENDS HERE ================
// } , '/keys');
} , '/localhostInLevels');
));
~gdurmode = 2;
// ----------------------------------------------------
// LIVE CODE / PERFORMABLE PARAMETERS /////////////////
// ----------------------------------------------------
thisProcess.platform.recordingsDir;// find where the recordings are written to
s.record(numChannels:4); // record
// set recorder loop and overdub modes ////////////
// start recording (without button)
r.set(\in, 0, \l, 0, \t_trig, 1);
r.set(\l, 1); // looping record on/off 0/1 - MAPPED TO SWITCH 3
r.set(\overdub, 0.9); // overdub mode 0 - 0.99 - MAPPED TO SWITCH 4
/////////////////////
~g1.set(\pitchmodeindex, 1); // pitchmode
~g1.set(\gdurmodeindex, 1); // grain duration mode
~g1.set(\imp,2); // grain impulse rate
~g1.set(\impulsemodeindex, 1); // 0 1 2 imp, dust, sensor
~g1.set(\positionmodeindex, 1); // playhead FIXED.RND.SENSOR 0 1 2
~g1.set(\gpanmodeindex, 1); // pan mode
~g1.set(\amp, 0); // amplitude
~ringMod.set(\modulator, 0); // 0 to disable
/// random pitch/rate low and high values
~g1.set(\rlow, 10); // APPLIES ONLY TO PITCH MODE 7
~g1.set(\rhigh, 1);
~dseqarrayIndex=0;
~g1.set(\dseqarrayIndex, 0);
~g1.set(\gpan, -1 );
~channelmode = 1;
//~ringMod.set(\in, 0);
//~gtrIn.set(\out, 0);
//~gtrIn.set(\out, ~ringModBus);
//~gtrIn.set(\out, ~reverbBus);
//~gtrIn.set(\out, [~reverbBus, ~ringModBus]);
~ringMod.set(\modulator, 77, \mulrate, 0.1);
~ringMod.set(\modulator, 0, \mulrate, 0);
~ringMod.set(\mulrate, 0);
~gtrIn.set(\instrAmp, 1);
// fix doneaction
~g1.set(\gate, 1); // granulator on
~g1.set(\gate, 0); // granulator off
~g1.set(\amp, 1); // granulator off
a = Scale.major;
/////////////////////////////////////////////////
// -----------------------------------------------
~btn4val = 2;
~gdurmode = 4;
// list all open ports
// -----------------------------------------------
// CODE DUMP ZONE ///////////////////////////////
// switch to the custom env
//~g1.set(\envbuf, z);
//~g1.set(\envbuf, -1);
n = NetAddr("127.0.0.1", NetAddr.langPort);
//n = NetAddr.new("224.0.1.9", 6696);