[Scummvm-cvs-logs] SF.net SVN: scummvm: [21479] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Mar 28 07:16:15 CEST 2006


Revision: 21479
Author:   lordhoto
Date:     2006-03-28 07:15:36 -0800 (Tue, 28 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21479&view=rev

Log Message:
-----------
- Commits heaviliy modifed patch #1459951 ("KYRA: Combining MIDI music with Adlib sfx") (created a wrapper class for two different sound drivers instead of adding a new variable to the KyraEngine class and chaning stuff there)
- Prevents to play track 0 for non mt-32 midi devices (got ugly sound output with windows midi)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound.h
Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2006-03-28 13:33:18 UTC (rev 21478)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2006-03-28 15:15:36 UTC (rev 21479)
@@ -330,7 +330,7 @@
 		_system->initSize(320, 200);
 	_system->endGFXTransaction();
 
-	// for now we prefer MIDI-to-Adlib conversion over native midi
+	// for now we prefer Adlib over native MIDI
 	int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/);
 
 	if (midiDriver == MD_ADLIB) {
@@ -349,6 +349,18 @@
 		_sound = soundMidiPc;
 		assert(_sound);
 		soundMidiPc->hasNativeMT32(native_mt32);
+		
+		// Unlike some SCUMM games, it's not that the MIDI sounds are
+		// missing. It's just that at least at the time of writing they
+		// decidedly inferior to the Adlib ones.
+
+		if (ConfMan.getBool("multi_midi")) {
+			SoundAdlibPC *adlib = new SoundAdlibPC(_mixer, this);
+			assert(adlib);
+			
+			_sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib);
+			assert(_sound);
+		}
 	}
 	if (!_sound->init()) {
 		error("Couldn't init sound");

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2006-03-28 13:33:18 UTC (rev 21478)
+++ scummvm/trunk/engines/kyra/sound.cpp	2006-03-28 15:15:36 UTC (rev 21479)
@@ -247,9 +247,9 @@
 		return;
 	}
 
-	_parser->setTrack(0);
 	_parser->setMidiDriver(this);
 	_parser->setTimerRate(getBaseTempo());
+	_parser->setTempo(0);
 	_parser->property(MidiParser::mpAutoLoop, true);
 }
 
@@ -282,9 +282,9 @@
 		return;
 	}
 
-	_soundEffect->setTrack(0);
 	_soundEffect->setMidiDriver(this);
 	_soundEffect->setTimerRate(getBaseTempo());
+	_soundEffect->setTempo(0);
 	_soundEffect->property(MidiParser::mpAutoLoop, false);
 }
 
@@ -357,7 +357,7 @@
 }
 
 void SoundMidiPC::playTrack(uint8 track) {
-	if (_parser) {
+	if (_parser && (track != 0 || _nativeMT32)) {
 		_isPlaying = true;
 		_fadeMusicOut = false;
 		_fadeStartTime = 0;
@@ -376,7 +376,7 @@
 		setVolume(255);
 		_parser->setTrack(0);
 		_parser->jumpToTick(0);
-		_parser->setTempo(1);
+		_parser->setTempo(0);
 	}
 }
 
@@ -385,6 +385,7 @@
 		_sfxIsPlaying = true;
 		_soundEffect->setTrack(track);
 		_soundEffect->jumpToTick(0);
+		_soundEffect->setTempo(1);
 		_soundEffect->property(MidiParser::mpAutoLoop, false);
 	}
 }

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2006-03-28 13:33:18 UTC (rev 21478)
+++ scummvm/trunk/engines/kyra/sound.h	2006-03-28 15:15:36 UTC (rev 21479)
@@ -188,6 +188,30 @@
 	MidiParser *_soundEffect;
 	byte *_soundEffectSource;
 };
+
+class MixedSoundDriver : public Sound {
+public:
+	MixedSoundDriver(KyraEngine *engine, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(engine, mixer), _music(music), _sfx(sfx) {}
+	~MixedSoundDriver() { delete _music; delete _sfx; }
+
+	bool init() { return _music->init() | _sfx->init(); }
+	void process() { _music->process(); _sfx->process(); }
+
+	void setVolume(int volume) { _music->setVolume(volume); _sfx->setVolume(volume); }
+	int getVolume() { return _music->getVolume(); }
+
+	void loadMusicFile(const char *file) { _music->loadMusicFile(file); _sfx->loadMusicFile(file); }
+
+	void playTrack(uint8 track) { _music->playTrack(track); }
+	void haltTrack() { _music->haltTrack(); }
+
+	void playSoundEffect(uint8 track) { _sfx->playSoundEffect(track); }
+
+	void beginFadeOut() { _music->beginFadeOut(); }
+private:
+	Sound *_music, *_sfx;
+};
+
 } // end of namespace Kyra
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list