diff options
author | Max Horn | 2004-12-27 23:33:19 +0000 |
---|---|---|
committer | Max Horn | 2004-12-27 23:33:19 +0000 |
commit | bc882a1af4df93feeaff82e69a4609367e373e20 (patch) | |
tree | 3802139b103372ec1e23f3d8e7c47014dbf2ea3f | |
parent | d299f0601bd977907426d18828dacec14907b8dc (diff) | |
download | scummvm-rg350-bc882a1af4df93feeaff82e69a4609367e373e20.tar.gz scummvm-rg350-bc882a1af4df93feeaff82e69a4609367e373e20.tar.bz2 scummvm-rg350-bc882a1af4df93feeaff82e69a4609367e373e20.zip |
Introduced two new constants SoundMixer::kMaxChannelVolume and SoundMixer::kMaxMixerVolume, for clarity
svn-id: r16348
-rw-r--r-- | sound/mixer.cpp | 22 | ||||
-rw-r--r-- | sound/mixer.h | 5 |
2 files changed, 16 insertions, 11 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 72c5738e4f..74165d3a0a 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -106,7 +106,7 @@ SoundMixer::SoundMixer() { int i = 0; for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++) - _volumeForSoundType[i] = 256; + _volumeForSoundType[i] = kMaxMixerVolume; _paused = false; @@ -406,8 +406,8 @@ void SoundMixer::setVolumeForSoundType(SoundType type, int volume) { 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 @@ int SoundMixer::getVolumeForSoundType(SoundType type) const { 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::Soun 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 @@ void Channel::mix(int16 *data, uint len) { 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; diff --git a/sound/mixer.h b/sound/mixer.h index 9fe7d3cda0..cdc601e402 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -76,6 +76,11 @@ public: kSFXAudioDataType = 2, kSpeechAudioDataType = 3 }; + + enum { + kMaxChannelVolume = 255, + kMaxMixerVolume = 256 + }; private: enum { |