aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tinsel')
-rw-r--r--engines/tinsel/music.cpp51
-rw-r--r--engines/tinsel/music.h12
-rw-r--r--engines/tinsel/tinsel.cpp18
3 files changed, 31 insertions, 50 deletions
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 3e0d87bbb8..235f03ada8 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -386,18 +386,41 @@ void DeleteMidiBuffer() {
midiBuffer.pDat = NULL;
}
-MidiMusicPlayer::MidiMusicPlayer(MidiDriver *driver) : _parser(0), _driver(driver), _looping(false), _isPlaying(false) {
+MidiMusicPlayer::MidiMusicPlayer() : _parser(0), _driver(0), _looping(false), _isPlaying(false) {
+ MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
+ bool native_mt32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32"));
+ //bool adlib = (MidiDriver::getMusicType(dev) == MT_ADLIB);
+
+ _driver = MidiDriver::createMidi(dev);
+ assert(_driver);
+ if (native_mt32)
+ _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
+
memset(_channel, 0, sizeof(_channel));
memset(_channelVolume, 0, sizeof(_channelVolume));
_masterVolume = 0;
- this->open();
+
+ int ret = _driver->open();
+ if (ret == 0) {
+ if (native_mt32)
+ _driver->sendMT32Reset();
+ else
+ _driver->sendGMReset();
+
+ _driver->setTimerCallback(this, &onTimer);
+ }
+
_xmidiParser = MidiParser::createParser_XMIDI();
}
MidiMusicPlayer::~MidiMusicPlayer() {
_driver->setTimerCallback(NULL, NULL);
stop();
- this->close();
+ if (_driver) {
+ _driver->close();
+ delete _driver;
+ _driver = 0;
+ }
_xmidiParser->setMidiDriver(NULL);
delete _xmidiParser;
}
@@ -419,28 +442,6 @@ void MidiMusicPlayer::setVolume(int volume) {
}
}
-int MidiMusicPlayer::open() {
- // Don't ever call open without first setting the output driver!
- if (!_driver)
- return 255;
-
- int ret = _driver->open();
- if (ret)
- return ret;
-
- _driver->setTimerCallback(this, &onTimer);
- return 0;
-}
-
-void MidiMusicPlayer::close() {
- stop();
- if (_driver) {
- _driver->close();
- delete _driver;
- }
- _driver = 0;
-}
-
void MidiMusicPlayer::send(uint32 b) {
byte channel = (byte)(b & 0x0F);
if ((b & 0xFFF0) == 0x07B0) {
diff --git a/engines/tinsel/music.h b/engines/tinsel/music.h
index a75f2b8617..1857032a6d 100644
--- a/engines/tinsel/music.h
+++ b/engines/tinsel/music.h
@@ -62,7 +62,7 @@ void dumpMusic();
class MidiMusicPlayer : public MidiDriver_BASE {
public:
- MidiMusicPlayer(MidiDriver *driver);
+ MidiMusicPlayer();
~MidiMusicPlayer();
bool isPlaying() { return _isPlaying; }
@@ -78,16 +78,12 @@ public:
void resume();
void setLoop(bool loop) { _looping = loop; }
- //MidiDriver interface implementation
- int open();
- void close();
- void send(uint32 b);
-
- void metaEvent(byte type, byte *data, uint16 length);
+ // MidiDriver_BASE interface implementation
+ virtual void send(uint32 b);
+ virtual void metaEvent(byte type, byte *data, uint16 length);
// The original sets the "sequence timing" to 109 Hz, whatever that
// means. The default is 120.
-
uint32 getBaseTempo() { return _driver ? (109 * _driver->getBaseTempo()) / 120 : 0; }
protected:
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 23335539d1..ef0fe1c909 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -856,23 +856,8 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc)
if (cd_num >= 0)
_system->getAudioCDManager()->openCD(cd_num);
- MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
- bool native_mt32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32"));
- //bool adlib = (MidiDriver::getMusicType(dev) == MT_ADLIB);
-
- _driver = MidiDriver::createMidi(dev);
- if (native_mt32)
- _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
-
- _midiMusic = new MidiMusicPlayer(_driver);
+ _midiMusic = new MidiMusicPlayer();
_pcmMusic = new PCMMusicPlayer();
- //_midiMusic->setNativeMT32(native_mt32);
- //_midiMusic->setAdLib(adlib);
-
- if (native_mt32)
- _driver->sendMT32Reset();
- else
- _driver->sendGMReset();
_musicVolume = ConfMan.getInt("music_volume");
@@ -896,7 +881,6 @@ TinselEngine::~TinselEngine() {
delete _midiMusic;
delete _pcmMusic;
delete _console;
- delete _driver;
_screenSurface.free();
FreeSaveScenes();
FreeTextBuffer();