Author Topic: Gapless AAC playback on macOS  (Read 574 times)

Klaus

  • Posts: 11
Gapless AAC playback on macOS
« on: 15 Aug '23 - 15:52 »
Hello,
Here an issue where I am not sure, if it is related to BASS or to macOS Versions, since BASS uses the OS's AAC codec on macOS.

AAC encodes in overlapping frames of 1024 samples. For that reason encoders typically encode 2112 silent samples before the actual audio begins. This is called AAC priming, and the number of extra samples is written to the MP4 stream.

I created ACC encoded m4a audio files using Apple's afconvert that comes with the OS. (For anybody trying to do so, note that you need to set afconvert's options --gapless-before and --gapless-after to really obtain gapless playback.)

Decoding theses files with BASS_StreamCreateFile() and BASS_ChannelGetData() results to the following strange behaviour:

On macOS 12.6.1 (x86_64) and macOS 10.13.6 (x86_64) everything works as it should be. BASS_ChannelGetData() delivers samples from the actual start of the audio and I can play back multiple files without audio gaps.

But, on macOS 13.5 (arm64), BASS_ChannelGetData() delivers the 2112 priming samples first, causing a silent gap. Moreover the total number of delivered samples is correct, so at the end of the stream there are 2112 audio samples missing. Decoding the same files on that machine using afconvert, Music.app or AVQueuePlayer from AVFoundation framework does not result in audio gaps.

Do you do anything different in BASS depending on macOS and/or intel/arm that could explain this behaviour?

Thanks again, Klaus


Klaus

  • Posts: 11
Re: Gapless AAC playback on macOS
« Reply #1 on: 15 Aug '23 - 16:53 »
Please find attached some files to test gapless AAC playback. The audio tracks just play a constant tone that should not be interrupted when a gapless player changes from one track to the next.

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: Gapless AAC playback on macOS
« Reply #2 on: 15 Aug '23 - 17:24 »
Ah yes, the priming delay is indeed currently being ignored on arm64 macOS. Here's an update that should fix that:

   www.un4seen.com/stuff/bass-osx.zip

Please let me know if you still see a problem with it.

Klaus

  • Posts: 11
Re: Gapless AAC playback on macOS
« Reply #3 on: 15 Aug '23 - 17:45 »
Yep, that fixes the isse. Perfect gapless AAC playback on arm64 as well. Thanks.