[Scummvm-git-logs] scummvm master -> d91ea819efdfb358f67726ecf21b5c5f7cb50d6c

elasota noreply at scummvm.org
Thu Jul 21 23:26:02 UTC 2022


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:
d91ea819ef MTROPOLIS: Fix incorrect MIDI effective volume calculation


Commit: d91ea819efdfb358f67726ecf21b5c5f7cb50d6c
    https://github.com/scummvm/scummvm/commit/d91ea819efdfb358f67726ecf21b5c5f7cb50d6c
Author: elasota (ejlasota at gmail.com)
Date: 2022-07-21T19:24:34-04:00

Commit Message:
MTROPOLIS: Fix incorrect MIDI effective volume calculation

Changed paths:
    engines/mtropolis/hacks.cpp
    engines/mtropolis/plugin/standard.cpp


diff --git a/engines/mtropolis/hacks.cpp b/engines/mtropolis/hacks.cpp
index d3ac763042e..cd7ba4c0c97 100644
--- a/engines/mtropolis/hacks.cpp
+++ b/engines/mtropolis/hacks.cpp
@@ -410,9 +410,6 @@ void addObsidianBugFixes(const MTropolisGameDescription &desc, Hacks &hacks) {
 	// the player leaves the journal without clicking Continue.
 	hacks.ignoreMismatchedProjectNameInObjectLookups = true;
 
-	// Bump 70% volume musics to 100%
-	hacks.midiVolumeScale = (100 * 256 / 70);
-
 	// Fix for corrupted frame in transition from the outer edge in Spider to the air puzzle tower.
 	// The data is corrupted in both Mac and Win retail versions.
 	hacks.addAssetHooks(Common::SharedPtr<AssetHooks>(new ObsidianCorruptedAirTowerTransitionFix()));
diff --git a/engines/mtropolis/plugin/standard.cpp b/engines/mtropolis/plugin/standard.cpp
index ab4a147def3..dfa596d724e 100644
--- a/engines/mtropolis/plugin/standard.cpp
+++ b/engines/mtropolis/plugin/standard.cpp
@@ -1262,8 +1262,21 @@ void MidiCombinerDynamic::syncSourceHRController(uint outputChannel, OutputChann
 
 	uint16 effectiveValue = srcMidiChState._hrControllers[hrController];
 
-	if (hrController == MidiDriver_BASE::MIDI_CONTROLLER_VOLUME)
-		effectiveValue = effectiveValue * srcState._masterVolume / 255;
+	if (hrController == MidiDriver_BASE::MIDI_CONTROLLER_VOLUME) {
+		// GM volume to gain control is 40*log10(V/127)
+		// This means linearScale is (volume/0x38f0)^4
+		double linearScale = static_cast<double>(effectiveValue);
+		linearScale *= linearScale;
+		linearScale *= linearScale;
+
+		linearScale *= static_cast<double>(srcState._masterVolume) * (1.0 / 255.0);
+
+		double gmScale = sqrt(sqrt(linearScale)) * 0x38f0;
+		if (gmScale > static_cast<double>(0x3fff))
+			gmScale = 0x3fff;
+
+		effectiveValue = static_cast<uint16>(gmScale);
+	}
 
 	if (outState._hrControllers[hrController] == effectiveValue)
 		return;




More information about the Scummvm-git-logs mailing list