aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-10 22:39:40 -0400
committerPaul Gilbert2016-08-10 22:39:40 -0400
commit2b486009f51bf386be3c9d97c22b7b17b0e898e8 (patch)
treed4cfc901d98b76ba955c41e442d45267e2a28666 /engines/titanic/sound
parent223aaaa185489fb39c3e163840efd7d2160c24aa (diff)
downloadscummvm-rg350-2b486009f51bf386be3c9d97c22b7b17b0e898e8.tar.gz
scummvm-rg350-2b486009f51bf386be3c9d97c22b7b17b0e898e8.tar.bz2
scummvm-rg350-2b486009f51bf386be3c9d97c22b7b17b0e898e8.zip
TITANIC: Beginnings of music handler
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r--engines/titanic/sound/music_handler.cpp25
-rw-r--r--engines/titanic/sound/music_handler.h1
-rw-r--r--engines/titanic/sound/music_wave.cpp18
-rw-r--r--engines/titanic/sound/music_wave.h23
-rw-r--r--engines/titanic/sound/sound_manager.cpp17
-rw-r--r--engines/titanic/sound/sound_manager.h44
6 files changed, 99 insertions, 29 deletions
diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp
index 41545347b8..9ef5ffaa5a 100644
--- a/engines/titanic/sound/music_handler.cpp
+++ b/engines/titanic/sound/music_handler.cpp
@@ -29,12 +29,29 @@ namespace Titanic {
CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) :
_project(project), _soundManager(soundManager),
_field124(0) {
-
+ Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr);
}
-CMusicWave *CMusicHandler::createMusicWave(int v1, int v2) {
- // TODO
- return nullptr;
+CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) {
+ switch (waveIndex) {
+ case 0:
+ _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 2);
+ break;
+ case 1:
+ _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 3);
+ break;
+ case 2:
+ _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 0);
+ break;
+ case 3:
+ _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 1);
+ break;
+ default:
+ return nullptr;
+ }
+
+ _musicWaves[waveIndex]->setSize(count);
+ return _musicWaves[waveIndex];
}
bool CMusicHandler::isBusy() {
diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h
index cab2ef8074..7b8ee035b6 100644
--- a/engines/titanic/sound/music_handler.h
+++ b/engines/titanic/sound/music_handler.h
@@ -34,6 +34,7 @@ class CMusicHandler {
private:
CProjectItem *_project;
CSoundManager *_soundManager;
+ CMusicWave *_musicWaves[4];
int _field124;
public:
CMusicHandler(CProjectItem *project, CSoundManager *soundManager);
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
index 348f3bdbd4..753098eb46 100644
--- a/engines/titanic/sound/music_wave.cpp
+++ b/engines/titanic/sound/music_wave.cpp
@@ -26,11 +26,25 @@
namespace Titanic {
-CMusicWave::CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index) {
+CMusicWave::CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index) :
+ _project(project), _soundManager(soundManager) {
+}
+
+void CMusicWave::setSize(uint count) {
+ assert(_items.empty());
+ _items.resize(count);
}
void CMusicWave::load(int index, const CString &filename, int v3) {
- // TODO
+ assert(!_items[index]._waveFile);
+ _items[index]._waveFile = createWaveFile(filename);
+ _items[index]._value = v3;
+}
+
+CWaveFile *CMusicWave::createWaveFile(const CString &name) {
+ if (name.empty())
+ return nullptr;
+ return _soundManager->loadSound(name);
}
} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h
index d40b2ce74d..dcdd3615fb 100644
--- a/engines/titanic/sound/music_wave.h
+++ b/engines/titanic/sound/music_wave.h
@@ -23,18 +23,41 @@
#ifndef TITANIC_MUSIC_WAVE_H
#define TITANIC_MUSIC_WAVE_H
+#include "common/array.h"
#include "titanic/support/string.h"
namespace Titanic {
class CProjectItem;
class CSoundManager;
+class CWaveFile;
class CMusicWave {
+ struct CMusicWaveFile {
+ CWaveFile *_waveFile;
+ int _value;
+ CMusicWaveFile() : _waveFile(nullptr), _value(0) {}
+ };
private:
+ CProjectItem *_project;
+ CSoundManager *_soundManager;
+ Common::Array<CMusicWaveFile> _items;
+private:
+ /**
+ * Loads the specified wave file, and returns a CWaveFile instance for it
+ */
+ CWaveFile *createWaveFile(const CString &name);
public:
CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index);
+ /**
+ * Sets the maximum number of allowed files that be defined
+ */
+ void setSize(uint count);
+
+ /**
+ * Loads a new file into the list of available entries
+ */
void load(int index, const CString &filename, int v3);
};
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index a8bd0dfbe9..6544f6bd2f 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -142,9 +142,8 @@ CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId)
return waveFile;
}
-int QSoundManager::proc5() const {
- error("TODO");
- return 0;
+CWaveFile *QSoundManager::loadMusic(const CString &name) {
+ return loadSound(name);
}
int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) {
@@ -170,7 +169,7 @@ int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) {
return 0;
}
-void QSoundManager::stopSound(uint handle) {
+void QSoundManager::stopSound(int handle) {
resetChannel(10);
for (uint idx = 0; idx < _slots.size(); ++idx) {
@@ -206,7 +205,7 @@ void QSoundManager::stopChannel(int channel) {
}
}
-void QSoundManager::setCanFree(uint handle) {
+void QSoundManager::setCanFree(int handle) {
for (uint idx = 0; idx < _slots.size(); ++idx) {
if (_slots[idx]._handle == handle)
_slots[idx]._isTimed = true;
@@ -260,7 +259,7 @@ int QSoundManager::resetChannel(int iChannel) {
return newChannel;
}
-void QSoundManager::setVolume(uint handle, uint volume, uint seconds) {
+void QSoundManager::setVolume(int handle, uint volume, uint seconds) {
for (uint idx = 0; idx < _slots.size(); ++idx) {
Slot &slot = _slots[idx];
if (slot._handle == handle) {
@@ -279,7 +278,7 @@ void QSoundManager::setVolume(uint handle, uint volume, uint seconds) {
}
}
-void QSoundManager::setVectorPosition(uint handle, double x, double y, double z, uint panRate) {
+void QSoundManager::setVectorPosition(int handle, double x, double y, double z, uint panRate) {
for (uint idx = 0; idx < _slots.size(); ++idx) {
Slot &slot = _slots[idx];
if (slot._handle == handle) {
@@ -290,7 +289,7 @@ void QSoundManager::setVectorPosition(uint handle, double x, double y, double z,
}
}
-void QSoundManager::setPolarPosition(uint handle, double range, double azimuth, double elevation, uint panRate) {
+void QSoundManager::setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate) {
for (uint idx = 0; idx < _slots.size(); ++idx) {
Slot &slot = _slots[idx];
if (slot._handle == handle) {
@@ -302,7 +301,7 @@ void QSoundManager::setPolarPosition(uint handle, double range, double azimuth,
}
}
-bool QSoundManager::isActive(uint handle) const {
+bool QSoundManager::isActive(int handle) const {
for (uint idx = 0; idx < _slots.size(); ++idx) {
if (_slots[idx]._handle == handle)
return true;
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index 2c9975ede4..594d7ec34f 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -60,7 +60,15 @@ public:
*/
virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId) { return 0; }
- virtual int proc5() const { return 0; }
+ /**
+ * 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.
+ */
+ virtual CWaveFile *loadMusic(const CString &name) { return nullptr; }
/**
* Start playing a previously loaded wave file
@@ -70,14 +78,14 @@ public:
/**
* Stop playing the specified sound
*/
- virtual void stopSound(uint handle) = 0;
+ virtual void stopSound(int handle) = 0;
/**
* Stops a designated range of channels
*/
virtual void stopChannel(int channel) = 0;
- virtual void proc9(uint handle) {}
+ virtual void proc9(int handle) {}
/**
* Stops sounds on all playing channels
@@ -90,7 +98,7 @@ public:
* @param volume New volume
* @param seconds Number of seconds to transition to the new volume
*/
- virtual void setVolume(uint handle, uint volume, uint seconds) = 0;
+ virtual void setVolume(int handle, uint volume, uint seconds) = 0;
/**
* Set the position for a sound
@@ -100,7 +108,7 @@ public:
* @param z z position in metres
* @param panRate Rate in milliseconds to transition
*/
- virtual void setVectorPosition(uint handle, double x, double y, double z, uint panRate) {}
+ virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate) {}
/**
* Set the position for a sound
@@ -110,12 +118,12 @@ public:
* @param elevation Elevation value in degrees
* @param panRate Rate in milliseconds to transition
*/
- virtual void setPolarPosition(uint handle, double range, double azimuth, double elevation, uint panRate) {}
+ virtual void setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate) {}
/**
* Returns true if the given sound is currently active
*/
- virtual bool isActive(uint handle) const = 0;
+ virtual bool isActive(int handle) const = 0;
/**
* Returns true if the given sound is currently active
@@ -320,7 +328,15 @@ public:
*/
virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
- virtual int proc5() const;
+ /**
+ * 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.
+ */
+ virtual CWaveFile *loadMusic(const CString &name);
/**
* Start playing a previously loaded sound resource
@@ -330,7 +346,7 @@ public:
/**
* Stop playing the specified sound
*/
- virtual void stopSound(uint handle);
+ virtual void stopSound(int handle);
/**
* Stops a designated range of channels
@@ -340,7 +356,7 @@ public:
/**
* Flags that a sound can be freed if a timeout is set
*/
- virtual void setCanFree(uint handle);
+ virtual void setCanFree(int handle);
/**
* Stops sounds on all playing channels
@@ -353,7 +369,7 @@ public:
* @param volume New volume
* @param seconds Number of seconds to transition to the new volume
*/
- virtual void setVolume(uint handle, uint volume, uint seconds);
+ virtual void setVolume(int handle, uint volume, uint seconds);
/**
* Set the position for a sound
@@ -363,7 +379,7 @@ public:
* @param z z position in metres
* @param panRate Rate in milliseconds to transition
*/
- virtual void setVectorPosition(uint handle, double x, double y, double z, uint panRate);
+ virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate);
/**
* Set the position for a sound
@@ -373,12 +389,12 @@ public:
* @param elevation Elevation value in degrees
* @param panRate Rate in milliseconds to transition
*/
- virtual void setPolarPosition(uint handle, double range, double azimuth, double elevation, uint panRate);
+ virtual void setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate);
/**
* Returns true if the given sound is currently active
*/
- virtual bool isActive(uint handle) const;
+ virtual bool isActive(int handle) const;
/**
* Returns true if the given sound is currently active