Created
February 25, 2021 23:03
-
-
Save dglaude/7ce0a284e25015320712dbf5baf2ffc5 to your computer and use it in GitHub Desktop.
I2S RP2040 playing 10 times in loop.
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
import board | |
import audiocore | |
import audiobusio | |
import time | |
print("Playing 10 times StreetChicken.wav") | |
f = open("StreetChicken.wav", "rb") | |
wav = audiocore.WaveFile(f) | |
i2s = audiobusio.I2SOut(board.GP27, board.GP28, board.GP26) | |
for i in range(10): | |
start=time.monotonic() | |
i2s.play(wav) | |
while i2s.playing: | |
pass | |
stop = time.monotonic() | |
print("Total lenght = ", stop, "-", start, "=", stop-start) | |
#GPIO26 to DIN (serial data) | |
#GPIO27 is connected to the BCK input (bit clock) | |
#GPIO28 to LRCK (left or right clock) | |
#class audiobusio.I2SOut( | |
# bit_clock: microcontroller.Pin, | |
# word_select: microcontroller.Pin, | |
# data: microcontroller.Pin, | |
# *, | |
# left_justified: bool) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment