Commit 90a2109f authored by John Regan's avatar John Regan

gme: add configurable fade-out time

Also include fade-out time in song length.
parent 464b9021
...@@ -391,6 +391,8 @@ Video game music file emulator based on `game-music-emu <https://bitbucket.org/m ...@@ -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
---------- ----------
......
...@@ -60,6 +60,7 @@ struct GmeContainerPath { ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment