allow switching between XMP and Dumb for module playback via config variable.

This commit is contained in:
Christoph Oelckers 2024-10-05 11:41:34 +02:00
parent b71e1a2639
commit 6c5cf572aa
4 changed files with 20 additions and 4 deletions

View file

@ -151,6 +151,7 @@ typedef enum EIntConfigKey_
zmusic_snd_mididevice,
zmusic_snd_outputrate,
zmusic_mod_preferredplayer,
NUM_ZMUSIC_INT_CONFIGS
} EIntConfigKey;

View file

@ -652,6 +652,10 @@ DLL_EXPORT zmusic_bool ChangeMusicSettingInt(EIntConfigKey key, MusInfo *currSon
miscConfig.snd_outputrate = value;
return false;
case zmusic_mod_preferredplayer:
dumbConfig.mod_preferred_player = value;
return false;
}
return false;
}
@ -942,6 +946,7 @@ static ZMusicConfigurationSetting config[] = {
{"zmusic_mod_autochip_size_force", zmusic_mod_autochip_size_force, ZMUSIC_VAR_INT, 100},
{"zmusic_mod_autochip_size_scan", zmusic_mod_autochip_size_scan, ZMUSIC_VAR_INT, 500},
{"zmusic_mod_autochip_scan_threshold", zmusic_mod_autochip_scan_threshold, ZMUSIC_VAR_INT, 12},
{"zmusic_mod_preferred_player", zmusic_mod_preferredplayer, ZMUSIC_VAR_INT, 0},
{"zmusic_mod_dumb_mastervolume", zmusic_mod_dumb_mastervolume, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_gme_stereodepth", zmusic_gme_stereodepth, ZMUSIC_VAR_FLOAT, 0},

View file

@ -129,6 +129,7 @@ struct DumbConfig
int mod_autochip_size_force = 100;
int mod_autochip_size_scan = 500;
int mod_autochip_scan_threshold = 12;
int mod_preferred_player = 0;
float mod_dumb_mastervolume = 1;
};

View file

@ -263,12 +263,21 @@ static MusInfo *ZMusic_OpenSongInternal (MusicIO::FileInterface *reader, EMidiD
}
else
{
streamsource = XMP_OpenSong(reader, miscConfig.snd_outputrate);
if (!streamsource) {
ZMusic_Printf(ZMUSIC_MSG_WARNING, "Fallback to DUMB\n");
reader->seek(0, SEEK_SET);
// give the calling app an option to select between XMP and DUMB.
if (dumbConfig.mod_preferred_player != 0)
{
streamsource = MOD_OpenSong(reader, miscConfig.snd_outputrate);
}
if (!streamsource)
{
reader->seek(0, SEEK_SET);
streamsource = XMP_OpenSong(reader, miscConfig.snd_outputrate);
if (!streamsource && dumbConfig.mod_preferred_player == 0)
{
reader->seek(0, SEEK_SET);
streamsource = MOD_OpenSong(reader, miscConfig.snd_outputrate);
}
}
}
if (streamsource == nullptr)
{