aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r--engines/titanic/sound/auto_music_player.cpp75
-rw-r--r--engines/titanic/sound/auto_music_player.h54
-rw-r--r--engines/titanic/sound/auto_music_player_base.cpp101
-rw-r--r--engines/titanic/sound/auto_music_player_base.h59
-rw-r--r--engines/titanic/sound/auto_sound_player.cpp134
-rw-r--r--engines/titanic/sound/auto_sound_player.h65
-rw-r--r--engines/titanic/sound/auto_sound_player_adsr.cpp79
-rw-r--r--engines/titanic/sound/auto_sound_player_adsr.h54
-rw-r--r--engines/titanic/sound/background_sound_maker.cpp47
-rw-r--r--engines/titanic/sound/background_sound_maker.h52
-rw-r--r--engines/titanic/sound/bird_song.cpp56
-rw-r--r--engines/titanic/sound/bird_song.h53
-rw-r--r--engines/titanic/sound/dome_from_top_of_well.cpp47
-rw-r--r--engines/titanic/sound/dome_from_top_of_well.h49
-rw-r--r--engines/titanic/sound/enter_view_toggles_other_music.cpp60
-rw-r--r--engines/titanic/sound/enter_view_toggles_other_music.h52
-rw-r--r--engines/titanic/sound/gondolier_song.cpp94
-rw-r--r--engines/titanic/sound/gondolier_song.h56
-rw-r--r--engines/titanic/sound/music_handler.cpp85
-rw-r--r--engines/titanic/sound/music_handler.h72
-rw-r--r--engines/titanic/sound/music_player.cpp182
-rw-r--r--engines/titanic/sound/music_player.h64
-rw-r--r--engines/titanic/sound/music_room.cpp64
-rw-r--r--engines/titanic/sound/music_room.h86
-rw-r--r--engines/titanic/sound/music_wave.cpp54
-rw-r--r--engines/titanic/sound/music_wave.h71
-rw-r--r--engines/titanic/sound/node_auto_sound_player.cpp84
-rw-r--r--engines/titanic/sound/node_auto_sound_player.h54
-rw-r--r--engines/titanic/sound/proximity.cpp37
-rw-r--r--engines/titanic/sound/proximity.h71
-rw-r--r--engines/titanic/sound/qmixer.cpp173
-rw-r--r--engines/titanic/sound/qmixer.h312
-rw-r--r--engines/titanic/sound/restricted_auto_music_player.cpp79
-rw-r--r--engines/titanic/sound/restricted_auto_music_player.h56
-rw-r--r--engines/titanic/sound/room_auto_sound_player.cpp62
-rw-r--r--engines/titanic/sound/room_auto_sound_player.h51
-rw-r--r--engines/titanic/sound/room_trigger_auto_music_player.cpp62
-rw-r--r--engines/titanic/sound/room_trigger_auto_music_player.h51
-rw-r--r--engines/titanic/sound/season_noises.cpp115
-rw-r--r--engines/titanic/sound/season_noises.h59
-rw-r--r--engines/titanic/sound/seasonal_music_player.cpp135
-rw-r--r--engines/titanic/sound/seasonal_music_player.h61
-rw-r--r--engines/titanic/sound/sound.cpp223
-rw-r--r--engines/titanic/sound/sound.h190
-rw-r--r--engines/titanic/sound/sound_manager.cpp481
-rw-r--r--engines/titanic/sound/sound_manager.h454
-rw-r--r--engines/titanic/sound/titania_speech.cpp157
-rw-r--r--engines/titanic/sound/titania_speech.h57
-rw-r--r--engines/titanic/sound/trigger_auto_music_player.cpp61
-rw-r--r--engines/titanic/sound/trigger_auto_music_player.h51
-rw-r--r--engines/titanic/sound/view_auto_sound_player.cpp84
-rw-r--r--engines/titanic/sound/view_auto_sound_player.h53
-rw-r--r--engines/titanic/sound/view_toggles_other_music.cpp58
-rw-r--r--engines/titanic/sound/view_toggles_other_music.h52
-rw-r--r--engines/titanic/sound/water_lapping_sounds.cpp56
-rw-r--r--engines/titanic/sound/water_lapping_sounds.h51
-rw-r--r--engines/titanic/sound/wave_file.cpp101
-rw-r--r--engines/titanic/sound/wave_file.h83
58 files changed, 5539 insertions, 0 deletions
diff --git a/engines/titanic/sound/auto_music_player.cpp b/engines/titanic/sound/auto_music_player.cpp
new file mode 100644
index 0000000000..ce20c33765
--- /dev/null
+++ b/engines/titanic/sound/auto_music_player.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/auto_music_player.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CAutoMusicPlayer, CAutoMusicPlayerBase)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+END_MESSAGE_MAP()
+
+CAutoMusicPlayer::CAutoMusicPlayer() : CAutoMusicPlayerBase() {
+}
+
+void CAutoMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_leaveRoomSound, indent);
+
+ CAutoMusicPlayerBase::save(file, indent);
+}
+
+void CAutoMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _leaveRoomSound = file->readString();
+
+ CAutoMusicPlayerBase::load(file);
+}
+
+bool CAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
+ if (!_isRepeated) {
+ CRoomItem *room = findRoom();
+ if (msg->_newRoom == room)
+ addTimer(2000);
+ }
+
+ return true;
+}
+
+bool CAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ if (_isRepeated) {
+ CRoomItem *room = findRoom();
+ if (msg->_oldRoom == room) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 1;
+ changeMsg.execute(this);
+ }
+ }
+
+ if (!_leaveRoomSound.empty())
+ playSound(_leaveRoomSound);
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/auto_music_player.h b/engines/titanic/sound/auto_music_player.h
new file mode 100644
index 0000000000..722aa9cd7f
--- /dev/null
+++ b/engines/titanic/sound/auto_music_player.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_AUTO_MUSIC_PLAYER_H
+#define TITANIC_AUTO_MUSIC_PLAYER_H
+
+#include "titanic/sound/auto_music_player_base.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CAutoMusicPlayer : public CAutoMusicPlayerBase {
+ DECLARE_MESSAGE_MAP;
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+private:
+ CString _leaveRoomSound;
+public:
+ CLASSDEF;
+ CAutoMusicPlayer();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_AUTO_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/auto_music_player_base.cpp b/engines/titanic/sound/auto_music_player_base.cpp
new file mode 100644
index 0000000000..ad8b848c03
--- /dev/null
+++ b/engines/titanic/sound/auto_music_player_base.cpp
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/auto_music_player_base.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CAutoMusicPlayerBase, CGameObject)
+ ON_MESSAGE(StatusChangeMsg)
+ ON_MESSAGE(TimerMsg)
+ ON_MESSAGE(LoadSuccessMsg)
+ ON_MESSAGE(ChangeMusicMsg)
+END_MESSAGE_MAP()
+
+CAutoMusicPlayerBase::CAutoMusicPlayerBase() : CGameObject(),
+ _initialMute(true), _isRepeated(false), _volumeMode(-1), _transition(1) {
+}
+void CAutoMusicPlayerBase::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_filename, indent);
+ file->writeNumberLine(_initialMute, indent);
+ file->writeNumberLine(_isRepeated, indent);
+ file->writeNumberLine(_volumeMode, indent);
+ file->writeNumberLine(_transition, indent);
+
+ CGameObject::save(file, indent);
+}
+
+void CAutoMusicPlayerBase::load(SimpleFile *file) {
+ file->readNumber();
+ _filename = file->readString();
+ _initialMute = file->readNumber();
+ _isRepeated = file->readNumber();
+ _volumeMode = file->readNumber();
+ _transition = file->readNumber();
+
+ CGameObject::load(file);
+}
+
+bool CAutoMusicPlayerBase::StatusChangeMsg(CStatusChangeMsg *msg) {
+ return true;
+}
+
+bool CAutoMusicPlayerBase::TimerMsg(CTimerMsg *msg) {
+ CChangeMusicMsg musicMsg;
+ musicMsg._flags = 2;
+ musicMsg.execute(this);
+
+ return true;
+}
+
+bool CAutoMusicPlayerBase::LoadSuccessMsg(CLoadSuccessMsg *msg) {
+ if (_isRepeated)
+ playGlobalSound(_filename, _volumeMode, _initialMute, true, 0);
+
+ return true;
+}
+
+bool CAutoMusicPlayerBase::ChangeMusicMsg(CChangeMusicMsg *msg) {
+ if (_isRepeated && msg->_flags == 1) {
+ _isRepeated = false;
+ stopGlobalSound(_transition, -1);
+ }
+
+ if (!msg->_filename.empty()) {
+ _filename = msg->_filename;
+
+ if (_isRepeated) {
+ stopGlobalSound(_transition, -1);
+ playGlobalSound(_filename, _volumeMode, _initialMute, true, 0);
+ }
+ }
+
+ if (_isRepeated && msg->_flags == 2) {
+ _isRepeated = true;
+ playGlobalSound(_filename, _volumeMode, _initialMute, true, 0);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/auto_music_player_base.h b/engines/titanic/sound/auto_music_player_base.h
new file mode 100644
index 0000000000..0623258887
--- /dev/null
+++ b/engines/titanic/sound/auto_music_player_base.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_AUTO_MUSIC_PLAYER_BASE_H
+#define TITANIC_AUTO_MUSIC_PLAYER_BASE_H
+
+#include "titanic/core/game_object.h"
+
+namespace Titanic {
+
+class CAutoMusicPlayerBase : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool StatusChangeMsg(CStatusChangeMsg *msg);
+ bool TimerMsg(CTimerMsg *msg);
+ bool LoadSuccessMsg(CLoadSuccessMsg *msg);
+ bool ChangeMusicMsg(CChangeMusicMsg *msg);
+protected:
+ CString _filename;
+ bool _initialMute;
+ bool _isRepeated;
+ int _volumeMode;
+ int _transition;
+public:
+ CLASSDEF;
+ CAutoMusicPlayerBase();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_AUTO_MUSIC_PLAYER_BASE_H */
diff --git a/engines/titanic/sound/auto_sound_player.cpp b/engines/titanic/sound/auto_sound_player.cpp
new file mode 100644
index 0000000000..8267d65037
--- /dev/null
+++ b/engines/titanic/sound/auto_sound_player.cpp
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/auto_sound_player.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CAutoSoundPlayer, CGameObject)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(TurnOff)
+ ON_MESSAGE(SignalObject)
+ ON_MESSAGE(SetVolumeMsg)
+ ON_MESSAGE(LoadSuccessMsg)
+END_MESSAGE_MAP()
+
+CAutoSoundPlayer::CAutoSoundPlayer() : CGameObject(),
+ _fieldBC(0), _volume(70), _fieldD0(0), _repeated(false), _soundHandle(-1),
+ _stopSeconds(0), _startSeconds(-1), _active(false), _fieldE8(0) {
+}
+
+void CAutoSoundPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_fieldBC, indent);
+ file->writeQuotedLine(_filename, indent);
+ file->writeNumberLine(_volume, indent);
+ file->writeNumberLine(_fieldD0, indent);
+ file->writeNumberLine(_repeated, indent);
+ file->writeNumberLine(_soundHandle, indent);
+ file->writeNumberLine(_stopSeconds, indent);
+ file->writeNumberLine(_startSeconds, indent);
+ file->writeNumberLine(_active, indent);
+ file->writeNumberLine(_fieldE8, indent);
+
+ CGameObject::save(file, indent);
+}
+
+void CAutoSoundPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _fieldBC = file->readNumber();
+ _filename = file->readString();
+ _volume = file->readNumber();
+ _fieldD0 = file->readNumber();
+ _repeated = file->readNumber();
+ _soundHandle = file->readNumber();
+ _stopSeconds = file->readNumber();
+ _startSeconds = file->readNumber();
+ _active = file->readNumber();
+ _fieldE8 = file->readNumber();
+
+ CGameObject::load(file);
+}
+
+bool CAutoSoundPlayer::TurnOn(CTurnOn *msg) {
+ if (_soundHandle == -1) {
+ CProximity prox;
+ prox._fieldC = _fieldD0;
+ prox._repeated = _repeated;
+ if (_fieldE8)
+ prox._positioningMode = POSMODE_VECTOR;
+ prox._channelVolume = (_startSeconds == -1) ? _volume : 0;
+
+ _soundHandle = playSound(_filename, prox);
+ if (_startSeconds != -1)
+ setSoundVolume(_soundHandle, _volume, _startSeconds);
+
+ _active = true;
+ }
+
+ return true;
+}
+
+bool CAutoSoundPlayer::TurnOff(CTurnOff *msg) {
+ if (_soundHandle != -1) {
+ if (isSoundActive(_soundHandle))
+ stopSound(_soundHandle, _stopSeconds);
+
+ _soundHandle = -1;
+ _active = false;
+ }
+
+ return true;
+}
+
+bool CAutoSoundPlayer::SignalObject(CSignalObject *msg) {
+ if (_soundHandle != -1) {
+ if (isSoundActive(_soundHandle))
+ stopSound(_soundHandle, msg->_numValue);
+
+ _soundHandle = -1;
+ _active = false;
+ }
+
+ return true;
+}
+
+bool CAutoSoundPlayer::SetVolumeMsg(CSetVolumeMsg *msg) {
+ if (_soundHandle != -1 && isSoundActive(_soundHandle))
+ setSoundVolume(_soundHandle, msg->_volume, msg->_secondsTransition);
+
+ return true;
+}
+
+bool CAutoSoundPlayer::LoadSuccessMsg(CLoadSuccessMsg *msg) {
+ if (_active) {
+ _soundHandle = -1;
+ _active = false;
+
+ CTurnOn onMsg;
+ onMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/auto_sound_player.h b/engines/titanic/sound/auto_sound_player.h
new file mode 100644
index 0000000000..c8f1d3480e
--- /dev/null
+++ b/engines/titanic/sound/auto_sound_player.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_AUTO_SOUND_PLAYER_H
+#define TITANIC_AUTO_SOUND_PLAYER_H
+
+#include "titanic/core/game_object.h"
+
+namespace Titanic {
+
+class CAutoSoundPlayer : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool TurnOff(CTurnOff *msg);
+ bool SignalObject(CSignalObject *msg);
+ bool SetVolumeMsg(CSetVolumeMsg *msg);
+ bool LoadSuccessMsg(CLoadSuccessMsg *msg);
+public:
+ int _fieldBC;
+ CString _filename;
+ int _volume;
+ int _fieldD0;
+ bool _repeated;
+ int _soundHandle;
+ int _stopSeconds;
+ int _startSeconds;
+ bool _active;
+ int _fieldE8;
+public:
+ CLASSDEF;
+ CAutoSoundPlayer();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_AUTO_SOUND_PLAYER_H */
diff --git a/engines/titanic/sound/auto_sound_player_adsr.cpp b/engines/titanic/sound/auto_sound_player_adsr.cpp
new file mode 100644
index 0000000000..f9f045759b
--- /dev/null
+++ b/engines/titanic/sound/auto_sound_player_adsr.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/auto_sound_player_adsr.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CAutoSoundPlayerADSR, CAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(TurnOff)
+END_MESSAGE_MAP()
+
+void CAutoSoundPlayerADSR::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_soundName1, indent);
+ file->writeQuotedLine(_soundName2, indent);
+ file->writeQuotedLine(_soundName3, indent);
+ CAutoSoundPlayer::save(file, indent);
+}
+
+void CAutoSoundPlayerADSR::load(SimpleFile *file) {
+ file->readNumber();
+ _soundName1 = file->readString();
+ _soundName2 = file->readString();
+ _soundName3 = file->readString();
+ CAutoSoundPlayer::load(file);
+}
+
+bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) {
+ if (_soundHandle == -1) {
+ if (!_soundName1.empty()) {
+ _soundHandle = playSound(_soundName1, _volume, _fieldD0);
+
+ if (!_soundName2.empty())
+ _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _fieldD0);
+
+ _soundHandle = queueSound(_filename, _soundHandle, _volume, _fieldD0);
+ _active = true;
+ }
+ }
+
+ return true;
+}
+
+bool CAutoSoundPlayerADSR::TurnOff(CTurnOff *msg) {
+ if (_soundHandle != -1) {
+ if (!_soundName3.empty())
+ queueSound(_soundName3, _soundHandle, _volume, _fieldD0);
+
+ if (isSoundActive(_soundHandle))
+ stopSound(_soundHandle);
+
+ _soundHandle = -1;
+ _active = false;
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/auto_sound_player_adsr.h b/engines/titanic/sound/auto_sound_player_adsr.h
new file mode 100644
index 0000000000..9f09636610
--- /dev/null
+++ b/engines/titanic/sound/auto_sound_player_adsr.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_AUTO_SOUND_PLAYER_ADSR_H
+#define TITANIC_AUTO_SOUND_PLAYER_ADSR_H
+
+#include "titanic/sound/auto_sound_player.h"
+
+namespace Titanic {
+
+class CAutoSoundPlayerADSR : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool TurnOff(CTurnOff *msg);
+private:
+ CString _soundName1;
+ CString _soundName2;
+ CString _soundName3;
+public:
+ CLASSDEF;
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_AUTO_SOUND_PLAYER_ADSR_H */
diff --git a/engines/titanic/sound/background_sound_maker.cpp b/engines/titanic/sound/background_sound_maker.cpp
new file mode 100644
index 0000000000..58dde02518
--- /dev/null
+++ b/engines/titanic/sound/background_sound_maker.cpp
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/background_sound_maker.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CBackgroundSoundMaker, CGameObject)
+ ON_MESSAGE(FrameMsg)
+END_MESSAGE_MAP()
+
+void CBackgroundSoundMaker::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_value, indent);
+ CGameObject::save(file, indent);
+}
+
+void CBackgroundSoundMaker::load(SimpleFile *file) {
+ file->readNumber();
+ _value = file->readNumber();
+ CGameObject::load(file);
+}
+
+bool CBackgroundSoundMaker::FrameMsg(CFrameMsg *msg) {
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/background_sound_maker.h b/engines/titanic/sound/background_sound_maker.h
new file mode 100644
index 0000000000..94f3b792dc
--- /dev/null
+++ b/engines/titanic/sound/background_sound_maker.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_BACKGROUND_SOUND_MAKER_H
+#define TITANIC_BACKGROUND_SOUND_MAKER_H
+
+#include "titanic/core/game_object.h"
+
+namespace Titanic {
+
+class CBackgroundSoundMaker : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool FrameMsg(CFrameMsg *msg);
+public:
+ int _value;
+public:
+ CLASSDEF;
+ CBackgroundSoundMaker() : CGameObject(), _value(0) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_BACKGROUND_SOUND_MAKER_H */
diff --git a/engines/titanic/sound/bird_song.cpp b/engines/titanic/sound/bird_song.cpp
new file mode 100644
index 0000000000..53a25e2dbe
--- /dev/null
+++ b/engines/titanic/sound/bird_song.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/bird_song.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CBirdSong, CAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(SignalObject)
+END_MESSAGE_MAP()
+
+void CBirdSong::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_flag, indent);
+ CRoomAutoSoundPlayer::save(file, indent);
+}
+
+void CBirdSong::load(SimpleFile *file) {
+ file->readNumber();
+ _flag = file->readNumber();
+ CRoomAutoSoundPlayer::load(file);
+}
+
+bool CBirdSong::TurnOn(CTurnOn *msg) {
+ if (!_flag)
+ CAutoSoundPlayer::TurnOn(msg);
+ return true;
+}
+
+bool CBirdSong::SignalObject(CSignalObject *msg) {
+ _flag = true;
+ CAutoSoundPlayer::SignalObject(msg);
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/bird_song.h b/engines/titanic/sound/bird_song.h
new file mode 100644
index 0000000000..52af94b180
--- /dev/null
+++ b/engines/titanic/sound/bird_song.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_BIRD_SONG_H
+#define TITANIC_BIRD_SONG_H
+
+#include "titanic/sound/room_auto_sound_player.h"
+
+namespace Titanic {
+
+class CBirdSong : public CRoomAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool SignalObject(CSignalObject *msg);
+public:
+ bool _flag;
+public:
+ CLASSDEF;
+ CBirdSong() : CRoomAutoSoundPlayer(), _flag(false) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_BIRD_SONG_H */
diff --git a/engines/titanic/sound/dome_from_top_of_well.cpp b/engines/titanic/sound/dome_from_top_of_well.cpp
new file mode 100644
index 0000000000..789d7fa4cb
--- /dev/null
+++ b/engines/titanic/sound/dome_from_top_of_well.cpp
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/dome_from_top_of_well.h"
+
+namespace Titanic {
+
+EMPTY_MESSAGE_MAP(CDomeFromTopOfWell, CViewAutoSoundPlayer);
+
+CDomeFromTopOfWell::CDomeFromTopOfWell() : CViewAutoSoundPlayer() {
+ _filename = "z#227.wav";
+ _volume = 25;
+ _repeated = true;
+ _stopSeconds = 1;
+ _startSeconds = 1;
+}
+
+void CDomeFromTopOfWell::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ CViewAutoSoundPlayer::save(file, indent);
+}
+
+void CDomeFromTopOfWell::load(SimpleFile *file) {
+ file->readNumber();
+ CViewAutoSoundPlayer::load(file);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/dome_from_top_of_well.h b/engines/titanic/sound/dome_from_top_of_well.h
new file mode 100644
index 0000000000..001f66a1a8
--- /dev/null
+++ b/engines/titanic/sound/dome_from_top_of_well.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_DOME_FROM_TOP_OF_WELL_H
+#define TITANIC_DOME_FROM_TOP_OF_WELL_H
+
+#include "titanic/sound/view_auto_sound_player.h"
+
+namespace Titanic {
+
+class CDomeFromTopOfWell : public CViewAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+public:
+ CLASSDEF;
+ CDomeFromTopOfWell();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_DOME_FROM_TOP_OF_WELL_H */
diff --git a/engines/titanic/sound/enter_view_toggles_other_music.cpp b/engines/titanic/sound/enter_view_toggles_other_music.cpp
new file mode 100644
index 0000000000..2f0091a0a3
--- /dev/null
+++ b/engines/titanic/sound/enter_view_toggles_other_music.cpp
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/enter_view_toggles_other_music.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CEnterViewTogglesOtherMusic, CTriggerAutoMusicPlayer)
+ ON_MESSAGE(EnterViewMsg)
+END_MESSAGE_MAP()
+
+CEnterViewTogglesOtherMusic::CEnterViewTogglesOtherMusic() :
+ CTriggerAutoMusicPlayer(), _value(2) {
+}
+
+void CEnterViewTogglesOtherMusic::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_value, indent);
+
+ CTriggerAutoMusicPlayer::save(file, indent);
+}
+
+void CEnterViewTogglesOtherMusic::load(SimpleFile *file) {
+ file->readNumber();
+ _value = file->readNumber();
+
+ CTriggerAutoMusicPlayer::load(file);
+}
+
+bool CEnterViewTogglesOtherMusic::EnterViewMsg(CEnterViewMsg *msg) {
+ CViewItem *view = findView();
+ if (view == msg->_newView) {
+ CTriggerAutoMusicPlayerMsg triggerMsg;
+ triggerMsg._value = _value;
+ triggerMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/enter_view_toggles_other_music.h b/engines/titanic/sound/enter_view_toggles_other_music.h
new file mode 100644
index 0000000000..a91b1e1933
--- /dev/null
+++ b/engines/titanic/sound/enter_view_toggles_other_music.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H
+#define TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H
+
+#include "titanic/sound/trigger_auto_music_player.h"
+
+namespace Titanic {
+
+class CEnterViewTogglesOtherMusic : public CTriggerAutoMusicPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterViewMsg(CEnterViewMsg *msg);
+protected:
+ int _value;
+public:
+ CLASSDEF;
+ CEnterViewTogglesOtherMusic();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H */
diff --git a/engines/titanic/sound/gondolier_song.cpp b/engines/titanic/sound/gondolier_song.cpp
new file mode 100644
index 0000000000..5c96718723
--- /dev/null
+++ b/engines/titanic/sound/gondolier_song.cpp
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "titanic/sound/gondolier_song.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CGondolierSong, CRoomAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(SignalObject)
+ ON_MESSAGE(SetVolumeMsg)
+ ON_MESSAGE(StatusChangeMsg)
+END_MESSAGE_MAP()
+
+void CGondolierSong::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(_enabled, indent);
+ file->writeNumberLine(_value, indent);
+ CRoomAutoSoundPlayer::save(file, indent);
+}
+
+void CGondolierSong::load(SimpleFile *file) {
+ _enabled = file->readNumber();
+ _value = file->readNumber();
+ CRoomAutoSoundPlayer::load(file);
+}
+
+bool CGondolierSong::TurnOn(CTurnOn *msg) {
+ if (_enabled) {
+ if (_soundHandle != -1) {
+ int volume = _value * _volume / 100;
+
+ if (_startSeconds == -1) {
+ _soundHandle = playSound(_filename, volume, _fieldD0, _repeated);
+ } else {
+ _soundHandle = playSound(_filename, 0, _fieldD0, _repeated);
+ setSoundVolume(_soundHandle, _volume, _startSeconds);
+ }
+
+ _active = true;
+ }
+ }
+
+ return true;
+}
+
+bool CGondolierSong::SignalObject(CSignalObject *msg) {
+ _enabled = false;
+ CAutoSoundPlayer::SignalObject(msg);
+ return true;
+}
+
+bool CGondolierSong::SetVolumeMsg(CSetVolumeMsg *msg) {
+ if (_enabled) {
+ _volume = msg->_volume;
+
+ if (_soundHandle != -1 && isSoundActive(_soundHandle)) {
+ int newVolume = _value * _volume / 100;
+ setSoundVolume(_soundHandle, newVolume, msg->_secondsTransition);
+ }
+ }
+
+ return true;
+}
+
+bool CGondolierSong::StatusChangeMsg(CStatusChangeMsg *msg) {
+ if (_enabled) {
+ _value = CLIP(msg->_newStatus, 0, 100);
+ CSetVolumeMsg volumeMsg(_volume, _stopSeconds);
+ volumeMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/gondolier_song.h b/engines/titanic/sound/gondolier_song.h
new file mode 100644
index 0000000000..d586711de9
--- /dev/null
+++ b/engines/titanic/sound/gondolier_song.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_GONDOLIER_SONG_H
+#define TITANIC_GONDOLIER_SONG_H
+
+#include "titanic/sound/room_auto_sound_player.h"
+
+namespace Titanic {
+
+class CGondolierSong : public CRoomAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool SignalObject(CSignalObject *msg);
+ bool SetVolumeMsg(CSetVolumeMsg *msg);
+ bool StatusChangeMsg(CStatusChangeMsg *msg);
+public:
+ bool _enabled;
+ int _value;
+public:
+ CLASSDEF;
+ CGondolierSong() : CRoomAutoSoundPlayer(), _enabled(true), _value(0) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_GONDOLIER_SONG_H */
diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp
new file mode 100644
index 0000000000..07c3994334
--- /dev/null
+++ b/engines/titanic/sound/music_handler.cpp
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/music_handler.h"
+#include "titanic/sound/sound_manager.h"
+#include "titanic/core/project_item.h"
+
+namespace Titanic {
+
+CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) :
+ _project(project), _soundManager(soundManager), _stopWaves(false),
+ _soundHandle(-1), _waveFile(nullptr) {
+ Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr);
+}
+
+CMusicHandler::~CMusicHandler() {
+ stop();
+}
+
+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() {
+ // TODO
+ return false;
+}
+
+void CMusicHandler::stop() {
+ if (_waveFile) {
+ _soundManager->stopSound(_soundHandle);
+ delete _waveFile;
+ _waveFile = nullptr;
+ _soundHandle = -1;
+ }
+
+ for (int idx = 0; idx < 4; ++idx) {
+ if (_stopWaves && _musicWaves[idx])
+ _musicWaves[idx]->stop();
+ }
+}
+
+bool CMusicHandler::checkSound(int index) const {
+ // TODO
+ return false;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h
new file mode 100644
index 0000000000..6792844cb5
--- /dev/null
+++ b/engines/titanic/sound/music_handler.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_MUSIC_HANDLER_H
+#define TITANIC_MUSIC_HANDLER_H
+
+#include "titanic/sound/music_wave.h"
+#include "titanic/sound/wave_file.h"
+
+namespace Titanic {
+
+class CProjectItem;
+class CSoundManager;
+
+class CMusicHandler {
+private:
+ CProjectItem *_project;
+ CSoundManager *_soundManager;
+ CMusicWave *_musicWaves[4];
+ bool _stopWaves;
+ CWaveFile *_waveFile;
+ int _soundHandle;
+public:
+ CMusicHandler(CProjectItem *project, CSoundManager *soundManager);
+ ~CMusicHandler();
+
+ /**
+ * Creates a new music wave class instance, and assigns it to a slot
+ * in the music handler
+ * @param waveIndex Slot to save new instance in
+ * @param count Number of files the new instance will contain
+ */
+ CMusicWave *createMusicWave(int waveIndex, int count);
+
+ bool isBusy();
+
+ /**
+ * Flags whether the loaded music waves will be stopped when the
+ * music handler is stopped
+ */
+ void setStopWaves(bool flag) { _stopWaves = flag; }
+
+ /**
+ * Stop playing the music
+ */
+ void stop();
+
+ bool checkSound(int index) const;
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MUSIC_HANDLER_H */
diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp
new file mode 100644
index 0000000000..cd764c7f93
--- /dev/null
+++ b/engines/titanic/sound/music_player.cpp
@@ -0,0 +1,182 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/music_player.h"
+#include "titanic/sound/music_room.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CMusicPlayer, CGameObject)
+ ON_MESSAGE(StartMusicMsg)
+ ON_MESSAGE(StopMusicMsg)
+ ON_MESSAGE(FrameMsg)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+ ON_MESSAGE(CreateMusicPlayerMsg)
+ ON_MESSAGE(LoadSuccessMsg)
+END_MESSAGE_MAP()
+
+void CMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_isActive, indent);
+ file->writeQuotedLine(_stopTarget, indent);
+ file->writeNumberLine(_stopWaves, indent);
+ file->writeNumberLine(_musicId, indent);
+
+ CGameObject::save(file, indent);
+}
+
+void CMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _isActive = file->readNumber();
+ _stopTarget = file->readString();
+ _stopWaves = file->readNumber();
+ _musicId = file->readNumber();
+
+ CGameObject::load(file);
+}
+
+bool CMusicPlayer::StartMusicMsg(CStartMusicMsg *msg) {
+ if (msg->_musicPlayer == this) {
+ if (_isActive) {
+ CStopMusicMsg stopMusicMsg;
+ stopMusicMsg.execute(this);
+ }
+
+ return false;
+ }
+
+ if (!_isActive) {
+ lockMouse();
+
+ CCreateMusicPlayerMsg createMsg;
+ createMsg.execute(this);
+ CSetMusicControlsMsg controlsMsg;
+ controlsMsg.execute(this, nullptr, MSGFLAG_SCAN);
+
+ getMusicRoom()->startMusic(_musicId);
+ _isActive = true;
+ }
+
+ return true;
+}
+
+bool CMusicPlayer::StopMusicMsg(CStopMusicMsg *msg) {
+ if (!_isActive)
+ // Player isn't playing, so ignore message
+ return false;
+
+ // Stop the music
+ CMusicRoom *musicRoom = getMusicRoom();
+ if (musicRoom)
+ musicRoom->stopMusic();
+ _isActive = false;
+
+ CMusicHasStoppedMsg stoppedMsg;
+ stoppedMsg.execute(_stopTarget, nullptr, MSGFLAG_SCAN);
+ return true;
+}
+
+bool CMusicPlayer::FrameMsg(CFrameMsg *msg) {
+ if (_isActive && !CMusicRoom::_musicHandler->isBusy()) {
+ getMusicRoom()->stopMusic();
+ _isActive = false;
+
+ CMusicHasStoppedMsg stoppedMsg;
+ stoppedMsg.execute(_stopTarget);
+ }
+
+ return true;
+}
+
+bool CMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
+ addTimer(100);
+ return true;
+}
+
+bool CMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ getMusicRoom()->destroyMusicHandler();
+ return true;
+}
+
+bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) {
+ if (CMusicRoom::_musicHandler) {
+ CMusicRoom::_musicHandler->setStopWaves(_stopWaves);
+ return true;
+ }
+
+ CMusicHandler *musicHandler = getMusicRoom()->createMusicHandler();
+ CMusicWave *wave;
+
+ if (musicHandler) {
+ wave = musicHandler->createMusicWave(0, 3);
+ wave->load(0, "z#490.wav", 60);
+ wave->load(1, "z#488.wav", 62);
+ wave->load(2, "z#489.wav", 63);
+
+ wave = musicHandler->createMusicWave(1, 5);
+ wave->load(0, "z#493.wav", 22);
+ wave->load(1, "z#495.wav", 29);
+ wave->load(2, "z#492.wav", 34);
+ wave->load(3, "z#494.wav", 41);
+ wave->load(4, "z#491.wav", 46);
+
+ wave = musicHandler->createMusicWave(2, 5);
+ wave->load(0, "z#499.wav", 26);
+ wave->load(1, "z#497.wav", 34);
+ wave->load(2, "z#498.wav", 38);
+ wave->load(3, "z#496.wav", 46);
+ wave->load(4, "z#500.wav", 60);
+
+ wave = musicHandler->createMusicWave(3, 7);
+ wave->load(0, "z#504.wav", 22);
+ wave->load(1, "z#507.wav", 29);
+ wave->load(2, "z#503.wav", 34);
+ wave->load(3, "z#506.wav", 41);
+ wave->load(4, "z#502.wav", 46);
+ wave->load(5, "z#505.wav", 53);
+ wave->load(6, "z#501.wav", 58);
+
+ CMusicRoom::_musicHandler->setStopWaves(_stopWaves);
+ }
+
+ return true;
+}
+
+bool CMusicPlayer::TimerMsg(CTimerMsg *msg) {
+ CCreateMusicPlayerMsg playerMsg;
+ playerMsg.execute(this);
+ return true;
+}
+
+bool CMusicPlayer::LoadSuccessMsg(CLoadSuccessMsg *msg) {
+ if (_isActive) {
+ CStopMusicMsg stopMsg;
+ stopMsg.execute(this);
+ CStartMusicMsg startMsg;
+ startMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_player.h b/engines/titanic/sound/music_player.h
new file mode 100644
index 0000000000..7b82d4da00
--- /dev/null
+++ b/engines/titanic/sound/music_player.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_MUSIC_PLAYER_H
+#define TITANIC_MUSIC_PLAYER_H
+
+#include "titanic/core/game_object.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CMusicPlayer : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool StartMusicMsg(CStartMusicMsg *msg);
+ bool StopMusicMsg(CStopMusicMsg *msg);
+ bool FrameMsg(CFrameMsg *msg);
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+ bool CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg);
+ bool TimerMsg(CTimerMsg *msg);
+ bool LoadSuccessMsg(CLoadSuccessMsg *msg);
+protected:
+ bool _isActive;
+ CString _stopTarget;
+ bool _stopWaves;
+ int _musicId;
+public:
+ CLASSDEF;
+ CMusicPlayer() : CGameObject(),
+ _isActive(false), _stopWaves(false), _musicId(100) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp
new file mode 100644
index 0000000000..2e4ad904fa
--- /dev/null
+++ b/engines/titanic/sound/music_room.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "titanic/sound/music_room.h"
+#include "titanic/sound/sound.h"
+#include "titanic/game_manager.h"
+
+namespace Titanic {
+
+CMusicHandler *CMusicRoom::_musicHandler;
+
+CMusicRoom::CMusicRoom(CGameManager *gameManager) :
+ _gameManager(gameManager) {
+ _sound = &_gameManager->_sound;
+ _items.resize(4);
+}
+
+CMusicRoom::~CMusicRoom() {
+ destroyMusicHandler();
+}
+
+CMusicHandler *CMusicRoom::createMusicHandler() {
+ if (_musicHandler)
+ destroyMusicHandler();
+
+ _musicHandler = new CMusicHandler(_gameManager->_project, &_sound->_soundManager);
+ return _musicHandler;
+}
+
+void CMusicRoom::destroyMusicHandler() {
+ delete _musicHandler;
+ _musicHandler = nullptr;
+}
+
+void CMusicRoom::startMusic(int musicId) {
+ // TODO
+}
+
+void CMusicRoom::stopMusic() {
+ if (_musicHandler)
+ _musicHandler->stop();
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_room.h b/engines/titanic/sound/music_room.h
new file mode 100644
index 0000000000..5f0b271ab3
--- /dev/null
+++ b/engines/titanic/sound/music_room.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_MUSIC_ROOM_H
+#define TITANIC_MUSIC_ROOM_H
+
+#include "common/array.h"
+#include "titanic/sound/music_handler.h"
+
+namespace Titanic {
+
+class CGameManager;
+class CSound;
+
+enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 };
+
+class CMusicRoom {
+ struct Entry {
+ uint _val1;
+ uint _val2;
+ uint _val3;
+ uint _val4;
+ uint _val5;
+
+ Entry() : _val1(0), _val2(0), _val3(0), _val4(0), _val5(0) {}
+ };
+private:
+ Common::Array<Entry> _items;
+public:
+ static CMusicHandler *_musicHandler;
+public:
+ CGameManager *_gameManager;
+ CSound *_sound;
+public:
+ CMusicRoom(CGameManager *owner);
+ ~CMusicRoom();
+
+ /**
+ * Creates a music handler
+ */
+ CMusicHandler *createMusicHandler();
+
+ /**
+ * Destroys and currently active music handler
+ */
+ void destroyMusicHandler();
+
+ void setItem1(MusicControlArea index, int val) { _items[index]._val1 = val; }
+ void setItem2(MusicControlArea index, int val) { _items[index]._val2 = val; }
+ void setItem3(MusicControlArea index, int val) { _items[index]._val3 = val; }
+ void setItem4(MusicControlArea index, int val) { _items[index]._val4 = val; }
+ void setItem5(MusicControlArea index, int val) { _items[index]._val5 = val; }
+
+ /**
+ * Start playing a given music number
+ */
+ void startMusic(int musicId);
+
+ /**
+ * Stop playing music
+ */
+ void stopMusic();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MUSIC_ROOM_H */
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
new file mode 100644
index 0000000000..6b5b187805
--- /dev/null
+++ b/engines/titanic/sound/music_wave.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/music_wave.h"
+#include "titanic/sound/sound_manager.h"
+#include "titanic/core/project_item.h"
+
+namespace Titanic {
+
+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) {
+ 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);
+}
+
+void CMusicWave::stop() {
+
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h
new file mode 100644
index 0000000000..b240f4a856
--- /dev/null
+++ b/engines/titanic/sound/music_wave.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#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);
+
+ /**
+ * Stops the music
+ */
+ void stop();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MUSIC_WAVE_H */
diff --git a/engines/titanic/sound/node_auto_sound_player.cpp b/engines/titanic/sound/node_auto_sound_player.cpp
new file mode 100644
index 0000000000..40b3d2ea39
--- /dev/null
+++ b/engines/titanic/sound/node_auto_sound_player.cpp
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/node_auto_sound_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CNodeAutoSoundPlayer, CAutoSoundPlayer)
+ ON_MESSAGE(EnterNodeMsg)
+ ON_MESSAGE(LeaveNodeMsg)
+END_MESSAGE_MAP()
+
+void CNodeAutoSoundPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_enabled, indent);
+ CAutoSoundPlayer::save(file, indent);
+}
+
+void CNodeAutoSoundPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _enabled = file->readNumber();
+ CAutoSoundPlayer::load(file);
+}
+
+bool CNodeAutoSoundPlayer::EnterNodeMsg(CEnterNodeMsg *msg) {
+ CNodeItem *node = findNode();
+ CRoomItem *room = findRoom();
+
+ if (node == msg->_newNode) {
+ CTurnOn onMsg;
+ onMsg.execute(this);
+
+ if (_enabled) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 1;
+ changeMsg.execute(room, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+ }
+ }
+
+ return true;
+}
+
+bool CNodeAutoSoundPlayer::LeaveNodeMsg(CLeaveNodeMsg *msg) {
+ CNodeItem *node = findNode();
+ CRoomItem *room = findRoom();
+
+ if (node == msg->_oldNode) {
+ CTurnOff offMsg;
+ offMsg.execute(this);
+
+ if (_enabled) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 2;
+ changeMsg.execute(room, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+ }
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/node_auto_sound_player.h b/engines/titanic/sound/node_auto_sound_player.h
new file mode 100644
index 0000000000..f5bdc42c3c
--- /dev/null
+++ b/engines/titanic/sound/node_auto_sound_player.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_NODE_AUTO_SOUND_PLAYER_H
+#define TITANIC_NODE_AUTO_SOUND_PLAYER_H
+
+#include "titanic/sound/auto_sound_player.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CNodeAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterNodeMsg(CEnterNodeMsg *msg);
+ bool LeaveNodeMsg(CLeaveNodeMsg *msg);
+private:
+ bool _enabled;
+public:
+ CLASSDEF;
+ CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(true) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_NODE_AUTO_SOUND_PLAYER_H */
diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp
new file mode 100644
index 0000000000..7f4e6784f2
--- /dev/null
+++ b/engines/titanic/sound/proximity.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/proximity.h"
+#include "titanic/true_talk/tt_talker.h"
+
+namespace Titanic {
+
+CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0),
+ _priorSoundHandle(-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875),
+ _repeated(false), _channel(10), _positioningMode(POSMODE_NONE), _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),
+ _field54(0), _field58(0), _field5C(0), _freeSoundFlag(false), _endTalkerFn(nullptr),
+ _talker(nullptr), _field6C(0) {
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h
new file mode 100644
index 0000000000..b728f22c26
--- /dev/null
+++ b/engines/titanic/sound/proximity.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_PROXIMITY_H
+#define TITANIC_PROXIMITY_H
+
+#include "common/scummsys.h"
+
+namespace Titanic {
+
+enum PositioningMode { POSMODE_NONE = 0, POSMODE_POLAR = 1, POSMODE_VECTOR = 2 };
+
+class TTtalker;
+
+typedef void (*CEndTalkerFn)(TTtalker *talker);
+
+class CProximity {
+public:
+ int _field4;
+ int _channelVolume;
+ int _fieldC;
+ int _priorSoundHandle;
+ int _field14;
+ double _frequencyMultiplier;
+ double _field1C;
+ bool _repeated;
+ int _channel;
+ PositioningMode _positioningMode;
+ double _azimuth;
+ double _range;
+ double _elevation;
+ double _posX;
+ double _posY;
+ double _posZ;
+ bool _hasVelocity;
+ double _velocityX;
+ double _velocityY;
+ double _velocityZ;
+ int _field54;
+ int _field58;
+ int _field5C;
+ bool _freeSoundFlag;
+ CEndTalkerFn _endTalkerFn;
+ TTtalker *_talker;
+ int _field6C;
+public:
+ CProximity();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_PROXIMITY_H */
diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp
new file mode 100644
index 0000000000..145d142b2d
--- /dev/null
+++ b/engines/titanic/sound/qmixer.cpp
@@ -0,0 +1,173 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/qmixer.h"
+
+namespace Titanic {
+
+QMixer::QMixer(Audio::Mixer *mixer) : _mixer(mixer) {
+}
+
+bool QMixer::qsWaveMixInitEx(const QMIXCONFIG &config) {
+ assert(_channels.empty());
+ assert(config.iChannels > 0 && config.iChannels < 256);
+
+ _channels.resize(config.iChannels);
+ return true;
+}
+
+void QMixer::qsWaveMixActivate(bool fActivate) {
+ // Not currently implemented in ScummVM
+}
+
+int QMixer::qsWaveMixOpenChannel(int iChannel, QMixFlag mode) {
+ // Not currently implemented in ScummVM
+ return 0;
+}
+
+int QMixer::qsWaveMixEnableChannel(int iChannel, uint flags, bool enabled) {
+ // Not currently implemented in ScummVM
+ return 0;
+}
+
+void QMixer::qsWaveMixCloseSession() {
+ _mixer->stopAll();
+ _channels.clear();
+}
+
+void QMixer::qsWaveMixFreeWave(Audio::SoundHandle &handle) {
+ _mixer->stopHandle(handle);
+}
+
+void QMixer::qsWaveMixFlushChannel(int iChannel, uint flags) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetPanRate(int iChannel, uint flags, uint rate) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetVolume(int iChannel, uint flags, uint volume) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetPolarPosition(int iChannel, uint flags, const QSPOLAR &position) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetListenerPosition(const QSVECTOR &position, uint flags) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetListenerOrientation(const QSVECTOR &direction, const QSVECTOR &up, uint flags) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetDistanceMapping(int iChannel, uint flags, const QMIX_DISTANCES &distances) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetFrequency(int iChannel, uint flags, uint frequency) {
+ // Not currently implemented in ScummVM
+}
+
+void QMixer::qsWaveMixSetSourceVelocity(int iChannel, uint flags, const QSVECTOR &velocity) {
+ // Not currently implemented in ScummVM
+}
+
+int QMixer::qsWaveMixPlayEx(int iChannel, uint flags, CWaveFile *waveFile, int loops, const QMIXPLAYPARAMS &params) {
+ if (iChannel == -1) {
+ // Find a free channel
+ for (iChannel = 0; iChannel < (int)_channels.size(); ++iChannel) {
+ if (_channels[iChannel]._sounds.empty())
+ break;
+ }
+ assert(iChannel != (int)_channels.size());
+ }
+
+ // If the new sound replaces current ones, then clear the channel
+ ChannelEntry &channel = _channels[iChannel];
+ if (flags & QMIX_CLEARQUEUE) {
+ if (!channel._sounds.empty() && channel._sounds.front()._started)
+ _mixer->stopHandle(channel._sounds.front()._soundHandle);
+
+ channel._sounds.clear();
+ }
+
+ // Add the sound to the channel
+ channel._sounds.push_back(SoundEntry(waveFile, params.callback, loops, params.dwUser));
+ qsWaveMixPump();
+
+ return 0;
+}
+
+bool QMixer::qsWaveMixIsChannelDone(int iChannel) const {
+ return _channels[iChannel]._sounds.empty();
+}
+
+void QMixer::qsWaveMixPump() {
+ // Iterate through each of the channels
+ for (uint iChannel = 0; iChannel < _channels.size(); ++iChannel) {
+ ChannelEntry &channel = _channels[iChannel];
+
+ // If the playing sound on the channel is finished, then call
+ // the callback registered for it, and remove it from the list
+ if (!channel._sounds.empty()) {
+ SoundEntry &sound = channel._sounds.front();
+ if (sound._started && !_mixer->isSoundHandleActive(sound._soundHandle)) {
+ if (sound._loops == -1 || sound._loops-- > 0) {
+ // Need to loop the sound again
+ sound._waveFile->_stream->rewind();
+ _mixer->playStream(sound._waveFile->_soundType,
+ &sound._soundHandle, sound._waveFile->_stream,
+ -1, 0xff, 0, DisposeAfterUse::NO);
+ } else {
+ // Sound is finished
+ if (sound._callback)
+ // Call the callback to signal end
+ sound._callback(iChannel, sound._waveFile, sound._userData);
+
+ // Remove sound record from channel
+ channel._sounds.erase(channel._sounds.begin());
+ }
+ }
+ }
+
+ // If there's an unstarted sound at the front of a channel's
+ // sound list, then start it playing
+ if (!channel._sounds.empty()) {
+ SoundEntry &sound = channel._sounds.front();
+ if (!sound._started) {
+ _mixer->playStream(sound._waveFile->_soundType,
+ &sound._soundHandle, sound._waveFile->_stream,
+ -1, 0xff, 0, DisposeAfterUse::NO);
+ sound._started = true;
+ }
+ }
+ }
+}
+
+} // End of namespace Titanic z
diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h
new file mode 100644
index 0000000000..4ba76a8969
--- /dev/null
+++ b/engines/titanic/sound/qmixer.h
@@ -0,0 +1,312 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * aint with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_QMIXER_H
+#define TITANIC_QMIXER_H
+
+#include "audio/mixer.h"
+#include "titanic/sound/wave_file.h"
+
+namespace Titanic {
+
+enum QMixFlag {
+ QMIX_OPENSINGLE = 0, // Open the single channel specified by iChannel
+ QMIX_OPENALL = 1, // Opens all the channels, iChannel ignored
+ QMIX_OPENCOUNT = 2, // Open iChannel Channels (eg. if iChannel = 4 will create channels 0-3)
+ QMIX_OPENAVAILABLE = 3, // Open the first unopened channel, and return channel number
+
+ // Channel function flags
+ 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
+};
+
+// qsWaveMixEnableChannel flags: if mode==0, use conventional, high-performance
+// stereo mixer. Non-zero modes imply some form of additional processing.
+enum QMixChannelFlag {
+ QMIX_CHANNEL_STEREO = 0x0000, // Perform stereo mixing
+ QMIX_CHANNEL_QSOUND = 0x0001, // Perform QSound localization (default)
+ QMIX_CHANNEL_DOPPLER = 0x0002, // Calculate velocity using position updates
+ QMIX_CHANNEL_RANGE = 0x0004, // Do range effects
+ QMIX_CHANNEL_ELEVATION = 0x0008, // Do elevation effects
+ QMIX_CHANNEL_NODOPPLERPITCH = 0x0010, // Disable Doppler pitch shift for this channel
+ QMIX_CHANNEL_PITCH_COPY = 0x0000, // Pitch shifting using copying (fastest)
+ QMIX_CHANNEL_PITCH_LINEAR = 0x0100, // Pitch shifting using linear interpolation (better but slower)
+ QMIX_CHANNEL_PITCH_SPLINE = 0x0200, // Pitch shifting using spline interpolation (better yet, but much slower)
+ QMIX_CHANNEL_PITCH_FILTER = 0x0300, // Pitch shifting using FIR filter (best, but slowest)
+ QMIX_CHANNEL_PITCH_MASK = 0x0700 // Bits reserved for pitch types
+};
+
+/**
+ * Options for dwFlags parameter in QSWaveMixPlayEx.
+ *
+ * Notes: The QMIX_USELRUCHANNEL flag has two roles. When QMIX_CLEARQUEUE is also set,
+ * the channel that has been playing the longest (least-recently-used) is cleared and
+ * the buffer played. When QMIX_QUEUEWAVE is set, the channel that will first finish
+ * playing will be selected and the buffer queued to play. Of course, if an unused
+ * channel is found, it will be selected instead.
+ * If QMIX_WAIT hasn't been specified, then the channel number will be returned
+ * in the iChannel field.
+ */
+enum QMixPlayFlag {
+ QMIX_QUEUEWAVE = 0x0000, // Queue on channel
+ QMIX_CLEARQUEUE = 0x0001, // Clear queue on channel
+ QMIX_USELRUCHANNEL = 0x0002, // See notes above
+ QMIX_HIGHPRIORITY = 0x0004,
+ QMIX_WAIT = 0x0008, // Queue to be played with other sounds
+ QMIX_IMMEDIATE = 0x0020, // Apply volume/pan changes without interpolation
+
+ QMIX_PLAY_SETEVENT = 0x0100, // Calls SetEvent in the original library when done
+ QMIX_PLAY_PULSEEVENT = 0x0200, // Calls PulseEvent in the original library when done
+ QMIX_PLAY_NOTIFYSTOP = 0x0400 // Do callback even when stopping or flushing sound
+};
+
+/**
+ * Mixer configuration structure for qsWaveMixInitEx
+ */
+struct QMIXCONFIG {
+ uint32 dwSize;
+ uint32 dwFlags;
+ uint32 dwSamplingRate; // Sampling rate in Hz
+ void *lpIDirectSound;
+ const void *lpGuid;
+ int iChannels; // Number of channels
+ int iOutput; // if 0, uses best output device
+ int iLatency; // (in ms) if 0, uses default for output device
+ int iMath; // style of math
+ uint hwnd;
+
+ QMIXCONFIG() : dwSize(40), dwFlags(0), dwSamplingRate(0), lpIDirectSound(nullptr),
+ lpGuid(nullptr), iChannels(0), iOutput(0), iLatency(0), iMath(0), hwnd(0) {}
+ QMIXCONFIG(uint32 rate, int channels, int latency) : dwSize(40), dwFlags(0),
+ dwSamplingRate(rate), iChannels(channels), iLatency(latency),
+ lpIDirectSound(nullptr), lpGuid(nullptr), iOutput(0), iMath(0), hwnd(0) {}
+};
+
+/**
+ * Vector positioning in metres
+ */
+struct QSVECTOR {
+ double x;
+ double y;
+ double z;
+
+ QSVECTOR() : x(0.0), y(0.0), z(0.0) {}
+ QSVECTOR(double xp, double yp, double zp) : x(xp), y(yp), z(zp) {}
+};
+
+/**
+ * Polar positioning
+ */
+struct QSPOLAR {
+ double azimuth; // degrees
+ double range; // meters
+ double elevation; // degrees
+
+ QSPOLAR() : azimuth(0.0), range(0.0), elevation(0.0) {}
+ QSPOLAR(double azimuth_, double range_, double elevation_) :
+ azimuth(azimuth_), range(range_), elevation(elevation_) {}
+};
+
+struct QMIX_DISTANCES {
+ int cbSize; // Structure size
+ double minDistance; // sounds are at full volume if closer than this
+ double maxDistance; // sounds are muted if further away than this
+ double scale; // relative amount to adjust rolloff by
+
+ QMIX_DISTANCES() : cbSize(16), minDistance(0.0), maxDistance(0.0), scale(0.0) {}
+ QMIX_DISTANCES(double minDistance_, double maxDistance_, double scale_) :
+ cbSize(16), minDistance(minDistance_), maxDistance(maxDistance_), scale(scale_) {}
+};
+
+typedef void (*LPQMIXDONECALLBACK)(int iChannel, CWaveFile *lpWave, void *dwUser);
+
+struct QMIXPLAYPARAMS {
+ uint dwSize; // Size of the play structure
+ void *lpImage; // Additional preprocessed audio for high performance
+ uint hwndNotify; // if set, WOM_OPEN and WOM_DONE messages sent to that window
+ LPQMIXDONECALLBACK callback; // Callback function
+ void *dwUser; // User data accompanying callback
+ int lStart;
+ int lStartLoop;
+ int lEndLoop;
+ int lEnd;
+ const void *lpChannelParams; // initialize with these parameters
+ // Properties introduced by ScummVM
+ Audio::Mixer::SoundType _soundType;
+
+ QMIXPLAYPARAMS() : dwSize(36), lpImage(nullptr), hwndNotify(0), callback(nullptr),
+ dwUser(nullptr), lStart(0), lStartLoop(0), lEndLoop(0), lEnd(0),
+ lpChannelParams(nullptr), _soundType(Audio::Mixer::kPlainSoundType) {}
+};
+
+/**
+ * This class represents an interface to the QMixer library developed by
+ * QSound Labs, Inc. Which itself is apparently based on Microsoft's
+ * WaveMix API.
+ *
+ * It does not currently have any actual code from the library,
+ * and instead remaps calls to ScummVM's existing mixer where possible.
+ * This means that advanced features of the QMixer library, like being
+ * able to set up both the player and sounds at different positions are
+ * currently ignored, and all sounds play at full volume.
+ */
+class QMixer {
+ struct SoundEntry {
+ bool _started;
+ CWaveFile *_waveFile;
+ Audio::SoundHandle _soundHandle;
+ LPQMIXDONECALLBACK _callback;
+ int _loops;
+ void *_userData;
+ SoundEntry() : _started(false), _waveFile(nullptr), _callback(nullptr),
+ _loops(0), _userData(nullptr) {}
+
+ SoundEntry(CWaveFile *waveFile, LPQMIXDONECALLBACK callback, int loops, void *userData) :
+ _started(false), _waveFile(waveFile), _callback(callback), _loops(loops), _userData(userData) {}
+ };
+ struct ChannelEntry {
+ Common::List<SoundEntry> _sounds;
+ };
+private:
+ Audio::Mixer *_mixer;
+ Common::Array<ChannelEntry> _channels;
+public:
+ QMixer(Audio::Mixer *mixer);
+ virtual ~QMixer() {}
+
+ /**
+ * Initializes the mixer
+ */
+ bool qsWaveMixInitEx(const QMIXCONFIG &config);
+
+ /**
+ * Activates the mixer
+ */
+ void qsWaveMixActivate(bool fActivate);
+
+ /**
+ * Opens channels in the mixer for access
+ */
+ int qsWaveMixOpenChannel(int iChannel, QMixFlag mode);
+
+ /**
+ * Enables a given channel
+ */
+ int qsWaveMixEnableChannel(int iChannel, uint flags, bool enabled);
+
+ /**
+ * Closes down the mixer
+ */
+ void qsWaveMixCloseSession();
+
+ /**
+ * Stops a sound from playing
+ */
+ void qsWaveMixFreeWave(Audio::SoundHandle &handle);
+
+ /**
+ * Flushes a channel
+ */
+ void qsWaveMixFlushChannel(int iChannel, uint flags = 0);
+
+ /**
+ * Sets the amount of time, in milliseconds, to effect a change in
+ * a channel property (e.g. volume, position). Non-zero values
+ * smooth out changes
+ * @param iChannel Channel to change
+ * @param flags Flags
+ * @param rate Pan rate in milliseconds
+ */
+ void qsWaveMixSetPanRate(int iChannel, uint flags, uint rate);
+
+ /**
+ * Sets the volume for a channel
+ */
+ void qsWaveMixSetVolume(int iChannel, uint flags, uint volume);
+
+ /**
+ * Sets the relative position of a channel
+ * @param iChannel Channel number
+ * @param Flags Flags
+ * @param position Vector position for channel
+ */
+ void qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position);
+
+ /**
+ * Sets the relative position of a channel using polar co-ordinates
+ * @param iChannel Channel number
+ * @param Flags Flags
+ * @param position Polar position for channel
+ */
+ void qsWaveMixSetPolarPosition(int iChannel, uint flags, const QSPOLAR &position);
+
+ /**
+ * Sets the listener position
+ */
+ void qsWaveMixSetListenerPosition(const QSVECTOR &position, uint flags = 0);
+
+ /**
+ * Sets the listener orientation
+ */
+ void qsWaveMixSetListenerOrientation(const QSVECTOR &direction, const QSVECTOR &up, uint flags = 0);
+
+ /**
+ * Sets the mapping ditance range
+ */
+ void qsWaveMixSetDistanceMapping(int iChannel, uint flags, const QMIX_DISTANCES &distances);
+
+ /**
+ *
+ */
+ void qsWaveMixSetFrequency(int iChannel, uint flags, uint frequency);
+
+ /**
+ * Sets the velocity of the source (listener)
+ */
+ void qsWaveMixSetSourceVelocity(int iChannel, uint flags, const QSVECTOR &velocity);
+
+ /**
+ * Plays sound
+ * @param iChannel The channel number to be played on
+ * @param flags Play flags
+ * @param mixWave Data for the sound to be played
+ * @param loops Number of loops to play (-1 for forever)
+ * @param params Playback parameter data
+ */
+ int qsWaveMixPlayEx(int iChannel, uint flags, CWaveFile *waveFile, int loops, const QMIXPLAYPARAMS &params);
+
+ /**
+ * Returns true if there are no more buffers playing or queued on the channel
+ */
+ bool qsWaveMixIsChannelDone(int iChannel) const;
+
+ /**
+ * Handles regularly updating the mixer
+ */
+ void qsWaveMixPump();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_QMIXER_H */
diff --git a/engines/titanic/sound/restricted_auto_music_player.cpp b/engines/titanic/sound/restricted_auto_music_player.cpp
new file mode 100644
index 0000000000..2384d4da25
--- /dev/null
+++ b/engines/titanic/sound/restricted_auto_music_player.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/restricted_auto_music_player.h"
+#include "titanic/core/room_item.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CRestrictedAutoMusicPlayer, CAutoMusicPlayer)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+END_MESSAGE_MAP()
+
+void CRestrictedAutoMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_oldNodeName, indent);
+ file->writeQuotedLine(_newNodeName, indent);
+ file->writeQuotedLine(_newRoomName, indent);
+ file->writeQuotedLine(_oldRoomName, indent);
+
+ CAutoMusicPlayer::save(file, indent);
+}
+
+void CRestrictedAutoMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _oldNodeName = file->readString();
+ _newNodeName = file->readString();
+ _newRoomName = file->readString();
+ _oldRoomName = file->readString();
+
+ CAutoMusicPlayer::load(file);
+}
+
+bool CRestrictedAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
+ if (!msg->_oldRoom)
+ return true;
+ if (petCheckNode(_oldNodeName))
+ return false;
+
+ CString roomName = msg->_oldRoom->getName();
+ if (_oldRoomName.compareToIgnoreCase(roomName)) {
+ _isRepeated = true;
+ return false;
+ } else {
+ return CAutoMusicPlayer::EnterRoomMsg(msg);
+ }
+}
+
+bool CRestrictedAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ CString roomName = msg->_newRoom->getName();
+
+ if (petCheckNode(_newNodeName) || _newRoomName.compareToIgnoreCase(roomName)) {
+ _isRepeated = false;
+ return true;
+ } else {
+ return CAutoMusicPlayer::LeaveRoomMsg(msg);
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/restricted_auto_music_player.h b/engines/titanic/sound/restricted_auto_music_player.h
new file mode 100644
index 0000000000..d36ee5a7ab
--- /dev/null
+++ b/engines/titanic/sound/restricted_auto_music_player.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H
+#define TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H
+
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CRestrictedAutoMusicPlayer : public CAutoMusicPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+private:
+ CString _oldNodeName;
+ CString _newNodeName;
+ CString _newRoomName;
+ CString _oldRoomName;
+public:
+ CLASSDEF;
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/room_auto_sound_player.cpp b/engines/titanic/sound/room_auto_sound_player.cpp
new file mode 100644
index 0000000000..cad7c10771
--- /dev/null
+++ b/engines/titanic/sound/room_auto_sound_player.cpp
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/room_auto_sound_player.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CRoomAutoSoundPlayer, CAutoSoundPlayer)
+ ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+END_MESSAGE_MAP()
+
+void CRoomAutoSoundPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ CAutoSoundPlayer::save(file, indent);
+}
+
+void CRoomAutoSoundPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ CAutoSoundPlayer::load(file);
+}
+
+bool CRoomAutoSoundPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
+ CRoomItem *room = findRoom();
+ if (room == msg->_newRoom) {
+ CTurnOn onMsg;
+ onMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CRoomAutoSoundPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ CRoomItem *room = findRoom();
+ if (room == msg->_oldRoom) {
+ CTurnOff offMsg;
+ offMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/room_auto_sound_player.h b/engines/titanic/sound/room_auto_sound_player.h
new file mode 100644
index 0000000000..56525ccfa3
--- /dev/null
+++ b/engines/titanic/sound/room_auto_sound_player.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_ROOM_AUTO_SOUND_PLAYER_H
+#define TITANIC_ROOM_AUTO_SOUND_PLAYER_H
+
+#include "titanic/sound/auto_sound_player.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CRoomAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+public:
+ CLASSDEF;
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_ROOM_AUTO_SOUND_PLAYER_H */
diff --git a/engines/titanic/sound/room_trigger_auto_music_player.cpp b/engines/titanic/sound/room_trigger_auto_music_player.cpp
new file mode 100644
index 0000000000..7782cef0e2
--- /dev/null
+++ b/engines/titanic/sound/room_trigger_auto_music_player.cpp
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/room_trigger_auto_music_player.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CRoomTriggerAutoMusicPlayer, CTriggerAutoMusicPlayer)
+ ON_MESSAGE(LeaveRoomMsg)
+ ON_MESSAGE(EnterRoomMsg)
+END_MESSAGE_MAP()
+
+void CRoomTriggerAutoMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ CTriggerAutoMusicPlayer::save(file, indent);
+}
+
+void CRoomTriggerAutoMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ CTriggerAutoMusicPlayer::load(file);
+}
+
+bool CRoomTriggerAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ if (msg->_oldRoom == findRoom()) {
+ CTriggerAutoMusicPlayerMsg triggerMsg;
+ triggerMsg._value = 1;
+ triggerMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CRoomTriggerAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
+ if (msg->_newRoom == findRoom()) {
+ CTriggerAutoMusicPlayerMsg triggerMsg;
+ triggerMsg._value = 2;
+ triggerMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/room_trigger_auto_music_player.h b/engines/titanic/sound/room_trigger_auto_music_player.h
new file mode 100644
index 0000000000..a57e133eb6
--- /dev/null
+++ b/engines/titanic/sound/room_trigger_auto_music_player.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H
+#define TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H
+
+#include "titanic/sound/trigger_auto_music_player.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CRoomTriggerAutoMusicPlayer : public CTriggerAutoMusicPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+public:
+ CLASSDEF;
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/season_noises.cpp b/engines/titanic/sound/season_noises.cpp
new file mode 100644
index 0000000000..ce045488ee
--- /dev/null
+++ b/engines/titanic/sound/season_noises.cpp
@@ -0,0 +1,115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/season_noises.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CSeasonNoises, CViewAutoSoundPlayer)
+ ON_MESSAGE(ChangeSeasonMsg)
+ ON_MESSAGE(EnterViewMsg)
+ ON_MESSAGE(ActMsg)
+ ON_MESSAGE(LoadSuccessMsg)
+END_MESSAGE_MAP()
+
+CSeasonNoises::CSeasonNoises() : CViewAutoSoundPlayer(), _seasonNumber(0),
+ _springName("NULL"), _summerName("NULL"), _autumnName("NULL"), _winterName("NULL") {
+}
+
+void CSeasonNoises::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_seasonNumber, indent);
+ file->writeQuotedLine(_springName, indent);
+ file->writeQuotedLine(_summerName, indent);
+ file->writeQuotedLine(_autumnName, indent);
+ file->writeQuotedLine(_winterName, indent);
+
+ CViewAutoSoundPlayer::save(file, indent);
+}
+
+void CSeasonNoises::load(SimpleFile *file) {
+ file->readNumber();
+ _seasonNumber = file->readNumber();
+ _springName = file->readString();
+ _summerName = file->readString();
+ _autumnName = file->readString();
+ _winterName = file->readString();
+
+ CViewAutoSoundPlayer::load(file);
+}
+
+bool CSeasonNoises::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
+ _seasonNumber = (_seasonNumber + 1) % 4;
+ CActMsg actMsg("Update");
+ actMsg.execute(this);
+
+ return true;
+}
+
+bool CSeasonNoises::EnterViewMsg(CEnterViewMsg *msg) {
+ CActMsg actMsg("Update");
+ return true;
+}
+
+bool CSeasonNoises::ActMsg(CActMsg *msg) {
+ msg->_action = "Update";
+
+ switch (_seasonNumber) {
+ case 0:
+ _filename = _springName;
+ break;
+ case 1:
+ _filename = _summerName;
+ break;
+ case 2:
+ _filename = _autumnName;
+ break;
+ case 3:
+ _filename = _winterName;
+ break;
+ default:
+ break;
+ }
+
+ CSignalObject signalMsg;
+ signalMsg._numValue = 2;
+ signalMsg.execute(this);
+
+ CTurnOn onMsg;
+ onMsg.execute(this);
+
+ return true;
+}
+
+bool CSeasonNoises::LoadSuccessMsg(CLoadSuccessMsg *msg) {
+ if (_active) {
+ _active = false;
+ _soundHandle = -1;
+
+ CActMsg actMsg("Update");
+ actMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/season_noises.h b/engines/titanic/sound/season_noises.h
new file mode 100644
index 0000000000..796628d10d
--- /dev/null
+++ b/engines/titanic/sound/season_noises.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_SEASON_NOISES_H
+#define TITANIC_SEASON_NOISES_H
+
+#include "titanic/sound/view_auto_sound_player.h"
+
+namespace Titanic {
+
+class CSeasonNoises : public CViewAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
+ bool EnterViewMsg(CEnterViewMsg *msg);
+ bool ActMsg(CActMsg *msg);
+ bool LoadSuccessMsg(CLoadSuccessMsg *msg);
+private:
+ int _seasonNumber;
+ CString _springName;
+ CString _summerName;
+ CString _autumnName;
+ CString _winterName;
+public:
+ CLASSDEF;
+ CSeasonNoises();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_SEASON_NOISES_H */
diff --git a/engines/titanic/sound/seasonal_music_player.cpp b/engines/titanic/sound/seasonal_music_player.cpp
new file mode 100644
index 0000000000..3532311bdf
--- /dev/null
+++ b/engines/titanic/sound/seasonal_music_player.cpp
@@ -0,0 +1,135 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/seasonal_music_player.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CSeasonalMusicPlayer, CAutoMusicPlayerBase)
+ ON_MESSAGE(ChangeSeasonMsg)
+ ON_MESSAGE(ArboretumGateMsg)
+ ON_MESSAGE(ChangeMusicMsg)
+END_MESSAGE_MAP()
+
+CSeasonalMusicPlayer::CSeasonalMusicPlayer() : CAutoMusicPlayerBase() {
+ _isSpring = false;
+ _isSummer = true;
+ _isAutumn = false;
+ _isWinter = false;
+ _springMode = -4;
+ _summerMode = -2;
+ _autumnMode = -4;
+ _winterMode = -4;
+}
+
+void CSeasonalMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_isSpring, indent);
+ file->writeNumberLine(_isSummer, indent);
+ file->writeNumberLine(_isAutumn, indent);
+ file->writeNumberLine(_isWinter, indent);
+ file->writeNumberLine(_springMode, indent);
+ file->writeNumberLine(_summerMode, indent);
+ file->writeNumberLine(_autumnMode, indent);
+ file->writeNumberLine(_winterMode, indent);
+
+ CAutoMusicPlayerBase::save(file, indent);
+}
+
+void CSeasonalMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _isSpring = file->readNumber();
+ _isSummer = file->readNumber();
+ _isAutumn = file->readNumber();
+ _isWinter = file->readNumber();
+ _springMode = file->readNumber();
+ _summerMode = file->readNumber();
+ _autumnMode = file->readNumber();
+ _winterMode = file->readNumber();
+
+ CAutoMusicPlayerBase::load(file);
+}
+
+bool CSeasonalMusicPlayer::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
+ _isSpring = msg->_season == "spring";
+ _isSummer = msg->_season == "summer";
+ _isAutumn = msg->_season == "autumn";
+ _isWinter = msg->_season == "winter";
+
+ _springMode = _isSpring ? -2 : -4;
+ _summerMode = _isSummer ? -2 : -4;
+ _autumnMode = _isAutumn ? -2 : -4;
+ _winterMode = _isWinter ? -2 : -4;
+
+ CChangeMusicMsg changeMsg;
+ changeMsg._filename = msg->_season;
+ changeMsg.execute(this);
+
+ return true;
+}
+
+bool CSeasonalMusicPlayer::ArboretumGateMsg(CArboretumGateMsg *msg) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = msg->_value ? 2 : 1;
+ changeMsg.execute(this);
+
+ return true;
+}
+
+bool CSeasonalMusicPlayer::ChangeMusicMsg(CChangeMusicMsg *msg) {
+ if (_isRepeated && msg->_flags == 1) {
+ _isRepeated = false;
+ stopGlobalSound(_transition, -1);
+ }
+
+ if (!msg->_filename.empty()) {
+ if (_isSummer) {
+ setGlobalSoundVolume(-4, 2, 0);
+ setGlobalSoundVolume(-2, 2, 1);
+ } else if (_isAutumn) {
+ setGlobalSoundVolume(-4, 2, 1);
+ setGlobalSoundVolume(-2, 2, 2);
+ } else if (_isWinter) {
+ setGlobalSoundVolume(-4, 2, 2);
+ setGlobalSoundVolume(-2, 2, 3);
+ } else if (_isSpring) {
+ setGlobalSoundVolume(-4, 2, 3);
+ setGlobalSoundVolume(-2, 2, 0);
+ }
+ }
+
+ if (!_isRepeated && msg->_flags == 2) {
+ _isRepeated = true;
+ loadSound("c#64.wav");
+ loadSound("c#63.wav");
+ loadSound("c#65.wav");
+ loadSound("c#62.wav");
+ playGlobalSound("c#64.wav", _springMode, _isSpring, true, 0);
+ playGlobalSound("c#63.wav", _summerMode, _isSummer, true, 1);
+ playGlobalSound("c#65.wav", _autumnMode, _isAutumn, true, 2);
+ playGlobalSound("c#62.wav", _winterMode, _isWinter, true, 3);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/seasonal_music_player.h b/engines/titanic/sound/seasonal_music_player.h
new file mode 100644
index 0000000000..d6a79d73da
--- /dev/null
+++ b/engines/titanic/sound/seasonal_music_player.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_SEASONAL_MUSIC_PLAYER_H
+#define TITANIC_SEASONAL_MUSIC_PLAYER_H
+
+#include "titanic/sound/auto_music_player_base.h"
+
+namespace Titanic {
+
+class CSeasonalMusicPlayer : public CAutoMusicPlayerBase {
+ DECLARE_MESSAGE_MAP;
+ bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
+ bool ArboretumGateMsg(CArboretumGateMsg *msg);
+ bool ChangeMusicMsg(CChangeMusicMsg *msg);
+private:
+ bool _isSpring;
+ bool _isSummer;
+ bool _isAutumn;
+ bool _isWinter;
+ int _springMode;
+ int _summerMode;
+ int _autumnMode;
+ int _winterMode;
+public:
+ CLASSDEF;
+ CSeasonalMusicPlayer();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_SEASONAL_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
new file mode 100644
index 0000000000..7e791c2ba5
--- /dev/null
+++ b/engines/titanic/sound/sound.cpp
@@ -0,0 +1,223 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/sound.h"
+#include "titanic/game_manager.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+CSound::CSound(CGameManager *owner, Audio::Mixer *mixer) :
+ _gameManager(owner), _soundManager(mixer) {
+ g_vm->_movieManager.setSoundManager(&_soundManager);
+}
+
+void CSound::save(SimpleFile *file) const {
+ _soundManager.save(file);
+}
+
+void CSound::load(SimpleFile *file) {
+ _soundManager.load(file);
+}
+
+void CSound::preLoad() {
+ _soundManager.preLoad();
+
+ if (_gameManager)
+ _gameManager->_musicRoom.destroyMusicHandler();
+}
+
+void CSound::preEnterView(CViewItem *newView, bool isNewRoom) {
+ CNodeItem *node = newView->findNode();
+ double xp, yp, zp;
+ node->getPosition(xp, yp, zp);
+
+ double cosVal = cos(newView->_angle);
+ double sinVal = -sin(newView->_angle);
+
+ _soundManager.setListenerPosition(xp, yp, zp, cosVal, sinVal, 0, isNewRoom);
+}
+
+bool CSound::isActive(int handle) const {
+ if (handle != 0 && handle != -1)
+ return _soundManager.isActive(handle);
+
+ return false;
+}
+
+void CSound::setVolume(uint handle, uint volume, uint seconds) {
+ _soundManager.setVolume(handle, volume, seconds);
+}
+
+void CSound::activateSound(CWaveFile *waveFile, bool freeFlag) {
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *sound = *i;
+ if (sound->_waveFile == waveFile) {
+ sound->_active = true;
+ sound->_freeFlag = freeFlag;
+
+ if (!freeFlag && waveFile->size() > 51200)
+ sound->_freeFlag = true;
+ break;
+ }
+ }
+}
+
+void CSound::stopChannel(int channel) {
+ _soundManager.stopChannel(channel);
+}
+
+void CSound::checkSounds() {
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_active && soundItem->_freeFlag) {
+ if (_soundManager.isActive(soundItem->_waveFile)) {
+ _sounds.remove(soundItem);
+ delete soundItem;
+ }
+ }
+ }
+}
+
+void CSound::removeOldest() {
+ for (CSoundItemList::iterator i = _sounds.reverse_begin();
+ i != _sounds.end(); --i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_active && !_soundManager.isActive(soundItem->_waveFile)) {
+ _sounds.remove(soundItem);
+ delete soundItem;
+ break;
+ }
+ }
+}
+
+CWaveFile *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) {
+ return loadSpeech(dialogueFile, index);
+}
+
+CWaveFile *CSound::loadSound(const CString &name) {
+ checkSounds();
+
+ // Check whether an entry for the given name is already active
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_name == name) {
+ // Found it, so move it to the front of the list and return
+ _sounds.remove(soundItem);
+ _sounds.push_front(soundItem);
+ return soundItem->_waveFile;
+ }
+ }
+
+ // Create new sound item
+ CSoundItem *soundItem = new CSoundItem(name);
+ soundItem->_waveFile = _soundManager.loadSound(name);
+
+ if (!soundItem->_waveFile) {
+ // Couldn't load sound, so destroy new item and return
+ delete soundItem;
+ return 0;
+ }
+
+ // Add the item to the list of sounds
+ _sounds.push_front(soundItem);
+
+ // If there are more than 10 sounds loaded, remove the last one,
+ // which is the least recently used of all of them
+ if (_sounds.size() > 10)
+ removeOldest();
+
+ return soundItem->_waveFile;
+}
+
+int CSound::playSound(const CString &name, CProximity &prox) {
+ CWaveFile *waveFile = loadSound(name);
+ if (!waveFile)
+ return -1;
+
+ prox._field6C = waveFile->fn1();
+ activateSound(waveFile, prox._freeSoundFlag);
+
+ return _soundManager.playSound(*waveFile, prox);
+}
+
+CWaveFile *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
+ checkSounds();
+
+ // Check whether an entry for the given name is already active
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_dialogueFileHandle == dialogueFile->getFile()
+ && soundItem->_speechId == speechId) {
+ // Found it, so move it to the front of the list and return
+ _sounds.remove(soundItem);
+ _sounds.push_front(soundItem);
+ return soundItem->_waveFile;
+ }
+ }
+
+ // Create new sound item
+ CSoundItem *soundItem = new CSoundItem(dialogueFile->getFile(), speechId);
+ soundItem->_waveFile = _soundManager.loadSpeech(dialogueFile, speechId);
+
+ if (!soundItem->_waveFile) {
+ // Couldn't load speech, so destroy new item and return
+ delete soundItem;
+ return 0;
+ }
+
+ // Add the item to the list of sounds
+ _sounds.push_front(soundItem);
+
+ // If there are more than 10 sounds loaded, remove the last one,
+ // which is the least recently used of all of them
+ if (_sounds.size() > 10)
+ removeOldest();
+
+ return soundItem->_waveFile;
+}
+
+int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox) {
+ CWaveFile *waveFile = loadSpeech(dialogueFile, speechId);
+ if (!waveFile)
+ return -1;
+
+ prox._field6C = waveFile->fn1();
+ activateSound(waveFile, prox._freeSoundFlag);
+
+ return _soundManager.playSound(*waveFile, prox);
+}
+
+void CSound::stopSound(uint handle) {
+ _soundManager.stopSound(handle);
+}
+
+void CSound::setCanFree(int handle) {
+ if (handle != 0 && handle != -1)
+ _soundManager.setCanFree(handle);
+}
+
+void CSound::updateMixer() {
+ _soundManager.waveMixPump();
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h
new file mode 100644
index 0000000000..de95f9edf1
--- /dev/null
+++ b/engines/titanic/sound/sound.h
@@ -0,0 +1,190 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_SOUND_H
+#define TITANIC_SOUND_H
+
+#include "titanic/support/simple_file.h"
+#include "titanic/sound/proximity.h"
+#include "titanic/sound/sound_manager.h"
+#include "titanic/sound/wave_file.h"
+#include "titanic/core/list.h"
+#include "titanic/core/view_item.h"
+#include "titanic/true_talk/dialogue_file.h"
+
+namespace Titanic {
+
+class CGameManager;
+
+class CSoundItem : public ListItem {
+public:
+ CString _name;
+ CWaveFile *_waveFile;
+ File *_dialogueFileHandle;
+ int _speechId;
+ bool _freeFlag;
+ bool _active;
+public:
+ CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr),
+ _speechId(0), _freeFlag(false), _active(false) {}
+ CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr),
+ _dialogueFileHandle(nullptr), _speechId(0), _freeFlag(false), _active(false) {}
+ CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr),
+ _dialogueFileHandle(dialogueFile), _speechId(speechId), _freeFlag(false), _active(false) {}
+};
+
+class CSoundItemList : public List<CSoundItem> {
+};
+
+class CSound {
+private:
+ CGameManager *_gameManager;
+ CSoundItemList _sounds;
+private:
+ /**
+ * Check whether any sounds are done and can be be removed
+ */
+ void checkSounds();
+
+ /**
+ * Removes the oldest sound from the sounds list that isn't
+ * currently playing
+ */
+ void removeOldest();
+public:
+ QSoundManager _soundManager;
+public:
+ CSound(CGameManager *owner, Audio::Mixer *mixer);
+
+ /**
+ * Save the data for the class to file
+ */
+ void save(SimpleFile *file) const;
+
+ /**
+ * Load the data for the class from file
+ */
+ void load(SimpleFile *file);
+
+ /**
+ * Called when a game is about to be loaded
+ */
+ void preLoad();
+
+ /**
+ * Called when loading a game is complete
+ */
+ void postLoad() { _soundManager.postLoad(); }
+
+ /**
+ * Called when a game is about to be saved
+ */
+ void preSave() { _soundManager.preSave(); }
+
+ /**
+ * Called when a game has finished being saved
+ */
+ void postSave() { _soundManager.postSave(); }
+
+ /**
+ * Called when the view has been changed
+ */
+ void preEnterView(CViewItem *newView, bool isNewRoom);
+
+ /**
+ * Returns true if a sound with the specified handle is active
+ */
+ bool isActive(int handle) const;
+
+ /**
+ * Sets the volume for a sound
+ * @param handle Sound handle
+ * @param volume Volume percentage (0 to 100)
+ * @param seconds Number of seconds to transition to the new volume
+ */
+ void setVolume(uint handle, uint volume, uint seconds);
+
+ /**
+ * Flags a sound about to be played as activated
+ */
+ void activateSound(CWaveFile *waveFile, bool freeFlag);
+
+ /**
+ * Stops any sounds attached to a given channel
+ */
+ void stopChannel(int channel);
+
+ /**
+ * Loads a TrueTalk dialogue
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @returns Wave file instance
+ */
+ CWaveFile *getTrueTalkSound(CDialogueFile *dialogueFile, int index);
+
+ /**
+ * Load a speech resource
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @returns Wave file instance
+ */
+ CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
+
+ /**
+ * Play a speech
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @param prox Proximity instance
+ */
+ int playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox);
+
+ /**
+ * Load a sound
+ * @param name Name of sound resource
+ * @returns Sound item record
+ */
+ CWaveFile *loadSound(const CString &name);
+
+ /**
+ * Play a sound
+ */
+ int playSound(const CString &name, CProximity &prox);
+
+ /**
+ * Stop a sound
+ */
+ void stopSound(uint handle);
+
+ /**
+ * Flags that a sound can be freed if a timeout is set
+ */
+ void setCanFree(int handle);
+
+ /**
+ * Handles regularly updating the mixer
+ */
+ void updateMixer();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_SOUND_H */
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
new file mode 100644
index 0000000000..ae806feb52
--- /dev/null
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -0,0 +1,481 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/sound_manager.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+const uint SAMPLING_RATE = 22050;
+const uint LATENCY = 100;
+const uint CHANNELS_COUNT = 16;
+
+CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0),
+ _masterPercent(75.0), _parrotPercent(75.0), _handleCtr(1) {
+}
+
+uint CSoundManager::getModeVolume(int mode) {
+ switch (mode) {
+ case -1:
+ return (uint)_masterPercent;
+ case -2:
+ return (uint)(_masterPercent * 30 / 100);
+ case -3:
+ return (uint)(_masterPercent * 15 / 100);
+ default:
+ return 0;
+ }
+}
+
+/*------------------------------------------------------------------------*/
+
+void QSoundManagerSounds::add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) {
+ push_back(new QSoundManagerSound(waveFile, iChannel, endFn, talker));
+}
+
+void QSoundManagerSounds::flushChannel(int iChannel) {
+ for (iterator i = begin(); i != end(); ++i) {
+ QSoundManagerSound *item = *i;
+ if (item->_iChannel == iChannel) {
+ if (item->_endFn)
+ item->_endFn(item->_talker);
+
+ remove(item);
+ delete item;
+ break;
+ }
+ }
+}
+
+void QSoundManagerSounds::flushChannel(CWaveFile *waveFile, int iChannel) {
+ for (iterator i = begin(); i != end(); ++i) {
+ QSoundManagerSound *item = *i;
+ if (item->_waveFile->isLoaded() && item->_iChannel == iChannel) {
+ if (item->_endFn)
+ item->_endFn(item->_talker);
+
+ remove(item);
+ delete item;
+ break;
+ }
+ }
+}
+
+bool QSoundManagerSounds::contains(const CWaveFile *waveFile) const {
+ for (const_iterator i = begin(); i != end(); ++i) {
+ const QSoundManagerSound *item = *i;
+ if (item->_waveFile == waveFile)
+ return true;
+ }
+
+ return false;
+}
+
+/*------------------------------------------------------------------------*/
+
+void QSoundManager::Slot::clear() {
+ _waveFile = nullptr;
+ _isTimed = false;
+ _ticks = 0;
+ _channel = -1;
+ _handle = 0;
+ _positioningMode = POSMODE_NONE;
+}
+
+/*------------------------------------------------------------------------*/
+
+QSoundManager::QSoundManager(Audio::Mixer *mixer) : CSoundManager(), QMixer(mixer),
+ _field18(0), _field1C(0) {
+ _slots.resize(48);
+ Common::fill(&_channelsVolume[0], &_channelsVolume[16], 0);
+ Common::fill(&_channelsMode[0], &_channelsMode[16], 0);
+
+ qsWaveMixInitEx(QMIXCONFIG(SAMPLING_RATE, CHANNELS_COUNT, LATENCY));
+ qsWaveMixActivate(true);
+ qsWaveMixOpenChannel(0, QMIX_OPENALL);
+}
+
+QSoundManager::~QSoundManager() {
+ // Close down the mixer
+ qsWaveMixCloseSession();
+}
+
+CWaveFile *QSoundManager::loadSound(const CString &name) {
+ CWaveFile *waveFile = new CWaveFile();
+
+ // Try to load the specified sound
+ if (!waveFile->loadSound(name)) {
+ delete waveFile;
+ return nullptr;
+ }
+
+ return waveFile;
+}
+
+CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
+ CWaveFile *waveFile = new CWaveFile();
+
+ // Try to load the specified sound
+ if (!waveFile->loadSpeech(dialogueFile, speechId)) {
+ delete waveFile;
+ return nullptr;
+ }
+
+ return waveFile;
+}
+
+CWaveFile *QSoundManager::loadMusic(const CString &name) {
+ CWaveFile *waveFile = new CWaveFile();
+
+ // Try to load the specified sound
+ if (!waveFile->loadMusic(name)) {
+ delete waveFile;
+ return nullptr;
+ }
+
+ return waveFile;
+}
+
+int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) {
+ int channel = -1;
+ uint flags = QMIX_CLEARQUEUE;
+
+ if (prox._priorSoundHandle >= 1) {
+ // This sound should only be started after a prior one finishes,
+ // so scan the slots for the specified sound
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ if (_slots[idx]._handle == prox._priorSoundHandle) {
+ channel = _slots[idx]._channel;
+ flags = QMIX_QUEUEWAVE;
+ break;
+ }
+ }
+ }
+
+ if (channel >= 0 || (channel = resetChannel(prox._channel)) != -1) {
+ return playWave(&waveFile, channel, flags, prox);
+ }
+
+ return 0;
+}
+
+void QSoundManager::stopSound(int handle) {
+ resetChannel(10);
+
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ Slot &slot = _slots[idx];
+ if (slot._handle == handle) {
+ qsWaveMixFlushChannel(slot._channel);
+ _sounds.flushChannel(slot._channel);
+ resetChannel(10);
+ }
+ }
+}
+
+void QSoundManager::stopChannel(int channel) {
+ int endChannel;
+ switch (channel) {
+ case 0:
+ case 3:
+ endChannel = channel + 3;
+ break;
+ case 6:
+ endChannel = 10;
+ break;
+ case 10:
+ endChannel = 48;
+ break;
+ default:
+ return;
+ }
+
+ for (; channel < endChannel; ++channel) {
+ qsWaveMixFlushChannel(channel);
+ _sounds.flushChannel(channel);
+ }
+}
+
+void QSoundManager::setCanFree(int handle) {
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ if (_slots[idx]._handle == handle)
+ _slots[idx]._isTimed = true;
+ }
+}
+
+void QSoundManager::stopAllChannels() {
+ qsWaveMixFlushChannel(0, QMIX_OPENALL);
+
+ for (int idx = 0; idx < 16; ++idx)
+ _sounds.flushChannel(idx);
+ resetChannel(10);
+}
+
+int QSoundManager::resetChannel(int iChannel) {
+ int newChannel = -1;
+ int channelStart = 10;
+ int channelEnd = 16;
+
+ if (iChannel != 10) {
+ qsWaveMixFlushChannel(iChannel);
+ _sounds.flushChannel(iChannel);
+ channelStart = iChannel;
+ channelEnd = iChannel + 1;
+ } else {
+ uint ticks = g_vm->_events->getTicksCount();
+
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ Slot &slot = _slots[idx];
+ if (slot._isTimed && slot._ticks && ticks > slot._ticks) {
+ qsWaveMixFlushChannel(slot._channel);
+ _sounds.flushChannel(slot._channel);
+ }
+ }
+ }
+
+ for (iChannel = channelStart; iChannel < channelEnd; ++iChannel) {
+ if (qsWaveMixIsChannelDone(iChannel)) {
+ // Scan through the slots, and reset any slot using the channel
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ Slot &slot = _slots[idx];
+ if (slot._channel == iChannel)
+ slot.clear();
+ }
+
+ // Use the empty channel
+ newChannel = iChannel;
+ }
+ }
+
+ return newChannel;
+}
+
+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) {
+ _channelsVolume[slot._channel] = volume;
+ updateVolume(slot._channel, seconds * 1000);
+
+ if (volume) {
+ uint ticks = g_vm->_events->getTicksCount() + seconds * 1000;
+ if (!slot._ticks || ticks >= slot._ticks)
+ slot._ticks = ticks;
+ } else {
+ slot._ticks = 0;
+ }
+ break;
+ }
+ }
+}
+
+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) {
+ qsWaveMixSetPanRate(slot._channel, QMIX_USEONCE, panRate);
+ qsWaveMixSetSourcePosition(slot._channel, QMIX_USEONCE, QSVECTOR(x, y, z));
+ break;
+ }
+ }
+}
+
+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) {
+ qsWaveMixSetPanRate(slot._channel, QMIX_USEONCE, panRate);
+ qsWaveMixSetPolarPosition(slot._channel, QMIX_USEONCE,
+ QSPOLAR(azimuth, range, elevation));
+ break;
+ }
+ }
+}
+
+bool QSoundManager::isActive(int handle) const {
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ if (_slots[idx]._handle == handle)
+ return true;
+ }
+
+ return false;
+}
+
+bool QSoundManager::isActive(const CWaveFile *waveFile) const {
+ return _sounds.contains(waveFile);
+}
+
+void QSoundManager::waveMixPump() {
+ qsWaveMixPump();
+}
+
+uint QSoundManager::getLatency() const {
+ return LATENCY;
+}
+
+void QSoundManager::setMusicPercent(double percent) {
+ _musicPercent = percent;
+ updateVolumes();
+}
+
+void QSoundManager::setSpeechPercent(double percent) {
+ _speechPercent = percent;
+ updateVolumes();
+}
+
+void QSoundManager::setMasterPercent(double percent) {
+ _masterPercent = percent;
+ updateVolumes();
+}
+
+void QSoundManager::setParrotPercent(double percent) {
+ _parrotPercent = percent;
+}
+
+void QSoundManager::setListenerPosition(double posX, double posY, double posZ,
+ double directionX, double directionY, double directionZ, bool stopSounds) {
+ if (stopSounds) {
+ // Stop any running sounds
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ if (_slots[idx]._positioningMode != 0)
+ stopSound(_slots[idx]._handle);
+ }
+ }
+
+ qsWaveMixSetListenerPosition(QSVECTOR(posX, posY, posZ));
+ qsWaveMixSetListenerOrientation(QSVECTOR(directionX, directionY, directionZ),
+ QSVECTOR(0.0, 0.0, -1.0));
+}
+
+int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProximity &prox) {
+ if (!waveFile || !waveFile->isLoaded())
+ return 0;
+
+ prox._channelVolume = CLIP(prox._channelVolume, 0, 100);
+ prox._fieldC = CLIP(prox._fieldC, -100, 100);
+
+ int slotIndex = findFreeSlot();
+ if (slotIndex == -1)
+ return -1;
+
+ switch (prox._positioningMode) {
+ case POSMODE_POLAR:
+ qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(prox._azimuth, prox._range, prox._elevation));
+ qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
+ qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0));
+ break;
+
+ case POSMODE_VECTOR:
+ qsWaveMixSetSourcePosition(iChannel, 8, QSVECTOR(prox._posX, prox._posY, prox._posZ));
+ qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
+ qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0));
+ break;
+
+ default:
+ qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true);
+ qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(0.0, 1.0, 0.0));
+ break;
+ }
+
+ if (prox._frequencyMultiplier || prox._field1C != 1.875) {
+ uint freq = (uint)(waveFile->getFrequency() * prox._frequencyMultiplier);
+ qsWaveMixSetFrequency(iChannel, 8, freq);
+ }
+
+ _sounds.add(waveFile, iChannel, prox._endTalkerFn, prox._talker);
+
+ QMIXPLAYPARAMS playParams;
+ playParams.callback = soundFinished;
+ playParams.dwUser = this;
+ if (!qsWaveMixPlayEx(iChannel, flags, waveFile, prox._repeated ? -1 : 0, playParams)) {
+ Slot &slot = _slots[slotIndex];
+ slot._handle = _handleCtr++;
+ slot._channel = iChannel;
+ slot._waveFile = waveFile;
+ slot._positioningMode = prox._positioningMode;
+
+ return slot._handle;
+ } else {
+ _sounds.flushChannel(waveFile, iChannel);
+ if (prox._freeSoundFlag)
+ delete waveFile;
+ return 0;
+ }
+}
+
+void QSoundManager::soundFreed(Audio::SoundHandle &handle) {
+ qsWaveMixFreeWave(handle);
+}
+
+void QSoundManager::updateVolume(int channel, uint panRate) {
+ uint volume = _channelsVolume[channel] * 327;
+
+ switch (_channelsMode[channel]) {
+ case 0:
+ case 1:
+ case 2:
+ volume = (_speechPercent * volume) / 100;
+ break;
+ case 3:
+ case 4:
+ case 5:
+ volume = (24525 * volume) / 100;
+ break;
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ volume = (_masterPercent * volume) / 100;
+ break;
+ default:
+ break;
+ }
+
+ volume = (_musicPercent * volume) / 100;
+ qsWaveMixSetPanRate(channel, 0, panRate);
+ qsWaveMixSetVolume(channel, 0, volume);
+}
+
+void QSoundManager::updateVolumes() {
+ for (uint idx = 0; idx < CHANNELS_COUNT; ++idx)
+ updateVolume(idx, 250);
+}
+
+void QSoundManager::soundFinished(int iChannel, CWaveFile *waveFile, void *soundManager) {
+ static_cast<QSoundManager *>(soundManager)->_sounds.flushChannel(waveFile, iChannel);
+}
+
+int QSoundManager::findFreeSlot() {
+ for (uint idx = 0; idx < _slots.size(); ++idx) {
+ if (!_slots[idx]._waveFile)
+ return idx;
+ }
+
+ return -1;
+}
+
+void QSoundManager::setChannelVolume(int iChannel, uint volume, uint mode) {
+ _channelsVolume[iChannel] = volume;
+ _channelsMode[iChannel] = mode;
+ updateVolume(iChannel, 250);
+}
+
+} // End of namespace Titanic z
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
new file mode 100644
index 0000000000..d1afdb4ad4
--- /dev/null
+++ b/engines/titanic/sound/sound_manager.h
@@ -0,0 +1,454 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_SOUND_MANAGER_H
+#define TITANIC_SOUND_MANAGER_H
+
+#include "titanic/core/list.h"
+#include "titanic/support/simple_file.h"
+#include "titanic/sound/proximity.h"
+#include "titanic/sound/qmixer.h"
+#include "titanic/sound/wave_file.h"
+#include "titanic/true_talk/dialogue_file.h"
+
+namespace Titanic {
+
+/**
+ * Abstract interface class for a sound manager
+ */
+class CSoundManager {
+protected:
+ double _musicPercent;
+ double _speechPercent;
+ double _masterPercent;
+ double _parrotPercent;
+ uint _handleCtr;
+public:
+ CSoundManager();
+ virtual ~CSoundManager() {}
+
+ /**
+ * Loads a sound
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual CWaveFile *loadSound(const CString &name) { return nullptr; }
+
+ /**
+ * Loads a speech resource from a dialogue file
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId) { 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
+ */
+ virtual int playSound(CWaveFile &waveFile, CProximity &prox) = 0;
+
+ /**
+ * Stop playing the specified sound
+ */
+ virtual void stopSound(int handle) = 0;
+
+ /**
+ * Stops a designated range of channels
+ */
+ virtual void stopChannel(int channel) = 0;
+
+ virtual void proc9(int handle) {}
+
+ /**
+ * Stops sounds on all playing channels
+ */
+ virtual void stopAllChannels() = 0;
+
+ /**
+ * Sets the volume for a sound
+ * @param handle Handle for sound
+ * @param volume New volume
+ * @param seconds Number of seconds to transition to the new volume
+ */
+ virtual void setVolume(int handle, uint volume, uint seconds) = 0;
+
+ /**
+ * Set the position for a sound
+ * @param handle Handle for sound
+ * @param x x position in metres
+ * @param y y position in metres
+ * @param z z position in metres
+ * @param panRate Rate in milliseconds to transition
+ */
+ virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate) {}
+
+ /**
+ * Set the position for a sound
+ * @param handle Handle for sound
+ * @param range Range value in metres
+ * @param azimuth Azimuth value in degrees
+ * @param elevation Elevation value in degrees
+ * @param panRate Rate in milliseconds to transition
+ */
+ 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(int handle) const = 0;
+
+ /**
+ * Returns true if the given sound is currently active
+ */
+ virtual bool isActive(const CWaveFile *waveFile) const { return false; }
+
+ /**
+ * Handles regularly updating the mixer
+ */
+ virtual void waveMixPump() = 0;
+
+ /**
+ * Returns the movie latency
+ */
+ virtual uint getLatency() const { return 0; }
+
+ /**
+ * Sets the music volume percent
+ */
+ virtual void setMusicPercent(double percent) = 0;
+
+ /**
+ * Sets the speech volume percent
+ */
+ virtual void setSpeechPercent(double percent) = 0;
+
+ /**
+ * Sets the master volume percent
+ */
+ virtual void setMasterPercent(double percent) = 0;
+
+ /**
+ * Sets the Parrot NPC volume percent
+ */
+ virtual void setParrotPercent(double percent) = 0;
+
+ /**
+ * Called when a game is about to be loaded
+ */
+ virtual void preLoad() { stopAllChannels(); }
+
+ /**
+ * Load the data for the class from file
+ */
+ void load(SimpleFile *file) {}
+
+ /**
+ * Called after loading of a game is completed
+ */
+ virtual void postLoad() {}
+
+ /**
+ * Called when a game is about to be saved
+ */
+ virtual void preSave() {}
+
+ /**
+ * Save the data for the class to file
+ */
+ void save(SimpleFile *file) const {}
+
+ /**
+ * Called after saving is complete
+ */
+ virtual void postSave() {}
+
+ /**
+ * Sets the position and orientation for the listener (player)
+ */
+ virtual void setListenerPosition(double posX, double posY, double posZ,
+ double directionX, double directionY, double directionZ, bool stopSounds) {}
+
+ /**
+ * Returns the music volume percent
+ */
+ double getMusicVolume() const { return _musicPercent; }
+
+ /**
+ * Returns the speech volume percent
+ */
+ double getSpeechVolume() const { return _speechPercent; }
+
+ /**
+ * Returns the parrot volume percent
+ */
+ double getParrotVolume() const { return _parrotPercent; }
+
+ /**
+ * Gets the volume for a given mode? value
+ */
+ uint getModeVolume(int mode);
+};
+
+class QSoundManagerSound : public ListItem {
+public:
+ CWaveFile *_waveFile;
+ int _iChannel;
+ CEndTalkerFn _endFn;
+ TTtalker *_talker;
+public:
+ QSoundManagerSound() : ListItem(), _waveFile(nullptr),
+ _iChannel(0), _endFn(nullptr), _talker(nullptr) {}
+ QSoundManagerSound(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) :
+ ListItem(), _waveFile(waveFile), _iChannel(iChannel), _endFn(endFn), _talker(talker) {}
+};
+
+class QSoundManagerSounds : public List<QSoundManagerSound> {
+public:
+ /**
+ * Adds a new sound entry to the list
+ */
+ void add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker);
+
+ /**
+ * Flushes a wave file attached to the specified channel
+ */
+ void flushChannel(int iChannel);
+
+ /**
+ * Flushes a wave file attached to the specified channel
+ */
+ void flushChannel(CWaveFile *waveFile, int iChannel);
+
+ /**
+ * Returns true if the list contains the specified wave file
+ */
+ bool contains(const CWaveFile *waveFile) const;
+};
+
+/**
+ * Concrete sound manager class that handles interfacing with
+ * the QMixer sound mixer class
+ */
+class QSoundManager : public CSoundManager, public QMixer {
+ struct Slot {
+ CWaveFile *_waveFile;
+ bool _isTimed;
+ uint _ticks;
+ int _channel;
+ int _handle;
+ PositioningMode _positioningMode;
+
+ Slot() : _waveFile(0), _isTimed(0), _ticks(0), _channel(-1),
+ _handle(0), _positioningMode(POSMODE_NONE) {}
+ void clear();
+ };
+private:
+ QSoundManagerSounds _sounds;
+ Common::Array<Slot> _slots;
+ uint _channelsVolume[16];
+ int _channelsMode[16];
+private:
+ /**
+ * Updates the volume for a channel
+ * @param channel Channel to be update
+ * @param panRate Time in milliseconds for change to occur
+ */
+ void updateVolume(int channel, uint panRate);
+
+ /**
+ * Updates all the volumes
+ */
+ void updateVolumes();
+
+ /**
+ * Called by the QMixer when a sound finishes playing
+ */
+ static void soundFinished(int iChannel, CWaveFile *waveFile, void *soundManager);
+
+ /**
+ * Finds the first free slot
+ */
+ int findFreeSlot();
+
+ /**
+ * Sets a channel volume
+ */
+ void setChannelVolume(int iChannel, uint volume, uint mode);
+
+ /**
+ * Resets the specified channel and returns a new free one
+ */
+ int resetChannel(int iChannel);
+public:
+ int _field18;
+ int _field1C;
+
+public:
+ QSoundManager(Audio::Mixer *mixer);
+ virtual ~QSoundManager();
+
+ /**
+ * Loads a sound
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual CWaveFile *loadSound(const CString &name);
+
+ /**
+ * Loads a speech resource from a dialogue file
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
+
+ /**
+ * 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
+ */
+ virtual int playSound(CWaveFile &waveFile, CProximity &prox);
+
+ /**
+ * Stop playing the specified sound
+ */
+ virtual void stopSound(int handle);
+
+ /**
+ * Stops a designated range of channels
+ */
+ virtual void stopChannel(int channel);
+
+ /**
+ * Flags that a sound can be freed if a timeout is set
+ */
+ virtual void setCanFree(int handle);
+
+ /**
+ * Stops sounds on all playing channels
+ */
+ virtual void stopAllChannels();
+
+ /**
+ * Sets the volume for a sound
+ * @param handle Handle for sound
+ * @param volume New volume
+ * @param seconds Number of seconds to transition to the new volume
+ */
+ virtual void setVolume(int handle, uint volume, uint seconds);
+
+ /**
+ * Set the position for a sound
+ * @param handle Handle for sound
+ * @param x x position in metres
+ * @param y y position in metres
+ * @param z z position in metres
+ * @param panRate Rate in milliseconds to transition
+ */
+ virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate);
+
+ /**
+ * Set the position for a sound
+ * @param handle Handle for sound
+ * @param range Range value in metres
+ * @param azimuth Azimuth value in degrees
+ * @param elevation Elevation value in degrees
+ * @param panRate Rate in milliseconds to transition
+ */
+ 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(int handle) const;
+
+ /**
+ * Returns true if the given sound is currently active
+ */
+ virtual bool isActive(const CWaveFile *waveFile) const;
+
+ /**
+ * Handles regularly updating the mixer
+ */
+ virtual void waveMixPump();
+
+ /**
+ * Returns the movie latency
+ */
+ virtual uint getLatency() const;
+
+ /**
+ * Sets the music volume percent
+ */
+ virtual void setMusicPercent(double percent);
+
+ /**
+ * Sets the speech volume percent
+ */
+ virtual void setSpeechPercent(double percent);
+
+ /**
+ * Sets the master volume percent
+ */
+ virtual void setMasterPercent(double percent);
+
+ /**
+ * Sets the Parrot NPC volume percent
+ */
+ virtual void setParrotPercent(double percent);
+
+ /**
+ * Sets the position and orientation for the listener (player)
+ */
+ virtual void setListenerPosition(double posX, double posY, double posZ,
+ double directionX, double directionY, double directionZ, bool stopSounds);
+
+ /**
+ * Starts a wave file playing
+ */
+ virtual int playWave(CWaveFile *waveFile, int iChannel, uint flags, CProximity &prox);
+
+ /**
+ * Called when a wave file is freed
+ */
+ void soundFreed(Audio::SoundHandle &handle);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_QSOUND_MANAGER_H */
diff --git a/engines/titanic/sound/titania_speech.cpp b/engines/titanic/sound/titania_speech.cpp
new file mode 100644
index 0000000000..a07cc79334
--- /dev/null
+++ b/engines/titanic/sound/titania_speech.cpp
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/titania_speech.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CTitaniaSpeech, CGameObject)
+ ON_MESSAGE(ActMsg)
+ ON_MESSAGE(MovieEndMsg)
+ ON_MESSAGE(MovieFrameMsg)
+ ON_MESSAGE(TimerMsg)
+ ON_MESSAGE(EnterRoomMsg)
+END_MESSAGE_MAP()
+
+void CTitaniaSpeech::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_paraNum, indent);
+ file->writeNumberLine(_frameNum, indent);
+
+ CGameObject::save(file, indent);
+}
+
+void CTitaniaSpeech::load(SimpleFile *file) {
+ file->readNumber();
+ _paraNum = file->readNumber();
+ _frameNum = file->readNumber();
+
+ CGameObject::load(file);
+}
+
+bool CTitaniaSpeech::ActMsg(CActMsg *msg) {
+ CSetFrameMsg frameMsg;
+ CVisibleMsg visibleMsg;
+ CActMsg actMsg;
+
+ if (msg->_action == "TitaniaSpeech") {
+ switch (_paraNum) {
+ case 0:
+ movieSetAudioTiming(true);
+ loadSound("a#12.wav");
+ sleep(1000);
+ playMovie(0, 187, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT);
+ movieEvent(0);
+ break;
+
+ case 1:
+ loadSound("a#11.wav");
+ addTimer(0);
+ startAnimTimer("Para2", 300);
+ addTimer(6000);
+ addTimer(12000);
+ addTimer(18000);
+ addTimer(24000);
+ startAnimTimer("NextPara", 30000);
+ break;
+
+ case 2:
+ visibleMsg._visible = false;
+ visibleMsg.execute("TitaniaStillControl");
+ loadSound("a#10.wav");
+ playMovie(585, 706, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT);
+ playSound("a#10.wav");
+ break;
+
+ case 3:
+ visibleMsg._visible = false;
+ visibleMsg.execute("TitaniaStillControl");
+ loadSound("a#9.wav");
+ playMovie(707, 905, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT);
+ playSound("a#9.wav");
+ break;
+
+ case 4:
+ visibleMsg._visible = false;
+ visibleMsg.execute("TitaniaStillControl");
+ loadSound("a#8.wav");
+ playMovie(906, 938, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT);
+ playSound("a#8.wav");
+ break;
+
+ default:
+ sleep(3000);
+ actMsg._action = "SleepTitania";
+ actMsg.execute(this);
+ }
+ }
+
+ return true;
+}
+
+bool CTitaniaSpeech::MovieEndMsg(CMovieEndMsg *msg) {
+ if (_paraNum == 5) {
+ startAnimTimer("NextPara", 0);
+ } else {
+ if (_paraNum != 1)
+ addTimer(0);
+ startAnimTimer("NextPara", 3000);
+ }
+
+ return true;
+}
+
+bool CTitaniaSpeech::MovieFrameMsg(CMovieFrameMsg *msg) {
+ int frame = getMovieFrame();
+ if (!frame)
+ playSound("a#12.wav");
+
+ return true;
+}
+
+bool CTitaniaSpeech::TimerMsg(CTimerMsg *msg) {
+ CSetFrameMsg frameMsg;
+ CVisibleMsg visibleMsg;
+ CActMsg actMsg("TitaniaSpeech");
+
+ if (msg->_action == "NextPara") {
+ visibleMsg.execute("TitaniaStillControl");
+ ++_paraNum;
+ actMsg.execute(this);
+ } else if (msg->_action == "Para2") {
+ playSound("a#11.wav");
+ } else {
+ frameMsg._frameNumber = _frameNum;
+ frameMsg.execute("TitaniaStillControl");
+ }
+
+ return true;
+}
+
+bool CTitaniaSpeech::EnterRoomMsg(CEnterRoomMsg *msg) {
+ CActMsg actMsg("Disable");
+ actMsg.execute("ShipAnnouncements");
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/titania_speech.h b/engines/titanic/sound/titania_speech.h
new file mode 100644
index 0000000000..2244bb01af
--- /dev/null
+++ b/engines/titanic/sound/titania_speech.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_TITANIA_SPEECH_H
+#define TITANIC_TITANIA_SPEECH_H
+
+#include "titanic/core/game_object.h"
+#include "titanic/messages/messages.h"
+
+namespace Titanic {
+
+class CTitaniaSpeech : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool ActMsg(CActMsg *msg);
+ bool MovieEndMsg(CMovieEndMsg *msg);
+ bool MovieFrameMsg(CMovieFrameMsg *msg);
+ bool TimerMsg(CTimerMsg *msg);
+ bool EnterRoomMsg(CEnterRoomMsg *msg);
+private:
+ int _paraNum, _frameNum;
+public:
+ CLASSDEF;
+ CTitaniaSpeech() : CGameObject(), _paraNum(1), _frameNum(0) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TITANIA_SPEECH_H */
diff --git a/engines/titanic/sound/trigger_auto_music_player.cpp b/engines/titanic/sound/trigger_auto_music_player.cpp
new file mode 100644
index 0000000000..a332570aba
--- /dev/null
+++ b/engines/titanic/sound/trigger_auto_music_player.cpp
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/trigger_auto_music_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CTriggerAutoMusicPlayer, CGameObject)
+ ON_MESSAGE(TriggerAutoMusicPlayerMsg)
+END_MESSAGE_MAP()
+
+void CTriggerAutoMusicPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_roomName, indent);
+ CGameObject::save(file, indent);
+}
+
+void CTriggerAutoMusicPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _roomName = file->readString();
+ CGameObject::load(file);
+}
+
+bool CTriggerAutoMusicPlayer::TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg) {
+ CRoomItem *room1 = msg->_value == 1 ? locateRoom(_roomName) : findRoom();
+ CRoomItem *room2 = msg->_value == 2 ? locateRoom(_roomName) : findRoom();
+
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 1;
+ changeMsg.execute(room1, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+
+ changeMsg._flags = 2;
+ changeMsg.execute(room2, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/trigger_auto_music_player.h b/engines/titanic/sound/trigger_auto_music_player.h
new file mode 100644
index 0000000000..45631e08fc
--- /dev/null
+++ b/engines/titanic/sound/trigger_auto_music_player.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H
+#define TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H
+
+#include "titanic/core/game_object.h"
+
+namespace Titanic {
+
+class CTriggerAutoMusicPlayer : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg);
+protected:
+ CString _roomName;
+public:
+ CLASSDEF;
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H */
diff --git a/engines/titanic/sound/view_auto_sound_player.cpp b/engines/titanic/sound/view_auto_sound_player.cpp
new file mode 100644
index 0000000000..55501fe340
--- /dev/null
+++ b/engines/titanic/sound/view_auto_sound_player.cpp
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/view_auto_sound_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CViewAutoSoundPlayer, CAutoSoundPlayer)
+ ON_MESSAGE(EnterViewMsg)
+ ON_MESSAGE(LeaveViewMsg)
+END_MESSAGE_MAP()
+
+void CViewAutoSoundPlayer::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_enabled, indent);
+ CAutoSoundPlayer::save(file, indent);
+}
+
+void CViewAutoSoundPlayer::load(SimpleFile *file) {
+ file->readNumber();
+ _enabled = file->readNumber();
+ CAutoSoundPlayer::load(file);
+}
+
+bool CViewAutoSoundPlayer::EnterViewMsg(CEnterViewMsg *msg) {
+ CViewItem *view = findView();
+ CRoomItem *room = findRoom();
+
+ if (view == msg->_newView) {
+ CTurnOn onMsg;
+ onMsg.execute(this);
+
+ if (_enabled) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 1;
+ changeMsg.execute(room, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF |MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+ }
+ }
+
+ return true;
+}
+
+bool CViewAutoSoundPlayer::LeaveViewMsg(CLeaveViewMsg *msg) {
+ CViewItem *view = findView();
+ CRoomItem *room = findRoom();
+
+ if (view == msg->_oldView) {
+ CTurnOff offMsg;
+ offMsg.execute(this);
+
+ if (_enabled) {
+ CChangeMusicMsg changeMsg;
+ changeMsg._flags = 2;
+ changeMsg.execute(room, CAutoMusicPlayer::_type,
+ MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+ }
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/view_auto_sound_player.h b/engines/titanic/sound/view_auto_sound_player.h
new file mode 100644
index 0000000000..b62805ea6e
--- /dev/null
+++ b/engines/titanic/sound/view_auto_sound_player.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_VIEW_AUTO_SOUND_PLAYER_H
+#define TITANIC_VIEW_AUTO_SOUND_PLAYER_H
+
+#include "titanic/sound/auto_sound_player.h"
+
+namespace Titanic {
+
+class CViewAutoSoundPlayer : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool EnterViewMsg(CEnterViewMsg *msg);
+ bool LeaveViewMsg(CLeaveViewMsg *msg);
+private:
+ bool _enabled;
+public:
+ CLASSDEF;
+ CViewAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(false) {}
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_VIEW_AUTO_SOUND_PLAYER_H */
diff --git a/engines/titanic/sound/view_toggles_other_music.cpp b/engines/titanic/sound/view_toggles_other_music.cpp
new file mode 100644
index 0000000000..731f59bd53
--- /dev/null
+++ b/engines/titanic/sound/view_toggles_other_music.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/view_toggles_other_music.h"
+
+namespace Titanic {
+
+BEGIN_MESSAGE_MAP(CViewTogglesOtherMusic, CEnterViewTogglesOtherMusic)
+ ON_MESSAGE(LeaveViewMsg)
+END_MESSAGE_MAP()
+
+CViewTogglesOtherMusic::CViewTogglesOtherMusic() :
+ CEnterViewTogglesOtherMusic(), _value(1) {
+}
+
+void CViewTogglesOtherMusic::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeNumberLine(_value, indent);
+
+ CEnterViewTogglesOtherMusic::save(file, indent);
+}
+
+void CViewTogglesOtherMusic::load(SimpleFile *file) {
+ file->readNumber();
+ _value = file->readNumber();
+
+ CEnterViewTogglesOtherMusic::load(file);
+}
+
+bool CViewTogglesOtherMusic::LeaveViewMsg(CLeaveViewMsg *msg) {
+ if (msg->_oldView == findView()) {
+ CTriggerAutoMusicPlayerMsg playerMsg(_value);
+ playerMsg.execute(this);
+ }
+
+ return true;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/view_toggles_other_music.h b/engines/titanic/sound/view_toggles_other_music.h
new file mode 100644
index 0000000000..1b5f110e70
--- /dev/null
+++ b/engines/titanic/sound/view_toggles_other_music.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H
+#define TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H
+
+#include "titanic/sound/enter_view_toggles_other_music.h"
+
+namespace Titanic {
+
+class CViewTogglesOtherMusic : public CEnterViewTogglesOtherMusic {
+ DECLARE_MESSAGE_MAP;
+ bool LeaveViewMsg(CLeaveViewMsg *msg);
+private:
+ int _value;
+public:
+ CLASSDEF;
+ CViewTogglesOtherMusic();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H */
diff --git a/engines/titanic/sound/water_lapping_sounds.cpp b/engines/titanic/sound/water_lapping_sounds.cpp
new file mode 100644
index 0000000000..7616c4b43b
--- /dev/null
+++ b/engines/titanic/sound/water_lapping_sounds.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "titanic/sound/water_lapping_sounds.h"
+
+namespace Titanic {
+
+EMPTY_MESSAGE_MAP(CWaterLappingSounds, CRoomAutoSoundPlayer);
+
+CWaterLappingSounds::CWaterLappingSounds() : CRoomAutoSoundPlayer(),
+ _value(0) {
+ _filename = "z#217.wav";
+ _repeated = false;
+ _startSeconds = 0;
+}
+
+void CWaterLappingSounds::save(SimpleFile *file, int indent) {
+ file->writeNumberLine(1, indent);
+ file->writeQuotedLine(_filename, indent);
+ file->writeNumberLine(_repeated, indent);
+ file->writeNumberLine(_startSeconds, indent);
+ file->writeNumberLine(_value, indent);
+
+ CRoomAutoSoundPlayer::save(file, indent);
+}
+
+void CWaterLappingSounds::load(SimpleFile *file) {
+ file->readNumber();
+ _filename = file->readString();
+ _repeated = file->readNumber();
+ _startSeconds = file->readNumber();
+ _value = file->readNumber();
+
+ CRoomAutoSoundPlayer::load(file);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/water_lapping_sounds.h b/engines/titanic/sound/water_lapping_sounds.h
new file mode 100644
index 0000000000..2d0594b26b
--- /dev/null
+++ b/engines/titanic/sound/water_lapping_sounds.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_WATER_LAPPING_SOUNDS_H
+#define TITANIC_WATER_LAPPING_SOUNDS_H
+
+#include "titanic/sound/room_auto_sound_player.h"
+
+namespace Titanic {
+
+class CWaterLappingSounds : public CRoomAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+public:
+ int _value;
+public:
+ CLASSDEF;
+ CWaterLappingSounds();
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_WATER_LAPPING_SOUNDS_H */
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
new file mode 100644
index 0000000000..8c00637d73
--- /dev/null
+++ b/engines/titanic/sound/wave_file.cpp
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "audio/decoders/wave.h"
+#include "common/memstream.h"
+#include "titanic/sound/wave_file.h"
+#include "titanic/sound/sound_manager.h"
+#include "titanic/support/simple_file.h"
+
+namespace Titanic {
+
+CWaveFile::CWaveFile() : _owner(nullptr), _stream(nullptr),
+ _soundType(Audio::Mixer::kPlainSoundType) {
+}
+
+CWaveFile::CWaveFile(QSoundManager *owner) : _owner(owner), _stream(nullptr),
+ _soundType(Audio::Mixer::kPlainSoundType) {
+}
+
+CWaveFile::~CWaveFile() {
+ if (_stream) {
+ _owner->soundFreed(_soundHandle);
+ delete _stream;
+ }
+}
+
+int CWaveFile::fn1() {
+ // TODO
+ return 0;
+}
+
+bool CWaveFile::loadSound(const CString &name) {
+ assert(!_stream);
+
+ StdCWadFile file;
+ if (!file.open(name))
+ return false;
+
+ Common::SeekableReadStream *stream = file.readStream();
+ _size = stream->size();
+ _stream = Audio::makeWAVStream(stream->readStream(_size), DisposeAfterUse::YES);
+ _soundType = Audio::Mixer::kSFXSoundType;
+
+ return true;
+}
+
+bool CWaveFile::loadSpeech(CDialogueFile *dialogueFile, int speechIndex) {
+ DialogueResource *res = dialogueFile->openWaveEntry(speechIndex);
+ if (!res)
+ return false;
+
+ byte *data = (byte *)malloc(res->_size);
+ dialogueFile->read(res, data, res->_size);
+
+ _size = res->_size;
+ _stream = Audio::makeWAVStream(new Common::MemoryReadStream(data, _size, DisposeAfterUse::YES),
+ DisposeAfterUse::YES);
+ _soundType = Audio::Mixer::kSpeechSoundType;
+
+ return true;
+}
+
+bool CWaveFile::loadMusic(const CString &name) {
+ assert(!_stream);
+
+ StdCWadFile file;
+ if (!file.open(name))
+ return false;
+
+ Common::SeekableReadStream *stream = file.readStream();
+ _size = stream->size();
+ _stream = Audio::makeWAVStream(stream->readStream(_size), DisposeAfterUse::YES);
+ _soundType = Audio::Mixer::kMusicSoundType;
+
+ return true;
+}
+
+uint CWaveFile::getFrequency() const {
+ return _stream->getRate();
+}
+
+} // End of namespace Titanic z
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
new file mode 100644
index 0000000000..aede0c9328
--- /dev/null
+++ b/engines/titanic/sound/wave_file.h
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_WAVE_FILE_H
+#define TITANIC_WAVE_FILE_H
+
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "titanic/support/string.h"
+#include "titanic/true_talk/dialogue_file.h"
+
+namespace Titanic {
+
+class QSoundManager;
+
+class CWaveFile {
+private:
+ uint _size;
+public:
+ QSoundManager *_owner;
+ Audio::SeekableAudioStream *_stream;
+ Audio::SoundHandle _soundHandle;
+ Audio::Mixer::SoundType _soundType;
+public:
+ CWaveFile();
+ CWaveFile(QSoundManager *owner);
+ ~CWaveFile();
+
+ int fn1();
+
+ /**
+ * Return the size of the wave file
+ */
+ uint size() const { return _size; }
+
+ /**
+ * Tries to load the specified wave file sound
+ */
+ bool loadSound(const CString &name);
+
+ /**
+ * Tries to load speech from a specified dialogue file
+ */
+ bool loadSpeech(CDialogueFile *dialogueFile, int speechIndex);
+
+ /**
+ * Tries to load the specified music wave file
+ */
+ bool loadMusic(const CString &name);
+
+ /**
+ * Returns true if the wave file has data loaded
+ */
+ bool isLoaded() const { return _stream != nullptr; }
+
+ /**
+ * Return the frequency of the loaded wave file
+ */
+ uint getFrequency() const;
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_WAVE_FILE_H */