Skip to content

Commit

Permalink
TITANIC: Further work on sound manager, fix extra enum comma
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 6, 2016
1 parent 7b5b06f commit 4679675
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/sound/proximity.cpp
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/sound/proximity.h
Expand Up @@ -36,7 +36,7 @@ class CProximity {
int _field4;
int _channelVolume;
int _fieldC;
int _speechHandle;
uint _soundHandle;
int _field14;
double _frequencyMultiplier;
double _field1C;
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/sound/qmixer.h
Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions engines/titanic/sound/sound_manager.cpp
Expand Up @@ -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;
}

Expand All @@ -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];
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions engines/titanic/sound/sound_manager.h
Expand Up @@ -240,9 +240,9 @@ class QSoundManager : public CSoundManager, public QMixer {
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
Expand Down Expand Up @@ -270,6 +270,11 @@ class QSoundManager : public CSoundManager, public QMixer {
* Sets a channel volume
*/
void setChannelVolume(int iChannel, uint volume, uint mode);

/**
* Flushes channels
*/
int flushChannels(int iChannel);
public:
int _field18;
int _field1C;
Expand Down
6 changes: 3 additions & 3 deletions engines/titanic/true_talk/true_talk_manager.cpp
Expand Up @@ -535,18 +535,18 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV
}

// Start the speech
p1._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1);
p1._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1);
if (!milli)
continue;

if (idx == 0)
g_vm->_events->sleep(milli);

p3._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3);
p3._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3);
if (idx == 0)
g_vm->_events->sleep(milli);

p2._speechHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2);
p2._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2);
}
}

Expand Down

0 comments on commit 4679675

Please sign in to comment.