[Scummvm-git-logs] scummvm master -> 5796de1db67e5b90718491e8588faba378e113c2

mduggan mgithub at guarana.org
Sun Mar 29 05:22:08 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5796de1db6 ULTIMA8: Set volume and balance on sfx


Commit: 5796de1db67e5b90718491e8588faba378e113c2
    https://github.com/scummvm/scummvm/commit/5796de1db67e5b90718491e8588faba378e113c2
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-03-29T14:21:37+09:00

Commit Message:
ULTIMA8: Set volume and balance on sfx

Changed paths:
    engines/ultima/ultima8/audio/audio_channel.cpp


diff --git a/engines/ultima/ultima8/audio/audio_channel.cpp b/engines/ultima/ultima8/audio/audio_channel.cpp
index 97221d9ba5..c997fd16b2 100644
--- a/engines/ultima/ultima8/audio/audio_channel.cpp
+++ b/engines/ultima/ultima8/audio/audio_channel.cpp
@@ -30,16 +30,6 @@
 namespace Ultima {
 namespace Ultima8 {
 
-// We divide the data by 2, to prevent overshots. Imagine this _sample pattern:
-// 0, 65535, 65535, 0. Now you want to compute a value between the two 65535.
-// Obviously, it will be *bigger* than 65535 (it can get to about 80,000).
-// It is possibly to clamp it, but that leads to a distored wave form. Compare
-// this to turning up the volume of your stereo to much, it will start to sound
-// bad at a certain level (depending on the power of your stereo, your speakers
-// etc, this can be quite loud, though ;-). Hence we reduce the original range.
-// A factor of roughly 1/1.2 = 0.8333 is sufficient. Since we want to avoid
-// floating point, we approximate that by 27/32
-#define RANGE_REDUX(x)  (((x) * 27) >> 5)
 
 AudioChannel::AudioChannel(Audio::Mixer *mixer, uint32 sampleRate, bool stereo) :
 		_mixer(mixer), _decompressorSize(0), _frameSize(0), _loop(0), _sample(nullptr),
@@ -95,7 +85,9 @@ void AudioChannel::playSample(AudioSample *sample, int loop, int priority, bool
 		new Audio::LoopingAudioStream(audioStream, _loop);
 
 	// Play it
-	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, stream);
+	int vol = (_lVol + _rVol) / 2;
+	int balance = (_rVol - _lVol);
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, stream, -1, vol, balance);
 	if (paused)
 		_mixer->pauseHandle(_soundHandle, true);
 }




More information about the Scummvm-git-logs mailing list