audioplayers
audioplayers copied to clipboard
Creating & Playing Single Audio From Multiple Assets
Hi,
I have multiple sound files in assets folder. Currently, I can play them by creating a Timer object.
I will give a concrete example to explain it more clearly. Let's say I have A, B, C, D, E and F asset files. And assume I am playing some of these audio files at 1 second interval using the Dart's Timer.periodic function.
An example schedule: 0 sec: Play A, C, D simultaneously 1 sec: None (Silence) 2 sec: Play B, F simultaneously 3 sec: Play B, E simultaneously 4 sec: None (Silence) 5 sec: Play A, C simultaneously ...
Currently, I am using separate AudioPlayer instances for each sound but I don't want this. I know in advance what sounds to play and when.
So, I want to create a single combined audio programmatically beforehand. Then I will play that combined audio playback with using single AudioPlayer instance. I don't have much of a performance problem with "low latency" mode at the moment, but the playbacks I've created will become much more complex. So, it is better for me to construct a single audio.
As far as I investigated the library, this might be possible by creating a single Uint8List from bytes of multiple sounds. But I couldn't figure out
- how can I combine byte arrays of sounds playing at the same time and
- how can I create a 1 second long silence data programmatically.
Could you help me on this case? Other than this, I would like to know if there are other methods to do it.