ScummVM API documentation
audio_player.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BLADERUNNER_AUDIO_PLAYER_H
23#define BLADERUNNER_AUDIO_PLAYER_H
24
25#include "common/array.h"
26#include "common/mutex.h"
27#include "common/str.h"
28
29#include "audio/audiostream.h"
30#include "audio/mixer.h"
31
32#include "bladerunner/bladerunner.h" // For BLADERUNNER_ORIGINAL_BUGS and BLADERUNNER_ORIGINAL_SETTINGS symbols
33
34namespace BladeRunner {
35
36class BladeRunnerEngine;
37class AudioCache;
38class AudStream;
39
40enum AudioPlayerFlags {
41 kAudioPlayerLoop = 1,
42 kAudioPlayerOverrideVolume = 2
43};
44
46#if BLADERUNNER_ORIGINAL_BUGS
47 static const int kTracks = 6;
48#else
49 // increase tracks, reduce probability of tracks being skipped
50 static const int kTracks = 12;
51#endif // BLADERUNNER_ORIGINAL_BUGS
52 // Use SFX sound type if none is specified
53 static const Audio::Mixer::SoundType kAudioPlayerSoundType = Audio::Mixer::kSFXSoundType;
54
55 struct Track {
56 bool isActive;
57 int channel;
58 int priority;
59 int volume; // should be in [0, 100]
60 int pan; // should be in [-100, 100]
61 AudStream *stream;
62 };
63
65
66 Common::Mutex _mutex;
67 Track _tracks[kTracks];
68 int _sfxVolumeFactorOriginalEngine; // should be in [0, 100] - Unused in ScummVM Engine, used in original engine
69
70public:
73
74 int playAud(const Common::String &name, int volume, int panStart, int panEnd, int priority, byte flags = 0, Audio::Mixer::SoundType type = kAudioPlayerSoundType);
75 bool isActive(int track) const;
76 uint32 getLength(int track) const;
77 void stop(int track, bool immediately);
78 void stopAll();
79 void adjustVolume(int track, int volume, uint32 delaySeconds, bool explicitVolumeAdjustment);
80 void adjustPan(int track, int pan, uint32 delaySeconds);
81
82#if BLADERUNNER_ORIGINAL_SETTINGS
83 void setVolume(int volume);
84 int getVolume() const;
85#endif // BLADERUNNER_ORIGINAL_SETTINGS
86 void playSample();
87
88private:
89 void remove(int channel);
90 static void mixerChannelEnded(int channel, void *data);
91};
92
93} // End of namespace BladeRunner
94
95#endif
SoundType
Definition: mixer.h:73
@ kSFXSoundType
Definition: mixer.h:77
Definition: aud_stream.h:35
Definition: audio_player.h:45
Definition: bladerunner.h:113
Definition: mutex.h:67
Definition: str.h:59