Skip to content

Instantly share code, notes, and snippets.

@todbot
Created May 19, 2025 19:38
Show Gist options
  • Save todbot/16ebcfb2b3d1d4934d4ea5a3261898be to your computer and use it in GitHub Desktop.
Save todbot/16ebcfb2b3d1d4934d4ea5a3261898be to your computer and use it in GitHub Desktop.
CircuitPython Pico 2 RP2350 audio playback example at 44.1kHz 16-bit
import time
import board
import audiocore, audiobusio, audiomixer
SAMPLE_RATE = 44100
BUFFER_SIZE = 2048
CHANNEL_COUNT = 2
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=CHANNEL_COUNT, buffer_size=BUFFER_SIZE)
audio.play(mixer)
mywav = audiocore.WaveFile("48254__digifishmusic__nylon-guitar-loop-b-1.wav")
mixer.voice[0].level = 1.0
mixer.voice[0].play(mywav, loop=True)
while True:
print("hi", time.monotonic())
time.sleep(0.3)
@todbot
Copy link
Author

todbot commented May 19, 2025

Uses a the WAV file "48254__digifishmusic__nylon-guitar-loop-b-1.wav" downloaded from https://freesound.org/people/digifishmusic/sounds/48254/ with no post-processing.

Video demo of the above code, recording line-in directly into an iPhone with a Synido Live Dock 10:

05192025_124424.mp4

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