Skip to content

Instantly share code, notes, and snippets.

@pfig
Created October 10, 2016 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfig/62205a94ebe1d1d849da1f2cbc2deca1 to your computer and use it in GitHub Desktop.
Save pfig/62205a94ebe1d1d849da1f2cbc2deca1 to your computer and use it in GitHub Desktop.
A crude driver for my attempts at phase music
s.quit;
s.boot;
(
b = Buffer.read(s, thisProcess.nowExecutingPath.dirname +/+ "press_the_red_again.wav");
k = Buffer.read(s, thisProcess.nowExecutingPath.dirname +/+ "kissy_face.wav");
m = Buffer.read(s, thisProcess.nowExecutingPath.dirname +/+ "notice_me_senpai_short.aiff");
// Create a Synth capable of all the transforms we want
SynthDef(\reich, {
arg out=0, bufnum=b.bufnum, rate=1, glide=0, gate=1, loopRel=0, startPos=0, pan=0,
startLoop=85000, endLoop=129500, ipol=4;
var env, signal;
rate = Lag.kr(rate, glide);
env = EnvGen.ar(Env.adsr(0.1, 0.2, 1, 2), gate, doneAction: 2);
signal = LoopBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, gate + loopRel,
startPos, startLoop, endLoop, ipol);
Out.ar(out, Pan2.ar(signal * env, pan));
}).add;
// Granulator triggered by audio in, by Sam Pluta
SynthDef("TriggerBufferGranular", {arg out=0, bufnum=0, in=1, thresh = 0.004, ampScaler = 1, duration =
0.2, pan=0,centerPosition=0.1, interp=1, incrementBy = 200;
var trig, amp, gatedAmp, triggerBool, outamp, bufferFrames, bufRateScale;
var bufPointer, trigs, env, envGens, outArray, grNum;
grNum = 4; // the number of granulators in the synthdef
bufferFrames = BufFrames.kr(bufnum);
bufRateScale = BufRateScale.kr(bufnum);
amp = Amplitude.kr (AudioIn.ar(in));
triggerBool = (AudioIn.ar(in) >= thresh);
gatedAmp = Latch.kr(amp, triggerBool);
outamp = (gatedAmp * ampScaler);
trig = Trig.kr(triggerBool, duration/4); //makes a trigger if triggerBool goes over the threshold
env = Env([0,1,0],[duration/2,duration/2],'sine');
bufPointer = PulseCount.kr(trig); //a counter that counts the number of triggers triggered
//each trigger below triggers once for every four times trig (above) triggers (if a trig trig could trig trig)
trigs = Array.fill(grNum, {|i| PulseDivider.kr(trig, 4, i )});
envGens = Array.fill(grNum, {|i| EnvGen.kr(env, trigs[i] ) });
//trigs correspond to and trigger a PlayBuf below - the pointer slowly moves through the file
outArray = Array.fill(grNum, {|i| PlayBuf.ar(1, bufnum, bufRateScale, trigs[i], (bufPointer*incrementBy)%bufferFrames)*envGens[i]});
Out.ar(out, Pan2.ar(Mix(outArray)));
}).add;
)
(
// Start the jazz
var timeNow = TempoClock.default.beats;
// These are the loops I want going (named in a ratePan format)
// normalLeft, bumpedRight, bumpedRight2, bumpedLeft, slowRight, slowLeft;
var redNormalLeft = Task({ Synth(\reich, [pan: -1]).postln; });
var redBumpedRight = Task({Synth(\reich, [pan: 1, rate: 1.0004]).postln; });
var redBumpedLeft = Task({ Synth(\reich, [pan: -1, rate: 1.0006]).postln; });
var redBumpedRight2 = Task({ Synth(\reich, [pan: 1, rate: 1.001]).postln; });
var redSlowRight = Task({ Synth(\reich, [pan: 1, rate: 0.133]).postln; });
var redSlowLeft = Task({ Synth(\reich, [pan: -1, rate: 0.134]).postln; });
var kissy = Task({
"kissy: ".post;
Synth(\TriggerBufferGranular, [out: 0, bufnum: k.bufnum]).postln;
});
var senpaiNormalLeft = Task({ Synth(\reich, [bufnum: m.bufnum, pan: -1, startLoop: 0, endLoop: m.numFrames]).postln; });
var senpaiBumpedRight = Task({Synth(\reich, [bufnum: m.bufnum, startLoop: 0, endLoop: m.numFrames, pan: 1, rate: 1.0006]).postln; });
var senpaiBumpedLeft = Task({ Synth(\reich, [bufnum: m.bufnum, startLoop: 0, endLoop: m.numFrames, pan: -1, rate: 1.001]).postln; });
var senpaiBumpedRight2 = Task({ Synth(\reich, [bufnum: m.bufnum, startLoop: 0, endLoop: m.numFrames, pan: 1, rate: 1.005]).postln; });
var senpaiSlowRight = Task({ Synth(\reich, [bufnum: m.bufnum, startLoop: 0, endLoop: m.numFrames, pan: 1, rate: 0.133]).postln; });
var senpaiSlowLeft = Task({ Synth(\reich, [bufnum: m.bufnum, startLoop: 0, endLoop: m.numFrames, pan: -1, rate: 0.134]).postln; });
kissy.play(quant: timeNow + 30.0);
redNormalLeft.play(quant: timeNow + 1.0);
redBumpedLeft.play(quant: timeNow + 1.0);
redSlowLeft.play(quant: timeNow + 1.0);
redBumpedRight.play(quant: timeNow + 1.0);
redBumpedRight2.play(quant: timeNow + 1.0);
redSlowRight.play(quant: timeNow + 1.0);
senpaiNormalLeft.play(quant: timeNow + 420.0);
senpaiBumpedLeft.play(quant: timeNow + 420.0);
senpaiSlowLeft.play(quant: timeNow + 420.0);
senpaiBumpedRight.play(quant: timeNow + 420.0);
senpaiBumpedRight2.play(quant: timeNow + 420.0);
senpaiSlowRight.play(quant: timeNow + 420.0);
)
// stop red
(
s.sendMsg("/n_set", 1000, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1001, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1002, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1003, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1004, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1005, \loopRel, 1, \gate, 0);
// lower kissy at the same time
s.sendMsg("/n_set", 1006, \ampScaler, 0.3);
)
// lower kissy
(
s.sendMsg("/n_set", 1006, \ampScaler, 0.3);
)
// stop kissy
(
s.sendMsg("/n_free", 1006);
)
// stop senpai
(
s.sendMsg("/n_set", 1007, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1008, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1009, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1010, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1011, \loopRel, 1, \gate, 0);
s.sendMsg("/n_set", 1012, \loopRel, 1, \gate, 0);
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment