If I understand @dawamss’s code correctly, the warnings in his code are due to the conflict between
- the numChannels of BufRd and
- the numChannels of the numcBuffer loaded into that BufRd.
There are two warnings:
- due to the following lines:
~rd = Synth(\bufRd3, [
\buf, ~buf[~stack],
\otherBuf, ~otherBuf[~stack],
\out, ~rdBus,
\bpm, 120
])
It returns:
-> a Function
Buffer UGen channel mismatch: expected 3, yet buffer has 32 channels
- when evaluating
~rdType.(0)
due to the following lines:
~rd.replace(type, [
\buf, ~buf[~stack],
\otherBuf, ~otherBuf[~stack],
\out, ~rdBus,
\bpm, 120
], sameID: true
)
It returns:
-> a Routine
Buffer UGen channel mismatch: expected 3, yet buffer has 32 channels
The code from @dawamss does not show these warnings when changing some parts with numChannels
as follows:
(
SynthDef(\bufRd3, {
arg buf, otherBuf, out, bpm;
var rate = ControlDur.ir * (bpm/15);
var phase = Phasor.kr(0, rate, 0, BufFrames.kr(buf));
var sig;
/* this don't warn on postWindow but read too many channels
sig = BufRr.kr(32, buf, phase, 1, 1)[..2];
*/
sig = BufRd.kr(3, buf, phase, 1, 1);
sig = sig ++ BufRd.kr(29, otherBuf, phase, 1, 1);
Out.kr(out, sig);
}).add;
SynthDef(\bufRdAll, {
arg buf, out, bpm;
var rate = ControlDur.ir * (bpm/15);
var phase = Phasor.kr(0, rate, 0, BufFrames.kr(buf));
var sig = BufRd.kr(32, buf, phase, 1, 1);
Out.kr(out, sig);
}).add;
s.waitForBoot{
var numframes = 128;
var numchannels = 3; // changed
~stack = 0;
~buf = 2.collect{ Buffer.alloc(s, numframes, numchannels) };
~otherBuf = 2.collect{ Buffer.alloc(s, numframes, 32 - numchannels) }; // changed
~rdBus = Bus.control(s, 32);
s.sync;
~rd = Synth(\bufRd3, [
\buf, ~buf[~stack],
\otherBuf, ~otherBuf[~stack],
\out, ~rdBus,
\bpm, 120
])
};
~rdType = {|type=0|
r{
var numFrames = 127.rand + 1;
type = [\bufRd3, \bufRdAll][type];
~stack = (~stack + 1).mod(2);
// free next buffers
~buf[~stack].free;
~otherBuf[~stack].free;
// load next buffers
~buf.put(~stack, Buffer.alloc(s, numFrames, 3)); // changed
~otherBuf.put(~stack, Buffer.alloc(s, numFrames, 29));
s.sync;
~rd.replace(type, [
\buf, ~buf[~stack],
\otherBuf, ~otherBuf[~stack],
\out, ~rdBus,
\bpm, 120
], sameID: true
)
}.play
}
)
~rdType.(0)
Do I understand @dawamss’s intention correctly?