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  bool _playingSound;
70 public:
72  ~SoundManager();
73 
74  void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
75 
76  void playSound(int soundIndex, bool loop = false);
77  void checkSoundQueue();
78  bool isSFXPlaying();
79 
80  Resource *loadSound(int fileNum, int subfile);
81  void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
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  bool _byte1F781;
99 
100 public:
102  ~MusicManager() override;
103 
104  void midiPlay();
105 
106  bool checkMidiDone();
107 
108  void midiRepeat();
109 
110  void stopSong();
111 
112  void newMusic(int musicId, int mode);
113 
114  void freeMusic();
115 
116  void loadMusic(int fileNum, int subfile);
117  void loadMusic(FileIdent file);
118 
119  void setLoop(bool loop);
120 };
121 } // End of namespace Access
122 
123 #endif /* ACCESS_SOUND_H*/
Definition: midiplayer.h:63
Definition: files.h:35
Definition: access.h:84
Definition: sound.h:40
Definition: sound.h:87
Definition: files.h:54
Definition: mixer.h:49
Definition: mixer.h:59
Definition: sound.h:48
Definition: audiostream.h:50
Definition: access.h:62
Definition: system.h:38