-
functional draft
Karst-031-secondforce by Meghatron
This draft is functioning, i.e. exoskeleton activated 24” force sensors with correct behaviors. Needs a lot of work on trigger control, but now that it’s all working I can dive into the compositional considerations. I’m still using the previous work for formal considerations, but will try to rely on the inherent properties of this form as well.
SuperCollider code below, there is still a ton of junk in there that needs to be jettisoned as I finalize the piece.
//Karst version 31
//code still not finalized but getting cleaned up
//things to do:
//add envelope with gate to decrease clipping
//setup MOTU inputs for wall scraping with exoskeleton
//more notes in the code to help with version tracking in the final 24 hours
//add notes about site layout where pertinent
//test different sensor behavior with exoskeleton -DONE
//transition to normalized audio files - DONE
//add stops to sensor behavior: CmdPeriod.run; and a-k.stop inside fork
//SERVER
(
Server.default = s = Server.internal.boot;
s.waitForBoot({
});
)
//ARDUINO
(
SerialPort.listDevices;
d = SerialPort.devices[2];
f = SCPyduino.new(d); //declares f an SCPyduino object
)
//KARST MAIN CODE BLOCK
(
//VARIABLES
//synths
var synth, synth2;
//functions
var func, pfunc, ffunc;
//alpha &
var omega = 1;
//sample variables
var transform, death, machine, noisefloor;
//crap imma get rid of
var syn1, syn2, syn3, syn4, syn5, syn6;
var breath, chant;
//more joshparametrical magic right here
var flex1, flex2, controlflex1, controlflex2;
controlflex1 = CtkControl.play;
controlflex2 = CtkControl.play;
//SAMPLES
//Source = Rilke: Orpheus Sonnet pt2 10 “The machine threatens all we have gained, so long as it dare become the tyrant of spirit, rather than its servant.”
machine = CtkBuffer.playbuf(“sounds/Karst_Machine.aif”).load;
//Source = Rilke: Orpheus Sonnet pt2 11 “Many quietly acceptable methods of death have come to pass since onward conquering man first laid claim to the hunter’s arts;….”
death = CtkBuffer.playbuf(“sounds/Karst_Death.aif”).load;
//Source = Rilke: Orpheus Sonnet pt2 12 “Aspire to transform, O enraptured be by the fire wherein something elusive flames with brazen tidings of change;….”
transform = CtkBuffer.playbuf(“sounds/Karst_Transform.aif”).load;
//Source = Site Noisefloor, May 29, 2010
noisefloor = CtkBuffer.playbuf(“sounds/Karst_Noisefloor.aif”).load;
//testing samples
breath = CtkBuffer.playbuf(“sounds/breath.aif”).load;
chant = CtkBuffer.playbuf(“sounds/chant.aif”).load;
CmdPeriod.doOnce({“I’m freeing the buffers!”.postln;
machine.free;
death.free;
transform.free;
noisefloor.free;
breath.free;
chant.free;
});
//SYNTHDEFS
// trigger synth
synth = CtkSynthDef(\synth, {arg imp, begin, out = 0, bufnum = 0, pan = 0, amp =0.5, deviation = 0, pch = 1;
var trig, sig, sampstosecs, devAmt, outsig;
trig = Impulse.ar(imp);
sampstosecs = (SampleRate.ir * BufRateScale.kr(bufnum));
devAmt = (deviation * LFNoise1.kr( imp) * sampstosecs);
sig = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * pch, trig, (begin * sampstosecs) + devAmt, 0);
outsig = Pan2.ar(sig*amp, pan);
Out.ar(out, [outsig[0], DelayN.ar(outsig[1], 0.002, 0.002)]);
});
//FUNCTIONS
//FUNC :: for use with impulse triggers
func = {arg duration, amp, rhythms, durs, imps, begs, pans, dev;
var start, now, index, dur, imp, beg, rhy, pan1;
Task({
start = Main.elapsedTime;
now = 0;
index = 0;
imp = imps;
while({
now < duration;
}, {
now = Main.elapsedTime - start;
rhy = rhythms[index%rhythms.size];
dur = durs[index%durs.size];
imp = imps[index%imps.size];
beg = begs[index%begs.size];
pan1 =pans[index%pans.size];
synth.new(0, 10).bufnum_(noisefloor.bufnum).imp_(4).begin_(beg).pan_(pan1).amp_(amp).deviation_(dev)
.pch_(controlflex1).play;
(rhy + dur).wait;
index = index + 1;
})
}).play
};
//PFUNC :: make my func the pfunc
pfunc = {arg duration, amp, rhythms, durs, imps, begs, pans, dev;
var start, now, index, dur, imp, beg, rhy, pan1;
Task({
start = Main.elapsedTime;
now = 0;
index = 0;
imp = imps;
while({
now < duration;
}, {
now = Main.elapsedTime - start;
rhy = rhythms[index%rhythms.size];
dur = durs[index%durs.size];
imp = imps[index%imps.size];
beg = begs[index%begs.size];
pan1 =pans[index%pans.size];
synth.new(0, 10).bufnum_(noisefloor.bufnum).imp_(4).begin_(beg).pan_(pan1).amp_(amp).deviation_(dev).play;
(rhy + dur).wait;
index = index + 1;
})
}).play
};
//FFUNC
ffunc = {arg duration, amp, rhythms, durs, imps, begs, pans, dev;
var start, now, index, dur, imp, beg, rhy, pan1;
Task({
start = Main.elapsedTime;
now = 0;
index = 0;
imp = imps;
while({
now < duration;
}, {
now = Main.elapsedTime - start;
rhy = rhythms[index%rhythms.size];
dur = durs[index%durs.size];
imp = imps[index%imps.size];
beg = begs[index%begs.size];
pan1 =pans[index%pans.size];
synth.new(0, 10).bufnum_(machine.bufnum).imp_(4).begin_(beg).pan_(pan1).amp_(amp).deviation_(dev).play;
(rhy + dur).wait;
index = index + 1;
})
}).play
};
/*
//synth instantiations :: aka crap imma get rid of
syn1 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(0).pan_(1).amp_(4).deviation_(2).play;
syn2 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(110).pan_(-1).amp_(4).deviation_(2).play;
syn3 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(220).pan_(-1).amp_(4).deviation_(2).play;
syn4 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(330).pan_(-1).amp_(4).deviation_(2).play;
syn5 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(440).pan_(-1).amp_(4).deviation_(2).play;
syn6 = synth.new(0, nil).bufnum_(noisefloor.bufnum).imp_(4).begin_(550).pan_(-1).amp_(4).deviation_(2).play;
*/
//ARDUINO
//Arduino: Sensors
//Left Piezo “a” “u” lop
f.analog[0].active_(1);
//Left Flex “b” “v” lox
f.analog[1].active_(1);
//Left Force “c” “w” lor
f.analog[2].active_(1);
//Right Piezo “g” “x” rop
f.analog[3].active_(1);
//Right Flex “h” “y” rox
f.analog[4].active_(1);
//Right Force “k” “z” ror
f.analog[5].active_(1);
//j = CtkSynthDef(\grain, {arg freq, dur;
// Out.ar(0, SinOsc.ar(freq, 0, 0.1) * EnvGen.kr(Env([0, 1, 0], [0.5, 0.5], \sin), timeScale: dur, doneAction: 2))
// });
j = synth2 = CtkSynthDef(\synth2, {arg freq, dur, imp, begin, out = 0, bufnum = 0, pan = 0, amp =0.5, deviation = 0;
var trig, sig, sampstosecs, devAmt, outsig;
trig = Impulse.ar(imp);
sampstosecs = (SampleRate.ir * BufRateScale.kr(bufnum));
devAmt = (deviation * LFNoise1.kr( imp) * sampstosecs);
sig = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, (begin * sampstosecs) + devAmt, 0);
outsig = Pan2.ar(sig*amp, pan);
Out.ar(out, [outsig[0], DelayN.ar(outsig[1], 0.002, 0.002)]);
});
l = CtkSynthDef(\sawgrain, {arg freq, dur;
Out.ar(0, LFSaw.ar(freq, 0.05) * EnvGen.kr(Env([0, 1, 0], [0.5, 0.5], \sin), timeScale: dur, doneAction: 2))
});
k = {arg noteObj;
Task({
20.do({
noteObj.new.freq_(1000 - v).dur_(2.5).play;
0.05.wait;
})
}).play;
};
/*
//Left Piezo
a = fork{
loop{
var lop;
f.iterate;
u= f.analog[0].value;
“u:”.post;
u.postln;
lop = (1000-u)/100;
“lop: imp: “.post;
lop.postln;
syn1.imp_(lop);
0.001.wait;
}
};
*/
m = 0;
//Left Flex
//3030: this is working, starts inactive, is trigger at first bend and cycles through noisefloor functions, the first of which is pitch affected by sensor value
b = fork{
t = Main.elapsedTime;
loop{
var lox;
f.iterate;
v= f.analog[1].value;
flex1 = v;
//controlflex1.set((flex1 / 500) - 0.5);
controlflex1.set((flex1 / 250) - 0.5);
“v:”.post;
v.postln;
(v < 250).if({
(Main.elapsedTime > (t + 1)).if({
t = Main.elapsedTime;
m = m + 1;
m.postln;
[
{func.value(0.5, 0.5, [0.25],[3],[3],[4],[0, 1, -1],[2]).play},
{pfunc.value(2, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play},
//{ffunc.value(2, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play},
//{pfunc.value(0.1, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play}
].wrapAt(m).value;
//
//
// (m.odd).if({
// func.value(0.5, 0.5, [0.25],[3],[3],[4],[0, 1, -1],[2]).play;
// }, {
// pfunc.value(2, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play;
// },
// {
// pfunc.value(0.1, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play;
// });
//
// Task({
// 20.do({
// noteObj.new.freq_(1000 - v).dur_(2.5).play;
// 0.05.wait;
// })
// }).play;
})
});
lox = 250-v;
// “lox: imp: “.post;
// lox.postln;
//syn2.imp_(lox);
// if((v == 40) ,{arg inc = 0;
// inc = inc+1;
// func.value(0, 15, 0.5, [0.25],[3],[30],[4,5,6,7,8,9],[0, 1, -1],[4]).play;
// },{
//
// }
// );
0.001.wait;
}
};
/*
//Left Force
c = fork{
loop{
var lor;
f.iterate;
w= f.analog[2].value;
“w:”.post;
w.postln;
lor = 100-w;
“lor: imp: “.post;
lor.postln;
syn3.imp_(lor);
syn3.pan_(lor-80);
syn3.imp_(lor+0.1);
syn3.pan_(lor-90);
0.001.wait;
}
};
//Right Piezo
//Right Piezo has a yellow wire conencting to the breadboard in prototype layout
g = fork{
loop{
var rop;
f.iterate;
x= f.analog[3].value;
“x:”.post;
x.postln;
rop = x-350/100;
“imp “.post;
rop.postln;
syn4.imp_(rop);
0.001.wait;
}
};
*/
n = 0;
//Right Flex
h = fork{
t = Main.elapsedTime;
loop{
var lox;
f.iterate;
y= f.analog[4].value;
flex1 = y;
controlflex2.set((flex1 / 1000) - 0.5);
“y:”.post;
y.postln;
(y < 300).if({
(Main.elapsedTime > (t + 1)).if({
t = Main.elapsedTime;
n = n + 1;
n.postln;
[
{pfunc.value(0.5, 0.5, [0.25],[3],[3],[4],[0, 1, -1],[2]).play},
{ffunc.value(2, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play},
{pfunc.value(0.5, 0.5, [0.25],[30],[3],[4],[0, 1, -1],[2]).play},
{ffunc.value(2, 0.5, [0.25],[1],[5],[4,5,6,7,8,9],[0, 1, -1],[2]).play},
{pfunc.value(0.5, 0.5, [0.25],[5],[1],[4],[0, 1, -1],[2]).play},
{ffunc.value(2, 0.5, [0.25],[3],[3],[4,5,6,7,8,9],[0, 1, -1],[2]).play}
].wrapAt(m).value;
})
});
lox = 250-y;
0.001.wait;
}
};
/*
//Right Force
k= fork{
loop{
var ror;
f.iterate;
z = f.analog[5].value;
“z:”.post;
z.postln;
ror = 100-z;
syn6.begin_(ror);
“beg:”.post;
ror.postln;
0.001.wait;
}
};
*/
)
//cease reading values
(
a.stop;
b.stop;
c.stop;
g.stop;
h.stop;
k.stop;
)
//close the serial port
(
f.close;
)