[Scummvm-git-logs] scummvm master -> 3cd6343fdf35d242786a6d8637d78f458df1d471

aquadran noreply at scummvm.org
Mon Sep 15 17:44:59 UTC 2025


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

Summary:
3cd6343fdf WINTERMUTE: Sync code with original


Commit: 3cd6343fdf35d242786a6d8637d78f458df1d471
    https://github.com/scummvm/scummvm/commit/3cd6343fdf35d242786a6d8637d78f458df1d471
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2025-09-15T19:44:55+02:00

Commit Message:
WINTERMUTE: Sync code with original

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


diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 4fe034d4017..fb8eca674ea 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -741,6 +741,7 @@ bool BaseGame::initLoop() {
 	_currentTime = BasePlatform::getTime();
 
 	_renderer->initLoop();
+	_soundMgr->initLoop();
 	updateMusicCrossfade();
 
 	_surfaceStorage->initLoop();
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index 70d782da0d5..4018a8c6da4 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -292,7 +292,7 @@ bool BaseSoundBuffer::setPan(float pan) {
 
 //////////////////////////////////////////////////////////////////////////
 bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) {
-	// This function was stubbed out in WME Lite.
+	// TODO
 	switch (type) {
 	case SFX_ECHO:
 		warning("BaseSoundBuffer::ApplyFX(SFX_ECHO, %f, %f, %f, %f)  - not implemented yet", param1, param2, param3, param4);
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 4ab5e358205..53a5469598f 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -85,13 +85,13 @@ public:
 	Audio::SeekableAudioStream *_stream;
 	Audio::SoundHandle *_handle;
 	bool _freezePaused;
-	bool _looping;
-	int32 _privateVolume;
 	uint32 _loopStart;
-	uint32 _startPos;
+	bool _looping;
 	Common::String _filename;
 	bool _streamed;
+	int32 _privateVolume;
 	int32 _volume;
+	uint32 _startPos;
 	int8 _pan;
 };
 
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 839ac49aa42..3cb5351ce6e 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -29,10 +29,12 @@
 #include "engines/wintermute/base/base_engine.h"
 #include "engines/wintermute/utils/path_util.h"
 #include "engines/wintermute/utils/string_util.h"
+#include "engines/wintermute/base/base_game.h"
 #include "engines/wintermute/base/base_file_manager.h"
 #include "engines/wintermute/base/gfx/base_renderer.h"
 #include "engines/wintermute/base/sound/base_sound_buffer.h"
 #include "engines/wintermute/wintermute.h"
+
 #include "common/config-manager.h"
 #include "audio/mixer.h"
 
@@ -90,6 +92,15 @@ bool BaseSoundMgr::initialize() {
 	return STATUS_OK;
 }
 
+//////////////////////////////////////////////////////////////////////////
+bool BaseSoundMgr::initLoop() {
+	if (!_soundAvailable) {
+		return STATUS_OK;
+	}
+
+	return STATUS_OK;
+}
+
 //////////////////////////////////////////////////////////////////////////
 BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
 	if (!_soundAvailable) {
@@ -126,7 +137,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
 
 	bool res = sound->loadFromFile(useFilename);
 	if (DID_FAIL(res)) {
-		BaseEngine::LOG(res, "Error loading sound '%s'", useFilename.c_str());
+		_game->LOG(res, "Error loading sound '%s'", useFilename.c_str());
 		delete sound;
 		return nullptr;
 	}
@@ -213,7 +224,6 @@ byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) {
 		volume = g_system->getMixer()->getVolumeForSoundType(type);
 		break;
 	default:
-		error("Sound-type not set");
 		break;
 	}
 
@@ -284,10 +294,29 @@ bool BaseSoundMgr::resumeAll() {
 
 //////////////////////////////////////////////////////////////////////////
 float BaseSoundMgr::posToPan(int x, int y) {
-	float relPos = (float)x / ((float)BaseEngine::getRenderer()->getWidth());
+	/*
+	 * This is tricky to do right. Scenes could be scrolling (thus bigger than rendering width)
+	 * and even then objects that emit sound could be "outside" the scene.
+	 *
+	 * As a compromise, the range where panning is applied is defined from
+	 * (-0.5 * width) .. 0 .. (+1.5 * width).
+	 *
+	 * Because the sound library might simply ignore values out of range, extreme
+	 * values are truncated.
+	 */
+	float width = (float)_game->_renderer->getWidth();
+	float relPos = ((float)x + (0.5f * width)) / (width * 2.0f);
+
+	// saturate
+	if (relPos < 0.0f) {
+		relPos = 0.0f;
+	}
+	if (relPos > 1.0f) {
+		relPos = 1.0f;
+	}
 
-	float minPan = -0.7f;
-	float maxPan = 0.7f;
+	float minPan = -1.0f;
+	float maxPan = 1.0f;
 
 	return minPan + relPos * (maxPan - minPan);
 }
diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h
index 7a1542555e9..7519f14a52c 100644
--- a/engines/wintermute/base/sound/base_sound_manager.h
+++ b/engines/wintermute/base/sound/base_sound_manager.h
@@ -52,6 +52,7 @@ public:
 	bool removeSound(BaseSoundBuffer *sound);
 	BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
 	bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
+	bool initLoop();
 	bool initialize();
 	bool _soundAvailable;
 	BaseSoundMgr(BaseGame *inGame);




More information about the Scummvm-git-logs mailing list