new button logic in supercollider
parent
3f595e5750
commit
d2ec85ba95
187
gtr.scd
187
gtr.scd
|
@ -11,10 +11,7 @@
|
|||
|/ '-' '-'
|
||||
|
||||
Ljudmila OTF Hackathon, Maribor 1-6 March 2022 */
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
// guitar MAC address 98:CD:AC:63:78:E2
|
||||
// GTR MAC address: 10:97:BD:36:D6:4E
|
||||
|
||||
// RUNME 0 =========================================
|
||||
s.boot();
|
||||
|
@ -35,6 +32,7 @@ thisProcess.openUDPPort(57121);
|
|||
|
||||
// RUNME 2 ==========================================
|
||||
// -------------------------------------------------
|
||||
|
||||
( // DEFINE SYNTHS --------------------------------- <--
|
||||
// -------------------------------------------------
|
||||
|
||||
|
@ -53,11 +51,11 @@ SynthDef("dryIn", { arg in=0, out=0;
|
|||
( // mono buffer recorder ----------------------------
|
||||
// with loop and overdub modes /////////////////////
|
||||
// make record togglable between looping, direct or onset detection trigger
|
||||
SynthDef("recBuf",{ arg in=0, out=0, bufnum=0, t_trig=0, l=0, overdub=0;
|
||||
|
||||
SynthDef("recBuf",{
|
||||
arg in=0, out=0, bufnum=0, t_trig=0, l=0, overdub=0;
|
||||
var sig, chain, onsets;
|
||||
sig = SoundIn.ar(in);
|
||||
|
||||
// Onsets
|
||||
chain = FFT(LocalBuf(512), sig);
|
||||
onsets = Onsets.kr(chain, MouseX.kr(0,1), \rcomplex);
|
||||
|
@ -88,7 +86,7 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 1,
|
|||
|
||||
var signal, env, freqdev, pos,
|
||||
pitchmode0, pitchmode1, pitch,
|
||||
gdurmode0, gdurmode1, gdur,
|
||||
gdurmode0, gdurmode1, gdurmode2, gdur,
|
||||
gpanmode0, gpanmode1, gpan,
|
||||
positionmode0, positionmode1, position,
|
||||
impulsemode0, impulsemode1, impulse;
|
||||
|
@ -96,8 +94,10 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 1,
|
|||
// grain duration mode -untransposed, random, or sensor controlled
|
||||
gdurmode0 = 0.1;
|
||||
gdurmode1 = LFNoise1.kr.range(0.2, 3.3);
|
||||
gdurmode2 = LFNoise1.kr.range(0.2, 3.3);
|
||||
|
||||
gdur = Select.kr(gdurmodeindex,
|
||||
[gdurmode0, gdurmode1, sensorgdur]);
|
||||
[gdurmode0, gdurmode1, gdurmode2, sensorgdur]);
|
||||
|
||||
// grain pan mode -untransposed, random, or sensor controlled
|
||||
gpanmode0 = 0.1;
|
||||
|
@ -142,6 +142,7 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 1,
|
|||
// RUNME 3 ==========================================
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
||||
(( // START SYNTHS ---------------------------------
|
||||
// ----------------------------------------------------
|
||||
|
||||
|
@ -156,7 +157,7 @@ SynthDef(\buf_grain, { | out, gate = 1, amp = 1,
|
|||
// ----------------------------------------------------
|
||||
(( // OSC Receivers // ENABLE SENSOR AND SWITCH VALUES <--
|
||||
// ----------------------------------------------------
|
||||
~pitchmode = 0; ~positionmode = 2; ~impulsemode = 0; ~gdurmode=0; ~gpanmode=0;
|
||||
~pitchmode = 0; ~positionmode = 0; ~impulsemode = 0; ~gdurmode=0; ~gpanmode=0;
|
||||
|
||||
( // accel gyro quaternion mapping ///////////////////
|
||||
// msg[1] msg[2] msg[3] X Y Z ==> ROLL, PITCH, YAW
|
||||
|
@ -194,7 +195,14 @@ o = OSCdef(\test, { arg msg, time, addr, recvPort, rlow, rhigh;
|
|||
// button press mapping ///////////////////////////////
|
||||
// ----------------------------------------------------
|
||||
|
||||
~btn2val = 0;
|
||||
~btn0val = 0; ~btn1val = 0; ~btn2val = 0; ~btn3val = 0;
|
||||
~btn4val = 0; ~btn5val = 0; ~btn6val = 0; ~btn7val = 0;
|
||||
~btn8val = 0; // shift buttons
|
||||
|
||||
|
||||
m = NetAddr("127.0.0.1", 57120); // loopback
|
||||
m.sendMsg("/chat", "Hello App 1");
|
||||
|
||||
|
||||
p = OSCdef(\keys, { arg msg, time, addr, recvPort;
|
||||
//msg.println;
|
||||
|
@ -208,100 +216,93 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
|
|||
if (msg[9] == 0, {
|
||||
|
||||
// BUTTON X ----- TRIGGER ONESHOT BUFFER RECORD
|
||||
if (msg[10] == 1, { r.set( \in, 0, \l, 0, \t_trig, 1);
|
||||
if (msg[10] == 1, { r.set( \in, 0, \l, 0, \t_trig, 1);
|
||||
" /////////// SAMPLING!".postln }, {});
|
||||
|
||||
|
||||
|
||||
if (msg[16]==1,
|
||||
// BUTTON X ----> LOOP RECORDING MODE ON/OFF
|
||||
if (msg[11]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 3 ) ;
|
||||
|
||||
switch(~btn2val,
|
||||
0, { ~positionmode = 0; "TEST MODE FIXED".postln; },
|
||||
1, { ~positionmode = 1; "POSITION MODE RANDOM".postln; },
|
||||
2, { ~positionmode = 2; "POSITION MODE SENSOR".postln; },
|
||||
)
|
||||
( ~btn4val = (~btn4val + 1) % 3 ) ;
|
||||
switch( ~btn4val,
|
||||
0, { r.set(\l, 0); "RECORD LOOPING OFF".postln; },
|
||||
1, { r.set(\l, 1); "RECORD LOOPING ON".postln; },
|
||||
2, { r.set(\l, 1); "RECORDING ONSET DETECTION ON".postln; }, //todo
|
||||
)
|
||||
});
|
||||
|
||||
// BUTTON X ----- GRANULAR POSITION MODE
|
||||
|
||||
if (msg[11]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 3 ) ;
|
||||
|
||||
switch(~btn2val,
|
||||
0, { ~positionmode = 0; "POSITION MODE FIXED".postln; },
|
||||
1, { ~positionmode = 1; "POSITION MODE RANDOM".postln; },
|
||||
2, { ~positionmode = 2; "POSITION MODE SENSOR".postln; },
|
||||
)
|
||||
// BUTTON X ----> OVERDUB RECORDING MODE ON/OFF
|
||||
if (msg[12]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 2 ) ;
|
||||
switch( ~btn2val,
|
||||
0, { r.set(\overdub, 0); "SAMPLE OVERDUB OFF".postln; },
|
||||
1, { r.set(\overdub, 1); "SAMPLE OVERDUB ON".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
// BUTTON X ----- GRANULAR PITCH MODE
|
||||
|
||||
if (msg[15]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 3 ) ;
|
||||
|
||||
switch(~btn2val,
|
||||
0, { ~granulator1.set(\pitchmodeindex, 0 ); "PITCH MODE FIXED".postln; },
|
||||
1, { ~granulator1.set(\pitchmodeindex, 1 ); "PITCH MODE RANDOM".postln; },
|
||||
2, { ~granulator1.set(\pitchmodeindex, 2 ); "PITCH MODE SENSOR".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
// BUTTON X ----- GRANULAR IMPULSE MODE
|
||||
|
||||
if (msg[12]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 3 ) ;
|
||||
|
||||
switch( msg[12].asInteger,
|
||||
0, { ~granulator1.set(\impulsemodeindex, 0 ); "IMPULSE MODE FIXED".postln; },
|
||||
1, { ~granulator1.set(\impulsemodeindex, 1 ); "IMPULSE MODE DUST".postln; },
|
||||
2, { ~granulator1.set(\impulsemodeindex, 2 ); "IMPULSE MODE SENSOR".postln; },
|
||||
);
|
||||
};
|
||||
|
||||
);
|
||||
|
||||
// BUTTON X ----> LOOP RECORDING MODE ON/OFF
|
||||
|
||||
|
||||
if (msg[13]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 2 ) ;
|
||||
|
||||
switch( msg[13].asInteger,
|
||||
0, { r.set(\l, 1); "RECORD LOOPING ON".postln; },
|
||||
1, { r.set(\l, 0); "RECORD LOOPING OFF".postln; }
|
||||
);
|
||||
};
|
||||
|
||||
);
|
||||
|
||||
// BUTTON X ----> OVERDUB RECORDING MODE ON/OFF
|
||||
|
||||
if (msg[14]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 2 ) ;
|
||||
switch( msg[14].asInteger,
|
||||
0, { r.set(\overdub, 1); "SAMPLE OVERDUB ON".postln; },
|
||||
1, { r.set(\overdub, 0); "SAMPLE OVERDUB OFF".postln; },
|
||||
);
|
||||
};
|
||||
);
|
||||
|
||||
}, /// SHIFT 0 LOGIC ENDS HERE
|
||||
|
||||
{ // SHIFT IN STATE 1 =======================
|
||||
|
||||
// BUTTON X && X RESET/ZERO SENSORS [in firmware]
|
||||
// BUTTON X ----- GRAIN DURATION MODE
|
||||
if (msg[15]==1,
|
||||
{
|
||||
( ~btn8val = (~btn8val + 1) % 4 ) ;
|
||||
switch(~btn8val,
|
||||
0, { ~gdurmode = 0; "DURATION MODE 0".postln; },
|
||||
1, { ~gdurmode = 1; "DURATION MODE 1".postln; },
|
||||
2, { ~gdurmode = 2; "DURATION MODE 2".postln; },
|
||||
3, { ~gdurmode = 3; "DURATION MODE 3".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
if (msg[11] == 1,
|
||||
{ " ===== EULER ZEROED! =====".postln },
|
||||
{});
|
||||
// BUTTON X ----- GRANULAR POSITION MODE
|
||||
if (msg[13]==1,
|
||||
{
|
||||
( ~btn3val = (~btn3val + 1) % 3 ) ;
|
||||
switch(~btn3val,
|
||||
0, { ~positionmode = 0; "POSITION MODE FIXED".postln; },
|
||||
1, { ~positionmode = 1; "POSITION MODE RANDOM".postln; },
|
||||
2, { ~positionmode = 2; "POSITION MODE SENSOR".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
// BUTTON X ----- GRANULAR PITCH MODE
|
||||
if (msg[14]==1,
|
||||
{
|
||||
( ~btn6val = (~btn6val + 1) % 3 ) ;
|
||||
switch(~btn6val,
|
||||
0, { ~pitchmode = 0; "PITCH MODE FIXED".postln; },
|
||||
1, { ~pitchmode = 1; "PITCH MODE RANDOM".postln; },
|
||||
2, { ~pitchmode = 2; "PITCH MODE SENSOR".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
// BUTTON X ----- GRANULAR IMPULSE MODE
|
||||
if (msg[16]==1,
|
||||
{
|
||||
( ~btn7val = (~btn7val + 1) % 3 ) ;
|
||||
switch( ~btn7val,
|
||||
0, { ~granulator1.set(\impulsemodeindex, 0 ); "IMPULSE MODE FIXED".postln; },
|
||||
1, { ~granulator1.set(\impulsemodeindex, 1 ); "IMPULSE MODE DUST".postln; },
|
||||
2, { ~granulator1.set(\impulsemodeindex, 2 ); "IMPULSE MODE SENSOR".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
// BUTTON X && X RESET/ZERO SENSORS [in firmware just here for notificaton]
|
||||
if (msg[12] == 1, { " ===== EULER ZEROED! =====".postln }, {});
|
||||
|
||||
// GTR INPUT =======================
|
||||
if (msg[11]==1,
|
||||
{
|
||||
( ~btn2val = (~btn2val + 1) % 3 ) ;
|
||||
switch(~btn2val,
|
||||
0, { ~gtrIn.set(\in, 1 ); "DRY SIGNAL OFF".postln; },
|
||||
1, { ~gtrIn.set(\in, 0 ); "DRY SIGNAL ON".postln; },
|
||||
2, { ~gtrIn.set(\in, 1 ); "DRY + REVERB ON".postln; },
|
||||
)
|
||||
});
|
||||
|
||||
} // SHIFT ONE LOGIC ENDS HERE ================
|
||||
|
||||
|
@ -311,7 +312,7 @@ p = OSCdef(\keys, { arg msg, time, addr, recvPort;
|
|||
|
||||
);
|
||||
);
|
||||
|
||||
GUI
|
||||
// ----------------------------------------------------
|
||||
// ----------------------------------------------------
|
||||
// PERFORMABLE PARAMETERS /////////////////////////////
|
||||
|
@ -332,7 +333,7 @@ r.set(\overdub, 0); // off
|
|||
~granulator1.set(\rlow, 0);
|
||||
~granulator1.set(\rlow, -1);
|
||||
~granulator1.set(\rhigh, 1);
|
||||
~granulator1.set(\rhigh, 3);
|
||||
~granulator1.set(\rhigh, 2);
|
||||
|
||||
~impulsemode = 0; // impulse
|
||||
~impulsemode = 1; // dust
|
||||
|
|
|
@ -130,11 +130,7 @@ float GyX, GyY, GyZ;
|
|||
|
||||
// Keys
|
||||
//byte keys[] = {16, 17, 5, 18};
|
||||
|
||||
// noise on
|
||||
byte keys[] = {4, 0, 2, 15, 13, 14, 12, 27}; // TOUCH0 - TOUCH7
|
||||
//byte keys[] = {33, 0, 2, 15, 13, 14, 12, 27}; // TOUCH8, TOUCH1 - TOUCH7
|
||||
|
||||
|
||||
byte pressed[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
byte KEYLEN = 8;
|
||||
|
@ -188,6 +184,7 @@ int touchValue;
|
|||
|
||||
|
||||
void setup() {
|
||||
pinMode(32, OUTPUT);
|
||||
// Basic(debug) serial init
|
||||
Serial.begin(115200); // set this as high as you can reliably run on your platform
|
||||
Serial.println("Starting up...");
|
||||
|
@ -301,6 +298,7 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
// LED ON
|
||||
|
||||
// capacitive ------------------
|
||||
|
||||
|
@ -390,7 +388,7 @@ void loop() {
|
|||
speed += speedGain;
|
||||
|
||||
bundle.add("/position/").add(position(0)).add(position(1)).add(position(2));
|
||||
bundle.add("/speed/").add(speed(0)).add(speed(1)).add(speed(2));
|
||||
bundle.add("3/speed/").add(speed(0)).add(speed(1)).add(speed(2));
|
||||
*/
|
||||
// Accelerometer
|
||||
bundle.add("/accel").add(AcX).add(AcY).add(AcZ); ; // X Y Z
|
||||
|
@ -399,16 +397,14 @@ void loop() {
|
|||
bundle.add("/keys"); // A B C D E
|
||||
|
||||
// Send keys
|
||||
for(int i = 0; i < KEYLEN; i++) {
|
||||
|
||||
//pressed[i] = !digitalRead(keys[i]);
|
||||
for(int i = 0; i < KEYLEN; i++) {
|
||||
pressed[i] = touchRead(keys[i]);
|
||||
|
||||
|
||||
|
||||
bundle.getOSCMessage("/keys")->add(pressed[i]);
|
||||
}
|
||||
|
||||
if (pressed[0] != 0 ){ digitalWrite(32, HIGH);}
|
||||
else { digitalWrite(32, LOW); };
|
||||
|
||||
// Reset calibration euler?
|
||||
if (pressed[0] && pressed[1] && pressed[2] && pressed[3]) {
|
||||
if (!reset) {
|
||||
|
|
Loading…
Reference in New Issue