Skip to content

Instantly share code, notes, and snippets.

@todbot
Created August 14, 2024 21:21
Show Gist options
  • Save todbot/d3c2a1889e2d3df905d98a5d5c19b023 to your computer and use it in GitHub Desktop.
Save todbot/d3c2a1889e2d3df905d98a5d5c19b023 to your computer and use it in GitHub Desktop.
demo CircuitPython synthio on SparkFun Pro Micro RP2350
# random-boops.py - demo CircuitPython synthio on SparkFun Pro Micro RP2350
# 13 Aug 2024 - @todbot
#
import board, audiopwmio, audiomixer, audiocore, synthio, random, time
import neopixel
audio = audiopwmio.PWMAudioOut(board.D9)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
synth.envelope = synthio.Envelope(sustain_level=0.8, release_time=0.1, attack_time=0.001)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
while True:
n = random.randint(36, 72)
synth.press(n)
led.fill( n* 2**24/72 )
time.sleep(0.05)
synth.release(n)
led.fill(0)
time.sleep(0.05)
@todbot
Copy link
Author

todbot commented Aug 14, 2024

Video demo:

random-boops-rp2350.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment