Crackly, distorted output

Two side notes:
1.) the cutoff frequency won’t change during the process block, so you can (and should) move the filter.setCutoff() call outside the loop

2.) although reading the code might be easier with both filters in one loop, for the processor it is better to compute it channel by channel. The reason is so called cache coherence, which means a lot of read and write operations from one adress to the next is faster that accessing alternating the left and the right channel. Eventually the optimizer will unwind that for you, but it is better to write it like you want it to be processed

Timur explains that here (youtube).

3.) so iterating over the channels would make the code coping with mone, stereo and other formats. And there is good reason (see 2) to have the channels in the outer loop.

maybe still of interest:

HTH

1 Like