Music Gapless Playback (2 Viewers)

hwahrmann

Development Group
  • Team MediaPortal
  • September 15, 2004
    4,633
    2,457
    Vienna, Austria
    Home Country
    Austria Austria
    This version is based on 1.5 - Pre Release.
    It supports Gapless Playback via BASS.

    I needed to let the BASS Audio engine handle the Playlist Processing, because when invoked via the Player Framework it would Stop the playback of the previous song, causing hicks to be heard.

    Comments and suggestions please in this thread.

    Build from 03.10.2013 is here
    This is based on 1.5.0 Final
     
    Last edited:

    sikkek

    Portal Member
    November 10, 2009
    27
    3
    The Hague
    Home Country
    Netherlands Netherlands
    hwarmann, thanks in advance for all your hard work! Will test a.s.a.p. One question though regarding the technical solution:

    Is there a particular reason you're not using the STREAMPROC callback to provide BASS with stream data? That would be truly gapless playback

    Simple C++ example:

    Code:
    HSTREAM str1,str2,strout;
     
    DWORD CALLBACK MyStreamProc(HSTREAM handle, void *buf, DWORD len, DWORD user)
    {
      DWORD r;
      if (BASS_ChannelIsActive(str1)) { // stream1 has data
          r=BASS_ChannelGetData(str1,buf,len);
      } else if (BASS_ChannelIsActive(str2)) { // stream2 has data
          r=BASS_ChannelGetData(str2,buf,len);
          if (!BASS_ChannelIsActive(str2))
            r|=BASS_STREAMPROC_END; // stream2 has ended, so we're done
      } else r=BASS_STREAMPROC_END;
      return r;
    }
     
    ...
     
    BASS_CHANNELINFO info;
    str1=BASS_StreamCreateFile(...,BASS_STREAM_DECODE);
    str2=BASS_StreamCreateFile(...,BASS_STREAM_DECODE);
    BASS_ChannelGetInfo(str1,&info);
    strout=BASS_StreamCreate(info.freq,info.chans,0,&MyStreamProc,0); // create the output stream
    BASS_StreamPlay(strout,0,0);

    Off course, when the sample rate/#channels/bitdepth changes, a re-initialisation of the stream is required, but that is no problem, gapless playback (almost) always used for rips of live or mixed cd's, so the files would all have the same properties.
     

    hwahrmann

    Development Group
  • Team MediaPortal
  • September 15, 2004
    4,633
    2,457
    Vienna, Austria
    Home Country
    Austria Austria
    • Thread starter
    • Moderator
    • #3
    Thanks for your suggestions, but it is not only about Gapless playback. I also would like to have Crossfading and the ability to Upmix, Downmix some channels.
    Therefore i have decided to put everything into a Mixer channel.
    I know this sample from above, but the Music Player is invoked from the MediaPortal Player Framework and this is designed to issue a Play() command for every new title, which means that the previous file is Stopped, before the next file is started. And this caused the hicks previously.
    So i was rewriting the Audio Engine in a way that this doesn't happen.

    Please test and let me know.
     

    sikkek

    Portal Member
    November 10, 2009
    27
    3
    The Hague
    Home Country
    Netherlands Netherlands
    Will test a.s.a.p (have only 1 system, wife and kids use it a lot!)

    However, won't using a mixer channel screw up bit-perfect playback? E.g. resample everything? I was so happy with exclusive WASAPI playback...
     

    hwahrmann

    Development Group
  • Team MediaPortal
  • September 15, 2004
    4,633
    2,457
    Vienna, Austria
    Home Country
    Austria Austria
    • Thread starter
    • Moderator
    • #5
    no it doesn't screw up bit-perfect playback, since it is created with the same parms as the stream it plays.
    You are using a Mixer with 1.4 already.
     

    sikkek

    Portal Member
    November 10, 2009
    27
    3
    The Hague
    Home Country
    Netherlands Netherlands
    Finally got the chance to test yesterday evening. Result: gapless playback works sometimes...

    I installed your pre release version as an upgrade, and changed from wasapi to bass in the music settings.
    I tested with 2 flac files from a mixed cd. On first try, I could hear no gap. However, on subsequent tries (3 times) there was a small glitch between track boundaries.

    On a side note: how can you fast forward a song? On my remote (IRSS), fast forward buttons have no effect, skip steps also do nothing (they do work when playing a movie or tv serie). On my keyboard, arrow keys are also not working. even the top bar has no effect. This also happens in 1.4 by the way. It makes testing gapless very time consuming, I have to wait untill the complete song has played.
     

    hwahrmann

    Development Group
  • Team MediaPortal
  • September 15, 2004
    4,633
    2,457
    Vienna, Austria
    Home Country
    Austria Austria
    • Thread starter
    • Moderator
    • #7
    You can configure Music to use "Skip Steps" and standard FF, like on a DVD Player works as well.
    I do it here all the time to test gapless playback.
     

    Wiedmann

    Portal Pro
    June 22, 2007
    107
    28
    Home Country
    Germany Germany
    Build from 02.09.2013 is here
    Not working on my setup, too.
    Player:
    BASS Engine; Default Sound Device

    General BASS Player Settings:
    Output Level : 100
    Only Gapless playback ticked


    It should support Gapless Playback via BASS
    BTW: Is it important to have "BASS Engine" as Player for this quick fix? Because I'm more interested in WASAPI/ASIO. But that's also not working.


    Comments and suggestions please in this thread.
    Well, with PureAudio/ASIO gapless playback is perfectly working (MP1.4; 1.5Pre). Maybe you will spend some time and fix DirectSound in PureAudio instead (for those who need this)?
    Another important thing which is working in PureAudio (especially for (WASAPI/)ASIO): I can define the possible sampling rates for my device. And (only) other sampling rates will be resampled.
     

    Helios61

    Retired Team Member
  • Premium Supporter
  • January 30, 2008
    4,587
    873
    62
    NRW
    Home Country
    Germany Germany
    Hi @hwahrmann

    Thanks for the testversion. Unfortunately it doesn't work here. I've added debug logs, testfiles and recording of playback!

    Setup -> WASAPI/Gapless/Fade-in (-ou) diabled.

    Best regards
    Helios
     

    Attachments

    • 1KHz tone.rar
      1.7 MB
    • Recording.rar
      537.2 KB

    Users who are viewing this thread

    Top Bottom