Strategies to silently change buffer offset

Dear list,

i’m trying to silently change a buffer offset with BufRd, which should be simple but it eludes me.

Two possible solutions come to my mind:

One possibility would be to use Select.ar to only pass triggers on all the non-active channels.
Another would be to Gate.ar the retriggering on active channels so it only works on the muted ones.
Both option would probably need the array that returns all the muted channels.
Any thoughts how that could look like? Or wholly other ideas?

b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
(
{
	
	var n = 8;
	
	var freq=200;
	
	var index1=(LFDNoise3.ar(1).abs*(1..n)).round(1).poll(1); //index for channels to output/hear
	
	var index2 = n-index1;   //?create an index with all the non-active channels on index1 to use for bufferoffset?
	
	var env = EnvGen.ar(Env.sine,Impulse.ar(freq),timeScale:1/freq);
	
	var bufferoffset = TIRand.ar(0,BufFrames.kr(b)-1,Impulse.ar(freq/n!n));
	
	var bufoffset1 = Select.ar(index2,bufferoffset);
	// var bufoffset2 = Gate.ar(bufferoffset,??);  //alternatively, how to gate the active channel retrigger?
	
	
	var sig = LeakDC.ar(BufRd.ar(1,b,bufoffset1.poll,1,4))*env;
	
	Splay.ar(Select.ar(index1,sig).poll(1))}.play

)
1 Like

There’s a way to significantly reduce the noise by masking the offset change with a Gate.
While it works quite well, it unfortunately doesn’t completely eliminate the noise though. It’s not clear to me why that is exactly…

b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");

(
{

	var n = 8;

	var freq=200;

	var index1=(LFDNoise3.ar(10!n).abs*(1..n)).round(1).poll(1); //index for channels to output/hear

	var gate=(Select.ar(index1,K2A.ar(Array.fill(n, {|i| [([1]++0.dup(n-1)).rotate(i)]}))).sum.clip(0,1));  //masking the channels so triggers only passes on non-active ones

	var env = EnvGen.ar(Env.sine,Impulse.ar(freq),timeScale:1/freq);

	var bufferoffset = TIRand.ar(0,BufFrames.kr(b)-1,Impulse.ar(freq/n!n));

	//var bufoffset1 = Select.ar(index2,bufferoffset);
	var bufoffset2 = Gate.ar(Select.ar(index1,bufferoffset),1-gate); //remove Gate and noise increases significantly
	
	var sig = LeakDC.ar(BufRd.ar(1,b,(bufoffset2).poll,1,4))*env;

	Splay.ar(Select.ar(index1,sig).poll(1))}.play

)