improvements to installation audio player

main
mwinter 1 year ago
parent 32b4768ca6
commit b96cca7a2e

@ -1,44 +1,51 @@
(
SynthDef(\hdpPlayer, {arg playDurBus = 5, playBuf = 0;
var startTrig, playDur, fadeTime, changeTrig, playSig, fade;
startTrig = InTrig.kr(playDurBus);
playDur = In.kr(playDurBus);
SynthDef(\hdpPlayer, {arg playBuf = 0, gate = 0;
var playDur, fadeTime, changeTrig, playSig, fade;
fadeTime = 30;
playSig = PlayBuf.ar(2, playBuf, BufRateScale.kr(playBuf), startTrig, 0);
fade = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), Stepper.kr(startTrig + TDelay.kr(startTrig, playDur - fadeTime), 0, 0, 1));
playSig = PlayBuf.ar(2, playBuf, BufRateScale.kr(playBuf), gate, 0);
fade = EnvGen.kr(Env.asr(fadeTime, 1, fadeTime), gate);
Out.ar(0, playSig * fade);
Out.ar([0, 1], BrownNoise.ar * 0.05 * (fade - 1).abs);
SendReply.kr(TDelay.kr(startTrig, playDur), '/unlock');
}).add;
);
(
var recDir, recPaths, recInfo, playBuf, playDurBus, lock;
recDir = "/home/mwinter/a_history_of_the_domino_problem/recs/";
var recDir, recPaths, recInfo, playBuf, player, isPlaying, playRoutine;
recDir = "/home/mwinter/Portfolio/a_history_of_the_domino_problem/a_history_of_the_domino_problem_source/recs/";
recPaths = ["berger_knuth.wav", "robinson.wav", "penrose.wav", "ammann.wav", "kari_culik.wav", "jaendel_rao.wav"].collect({arg file; recDir +/+ file});
recInfo = recPaths.collect({arg path; var sndFile; sndFile = SoundFile.openRead(path); [sndFile.numFrames, sndFile.sampleRate]});
playBuf = Buffer.read(s, recPaths[0]);
playDurBus = Bus.control(s,1);
lock = false;
//lock = false;
isPlaying = false;
player = Synth(\hdpPlayer, [\playBuf, playBuf]);
OSCFunc({ arg msg, time;
var numPlayFrames, startFrame;
[time, msg].postln;
lock.postln;
if(lock.not, {
numPlayFrames = (5.rand + 5) * 60 * recInfo[msg[1]][1];
startFrame = (recInfo[msg[1]][0] - numPlayFrames).rand;
//lock.postln;
playRoutine.stop;
playRoutine = Routine({
var playDur, piece, numPlayFrames, startFrame;
if(isPlaying, {
player.set(\gate, 0);
30.wait;
});
isPlaying = true;
piece = msg[1];
playDur = (5.0.rand + 5) * 10;
numPlayFrames = playDur * recInfo[piece][1];
startFrame = (recInfo[piece][0] - numPlayFrames).rand;
playBuf.free;
playBuf = Buffer.read(s, recPaths[msg[1]], startFrame, numPlayFrames, action: {arg buf;
playDurBus.set(numPlayFrames / recInfo[msg[1]][1])
playBuf = Buffer.read(s, recPaths[piece], startFrame, numPlayFrames, action: {arg buf;
player.set(\gate, 1);
});
lock = true;
Routine({10.wait; lock = false; lock.postln}).play
});
(playDur - 30).wait;
player.set(\gate, 0);
30.wait;
isPlaying = false;
}).play
},'/playTiling', n);
Synth(\hdpPlayer, [\playDurBus, playDurBus, \playBuf, playBuf]);
)
n = NetAddr("127.0.0.1", 57120)
n.sendMsg('/playTiling', 5)
n.sendMsg('/playTiling', 1)

Loading…
Cancel
Save