File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66# SD card. Default pinout matches the Audio BFF for QT Py S2, S3 and RP2040
77
88import os
9- import time
9+ import random
1010import audiocore
1111import board
1212import audiobusio
1313import audiomixer
1414import adafruit_sdcard
1515import storage
1616import digitalio
17- import random
1817
1918card_cs = digitalio .DigitalInOut (board .A0 )
2019card_cs .direction = digitalio .Direction .INPUT
3635 if filename .endswith (".wav" ) and not filename .startswith ("." ):
3736 wave_files .append (filename )
3837
38+ def open_audio ():
39+ n = random .choice (wave_files )
40+ print ("playing" , n )
41+ f = open (n , "rb" )
42+ w = audiocore .WaveFile (f )
43+ return f , w
44+
45+ wavefile = 0
46+
3947while True :
4048 if not sdcard :
4149 try :
5664 if wavefile :
5765 wavefile .close ()
5866 else :
59- name = random .choice (wave_files )
60- print ("playing" , name )
61- wavefile = open (name , "rb" )
62- wave = audiocore .WaveFile (wavefile )
67+ wavefile , wave = open_audio ()
6368 mixer = audiomixer .Mixer (voice_count = 1 ,
6469 sample_rate = wave .sample_rate ,
6570 channel_count = wave .channel_count ,
You can’t perform that action at this time.
0 commit comments