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 DGDS_SOUND_H
23 #define DGDS_SOUND_H
24 
25 #include "common/scummsys.h"
26 #include "audio/audiostream.h"
27 #include "audio/mixer.h"
28 
29 namespace Dgds {
30 
31 class ResourceManager;
32 class Decompressor;
33 class DgdsMidiPlayer;
34 
35 struct Channel {
36  Audio::AudioStream *stream;
37  Audio::SoundHandle handle;
38  byte volume;
39 };
40 
41 class Sound {
42 public:
43  Sound(Audio::Mixer *mixer, ResourceManager *resource, Decompressor *decompressor);
44  ~Sound();
45 
46  void playAmigaSfx(const Common::String &filename, byte channel, byte volume);
47  void loadMusic(const Common::String &filename);
48  void loadMacMusic(const Common::String &filename);
49  void loadSFX(const Common::String &filename);
50 
51  void playMusic(uint num);
52  void stopMusic();
53  void unloadMusic();
54 
55  void playSFX(uint num);
56 
57  void stopSfx(byte channel);
58  void stopAllSfx();
59 
60  bool playPCM(const byte *data, uint32 size);
61 
62  DgdsMidiPlayer *getMidiPlayer() { return _midiMusicPlayer; }
63 
64 private:
65  void loadPCSound(const Common::String &filename, Common::Array<uint32> &sizeArray, Common::Array<byte *> &dataArray);
66  void playPCSound(uint num, const Common::Array<uint32> &sizeArray, const Common::Array<byte *> &dataArray, DgdsMidiPlayer *midiPlayer);
67 
68  struct Channel _channels[2];
69  Common::SeekableReadStream *_soundData = nullptr;
70 
71  Common::Array<uint32> _musicSizes;
72  Common::Array<byte *> _musicData;
73 
74  Common::Array<uint32> _sfxSizes;
75  Common::Array<byte *> _sfxData;
76 
77  Audio::Mixer *_mixer;
78  DgdsMidiPlayer *_midiMusicPlayer;
79  DgdsMidiPlayer *_midiSoundPlayer;
80  ResourceManager *_resource;
81  Decompressor *_decompressor;
82 };
83 
84 enum {
85  DIGITAL_PCM = 1 << 0,
86  TRACK_ADLIB = 1 << 1,
87  TRACK_GM = 1 << 2,
88  TRACK_MT32 = 1 << 3
89 };
90 
91 byte loadSndTrack(uint32 track, const byte** trackPtr, uint16* trackSiz, const byte *data, uint32 size);
92 
93 } // End of namespace Dgds
94 
95 #endif // DGDS_SOUND_H
Definition: str.h:59
Definition: ads.h:28
Definition: sound.h:41
Definition: stream.h:745
Definition: sound.h:35
Definition: mixer.h:49
Definition: mixer.h:59
Definition: audiostream.h:50
Definition: music.h:29
Definition: decompress.h:67
Definition: resource.h:49