Skip to content

Commit

Permalink
Merge pull request #1186 from Player701/MusicFormatExtension
Browse files Browse the repository at this point in the history
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 9c71d43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Engine/Options.h
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/Menu/OptionsAudioState.cpp
Expand Up @@ -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"));
Expand Down
21 changes: 6 additions & 15 deletions src/Mod/Mod.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9c71d43

Please sign in to comment.