Hello. I’ve got two primary questions. I am pulling my non-existent hair out over this.
I’m currently working on a simple live sampler. Input from the audio interface is continuously recorded into a buffer and then played back at various speeds and ways. Right now I am routing the output of SC out via the Blackhole app into Reaper for recording. I am on a Mac laptop by the way (running 10.13.6).
My issues are, right now:
- I’m getting heavily aliased output when playing the SynthDefs. Sometimes it starts right away, sometimes it starts after a few seconds. This does not happen when I had a version of the sampler using RecordBuf and PlayBuf. The current version uses BufWr and BufRd (see question 2).
I have tried all manner of sample rate and buffer size adjustments, settings, tests, but to no avail. Sometimes rebooting the server will help, running no plugins in Reaper while monitoring the output will help a lot, and sometimes, just sometimes, changing the sample rate in Reaper will alleviate the problem for a while. Interestingly it is only on the Supercollider channel. So it has to be coming from sc itself.
I read something about BufWr recording over the allocated buffer length, which could explain it, but then trying to allocate a buffer size twice the length of what I need and then only playing back a portion of it still didn’t help.
I am going nuts over here, I’ve never tried anything like this. I have to assume I’m going about it the wrong way. I am using a large buffersize (512, 1024+), since I’m running all this on an older laptop.
- This whole thing is a product of trying to get a click-free live sampler going. I realized after many tries yesterday that I couldn’t do what I wanted to with RecordBuf and PlayBuf, since I would, to avoid clicks with recording to and playing from a continuously filled buffer, would have to do some logic business by offsetting the playback “head” from the current position of the recording “head”, and I couldn’t figure out how to get the current position of RecordBuf, but using BufWr and then reading from the recording Phasor via a bus seems more do-able, but I can’t continue with my testing with this aliased output.
If anyone has any specific ideas or tips for how to achieve the click-free sampling, please do tell me.
The code, without any bus-reading at this point:
(
var bufLength = 5;
~b1 = Buffer.alloc(s, 48000 * bufLength,1,bufnum:0);
SynthDef.new(\liverecorder,{
arg buf=0, trigger=1, loop=1, channel_in=2;
var start = 0;
var end = BufFrames.kr(buf) - 1;
var rate = 1;
var input = SoundIn.ar(channel_in);
var phasor = Phasor.ar(trigger, rate, start, end);
var rec = BufWr.ar(input, bufnum: 0, phase: phasor, loop: loop);
}).add;
SynthDef.new(\liveplayer, {
arg buf=0, note=60, trigger=1, loop=1, pan=0, amp=1, out=0, atk=0.1, rel=1;
var rate = BufRateScale.kr(buf) * (note/60);
var start = BufFrames.kr(buf)-1;
var end = BufDur.kr(buf);
var env = EnvGen.kr(Env.perc(attackTime:atk, releaseTime:rel), doneAction:2);
var ptr = Phasor.ar(trigger,rate,start, end);
var play = BufRd.ar(1,buf, ptr, loop, 4);
Out.ar(out, Pan2.ar(play,pan,amp * env));
}).add;
)
All the best,
MH.