kartik-venugopal / aural-player

An audio player for macOS, inspired by Winamp.
MIT License
792 stars 44 forks source link

Gapless playback mode #90

Closed yan-8 closed 1 month ago

yan-8 commented 2 months ago

Example in video. I think much better do not have it.

https://github.com/kartik-venugopal/aural-player/assets/23197048/2b90620f-1ba7-4065-8e53-dc4f49d179f6

kartik-venugopal commented 2 months ago

Hi, thanks for the issue report. I am aware of this issue, and it will most likely be fixed in v4. It is not easy to implement, but I will try my best πŸ˜„

Cheers.

kartik-venugopal commented 1 month ago

I have done extensive research and experimentation to achieve gapless playback. And I can confidently say that with the current implementation of AVAudioEngine, this is extremely difficult to achieve, and the result would not be worth the investment of effort and would mess up the code too much to be worth it.

If AVAudioEngine is enhanced in the future, I will definitely consider doing this.

PS - That said, I have already made some small enhancements to reduce the gap in playback - for example, if the next track has the same audio format as the currently playing one (like tracks in an album), the audio engine will not reconfigure itself, saving a few milliseconds. It's not perfect, but a good enough half measure.

yan-8 commented 1 month ago

Thank you for your effort. A bit sad, yep I mean that you did not find any fast solutions. I hope AVAudioEngine will help us in the future.

kartik-venugopal commented 1 month ago

@yan-8 - I just thought of a way to implement this that would be possible, but only under certain some conditions:

There can be a special "gapless playback mode" which can be enabled when:

I can do this. Should not be too difficult if done in this way. In any case, this will be done only in v4, not in v3 (the version you currently have).

What do you think ?

yan-8 commented 1 month ago

Thank you for your explanation, so interesting thoughts. May I ask a few questions about your conditions. So when this mode will be implemented and turned on, the user play its audio album like Pink Floyd - The Wall album where all tracks don’t have gaps.

"All tracks in the play queue have the exact same audio format (and do not require audio engine reconfiguration between tracks). This will generally be true for tracks in the same album." -> As for me it sounds logically and intuitively.

"The user agrees not to reorder or move any tracks around during playback. So, the order of tracks when playing would remain constant." -> Question - when user wants to make fast-forward or rewind, will it work?

"Sorting would now no longer be possible till playback is finished." -> Question - what does it mean, sorting? You mean sorting files in playlist?

"Shuffling would not be available" -> No problem.

"I can do this. Should not be too difficult if done in this way. In any case, this will be done only in v4, not in v3 (the version you currently have)." -> As for me it looks good, I think that if you have an opportunity to implement this I think it is amazing. At least we will understand it when will try it.

-> Speaking about v4, may I ask, when are you planning to release v4 version? I am asking cause I saw some other visual or UI issues and I would report to you some of them if you don’t mind, what do you think? Or all these UI issues are independent on new v4 version?

kartik-venugopal commented 1 month ago

Hey, thanks for the reply.

Yes, I mean let's say you play Pink Floyd The Wall, where there are no gaps, and you will not hear any gaps when this playback mode is enabled.

Yes, fast-forward and rewind will still work like before, no restrictions. Segment looping will not be available (looping part of a track). Repeating a single track (repeat one) will not be available, but "Repeat all" will be available.

Yes, by sorting, I mean sorting files in the playlist or "Play Queue" (in v4, it's called Play Queue)

About the v4 release, I have been really busy this year with personal things, so I am slowly doing little by little whenever I find time ... I am hoping by the end of this year :) But there is the preview release already available ... you can try it out, and I will keep updating the preview build over time.

yan-8 commented 1 month ago

Cool, thank you. I wish you inspiring and luck of it.

kartik-venugopal commented 1 month ago

@yan-8 - I've implemented it, and it seems to be working well. I will do some final testing and give you a testable build soon (v4).

yan-8 commented 1 month ago

Great news. Thank you!

kartik-venugopal commented 1 month ago

@yan-8 - I have released this feature in the preview3 build (check the latest release page, download the Zip from there).

Let me know how it works for you. Cheers!

yan-8 commented 1 month ago

