aboutsummaryrefslogtreecommitdiff
path: root/engines/saga
diff options
context:
space:
mode:
authorMatthew Hoops2012-09-12 19:31:29 -0400
committerMatthew Hoops2012-09-12 19:31:29 -0400
commitb996a6a27034850b0c6e110e4ca3ac69adab9c84 (patch)
tree71a8c834f11403badc286ec670cd0eadf293d3dc /engines/saga
parent77ef097723a869d85c2c7addba6afff85e3447ca (diff)
downloadscummvm-rg350-b996a6a27034850b0c6e110e4ca3ac69adab9c84.tar.gz
scummvm-rg350-b996a6a27034850b0c6e110e4ca3ac69adab9c84.tar.bz2
scummvm-rg350-b996a6a27034850b0c6e110e4ca3ac69adab9c84.zip
SAGA: Add support for IHNM Mac music
Diffstat (limited to 'engines/saga')
-rw-r--r--engines/saga/music.cpp59
-rw-r--r--engines/saga/music.h1
2 files changed, 33 insertions, 27 deletions
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index 13850a0b6d..0eebf3f175 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -30,6 +30,7 @@
#include "audio/audiostream.h"
#include "audio/mididrv.h"
#include "audio/midiparser.h"
+#include "audio/midiparser_qt.h"
#include "audio/decoders/raw.h"
#include "common/config-manager.h"
#include "common/file.h"
@@ -76,19 +77,14 @@ void MusicDriver::play(SagaEngine *vm, ByteArray *buffer, bool loop) {
}
// Check if the game is using XMIDI or SMF music
- if (vm->getGameId() == GID_IHNM && vm->isMacResources()) {
- // Just set an XMIDI parser for Mac IHNM for now
+ if (!memcmp(buffer->getBuffer(), "FORM", 4)) {
_parser = MidiParser::createParser_XMIDI();
+ // ITE had MT32 mapped instruments
+ _isGM = (vm->getGameId() != GID_ITE);
} else {
- if (!memcmp(buffer->getBuffer(), "FORM", 4)) {
- _parser = MidiParser::createParser_XMIDI();
- // ITE had MT32 mapped instruments
- _isGM = (vm->getGameId() != GID_ITE);
- } else {
- _parser = MidiParser::createParser_SMF();
- // ITE with standalone MIDI files is General MIDI
- _isGM = (vm->getGameId() == GID_ITE);
- }
+ _parser = MidiParser::createParser_SMF();
+ // ITE with standalone MIDI files is General MIDI
+ _isGM = (vm->getGameId() == GID_ITE);
}
if (!_parser->loadMusic(buffer->getBuffer(), buffer->size()))
@@ -107,6 +103,27 @@ void MusicDriver::play(SagaEngine *vm, ByteArray *buffer, bool loop) {
_isPlaying = true;
}
+void MusicDriver::playQuickTime(const Common::String &musicName, bool loop) {
+ // IHNM Mac uses QuickTime MIDI
+ _parser = MidiParser::createParser_QT();
+ _isGM = true;
+
+ if (!((MidiParser_QT *)_parser)->loadFromContainerFile(musicName))
+ error("MusicDriver::playQuickTime(): Failed to load file '%s'", musicName.c_str());
+
+ _parser->setTrack(0);
+ _parser->setMidiDriver(this);
+ _parser->setTimerRate(_driver->getBaseTempo());
+ _parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+ _parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1);
+
+ // Handle music looping
+ _parser->property(MidiParser::mpAutoLoop, loop);
+// _isLooping = loop;
+
+ _isPlaying = true;
+}
+
void MusicDriver::pause() {
_isPlaying = false;
}
@@ -343,31 +360,19 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
// Load MIDI/XMI resource data
if (_vm->getGameId() == GID_IHNM && _vm->isMacResources()) {
- // Load the external music file for Mac IHNM
-#if 0
- Common::File musicFile;
- char musicFileName[40];
- sprintf(musicFileName, "Music/Music%02x", resourceId);
- musicFile.open(musicFileName);
- resourceSize = musicFile.size();
- resourceData = new byte[resourceSize];
- musicFile.read(resourceData, resourceSize);
- musicFile.close();
-
- // TODO: The Mac music format is unsupported (QuickTime MIDI)
- // so stop here
-#endif
- return;
+ // Load the external music file for Mac IHNM
+ _player->playQuickTime(Common::String::format("Music/Music%02x", resourceId), flags & MUSIC_LOOP);
} else {
if (_currentMusicBuffer == &_musicBuffer[1]) {
_currentMusicBuffer = &_musicBuffer[0];
} else {
_currentMusicBuffer = &_musicBuffer[1];
}
+
_vm->_resource->loadResource(_musicContext, resourceId, *_currentMusicBuffer);
+ _player->play(_vm, _currentMusicBuffer, (flags & MUSIC_LOOP));
}
- _player->play(_vm, _currentMusicBuffer, (flags & MUSIC_LOOP));
setVolume(_vm->_musicVolume);
}
diff --git a/engines/saga/music.h b/engines/saga/music.h
index 5a4e662af4..081fab21f6 100644
--- a/engines/saga/music.h
+++ b/engines/saga/music.h
@@ -46,6 +46,7 @@ public:
MusicDriver();
void play(SagaEngine *vm, ByteArray *buffer, bool loop);
+ void playQuickTime(const Common::String &musicName, bool loop);
virtual void pause();
virtual void resume();