Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very beginning of audio cut off #88

Closed
hell001 opened this issue Jul 16, 2024 · 6 comments · Fixed by #89
Closed

Very beginning of audio cut off #88

hell001 opened this issue Jul 16, 2024 · 6 comments · Fixed by #89

Comments

@hell001
Copy link

hell001 commented Jul 16, 2024

Same issue as in StreamingKit, which I believe this project takes inspiration from

Just using the basic syntax for now:

let player = AudioPlayer()
player.play(<url-to-remote-audio-file>)

or

let player = AudioPlayer()
player.queue(<url-to-remote-audio-file>)

Running this will cause the very beginning of the audio to be chopped off. So like, it starts playing just barely into the song rather than the actual beginning. This also poses an issue for gapless playback, since it is not seamless. Only tested on FLAC

Gapless playback example (although this happens when just playing one file as well):

How it's supposed to sound: https://voca.ro/12qDs9q4ApSZ

How it does sound: https://voca.ro/1hAYzsF8paPl

@dimitris-c
Copy link
Owner

dimitris-c commented Jul 16, 2024

Hey, are we talking milliseconds at the start of the audio file? I just listened to the two files you above and barely noticed a difference.
MP3 does not support gapless playback due to just samples added to the file (unless removed by an encoder) , although lossless files are inherently gapless some encoders might add just samples

I tested this with a drum beat loop sample taken from loopazon - uploaded sample files here
My observations were the MP3 file downloaded from loopazon supports gapless playback and AudioStreaming plays it gapless. I converted the MP3 to FLAC on cloudconvert and I do hear a cut off especially when queuing the same file...

I'm not sure if it's a bug on AudioFileStreamServices or a bug in this library will investigate.

Thanks for raising this

@hell001
Copy link
Author

hell001 commented Jul 16, 2024

Hey, are we talking milliseconds at the start of the audio file? I just listened to the two files you above and barely noticed a difference. MP3 does not support gapless playback due to just samples added to the file (unless removed by an encoder) , although lossless files are inherently gapless some encoders might add just samples

I tested this with a drum beat loop sample taken from loopazon - uploaded sample files here My observations were the MP3 file downloaded from loopazon supports gapless playback and AudioStreaming plays it gapless. I converted the MP3 to FLAC on cloudconvert and I do hear a cut off especially when queuing the same file...

I'm not sure if it's a bug on AudioFileStreamServices or a bug in this library will investigate.

Thanks for raising this

Sorry for the confusion. I'll clarify.

The issue is talking about the beginning being cut off of a song file, not the beginning the the files I linked in the example. The example I gave is gapless playback between 2 songs, so the issue in those files is in the middle (end of one song transitioning into another). I didn't focus on perfectly matching the beginning and end of the 2 files since I was trying to highlight what's happening in the middle. these particular files are made for being gapless (and are FLAC, not mp3 as you were mentioning above)

if it helps, below are links to the full songs above, and the third link is both songs transitioning gaplessly (intended effect).

so with that info, listening to the 2 files I initially provided hopefully it makes more sense that its a noticeable difference. the playback does seem to be gapless, but the beginning of the song is being cut off. it also cuts off if I play just the second file alone (so ignoring gapless playback entirely, its just an issue with playing a song itself)

@dimitris-c
Copy link
Owner

dimitris-c commented Jul 17, 2024

yes, it seems the issue occurs on FLAC files which as I mentioned is noticeable on the drum beat loops I posted, it makes it easier for debugging.

I've also played the files on a private project which uses AudioFileStreamServices and TPCircularBuffer which handles things a bit differently and the same issue occurs... I'm leaning towards that AudioFileStreamServices might have an issue here... or perhaps AudioConverter...

@hell001
Copy link
Author

hell001 commented Jul 17, 2024

yes, it seems the issue occurs on FLAC files which as I mentioned is noticeable on the drum beat loops I posted, it makes it easier for debugging.

I've also played the files on a private project which uses AudioFileStreamServices and TPCircularBuffer which handles things a bit differently and the same issue occurs... I'm leaning towards that AudioFileStreamServices might have an issue here... or perhaps AudioConverter...

What’s interesting is that AVQueuePlayer (a subclass of AVPlayer) handles it perfectly, but sadly has quite a few limitations. Even setting up a queue myself and using AVPlayer doesnt work, let alone AVAudioEngine

I wish we knew the inner workings of AVQueuePlayer!

@dimitris-c
Copy link
Owner

I can't pinpoint to where this issue lies and how to resolve it, I'll keep looking at it.

I also have plans, time permitting to include an API similar to AVQueuePlayer, but I have limited time at the moment

@dimitris-c
Copy link
Owner

@hell001 This should be fixed on version 1.2.4, can you test with your audio files? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants