Problem with very long file

hi

I am reading a 40min long buffer with a Phasor and I noticed that the closest it is to the end the worst the sound quality it gets. It sounds like low sample rate type of sound, with that peculiar noise that low quality digital sounds get.

I guess my problem is related to this thread The problem with long buffers... examples? but I wonder if there is any solution that I could not find apart from using super-bufrd ugens GitHub - esluyter/super-bufrd: UGens for accessing long buffers with subsample accuracy.

Thanks

This is the code

b.free;
p.free;

b = Buffer.read(s, "longfile40mins.flac");

(
SynthDef( \rPlayerLoop, { arg out=0, buffer=0, amp=1, pan=0, start=0, end=1, rate=0, dir=1, index=0,
	trig=0, reset=0;

	var left, right, phasor, dur = BufFrames.kr(buffer);

	phasor = Phasor.ar( trig, rate * BufRateScale.kr(buffer), start*dur, end*dur, resetPos: reset*dur);

	#left, right = BufRd.ar( 2, buffer, phasor ) * amp;
	Out.ar(out, Balance2.ar(left, right, pan));
}).load;
)


(
p.free;
p = Synth(\rPlayerLoop, [buffer: b, rate: 1, start: 0.92])
)

enrike

With standard BufRd, you get about 6 minutes at 44.1 kHz, less than that at higher sample rates. There’s no way to play 40 minutes from a single buffer using BufRd. This is because of the numeric precision of the phase input, which isn’t going to change (hence, extension UGens like super-BufRd).

You could stream from disk using DiskIn.

With standard BufRd, you could load part of the file into one buffer, and the next part into another buffer, and “hand-off” from one buffer to the other at the right time, for as many parts as you need.

I can’t think of other solutions in vanilla SC. Maybe someone else…?

hjh

ok thanks for the detailed explanation. I understand now. I though I might be doing something wrong. I guess I will need to try the trick you describe because I dont want to use extensions to solve this.

Maybe you were already aware of this, but I think it’s worth stressing it out: you don’t run into this problem if you use PlayBuf. So, if you don’t need to control the playback position at audio-rate (and in your example I’m not sure you need to), you don’t need to face this problem at all!

Thanks for pointing this out, but I need to control the playback position.

I don’t think anybody has tried this, but… PlayBuf’s internal position only integrates the rate input. Therefore you could provide a rate input that is the derivative of the desired position.

hjh

1 Like

Before you totally dismiss PlayBuf as @elgiano suggested, wouldn’t using PlayBuf with a demand ar Ugens to move the playhead give you the same precision and control as using BufRd? In any case true sample accuracy in SC if very hard to obtain as UGens introduce a small amount of delay and the exact amount of delay is not obvious, see this post. As far is I know, there is no easy way of detecting and compensating the delay caused by UGens.

Communication between language and a running synth with any kind of buffer playback will make sample accuracy impossible in any case, so once initiated, the synth must be on its own, so to speak.

I personally gave up on trying to hunt for sample accuracy in SC, it made my life better:) Just my 2 cents.