libgme / game-music-emu

Blargg's video game music emulation library, which allows audio applications to easily add playback support for the music of many classic video game consoles.
GNU Lesser General Public License v2.1
68 stars 12 forks source link

SPC files keep playing past end #27

Closed Wohlstand closed 5 years ago

Wohlstand commented 6 years ago

Original report by Ben Larson (Bitbucket: bm1larson, ).


I've been trying to convert SPC files to Ogg Vorbis using VLC, but many of the SPC files play past the supposed end. For example, an SPC file with a length of 2:00 will keep going to 2:30 and beyond. I have confirmed that this happens while playing SPC files normally as well, but it's a bigger issue when converting to a different format, because it results in huge file sizes. There are similar issues on the VLC bug tracker, but they haven't been resolved because the issue is in game-music-emu.

After investigating the issue using the source code, I have found that the length from the SPC header (which is read by get_spc_info() in Spc_Emu.cpp) seems to be ignored in SpcEmu::play() and similar functions.

It seems that the proper solution would be to put a length check in SpcEmu::play() or one of the higher- or lower-level play functions. This should probably be complemented by a similar check in the corresponding skip function.

Wohlstand commented 6 years ago

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


This has normally been a function of the client application itself (using gme_set_fade, to permit the player the option of whether to play for an arbitrary time or not (e.g. as this NaCl-based player does: http://gamemusic.multimedia.cx/).

But I can see why this would be annoying for this use case. Maybe the best thing is to default the fade start to the encoded SPC length and instead allow the player to set the fade start to 0 for infinite playback.

Wohlstand commented 6 years ago

Original comment by Ben Larson (Bitbucket: bm1larson, ).


Yeah, that should help. It would probably be best for the default to have the nominal duration and actual duration be exactly equal, rather than adding a few seconds to fade out, because that's what people would expect. FFmpeg treats this library as a decoder, and fading and most other effects fall outside of that scope.

Also, VLC has a 'skip-underrun' patch for GME that fixes the crash that otherwise occurs whenever a user tries to seek ahead rather than playing the whole audio track sequentially. I suggest that the patch be incorporated into GME.

Wohlstand commented 6 years ago

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


See https://bitbucket.org/mpyne/game-music-emu/pull-requests/9/spc-set-a-playback-length-by-default-if/diff for the potential implementation.

Wohlstand commented 5 years ago

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


Fixed in master (see PR #9)