You're quite welcome. Yeah, 8Khz 8-bit is pretty nasty.
The trick with playing sounds is either write everything cooperatively threaded, such that your classes have update() methods on them and only perform a bit of work at a time, OR you can create a high priority FreeRTOS task in ESP32, and in the loop there you can drive the sound. Be careful with that though, as there are many pitfalls, and it's fundamentally less efficient than the first method, overall.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
I will try with 44kHz 16bit mono, maybe it fits with the few sounds.
About the multithreading, yes basically there is not much to do in my code though.
It plays a sound, sends a bit through wifi UDP and blinks an LED.
In theory though, the wifi thing is another obstacle that needs to be solved but at least I understand how to do it, there just seems to be a bug in the current espressif pack so ESP32 LR mode can't get connections. But that is another construction yard.
Worst thing that could happen here is that it prevents too quick button presses but it is about half of a second or smth like that. It should be ok.
While this happens, the second core of the ESP is listing on RX for incoming data, it took me quite some attempts to get this working, the ESP is quite picky with that and easily quits in boot loops if something isn't okay for it. Anyway, once it detects incoming data it will play another sound but at this time all button presses are blocked anyway, so it won't get into trouble with other activities. Uhh, maybe I should say "shouldn't".
as soon as audiodata is wrapped with stm, all SFX operations will take that stm.
r is just an error code. it is sfx_result::success if it succeeded, or one of several possible error values on failure.
remember you need to keep your stm around and opened until you'll never play the wav again
and yeah, you'd use stm. And you wouldn't bother creating the wve_file_source, wav, because performer already handles all that.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
you can't capture in your lambda expression. you're trying to pass stm into a lambda. you can't do that. a lambda is its own function.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
hmm I thought I just replaced the sd-read wav here with the one from array.
However, even if that would work it leads to a problem when using multiple wav from arrays.
I could even imagine playing parts instead of sizeof(audiodata44_16) if I put all in one array
but I am probably wrong with that idea.
if you want more wavs you need more stm objects. One for each array. I don't get what you're asking.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
Go here and you can get more help. You'll need to access discord either with your PC as an app, phone as an app, or through the browser
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
just saw you on discord. i was napping when you first logged in.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
Thanks. I haven't really worked on it in awhile. For starters it does everything I want it to do so far. Maybe when I find some more different use cases for audio I'll come up with more features.