aboutsummaryrefslogtreecommitdiff
path: root/engines/made/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/made/music.cpp')
-rw-r--r--engines/made/music.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/engines/made/music.cpp b/engines/made/music.cpp
index 1b51fb3b80..c3b36d3b8c 100644
--- a/engines/made/music.cpp
+++ b/engines/made/music.cpp
@@ -42,6 +42,7 @@ MusicPlayer::MusicPlayer(MidiDriver *driver) : _parser(0), _driver(driver), _loo
_masterVolume = 0;
this->open();
_xmidiParser = MidiParser::createParser_XMIDI();
+ _smfParser = MidiParser::createParser_SMF();
}
MusicPlayer::~MusicPlayer() {
@@ -49,7 +50,9 @@ MusicPlayer::~MusicPlayer() {
stop();
this->close();
_xmidiParser->setMidiDriver(NULL);
+ _smfParser->setMidiDriver(NULL);
delete _xmidiParser;
+ delete _smfParser;
}
void MusicPlayer::setVolume(int volume) {
@@ -140,13 +143,13 @@ void MusicPlayer::onTimer(void *refCon) {
music->_parser->onTimer();
}
-void MusicPlayer::play(XmidiResource *midiResource, MusicFlags flags) {
+void MusicPlayer::playXMIDI(GenericResource *midiResource, MusicFlags flags) {
if (_isPlaying)
return;
stop();
- // Load MIDI/XMI resource data
+ // Load XMID resource data
_isGM = true;
@@ -166,6 +169,32 @@ void MusicPlayer::play(XmidiResource *midiResource, MusicFlags flags) {
}
}
+void MusicPlayer::playSMF(GenericResource *midiResource, MusicFlags flags) {
+ if (_isPlaying)
+ return;
+
+ stop();
+
+ // Load MIDI resource data
+
+ _isGM = true;
+
+ if (_smfParser->loadMusic(midiResource->getData(), midiResource->getSize())) {
+ MidiParser *parser = _smfParser;
+ parser->setTrack(0);
+ parser->setMidiDriver(this);
+ parser->setTimerRate(getBaseTempo());
+ parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+
+ _parser = parser;
+
+ setVolume(255);
+
+ _looping = flags & MUSIC_LOOP;
+ _isPlaying = true;
+ }
+}
+
void MusicPlayer::stop() {
Common::StackLock lock(_mutex);