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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_SOUND_SOUND_H
29 #define GOB_SOUND_SOUND_H
30 
31 #include "common/str.h"
32 #include "gob/sound/sounddesc.h"
33 
34 namespace Gob {
35 
36 class GobEngine;
37 class BackgroundAtmosphere;
38 class PCSpeaker;
39 class SoundBlaster;
40 class ADLPlayer;
41 class MUSPlayer;
42 class Infogrames;
43 class Protracker;
44 class CDROM;
45 
46 class Sound {
47 public:
48  enum BackgroundPlayMode {
49  kPlayModeLinear,
50  kPlayModeRandom
51  };
52 
53  static const int kSoundsCount = 60;
54 
55  Sound(GobEngine *vm);
56  ~Sound();
57 
58  static void convToSigned(byte *buffer, int length);
59 
60  // Samples
61  SoundDesc *sampleGetBySlot(int slot);
62  const SoundDesc *sampleGetBySlot(int slot) const;
63  int sampleGetNextFreeSlot() const;
64 
65  bool sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName);
66  void sampleFree(SoundDesc *sndDesc, bool noteAdLib = false, int index = -1);
67 
68 
69  // SoundBlaster
70  void blasterPlay(SoundDesc *sndDesc, int16 repCount,
71  int16 frequency, int16 fadeLength = 0);
72  void blasterStop(int16 fadeLength, SoundDesc *sndDesc = 0);
73 
74  void blasterPlayComposition(const int16 *composition, int16 freqVal,
75  SoundDesc *sndDescs = 0, int8 sndCount = kSoundsCount);
76  void blasterStopComposition();
77  void blasterRepeatComposition(int32 repCount);
78 
79  char blasterPlayingSound() const;
80 
81  void blasterSetRepeating(int32 repCount);
82  void blasterWaitEndPlay(bool interruptible = false, bool stopComp = true);
83 
84 
85  // PCSpeaker
86  void speakerOn(int16 frequency, int32 length = -1);
87  void speakerOff();
88  void speakerOnUpdate(uint32 millis);
89 
90 
91  // AdLib
92  bool adlibLoadADL(const char *fileName);
93  bool adlibLoadADL(byte *data, uint32 size, int index = -1);
94  bool adlibLoadMDY(const char *fileName);
95  bool adlibLoadTBR(const char *fileName);
96  void adlibUnload();
97 
98  void adlibPlayTrack(const char *trackname);
99  void adlibPlayBgMusic();
100 
101  void adlibPlay();
102  void adlibStop();
103 
104  bool adlibIsPlaying() const;
105 
106  int adlibGetIndex() const;
107  int32 adlibGetRepeating() const;
108 
109  void adlibSetRepeating(int32 repCount);
110  void adlibSyncVolume();
111 
112 
113  // Infogrames
114  bool infogramesLoadInstruments(const char *fileName);
115  bool infogramesLoadSong(const char *fileName);
116 
117  void infogramesPlay();
118  void infogramesStop();
119 
120 
121  // Protracker
122  bool protrackerPlay(const char *fileName);
123  void protrackerStop();
124 
125 
126  // CD-ROM
127  void cdLoadLIC(const Common::String &fname);
128  void cdUnloadLIC();
129 
130  void cdPlayBgMusic();
131  void cdPlayMultMusic();
132 
133  void cdPlay(const Common::String &);
134  void cdStop();
135 
136  bool cdIsPlaying() const;
137 
138  int32 cdGetTrackPos(const char *keyTrack = 0) const;
139  const char *cdGetCurrentTrack() const;
140 
141  void cdTest(int trySubst, const char *label);
142 
143 
144  // Background Atmosphere
145  void bgPlay(const char *file, SoundType type);
146  void bgPlay(const char *base, const char *ext, SoundType type, int count);
147  void bgStop();
148 
149  void bgSetPlayMode(BackgroundPlayMode mode);
150 
151  void bgShade();
152  void bgUnshade();
153 
154 private:
155  GobEngine *_vm;
156 
157  bool _hasAdLib;
158  bool _hasAdLibBg;
159 
160  SoundDesc _sounds[kSoundsCount];
161 
162  // Speaker
163  PCSpeaker *_pcspeaker;
164 
165  // PCM based
166  SoundBlaster *_blaster;
167  BackgroundAtmosphere *_bgatmos;
168 
169  // AdLib
170  MUSPlayer *_mdyPlayer;
171  ADLPlayer *_adlPlayer;
172 
173  // Amiga Paula
174  Infogrames *_infogrames;
175  Protracker *_protracker;
176 
177  // Audio CD
178  CDROM *_cdrom;
179 
180  void createMDYPlayer();
181  void createADLPlayer();
182 };
183 
184 } // End of namespace Gob
185 
186 #endif // GOB_SOUND_SOUND_H
Definition: gob.h:156
Definition: str.h:59
Definition: protracker.h:39
Definition: cdrom.h:33
Definition: adlplayer.h:42
Definition: bgatmosphere.h:46
Definition: anifile.h:40
Definition: musplayer.h:46
Definition: sound.h:46
Definition: pcspeaker.h:39
Definition: infogrames.h:36
Definition: sounddesc.h:43
Definition: soundblaster.h:43