Nice, thank you! Will check it.

LesterJitsi commented 1 month ago

I'm following all discussions here and installed preview 3. Right now I happened to listen, after a long time, to John Martyn's Live at Leeds CD** ripped in flac format. Well, I realized that it's been recorded without any gaps and so Aural plays it. What's odd is that the Begin Gapless Playback is greyed out and not available, even though all requirements should be fulfilled. The same happens with all ripped CDs I tested, no matter the format.

**May this be related to original DAO recording instead of TAO? Thank you!

kartik-venugopal commented 1 month ago

Hey @LesterJitsi , there are only 2 conditions required for the gapless playback menu item to be enabled: 1 - The player is not currently playing 2 - There are at least 2 tracks in the Play Queue.

Then, once you click the menu item, the only requirement is that all tracks must have exactly the same audio format, which will generally be true for all tracks in any album (if they came together as a set).

You must first stop the player, and then initiate Gapless Playback Mode. If it is stopped and it is still not enabled, let me know πŸ˜„

LesterJitsi commented 1 month ago

To make it work I had to disable After adding tracks, play first added tracks > If no track is currently playing. It seems Aural doesn't care that no track is playing and starts to play anyway (I am dropping files over an empty Play Queue window). Stopping the player doesn't enable Gapless Playback Mode if the option above is checked. On app startup (if at least 1 track available) is permanently disabled.

yan-8 commented 1 month ago

Hey @LesterJitsi, how did you run "preview 3" version? I have a issue with it.

LesterJitsi commented 1 month ago

@yan-8, I just installed in /Applications overwriting previous release and clicked on Aural icon in the Dock.

yan-8 commented 1 month ago

Strange, I did it couple times but still have a issue with it.

LesterJitsi commented 1 month ago

Maybe that if the "issue" is disclosed a solution can be found...

kartik-venugopal commented 1 month ago

@LesterJitsi - I think maybe there is some confusion of what Gapless Playback Mode is. It is only a temporary state that begins when you click the gapless playback menu item and ends when playback stops. Once your album finishes playing, or you press Stop, that's the end of Gapless Playback Mode. It does not continue beyond that. It is not a mode that lives as long as the app is open ... not at all, it only exists between initiation and Stop (while your album is playing).

This also means that once your album finishes, if you want gapless playback again, you have to go back and execute that menu item again (or use the associated keyboard shortcut - Alt + Space).

If you drag a bunch of files into the Play Queue and they begin playing, you cannot initiate gapless playback mode until you stop playback (with the Playback > Stop menu item or keyboard shortcut Cmd + .) Also, gapless playback cannot be initiated automatically by drag-and-drop ... the only way is the menu item (or its shortcut).

So, at any given time, regardless of all other app settings, you must first stop the player (it must not be playing or paused), and then you can try the menu item ... it has to be enabled then. If not, please let me know πŸ˜„

Hope my description is clear :)

kartik-venugopal commented 1 month ago

Strange, I did it couple times but still have a issue with it.

@yan-8 Can you please share your aural.log file with me ? I am not sure what issue you are facing. The log file can be found in ~/Music/aural

Thanks

kartik-venugopal commented 1 month ago

@LesterJitsi - So if you want to drag an album into the Play Queue and play it gaplessly, do the following:

Since gapless playback mode imposes many restrictions on the app (described in above comments here), it is a special mode and by default, the app will choose normal playback mode so as not to restrict the user. Gapless Playback Mode must be initiated deliberately by the user on-demand.

LesterJitsi commented 1 month ago

If you drag a bunch of files into the Play Queue and they begin playing, you cannot initiate gapless playback mode until you stop playback (with the Playback > Stop menu item or keyboard shortcut Cmd + .)

Thank you, most likely I was not clear. I got it right and I meant that even stopping the playback, the gapless mode menu item remains greyed out.

To make it work I had to disable After adding tracks, play first added tracks > If no track is currently playing. It seems Aural doesn't care that no track is playing and starts to play anyway

This is the core of my issue, but maybe this is the intended behavior. Stopping the playback makes no difference. BTW, I'm reporting this only for debugging, as I don't think gapless mode will be relevant for me :wink:

