2015-02-06 14:31:43 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-08-24 21:43:47 +00:00
|
|
|
#ifndef BLADERUNNER_AUDIO_PLAYER_H
|
|
|
|
#define BLADERUNNER_AUDIO_PLAYER_H
|
2015-02-06 14:31:43 +00:00
|
|
|
|
2015-02-10 16:51:16 +00:00
|
|
|
#include "common/array.h"
|
|
|
|
#include "common/mutex.h"
|
2015-02-06 14:31:43 +00:00
|
|
|
#include "common/str.h"
|
2018-01-14 11:12:06 +00:00
|
|
|
|
2017-09-10 18:19:02 +00:00
|
|
|
#include "audio/audiostream.h"
|
2019-02-10 15:53:25 +00:00
|
|
|
#include "audio/mixer.h"
|
2015-02-06 14:31:43 +00:00
|
|
|
|
|
|
|
namespace BladeRunner {
|
|
|
|
|
|
|
|
class BladeRunnerEngine;
|
|
|
|
class AudioCache;
|
2020-02-17 22:52:47 +00:00
|
|
|
class AudStream;
|
2015-02-06 14:31:43 +00:00
|
|
|
|
2018-02-10 19:34:28 +00:00
|
|
|
enum AudioPlayerFlags {
|
|
|
|
kAudioPlayerLoop = 1,
|
|
|
|
kAudioPlayerOverrideVolume = 2
|
|
|
|
};
|
|
|
|
|
2015-02-06 14:31:43 +00:00
|
|
|
class AudioPlayer {
|
2019-03-27 13:11:31 +00:00
|
|
|
#if BLADERUNNER_ORIGINAL_BUGS
|
|
|
|
static const int kTracks = 6;
|
|
|
|
#else
|
2020-02-17 22:52:47 +00:00
|
|
|
// increase tracks, reduce probability of tracks being skipped
|
2019-03-27 13:11:31 +00:00
|
|
|
static const int kTracks = 12;
|
|
|
|
#endif // BLADERUNNER_ORIGINAL_BUGS
|
2015-02-06 14:31:43 +00:00
|
|
|
|
|
|
|
struct Track {
|
2017-09-10 18:19:02 +00:00
|
|
|
bool isActive;
|
|
|
|
int channel;
|
|
|
|
int priority;
|
|
|
|
int volume;
|
|
|
|
int pan;
|
2020-02-17 22:52:47 +00:00
|
|
|
AudStream *stream;
|
2015-02-06 14:31:43 +00:00
|
|
|
};
|
|
|
|
|
2017-08-24 21:43:47 +00:00
|
|
|
BladeRunnerEngine *_vm;
|
2015-02-06 14:31:43 +00:00
|
|
|
|
2017-08-24 21:43:47 +00:00
|
|
|
Common::Mutex _mutex;
|
|
|
|
Track _tracks[kTracks];
|
|
|
|
int _sfxVolume;
|
2015-02-06 14:31:43 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
AudioPlayer(BladeRunnerEngine *vm);
|
|
|
|
~AudioPlayer();
|
|
|
|
|
2019-02-10 15:53:25 +00:00
|
|
|
int playAud(const Common::String &name, int volume, int panStart, int panEnd, int priority, byte flags = 0, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
|
2018-01-14 11:12:06 +00:00
|
|
|
bool isActive(int track) const;
|
2020-02-17 22:52:47 +00:00
|
|
|
uint32 getLength(int track) const;
|
2017-08-24 21:43:47 +00:00
|
|
|
void stop(int track, bool immediately);
|
2015-02-06 14:31:43 +00:00
|
|
|
void stopAll();
|
2019-07-17 16:08:43 +00:00
|
|
|
void adjustVolume(int track, int volume, uint32 delay, bool overrideVolume);
|
|
|
|
void adjustPan(int track, int pan, uint32 delay);
|
2017-08-24 21:43:47 +00:00
|
|
|
|
2018-01-14 11:12:06 +00:00
|
|
|
void setVolume(int volume);
|
|
|
|
int getVolume() const;
|
|
|
|
void playSample();
|
|
|
|
|
2017-08-24 21:43:47 +00:00
|
|
|
private:
|
|
|
|
void remove(int channel);
|
|
|
|
static void mixerChannelEnded(int channel, void *data);
|
2015-02-06 14:31:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace BladeRunner
|
|
|
|
|
|
|
|
#endif
|