Content-Length: 216053 | pFad | http://github.com/adafruit/circuitpython/issues/10200

93 synthio filters glitch at certain frequencies with Q > 1.41 · Issue #10200 · adafruit/circuitpython · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synthio filters glitch at certain frequencies with Q > 1.41 #10200

Open
todbot opened this issue Mar 29, 2025 · 0 comments
Open

synthio filters glitch at certain frequencies with Q > 1.41 #10200

todbot opened this issue Mar 29, 2025 · 0 comments
Labels
audio bug rp2 Both RP2 microcontrollers
Milestone

Comments

@todbot
Copy link

todbot commented Mar 29, 2025

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

@todbot todbot added the bug label Mar 29, 2025
@tannewt tannewt added audio rp2 Both RP2 microcontrollers labels Mar 31, 2025
@tannewt tannewt added this to the Long term milestone Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio bug rp2 Both RP2 microcontrollers
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/issues/10200

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy