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 AGI_SOUND_H
23#define AGI_SOUND_H
24
25namespace Audio {
26class Mixer;
27class SoundHandle;
28}
29
30namespace Agi {
31
32#define SOUND_EMU_NONE 0
33#define SOUND_EMU_PC 1
34#define SOUND_EMU_PCJR 2
35#define SOUND_EMU_MAC 3
36#define SOUND_EMU_AMIGA 4
37#define SOUND_EMU_APPLE2 5
38#define SOUND_EMU_APPLE2GS 6
39#define SOUND_EMU_COCO3 7
40#define SOUND_EMU_MIDI 8
41
48 AGI_SOUND_SAMPLE = 0x0001,
49 AGI_SOUND_MIDI = 0x0002,
50 AGI_SOUND_4CHN = 0x0008,
51 AGI_SOUND_APPLE2 = 0xffff,
52 AGI_SOUND_COCO3 = 0xfffe
53};
54
55class SoundMgr;
56
57class SoundGen {
58public:
59 SoundGen(AgiBase *vm, Audio::Mixer *pMixer);
60 virtual ~SoundGen();
61
62 virtual void play(int resnum) = 0;
63 virtual void stop() = 0;
64
65 AgiBase *_vm;
66
67 Audio::Mixer *_mixer;
68 Audio::SoundHandle *_soundHandle;
69
70 uint32 _sampleRate;
71};
72
76class AgiSound {
77public:
78 AgiSound(byte resourceNr, byte *data, uint32 length, uint16 type) :
79 _resourceNr(resourceNr),
80 _data(data),
81 _length(length),
82 _type(type),
83 _isPlaying(false) {}
84
85 virtual ~AgiSound() { free(_data); }
86
87 virtual void play() { _isPlaying = true; }
88 virtual void stop() { _isPlaying = false; }
89 virtual bool isPlaying() { return _isPlaying; }
90 byte *getData() { return _data; }
91 uint32 getLength() { return _length; }
92 virtual uint16 type() { return _type; }
93 virtual bool isValid() { return true; }
94
99 static AgiSound *createFromRawResource(uint8 *data, uint32 len, int resnum, int soundemu, bool isAgiV1);
100
101protected:
102 byte _resourceNr;
103 byte *_data;
104 uint32 _length;
105 uint16 _type;
106 bool _isPlaying;
107};
108
109class PCjrSound : public AgiSound {
110public:
111 PCjrSound(byte resourceNr, byte *data, uint32 length, uint16 type);
112 const uint8 *getVoicePointer(uint voiceNum);
113};
114
115class SoundMgr {
116
117public:
118 SoundMgr(AgiBase *agi, Audio::Mixer *pMixer);
119 ~SoundMgr();
120
121 void unloadSound(int);
122 void startSound(int, int);
123 void stopSound();
124
125 void soundIsFinished();
126 bool isPlaying() const { return _playingSound != -1; }
127
128private:
129 int _endflag;
130 AgiBase *_vm;
131
132 SoundGen *_soundGen;
133
134 int _playingSound;
135};
136
137} // End of namespace Agi
138
139#endif /* AGI_SOUND_H */
Definition: agi.h:573
Definition: sound.h:76
static AgiSound * createFromRawResource(uint8 *data, uint32 len, int resnum, int soundemu, bool isAgiV1)
Definition: sound.h:109
Definition: sound.h:57
Definition: sound.h:115
Definition: mixer.h:70
Definition: mixer.h:49
Definition: agi.h:64
AgiSoundEmuType
Definition: sound.h:47
Definition: system.h:39