Skip to content

Instantly share code, notes, and snippets.

@todbot
Created June 6, 2023 00:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todbot/dc7890b90208aef2761e2c7858db773a to your computer and use it in GitHub Desktop.
Save todbot/dc7890b90208aef2761e2c7858db773a to your computer and use it in GitHub Desktop.
trying out new synthio filter PR, knobs control frequency and resonance, in CircuitPython
# synthio_filter_test.py -- trying out new filter PR, knobs control frequency and resonance
# 5 Jun 2023 - @todbot / Tod Kurt
import time, random, board, analogio, audiopwmio, synthio
audio = audiopwmio.PWMAudioOut(board.GP10)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
knob1 = analogio.AnalogIn(board.GP26)
knob2 = analogio.AnalogIn(board.GP27)
note1 = synthio.Note(frequency=110)
synth.press(note1)
while True:
lpf_f = 10 + knob1.value / 32
lpf_q = knob2.value / 20000
note1.filter = synth.low_pass_filter(lpf_f, lpf_q)
print(lpf_f, lpf_q)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment