Hello everyone!
I have an hour long stereo file. I want to skip through it in fixed intervals and play a few seconds. I want to record this and end up with a crude compression of the recording (including hard cuts).
I asked around for help since my understanding of SuperCollider is so small at this point that I wouldn’t solve this task myself - I have absolutely no coding experience and slowly try to get a feeling for SC.
A code (do you call it code? Or pattern?) was suggested to me. It somehow works for me and I was able to work out most of it but two questions remain and your input would help me to better understand on how to work with audio files in Supercollider:
// define your buffer
b = Buffer.read(s,Platform.resourceDir +/+"sounds/a11wlk01.wav");
// this will be our playback for our buffer
(
SynthDef(\test,{|out=0, bufNum=0, start=0, end=1000|
[Out.ar](http://Out.ar)(out,
// instead of PlayBuf we use BufRd b/c we can
[BufRd.ar](http://BufRd.ar)(1, bufNum, [Phasor.ar](http://Phasor.ar)(0, [BufRateScale.kr](http://BufRateScale.kr)(bufNum), start, end), loop: 0)
);
}).add;
)
// test synth
s = Synth(\test)
s.free;
(
var numSkips, durationWait;
numSkips = 500;
durationWait = 0.02;
s = Synth(\test, [
\buf, b.bufnum,
]);
{
numSkips.do({|i|
// we now set the skips skip
s.set(\start, i/numSkips * b.numFrames, \end, (i/numSkips * b.numFrames) + 10000);
durationWait.wait;
// lets free the synth after the last step
if(i==(numSkips-1), {s.free});
});
// fork which will create a routine which we will need b/c we "wait"
}.fork;
)
-
“test synth” - executing this line just gives a buzzing noise on the left channel: I expect this to be a tiny section of the loaded buffer being played? Or what do I test here?
-
To understand the concept here: I create a SynthDef holding my buffer where the recording lives in. This gets played later on and “s.set” plus the added 10000 make up for the different sections…
What exactly is Phasor.ar for? It has nothing to do with the phase of the buffer right? The help file says it’s ramping up after a trigger so is this the thing that “goes” through the buffer? -
I’m not sure I get the variable numSkips… What exaclty are the values here? I see that it gets multiplied with numFrames and I know that the “sample” is made up of a finite number of frames. But where exactly do I read the code for the movement? At the added 10000? But why is it added to end, not to start. And what should I manipulate to modify the lenght of the crops? durationWait is obvious, but changing the numSkips yields somewhat unpredictable results: At some point they give me loops which play a few times before going to the next section…
Maybe someone could break this line down for me, I’m afraid there is some super obvious math going on that I just don’t see…:
s.set(\start, i/numSkips * b.numFrames, \end, (i/numSkips * b.numFrames) + 10000);
Thank you!