2012-01-26 12:11:43 +00:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
|
|
|
*
|
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* 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 SOUND_H_
|
|
|
|
#define SOUND_H_
|
|
|
|
|
|
|
|
#include "common/str.h"
|
|
|
|
|
|
|
|
namespace Myst3 {
|
|
|
|
|
|
|
|
class Myst3Engine;
|
|
|
|
|
2012-03-10 13:35:27 +00:00
|
|
|
enum SoundType {
|
|
|
|
kUnk0,
|
2014-03-01 13:03:35 +00:00
|
|
|
kAmbient,
|
2014-03-01 08:09:54 +00:00
|
|
|
kCue,
|
2012-03-10 13:35:27 +00:00
|
|
|
kEffect,
|
|
|
|
kMusic
|
|
|
|
};
|
|
|
|
|
2012-01-26 12:11:43 +00:00
|
|
|
class SoundChannel {
|
|
|
|
public:
|
|
|
|
SoundChannel(Myst3Engine *vm);
|
|
|
|
virtual ~SoundChannel();
|
|
|
|
|
2014-03-01 13:43:44 +00:00
|
|
|
void play(uint32 id, uint32 volume, uint16 heading, uint16 attenuation, bool loop, SoundType type);
|
2014-03-01 13:03:35 +00:00
|
|
|
void setVolume3D(uint32 volume, uint16 heading, uint16 attenuation);
|
2014-03-01 08:09:54 +00:00
|
|
|
void fade(uint32 targetVolume, int32 targetHeading, int32 targetAttenuation, uint32 fadeDelay);
|
2014-03-01 13:03:35 +00:00
|
|
|
void fadeOut(uint32 fadeDelay);
|
2012-01-26 12:11:43 +00:00
|
|
|
void update();
|
2014-03-01 08:09:54 +00:00
|
|
|
void stop();
|
2014-03-01 13:03:35 +00:00
|
|
|
void age(uint32 maxAge);
|
2012-01-26 12:11:43 +00:00
|
|
|
|
|
|
|
uint32 _id;
|
2012-03-10 13:35:27 +00:00
|
|
|
bool _playing;
|
2014-03-02 10:24:56 +00:00
|
|
|
bool _fading;
|
2012-03-10 13:35:27 +00:00
|
|
|
SoundType _type;
|
2014-03-01 13:03:35 +00:00
|
|
|
uint32 _age;
|
|
|
|
uint32 _ambientFadeOutDelay;
|
2012-01-26 12:11:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Myst3Engine *_vm;
|
|
|
|
|
|
|
|
Common::String _name;
|
2014-03-02 10:24:56 +00:00
|
|
|
|
2012-01-26 12:11:43 +00:00
|
|
|
uint32 _volume;
|
2014-03-02 10:24:56 +00:00
|
|
|
int32 _heading;
|
|
|
|
uint32 _headingAngle;
|
|
|
|
|
2014-03-01 13:03:35 +00:00
|
|
|
Audio::AudioStream *_stream;
|
2012-01-26 12:11:43 +00:00
|
|
|
Audio::SoundHandle _handle;
|
|
|
|
|
|
|
|
Audio::RewindableAudioStream *makeAudioStream(const Common::String &name) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Sound {
|
|
|
|
public:
|
|
|
|
Sound(Myst3Engine *vm);
|
|
|
|
virtual ~Sound();
|
|
|
|
|
2014-03-01 13:03:35 +00:00
|
|
|
SoundChannel *getChannelForSound(uint32 id, SoundType type, bool *found = nullptr);
|
|
|
|
|
2012-03-10 13:35:27 +00:00
|
|
|
void playEffect(uint32 id, uint32 volume, uint16 heading = 0, uint16 attenuation = 0);
|
2014-03-01 08:09:54 +00:00
|
|
|
|
|
|
|
void playCue(uint32 id, uint32 volume, uint16 heading, uint16 attenuation);
|
|
|
|
void stopCue(uint32 fadeDelay);
|
|
|
|
|
2012-01-26 12:11:43 +00:00
|
|
|
void update();
|
2014-03-01 13:03:35 +00:00
|
|
|
void age();
|
|
|
|
|
|
|
|
void fadeOutOldSounds(uint32 fadeDelay);
|
2012-01-26 12:11:43 +00:00
|
|
|
|
2014-03-02 10:24:56 +00:00
|
|
|
void compute3DVolumes(int32 heading, uint angle, int32 *left, int32 *right);
|
|
|
|
|
2012-01-26 12:11:43 +00:00
|
|
|
private:
|
2014-03-01 08:09:54 +00:00
|
|
|
static const uint kNumChannels = 14;
|
2012-01-26 12:11:43 +00:00
|
|
|
|
|
|
|
Myst3Engine *_vm;
|
|
|
|
SoundChannel *_channels[kNumChannels];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace Myst3 */
|
|
|
|
#endif /* SOUND_H_ */
|