Playing wav files in Fire, UIFlow v1.13.8. It works.
-
It took many hours to get WAV files playing, so I though I would share my findings here.
First the UIFlow UI does not show a "play WAV file" not in the SDCard section, the Speaker section, nor in the DAC section.
Second
from wav import wav_player wav_player.playWav('/sd/myfile.wav')fails with an
I2S does not have MODE_MASTERerror.Third
import machine dac0 = machine.DAC(25) dac0.wavplay('/sd/myfile.wav')does not work either, no sound is produced.
However the similar (according to the code)
from wav import wav ww = wave.open('/sd/myfile.wav') sample_rate = ww.getframerate() # read all data, play in background data = ww.readframes(ww.getnframes()) dac_buffer = array.array("B", data) ret = dac0.write_buffer(dac_buffer, sample_rate, wait=False)works fine. Finally !
If the sound file is big you can also use
while True: data = ww.readframes(2048) if len(data) > 0: dac_buffer = array.array("B", data) ret = dac0.write_buffer(dac_buffer, sample_rate, wait=True) else: breakor similar (notice the difference in wait=False or True)
I hope this helps future users.
In the end digging into the code of what M5Stack provides or not has been the best way to understand how to make the best out of the codebase.(could not use UIFlow 2 due to SDCard issue)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login