Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
869 stars 568 forks source link

Left & Right separation for player #608

Open GGLabCenter opened 3 years ago

GGLabCenter commented 3 years ago

Hi,

I would like/need to have a separation of the left and the right headsets. I'd say this means two streams/players, one for each side, since I would like to send different data in each. Do you think this could be possible?

Thanks

Larpoux commented 3 years ago

Hi Gabriele,

Can you prepare your record before playing it, or do you want to separate live sound during the playback ?

If you can prepare your record, it should not be very difficult. You can build your record by hand (PCM, Wave), or using a magic tool : FFmpeg.

If you want to separate the two channels dynamically during the playback, playing two records simultaneously is probably possible, but you can have some problems with synchronization. My own feeling is that it is a turn around but not a clean solution. Building a PCM stream dynamically is probably easy. The two channels on a PCM record are interleaved and it is very simple to create a stereo stream from two monophonic streams. Unfortunately, τ is not able actually to play PCM stereo. This is really bad, because it is very simple to implement that inside τ. Probably in a future version ... but I have so many things to do ....

GGLabCenter commented 3 years ago

Hi Larpoux,

I need the separate live sound during the playback! You are right: the stereo pcm would be a clean solution. I would like to be able to edit directly and improve tau. I just imported the tau project in VSCode in order to have a look around and understand if I am able to do that (I would like to..).

So, if I understood right, for an input mono channel after the int16 conversion, like [ 350, 760, 662, 238, 1, 248, 961, 783.. ], the stereo interleaved version would be ch1 ch2 ch1 ch2 ch1 ch2 etc.: [ 350, 350, 760, 760, 662, 662, 238, 238, 1, 1, 248, 248, 961, 961, 783, 783,..] they just alternate each two bytes, right? Inside tau the limitation is due to the recorder or to the player?

For my current needs, it would be enough to have a recorded mono pcm and to stream it as stereo, after an interleaving process.

Larpoux commented 3 years ago

I do not want to promise anything. But I will try to implement stereo PCM stream during the next few weeks. At the end of the week, I will have to switch to another important project, and I will be unavailable during 2 or 3 months for τ. But stereo support is easy to do, and I will try to do it during some spare time (if I have any).

t-kietzmann commented 3 years ago

Any updates on this ?

Larpoux commented 3 years ago

Yes. I would like to tell you some positive news :

I want to do several things on Flutter Sound, soon. One of those things is to extend the PCM parameters. But I do not like the current API to specify all the parameters. So, before implementing stereo, int8 and flt32 PCM, I want to release a new API that I am currently working on.

I hope to be able to release a beta version V9.0 during september. Hopefully, this version will support many PCM records, and not only PCM16 mono

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

miguelfs commented 5 months ago

Hi @Larpoux, thanks for maintaining this awesome library :)

I also noticed the lack of a setPan-alike function in player, for updating it in real-time while playing the audio.

I'm exploring flutter_sound to check if I could use it to make an audio mixer with multiple tracks.

image
Larpoux commented 5 months ago

@miguelfs

If your App is a web app, you should look to the Web Audio API (WAA). This API is great for developing an Audio Mixer.

Unfortunatly I didn’t found a good implementation of this API on mobiles. I looked for a RUST port of it, but I didn’t go further because I was not able to debug the library under flutter.