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 "audio/audiostream.h"
28 #include "common/hashmap.h"
29 #include "m4/m4_types.h"
30 
31 namespace M4 {
32 namespace Sound {
33 
34 #define MAX_CHANNELS 4
35 
39 class Digi {
43  struct DigiEntry {
44  Common::String _filename;
45  byte *_data = nullptr;
46  size_t _size = 0;
47  bool _isFootsteps = false;
48  DigiEntry() {}
49  DigiEntry(Common::String &name, byte *data, size_t size) :
50  _filename(name), _data(data), _size(size) {}
51  };
55  struct Channel {
56  Audio::SoundHandle _soundHandle;
57  int _trigger = -1;
58  Common::String _name;
59  };
60 private:
61  Audio::Mixer *_mixer;
62  Channel _channels[4];
64 
65  int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger,
66  int32 room_num, bool loop);
67 
68 public:
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  void set_overall_volume(int vol);
105  int get_overall_volume();
106  int32 ticks_to_play(const char *name, int roomNum = -1);
107  void change_panning(int val1, int val2);
108 };
109 
110 } // namespace Sound
111 
112 bool digi_preload(const Common::String &name, int roomNum = -1);
113 void digi_unload(const Common::String &name);
114 int32 digi_play(const char *name, uint channel, int32 vol = 255,
115  int32 trigger = -1, int32 room_num = -1);
116 int32 digi_play_loop(const char *name, uint channel, int32 vol = 255,
117  int32 trigger = -1, int32 room_num = -1);
118 void digi_read_another_chunk();
119 void digi_stop(int channel);
120 bool digi_play_state(int channel);
121 void digi_change_volume(int channel, int vol);
122 void digi_set_overall_volume(int vol);
123 int digi_get_overall_volume();
124 int32 digi_ticks_to_play(const char *name, int roomNum = -1);
125 void digi_change_panning(int val1, int val2);
126 
127 } // namespace M4
128 
129 #endif
Definition: str.h:59
bool preload(const Common::String &name, bool isFootsteps, int roomNum=-1)
Definition: mixer.h:49
Definition: mixer.h:59
Definition: digi.h:39
Definition: database.h:28
void loadFootstepSounds(const char **names)