gme: add configurable fade-out time

Also include fade-out time in song length.
This commit is contained in:
John Regan 2020-04-26 09:07:59 -04:00
parent 464b90210c
commit 90a2109fd1
2 changed files with 10 additions and 3 deletions

View File

@ -391,6 +391,8 @@ Video game music file emulator based on `game-music-emu <https://bitbucket.org/m
- Description - Description
* - **accuracy yes|no** * - **accuracy yes|no**
- Enable more accurate sound emulation. - Enable more accurate sound emulation.
* - **default_fade**
- The default fade-out time, in seconds. Used by songs that don't specify their own fade-out time.
hybrid_dsd hybrid_dsd
---------- ----------

View File

@ -60,6 +60,7 @@ struct GmeContainerPath {
#if GME_VERSION >= 0x000600 #if GME_VERSION >= 0x000600
static int gme_accuracy; static int gme_accuracy;
#endif #endif
static unsigned gme_default_fade;
static bool static bool
gme_plugin_init([[maybe_unused]] const ConfigBlock &block) gme_plugin_init([[maybe_unused]] const ConfigBlock &block)
@ -70,6 +71,10 @@ gme_plugin_init([[maybe_unused]] const ConfigBlock &block)
? (int)accuracy->GetBoolValue() ? (int)accuracy->GetBoolValue()
: -1; : -1;
#endif #endif
auto fade = block.GetBlockParam("default_fade");
gme_default_fade = fade != nullptr
? fade->GetUnsignedValue() * 1000
: 8000;
return true; return true;
} }
@ -171,7 +176,7 @@ gme_file_decode(DecoderClient &client, Path path_fs)
gme_free_info(ti); gme_free_info(ti);
const SignedSongTime song_len = length > 0 const SignedSongTime song_len = length > 0
? SignedSongTime::FromMS(length) ? SignedSongTime::FromMS(length + gme_default_fade)
: SignedSongTime::Negative(); : SignedSongTime::Negative();
/* initialize the MPD decoder */ /* initialize the MPD decoder */
@ -189,7 +194,7 @@ gme_file_decode(DecoderClient &client, Path path_fs)
if (length > 0) if (length > 0)
gme_set_fade(emu, length gme_set_fade(emu, length
#if GME_VERSION >= 0x000700 #if GME_VERSION >= 0x000700
, 8000 , gme_default_fade
#endif #endif
); );
@ -224,7 +229,7 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
TagHandler &handler) noexcept TagHandler &handler) noexcept
{ {
if (info.play_length > 0) if (info.play_length > 0)
handler.OnDuration(SongTime::FromMS(info.play_length)); handler.OnDuration(SongTime::FromMS(info.play_length + gme_default_fade));
if (track_count > 1) if (track_count > 1)
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1).c_str()); handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1).c_str());