aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound
diff options
context:
space:
mode:
authorPaul Gilbert2017-02-12 21:00:31 -0500
committerPaul Gilbert2017-02-12 21:00:31 -0500
commitbb840c9ec205d4c6a94d73c107f520d557983791 (patch)
tree121e17ab3572437c443a107503ff32959a18807f /engines/titanic/sound
parent2c8d72afd70d9cb40daafec5d3b2947ba33fe2e2 (diff)
downloadscummvm-rg350-bb840c9ec205d4c6a94d73c107f520d557983791.tar.gz
scummvm-rg350-bb840c9ec205d4c6a94d73c107f520d557983791.tar.bz2
scummvm-rg350-bb840c9ec205d4c6a94d73c107f520d557983791.zip
TITANIC: More renamings in music classes
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r--engines/titanic/sound/music_room_handler.cpp56
-rw-r--r--engines/titanic/sound/music_room_handler.h13
-rw-r--r--engines/titanic/sound/music_room_instrument.cpp12
-rw-r--r--engines/titanic/sound/music_room_instrument.h2
-rw-r--r--engines/titanic/sound/music_song.cpp (renamed from engines/titanic/sound/music_object.cpp)26
-rw-r--r--engines/titanic/sound/music_song.h (renamed from engines/titanic/sound/music_object.h)20
6 files changed, 67 insertions, 62 deletions
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index df2bc54dec..1373f200e7 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -35,9 +35,9 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound
_startTicks = _soundStartTicks = 0;
Common::fill(&_instruments[0], &_instruments[4], (CMusicRoomInstrument *)nullptr);
for (int idx = 0; idx < 4; ++idx)
- _musicObjs[idx] = new CMusicObject(idx);
+ _songs[idx] = new CMusicSong(idx);
Common::fill(&_startPos[0], &_startPos[4], 0);
- Common::fill(&_array5[0], &_array5[4], 0.0);
+ Common::fill(&_animTime[0], &_animTime[4], 0.0);
Common::fill(&_position[0], &_position[4], 0);
_audioBuffer = new CAudioBuffer(88200);
@@ -46,7 +46,7 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound
CMusicRoomHandler::~CMusicRoomHandler() {
stop();
for (int idx = 0; idx < 4; ++idx)
- delete _musicObjs[idx];
+ delete _songs[idx];
delete _audioBuffer;
}
@@ -84,11 +84,11 @@ void CMusicRoomHandler::setup(int volume) {
if (ins1._directionControl == ins2._directionControl) {
_startPos[idx] = 0;
} else {
- _startPos[idx] = _musicObjs[idx]->size() - 1;
+ _startPos[idx] = _songs[idx]->size() - 1;
}
_position[idx] = _startPos[idx];
- _array5[idx] = 0.0;
+ _animTime[idx] = 0.0;
}
_field108 = 4;
@@ -246,18 +246,18 @@ void CMusicRoomHandler::updateInstruments() {
CMusicRoomInstrument *ins = _instruments[instrument];
// Is this about checking playback position?
- if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _musicObjs[instrument]->size()) {
+ if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _songs[instrument]->size()) {
_position[instrument] = -1;
continue;
}
uint ticks = g_vm->_events->getTicksCount() - _soundStartTicks;
- double val = (double)ticks * 0.001 - 0.6;
+ double time = (double)ticks * 0.001 - 0.6;
- if (val >= (ins->_floatVal - _array5[instrument])) {
- _array5[instrument] += fn3(instrument, _position[instrument]);
+ if (time >= (ins->_animTime - _animTime[instrument])) {
+ _animTime[instrument] += getAnimDuration(instrument, _position[instrument]);
- const CValuePair &vp = (*_musicObjs[instrument])[_position[instrument]];
+ const CValuePair &vp = (*_songs[instrument])[_position[instrument]];
if (vp._field0 != 0x7FFFFFFF) {
int amount = getPitch(instrument, _position[instrument]);
_instruments[instrument]->update(amount);
@@ -280,20 +280,20 @@ bool CMusicRoomHandler::pollInstrument(MusicInstrument instrument) {
return false;
}
- const CMusicObject &mObj = *_musicObjs[instrument];
- if (arrIndex >= mObj.size()) {
+ const CMusicSong &song = *_songs[instrument];
+ if (arrIndex >= song.size()) {
arrIndex = -1;
_instruments[instrument]->clear();
return false;
}
- const CValuePair &vp = mObj[arrIndex];
- int size = static_cast<int>(fn3(instrument, arrIndex) * 44100.0) & ~1;
+ const CValuePair &vp = song[arrIndex];
+ uint duration = static_cast<int>(getAnimDuration(instrument, arrIndex) * 44100.0) & ~1;
if (vp._field0 == 0x7FFFFFFF || _array1[instrument]._muteControl)
- _instruments[instrument]->reset(size);
+ _instruments[instrument]->reset(duration);
else
- _instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), size);
+ _instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), duration);
if (_array1[instrument]._directionControl == _array2[instrument]._directionControl) {
++arrIndex;
@@ -304,36 +304,36 @@ bool CMusicRoomHandler::pollInstrument(MusicInstrument instrument) {
return true;
}
-double CMusicRoomHandler::fn3(MusicInstrument instrument, int arrIndex) {
- const CValuePair &vp = (*_musicObjs[instrument])[arrIndex];
+double CMusicRoomHandler::getAnimDuration(MusicInstrument instrument, int arrIndex) {
+ const CValuePair &vp = (*_songs[instrument])[arrIndex];
switch (_array1[instrument]._speedControl + _array2[instrument]._speedControl + 3) {
case 0:
- return (double)vp._field4 * 1.5 * 0.0625 * 0.46875;
+ return (double)vp._length * 1.5 * 0.0625 * 0.46875;
case 1:
- return (double)vp._field4 * 1.33 * 0.0625 * 0.46875;
+ return (double)vp._length * 1.33 * 0.0625 * 0.46875;
case 2:
- return (double)vp._field4 * 1.25 * 0.0625 * 0.46875;
+ return (double)vp._length * 1.25 * 0.0625 * 0.46875;
case 4:
- return (double)vp._field4 * 0.75 * 0.0625 * 0.46875;
+ return (double)vp._length * 0.75 * 0.0625 * 0.46875;
case 5:
- return (double)vp._field4 * 0.67 * 0.0625 * 0.46875;
+ return (double)vp._length * 0.67 * 0.0625 * 0.46875;
case 6:
- return (double)vp._field4 * 0.5 * 0.0625 * 0.46875;
+ return (double)vp._length * 0.5 * 0.0625 * 0.46875;
default:
- return (double)vp._field4 * 1.0 * 0.0625 * 0.46875;
+ return (double)vp._length * 1.0 * 0.0625 * 0.46875;
}
}
int CMusicRoomHandler::getPitch(MusicInstrument instrument, int arrIndex) {
- const CMusicObject &mObj = *_musicObjs[instrument];
- const CValuePair &vp = mObj[arrIndex];
+ const CMusicSong &song = *_songs[instrument];
+ const CValuePair &vp = song[arrIndex];
int val = vp._field0;
const MusicRoomInstrument &ins1 = _array1[instrument];
const MusicRoomInstrument &ins2 = _array2[instrument];
if (ins1._inversionControl != ins2._inversionControl) {
- val = mObj._minVal * 2 + mObj._range - val;
+ val = song._minVal * 2 + song._range - val;
}
val += ins1._pitchControl + ins2._pitchControl;
diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h
index 34d2b95740..9222a9248d 100644
--- a/engines/titanic/sound/music_room_handler.h
+++ b/engines/titanic/sound/music_room_handler.h
@@ -24,8 +24,8 @@
#define TITANIC_MUSIC_ROOM_HANDLER_H
#include "titanic/sound/audio_buffer.h"
-#include "titanic/sound/music_object.h"
#include "titanic/sound/music_room_instrument.h"
+#include "titanic/sound/music_song.h"
#include "titanic/sound/wave_file.h"
namespace Titanic {
@@ -52,10 +52,10 @@ private:
CMusicRoomInstrument *_instruments[4];
MusicRoomInstrument _array1[4];
MusicRoomInstrument _array2[4];
- CMusicObject *_musicObjs[4];
+ CMusicSong *_songs[4];
int _startPos[4];
int _position[4];
- double _array5[4];
+ double _animTime[4];
bool _active;
CWaveFile *_waveFile;
@@ -89,7 +89,12 @@ private:
*/
bool pollInstrument(MusicInstrument instrument);
- double fn3(MusicInstrument instrument, int arrIndex);
+ /**
+ * Gets the duration for a given fragment of an instrument to play
+ * out, so that animations of the instruments can be synchronized
+ * to the actual music
+ */
+ double getAnimDuration(MusicInstrument instrument, int arrIndex);
/**
* Figures out a pitch value (of some sort) for use in determining
diff --git a/engines/titanic/sound/music_room_instrument.cpp b/engines/titanic/sound/music_room_instrument.cpp
index 144f9d190b..5e7bd9bb8c 100644
--- a/engines/titanic/sound/music_room_instrument.cpp
+++ b/engines/titanic/sound/music_room_instrument.cpp
@@ -52,7 +52,7 @@ void CMusicRoomInstrument::deinit() {
CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager *soundManager, MusicWaveInstrument instrument) :
_project(project), _soundManager(soundManager), _instrument(instrument) {
Common::fill(&_gameObjects[0], &_gameObjects[4], (CGameObject *)nullptr);
- _floatVal = 0.0;
+ _animTime = 0.0;
_waveIndex = -1;
_readPos = 0;
_readIncrement = 0;
@@ -66,7 +66,7 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager
_gameObjects[1] = static_cast<CGameObject *>(_project->findByName("Piano Mouth"));
_gameObjects[2] = static_cast<CGameObject *>(_project->findByName("Piano Left Arm"));
_gameObjects[3] = static_cast<CGameObject *>(_project->findByName("Piano Right Arm"));
- _floatVal = 0.45;
+ _animTime = 0.45;
break;
case MV_BASS:
@@ -75,14 +75,14 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager
case MV_BELLS:
_gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Tubular Bells"));
- _floatVal = 0.4;
+ _animTime = 0.4;
break;
case MV_SNAKE:
_gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Snake_Hammer"));
_gameObjects[1] = static_cast<CGameObject *>(_project->findByName("Snake_Glass"));
_gameObjects[2] = static_cast<CGameObject *>(_project->findByName("Snake_Head"));
- _floatVal = 0.17;
+ _animTime = 0.17;
break;
}
}
@@ -212,12 +212,12 @@ void CMusicRoomInstrument::update(int val) {
case 60:
_gameObjects[0]->movieSetAudioTiming(true);
_gameObjects[0]->playMovie(0, 512, MOVIE_STOP_PREVIOUS);
- _floatVal = 0.6;
+ _animTime = 0.6;
break;
case 62:
_gameObjects[0]->playMovie(828, 1023, MOVIE_STOP_PREVIOUS);
- _floatVal = 0.3;
+ _animTime = 0.3;
break;
case 63:
diff --git a/engines/titanic/sound/music_room_instrument.h b/engines/titanic/sound/music_room_instrument.h
index d63fe93f20..d859fe2a0e 100644
--- a/engines/titanic/sound/music_room_instrument.h
+++ b/engines/titanic/sound/music_room_instrument.h
@@ -73,7 +73,7 @@ private:
*/
void setupArray(int minVal, int maxVal);
public:
- double _floatVal;
+ double _animTime;
public:
/**
* Handles initialization of static fields
diff --git a/engines/titanic/sound/music_object.cpp b/engines/titanic/sound/music_song.cpp
index d12b6eb403..5894f344af 100644
--- a/engines/titanic/sound/music_object.cpp
+++ b/engines/titanic/sound/music_song.cpp
@@ -20,22 +20,22 @@
*
*/
-#include "titanic/sound/music_object.h"
+#include "titanic/sound/music_song.h"
#include "titanic/titanic.h"
#include "common/util.h"
namespace Titanic {
-CMusicObject::CMusicObject(int index) {
- // Read in the list of parser strings
+CMusicSong::CMusicSong(int index) {
+ // Read in the list of song strings
Common::SeekableReadStream *res = g_vm->_filesManager->getResource("MUSIC/PARSER");
Common::StringArray parserStrings;
while (res->pos() < res->size())
parserStrings.push_back(readStringFromStream(res));
delete res;
- // Set up a new parser with the desired string
- CMusicParser parser(parserStrings[index].c_str());
+ // Set up a new song parser with the desired string
+ CSongParser parser(parserStrings[index].c_str());
// Count how many encoded values there are
CValuePair r;
@@ -67,7 +67,7 @@ CMusicObject::CMusicObject(int index) {
_range = maxVal - _minVal;
}
-CMusicObject::~CMusicObject() {
+CMusicSong::~CMusicSong() {
_data.clear();
}
@@ -75,12 +75,12 @@ CMusicObject::~CMusicObject() {
#define FETCH_CHAR _currentChar = _str[_strIndex++]
-CMusicParser::CMusicParser(const char *str) : _str(str), _strIndex(0),
+CSongParser::CSongParser(const char *str) : _str(str), _strIndex(0),
_field8(0), _priorChar('A'), _field10(32), _field14(0), _flag(false),
_field1C(0), _currentChar(' '), _numValue(1) {
}
-void CMusicParser::reset() {
+void CSongParser::reset() {
_strIndex = 0;
_field8 = 0;
_field10 = 0;
@@ -91,7 +91,7 @@ void CMusicParser::reset() {
_field1C = 0;
}
-bool CMusicParser::parse(CValuePair &r) {
+bool CSongParser::parse(CValuePair &r) {
const int INDEXES[8] = { 0, 2, 3, 5, 7, 8, 10, 0 };
while (_currentChar) {
@@ -114,7 +114,7 @@ bool CMusicParser::parse(CValuePair &r) {
_field8 = _numValue * 12;
FETCH_CHAR;
} else if (_currentChar == '/') {
- r._field4 += _field10;
+ r._length += _field10;
_field1C += _field10;
FETCH_CHAR;
} else if (_currentChar == '+') {
@@ -129,7 +129,7 @@ bool CMusicParser::parse(CValuePair &r) {
_flag = true;
r._field0 = 0x7FFFFFFF;
- r._field4 = _field10;
+ r._length = _field10;
_field14 = 0;
_field1C += _field10;
FETCH_CHAR;
@@ -161,7 +161,7 @@ bool CMusicParser::parse(CValuePair &r) {
}
if (flag) {
- r._field4 = _field10;
+ r._length = _field10;
_field1C += _field10;
_field8 = r._field0;
_priorChar = _currentChar;
@@ -183,7 +183,7 @@ bool CMusicParser::parse(CValuePair &r) {
return true;
}
-void CMusicParser::skipSpaces() {
+void CSongParser::skipSpaces() {
while (_currentChar && Common::isSpace(_currentChar)) {
FETCH_CHAR;
}
diff --git a/engines/titanic/sound/music_object.h b/engines/titanic/sound/music_song.h
index 6159a034d8..33ad95882c 100644
--- a/engines/titanic/sound/music_object.h
+++ b/engines/titanic/sound/music_song.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TITANIC_MUSIC_OBJECT_H
-#define TITANIC_MUSIC_OBJECT_H
+#ifndef TITANIC_MUSIC_SONG_H
+#define TITANIC_MUSIC_SONG_H
#include "common/scummsys.h"
#include "common/array.h"
@@ -30,25 +30,25 @@ namespace Titanic {
struct CValuePair {
int _field0;
- int _field4;
- CValuePair() : _field0(0), _field4(0) {}
+ int _length;
+ CValuePair() : _field0(0), _length(0) {}
};
-class CMusicObject {
+class CMusicSong {
public:
Common::Array<CValuePair> _data;
int _minVal;
int _range;
public:
- CMusicObject(int index);
- ~CMusicObject();
+ CMusicSong(int index);
+ ~CMusicSong();
int size() const { return _data.size(); }
const CValuePair &operator[](int index) const { return _data[index]; }
};
-class CMusicParser {
+class CSongParser {
private:
const char *_str;
uint _strIndex;
@@ -63,7 +63,7 @@ private:
private:
void skipSpaces();
public:
- CMusicParser(const char *str);
+ CSongParser(const char *str);
/**
* Resets the parser
@@ -78,4 +78,4 @@ public:
} // End of namespace Titanic
-#endif /* TITANIC_MUSIC_OBJECT_H */
+#endif /* TITANIC_MUSIC_SONG_H */