ScummVM API documentation
digi.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef M4_PLATFORM_SOUND_DIGI_H
24#define M4_PLATFORM_SOUND_DIGI_H
25
26#include "audio/mixer.h"
27#include "common/hashmap.h"
28#include "m4/m4_types.h"
29
30namespace M4 {
31namespace Sound {
32
33#define MAX_CHANNELS 4
34
38class Digi {
42 struct DigiEntry {
43 Common::String _filename;
44 byte *_data = nullptr;
45 size_t _size = 0;
46 bool _isFootsteps = false;
47 DigiEntry() {}
48 DigiEntry(Common::String &name, byte *data, size_t size) :
49 _filename(name), _data(data), _size(size) {}
50 };
54 struct Channel {
55 Audio::SoundHandle _soundHandle;
56 int _trigger = -1;
57 Common::String _name;
58 };
59private:
60 Audio::Mixer *_mixer;
61 Channel _channels[4];
63 int _panningTodoRoom = 0;
64
65 int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger,
66 int32 room_num, bool loop);
67
68public:
69 Digi(Audio::Mixer *mixer) : _mixer(mixer) {}
70 ~Digi();
71
75 bool preload(const Common::String &name, bool isFootsteps, int roomNum = -1);
76
81 void loadFootstepSounds(const char **names);
82
83 void unload_sounds();
84 void unload(const Common::String &name);
85 void task();
86
87 // digi_play and digi_play_loop play a particular sound file in a given channel,
88 // at a particular volume. The room_num parameter tells us what directory the sound
89 // is stored in (all sounds are AIFFs). Trigger is an integer that is fed into
90 // kernel_dispatch_trigger when the sound has finished playing
91 // If the sound has been preloaded it will be played from memory, otherwise it will
92 // be streamed from disk
93
94 int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
95 int32 play_loop(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
96 void playFootsteps();
97 void stop(uint channel, bool calledFromUnload = false);
98 void flush_mem();
99
100 void read_another_chunk();
101 bool play_state(int channel) const;
102 void change_volume(int channel, int vol);
103
104 int32 ticks_to_play(const char *name, int roomNum = -1);
105 void change_panning(int val1, int val2);
106};
107
108} // namespace Sound
109
110bool digi_preload(const Common::String &name, int roomNum = -1);
111void digi_unload(const Common::String &name);
112int32 digi_play(const char *name, uint channel, int32 vol = 255,
113 int32 trigger = -1, int32 room_num = -1);
114int32 digi_play_loop(const char *name, uint channel, int32 vol = 255,
115 int32 trigger = -1, int32 room_num = -1);
116void digi_read_another_chunk();
117void digi_stop(int channel);
118bool digi_play_state(int channel);
119void digi_change_volume(int channel, int vol);
120int32 digi_ticks_to_play(const char *name, int roomNum = -1);
121void digi_change_panning(int val1, int val2);
122
123} // namespace M4
124
125#endif
Definition: mixer.h:70
Definition: mixer.h:49
Definition: str.h:59
Definition: digi.h:38
void loadFootstepSounds(const char **names)
bool preload(const Common::String &name, bool isFootsteps, int roomNum=-1)
Definition: database.h:28