From 467967542b499767ea5b271d5c0bbb0431ee9fcf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Aug 2016 19:21:21 -0400 Subject: TITANIC: Further work on sound manager, fix extra enum comma --- engines/titanic/sound/proximity.cpp | 2 +- engines/titanic/sound/proximity.h | 2 +- engines/titanic/sound/qmixer.h | 2 +- engines/titanic/sound/sound_manager.cpp | 25 ++++++++++++++++++++++--- engines/titanic/sound/sound_manager.h | 9 +++++++-- 5 files changed, 32 insertions(+), 8 deletions(-) (limited to 'engines/titanic/sound') diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp index 4352e9fce8..dd1f9a4b7a 100644 --- a/engines/titanic/sound/proximity.cpp +++ b/engines/titanic/sound/proximity.cpp @@ -26,7 +26,7 @@ namespace Titanic { CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0), - _speechHandle(-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), + _soundHandle((uint)-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), _repeated(false), _field24(10), _field28(0), _azimuth(0.0), _range(0.5), _elevation(0), _posX(0.0), _posY(0.0), _posZ(0.0), _hasVelocity(false), _velocityX(0), _velocityY(0), _velocityZ(0), diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h index 71ea1682d0..afec3a7069 100644 --- a/engines/titanic/sound/proximity.h +++ b/engines/titanic/sound/proximity.h @@ -36,7 +36,7 @@ public: int _field4; int _channelVolume; int _fieldC; - int _speechHandle; + uint _soundHandle; int _field14; double _frequencyMultiplier; double _field1C; diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h index ca5f6f758d..948e91979b 100644 --- a/engines/titanic/sound/qmixer.h +++ b/engines/titanic/sound/qmixer.h @@ -38,7 +38,7 @@ enum QMixFlag { QMIX_ALL = 0x01, // apply to all channels QMIX_NOREMIX = 0x02, // don't remix QMIX_CONTROL_NOREMIX = 0x04, // don't remix - QMIX_USEONCE = 0x10, // settings are temporary + QMIX_USEONCE = 0x10 // settings are temporary }; // qsWaveMixEnableChannel flags: if mode==0, use conventional, high-performance diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index d06c18aba1..cb65a71631 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -117,8 +117,22 @@ int QSoundManager::proc5() const { return 0; } -int QSoundManager::playSound(CWaveFile &soundRes, CProximity &prox) { - warning("TODO"); +int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) { + int channel = -1; + uint flags = QMIX_CLEARQUEUE; + + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._handle == prox._soundHandle) { + channel = _slots[idx]._channel; + flags = QMIX_QUEUEWAVE; + break; + } + } + + if (channel >= 0 || (channel = flushChannels(prox._field24)) != -1) { + return playWave(&waveFile, channel, flags, prox); + } + return 0; } @@ -145,6 +159,11 @@ void QSoundManager::stopAllChannels() { flushChannels(10); } +int QSoundManager::flushChannels(int iChannel) { + // TODO + return -1; +} + void QSoundManager::setVolume(uint handle, uint volume, uint seconds) { for (uint idx = 0; idx < _slots.size(); ++idx) { Slot &slot = _slots[idx]; @@ -298,7 +317,7 @@ void QSoundManager::soundFreed(Audio::SoundHandle &handle) { qsWaveMixFreeWave(handle); } -void QSoundManager::flushChannels(int channel) { +void QSoundManager::stopChannels(int channel) { int endChannel; switch (channel) { case 0: diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h index ce9ef7f2d3..7ad5c8f51a 100644 --- a/engines/titanic/sound/sound_manager.h +++ b/engines/titanic/sound/sound_manager.h @@ -240,9 +240,9 @@ private: int _channelsMode[16]; private: /** - * Flushes designated channels + * Stops a designated range of channels */ - void flushChannels(int channel); + void stopChannels(int channel); /** * Updates the volume for a channel @@ -270,6 +270,11 @@ private: * Sets a channel volume */ void setChannelVolume(int iChannel, uint volume, uint mode); + + /** + * Flushes channels + */ + int flushChannels(int iChannel); public: int _field18; int _field1C; -- cgit v1.2.3