broken quadraphonic granular

master
Rob Canning 2022-09-12 14:36:54 +02:00
parent 0c81b6db25
commit 199c07c246
1 changed files with 93 additions and 83 deletions

166
gtr.scd
View File

@ -1,28 +1,4 @@
////////////////////////////////////////////////////
/* GRANULATING SAMPLER INSTRUMENT //////////////////
////////////////////////////////////rc@kiben.net////
////////////////////////////////////////////////////
| .-.
| / \ .-.
| / \ / \ .-. .-. _
+--/-------\-----/-----\-----/---\---/---\---/-\-
| / \ / \ / '-' '-'
|/ '-' '-'
Ljudmila OTF Hackathon, Maribor 1-6 March 2022 */
// GTR MAC address: 10:97:BD:36:D6:4E
// DUMP ALL OSC MESSAGES (for debugging) ////////
OSCFunc.trace(true);
OSCFunc.trace(false);
thisProcess.openPorts;
( (
s.reboot{ s.reboot{
s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples s.options.numBuffers = 1024 * 256; // increase this if you need to load more samples
@ -36,12 +12,16 @@ s.reboot{
} ) } )
// RUNME 0 ========================================= // RUNME 0 =========================================
s.boot(); s.boot();
// RUNME 1 ========================================= // RUNME 1 =========================================
// ------------------------------------------------- // -------------------------------------------------
( // SETUP ----------------------------------------- - ( // SETUP ----------------------------------------- -
// --------------------------------------------------- // ---------------------------------------------------
// Allocate a 4 second mono buffer // Allocate a 4 second mono buffer
@ -111,20 +91,19 @@ SynthDef("recBuf",{
// ~rndpos = LFNoise2.kr(0.1).range(0, 1); // ~rndpos = LFNoise2.kr(0.1).range(0, 1);
SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5, SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
sndbuf, envbuf, pan=0, imp=50, sndbuf, envbuf, pan=0, imp=30,
pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0, pitchmodeindex=0, sensorpitch=1, sensorgdur=0.1, sensorgpan=0,
positionmodeindex=0, gdurmodeindex=0, gpanmodeindex=0, positionmodeindex=0, gdurmodeindex=0, gpanmodeindex=0,
sensorposition=0, impulsemodeindex=0, sensorimpulse=0, sensorposition=0, impulsemodeindex=0, sensorimpulse=0,
signalChannelIndex=1, signalChannelIndex=0, dseqarrayIndex=1,
rlow= -1, rhigh=10 | rlow= -1, rhigh=10 |
var signal, env, freqdev, pos, var signal, env, freqdev, pos,
pitchmode0, pitchmode1, pitchmode2, pitch, pitchmode0, pitchmode1, pitchmode2,pitchmode3,pitchmode4,pitchmode5, pitchmode6, pitch,
gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, gdur, gdurmode0, gdurmode1, gdurmode2, gdurmode3, gdurmode4, gdurmode5, gdurmode6, gdur,
gpanmode0, gpanmode1, gpanmode2, gpan, gpanmode0, gpanmode1, gpanmode2, gpan,
positionmode0, positionmode1, positionmode2, positionmode3, position, positionmode0, positionmode1, positionmode2, positionmode3, position,
impulsemode0, impulsemode1, impulse, impulsemode0, impulsemode1, impulse, dseq, dseq_array1, dseq_array2, dseq_array3, dseq_array4, dseq_array5, dseq_array6, stereosignal, quadsignalL, quadsignalR, quadsignal, signalchannels;
stereosignal, quadsignalL, quadsignalR, quadsignal, signalchannels;
// grain duration mode -untransposed, random, or sensor controlled // grain duration mode -untransposed, random, or sensor controlled
gdurmode0 = 0.2; gdurmode0 = 0.2;
@ -147,14 +126,27 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
// grain pitch mode -untransposed, random, or sensor controlled // grain pitch mode -untransposed, random, or sensor controlled
~dseq = Dseq([1,-1, 2, 1, -1.5, 1, 1.75, 1, -0.5, 1, 3, 1, 2.25, 1 -0.125, 1], inf); dseq_array1 = Dseq([1,-1, 2, 1, -1.5, 1, 1.33, 1, -0.5, 1, 3, 1, 2.37, 1, -0.33, 1], inf);
dseq_array2 = Dseq([1,-1, -0.5, 1, 1.33, 1], inf);
dseq_array3 = Drand([(1..5).mirror.midiratio], inf);
dseq_array4 = Drand([1,-1, 2, 1, -1.5, 1, 1.33, 1, -0.5, 1, 3, 1, 2.37, 1, -0.33, 1], inf);
dseq_array5 = Dseq([1,-1, -0.5, 1, 1.33, 1], inf);
dseq = [dseq_array1, dseq_array2,dseq_array3, dseq_array4, dseq_array5];
dseqarrayIndex =1;
pitchmode0 = 1; pitchmode0 = 1;
pitchmode1 = Demand.kr(Impulse.kr(imp), 0, ~dseq); pitchmode1 = Demand.kr(Impulse.kr(imp), 0, dseq[0]);
pitchmode2 = LFNoise1.kr(imp).range(rlow, rhigh); pitchmode2 = Demand.kr(Impulse.kr(imp), 0, dseq[1]);
pitchmode3 = Demand.kr(Impulse.kr(imp), 0, dseq[2]);
pitchmode4 = Demand.kr(Impulse.kr(imp), 0, dseq[3]);
pitchmode5 = Demand.kr(Impulse.kr(imp), 0, dseq[4]);
pitchmode6 = LFNoise1.kr(imp).range(rlow, rhigh);
pitch = Select.kr(pitchmodeindex, pitch = Select.kr(pitchmodeindex,
[pitchmode0, sensorpitch, pitchmode1, pitchmode2 ]); [pitchmode0, sensorpitch, pitchmode1, pitchmode2 ,pitchmode3, pitchmode4, pitchmode5, pitchmode6]);
// granular playhead mode - fixed random or sensor controlled // granular playhead mode - fixed random or sensor controlled
@ -169,6 +161,7 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
// grain impulse frequency mode - random, metric or sensor based impulse modes // grain impulse frequency mode - random, metric or sensor based impulse modes
impulsemode0 = Impulse.kr(imp); impulsemode0 = Impulse.kr(imp);
impulsemode1 = Dust.kr(imp); impulsemode1 = Dust.kr(imp);
impulse = Select.kr(impulsemodeindex, impulse = Select.kr(impulsemodeindex,
[impulsemode0, impulsemode1, sensorimpulse]); [impulsemode0, impulsemode1, sensorimpulse]);
@ -176,20 +169,24 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4) * env; signal = TGrains.ar(4, impulse, b, pitch, position, gdur, gpan, amp, 4) * env;
stereosignal = signal; ////////stereosignal = signal;
quadsignalL = PanAz.ar(4, signal[0], MouseX.kr(0,2)); //quadsignalL = PanAz.ar(4, signal[0], MouseX.kr(0,2));
quadsignalR = PanAz.ar(4, signal[1], MouseX.kr(0,2).range(2,0)); //quadsignalR = PanAz.ar(4, signal[1], MouseX.kr(0,2).range(2,0));
quadsignal = signal; //Mix.ar([quadsignalL, quadsignalR]); ////////quadsignal = signal; //Mix.ar([quadsignalL, quadsignalR]);
////////signalchannels = Select.ar(signalChannelIndex, [stereosignal, quadsignal]);
signalchannels = Select.ar(signalChannelIndex, [stereosignal, quadsignal]);
//signal = signalchannels; //signal = signalchannels;
Out.ar(0, signalchannels);
Out.ar(0, signal);
}).add; }).add;
); );
) )
// RUNME 3 ========================================== // RUNME 3 ==========================================
// ---------------------------------------------------- // ----------------------------------------------------
(( // START SYNTHS --------------------------------- (( // START SYNTHS ---------------------------------
@ -197,7 +194,7 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
// TODO NO EPRAND IN INSTR! // TODO NO EPRAND IN INSTR!
r = Synth(\recBuf, [\in, 0, \out, 0, \bufnum, b, \t_trig, 0]); // recorder r = Synth(\recBuf, [\in, 0, \out, 0, \bufnum, b, \t_trig, 0]); // recorder
~g1 = Synth(\buf_grain, [\sndbuf, b, \amp, exprand(0.4, 0.9), \envbuf, -1, \gate, 1, doneAction: 2]); // granulate ~g1 = Synth(\buf_grain, [\sndbuf, b, \amp, 0.6, \envbuf, -1, \gate, 1, doneAction: 2]); // granulate
~gtrIn = Synth(\dryIn); // dry audio signaL ~gtrIn = Synth(\dryIn); // dry audio signaL
)); ));
@ -205,10 +202,11 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
// RUNME 4 ========================================== // RUNME 4 ==========================================
// ---------------------------------------------------- // ----------------------------------------------------
(( // OSC Receivers // ENABLE SENSOR AND SWITCH VALUES <-- (( // OSC Receivers // ENABLE SENSOR AND SWITCH VALUES <--
// ---------------------------------------------------- // ----------------------------------------------------
~pitchmode = 0; ~positionmode = 0; ~impulsemode = 1; ~pitchmode = 0; ~positionmode = 0; ~impulsemode = 1;
~gdurmode=0; ~gpanmode=0; ~channelmode=0; ~gdurmode=0; ~gpanmode=1; ~channelmode=0;
~instrPanMode =0; ~instrPanMode =0;
~btnstate = []; ~btnstate = [];
@ -216,9 +214,15 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
~btnsB = []; ~btnsB = [];
~btnsC = []; ~btnsC = [];
~btn0val = 0; ~btn1val = 0; ~btn2val = 0; ~btn3val = 0; ~btn0val = -1; ~btn1val = -1; ~btn2val = -1; ~btn3val = -1;
~btn4val = 0; ~btn5val = 0; ~btn6val = 0; ~btn7val = 0; ~btn4val = -1; ~btn5val = -1; ~btn6val = -1; ~btn7val = -1;
~btn8val = 0; // shift buttons ~btn8val = -1; // shift buttons
~btn9val = -1; ~btn10val = -1; ~btn11val = -1; ~btn12val = -1;
~btn13val = -1; ~btn14val = -1; ~btn15val = -1; ~btn16val = -1;
( // accel gyro quaternion mapping /////////////////// ( // accel gyro quaternion mapping ///////////////////
// msg[1] msg[2] msg[3] X Y Z ==> ROLL, PITCH, YAW // msg[1] msg[2] msg[3] X Y Z ==> ROLL, PITCH, YAW
@ -247,8 +251,8 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 0.5,
~g1.set(\sensorgpan, msg[2]); ~g1.set(\sensorgpan, msg[2]);
~g1.set(\gpanmodeindex, ~gpanmode ); ~g1.set(\gpanmodeindex, ~gpanmode );
~g1.set(\sensorgpan, msg[2].linlin(-1, 1, -1, 1)); //~g1.set(\sensorgpan, msg[2].linlin(-1, 1, -1, 1));
~g1.set(\signalChannelIndex, ~channelmode ); //~g1.set(\signalChannelIndex, ~channelmode );
~gtrIn.set(\instrPan, msg[2].linlin(-1, 1, -1, 1)); ~gtrIn.set(\instrPan, msg[2].linlin(-1, 1, -1, 1));
~gtrIn.set(\instrPanModeIndex, ~instrPanMode); ~gtrIn.set(\instrPanModeIndex, ~instrPanMode);
@ -295,8 +299,8 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----> LOOP RECORDING MODE ON/OFF // BUTTON X ----> LOOP RECORDING MODE ON/OFF
if (msg[11]==1, if (msg[11]==1,
{ {
( ~btn4val = (~btn4val + 1) % 3 ) ; ( ~btn2val = (~btn2val + 1) % 3 ) ;
switch( ~btn4val, switch( ~btn2val,
0, { r.set(\l, 0); "RECORD LOOPING OFF".postln; }, 0, { r.set(\l, 0); "RECORD LOOPING OFF".postln; },
1, { r.set(\l, 1); "RECORD LOOPING ON".postln; }, 1, { r.set(\l, 1); "RECORD LOOPING ON".postln; },
2, { r.set(\l, 1); "RECORDING ONSET DETECTION ON".postln; }, //todo 2, { r.set(\l, 1); "RECORDING ONSET DETECTION ON".postln; }, //todo
@ -306,8 +310,8 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----> OVERDUB RECORDING MODE ON/OFF // BUTTON X ----> OVERDUB RECORDING MODE ON/OFF
if (msg[12]==1, if (msg[12]==1,
{ {
( ~btn2val = (~btn2val + 1) % 5 ) ; ( ~btn3val = (~btn3val + 1) % 5 ) ;
switch( ~btn2val, switch( ~btn3val,
0, { r.set(\overdub, 0); "SAMPLE OVERDUB OFF".postln; }, 0, { r.set(\overdub, 0); "SAMPLE OVERDUB OFF".postln; },
1, { r.set(\overdub, 0.5); "SAMPLE OVERDUB ON 50%".postln; }, 1, { r.set(\overdub, 0.5); "SAMPLE OVERDUB ON 50%".postln; },
2, { r.set(\overdub, 0.75); "SAMPLE OVERDUB ON 75%".postln; }, 2, { r.set(\overdub, 0.75); "SAMPLE OVERDUB ON 75%".postln; },
@ -322,23 +326,22 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
/////////////////// RESET RANDOM PITCH TO FIXED PITCH IN ONE TAP /////////////////// RESET RANDOM PITCH TO FIXED PITCH IN ONE TAP
if (msg[14]==1, if (msg[14]==1,
{ {
( ~btn6val = (~btn6val + 1) % 2 ) ; ( ~btn5val = (~btn5val + 1) % 2 ) ;
switch( ~btn6val, switch( ~btn5val,
0, { ~pitchmode = 0; "PITCH RESET TO UNTRANSPOSED MODE".postln; }, 0, { ~pitchmode = 0; "PITCH RESET TO UNTRANSPOSED MODE".postln; },
1, { ~pitchmode = 1; "PITCH IN SENSOR MODE".postln; } 1, { ~pitchmode = 1; "PITCH IN SENSOR MODE".postln; }
); );
}); });
// INCREASE IMPULSE RATE ---------------------------------------
if (msg[15]==1, if (msg[15]==1,
{ {
( ~btn7val = (~btn7val + 1) % 8 ) ; ( ~btn6val = (~btn6val + 1) % 8 ) ;
switch(~btn7val, switch(~btn6val,
0, { ~g1.set(\imp, 0); "IMPULSE = 0".postln; }, 0, { ~g1.set(\imp, 1); "IMPULSE = 1".postln; },
1, { ~g1.set(\imp, 2); "IMPULSE = 2".postln; }, 1, { ~g1.set(\imp, 2); "IMPULSE = 2".postln; },
2, { ~g1.set(\imp, 4); "IMPULSE = 4".postln; }, 2, { ~g1.set(\imp, 4); "IMPULSE = 4".postln; },
3, { ~g1.set(\imp, 8); "IMPULSE = 8".postln; }, 3, { ~g1.set(\imp, 8); "IMPULSE = 8".postln; },
@ -352,8 +355,8 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----- G PANNING MODE // BUTTON X ----- G PANNING MODE
if (msg[16]==1, if (msg[16]==1,
{ {
( ~btn8val = (~btn8val + 1) % 3 ) ; ( ~btn7val = (~btn7val + 1) % 3 ) ;
switch( ~btn8val, switch( ~btn7val,
0, { ~gpanmode = 0 ; "PAN STEREO".postln; }, 0, { ~gpanmode = 0 ; "PAN STEREO".postln; },
1, { ~gpanmode = 1 ; "PAN QUAD ROTATIONS".postln; }, 1, { ~gpanmode = 1 ; "PAN QUAD ROTATIONS".postln; },
2, { ~gpanmode = 2 ; "PAN RANDOM QUAD".postln; }, 2, { ~gpanmode = 2 ; "PAN RANDOM QUAD".postln; },
@ -361,7 +364,6 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
}); });
}, /// SHIFT 0 LOGIC ENDS HERE -------------------------------------------- }, /// SHIFT 0 LOGIC ENDS HERE --------------------------------------------
{ {
@ -371,8 +373,10 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// GTR INPUT ======================= // GTR INPUT =======================
if (msg[11]==1, if (msg[11]==1,
{ {
( ~btn2val = (~btn2val + 1) % 7 ) ; ( ~btn10val = (~btn10val + 1) % 7 ) ;
switch(~btn2val,
switch(~btn10val,
0, { ~gtrIn.set(\in, 1 ); "DRY SIGNAL OFF".postln; }, 0, { ~gtrIn.set(\in, 1 ); "DRY SIGNAL OFF".postln; },
1, { ~gtrIn.set(\in, 0 ); ~instrPanMode=0; "DRY FRONT {STERE0}".postln; }, 1, { ~gtrIn.set(\in, 0 ); ~instrPanMode=0; "DRY FRONT {STERE0}".postln; },
2, { ~gtrIn.set(\in, 0 ); ~instrPanMode=1; "DRY BACK {STERE0}".postln; }, 2, { ~gtrIn.set(\in, 0 ); ~instrPanMode=1; "DRY BACK {STERE0}".postln; },
@ -391,8 +395,8 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----- GRANULAR POSITION MODE // BUTTON X ----- GRANULAR POSITION MODE
if (msg[13]==1, if (msg[13]==1,
{ {
( ~btn3val = (~btn3val + 1) % 5 ) ; ( ~btn12val = (~btn12val + 1) % 5 ) ;
switch(~btn3val, switch(~btn12val,
0, { ~positionmode = 0; "POSITION MODE FIXED".postln; }, 0, { ~positionmode = 0; "POSITION MODE FIXED".postln; },
1, { ~positionmode = 1; "POSITION MODE LOOPING".postln; }, 1, { ~positionmode = 1; "POSITION MODE LOOPING".postln; },
2, { ~positionmode = 2; "POSITION MODE RANDOM".postln; }, 2, { ~positionmode = 2; "POSITION MODE RANDOM".postln; },
@ -404,24 +408,24 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----- GRANULAR PITCH MODE // BUTTON X ----- GRANULAR PITCH MODE
if (msg[14]==1, if (msg[14]==1,
{ {
( ~btn6val = (~btn6val + 1) % 7 ) ; ( ~btn13val = (~btn13val + 1) % 8 ) ;
switch(~btn6val, switch(~btn13val,
0, { ~pitchmode = 2; "mode 2".postln; }, 0, { ~pitchmode = 2; "pitch array 0".postln; },
1, { ~pitchmode = 2; "mode 2 reserve".postln; }, 1, { ~pitchmode = 3; "pitch array 1".postln; },
2, { ~pitchmode = 3; ~g1.set(\rlow, 0.8); ~g1.set(\rhigh, 1.2); "PITCH RANDOM 1".postln; }, 2, { ~pitchmode = 4; "pitch array 2".postln; },
3, { ~pitchmode = 3; ~g1.set(\rlow, 0.01); ~g1.set(\rhigh, 1.5); "PITCH MODE RANDOM 2".postln; }, 3, { ~pitchmode = 5; "pitch array 3".postln; },
4, { ~pitchmode = 3; ~g1.set(\rlow, -1.5 ); ~g1.set(\rhigh, 1.5); "PITCH MODE RANDOM 3".postln; }, 4, { ~pitchmode = 6; "pitch array 4".postln; },
5, { ~pitchmode = 3; ~g1.set(\rlow, -5 ); ~g1.set(\rhigh, 5); "PITCH MODE RANDOM 4".postln; }, 5, { ~pitchmode = 7; ~g1.set(\rlow, -0.8 ); ~g1.set(\rhigh, 1.5); "PITCH MODE RANDOM 4".postln; },
6, { ~pitchmode = 3; ~g1.set(\rlow, -10 ); ~g1.set(\rhigh, 10); "PITCH MODE RANDOM 5".postln; }, 6, { ~pitchmode = 7; ~g1.set(\rlow, -3 ); ~g1.set(\rhigh, 3); "PITCH MODE RANDOM 5".postln; },
7, { ~pitchmode = 3; ~g1.set(\rlow, -30 ); ~g1.set(\rhigh, 30); "PITCH MODE RANDOM 6".postln; }, 7, { ~pitchmode = 7; ~g1.set(\rlow, -8 ); ~g1.set(\rhigh, 8); "PITCH MODE RANDOM 6".postln; },
) )
}); });
// BUTTON X ----- GRAIN DURATION MODE // BUTTON X ----- GRAIN DURATION MODE
if (msg[15]==1, if (msg[15]==1,
{ {
( ~btn8val = (~btn8val + 1) % 7 ) ; ( ~btn14val = (~btn14val + 1) % 7 ) ;
switch(~btn8val, switch(~btn14val,
0, { ~gdurmode = 0; ~g1.set(\imp, 40); "DURATION MODE 0".postln; }, 0, { ~gdurmode = 0; ~g1.set(\imp, 40); "DURATION MODE 0".postln; },
1, { ~gdurmode = 1; ~g1.set(\imp, 30); "DURATION MODE 1".postln; }, 1, { ~gdurmode = 1; ~g1.set(\imp, 30); "DURATION MODE 1".postln; },
2, { ~gdurmode = 2; ~g1.set(\imp, 20); "DURATION MODE 2".postln; }, 2, { ~gdurmode = 2; ~g1.set(\imp, 20); "DURATION MODE 2".postln; },
@ -435,8 +439,8 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
// BUTTON X ----- GRANULAR IMPULSE MODE // BUTTON X ----- GRANULAR IMPULSE MODE
if (msg[16]==1, if (msg[16]==1,
{ {
( ~btn7val = (~btn7val + 1) % 3 ) ; ( ~btn15val = (~btn15val + 1) % 3 ) ;
switch( ~btn7val, switch( ~btn15val,
0, { ~g1.set(\impulsemodeindex, 0 ); "IMPULSE MODE FIXED".postln; }, 0, { ~g1.set(\impulsemodeindex, 0 ); "IMPULSE MODE FIXED".postln; },
1, { ~g1.set(\impulsemodeindex, 1 ); "IMPULSE MODE DUST".postln; }, 1, { ~g1.set(\impulsemodeindex, 1 ); "IMPULSE MODE DUST".postln; },
2, { ~g1.set(\impulsemodeindex, 2 ); "IMPULSE MODE SENSOR".postln; }, 2, { ~g1.set(\impulsemodeindex, 2 ); "IMPULSE MODE SENSOR".postln; },
@ -502,6 +506,12 @@ r.set(\overdub, 0); // off
~gpanmode = 2 ; // random position ~gpanmode = 2 ; // random position
~gpanmode = 3 ; // random position ~gpanmode = 3 ; // random position
~dseqarrayIndex=0;
~g1.set(\dseqarrayIndex, 0);
~g1.set(\gpan, -1 ); ~g1.set(\gpan, -1 );
~channelmode = 1; ~channelmode = 1;