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

NMIError 60350957+NMIError at users.noreply.github.com
Fri Jul 2 13:40:23 UTC 2021


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

Summary:
d897fe590e AUDIO: Fix struct and const init, add missing breaks
c234eb64a2 LURE: Fix struct init, member hiding warnings


Commit: d897fe590ee72cd63590ba6b12811eff2b850d2c
    https://github.com/scummvm/scummvm/commit/d897fe590ee72cd63590ba6b12811eff2b850d2c
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-07-02T15:40:13+02:00

Commit Message:
AUDIO: Fix struct and const init, add missing breaks

Changed paths:
    audio/adlib_ms.cpp
    audio/adlib_ms.h


diff --git a/audio/adlib_ms.cpp b/audio/adlib_ms.cpp
index 8731164c8d..b6588d3c69 100644
--- a/audio/adlib_ms.cpp
+++ b/audio/adlib_ms.cpp
@@ -320,8 +320,6 @@ const uint8 MidiDriver_ADLIB_Multisource::OPL_VOLUME_LOOKUP[32] = {
 	0x09, 0x08, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00
 };
 
-const float MidiDriver_ADLIB_Multisource::OPL_FREQUENCY_CONVERSION_FACTOR = pow(2, 20) / 49716.0f;
-
 MidiDriver_ADLIB_Multisource::MidiChannelControlData::MidiChannelControlData() {
 	init();
 }
