diff options
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r-- | engines/titanic/sound/music_handler.cpp | 57 | ||||
-rw-r--r-- | engines/titanic/sound/music_handler.h | 55 | ||||
-rw-r--r-- | engines/titanic/sound/music_player.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/sound/music_room.cpp | 38 | ||||
-rw-r--r-- | engines/titanic/sound/music_room.h | 31 | ||||
-rw-r--r-- | engines/titanic/sound/qmixer.cpp | 5 |
6 files changed, 163 insertions, 25 deletions
diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp index 07c3994334..e2f2ce8dec 100644 --- a/engines/titanic/sound/music_handler.cpp +++ b/engines/titanic/sound/music_handler.cpp @@ -28,12 +28,15 @@ namespace Titanic { CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) : _project(project), _soundManager(soundManager), _stopWaves(false), - _soundHandle(-1), _waveFile(nullptr) { + _soundHandle(-1), _waveFile(nullptr), _soundVolume(100), _ticks(0), + _field108(0) { Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr); } CMusicHandler::~CMusicHandler() { stop(); + for (int idx = 0; idx < 4; ++idx) + delete _musicWaves[idx]; } CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) { @@ -58,7 +61,12 @@ CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) { return _musicWaves[waveIndex]; } -bool CMusicHandler::isBusy() { +void CMusicHandler::createWaveFile(int musicVolume) { + _soundVolume = musicVolume; +// _waveFile = _soundManager->loadMusic() +} + +bool CMusicHandler::poll() { // TODO return false; } @@ -82,4 +90,49 @@ bool CMusicHandler::checkSound(int index) const { return false; } +void CMusicHandler::setSpeedControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._speedControl = value; +} + +void CMusicHandler::setPitchControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._pitchControl = value * 3; +} + +void CMusicHandler::setInversionControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._inversionControl = value; +} + +void CMusicHandler::setDirectionControl2(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array2[area]._directionControl = value; +} + +void CMusicHandler::setPitchControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._pitchControl = value; +} + +void CMusicHandler::setSpeedControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._speedControl = value; +} + +void CMusicHandler::setDirectionControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._directionControl = value; +} + +void CMusicHandler::setInversionControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._inversionControl = value; +} + +void CMusicHandler::setMuteControl(MusicControlArea area, int value) { + if (area >= 0 && area <= 3 && value >= -2 && value <= 2) + _array1[area]._muteControl = value; +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h index 6792844cb5..27b429d523 100644 --- a/engines/titanic/sound/music_handler.h +++ b/engines/titanic/sound/music_handler.h @@ -31,14 +31,36 @@ namespace Titanic { class CProjectItem; class CSoundManager; +enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 }; + class CMusicHandler { + struct Controls { + int _pitchControl; + int _speedControl; + int _directionControl; + int _inversionControl; + int _muteControl; + Controls() : _pitchControl(0), _speedControl(0), _directionControl(0), + _inversionControl(0), _muteControl(0) {} + }; + struct Array5Entry { + int _v1; + int _v2; + Array5Entry() : _v1(0), _v2(0) {} + }; private: CProjectItem *_project; CSoundManager *_soundManager; CMusicWave *_musicWaves[4]; + Controls _array1[4]; + Controls _array2[4]; + Array5Entry _array5[4]; bool _stopWaves; CWaveFile *_waveFile; int _soundHandle; + int _soundVolume; + uint _ticks; + int _field108; public: CMusicHandler(CProjectItem *project, CSoundManager *soundManager); ~CMusicHandler(); @@ -51,7 +73,12 @@ public: */ CMusicWave *createMusicWave(int waveIndex, int count); - bool isBusy(); + void createWaveFile(int musicVolume); + + /** + * Handles regular polling the music handler + */ + bool poll(); /** * Flags whether the loaded music waves will be stopped when the @@ -65,6 +92,32 @@ public: void stop(); bool checkSound(int index) const; + + /** + * Set a setting + */ + void setSpeedControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setPitchControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setInversionControl2(MusicControlArea area, int value); + + /** + * Set a setting + */ + void setDirectionControl2(MusicControlArea area, int value); + + void setPitchControl(MusicControlArea area, int value); + void setSpeedControl(MusicControlArea area, int value); + void setDirectionControl(MusicControlArea area, int value); + void setInversionControl(MusicControlArea area, int value); + void setMuteControl(MusicControlArea area, int value); }; } // End of namespace Titanic diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp index cd764c7f93..9106160d1f 100644 --- a/engines/titanic/sound/music_player.cpp +++ b/engines/titanic/sound/music_player.cpp @@ -97,7 +97,7 @@ bool CMusicPlayer::StopMusicMsg(CStopMusicMsg *msg) { } bool CMusicPlayer::FrameMsg(CFrameMsg *msg) { - if (_isActive && !CMusicRoom::_musicHandler->isBusy()) { + if (_isActive && !CMusicRoom::_musicHandler->poll()) { getMusicRoom()->stopMusic(); _isActive = false; diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp index 2e4ad904fa..29772cc65f 100644 --- a/engines/titanic/sound/music_room.cpp +++ b/engines/titanic/sound/music_room.cpp @@ -32,7 +32,7 @@ CMusicHandler *CMusicRoom::_musicHandler; CMusicRoom::CMusicRoom(CGameManager *gameManager) : _gameManager(gameManager) { _sound = &_gameManager->_sound; - _items.resize(4); + _controls.resize(4); } CMusicRoom::~CMusicRoom() { @@ -52,8 +52,40 @@ void CMusicRoom::destroyMusicHandler() { _musicHandler = nullptr; } -void CMusicRoom::startMusic(int musicId) { - // TODO +void CMusicRoom::startMusic(int volume) { + if (_musicHandler) { + _musicHandler->setSpeedControl2(BELLS, 0); + _musicHandler->setSpeedControl2(SNAKE, 1); + _musicHandler->setSpeedControl2(PIANO, -1); + _musicHandler->setSpeedControl2(BASS, -2); + + _musicHandler->setPitchControl2(BELLS, 1); + _musicHandler->setPitchControl2(SNAKE, 2); + _musicHandler->setPitchControl2(PIANO, 0); + _musicHandler->setPitchControl2(BELLS, 1); + + _musicHandler->setInversionControl2(BELLS, 1); + _musicHandler->setInversionControl2(SNAKE, 0); + _musicHandler->setInversionControl2(PIANO, 1); + _musicHandler->setInversionControl2(BASS, 0); + + _musicHandler->setDirectionControl2(BELLS, 0); + _musicHandler->setDirectionControl2(SNAKE, 0); + _musicHandler->setDirectionControl2(PIANO, 1); + _musicHandler->setDirectionControl2(BASS, 1); + + for (MusicControlArea idx = BELLS; idx <= BASS; + idx = (MusicControlArea)((int)idx + 1)) { + Controls &controls = _controls[idx]; + _musicHandler->setSpeedControl(idx, controls._speedControl); + _musicHandler->setPitchControl(idx, controls._pitchControl); + _musicHandler->setDirectionControl(idx, controls._directionControl); + _musicHandler->setInversionControl(idx, controls._inversionControl); + _musicHandler->setMuteControl(idx, controls._muteControl); + } + + _musicHandler->createWaveFile(volume); + } } void CMusicRoom::stopMusic() { diff --git a/engines/titanic/sound/music_room.h b/engines/titanic/sound/music_room.h index 5f0b271ab3..74f28acd29 100644 --- a/engines/titanic/sound/music_room.h +++ b/engines/titanic/sound/music_room.h @@ -31,20 +31,19 @@ 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; + struct Controls { + int _speedControl; + int _pitchControl; + int _directionControl; + int _inversionControl; + int _muteControl; - Entry() : _val1(0), _val2(0), _val3(0), _val4(0), _val5(0) {} + Controls() : _speedControl(0), _pitchControl(0), _directionControl(0), + _inversionControl(0), _muteControl(0) {} }; private: - Common::Array<Entry> _items; + Common::Array<Controls> _controls; public: static CMusicHandler *_musicHandler; public: @@ -64,16 +63,16 @@ public: */ 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; } + void setSpeedControl(MusicControlArea index, int val) { _controls[index]._speedControl = val; } + void setPitchControl(MusicControlArea index, int val) { _controls[index]._pitchControl = val; } + void setDirectionControl(MusicControlArea index, int val) { _controls[index]._directionControl = val; } + void setInversionControl(MusicControlArea index, int val) { _controls[index]._inversionControl = val; } + void setMuteControl(MusicControlArea index, int val) { _controls[index]._muteControl = val; } /** * Start playing a given music number */ - void startMusic(int musicId); + void startMusic(int volume = 100); /** * Stop playing music diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp index 145d142b2d..b5eb6d0b5c 100644 --- a/engines/titanic/sound/qmixer.cpp +++ b/engines/titanic/sound/qmixer.cpp @@ -67,7 +67,8 @@ void QMixer::qsWaveMixSetPanRate(int iChannel, uint flags, uint rate) { } void QMixer::qsWaveMixSetVolume(int iChannel, uint flags, uint volume) { - // Not currently implemented in ScummVM + + } void QMixer::qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position) { @@ -170,4 +171,4 @@ void QMixer::qsWaveMixPump() { } } -} // End of namespace Titanic z +} // End of namespace Titanic |