[Scummvm-git-logs] scummvm master -> 13648c8df5cbcea8f5cd4798b55324fc35bddd09

dreammaster dreammaster at scummvm.org
Fri Feb 3 03:38:17 CET 2017


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:
13648c8df5 TITANIC: Implemented CMusicRoomHandler setVolume


Commit: 13648c8df5cbcea8f5cd4798b55324fc35bddd09
    https://github.com/scummvm/scummvm/commit/13648c8df5cbcea8f5cd4798b55324fc35bddd09
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-02T21:38:11-05:00

Commit Message:
TITANIC: Implemented CMusicRoomHandler setVolume

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


diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index c827e94..50e3cdf 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -74,8 +74,29 @@ CMusicWave *CMusicRoomHandler::createMusicWave(MusicInstrument instrument, int c
 
 void CMusicRoomHandler::setVolume(int volume) {
 	_volume = volume;
-	// TODO
-//	_waveFile = _soundManager->loadMusic()
+	_audioBuffer->reset();
+
+	for (int idx = 0; idx < 4; ++idx) {
+		MusicRoomInstrument &ins1 = _array1[idx];
+		MusicRoomInstrument &ins2 = _array2[idx];
+
+		if (ins1._directionControl == ins2._directionControl) {
+			_array4[idx] = 0;
+		} else {
+			_array4[idx] = _array3[idx]->_field4;
+		}
+
+		_array6[idx] = _array4[idx];
+		_array5[idx].clear();
+	}
+
+	_field108 = 4;
+	_field118 = 1;
+	update();
+
+	_waveFile = _soundManager->loadMusic(_audioBuffer);
+	_audioBuffer->setC(_audioBuffer->getC());
+	update();
 }
 
 void CMusicRoomHandler::stop() {
diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h
index 869ce98..9102ad4 100644
--- a/engines/titanic/sound/music_room_handler.h
+++ b/engines/titanic/sound/music_room_handler.h
@@ -56,6 +56,8 @@ class CMusicRoomHandler {
 		int _v1;
 		int _v2;
 		Array5Entry() : _v1(0), _v2(0) {}
+
+		void clear() { _v1 = _v2 = 0; }
 	};
 private:
 	CProjectItem *_project;
@@ -95,7 +97,7 @@ public:
 	CMusicWave *createMusicWave(MusicInstrument instrument, int count);
 
 	/**
-	 * Sets the volume and ??? other stuff
+	 * TODO: Verify - this starts the given music?
 	 */
 	void setVolume(int volume);
 
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index a3cdae9..7c995c2 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -155,6 +155,18 @@ CWaveFile *QSoundManager::loadMusic(const CString &name) {
 	return waveFile;
 }
 
+CWaveFile *QSoundManager::loadMusic(CAudioBuffer *buffer) {
+	CWaveFile *waveFile = new CWaveFile();
+
+	// Try to load the specified audio buffer
+	if (!waveFile->loadMusic(buffer)) {
+		delete waveFile;
+		return nullptr;
+	}
+
+	return waveFile;
+}
+
 int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) {
 	int channel = -1;
 	uint flags = QMIX_CLEARQUEUE;
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index ff55634..1d522a7 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -25,6 +25,7 @@
 
 #include "titanic/core/list.h"
 #include "titanic/support/simple_file.h"
+#include "titanic/sound/audio_buffer.h"
 #include "titanic/sound/proximity.h"
 #include "titanic/sound/qmixer.h"
 #include "titanic/sound/wave_file.h"
@@ -64,13 +65,20 @@ public:
 	 * Loads a music file
 	 * @param name		Name of music resource
 	 * @returns			Loaded wave file
-	 * @remarks The original created a streaming audio buffer for the wave file,
-	 *		and passed this to the method. For ScummVM, this has been discarded
-	 *		in favor of simply passing the filename.
+	 * @remarks The original only classified music as what's produced in the
+	 * music room puzzle. For ScummVM, we've reclassified some wave files that
+	 * contain background music as music as well.
 	 */
 	virtual CWaveFile *loadMusic(const CString &name) { return nullptr; }
 
 	/**
+	 * Loads a music file from a streaming audio buffer
+	 * @param buffer	Audio buffer
+	 * @returns			Loaded wave file
+	 */
+	virtual CWaveFile *loadMusic(CAudioBuffer *buffer) { return nullptr; }
+
+	/**
 	 * Start playing a previously loaded wave file
 	 */
 	virtual int playSound(CWaveFile &waveFile, CProximity &prox) = 0;
@@ -333,13 +341,20 @@ public:
 	 * Loads a music file
 	 * @param name		Name of music resource
 	 * @returns			Loaded wave file
-	 * @remarks The original created a streaming audio buffer for the wave file,
-	 *		and passed this to the method. For ScummVM, this has been discarded
-	 *		in favor of simply passing the filename.
+	 * @remarks The original only classified music as what's produced in the
+	 * music room puzzle. For ScummVM, we've reclassified some wave files that
+	 * contain background music as music as well.
 	 */
 	virtual CWaveFile *loadMusic(const CString &name);
 
 	/**
+	 * Loads a music file from a streaming audio buffer
+	 * @param buffer	Audio buffer
+	 * @returns			Loaded wave file
+	 */
+	virtual CWaveFile *loadMusic(CAudioBuffer *buffer);
+
+	/**
 	 * Start playing a previously loaded sound resource
 	 */
 	virtual int playSound(CWaveFile &waveFile, CProximity &prox);
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index f2366d1..6112d36 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -102,6 +102,12 @@ bool CWaveFile::loadMusic(const CString &name) {
 	return true;
 }
 
+bool CWaveFile::loadMusic(CAudioBuffer *buffer) {
+	assert(!_stream && buffer);
+	warning("TODO: CWaveFile::loadMusic");
+	return false;
+}
+
 uint CWaveFile::getFrequency() const {
 	return _stream->getRate();
 }
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
index e4bb71a..c9a4c7d 100644
--- a/engines/titanic/sound/wave_file.h
+++ b/engines/titanic/sound/wave_file.h
@@ -25,6 +25,7 @@
 
 #include "audio/audiostream.h"
 #include "audio/mixer.h"
+#include "titanic/sound/audio_buffer.h"
 #include "titanic/support/string.h"
 #include "titanic/true_talk/dialogue_file.h"
 
@@ -73,6 +74,11 @@ public:
 	bool loadMusic(const CString &name);
 
 	/**
+	 * Tries to load the specified audio buffer
+	 */
+	bool loadMusic(CAudioBuffer *buffer);
+
+	/**
 	 * Returns true if the wave file has data loaded
 	 */
 	bool isLoaded() const { return _stream != nullptr; }





More information about the Scummvm-git-logs mailing list