Closed
Description
CircuitPython version and board name
Adafruit CircuitPython 9.2.6 on 2025-03-23; Raspberry Pi Pico 2 with rp2350a
Adafruit CircuitPython 9.2.6 on 2025-03-23; Raspberry Pi Pico with rp2040
Code/REPL
"""
filter Q over 1.41 causes glitches in the filter at certain frequency
"""
import time, board, synthio, audiobusio, audiomixer
SAMPLE_RATE = 44100
BUFFER_SIZE = 2048
i2s_bck_pin = board.GP20
i2s_lck_pin = board.GP21
i2s_dat_pin = board.GP22
audio = audiobusio.I2SOut(bit_clock=i2s_bck_pin, word_select=i2s_lck_pin, data=i2s_dat_pin)
mixer = audiomixer.Mixer(sample_rate=SAMPLE_RATE, channel_count=2, buffer_size=BUFFER_SIZE)
synth = synthio.Synthesizer(sample_rate=SAMPLE_RATE, channel_count=2)
audio.play(mixer)
mixer.voice[0].play(synth)
midi_notes = [ 49, # glitch near 170 & 150 Hz
37, # glitch near 100, 70, & 60 Hz
36, # gitch near 70 & 60 Hz
42, # glitch near 100 Hz
47, # glitch near 120 Hz
]
while True:
for n in midi_notes:
midi_note_f = synthio.midi_to_hz(n)
note = synthio.Note(midi_note_f)
note.filter = synthio.BlockBiquad(synthio.FilterMode.LOW_PASS,
frequency=200, Q=1.5)
synth.press(note)
for f in range(21): # modulate the filter down by hand to find glitches
filter_freq = 200 - (10*f)
print("Q: %.2f filter freq: %3d note freq: %3.2f" %
(note.filter.Q, filter_freq, midi_note_f))
note.filter.frequency = filter_freq
time.sleep(0.3)
synth.release(note)
Behavior
When synthio.BlockBiquad
is set to certain frequencies with Q>1.41, strange oscillations / "glitches" occur that should not. In general it seems to be around the pitch of the playing note and lower.
Description
Here's a video showing the above code running on a Pico2 RP2350 driving an I2S DAC.
The behavior is the same on a Pico RP2040 with I2S DAC. The behavior is also the same with PWMOut
.
This behavior has existed since synthio
has had filters, but with BlockBiquad
it's more noticeable because we can easily modulate the filter frequency.
synthio_filter_glitch.mp4
Additional information
No response