[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.78,1.79 d_sound.h,1.29,1.30

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sat Nov 1 10:13:03 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv24864/driver

Modified Files:
	d_sound.cpp d_sound.h 
Log Message:
Instead of having a function that reverses the panning table, we now have a
function that creates the panning table. The difference is that you now
have to tell whether you want one for normal or reverse stereo, so you are
not dependent on the previous state of the table.

(I still think it may be possible to get rid of the panning table
completely, but that's for later cleanups.)


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- d_sound.cpp	29 Oct 2003 07:53:05 -0000	1.78
+++ d_sound.cpp	1 Nov 2003 18:12:04 -0000	1.79
@@ -52,14 +52,6 @@
 #define GetCompressedSign(n)       (((n) >> 3) & 1)
 #define GetCompressedAmplitude(n)  ((n) & 7)
 
-static int32 panTable[33] = {
-	-127, -119, -111, -103,  -95,  -87,  -79,  -71,
-	 -63,  -55,  -47,  -39,  -31,  -23,  -15,   -7,
-	   0,
-	   7,   15,   23,   31,   39,   47,   55,   63,
-          71,   79,   87,   95,  103,  111,  119,  127
-};
-
 static int32 musicVolTable[17] = {
 	  0,  15,  31,  47,  63,  79,  95, 111, 127,
 	143, 159, 175, 191, 207, 223, 239, 255
@@ -165,12 +157,23 @@
 // FIXME: We could probably use the FLAG_REVERSE_STEREO mixer flag here.
 
 /**
- * This function reverses the pan table, thus reversing the stereo.
+ * This function creates the pan table.
  */
 
-void Sound::reverseStereo(void) {
-	for (int i = 0; i < 16; i++)
-		SWAP(panTable[i], panTable[32 - i]);
+void Sound::buildPanTable(bool reverse) {
+	int i;
+
+	for (i = 0; i < 16; i++) {
+		_panTable[i] = -127 + i * 8;
+		_panTable[i + 17] = (i + 1) * 8 - 1;
+	}
+
+	_panTable[16] = 0;
+
+	if (reverse) {
+		for (i = 0; i < 33; i++)
+			_panTable[i] = -_panTable[i];
+	}
 }
 
 // Save/Restore information about current music so that we can restore it
@@ -407,7 +410,7 @@
 		// Modify the volume according to the master volume
 
 		byte volume = _speechMuted ? 0 : vol * _speechVol;
-		int8 p = panTable[pan + 16];
+		int8 p = _panTable[pan + 16];
 
 		// Start the speech playing
 
@@ -659,7 +662,7 @@
 			// Start the sound effect playing
 
 			byte volume = _fxMuted ? 0 : vol * _fxVol;
-			int8 p = panTable[pan + 16];
+			int8 p = _panTable[pan + 16];
 
 			g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
 		} else {
@@ -703,7 +706,7 @@
 				// Start the sound effect playing
 
 				byte volume = _fxMuted ? 0 : vol * _fxVol;
-				int8 p = panTable[pan + 16];
+				int8 p = _panTable[pan + 16];
 
 				g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
 			}
@@ -733,7 +736,7 @@
 
 	if (!_fxMuted) {
 		g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol);
-		g_engine->_mixer->setChannelPan(_fx[i]._handle, panTable[pan + 16]);
+		g_engine->_mixer->setChannelPan(_fx[i]._handle, _panTable[pan + 16]);
 	}
 
 	return RD_OK;

Index: d_sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- d_sound.h	29 Oct 2003 07:53:05 -0000	1.29
+++ d_sound.h	1 Nov 2003 18:12:04 -0000	1.30
@@ -76,6 +76,8 @@
 	OSystem::MutexRef _mutex;
 	RateConverter *_converter;
 
+	uint32 _panTable[33];
+
 	FxHandle _fx[MAXFX];
 	MusicHandle _music[MAXMUS + 1];
 
@@ -122,7 +124,7 @@
 	void restoreMusicState();
 	void playLeadOut(uint8 *leadOut);
 	int32 musicTimeRemaining();
-	void reverseStereo(void);
+	void buildPanTable(bool reverse);
 	uint8 getFxVolume(void);
 	uint8 getSpeechVolume(void);
 	uint8 getMusicVolume(void);





More information about the Scummvm-git-logs mailing list