aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/made/music.cpp33
-rw-r--r--engines/made/music.h5
2 files changed, 34 insertions, 4 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);
diff --git a/engines/made/music.h b/engines/made/music.h
index b9fa1004d5..8ef39b4fd3 100644
--- a/engines/made/music.h
+++ b/engines/made/music.h
@@ -54,7 +54,8 @@ public:
void setNativeMT32(bool b) { _nativeMT32 = b; }
bool hasNativeMT32() { return _nativeMT32; }
- void play(XmidiResource *midiResource, MusicFlags flags = MUSIC_NORMAL);
+ void playXMIDI(GenericResource *midiResource, MusicFlags flags = MUSIC_NORMAL);
+ void playSMF(GenericResource *midiResource, MusicFlags flags = MUSIC_NORMAL);
void stop();
void pause();
void resume();
@@ -86,7 +87,7 @@ protected:
MidiChannel *_channel[16];
MidiDriver *_driver;
- MidiParser *_xmidiParser;
+ MidiParser *_xmidiParser, *_smfParser;
byte _channelVolume[16];
bool _nativeMT32;
bool _isGM;