scummvm/engines/xeen/sound.h
Paul Gilbert 8fc4a08e04 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
2018-02-19 10:17:33 -05:00

164 lines
3.4 KiB
C++

/* 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 XEEN_SOUND_H
#define XEEN_SOUND_H
#include "audio/mixer.h"
#include "audio/audiostream.h"
#include "xeen/files.h"
#include "xeen/sound_driver.h"
namespace Xeen {
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(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);
/**
* Play a given sound
*/
void playSound(const Common::String &name, int unused = 0);
/**
* Play a given sound
*/
void playSound(const Common::String &name, int ccNum, int unused);
/**
* 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 file is currently playing
* @remarks In the original, passing 0 to playSound returned play status
*/
bool isSoundPlaying() const;
/**
* Stops all playing music, FX, and sound samples
*/
void stopAllAudio();
};
} // End of namespace Xeen
#endif /* XEEN_SOUND_H */