AAC audio mixing? #211
-
I need to mix AAC audio packets coming from 3 sources. So, there are 2 ways:
So, my question is whether it is possible to go with the 2nd approach , because mixing aac packets will reduce the computational load as I will be decoding only once instead of 3 times? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 12 replies
-
I don't think that 2 is an option and I have also my doubts if the processing power for option 1 is feasible on an ESP32. If it is for music I suggest to look at
If it is for speech:
In any case keep us updated about your findings... |
Beta Was this translation helpful? Give feedback.
-
Just read https://github.com/pschatzmann/arduino-audio-tools/wiki/Encoding-and-Decoding-of-Audio. In the list you find the class names to use. Just replace the class name that you used (AACDecoderHelix) in your current sketch with the new one: e.g. SBCDecoder to decode and SBCEncoder to encode. The audio codecs usually expect a sample rate of 8000 with 1 channel. Examples which test the codecs can be found int https://github.com/pschatzmann/arduino-audio-tools/tree/main/examples/tests |
Beta Was this translation helpful? Give feedback.
-
I just realized that I currently only support mixing on the input side. You however need to do it on the output side. I just committed the OutputMixer class in AudioOutput.h. I haven't tested it however, so I suggest that you look at the implementation. |
Beta Was this translation helpful? Give feedback.
-
I committed a correction which should make your sketch work. However you will need to explicitly define the buffer size by providing the size in the begin. It seems that mp3 is submitting data chungs of 4608 bytes. So this is the min size mixer.begin(4608); |
Beta Was this translation helpful? Give feedback.
-
I think if you want to do mixing you can't use any resource intensitive encoded format. The best is to use PWM format or WAV which is basically PWM with a header. |
Beta Was this translation helpful? Give feedback.
-
I have made a setup with a WAV file, and the result is similar. If I set NUM_CHAN to 1, the audio plays (although a bit slower than its supposed to, I guess this is due to the larger file that has to be streamed).
I call mixer.begin with 16384 bytes, that should do right? The complete code is below. I also tried with adding an actual second wav stream from the SD card to the mixer (not just increasing the number in the constructor), and in that case the audio is also heavily distorted. Do you maybe have a working example of the output mixer that I could start from? Thanks!
|
Beta Was this translation helpful? Give feedback.
-
Examples can be found in the documentation: https://github.com/pschatzmann/arduino-audio-tools/wiki/Splitting-and-Merging-Audio |
Beta Was this translation helpful? Give feedback.
-
You could try to directly use File objects as input. In the add method you would pass the files. |
Beta Was this translation helpful? Give feedback.
I don't think that 2 is an option and I have also my doubts if the processing power for option 1 is feasible on an ESP32.
The good news is that if it is not working out, you can just try and replace the Codec with some other alternatives.
If it is for music I suggest to look at
If it is for speech:
In any case keep us updated about your findings...