Permalink
Browse files

Merge pull request #1186 from Player701/MusicFormatExtension

Split "MIDI" music format to "MIDI (GM.CAT)" and "MIDI (MID files)"
  • Loading branch information...
SupSuper committed Jul 6, 2018
2 parents b31a992 + 0527103 commit 9c71d43d6d580ff73d7f735c41bc7598157f2413
Showing with 9 additions and 17 deletions.
  1. +1 −1 src/Engine/Options.h
  2. +2 −1 src/Menu/OptionsAudioState.cpp
  3. +6 −15 src/Mod/Mod.cpp
@@ -33,7 +33,7 @@ enum KeyboardType { KEYBOARD_OFF, KEYBOARD_ON, KEYBOARD_VIRTUAL };
/// Savegame sorting modes.
enum SaveSort { SORT_NAME_ASC, SORT_NAME_DESC, SORT_DATE_ASC, SORT_DATE_DESC };
/// Music format preferences.
enum MusicFormat { MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_MIDI };
enum MusicFormat { MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_GM, MUSIC_MIDI };
/// Sound format preferences.
enum SoundFormat { SOUND_AUTO, SOUND_14, SOUND_10 };
/// Video format preferences.
@@ -118,14 +118,15 @@ OptionsAudioState::OptionsAudioState(OptionsOrigin origin) : OptionsBaseState(or
_slrUiVolume->onMouseOut((ActionHandler)&OptionsAudioState::txtTooltipOut);
std::vector<std::wstring> musicText, soundText, videoText;
/* MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_MIDI */
/* MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_GM, MUSIC_MIDI */
musicText.push_back(tr("STR_PREFERRED_FORMAT_AUTO"));
musicText.push_back(L"FLAC");
musicText.push_back(L"OGG");
musicText.push_back(L"MP3");
musicText.push_back(L"MOD");
musicText.push_back(L"WAV");
musicText.push_back(L"Adlib");
musicText.push_back(L"GM");
musicText.push_back(L"MIDI");
soundText.push_back(tr("STR_PREFERRED_FORMAT_AUTO"));
@@ -3011,7 +3011,7 @@ void Mod::loadExtraResources()
}
// Try the preferred format first, otherwise use the default priority
MusicFormat priority[] = { Options::preferredMusic, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_MIDI };
MusicFormat priority[] = { Options::preferredMusic, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_GM, MUSIC_MIDI };
for (std::map<std::string, RuleMusic *>::const_iterator i = _musicDefs.begin(); i != _musicDefs.end(); ++i)
{
Music *music = 0;
@@ -3376,8 +3376,8 @@ bool Mod::isImageFile(std::string extension) const
*/
Music *Mod::loadMusic(MusicFormat fmt, const std::string &file, int track, float volume, CatFile *adlibcat, CatFile *aintrocat, GMCatFile *gmcat) const
{
/* MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_MIDI */
static const std::string exts[] = { "", ".flac", ".ogg", ".mp3", ".mod", ".wav", "", ".mid" };
/* MUSIC_AUTO, MUSIC_FLAC, MUSIC_OGG, MUSIC_MP3, MUSIC_MOD, MUSIC_WAV, MUSIC_ADLIB, MUSIC_GM, MUSIC_MIDI */
static const std::string exts[] = { "", ".flac", ".ogg", ".mp3", ".mod", ".wav", "", "", ".mid" };
Music *music = 0;
std::set<std::string> soundContents = FileMap::getVFolderContents("SOUND");
try
@@ -3411,23 +3411,14 @@ Music *Mod::loadMusic(MusicFormat fmt, const std::string &file, int track, float
}
}
}
// Try MIDI music
else if (fmt == MUSIC_MIDI)
// Try MIDI music (from GM.CAT)
else if (fmt == MUSIC_GM)
{
// DOS MIDI
if (gmcat && track < gmcat->getAmount())
{
music = gmcat->loadMIDI(track);
}
// Windows MIDI
else
{
if (soundContents.find(fname) != soundContents.end())
{
music = new Music();
music->load(FileMap::getFilePath("SOUND/" + fname));
}
}
}
}
// Try digital tracks
else

0 comments on commit 9c71d43

Please sign in to comment.