Music Gapless Playback

Discussion in 'Area 51 - Testing Area' started by hwahrmann, September 2, 2013.

  1. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,497
    Likes Received:
    1,639
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,266 / 1
    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: October 3, 2013
    • Like Like x 3
    • Thank You! Thank You! x 2
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. sikkek

    sikkek Portal Member

    Joined:
    November 10, 2009
    Messages:
    27
    Likes Received:
    3
    Occupation:
    Software Engineer
    Location:
    The Hague
    Ratings:
    +3 / 0
    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 (Text):
    1. HSTREAM str1,str2,strout;
    2.  
    3. DWORD CALLBACK MyStreamProc(HSTREAM handle, void *buf, DWORD len, DWORD user)
    4. {
    5.   DWORD r;
    6.   if (BASS_ChannelIsActive(str1)) { // stream1 has data
    7.       r=BASS_ChannelGetData(str1,buf,len);
    8.   } else if (BASS_ChannelIsActive(str2)) { // stream2 has data
    9.       r=BASS_ChannelGetData(str2,buf,len);
    10.       if (!BASS_ChannelIsActive(str2))
    11.         r|=BASS_STREAMPROC_END; // stream2 has ended, so we're done
    12.   } else r=BASS_STREAMPROC_END;
    13.   return r;
    14. }
    15.  
    16. ...
    17.  
    18. BASS_CHANNELINFO info;
    19. str1=BASS_StreamCreateFile(...,BASS_STREAM_DECODE);
    20. str2=BASS_StreamCreateFile(...,BASS_STREAM_DECODE);
    21. BASS_ChannelGetInfo(str1,&info);
    22. strout=BASS_StreamCreate(info.freq,info.chans,0,&MyStreamProc,0); // create the output stream
    23. 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.
     
    • Like Like x 2
  4. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,497
    Likes Received:
    1,639
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,266 / 1
    Home Country:
    Austria Austria
    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.
     
  5. sikkek

    sikkek Portal Member

    Joined:
    November 10, 2009
    Messages:
    27
    Likes Received:
    3
    Occupation:
    Software Engineer
    Location:
    The Hague
    Ratings:
    +3 / 0
    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...
     
  6. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,497
    Likes Received:
    1,639
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,266 / 1
    Home Country:
    Austria Austria
    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.
     
  7. sikkek

    sikkek Portal Member

    Joined:
    November 10, 2009
    Messages:
    27
    Likes Received:
    3
    Occupation:
    Software Engineer
    Location:
    The Hague
    Ratings:
    +3 / 0
    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.
     
  8. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,497
    Likes Received:
    1,639
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,266 / 1
    Home Country:
    Austria Austria
    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.
     
  9. sikkek

    sikkek Portal Member

    Joined:
    November 10, 2009
    Messages:
    27
    Likes Received:
    3
    Occupation:
    Software Engineer
    Location:
    The Hague
    Ratings:
    +3 / 0
    Home Country:
    Netherlands Netherlands
    Yeah, well, on my set up it doesn't work. Anything special I need to configure?
     
  10. Wiedmann

    Wiedmann Portal Pro

    Joined:
    June 22, 2007
    Messages:
    107
    Likes Received:
    12
    Ratings:
    +27 / 3
    Home Country:
    Germany Germany
    Not working on my setup, too.
    Player:
    BASS Engine; Default Sound Device

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


    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.


    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.
     
  11. Helios61
    • Premium Supporter

    Helios61 Retired Team Member

    Joined:
    January 30, 2008
    Messages:
    4,587
    Likes Received:
    584
    Gender:
    Male
    Location:
    NRW
    Ratings:
    +897 / 4
    Home Country:
    Germany Germany
    Show System Specs
    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
     

    Attached Files:

    • 1KHz tone.rar
      File size:
      1.7 MB
      Uploaded:
      September 6, 2013
      Views:
      126
    • Recording.rar
      File size:
      537.2 KB
      Uploaded:
      September 6, 2013
      Views:
      119
    • Like Like x 1
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!