ScummVM API documentation
sound.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 ACCESS_SOUND_H
23 #define ACCESS_SOUND_H
24 
25 #include "common/scummsys.h"
26 #include "access/files.h"
27 #include "audio/midiplayer.h"
28 
29 #define MAX_SOUNDS 20
30 
31 namespace Audio {
32 class AudioStream;
33 class SoundHandle;
34 }
35 
36 namespace Access {
37 
38 class AccessEngine;
39 
40 struct SoundEntry {
41  Resource *_res;
42  int _priority;
43 
44  SoundEntry() { _res = nullptr; _priority = 0; }
45  SoundEntry(Resource *res, int priority) { _res = res; _priority = priority; }
46 };
47 
48 class SoundManager {
49  struct QueuedSound {
50  Audio::AudioStream *_stream;
51  int _soundId;
52 
53  QueuedSound() : _stream(nullptr), _soundId(-1) {}
54  QueuedSound(Audio::AudioStream *stream, int soundId) : _stream(stream), _soundId(soundId) {}
55  };
56 private:
57  AccessEngine *_vm;
58  Audio::Mixer *_mixer;
59  Audio::SoundHandle *_effectsHandle;
61 
62  void clearSounds();
63 
64  void playSound(Resource *res, int priority, bool loop, int soundIndex = -1);
65 
66  bool isSoundQueued(int soundId) const;
67 public:
68  Common::Array<SoundEntry> _soundTable;
69 public:
71  ~SoundManager();
72 
73  void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
74 
75  void playSound(int soundIndex, bool loop = false);
76  void checkSoundQueue();
77  bool isSFXPlaying();
78 
79  Resource *loadSound(int fileNum, int subfile);
80  void loadSounds(const Common::Array<RoomInfo::SoundIdent> &sounds);
81  void syncVolume();
82 
83  void stopSound();
84  void freeSounds();
85 };
86 
88 private:
89  AccessEngine *_vm;
90 
91  Resource *_tempMusic;
92 
93  // MidiDriver_BASE interface implementation
94  void send(uint32 b) override;
95 
96 public:
97  Resource *_music;
98 
99 public:
101  ~MusicManager() override;
102 
103  void midiPlay();
104 
105  bool checkMidiDone();
106 
107  void midiRepeat();
108 
109  void stopSong();
110 
111  void newMusic(int musicId, int mode);
112 
113  void freeMusic();
114 
115  void loadMusic(int fileNum, int subfile);
116  void loadMusic(FileIdent file);
117 
118  void setLoop(bool loop);
119 };
120 } // End of namespace Access
121 
122 #endif /* ACCESS_SOUND_H*/
Definition: midiplayer.h:63
Definition: files.h:35
Definition: access.h:139
Definition: sound.h:40
Definition: sound.h:87
Definition: files.h:54
Definition: mixer.h:49
Definition: mixer.h:70
Definition: sound.h:48
Definition: audiostream.h:50
Definition: access.h:62
Definition: system.h:38