Thank you very much for your answers which helped me a lot to understand SC.
My idea is not really to create a new granular syntesis program, GrainBuf works very well and I haven’t finished exploring all the existing capabilities in SC. I’m just doing an exercise that translates a tool I made in Csound and then in Max, something between a shuffle, a freeze and a sptializer, which I often use in my pieces, to familiarize myself with SC. You can see the current state here.
(
Buffer.freeAll;
(b = (sample: Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav"))));
(~window = (
triangle: Buffer.loadCollection(s, Signal.bartlettWindow(1024)),
blackman: Buffer.loadCollection(s, Signal.blackmanHarrisWindow(1024)),
tukey: Buffer.loadCollection(s, Signal.tukeyWindow(1024)),
hanning: Buffer.loadCollection(s, Signal.hanningWindow(1024)),
saw: Buffer.loadCollection(s, Signal.interpolation(1024, 1, 0))));
(
SynthDef.new(\play, {
arg outs = 0, duree = 1, buf, startPos = 0, win;
var sig, env, amp = 1, phase = Line.ar(0, BufFrames.kr(win), duree, doneAction: Done.freeSelf);
sig = PlayBuf.ar(
numChannels: 1,
bufnum: buf,
rate: \rate.kr(1.0),
trigger: \trig.kr(1.0),
startPos: startPos * BufSampleRate.ir(buf),
loop: \loop.kr(0),
doneAction: Done.freeSelf
);
sig = sig * BufRd.ar(1, win, phase);
sig = PanAz.ar(6, sig, \pan.kr(0));
Out.ar(outs, sig * amp);
}).add;
);
(
~sound = b.sample;
~durSound = ~sound.duration;
~speed = Pseq(Array.interpolation(30, 0.05, 0.3).mirror1, inf);
~step = 0.01;
Pbind(
\instrument, \play,
\dur, ~speed,
\buf, ~sound,
\duree, 2 * ~speed,
\startPos, Pseq([Pseries(1, ~step, 50)].mirror2, inf),
\rate, 1,
\amp, 1,
\win, ~window.triangle,
\pan, Pseq([1/6, 3/6, 5/6, 7/6, 9/6, 11/6], inf),
\outs, 0,
).play
)
Now I need to optimize it, following your advice. Also, I’m looking at different ways of controlling audio processing, like here, in order to compose with streams. I understand that there are basically two possibilities: patterns and signal modulation.
In fact, I’ve posted another question to make envelopes better suited to Pbind, without using time. I’ll keep looking…