Author Topic: Can't get gapless playback (resolved)  (Read 793 times)

SoundMike

  • Posts: 331
Can't get gapless playback (resolved)
« on: 31 Dec '12 - 09:30 »
I'm trying to get gapless playback between consecutive tracks ripped from a CD. I've written a test program based on Best way to perform fast transitions between audios (playback), but there is a very brief but noticable gap between the tracks. If I play the tracks consecutively with Windows Media Player there is no audible gap.

The posting I referred to above is quite old (Sep 2006) but I couldn't find anything better since then. Is there a way I can completely eliminate the gap? (btw I'm currently using WMA files for this test. Could that be an issue?)
« Last Edit: 3 Jan '13 - 22:28 by SoundMike »

SoundMike

  • Posts: 331
Re: Can't get gapless playback (resolved - I think!)
« Reply #1 on: 31 Dec '12 - 23:15 »
I've just run another test after re-ripping the tracks from the CD, saving them as WAV files. With WAV files I do get gapless playback - at least with the short test I ran. :)

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: Can't get gapless playback (resolved - I think!)
« Reply #2 on: 1 Jan '13 - 12:23 »
Oops, I had meant to reply to this yesterday. I was going to ask whether you're calling BASS_StreamCreateFile to create the next decoder in the SYNCPROC like in the linked thread, and if so, are you also using a small output buffer? The gap could be due to the SYNCPROC taking too long, and the output buffer getting exhausted in the meantime. From your result with WAV files (which require practically no initialization), it sounds like that is indeed what's happening. To reduce the chances of that, you could create the next decoder ahead of time (in another thread), so that it's ready to go in the SYNCPROC.

SoundMike

  • Posts: 331
Re: Can't get gapless playback (resolved - I think!)
« Reply #3 on: 3 Jan '13 - 05:18 »
I'm creating the streams outside the SYNCPROC - they are created earlier. So the SYNCPROC basically just adds the next stream and resets the mixer. I've now got this working well in my own app (not just the test program I was using before) and it works well with ASIO and also with the new ASYNC file reading etc.

But I do have to recommend my users select WAV files. I haven't tried MP3 but with WMA files I do get a small glitch between tracks. No audible glitch at all with WAV files.

Ian @ un4seen

  • Administrator
  • Posts: 20389
Re: Can't get gapless playback (resolved - I think!)
« Reply #4 on: 3 Jan '13 - 15:43 »
Doing some quick tests here, WMA encoding appears to add some padding to the end of the file, which prevents gapless playback. Regarding MP3 encoding, that also introduces padding to the end (and start), but the LAME encoder includes information in the MP3 file to allow that to be removed by the decoder for gapless playback, which BASS does.

SoundMike

  • Posts: 331
Re: Can't get gapless playback (resolved)
« Reply #5 on: 3 Jan '13 - 22:37 »
Yes, you're right about WMA files. I've just looked at one of my files with GoldWave, checking both the WAV and WMA versions of the track ripped from the CD. The length of the WAV file is 4:28.493 and contains audio right up to the end. The length of the WMA file is 4:28.527 and audio stops at around 4:28.494 leaving 0.033 second of silence at the end. Both files were ripped from the CD using Windows Media Player.