[Scummvm-cvs-logs] SF.net SVN: scummvm: [22107] scummvm/trunk/engines/simon

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Apr 23 08:43:02 CEST 2006


Revision: 22107
Author:   eriktorbjorn
Date:     2006-04-23 08:42:02 -0700 (Sun, 23 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22107&view=rev

Log Message:
-----------
Implemented volume and panning for FF sound effects. I hope my mapping from
DirectSound's logarithmic scale to ScummVM's linear scale is at least
reasonably collect. This should keep the sound effects from overpowering the
spoken voices in some scenes.

Modified Paths:
--------------
    scummvm/trunk/engines/simon/res.cpp
    scummvm/trunk/engines/simon/simon.h
    scummvm/trunk/engines/simon/sound.cpp
    scummvm/trunk/engines/simon/sound.h
    scummvm/trunk/engines/simon/vga.cpp
Modified: scummvm/trunk/engines/simon/res.cpp
===================================================================
--- scummvm/trunk/engines/simon/res.cpp	2006-04-23 14:47:43 UTC (rev 22106)
+++ scummvm/trunk/engines/simon/res.cpp	2006-04-23 15:42:02 UTC (rev 22107)
@@ -710,7 +710,7 @@
 	return dst;
 }
 
-void SimonEngine::loadSound(uint sound, uint pan, uint vol, uint type) {
+void SimonEngine::loadSound(uint sound, int pan, int vol, uint type) {
 	byte *dst;
 
 	if (getFeatures() & GF_ZLIBCOMP) {

Modified: scummvm/trunk/engines/simon/simon.h
===================================================================
--- scummvm/trunk/engines/simon/simon.h	2006-04-23 14:47:43 UTC (rev 22106)
+++ scummvm/trunk/engines/simon/simon.h	2006-04-23 15:42:02 UTC (rev 22107)
@@ -496,7 +496,7 @@
 	void loadGamePcFile();
 	void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
 	void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
-	void loadSound(uint sound, uint pan, uint vol, uint type);
+	void loadSound(uint sound, int pan, int vol, uint type);
 	void loadVoice(uint speechId);
 
 	void palette_fadeout(uint32 *pal_values, uint num);

Modified: scummvm/trunk/engines/simon/sound.cpp
===================================================================
--- scummvm/trunk/engines/simon/sound.cpp	2006-04-23 14:47:43 UTC (rev 22106)
+++ scummvm/trunk/engines/simon/sound.cpp	2006-04-23 15:42:02 UTC (rev 22107)
@@ -265,7 +265,6 @@
 		if (_vm->getGameType() == GType_SIMON1)
 			loadSfxFile(gss);
 	}
-
 }
 
 Sound::~Sound() {
@@ -585,7 +584,7 @@
 	playSoundData(&_voiceHandle, soundData, sound);
 }
 
-void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan, uint vol, bool loop) {
+void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) {
 	byte *buffer, flags;
 	uint16 compType;
 	int blockAlign, rate;
@@ -596,6 +595,38 @@
 		error("playSoundData: Not a valid WAV data");
 	}
 
+	// The Feeble Files originally used DirectSound, which specifies volume
+	// and panning differently than ScummVM does, using a logarithmic scale
+	// rather than a linear one.
+	//
+	// Volume is a value between -10,000 and 0.
+	// Panning is a value between -10,000 and 10,000.
+	//
+	// In both cases, the -10,000 represents -100 dB. When panning, only
+	// one speaker's volume is affected - just like in ScummVM - with
+	// negative values affecting the left speaker, and positive values
+	// affecting the right speaker. Thus -10,000 means the left speaker is
+	// silent.
+
+	int v, p;
+
+	vol = CLIP(vol, -10000, 0);
+	pan = CLIP(pan, -10000, 10000);
+
+	if (vol) {
+		v = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)vol / 2000.0) + 0.5);
+	} else {
+		v = Audio::Mixer::kMaxChannelVolume;
+	}
+
+	if (pan < 0) {
+		p = (int)(255.0 * pow(10.0, (double)pan / 2000.0) + 127.5);
+	} else if (pan > 0) {
+		p = (int)(255.0 * pow(10.0, (double)pan / -2000.0) - 127.5);
+	} else {
+		p = 0;
+	}
+
 	if (loop == true)
 		flags |= Audio::Mixer::FLAG_LOOP;
 	
@@ -610,7 +641,7 @@
 		memcpy(buffer, soundData + stream.pos(), size);
 	}
 
-	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);
+	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, v, p);
 }
 
 void Sound::stopSfx5() {

Modified: scummvm/trunk/engines/simon/sound.h
===================================================================
--- scummvm/trunk/engines/simon/sound.h	2006-04-23 14:47:43 UTC (rev 22106)
+++ scummvm/trunk/engines/simon/sound.h	2006-04-23 15:42:02 UTC (rev 22107)
@@ -76,7 +76,7 @@
 	void playAmbientData(byte *soundData, uint sound, uint pan, uint vol);
 	void playSfxData(byte *soundData, uint sound, uint pan, uint vol);
 	void playSfx5Data(byte *soundData, uint sound, uint pan, uint vol);
-	void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan = 0, uint vol = 0, bool loop = false);
+	void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan = 0, int vol = 0, bool loop = false);
 	void playVoiceData(byte *soundData, uint sound);
 	void switchVoiceFile(const GameSpecificSettings *gss, uint disc);
 

Modified: scummvm/trunk/engines/simon/vga.cpp
===================================================================
--- scummvm/trunk/engines/simon/vga.cpp	2006-04-23 14:47:43 UTC (rev 22106)
+++ scummvm/trunk/engines/simon/vga.cpp	2006-04-23 15:42:02 UTC (rev 22107)
@@ -1965,8 +1965,8 @@
 	}
 
 	if (getGameType() == GType_FF) {
-		uint16 pan = vcReadNextWord();
-		uint16 vol = vcReadNextWord();
+		int16 pan = vcReadNextWord();
+		int16 vol = vcReadNextWord();
 
 		if (ambient)
 			loadSound(sound, pan, vol, 2);
@@ -1986,11 +1986,11 @@
 
 void SimonEngine::vc53_panSFX() {
 	VgaSprite *vsp = findCurSprite();
-	int32 pan;
+	int pan;
 
 	uint16 sound = vcReadNextWord();
 	int16 xoffs = vcReadNextWord();
-	uint16 vol = vcReadNextWord();
+	int16 vol = vcReadNextWord();
 
 	pan = (vsp->x - _scrollX + xoffs) * 8 - 2560;
 	if (pan < -10000)
@@ -2488,8 +2488,8 @@
 
 void SimonEngine::vc83_playSoundLoop() {
 	uint sound = vcReadNextWord();
-	uint vol = vcReadNextWord();
-	uint pan = vcReadNextWord();
+	int16 vol = vcReadNextWord();
+	int16 pan = vcReadNextWord();
 
 	loadSound(sound, pan, vol, 3);
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list