[Scummvm-cvs-logs] SF.net SVN: scummvm:[49416] scummvm/trunk/engines/sci/sound

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jun 4 00:13:24 CEST 2010


Revision: 49416
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49416&view=rev
Author:   thebluegr
Date:     2010-06-03 22:13:23 +0000 (Thu, 03 Jun 2010)

Log Message:
-----------
A first attempt at channel remapping (currently disabled)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sound/music.cpp
    scummvm/trunk/engines/sci/sound/music.h

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-06-03 22:00:50 UTC (rev 49415)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-06-03 22:13:23 UTC (rev 49416)
@@ -173,6 +173,21 @@
 	MusicEntry ** pData = _playList.begin();
 	qsort(pData, _playList.size(), sizeof(MusicEntry *), &f_compare);
 }
+
+void SciMusic::findUsedChannels() {
+	// Reset list
+	for (int k = 0; k < 16; k++)
+		_usedChannels[k] = false;
+
+	const MusicList::iterator end = _playList.end();
+	for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
+		for (int channel = 0; channel < 16; channel++) {
+			if ((*i)->soundRes && (*i)->soundRes->isChannelUsed(channel))
+				_usedChannels[channel] = true;
+		}
+	}
+}
+
 void SciMusic::soundInitSnd(MusicEntry *pSnd) {
 	int channelFilterMask = 0;
 	SoundResource::Track *track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId());
@@ -220,6 +235,25 @@
 			channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayId(), _pMidiDrv->hasRhythmChannel());
 			pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
 
+			// TODO: Fix channel remapping. This doesn't quite work... (e.g. no difference in LSL1VGA)
+#if 0
+			// Remap channels
+			findUsedChannels();
+
+			for (int i = 0; i < 16; i++) {
+				if (_usedChannels[i] && pSnd->soundRes->isChannelUsed(i)) {
+					int16 newChannel = getNextUnusedChannel();
+					if (newChannel >= 0) {
+						_usedChannels[newChannel] = true;
+						debug("Remapping channel %d to %d\n", i, newChannel);
+						pSnd->pMidiParser->remapChannel(i, newChannel);
+					} else {
+						warning("Attempt to remap channel %d, but no unused channels exist", i);
+					}
+				}
+			}
+#endif
+
 			// Fast forward to the last position and perform associated events when loading
 			pSnd->pMidiParser->jumpToTick(pSnd->ticker, true);
 			_mutex.unlock();

Modified: scummvm/trunk/engines/sci/sound/music.h
===================================================================
--- scummvm/trunk/engines/sci/sound/music.h	2010-06-03 22:00:50 UTC (rev 49415)
+++ scummvm/trunk/engines/sci/sound/music.h	2010-06-03 22:13:23 UTC (rev 49416)
@@ -197,7 +197,6 @@
 	Common::Mutex _mutex;
 
 protected:
-	byte findAudEntry(uint16 nAud, byte&oVolume, uint32& oOffset, uint32&oSize);
 	void sortPlayList();
 
 	SciVersion _soundVersion;
@@ -211,10 +210,20 @@
 	bool _bMultiMidi;
 private:
 	static void miditimerCallback(void *p);
+	void findUsedChannels();
+	int16 getNextUnusedChannel() {
+		for (int i = 0; i < 16; i++) {
+			if (!_usedChannels[i])
+				return i;
+		}
 
+		return -1;
+	}
+
 	MusicList _playList;
 	bool _soundOn;
 	byte _masterVolume;
+	bool _usedChannels[16];
 };
 
 } // End of namespace Sci


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