Hi everyone!
My last two posts have been to do with a looper that I’m working on, and this one is no different! Thanks to @Takumi_Ogata especially for the help in the past, hoping I might be able to tempt you back for some more assistance?
The looper sketch has grown considerably over the last year or so, but the issue I’m facing at the moment is specific to clearing Audio Buffers. As you’ll see below, the first loop is recorded into bufL
, and then we have a distinction to make. A toggle switch corresponds to the bools stack
and flatten
. if(stack)
, all subsequent loops are recorded to bufR
. if(flatten)
, mixBuffer()
sends the previously recorded bufR loop to bufL, and clears it to accept new audio.
if(rec && first){
WriteBuffer_L(in, i);
}
if(rec && !first) {
rectime++;
if(stack) {
WriteBuffer_R(in, i);
full = true;
}
if(flatten) {
if(!cont) {
mixBuffer(posL, posR);
}
WriteBuffer_R(in, i);
}
if(undo){
for (int i = 0; i < mod; i++) {
bufR[i] = 0;
bufU[i] = 0;
}
undo = false;
full = false;
}
}
With the three called functions being
void mixBuffer(int posR, int posL) {
bufL[posL] = bufL[posL] + bufR[posR];
bufR[posR] = 0;
}
void WriteBuffer_R(float **in, size_t i) {
bufR[posR] = bufR[posR] + in[0][i];
}
void WriteBuffer_L(float **in, size_t i) {
bufL[posL] = bufL[posL] + in[0][i];
if (first) {
len++;
}
}
This is all working as intended, but we’ve identified an issue in flatten
when the incoming audio is shorter than the total buffer length. If, for example, mod
is set so that the buffer length is 30-seconds, and I record a 5-second loop, only 5-seconds of the previous loop in bufR is overwritten and sent to bufL. When this is eventually summed to Mono, you can’t tell, but it ends up breaking things when undo
is involved. Speaking of, undo
is obviously using the traditional method of clearing bufR
(and bufU
, but that’s a separate thing…), but when I try that method to clear bufR
in mixBuffer()
, the Daisy completely freezes up, and I get a horrible noise on the output…
I hope all of that makes sense! If there’s anything I need to clarify, or any other parts of the code that would help with diagnosing this issue, please let me know.
Cheers!
-Oliver