ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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  int _panningTodoRoom = 0;
65 
66  int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger,
67  int32 room_num, bool loop);
68 
69 public:
70  Digi(Audio::Mixer *mixer) : _mixer(mixer) {}
71  ~Digi();
72 
76  bool preload(const Common::String &name, bool isFootsteps, int roomNum = -1);
77 
82  void loadFootstepSounds(const char **names);
83 
84  void unload_sounds();
85  void unload(const Common::String &name);
86  void task();
87 
88  // digi_play and digi_play_loop play a particular sound file in a given channel,
89  // at a particular volume. The room_num parameter tells us what directory the sound
90  // is stored in (all sounds are AIFFs). Trigger is an integer that is fed into
91  // kernel_dispatch_trigger when the sound has finished playing
92  // If the sound has been preloaded it will be played from memory, otherwise it will
93  // be streamed from disk
94 
95  int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
96  int32 play_loop(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
97  void playFootsteps();
98  void stop(uint channel, bool calledFromUnload = false);
99  void flush_mem();
100 
101  void read_another_chunk();
102  bool play_state(int channel) const;
103  void change_volume(int channel, int vol);
104 
105  void set_overall_volume(int vol);
106  int get_overall_volume();
107  int32 ticks_to_play(const char *name, int roomNum = -1);
108  void change_panning(int val1, int val2);
109 };
110 
111 } // namespace Sound
112 
113 bool digi_preload(const Common::String &name, int roomNum = -1);
114 void digi_unload(const Common::String &name);
115 int32 digi_play(const char *name, uint channel, int32 vol = 255,
116  int32 trigger = -1, int32 room_num = -1);
117 int32 digi_play_loop(const char *name, uint channel, int32 vol = 255,
118  int32 trigger = -1, int32 room_num = -1);
119 void digi_read_another_chunk();
120 void digi_stop(int channel);
121 bool digi_play_state(int channel);
122 void digi_change_volume(int channel, int vol);
123 void digi_set_overall_volume(int vol);
124 int digi_get_overall_volume();
125 int32 digi_ticks_to_play(const char *name, int roomNum = -1);
126 void digi_change_panning(int val1, int val2);
127 
128 } // namespace M4
129 
130 #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)