An implementation of the classic four pole with feedback structure. Cutoff is mapped to incoming MIDI CC. Resonance is controlled with the gain of the inverting input on the sum stage which should stay between 0 and 4. It could be bound to a separate CC in an enhanced version.
This approach could easily be extended to other classic filter topologies.
import zrna
z = zrna.api.Client()
z.connect()
z.clear()
z.set_divisor(z.CLOCK_SYS1, 6)
osc = z.OscillatorTriSqr(
oscillation_frequency=0.044
)
osc.set_clock(z.CLOCK3)
z.add(osc)
sum = z.SumTwo()
sum.set_clock(z.CLOCK3)
sum.input2_polarity = z.INVERTING
sum.gain_input2 = 1.75
z.add(sum)
osc.square.connect(sum.input1)
poles = [
z.FilterLowpass(
corner_frequency=1,
gain=1.0)
for i in range(4)]
for pole in poles:
pole.set_clock(z.CLOCK3)
z.add(pole)
pole.corner_frequency.listen(
midi=z.CC,
min=0.1,
max=5)
audio_out = z.AudioOut()
z.add(audio_out)
osc.square.connect(sum.input1)
sum.output.connect(poles[0].input)
poles[0].output.connect(poles[1].input)
poles[1].output.connect(poles[2].input)
poles[2].output.connect(poles[3].input)
poles[3].output.connect(audio_out.input)
poles[3].output.connect(sum.input2)
z.run()