aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-02-02 21:38:11 -0500
committerPaul Gilbert2017-02-02 21:38:11 -0500
commit13648c8df5cbcea8f5cd4798b55324fc35bddd09 (patch)
tree32c4ba938c7577e7d17cc01e40859fa4c43d6e56 /engines
parente1e93fa9c025bc39cf05fd8cf4a232c846a813da (diff)
downloadscummvm-rg350-13648c8df5cbcea8f5cd4798b55324fc35bddd09.tar.gz
scummvm-rg350-13648c8df5cbcea8f5cd4798b55324fc35bddd09.tar.bz2
scummvm-rg350-13648c8df5cbcea8f5cd4798b55324fc35bddd09.zip
TITANIC: Implemented CMusicRoomHandler setVolume
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/sound/music_room_handler.cpp25
-rw-r--r--engines/titanic/sound/music_room_handler.h4
-rw-r--r--engines/titanic/sound/sound_manager.cpp12
-rw-r--r--engines/titanic/sound/sound_manager.h27
-rw-r--r--engines/titanic/sound/wave_file.cpp6
-rw-r--r--engines/titanic/sound/wave_file.h6
6 files changed, 71 insertions, 9 deletions
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index c827e94955..50e3cdf5f2 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 869ce98bb1..9102ad4243 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 a3cdae9635..7c995c29f7 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 ff556346de..1d522a7edf 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 f2366d1dd5..6112d36fa9 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 e4bb71a0b6..c9a4c7d323 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; }