Last active
July 26, 2023 09:26
-
-
Save todbot/40f80a937d6645cf3ce10a933250679e to your computer and use it in GitHub Desktop.
Demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico in CircuitPython
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
# dual_i2s_player.py -- demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico | |
# 19 May 2023 - @todbot / Tod Kurt | |
# video of this code: https://www.youtube.com/watch?v=CgqECxhqJEo | |
import time, board, audiocore, audiobusio | |
# qtpy rp2040 pins | |
# in this case, board.* names just match silkscreen, don't indicate functionality | |
lck1_pin, bck1_pin, dat1_pin = board.MISO, board.MOSI, board.SCK | |
lck2_pin, bck2_pin, dat2_pin = board.SCL, board.SDA, board.TX | |
audio1 = audiobusio.I2SOut(bit_clock=bck1_pin, word_select=lck1_pin, data=dat1_pin) | |
audio2 = audiobusio.I2SOut(bit_clock=bck2_pin, word_select=lck2_pin, data=dat2_pin) | |
# start both audio engines going, playing different waves | |
# could also (and should) use audiomixer.Mixer to give you more control | |
audio1.play( audiocore.WaveFile( open("amen_22k16b_160bpm.wav","rb") ), loop=True) | |
audio2.play( audiocore.WaveFile( open("dnb21580_22k16b_160bpm.wav","rb") ), loop=True) | |
while True: | |
print("hi") | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment