aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/sound.h
diff options
context:
space:
mode:
authorPaul Gilbert2018-02-19 10:17:33 -0500
committerPaul Gilbert2018-02-19 10:17:33 -0500
commit8fc4a08e04b947bc1ca01e716a7821fe41a03381 (patch)
tree49cba47520192e985e3b3a306c849d5d489d4933 /engines/xeen/sound.h
parent99c072e84495492a66e562a8dc0af6b39bf37d52 (diff)
downloadscummvm-rg350-8fc4a08e04b947bc1ca01e716a7821fe41a03381.tar.gz
scummvm-rg350-8fc4a08e04b947bc1ca01e716a7821fe41a03381.tar.bz2
scummvm-rg350-8fc4a08e04b947bc1ca01e716a7821fe41a03381.zip
XEEN: Refactor to merge Sound and Music classes
The existing structure didn't make sense, as Sound only handled sound files, but Music handled both music and short FX decoding. I've merged Sound & MUsic into a single Sound class, and moved the music driver to their own file, renamed to SoundDriver
Diffstat (limited to 'engines/xeen/sound.h')
-rw-r--r--engines/xeen/sound.h110
1 files changed, 91 insertions, 19 deletions
diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h
index f474063785..ab71af9b43 100644
--- a/engines/xeen/sound.h
+++ b/engines/xeen/sound.h
@@ -25,24 +25,107 @@
#include "audio/mixer.h"
#include "audio/audiostream.h"
-//#include "common/scummsys.h"
-//#include "common/system.h"
#include "xeen/files.h"
-#include "xeen/music.h"
+#include "xeen/sound_driver.h"
namespace Xeen {
-class Sound : public Music {
+
+class Sound {
private:
+ SoundDriver *_SoundDriver;
+ const byte *_effectsData;
+ Common::Array<uint16> _effectsOffsets;
+ const byte *_songData;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
+private:
+ /**
+ * Loads effects data that was embedded in the music driver
+ */
+ void loadEffectsData();
+
+ /**
+ * Updates any playing music
+ */
+ void update();
public:
bool _soundOn;
+ bool _musicOn;
+ Common::String _currentMusic, _priorMusic;
+ int _musicSide;
public:
- Sound(XeenEngine *vm, Audio::Mixer *mixer);
+ Sound(Audio::Mixer *mixer);
virtual ~Sound();
/**
+ * Starts an effect playing
+ */
+ void playFX(uint effectId);
+
+ /**
+ * Stops any currently playing FX
+ */
+ void stopFX();
+
+ /**
+ * Executes special music command
+ */
+ int songCommand(uint commandId, byte volume = 0);
+
+ /**
+ * Stops any currently playing music
+ */
+ void stopSong() { songCommand(STOP_SONG); }
+
+ /**
+ * Restart a previously playing song (which must still be loaded)
+ */
+ void restartSong() { songCommand(RESTART_SONG); }
+
+ /**
+ * Sets the music volume
+ */
+ void setMusicVolume(byte volume) { songCommand(SET_VOLUME, volume); }
+
+ /**
+ * Plays a song
+ */
+ void playSong(Common::SeekableReadStream &stream);
+
+ /**
+ * Plays a song
+ */
+ void playSong(const Common::String &name, int param = 0);
+
+ /**
+ * Plays a song
+ */
+ void playSong(const byte *data) {
+ _SoundDriver->playSong(data);
+ }
+
+ /**
+ * Returns true if music is playing
+ */
+ bool isMusicPlaying() const;
+
+ /**
+ * Sets whether music is on
+ */
+ void setMusicOn(bool isOn);
+
+ /**
+ * Sets whether sound effects is on
+ */
+ void setEffectsOn(bool isOn);
+
+ /**
+ * Called to reload sound settings
+ */
+ void updateSoundSettings();
+
+ /**
* Play a given sound
*/
void playSound(Common::SeekableReadStream &s, int unused = 0);
@@ -58,32 +141,21 @@ public:
void playSound(const Common::String &name, int ccNum, int unused);
/**
- * Stop playing a sound
+ * Stop playing a sound loaded from a .m file
* @remarks In the original, passing 1 to playSound stopped the sound
*/
void stopSound();
/**
- * Returns true if a sound is currently playing
+ * Returns true if a sound file is currently playing
* @remarks In the original, passing 0 to playSound returned play status
*/
- bool isPlaying() const;
+ bool isSoundPlaying() const;
/**
* Stops all playing music, FX, and sound samples
*/
void stopAllAudio();
-
- /**
- * Sets whether sound effects is on
- */
- void setEffectsOn(bool isOn);
-
- /**
- * Called to reload sound settings
- */
- virtual void updateSoundSettings();
-
};
} // End of namespace Xeen