kartik-venugopal commented 1 month ago

@LesterJitsi - I see ... let me try to reproduce your issue. Can you send me a screenshot of your Playback preferences panel ?

LesterJitsi commented 1 month ago

Screenshot 2024-08-05 alle 18 25 01_1

kartik-venugopal commented 1 month ago

With that screenshot, the autoplay behavior you described is exactly as intended ... stopping it should enable the menu item, though πŸ˜„

What "If no track is currently playing" means is ... only autoplay the first added track is nothing is currently playing. You said: " I had to disable After adding tracks, play first added tracks > If no track is currently playing. It seems Aural doesn't care that no track is playing and starts to play anyway (I am dropping files over an empty Play Queue window). "

So, if you mean this:

This ^ is working exactly right in terms of autoplay. You told it to play the first added track if nothing is currently playing ... that is happening just as you intended. Nothing is playing, and you have dragged a bunch of files in. So it will start playing.

But I cannot reproduce the menu item being disabled after stopping. Would you mind sending me a screen recording or the exact sequence of steps ? Because I'm not able to reproduce your issue.

kartik-venugopal commented 1 month ago

To make it work I had to disable After adding tracks, play first added tracks > If no track is currently playing. It seems Aural doesn't care that no track is playing and starts to play anyway (I am dropping files over an empty Play Queue window). Stopping the player doesn't enable Gapless Playback Mode if the option above is checked. On app startup (if at least 1 track available) is permanently disabled.

I think you misunderstood what the option means ... the option is saying, if you already have something playing, it will not interrupt playback of what is already playing with something new ... it will allow the already playing track to continue playing. Only if nothing is currently playing, it will start playing what you have added.

I think you are interpreting this option to mean that it will only play the new thing if something is already playing. That's the opposite of what this actually means.

LesterJitsi commented 1 month ago

While recording the screen I got it at last: I was pausing the player instead of stopping it. Sorry 😊 Now it works of course.

I think you misunderstood what the option means ... the option is saying, if you already have something playing, it will not interrupt playback of what is already playing with something new ... it will allow the already playing track to continue playing. Only if nothing is currently playing, it will start playing what you have added.

Yes, you're correct. Now I disabled all autoplay options. Thank you πŸ˜„

Off topic, would it be possible to have the settings window to remember the last active pane? Just like in Safari, e.g. Is it just me or the settings window can not be closed with the usual shortcut ⌘W? I'm getting an error sound.

kartik-venugopal commented 1 month ago

Cool, thanks πŸ˜„ Hmm, yeah, it is definitely possible to remember the last active pane ... I will implement that memory.

The settings window is currently modal ... I will make it non-modal 😁

Cheers!

yan-8 commented 3 weeks ago

Strange, I did it couple times but still have a issue with it.

@yan-8 Can you please share your aural.log file with me ? I am not sure what issue you are facing. The log file can be found in ~/Music/aural

Thanks

Hello, folder is empty. 2024 08 11 - 22 26 19

kartik-venugopal commented 3 weeks ago

Can you try downloading the latest release ?

yan-8 commented 3 weeks ago

Sure.

yan-8 commented 3 weeks ago

@kartik-venugopal, it works, thanks, but help me please, how to turn on "Gapless Playback Mode"? https://github.com/user-attachments/assets/38ca5018-2580-4085-825c-0c8c6e71bb17

kartik-venugopal commented 3 weeks ago

Screenshot 2024-08-11 at 11 20 09β€―PM

kartik-venugopal commented 3 weeks ago

NOTE - you must first completely stop the player (pausing is not enough), then go to that menu item.

yan-8 commented 3 weeks ago

Just run the player without music files, but I can't turn on it. 2024 08 11 - 23 54 24

yan-8 commented 3 weeks ago

or what is "completely stop the player"?

kartik-venugopal commented 3 weeks ago

You must have at least 2 tracks in the play queue, and the player must be stopped (no track info is shown on the player window) ... not paused

Gapless playback mode begins when you click the menu item and ends when the album finishes playing

kartik-venugopal commented 3 weeks ago

So here's what's required to do gapless playback: