[Scummvm-cvs-logs] scummvm master -> 0c0ed9fdd814e6dbf8dd0851b42e7ca1c12f6ae5

somaen einarjohants at gmail.com
Tue Jan 14 00:26:27 CET 2014


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:
0c0ed9fdd8 WINTERMUTE: Limit the range of the panning-variable to stay within [-1,1].


Commit: 0c0ed9fdd814e6dbf8dd0851b42e7ca1c12f6ae5
    https://github.com/scummvm/scummvm/commit/0c0ed9fdd814e6dbf8dd0851b42e7ca1c12f6ae5
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2014-01-13T15:24:28-08:00

Commit Message:
WINTERMUTE: Limit the range of the panning-variable to stay within [-1,1].

Also, store the panning state, so that the next playback starts with the same pan.

Changed paths:
    engines/wintermute/base/sound/base_sound_buffer.cpp
    engines/wintermute/base/sound/base_sound_buffer.h



diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index 7666a44..85ba52e 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -58,6 +58,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
 	_file = nullptr;
 	_privateVolume = 255;
 	_volume = 255;
+	_pan = 0;
 
 	_looping = false;
 	_loopStart = 0;
@@ -143,9 +144,9 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
 		_handle = new Audio::SoundHandle;
 		if (_looping) {
 			Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
-			g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
+			g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
 		} else {
-			g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO);
+			g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO);
 		}
 	}
 
@@ -268,8 +269,11 @@ bool BaseSoundBuffer::setLoopStart(uint32 pos) {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSoundBuffer::setPan(float pan) {
+	pan = MAX(pan, -1.0f);
+	pan = MIN(pan, 1.0f);
+	_pan = (int8)(pan * 127);
 	if (_handle) {
-		g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127));
+		g_system->getMixer()->setChannelBalance(*_handle, _pan);
 	}
 	return STATUS_OK;
 }
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 53b86f6..c52b34f 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -93,6 +93,7 @@ private:
 	bool _streamed;
 	Common::SeekableReadStream *_file;
 	int32 _volume;
+	int8 _pan;
 };
 
 } // End of namespace Wintermute






More information about the Scummvm-git-logs mailing list