Created
August 14, 2024 21:21
-
-
Save todbot/d3c2a1889e2d3df905d98a5d5c19b023 to your computer and use it in GitHub Desktop.
demo CircuitPython synthio on SparkFun Pro Micro RP2350
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Video demo:
random-boops-rp2350.mp4