aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-03 22:13:23 +0000
committerFilippos Karapetis2010-06-03 22:13:23 +0000
commit8dd7537a55add13179520ec751641baac47373c7 (patch)
tree2fe17bd34e7f26354f3f80604199cd8e9fc4b92f
parentddf7449b00d15c5419c667f9df553053e8dc0cec (diff)
downloadscummvm-rg350-8dd7537a55add13179520ec751641baac47373c7.tar.gz
scummvm-rg350-8dd7537a55add13179520ec751641baac47373c7.tar.bz2
scummvm-rg350-8dd7537a55add13179520ec751641baac47373c7.zip
A first attempt at channel remapping (currently disabled)
svn-id: r49416
-rw-r--r--engines/sci/sound/music.cpp34
-rw-r--r--engines/sci/sound/music.h11
2 files changed, 44 insertions, 1 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index bfa2c3b3ee..1d186647f8 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -173,6 +173,21 @@ void SciMusic::sortPlayList() {
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 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
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();
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h
index 8f08065b99..f5eb7ce8d9 100644
--- a/engines/sci/sound/music.h
+++ b/engines/sci/sound/music.h
@@ -197,7 +197,6 @@ public:
Common::Mutex _mutex;
protected:
- byte findAudEntry(uint16 nAud, byte&oVolume, uint32& oOffset, uint32&oSize);
void sortPlayList();
SciVersion _soundVersion;
@@ -211,10 +210,20 @@ protected:
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