[Scummvm-git-logs] scummvm master -> 58dbe629f369c4d4d3010b501cb909c251feb2ff

dreammaster dreammaster at scummvm.org
Sat Feb 11 23:30:57 CET 2017


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

Summary:
5b8d4cac58 TITANIC: Convert more methods to using MusicInstrument enum
b97137830a TITANIC: Fix getPitch calculation when inversion control is incorrect
58dbe629f3 TITANIC: Fix intial setup of BASS pitch control


Commit: 5b8d4cac5809f1b77981dddceff854254ab4a194
    https://github.com/scummvm/scummvm/commit/5b8d4cac5809f1b77981dddceff854254ab4a194
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-11T17:25:26-05:00

Commit Message:
TITANIC: Convert more methods to using MusicInstrument enum

Changed paths:
    engines/titanic/sound/music_room_handler.cpp
    engines/titanic/sound/music_room_handler.h


diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index 01d074c..7e23095 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -212,8 +212,9 @@ void CMusicRoomHandler::updateAudio() {
 		int16 *audioPtr = _audioBuffer->getWritePtr();
 		Common::fill(audioPtr, audioPtr + size / sizeof(uint16), 0);
 
-		for (int instrIdx = 0; instrIdx < 4; ++instrIdx) {
-			CMusicWave *musicWave = _musicWaves[instrIdx];
+		for (MusicInstrument instrument = BELLS; instrument <= BASS;
+				instrument = (MusicInstrument)((int)instrument + 1)) {
+			CMusicWave *musicWave = _musicWaves[instrument];
 
 			// Iterate through each of the four instruments and do an additive
 			// read that will merge their data onto the output buffer
@@ -222,7 +223,7 @@ void CMusicRoomHandler::updateAudio() {
 				if (amount > 0) {
 					count -= amount;
 					ptr += amount / sizeof(uint16);
-				} else if (!fn2(instrIdx)) {
+				} else if (!updateInstrument(instrument)) {
 					--_field108;
 					break;
 				}
@@ -237,14 +238,15 @@ void CMusicRoomHandler::updateAudio() {
 
 void CMusicRoomHandler::fn1() {
 	if (_active && _soundStartTicks) {
-		for (int idx = 0; idx < 4; ++idx) {
-			MusicRoomInstrument &ins1 = _array1[idx];
-			MusicRoomInstrument &ins2 = _array2[idx];
-			CMusicWave *musicWave = _musicWaves[idx];
+		for (MusicInstrument instrument = BELLS; instrument <= BASS;
+				instrument = (MusicInstrument)((int)instrument + 1)) {
+			MusicRoomInstrument &ins1 = _array1[instrument];
+			MusicRoomInstrument &ins2 = _array2[instrument];
+			CMusicWave *musicWave = _musicWaves[instrument];
 
 			// Is this about checking playback position?
-			if (_position[idx] < 0 || ins1._muteControl || _position[idx] >= _musicObjs[idx]->size()) {
-				_position[idx] = -1;
+			if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _musicObjs[instrument]->size()) {
+				_position[instrument] = -1;
 				continue;
 			}
 
@@ -252,47 +254,47 @@ void CMusicRoomHandler::fn1() {
 			double val = (double)ticks * 0.001 - 0.6;
 
 			if (val >= musicWave->_floatVal) {
-				_array5[idx] += fn3(idx, _position[idx]);
+				_array5[instrument] += fn3(instrument, _position[instrument]);
 
-				const CValuePair &vp = (*_musicObjs[idx])[_position[idx]];
+				const CValuePair &vp = (*_musicObjs[instrument])[_position[instrument]];
 				if (vp._field0 != 0x7FFFFFFF) {
-					int amount = getPitch(idx, _position[idx]);
-					_musicWaves[idx]->start(amount);
+					int amount = getPitch(instrument, _position[instrument]);
+					_musicWaves[instrument]->start(amount);
 				}
 
 				if (ins1._directionControl == ins2._directionControl) {
-					_position[idx]++;
+					_position[instrument]++;
 				} else {
-					_position[idx]--;
+					_position[instrument]--;
 				}
 			}
 		}
 	}
 }
 
-bool CMusicRoomHandler::fn2(int index) {
-	int &arrIndex = _startPos[index];
+bool CMusicRoomHandler::updateInstrument(MusicInstrument instrument) {
+	int &arrIndex = _startPos[instrument];
 	if (arrIndex < 0) {
-		_musicWaves[index]->reset();
+		_musicWaves[instrument]->reset();
 		return false;
 	}
 
-	const CMusicObject &mObj = *_musicObjs[index];
+	const CMusicObject &mObj = *_musicObjs[instrument];
 	if (arrIndex >= mObj.size()) {
 		arrIndex = -1;
-		_musicWaves[index]->reset();
+		_musicWaves[instrument]->reset();
 		return false;
 	}
 
 	const CValuePair &vp = mObj[arrIndex];
-	int size = static_cast<int>(fn3(index, arrIndex) * 44100.0) & ~1;
+	int size = static_cast<int>(fn3(instrument, arrIndex) * 44100.0) & ~1;
 
-	if (vp._field0 == 0x7FFFFFFF || _array1[index]._muteControl)
-		_musicWaves[index]->setSize(size);
+	if (vp._field0 == 0x7FFFFFFF || _array1[instrument]._muteControl)
+		_musicWaves[instrument]->setSize(size);
 	else
-		_musicWaves[index]->chooseWaveFile(getPitch(index, arrIndex), size);
+		_musicWaves[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), size);
 
-	if (_array1[index]._directionControl == _array2[index]._directionControl) {
+	if (_array1[instrument]._directionControl == _array2[instrument]._directionControl) {
 		++arrIndex;
 	} else {
 		--arrIndex;
@@ -301,10 +303,10 @@ bool CMusicRoomHandler::fn2(int index) {
 	return true;
 }
 
-double CMusicRoomHandler::fn3(int index, int arrIndex) {
-	const CValuePair &vp = (*_musicObjs[index])[arrIndex];
+double CMusicRoomHandler::fn3(MusicInstrument instrument, int arrIndex) {
+	const CValuePair &vp = (*_musicObjs[instrument])[arrIndex];
 
-	switch (_array1[index]._speedControl + _array2[index]._speedControl + 3) {
+	switch (_array1[instrument]._speedControl + _array2[instrument]._speedControl + 3) {
 	case 0:
 		return (double)vp._field4 * 1.5 * 0.0625 * 0.46875;
 	case 1:
@@ -322,12 +324,12 @@ double CMusicRoomHandler::fn3(int index, int arrIndex) {
 	}
 }
 
-int CMusicRoomHandler::getPitch(int index, int arrIndex) {
-	const CMusicObject &mObj = *_musicObjs[index];
+int CMusicRoomHandler::getPitch(MusicInstrument instrument, int arrIndex) {
+	const CMusicObject &mObj = *_musicObjs[instrument];
 	const CValuePair &vp = mObj[arrIndex];
 	int val = vp._field0;
-	const MusicRoomInstrument &ins1 = _array1[index];
-	const MusicRoomInstrument &ins2 = _array2[index];
+	const MusicRoomInstrument &ins1 = _array1[instrument];
+	const MusicRoomInstrument &ins2 = _array2[instrument];
 
 	if (ins1._inversionControl != ins2._inversionControl) {
 		val -= mObj._minVal * 2 + mObj._range;
diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h
index 38c1748..ed87f33 100644
--- a/engines/titanic/sound/music_room_handler.h
+++ b/engines/titanic/sound/music_room_handler.h
@@ -71,10 +71,16 @@ private:
 
 	void updateAudio();
 	void fn1();
-	bool fn2(int index);
-	double fn3(int index, int arrIndex);
-	int getPitch(int index, int arrIndex);
 
+	/**
+	 * Updates the state of the instrument.
+	 * @returns Returns true if a given instrument is still active..
+	 * that is, that there is still more data that can be read from it to play
+	 */
+	bool updateInstrument(MusicInstrument instrument);
+
+	double fn3(MusicInstrument instrument, int arrIndex);
+	int getPitch(MusicInstrument instrument, int arrIndex);
 public:
 	CMusicRoomHandler(CProjectItem *project, CSoundManager *soundManager);
 	~CMusicRoomHandler();


Commit: b97137830a021a420d6b505a1c1ae9972106c10f
    https://github.com/scummvm/scummvm/commit/b97137830a021a420d6b505a1c1ae9972106c10f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-11T17:25:27-05:00

Commit Message:
TITANIC: Fix getPitch calculation when inversion control is incorrect

Changed paths:
    engines/titanic/sound/music_room_handler.cpp


diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index 7e23095..e50384e 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -332,7 +332,7 @@ int CMusicRoomHandler::getPitch(MusicInstrument instrument, int arrIndex) {
 	const MusicRoomInstrument &ins2 = _array2[instrument];
 
 	if (ins1._inversionControl != ins2._inversionControl) {
-		val -= mObj._minVal * 2 + mObj._range;
+		val = mObj._minVal * 2 + mObj._range - val;
 	}
 
 	val += ins1._pitchControl + ins2._pitchControl;


Commit: 58dbe629f369c4d4d3010b501cb909c251feb2ff
    https://github.com/scummvm/scummvm/commit/58dbe629f369c4d4d3010b501cb909c251feb2ff
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-11T17:25:28-05:00

Commit Message:
TITANIC: Fix intial setup of BASS pitch control

Changed paths:
    engines/titanic/sound/music_room.cpp


diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp
index c2e5b5e..a3752c5 100644
--- a/engines/titanic/sound/music_room.cpp
+++ b/engines/titanic/sound/music_room.cpp
@@ -62,7 +62,7 @@ void CMusicRoom::setupMusic(int volume) {
 		_musicHandler->setPitchControl2(BELLS, 1);
 		_musicHandler->setPitchControl2(SNAKE, 2);
 		_musicHandler->setPitchControl2(PIANO, 0);
-		_musicHandler->setPitchControl2(BELLS, 1);
+		_musicHandler->setPitchControl2(BASS, 1);
 
 		_musicHandler->setInversionControl2(BELLS, true);
 		_musicHandler->setInversionControl2(SNAKE, false);





More information about the Scummvm-git-logs mailing list