There is an included synthesizer, which applies a filter on the output samples. I'm struggling to understand how it works. You can find where the filter is applied in the source code here (line 251). However it is not commented.
Here is my interpretation of its definition. First, the filter parameters:
a = cutoff/samplerate f = 1.5 * sin(PI * a) q = 1.0 - resonance
cutoff is in Hz. The
samplerate is fixed at 44100.
then the filter process
low[i] += f * band[i-1] high[i] = q * (x[i] - band[i-1]) - low[i] band[i] += f * high[i] y[i] = low[i]
x is the input sample array,
y the output and
band some other variable whose purpose I don't fully understand yet.
This looks like some kind of IIR filter to me. Do you recognize it? Can you break it down for me? Explain it to me?
This is the low-pass filter version. One is supposed to be able to get a high-pass filter (or a band-pass) by changing the output to
y[i] = high[i] (or
I've made some experiments and it works pretty well, however the actual cutoff is a bit shifted and is not exactly equal to
cutoff. I've been able to correct the problem by changing the definition of
f = sin(2.0 * PI * a). Now the cutoff is exactly where it is supposed to be, but I don't know why. If you want to see nice pictures of that, you can see the issue I've opened on GitHub, but no response yet.