Audio mixing / playing more wav/mp3 at once

Give it a try, it costs you nothing !
Post Reply
lolo753
Posts: 4
Joined: Mon Nov 22, 2021 6:52 pm

Audio mixing / playing more wav/mp3 at once

Post by lolo753 »

Hello,
Could be nice to have this feature. For example, playing music on background and have button sounds on foreground or music and sounds in game, rotor, engine and other sounds at once in model, etc. I'm sure, second core could do the trick (which one is actually playing sound files in Annex). There is Arduino library (for ESP32), which does this.
Thanks
cicciocb
Site Admin
Posts: 414
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 92 times
Been thanked: 297 times
Contact:

Re: Audio mixing / playing more wav/mp3 at once

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Nov 23, 2021 5:13 pm Hello,
Could be nice to have this feature. For example, playing music on background and have button sounds on foreground or music and sounds in game, rotor, engine and other sounds at once in model, etc. I'm sure, second core could do the trick (which one is actually playing sound files in Annex). There is Arduino library (for ESP32), which does this.
Thanks
That could be nice but I fear that this will not fit inside.
In fact Annex already use both cores, the core 1 is dedicated to the basic interpreter and the core 0 for the wifi and the mp3 / wav
lolo753
Posts: 4
Joined: Mon Nov 22, 2021 6:52 pm

Re: Audio mixing / playing more wav/mp3 at once

Post by lolo753 »

Well, I was thinking about the same, for my project. One core will process wavs and web/wifi and second control/monitor/comm.
However, I'm not afraid about processor power for this. I could see AVR running *.MOD files player. 4 simultaneous 8000kHz samples from SD card at once + effects for each channel + 44780 LCD. Ok, AVR was @24MHz and written in assembler. ESP32 (mainly @240MHz) should do the job too. BUT it doesn't need to be necessary mix of 10 MP3s. Only few wavs for example. And with same sample rate, etc. I believe, it would need only slight modification of current routines. Firstly, handling (opening and transferring more (let's say 2 at the beginning) wave files from SD) and then short mixture calculation. So file management and wav processing remain same (only doubles CPU requirements) I2S or DAC routine remains same as there is still same data flow as with only one wav.
I found this quite simple (and simplified) example, how to do it, if you're interested: [External Link Removed for Guests]
Ok, I don't want to argue as only you know, how much CPU consumption current situation has. I also don't know, how it would perform on ESP8266 or ESP32 at lower speed.
User avatar
Electroguard
Posts: 277
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 55 times
Been thanked: 129 times

Re: Audio mixing / playing more wav/mp3 at once

Post by Electroguard »

Instead of separate cores a simple work-around could be to use 2 audio sources into the same amp/speaker by using 2 devices, a device for playing background music and another for sound effects. ESP devices are relatively small and cheap, and one device could easily control the volume and playback of the other using serial2 or whatever, with the added advantage of double the gpio's and timers available.
lolo753
Posts: 4
Joined: Mon Nov 22, 2021 6:52 pm

Re: Audio mixing / playing more wav/mp3 at once

Post by lolo753 »

Haha, yes, this is actually my backup solution :D
Post Reply