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

digitall dgturner at iee.org
Mon Jun 3 18:06:05 CEST 2019


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:
b1bd75a083 AGOS: Mute fix for ADLIB Accolade


Commit: b1bd75a0838e1bf5ba87a70a4490b4b6265ef16b
    https://github.com/scummvm/scummvm/commit/b1bd75a0838e1bf5ba87a70a4490b4b6265ef16b
Author: Fedor Antokhin (fantohin at gmail.com)
Date: 2019-06-03T17:06:00+01:00

Commit Message:
AGOS: Mute fix for ADLIB Accolade

Changed paths:
    engines/agos/drivers/accolade/adlib.cpp
    engines/agos/midi.cpp
    engines/agos/midi.h


diff --git a/engines/agos/drivers/accolade/adlib.cpp b/engines/agos/drivers/accolade/adlib.cpp
index 3a95d8f..fce7c9b 100644
--- a/engines/agos/drivers/accolade/adlib.cpp
+++ b/engines/agos/drivers/accolade/adlib.cpp
@@ -153,9 +153,10 @@ private:
 		byte   currentA0hReg;
 		byte   currentB0hReg;
 		int16  volumeAdjust;
+		byte   velocity;
 
 		ChannelEntry() : currentInstrumentPtr(NULL), currentNote(0),
-						currentA0hReg(0), currentB0hReg(0), volumeAdjust(0) { }
+						currentA0hReg(0), currentB0hReg(0), volumeAdjust(0), velocity(0) { }
 	};
 
 	byte _percussionReg;
@@ -257,8 +258,17 @@ void MidiDriver_Accolade_AdLib::close() {
 }
 
 void MidiDriver_Accolade_AdLib::setVolume(byte volume) {
-	_masterVolume = volume;
-	//renewNotes(-1, true);
+	// Set the master volume in range from -128 to 127
+	_masterVolume = CLIP<int>(-128 + volume, -128, 127);
+	for (int i = 0; i < AGOS_ADLIB_VOICES_COUNT; i++) {
+		// Adjust channel volume with the master volume and re-set registers
+		byte adjustedVelocity = _channels[i].velocity * ((float) (128 + _masterVolume) / 128);
+		noteOnSetVolume(i, 1, adjustedVelocity);
+		if (i <= AGOS_ADLIB_VOICES_PERCUSSION_START) {
+			// Set second operator for FM voices + first percussion
+			noteOnSetVolume(i, 2, adjustedVelocity);
+		}
+	}
 }
 
 void MidiDriver_Accolade_AdLib::onTimer() {
@@ -376,12 +386,11 @@ void MidiDriver_Accolade_AdLib::noteOn(byte FMvoiceChannel, byte note, byte velo
 	int16 channelVolumeAdjust = _channels[FMvoiceChannel].volumeAdjust;
 	channelVolumeAdjust += adjustedVelocity;
 	channelVolumeAdjust = CLIP<int16>(channelVolumeAdjust, 0, 0x7F);
-
-	// TODO: adjust to global volume
-	// original drivers had a global volume variable, which was 0 for full volume, -64 for half volume
-	// and -128 for mute
-
-	adjustedVelocity = channelVolumeAdjust;
+	
+	// adjust velocity with the master volume
+	byte volumeAdjust = adjustedVelocity * ((float) (128 + _masterVolume) / 128);
+	
+	adjustedVelocity = volumeAdjust;
 
 	if (!_musicDrvMode) {
 		// INSTR.DAT
@@ -441,6 +450,8 @@ void MidiDriver_Accolade_AdLib::noteOn(byte FMvoiceChannel, byte note, byte velo
 		adjustedVelocity = adjustedVelocity >> 1; // divide by 2
 	}
 
+	// Save velocity in the case volume will need to be changed
+	_channels[FMvoiceChannel].velocity = adjustedVelocity;
 	// Set volume of voice channel
 	noteOnSetVolume(FMvoiceChannel, 1, adjustedVelocity);
 	if (FMvoiceChannel <= AGOS_ADLIB_VOICES_PERCUSSION_START) {
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp
index 5e28654..b20f183 100644
--- a/engines/agos/midi.cpp
+++ b/engines/agos/midi.cpp
@@ -28,6 +28,8 @@
 #include "agos/agos.h"
 #include "agos/midi.h"
 
+#include "agos/drivers/accolade/adlib.cpp"
+
 #include "agos/drivers/accolade/mididriver.h"
 #include "agos/drivers/simon1/adlib.h"
 // Miles Audio for Simon 2
@@ -89,7 +91,7 @@ int MidiPlayer::open(int gameType, bool isDemo) {
 	assert(!_driver);
 
 	Common::String accoladeDriverFilename;
-	MusicType musicType = MT_INVALID;
+	musicType = MT_INVALID;
 
 	switch (gameType) {
 	case GType_ELVIRA1:
@@ -159,6 +161,7 @@ int MidiPlayer::open(int gameType, bool isDemo) {
 		switch (musicType) {
 		case MT_ADLIB:
 			_driver = MidiDriver_Accolade_AdLib_create(accoladeDriverFilename);
+			
 			break;
 		case MT_MT32:
 			_driver = MidiDriver_Accolade_MT32_create(accoladeDriverFilename);
@@ -473,6 +476,10 @@ void MidiPlayer::pause(bool b) {
 	_paused = b;
 
 	Common::StackLock lock(_mutex);
+	// if using the driver Accolade_AdLib call setVolume() to turn off\on the volume on all channels
+	if (musicType == MT_ADLIB && _musicMode == kMusicModeAccolade) {
+		static_cast <MidiDriver_Accolade_AdLib*> (_driver)->setVolume(_paused ? 0 : 128);
+	}
 	for (int i = 0; i < 16; ++i) {
 		if (_music.channel[i])
 			_music.channel[i]->volume(_paused ? 0 : (_music.volume[i] * _musicVolume / 255));
diff --git a/engines/agos/midi.h b/engines/agos/midi.h
index fb987fd..070413e 100644
--- a/engines/agos/midi.h
+++ b/engines/agos/midi.h
@@ -123,7 +123,8 @@ public:
 
 private:
 	kMusicMode _musicMode;
-
+	MusicType musicType;
+	
 private:
 	Common::SeekableReadStream *simon2SetupExtractFile(const Common::String &requestedFileName);
 };





More information about the Scummvm-git-logs mailing list