diff options
author | Martin Kiewitz | 2015-07-05 12:17:17 +0200 |
---|---|---|
committer | Martin Kiewitz | 2015-07-05 12:17:17 +0200 |
commit | ba66236c2e64e3f0811d889d00dd36fae5fd89da (patch) | |
tree | 09c6adf014e51645ccb57517848492282f37d49d /audio | |
parent | 83f4565fe21e59afa3651413134a2ecfa613b84d (diff) | |
download | scummvm-rg350-ba66236c2e64e3f0811d889d00dd36fae5fd89da.tar.gz scummvm-rg350-ba66236c2e64e3f0811d889d00dd36fae5fd89da.tar.bz2 scummvm-rg350-ba66236c2e64e3f0811d889d00dd36fae5fd89da.zip |
AUDIO: Miles Audio AdLib: OPL3 detect for timbre
tries to detect OPL3 availability and prefers OPL3 timbre data
in that case.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/miles_adlib.cpp | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/audio/miles_adlib.cpp b/audio/miles_adlib.cpp index 3dcf2e9a55..f033c63b36 100644 --- a/audio/miles_adlib.cpp +++ b/audio/miles_adlib.cpp @@ -1065,6 +1065,8 @@ MidiDriver *MidiDriver_Miles_AdLib_create(const Common::String &filenameAdLib, c Common::String timbreFilename; Common::SeekableReadStream *timbreStream = nullptr; + bool preferOPL3 = false; + Common::File *fileStream = new Common::File(); uint32 fileSize = 0; uint32 fileDataOffset = 0; @@ -1083,16 +1085,39 @@ MidiDriver *MidiDriver_Miles_AdLib_create(const Common::String &filenameAdLib, c uint32 instrumentOffset = 0; uint16 instrumentDataSize = 0; + // Logic: + // We prefer OPL3 timbre data in case OPL3 is available in ScummVM + // If it's not or OPL3 timbre data is not available, we go for AdLib timbre data + // And if OPL3 is not available in ScummVM and also AdLib timbre data is not available, + // we then still go for OPL3 timbre data. + // + // Note: for most games OPL3 timbre data + AdLib timbre data is the same. + // And at least in theory we should still be able to use OPL3 timbre data even for AdLib. + // However there is a special OPL3-specific timbre format, which is currently not supported. + // In this case the error message "unsupported instrument size" should appear. I haven't found + // a game that uses it, which is why I haven't implemented it yet. + + if (OPL::Config::detect(OPL::Config::kOpl3) >= 0) { + // OPL3 available, prefer OPL3 timbre data because of this + preferOPL3 = true; + } + // Check if streams were passed to us and select one of them if ((streamAdLib) || (streamOPL3)) { // At least one stream was passed by caller - // Prefer AdLib for now - if (streamAdLib) { - timbreStream = streamAdLib; - } else { - // If not available, use OPL3 - if (streamOPL3) { - timbreStream = streamOPL3; + if (preferOPL3) { + // Prefer OPL3 timbre stream in case OPL3 is available + timbreStream = streamOPL3; + } + if (!timbreStream) { + // Otherwise prefer AdLib timbre stream first + if (streamAdLib) { + timbreStream = streamAdLib; + } else { + // If not available, use OPL3 timbre stream + if (streamOPL3) { + timbreStream = streamOPL3; + } } } } @@ -1100,20 +1125,39 @@ MidiDriver *MidiDriver_Miles_AdLib_create(const Common::String &filenameAdLib, c // Now check if any filename was passed to us if ((!filenameAdLib.empty()) || (!filenameOPL3.empty())) { // If that's the case, check if one of those exists - // Prefer the AdLib one for now - if (!filenameAdLib.empty()) { - if (fileStream->exists(filenameAdLib)) { - // if AdLib file exists, use it - timbreFilename = filenameAdLib; - } - } - if (timbreFilename.empty()) { + if (preferOPL3) { + // OPL3 available if (!filenameOPL3.empty()) { if (fileStream->exists(filenameOPL3)) { - // if OPL3 file exists, use it + // If OPL3 available, prefer OPL3 timbre file in case file exists timbreFilename = filenameOPL3; } } + if (timbreFilename.empty()) { + if (!filenameAdLib.empty()) { + if (fileStream->exists(filenameAdLib)) { + // otherwise use AdLib timbre file, if it exists + timbreFilename = filenameAdLib; + } + } + } + } else { + // OPL3 not available + // Prefer the AdLib one for now + if (!filenameAdLib.empty()) { + if (fileStream->exists(filenameAdLib)) { + // if AdLib file exists, use it + timbreFilename = filenameAdLib; + } + } + if (timbreFilename.empty()) { + if (!filenameOPL3.empty()) { + if (fileStream->exists(filenameOPL3)) { + // if OPL3 file exists, use it + timbreFilename = filenameOPL3; + } + } + } } if (timbreFilename.empty() && (!timbreStream)) { // If none of them exists and also no stream was passed, we can't do anything about it |