ryanheise / just_audio

Audio Player
1.03k stars 650 forks source link

Stereo, Left, or Right channel audio playing #126

Open jjb182 opened 4 years ago

jjb182 commented 4 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Not related to a problem. I would just like to be able to play a specific audio channel. I'd love to be able to set, Left, Right, or Stereo.

Describe the solution you'd like A clear and concise description of what you want to happen. I would love the ability to play just one channel of an audio track. That way you could play one track in the left ear and a different track (with a different player instance) in the other ear. Ex.
_player1.setOutpuChannel(Left); _player1.play(); _player2.setOutpuChannel(Right); _player2.play();

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. I can generate audio with just one channel, but it is clunky.

Additional context Add any other context or screenshots about the feature request here. For a meditation app, with binaural beats (200Hz in one ear 205Hz in the other ear)

jjb182 commented 4 years ago

Hi Ryan, I see 'assigned'... that seems like progress! I've looked over other people's request, and now I wish that I'd cleaned mine up more. Sorry, just new to this. At the moment, I only need this (urgently) for Android. iOS maybe later, and Web would be amazing. If you need any more clarification, I am happy to supply as much as you need, and to test whatever you have. Thanks again Ryan. jjb

ryanheise commented 4 years ago

Hi @jjb182 , thanks for the feature request. FYI, issues are automatically assigned to me and placed into my backlog. When I begin working on a feature, I change the "backlog" label to "fixing" (which I should probably rename since the word "fixing" is more applicable to bug reports than feature requests).

Currently I am working on #36 and #125 which is turning out to be 2-3 weeks of work. Some issues are obviously easier to resolve than others, but if I implement the feature myself, then yes it may take a while for me to get to it due to the large number of issues I have to work through.

However, pull requests are also welcome if you need it done sooner and are willing to contribute.

jjb182 commented 4 years ago

Hi Ryan, I'm very new to Flutter and Git for that matter, and though I think that it will be equally fast to wait for you as to try to implement something myself... perhaps today is the day that I learn about pull requests. So please tell me what I need to do to get started on a PR.

Thanks jjb

On Tue, Jul 14, 2020 at 12:04 AM ryanheise notifications@github.com wrote:

Hi @jjb182 https://github.com/jjb182 , thanks for the feature request. FYI, issues are automatically assigned to me and placed into my backlog. When I begin working on a feature, I change the "backlog" label to "fixing" (which I should probably rename since the word "fixing" is more applicable to bug reports than feature requests).

Currently I am working on #36 https://github.com/ryanheise/just_audio/issues/36 and #125 https://github.com/ryanheise/just_audio/issues/125 which is turning out to be 2-3 weeks of work. Some issues are obviously easier to resolve than others, but if I implement the feature myself, then yes it may take a while for me to get to it due to the large number of issues I have to work through.

However, pull requests are also welcome if you need it done sooner and are willing to contribute.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/126#issuecomment-657953448, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU3WNY4KWFDTZG5TVTW7PDR3PKL7ANCNFSM4OV2M6VQ .

ryanheise commented 4 years ago

Thanks for offering to have a go at it. I may not be able to teach you how to do it, but there are good tutorials online if you try the following Google searches:

jjb182 commented 4 years ago

I imagine that this is a LOW priority, but does anybody out there want to take a shot at this?

ryanheise commented 4 years ago

I would welcome anyone taking a shot at this. Although just note that all effort is going into the media-source branch at the moment, and so it would be best for anyone making a pull request to make it on the media-source branch.

ryanheise commented 3 years ago

Copying over some comments from duplicated issue #340 :

Looks like there was some discussion on this here for ExoPlayer: google/ExoPlayer#2659 (it is described as a niche feature so the app must implement it manually, although we can't take that approach with Flutter since audio processing over method channels won't be very efficient).

For iOS, it's a built-in feature of AVAudioPlayer although that's not the API just_audio is based on. Maybe this can be done after the iOS side is reimplemented based on AVAudioEngine.

And a question:

So is the best way for getting this functionality is to use a server power for quick mixing my sounds (to use desired L/R channel volumes) and playing a stream with just_audio? What do you think?

That's not a bad workaround given the feature is not currently implemented in just_audio. If you're dealing with assets, you could also prepare the desired mix ahead of time and bundle that in the assets. If the content is dynamic, you could prepare the mix just in time. It may be possible on device using ffmpeg, except that ffmpeg's license is not compatible with iOS or Android.

jjb182 commented 3 years ago

Hi Ryan, a friend of mine was able to implement this in just_audio_0.2.2 on the iOS side. A similar attempt was made for the ExoPlayer but we were unsuccessful. As fate would have it, one of my projects for the past couple weeks has been to reach out to anyone who would listen on Upwork in an attempt to make more progress with this.

