[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.176,1.177 mixer.h,1.90,1.91

Max Horn fingolfin at users.sourceforge.net
Mon Dec 27 15:34:03 CET 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28539

Modified Files:
	mixer.cpp mixer.h 
Log Message:
Introduced two new constants SoundMixer::kMaxChannelVolume and SoundMixer::kMaxMixerVolume, for clarity

Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- mixer.cpp	27 Dec 2004 02:58:55 -0000	1.176
+++ mixer.cpp	27 Dec 2004 23:33:19 -0000	1.177
@@ -106,7 +106,7 @@
 	int i = 0;
 
 	for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
-		_volumeForSoundType[i] = 256;
+		_volumeForSoundType[i] = kMaxMixerVolume;
 
 	_paused = false;
 	
@@ -406,8 +406,8 @@
 	assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType));
 
 	// Check range
-	if (volume > 256)
-		volume = 256;
+	if (volume > kMaxMixerVolume)
+		volume = kMaxMixerVolume;
 	else if (volume < 0)
 		volume = 0;
 	
@@ -431,7 +431,7 @@
 
 Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, int id)
 	: _type(type), _mixer(mixer), _handle(handle), _autofreeStream(true),
-	  _volume(255), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
+	  _volume(SoundMixer::kMaxChannelVolume), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
 	  _samplesDecoded(0), _mixerTimeStamp(0), _converter(0), _input(0) {
 	assert(mixer);
 }
@@ -439,7 +439,7 @@
 Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, AudioStream *input,
 				bool autofreeStream, bool reverseStereo, int id, bool permanent)
 	: _type(type), _mixer(mixer), _handle(handle), _autofreeStream(autofreeStream),
-	  _volume(255), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
+	  _volume(SoundMixer::kMaxChannelVolume), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
 	  _samplesDecoded(0), _mixerTimeStamp(0), _converter(0), _input(input), _permanent(permanent) {
 	assert(mixer);
 	assert(input);
@@ -480,14 +480,14 @@
 		st_volume_t vol_l, vol_r;
 
 		if (_balance == 0) {
-			vol_l = vol / 255;
-			vol_r = vol / 255;
+			vol_l = vol / SoundMixer::kMaxChannelVolume;
+			vol_r = vol / SoundMixer::kMaxChannelVolume;
 		} else if (_balance < 0) {
-			vol_l = vol / 255;
-			vol_r = ((127 + _balance) * vol) / (255 * 127);
+			vol_l = vol / SoundMixer::kMaxChannelVolume;
+			vol_r = ((127 + _balance) * vol) / (SoundMixer::kMaxChannelVolume * 127);
 		} else {
-			vol_l = ((127 - _balance) * vol) / (255 * 127);
-			vol_r = vol / 255;
+			vol_l = ((127 - _balance) * vol) / (SoundMixer::kMaxChannelVolume * 127);
+			vol_r = vol / SoundMixer::kMaxChannelVolume;
 		}
 
 		_samplesConsumed = _samplesDecoded;

Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- mixer.h	27 Dec 2004 02:58:55 -0000	1.90
+++ mixer.h	27 Dec 2004 23:33:19 -0000	1.91
@@ -76,6 +76,11 @@
 		kSFXAudioDataType = 2,
 		kSpeechAudioDataType = 3
 	};
+	
+	enum {
+		kMaxChannelVolume = 255,
+		kMaxMixerVolume = 256
+	};
 
 private:
 	enum {





More information about the Scummvm-git-logs mailing list