Two approaches I think could help out:
- using the code as-is, I was able to run it with the following rules:
// select this line, and cmd-enter to evaluate it (load the file
// into a variable called b, used below)
b=Buffer.read(s,"/Users/admin/Desktop/scal.aif");
// select this from one parenthesis all the way to the other
// and cmd-enter to evaluate (plays the buffer)
// cmd-period will kill the audio... you can rerun it though!
(
{
var trig, rate, pos, sig, rec;
trig = Dust.ar(3);
rate = TChoose.kr(trig, [-2, 1, 2, -3, -0.75]);
pos = TRand.ar(0, BufFrames.ir(b), trig);
sig = PlayBuf.ar(2, b, loop: 1);
rec = Phasor.ar(trig, K2A.ar(rate), 0, BufFrames.ir(b), pos);
BufWr.ar(sig, b, rec);
sig
}.play;
)
// this line frees up the buffer, select + run it last to cleanup
// when you're finished
b.free;
- or, modify the code to not use a global variable
b
- itās now one big block you can run all at once easily by doing cmd-a (select all) cmd-enter (evaluate):
(
{
var buf, trig, rate, pos, sig, rec;
buf = Buffer.read(s,"/Users/admin/Desktop/scal.aif");
trig = Dust.ar(3);
rate = TChoose.kr(trig, [-2, 1, 2, -3, -0.75]);
pos = TRand.ar(0, BufFrames.ir(b), trig);
sig = PlayBuf.ar(2, b, loop: 1);
rec = Phasor.ar(trig, K2A.ar(rate), 0, BufFrames.ir(b), pos);
BufWr.ar(sig, b, rec);
sig
}.play;
)
Other things to try:
- Double check the path to your file is 100% correct.
- I think SuperCollider will play AIFF?
so it should be fine. But FWIW I tested with a WAV!
Hope these help!