Skip to content

Commit

Permalink
TITANIC: Cleanup of music instrument settings code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 29, 2017
1 parent e7446ad commit 5095f4c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 52 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/gfx/music_control.cpp
Expand Up @@ -45,7 +45,7 @@ void CMusicControl::save(SimpleFile *file, int indent) {

void CMusicControl::load(SimpleFile *file) {
file->readNumber();
_controlArea = (MusicControlArea)file->readNumber();
_controlArea = (MusicInstrument)file->readNumber();
_controlVal = file->readNumber();
_controlMax = file->readNumber();
_enabled = file->readNumber();
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/gfx/music_control.h
Expand Up @@ -33,7 +33,7 @@ class CMusicControl : public CBackground {
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
public:
MusicControlArea _controlArea;
MusicInstrument _controlArea;
int _controlVal;
int _controlMax;
bool _enabled;
Expand Down
6 changes: 4 additions & 2 deletions engines/titanic/sound/music_room.cpp
Expand Up @@ -54,6 +54,7 @@ void CMusicRoom::destroyMusicHandler() {

void CMusicRoom::setupMusic(int volume) {
if (_musicHandler) {
// Set up the control values that form the correct settings
_musicHandler->setSpeedControl2(BELLS, 0);
_musicHandler->setSpeedControl2(SNAKE, 1);
_musicHandler->setSpeedControl2(PIANO, -1);
Expand All @@ -74,8 +75,9 @@ void CMusicRoom::setupMusic(int volume) {
_musicHandler->setDirectionControl2(PIANO, 1);
_musicHandler->setDirectionControl2(BASS, 1);

for (MusicControlArea idx = BELLS; idx <= BASS;
idx = (MusicControlArea)((int)idx + 1)) {
// Set up the current control values
for (MusicInstrument idx = BELLS; idx <= BASS;
idx = (MusicInstrument)((int)idx + 1)) {
Controls &controls = _controls[idx];
_musicHandler->setSpeedControl(idx, controls._speedControl);
_musicHandler->setPitchControl(idx, controls._pitchControl);
Expand Down
29 changes: 24 additions & 5 deletions engines/titanic/sound/music_room.h
Expand Up @@ -63,11 +63,30 @@ class CMusicRoom {
*/
void destroyMusicHandler();

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; }
/**
* Sets the speed control for a given instrument
*/
void setSpeedControl(MusicInstrument instrument, int val) { _controls[instrument]._speedControl = val; }

/**
* Sets the pitch control for a given instrument
*/
void setPitchControl(MusicInstrument instrument, int val) { _controls[instrument]._pitchControl = val; }

/**
* Sets the direction control for a given instrument
*/
void setDirectionControl(MusicInstrument instrument, int val) { _controls[instrument]._directionControl = val; }

/**
* Sets the inversion control for a given instrument
*/
void setInversionControl(MusicInstrument instrument, int val) { _controls[instrument]._inversionControl = val; }

/**
* Sets the mute control for a given instrument
*/
void setMuteControl(MusicInstrument instrument, int val) { _controls[instrument]._muteControl = val; }

/**
* Sets up the music controls
Expand Down
56 changes: 28 additions & 28 deletions engines/titanic/sound/music_room_handler.cpp
Expand Up @@ -85,54 +85,54 @@ void CMusicRoomHandler::stop() {
}
}

bool CMusicRoomHandler::checkInstrument(MusicControlArea area) const {
bool CMusicRoomHandler::checkInstrument(MusicInstrument instrument) const {
// TODO
return false;
}

void CMusicRoomHandler::setSpeedControl2(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array2[area]._speedControl = value;
void CMusicRoomHandler::setSpeedControl2(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array2[instrument]._speedControl = value;
}

void CMusicRoomHandler::setPitchControl2(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array2[area]._pitchControl = value * 3;
void CMusicRoomHandler::setPitchControl2(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array2[instrument]._pitchControl = value * 3;
}

void CMusicRoomHandler::setInversionControl2(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array2[area]._inversionControl = value;
void CMusicRoomHandler::setInversionControl2(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array2[instrument]._inversionControl = value;
}

void CMusicRoomHandler::setDirectionControl2(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array2[area]._directionControl = value;
void CMusicRoomHandler::setDirectionControl2(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array2[instrument]._directionControl = value;
}

void CMusicRoomHandler::setPitchControl(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array1[area]._pitchControl = value;
void CMusicRoomHandler::setPitchControl(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array1[instrument]._pitchControl = value;
}

void CMusicRoomHandler::setSpeedControl(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array1[area]._speedControl = value;
void CMusicRoomHandler::setSpeedControl(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array1[instrument]._speedControl = value;
}

void CMusicRoomHandler::setDirectionControl(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array1[area]._directionControl = value;
void CMusicRoomHandler::setDirectionControl(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array1[instrument]._directionControl = value;
}

void CMusicRoomHandler::setInversionControl(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array1[area]._inversionControl = value;
void CMusicRoomHandler::setInversionControl(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array1[instrument]._inversionControl = value;
}

void CMusicRoomHandler::setMuteControl(MusicControlArea area, int value) {
if (area >= 0 && area <= 3 && value >= -2 && value <= 2)
_array1[area]._muteControl = value;
void CMusicRoomHandler::setMuteControl(MusicInstrument instrument, int value) {
if (instrument >= BELLS && instrument <= BASS && value >= -2 && value <= 2)
_array1[instrument]._muteControl = value;
}

bool CMusicRoomHandler::isBusy() {
Expand Down
49 changes: 34 additions & 15 deletions engines/titanic/sound/music_room_handler.h
Expand Up @@ -31,7 +31,7 @@ namespace Titanic {
class CProjectItem;
class CSoundManager;

enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 };
enum MusicInstrument { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 };

class CMusicRoomHandler {
struct Controls {
Expand Down Expand Up @@ -95,33 +95,52 @@ class CMusicRoomHandler {
/**
* Checks the specified instrument to see if it's settings are "correct"
*/
bool checkInstrument(MusicControlArea area) const;
bool checkInstrument(MusicInstrument instrument) const;

/**
* Set a setting
* Sets the speed control value
*/
void setSpeedControl2(MusicControlArea area, int value);
void setSpeedControl2(MusicInstrument instrument, int value);

/**
* Set a setting
* Sets the pitch control value
*/
void setPitchControl2(MusicControlArea area, int value);
void setPitchControl2(MusicInstrument instrument, int value);

/**
* Set a setting
* Sets the inversion control value
*/
void setInversionControl2(MusicControlArea area, int value);
void setInversionControl2(MusicInstrument instrument, int value);

/**
* Set a setting
* Sets the direction control value
*/
void setDirectionControl2(MusicControlArea area, int value);
void setDirectionControl2(MusicInstrument instrument, 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);
/**
* Sets the pitch control value
*/
void setPitchControl(MusicInstrument instrument, int value);

/**
* Sets the speed control value
*/
void setSpeedControl(MusicInstrument instrument, int value);

/**
* Sets the direction control value
*/
void setDirectionControl(MusicInstrument instrument, int value);

/**
* Sets the inversion control value
*/
void setInversionControl(MusicInstrument instrument, int value);

/**
* Sets the mute control value
*/
void setMuteControl(MusicInstrument instrument, int value);
};

} // End of namespace Titanic
Expand Down

0 comments on commit 5095f4c

Please sign in to comment.