[Scummvm-cvs-logs] SF.net SVN: scummvm:[50414] scummvm/trunk/engines/sci/sound
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Mon Jun 28 11:22:58 CEST 2010
Revision: 50414
http://scummvm.svn.sourceforge.net/scummvm/?rev=50414&view=rev
Author: m_kiewitz
Date: 2010-06-28 09:22:57 +0000 (Mon, 28 Jun 2010)
Log Message:
-----------
SCI: implementing real setVolume() support, fixing some fading in sci1 games (like pq3 intro)
Modified Paths:
--------------
scummvm/trunk/engines/sci/sound/midiparser_sci.cpp
scummvm/trunk/engines/sci/sound/midiparser_sci.h
Modified: scummvm/trunk/engines/sci/sound/midiparser_sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/midiparser_sci.cpp 2010-06-28 08:25:45 UTC (rev 50413)
+++ scummvm/trunk/engines/sci/sound/midiparser_sci.cpp 2010-06-28 09:22:57 UTC (rev 50414)
@@ -53,7 +53,7 @@
_ppqn = 1;
setTempo(16667);
- _volume = 0;
+ _volume = 127;
_signalSet = false;
_signalToSet = 0;
@@ -88,6 +88,7 @@
_channelUsed[i] = false;
_channelRemap[i] = -1;
_channelMuted[i] = false;
+ _channelVolume[i] = 127;
}
_channelRemap[9] = 9; // never map channel 9, because that's used for percussion
_channelRemap[15] = 15; // never map channel 15, because thats used by sierra internally
@@ -109,9 +110,14 @@
}
void MidiParser_SCI::sendInitCommands() {
+ // reset our "global" volume and channel volumes
+ _volume = 127;
+ for (int i = 0; i < 16; i++)
+ _channelVolume[i] = 127;
+
+ // Set initial voice count
if (_pSnd) {
if (_soundVersion <= SCI_VERSION_0_LATE) {
- // Set initial voice count
for (int i = 0; i < 15; ++i) {
byte voiceCount = 0;
if (_channelUsed[i]) {
@@ -186,6 +192,17 @@
// Is channel muted? if so, don't send command
if (_channelMuted[midiChannel])
return;
+
+ if ((midi & 0xFFF0) == 0x07B0) {
+ // someone trying to set channel volume?
+ int channelVolume = (midi >> 16) & 0xFF;
+ // Remember, if we need to set it ourselves
+ _channelVolume[midiChannel] = channelVolume;
+ // Adjust volume accordingly to current "global" volume
+ channelVolume = channelVolume * _volume / 127;
+ midi = (midi & 0xFFF0) | ((channelVolume & 0xFF) << 16);
+ }
+
// Channel remapping
int16 realChannel = _channelRemap[midiChannel];
assert(realChannel != -1);
@@ -660,14 +677,23 @@
void MidiParser_SCI::setVolume(byte volume) {
// FIXME: This receives values > 127... throw a warning for now and clip the variable
if (volume > MUSIC_VOLUME_MAX) {
- warning("attempted to set an invalid volume(%d)", volume);
+ // FIXME: please write where we get an invalid volume, so we can track down the issue
+ error("attempted to set an invalid volume(%d)", volume);
volume = MUSIC_VOLUME_MAX; // reset
}
assert(volume <= MUSIC_VOLUME_MAX);
+ _volume = volume;
+ // Send previous channel volumes again to actually update the volume
+ for (int i = 0; i < 15; i++)
+ if (_channelRemap[i] != -1)
+ sendToDriver(0xB0 + i, 7, _channelVolume[i]);
+ return;
+ // TODO: old code, should be left here till we figured out that new code works fine
if (_volume != volume) {
_volume = volume;
+
switch (_soundVersion) {
case SCI_VERSION_0_EARLY:
case SCI_VERSION_0_LATE: {
Modified: scummvm/trunk/engines/sci/sound/midiparser_sci.h
===================================================================
--- scummvm/trunk/engines/sci/sound/midiparser_sci.h 2010-06-28 08:25:45 UTC (rev 50413)
+++ scummvm/trunk/engines/sci/sound/midiparser_sci.h 2010-06-28 09:22:57 UTC (rev 50414)
@@ -115,6 +115,7 @@
bool _channelUsed[16];
int16 _channelRemap[16];
bool _channelMuted[16];
+ byte _channelVolume[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