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

elasota noreply at scummvm.org
Sat Feb 24 01:58:21 UTC 2024


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:
c817aa8fdc MTROPOLIS: Fix wrong MIDI gain math


Commit: c817aa8fdc8a7857e696d092fb2516ac82b93732
    https://github.com/scummvm/scummvm/commit/c817aa8fdc8a7857e696d092fb2516ac82b93732
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-02-23T20:57:51-05:00

Commit Message:
MTROPOLIS: Fix wrong MIDI gain math

Amplitude is 10x = +20dB, not +10dB

Changed paths:
    engines/mtropolis/plugin/midi.cpp


diff --git a/engines/mtropolis/plugin/midi.cpp b/engines/mtropolis/plugin/midi.cpp
index 7a5cb868522..917630a73e8 100644
--- a/engines/mtropolis/plugin/midi.cpp
+++ b/engines/mtropolis/plugin/midi.cpp
@@ -504,7 +504,7 @@ private:
 		void deallocate();
 
 		SourceChannelState _sourceChannelState[MidiDriver_BASE::MIDI_CHANNEL_COUNT];
-		uint16 _root4MasterVolume;
+		uint16 _sqrtMasterVolume;
 		bool _isAllocated;
 	};
 
@@ -637,7 +637,8 @@ void MidiCombinerDynamic::deallocateSource(uint sourceID) {
 
 void MidiCombinerDynamic::setSourceVolume(uint sourceID, uint8 volume) {
 	SourceState &src = _sources[sourceID];
-	src._root4MasterVolume = static_cast<uint16>(floor(sqrt(sqrt(volume)) * 16400.0));
+	//src._root4MasterVolume = static_cast<uint16>(floor(sqrt(sqrt(volume)) * 16400.0));
+	src._sqrtMasterVolume = static_cast<uint16>(floor(sqrt(volume) * 4104.0));
 
 	for (uint i = 0; i < ARRAYSIZE(_outputChannels); i++) {
 		OutputChannelState &ch = _outputChannels[i];
@@ -1271,7 +1272,7 @@ void MidiCombinerDynamic::syncSourceHRController(uint outputChannel, OutputChann
 		// This means linear scale is (volume/0x3f80)^4
 		// To modulate the volume linearly, we must multiply the volume by the 4th root
 		// of the volume.
-		uint32 effectiveValueScaled = static_cast<uint32>(srcState._root4MasterVolume) * static_cast<uint32>(effectiveValue);
+		uint32 effectiveValueScaled = static_cast<uint32>(srcState._sqrtMasterVolume) * static_cast<uint32>(effectiveValue);
 		effectiveValueScaled += (effectiveValueScaled >> 16) + 1u;
 		effectiveValue = static_cast<uint16>(effectiveValueScaled >> 16);
 	}
@@ -1381,7 +1382,7 @@ MidiCombinerDynamic::SourceChannelState::SourceChannelState() {
 void MidiCombinerDynamic::SourceChannelState::reset() {
 }
 
-MidiCombinerDynamic::SourceState::SourceState() : _isAllocated(false), _root4MasterVolume(0xffffu) {
+MidiCombinerDynamic::SourceState::SourceState() : _isAllocated(false), _sqrtMasterVolume(0xffffu) {
 }
 
 void MidiCombinerDynamic::SourceState::allocate() {




More information about the Scummvm-git-logs mailing list