@@ -384,7 +382,8 @@ MidiDriver_ADLIB_Multisource::MidiDriver_ADLIB_Multisource(OPL::Config::OplType
 		_rhythmBank(OPL_RHYTHM_BANK),
 		_rhythmBankFirstNote(GS_RHYTHM_FIRST_NOTE),
 		_rhythmBankLastNote(GS_RHYTHM_LAST_NOTE),
-		_noteCounter(1) {
+		_noteCounter(1),
+		_oplFrequencyConversionFactor(pow(2, 20) / 49716.0f) {
 	memset(_channelAllocations, 0xFF, sizeof(_channelAllocations));
 	Common::fill(_shadowRegisters, _shadowRegisters + sizeof(_shadowRegisters), 0);
 }
@@ -783,6 +782,7 @@ void MidiDriver_ADLIB_Multisource::dataEntry(uint8 channel, uint8 dataMsb, uint8
 		}
 		// Apply the new pitch bend sensitivity to any active notes.
 		recalculateFrequencies(channel, source);
+		break;
 	case MIDI_RPN_MASTER_TUNING_FINE:
 		// MSB and LSB are combined to a fraction of a semitone.
 		if (dataMsb != 0xFF) {
@@ -795,6 +795,7 @@ void MidiDriver_ADLIB_Multisource::dataEntry(uint8 channel, uint8 dataMsb, uint8
 		}
 		// Apply the new master tuning to any active notes.
 		recalculateFrequencies(channel, source);
+		break;
 	case MIDI_RPN_MASTER_TUNING_COARSE:
 		// MSB = semitones, LSB is ignored.
 		if (dataMsb != 0xFF) {
@@ -802,8 +803,11 @@ void MidiDriver_ADLIB_Multisource::dataEntry(uint8 channel, uint8 dataMsb, uint8
 		}
 		// Apply the new master tuning to any active notes.
 		recalculateFrequencies(channel, source);
+		break;
+	default:
+		// Ignore data entry if null or an unknown RPN is active.
+		break;
 	}
-	// Ignore data entry if null or an unknown RPN is active.
 }
 
 void MidiDriver_ADLIB_Multisource::volume(uint8 channel, uint8 volume, uint8 source) {
@@ -1064,7 +1068,7 @@ void MidiDriver_ADLIB_Multisource::recalculateVolumes(uint8 channel, uint8 sourc
 }
 
 MidiDriver_ADLIB_Multisource::InstrumentInfo MidiDriver_ADLIB_Multisource::determineInstrument(uint8 channel, uint8 source, uint8 note) {
-	InstrumentInfo instrument = { 0 };
+	InstrumentInfo instrument = { 0, 0, 0 };
 
 	if (channel == MIDI_RHYTHM_CHANNEL) {
 		// On the rhythm channel, the note played indicates which instrument
@@ -1225,7 +1229,7 @@ uint16 MidiDriver_ADLIB_Multisource::calculateFrequency(uint8 channel, uint8 sou
 		// Note that the resulting value is double the actual frequency because
 		// of the use of block 0 (which halves the frequency). This allows for
 		// slightly higher precision in the pitch bend calculation.
-		oplFrequency = round(noteFrequency * OPL_FREQUENCY_CONVERSION_FACTOR);
+		oplFrequency = round(noteFrequency * _oplFrequencyConversionFactor);
 		block = 0;
 	}
 
diff --git a/audio/adlib_ms.h b/audio/adlib_ms.h
index 6538ed5e09..919d54d590 100644
--- a/audio/adlib_ms.h
+++ b/audio/adlib_ms.h
@@ -387,13 +387,6 @@ protected:
 	 */
 	static const uint8 OPL_VOLUME_LOOKUP[];
 
-
-	/**
-	 * Factor to convert a frequency in Hertz to the format used by the OPL
-	 * registers (F-num).
-	 */
-	static const float OPL_FREQUENCY_CONVERSION_FACTOR;
-
 	/**
 	 * Contains the current controller settings for a MIDI channel.
 	 */
@@ -1039,6 +1032,9 @@ protected:
 	// The amount of notes played since the driver was opened / reset.
 	uint32 _noteCounter;
 
+	// Factor to convert a frequency in Hertz to the format used by the OPL
+	// registers (F - num).
+	float _oplFrequencyConversionFactor;
 	// The values last written to each OPL register.
 	uint8 _shadowRegisters[0x200];
 


Commit: c234eb64a207b25c37874d506d81e1cb781de0a7
    https://github.com/scummvm/scummvm/commit/c234eb64a207b25c37874d506d81e1cb781de0a7
Author: Coen Rampen (crampen at gmail.com)
Date: 2021-07-02T15:40:14+02:00

Commit Message:
LURE: Fix struct init, member hiding warnings

Changed paths:
    engines/lure/sound.cpp
    engines/lure/sound.h


diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 1171f75707..070861cba4 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -565,8 +565,8 @@ void SoundManager::musicInterface_Stop(uint8 soundNumber) {
 	MusicListIterator i;
 	for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
 		if ((*i)->soundNumber() == soundNum) {
-			if ((*i)->source() >= 0)
-				_sourcesInUse[(*i)->source()] = false;
+			if ((*i)->getSource() >= 0)
+				_sourcesInUse[(*i)->getSource()] = false;
 			_playingSounds.erase(i);
 			break;
 		}
@@ -703,8 +703,8 @@ void SoundManager::musicInterface_TidySounds() {
 	MusicListIterator i = _playingSounds.begin();
 	while (i != _playingSounds.end()) {
 		if (!(*i)->isPlaying()) {
-			if ((*i)->source() >= 0)
-				_sourcesInUse[(*i)->source()] = false;
+			if ((*i)->getSource() >= 0)
+				_sourcesInUse[(*i)->getSource()] = false;
 			i = _playingSounds.erase(i);
 		} else {
 			++i;
@@ -982,7 +982,7 @@ void MidiDriver_ADLIB_Lure::metaEvent(int8 source, byte type, byte *data, uint16
 }
 
 MidiDriver_ADLIB_Lure::InstrumentInfo MidiDriver_ADLIB_Lure::determineInstrument(uint8 channel, uint8 source, uint8 note) {
-	InstrumentInfo instrument = { 0 };
+	InstrumentInfo instrument = { 0, 0, 0 };
 
 	// Lure does not use a rhythm channel.
 	instrument.oplNote = note;
@@ -1000,12 +1000,12 @@ uint16 MidiDriver_ADLIB_Lure::calculateFrequency(uint8 channel, uint8 source, ui
 
 	// The pitch bend is a number of semitones (in bits 8+) and an 8 bit
 	// fraction of a semitone (only the most significant 4 bits are used).
-	int32 pitchBend = calculatePitchBend(channel, source, 0);
+	int32 newPitchBend = calculatePitchBend(channel, source, 0);
 
 	// Discard the lower 4 bits of the pitch bend (the +8 is for rounding), 
 	// add the MIDI note and clip the result to the range 0-5FF. Note that
 	// MIDI notes 60-7F get clipped to 5F.
-	uint16 noteValue = CLIP((note << 4) + ((pitchBend + 8) >> 4), 0, 0x5FF);
+	uint16 noteValue = CLIP((note << 4) + ((newPitchBend + 8) >> 4), (int32)0, (int32)0x5FF);
 	// Convert the note value to octave note and octave (block).
 	uint8 octaveNote = (noteValue >> 4) % 12;
 	uint8 block = (noteValue >> 4) / 12;
@@ -1032,14 +1032,14 @@ uint16 MidiDriver_ADLIB_Lure::calculateFrequency(uint8 channel, uint8 source, ui
 int32 MidiDriver_ADLIB_Lure::calculatePitchBend(uint8 channel, uint8 source, uint16 oplFrequency) {
 	// Convert MIDI pitch bend value to a 14 bit signed value
 	// (range -0x2000 - 0x2000).
-	int16 pitchBend = _controlData[source][channel].pitchBend - 0x2000;
+	int16 newPitchBend = _controlData[source][channel].pitchBend - 0x2000;
 	// Discard the lower 5 bits to turn it into a 9 bit value (-0x100 - 0x100).
-	pitchBend >>= 5;
+	newPitchBend >>= 5;
 	// Double it for every sensitivity semitone over 1. Note that sensitivity
 	// is typically specified as 1, which will not change the value.
-	pitchBend <<= _pitchBendSensitivity - 1;
+	newPitchBend <<= _pitchBendSensitivity - 1;
 
-	return pitchBend;
+	return newPitchBend;
 }
 
 uint8 MidiDriver_ADLIB_Lure::calculateUnscaledVolume(uint8 channel, uint8 source, uint8 velocity, OplInstrumentDefinition &instrumentDef, uint8 operatorNum) {
diff --git a/engines/lure/sound.h b/engines/lure/sound.h
index e21e92fb06..86a5a85d94 100644
--- a/engines/lure/sound.h
+++ b/engines/lure/sound.h
@@ -90,7 +90,7 @@ public:
 	void onTimer();
 
 	uint8 soundNumber() const { return _soundNumber; }
-	int8 source() const { return _source; }
+	int8 getSource() const { return _source; }
 	bool isPlaying() const { return _isPlaying; }
 	bool isMusic() const { return _isMusic; }
 };




More information about the Scummvm-git-logs mailing list