I'm happy to share the iOS side and the attempts at the ExoPlayer side if anyone wants to look at it. The friend that implemented it can speak a lot more intelligently about the solution. I will ask him if he can put together an explanation.

/// Sets channel mode of audio based on integer input /// Stereo: 0 Left-Only: 1 Right-Only: 2

await freq_a_player.setActiveChannels(2);

Here is the pub_cache

https://dictationportal.com:4445/just_audio/just_audio-0.2.2-ios-setActiveChannels.zip

This currently does not contain any of the ExoPlayer stuff. I have to track that down.

On Sat, Mar 13, 2021 at 8:35 PM ryanheise @.***> wrote:

Copying over some comments from duplicated issue #340 https://github.com/ryanheise/just_audio/issues/340 :

Looks like there was some discussion on this here for ExoPlayer: google/ExoPlayer#2659 https://github.com/google/ExoPlayer/issues/2659 (it is described as a niche feature so the app must implement it manually, although we can't take that approach with Flutter since audio processing over method channels won't be very efficient).

For iOS, it's a built-in feature of AVAudioPlayer although that's not the API just_audio is based on. Maybe this can be done after the iOS side is reimplemented based on AVAudioEngine.

And a question:

So is the best way for getting this functionality is to use a server power for quick mixing my sounds (to use desired L/R channel volumes) and playing a stream with just_audio? What do you think?

That's not a bad workaround given the feature is not currently implemented in just_audio. If you're dealing with assets, you could also prepare the desired mix ahead of time and bundle that in the assets. If the content is dynamic, you could prepare the mix just in time. It may be possible on device using ffmpeg, except that ffmpeg's license is not compatible with iOS or Android.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/126#issuecomment-798814340, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU3WN6XJRL3HSAI3TCT463TDQHFXANCNFSM4OV2M6VQ .

jjb182 commented 3 years ago

I just talked to Grant and if he has time tomorrow he will illustrate his approach. The iOS version was also implemented for the latest version of just_audio, but I don't know that we tested it thoroughly. The ExoPlayer compiled but never produced audio output. Hopefully one of you other Exo-enthusiasts will see this and run with it. Until tomorrow.

ryanheise commented 3 years ago

Nice! If the iOS side is sorted, I'd be willing to consider taking a look at the Android side.

thesheps commented 1 year ago

Hey @ryanheise! I know it's been a minute since this last got looked at, was just wondering if there'd been any movement at all? More than happy to get my sleeves rolled up and get stuck in!

ryanheise commented 1 year ago

@jjb182 and and Grant did contact me privately with an almost working implementation, and together we were able to fix the final issues with it.

If they are willing to contribute that code to everyone as open source, then you and other people may be able to continue the efforts and make it better.

thesheps commented 1 year ago

Ah, I see! Well that's certainly encouraging :) @jjb182 would you be happy to sync up on this?

On Sat, Feb 11, 2023 at 1:43 AM ryanheise @.***> wrote:

@jjb182 https://github.com/jjb182 and and Grant did contact me privately with an almost working implementation, and together we were able to fix the final issues with it.

If they are willing to contribute that code to everyone as open source, then you and other people may be able to continue the efforts and make it better.

— Reply to this email directly, view it on GitHub https://github.com/ryanheise/just_audio/issues/126#issuecomment-1426562599, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWSTN7G7VYR6WZ4HB7SHZLWW3VFLANCNFSM4OV2M6VQ . You are receiving this because you commented.Message ID: @.***>

ryanheise commented 1 year ago

I would add that this was quite some time ago on a much older version of just_audio. That said, this could be an example of where the open source community could at least help to bring that code up to date with the latest version.

On the iOS side, this would involve the TAP, so it might make sense to work on this on the visualizer branch and to generalise the TAP code in the process.

And then on the Android side, I believe it was a custom audio processor, so it should be more straightforward integrating that into the latest just_audio.

chrislaurie-io commented 1 year ago

I would like to suggest that we use it as a balance control:

_player.setBalance(0) // normal left & right stereo _player.setBalance(-1.0) // play only left channel _player.setBalance(1.0) // play only right channel _player.setBalance(-0.75) // play left channel 100% , right channel 25% _player.setBalance(0.66) // play right channel 100% , left channel 33%

I.E. Mix the the left & right channels of the current playing track instead of muting one of the channels as the issue's original request states. Of course setBalance(-1), achieves the muting of the right channel.

Another feature that will be useful to rehearsal audio tracks where different parts are recorded in the left and right channels would be to play either of the left & right channels as mono, i.e. through both channels / speakers.

_player.setBalance(-1, mono: true);