diff options
author | Filippos Karapetis | 2011-10-21 08:19:35 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-11-20 22:43:12 +0100 |
commit | 9841ce6b9f3b00f387a6f149221db05815f64801 (patch) | |
tree | 9ee2c4bc847fd7b76cec670f3ade5699f06aee69 | |
parent | 360bd6edd316e0111bd61cd65accbc9c91ac8728 (diff) | |
download | scummvm-rg350-9841ce6b9f3b00f387a6f149221db05815f64801.tar.gz scummvm-rg350-9841ce6b9f3b00f387a6f149221db05815f64801.tar.bz2 scummvm-rg350-9841ce6b9f3b00f387a6f149221db05815f64801.zip |
TOLTECS: Code cleanup
-rw-r--r-- | engines/toltecs/music.cpp | 50 | ||||
-rw-r--r-- | engines/toltecs/music.h | 5 | ||||
-rw-r--r-- | engines/toltecs/script.cpp | 2 |
3 files changed, 11 insertions, 46 deletions
diff --git a/engines/toltecs/music.cpp b/engines/toltecs/music.cpp index 8c88c6ded9..84cb2f7148 100644 --- a/engines/toltecs/music.cpp +++ b/engines/toltecs/music.cpp @@ -28,7 +28,7 @@ namespace Toltecs { -MusicPlayer::MusicPlayer() : _isGM(false), _buffer(NULL) { +MusicPlayer::MusicPlayer(bool isGM) : _isGM(isGM), _buffer(NULL) { MidiPlayer::createDriver(); int ret = _driver->open(); @@ -50,22 +50,21 @@ void MusicPlayer::send(uint32 b) { Audio::MidiPlayer::send(b); } -void MusicPlayer::playXMIDI(const byte *data, uint32 size, MusicFlags flags) { +void MusicPlayer::playMIDI(const byte *data, uint32 size, MusicFlags flags) { Common::StackLock lock(_mutex); - if (_isPlaying) - return; - stopAndClear(); _buffer = new byte[size]; memcpy(_buffer, data, size); - // Load XMID resource data - - _isGM = true; + MidiParser *parser; + + if (!memcmp(data, "FORM", 4)) + parser = MidiParser::createParser_XMIDI(NULL); + else + parser = MidiParser::createParser_SMF(); - MidiParser *parser = MidiParser::createParser_XMIDI(NULL); if (parser->loadMusic(_buffer, size)) { parser->setTrack(0); parser->setMidiDriver(this); @@ -84,39 +83,6 @@ void MusicPlayer::playXMIDI(const byte *data, uint32 size, MusicFlags flags) { } } -void MusicPlayer::playSMF(const byte *data, uint32 size, MusicFlags flags) { - Common::StackLock lock(_mutex); - - if (_isPlaying) - return; - - stopAndClear(); - - _buffer = new byte[size]; - memcpy(_buffer, data, size); - - // Load MIDI resource data - - _isGM = true; - - MidiParser *parser = MidiParser::createParser_SMF(); - if (parser->loadMusic(_buffer, size)) { - parser->setTrack(0); - parser->setMidiDriver(this); - parser->setTimerRate(_driver->getBaseTempo()); - parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); - - _parser = parser; - - setVolume(127); - - _isLooping = flags & MUSIC_LOOP; - _isPlaying = true; - } else { - delete parser; - } -} - void MusicPlayer::pause() { setVolume(-1); _isPlaying = false; diff --git a/engines/toltecs/music.h b/engines/toltecs/music.h index 9658633b8a..45238213d8 100644 --- a/engines/toltecs/music.h +++ b/engines/toltecs/music.h @@ -36,10 +36,9 @@ enum MusicFlags { class MusicPlayer : public Audio::MidiPlayer { public: - MusicPlayer(); + MusicPlayer(bool isGM = true); - void playXMIDI(const byte *data, uint32 size, MusicFlags flags = MUSIC_NORMAL); - void playSMF(const byte *data, uint32 size, MusicFlags flags = MUSIC_NORMAL); + void playMIDI(const byte *data, uint32 size, MusicFlags flags = MUSIC_NORMAL); void pause(); void resume(); void stopAndClear(); diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp index 1104c966fe..91a3f36e83 100644 --- a/engines/toltecs/script.cpp +++ b/engines/toltecs/script.cpp @@ -1051,7 +1051,7 @@ void ScriptInterpreter::sfStartSequence() { if (!memcmp(data, "FORM", 4)) { // TODO: Looping flag - _vm->_musicPlayer->playXMIDI(data, resourceSize); + _vm->_musicPlayer->playMIDI(data, resourceSize); } else { // TODO: Where does this occur? Are these SMF MIDI files? warning("sfStartSequence: resource %d isn't XMIDI", sequenceResIndex); |