The dsp-G1 Biquad Moog filter code

I got slapped over my fingers in another thread for not showing source code for my synth.
Strange since there are other synths on this forum that does not show any source.

Anyway, thought I make up for it by posting my 18db 3-pole biquad moog filter on ATmega code.
The code takes just 139 clock cycles so yes, it’s fast and it’s 16-bits.

CUTOFF and RESONANCE are uint8_t and IN, OUT are int16_t

// 18dB 3pole lowpass DCF with resonance. The MX-filter

int16_t M0;

int16_t M1;

int16_t M2;

int16_t M3;

int16_t M4;

int16_t M5;

int16_t M6;

int16_t MX1;

int16_t MX2;

int8_t coefficient;

coefficient=CUTOFF^0xFF;

#define M (MX, MX1, MX2) \\
asm volatile ( \\
“clr r26 \
\\t”\\
“mulsu %B1, %A2 \
\\t”\\
“movw %A0, r0 \
\\t”\\
“mul %A1, %A2 \
\\t”\\
“add %A0, r1 \
\\t”\\
“adc %B0, r26 \
\\t”\\
“clr r1 \
\\t”\\
: \\
"=&r" (MX) \\
: \\
“a” (MX1), \\
“a” (MX2) \\
:\\
“r26”\\
)
M (MX1, M0, coefficient);
M (MX2, M1, CUTOFF);
M0=MX1+MX2;
M (MX1, M1, coefficient);
M (MX2, M2, CUTOFF);
M1=MX1+MX2;
M (MX1, M2, coefficient);
M (MX2, M3, CUTOFF);
M2=MX1+MX2;
M (MX1, M3, coefficient);
M (MX2, M4, CUTOFF);
M3=MX1+MX2;
M (MX1, M4, coefficient);
M (MX2, M5, CUTOFF);
M4=MX1+MX2;
M (MX1, M5, coefficient);
M (MX2, M6, CUTOFF);
M5=MX1+MX2;
M (MX1, M0, RESONANCE);
M6 = IN-MX1;
OUT=M0;

In the dsp-G1 it’s 4-pole and 24db but the ATmega is a really slow system so it requires optimization.

@janost, there are lots of other synths that don’t show source code and are mentioned on this forum, but if you want to be “embraced” by this community, it’s important that you embrace the characteristics too. One of those is the open source idea. Olivier’s code has been available since the beginning, and that fact has certainly not had an effect on his business or the near-cult following people have for his products.

His open source model has helped other people create great products, such as the Tubeohm filter boards and the MIDIAlf sequencer products. He has also contributed to the code of other products, such as the original PreenFM. It is an open, honest (sometimes too honest I suppose) community that is worth being a part of.