ScummVM API documentation
sound_sarien.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_SARIEN_H
23#define AGI_SOUND_SARIEN_H
24
25#include "audio/audiostream.h"
26
27namespace Agi {
28
29#define BUFFER_SIZE 410
30
31#define WAVEFORM_SIZE 64
32#define ENV_ATTACK 10000
33#define ENV_DECAY 1000
34#define ENV_SUSTAIN 100
35#define ENV_RELEASE 7500
36#define NUM_CHANNELS 7
38enum AgiSoundFlags {
39 AGI_SOUND_LOOP = 0x0001,
40 AGI_SOUND_ENVELOPE = 0x0002
41};
42enum AgiSoundEnv {
43 AGI_SOUND_ENV_ATTACK = 3,
44 AGI_SOUND_ENV_DECAY = 2,
45 AGI_SOUND_ENV_SUSTAIN = 1,
46 AGI_SOUND_ENV_RELEASE = 0
47};
48
49
54 AgiSoundEmuType type;
55 const uint8 *ptr; // Pointer to the AgiNote data
56 const int16 *ins;
57 int32 size;
58 uint32 phase;
59 uint32 flags; // ORs values from AgiSoundFlags
60 AgiSoundEnv adsr;
61 int32 timer;
62 uint32 end;
63 uint32 freq;
64 uint32 vol;
65 uint32 env;
66};
67
69public:
71 ~SoundGenSarien() override;
72
73 void play(int resnum) override;
74 void stop() override;
75
76 // AudioStream API
77 int readBuffer(int16 *buffer, const int numSamples) override;
78
79 bool isStereo() const override {
80 return false;
81 }
82
83 bool endOfData() const override {
84 return false;
85 }
86
87 int getRate() const override {
88 // FIXME: Ideally, we should use _sampleRate.
89 return 22050;
90 }
91
92private:
93 Common::Mutex _mutex;
94
95 ChannelInfo _chn[NUM_CHANNELS];
96 uint8 _env;
97
98 int16 *_sndBuffer;
99 const int16 *_waveform;
100
101 bool _useChorus;
102
103 bool _playing;
104 int _playingSound;
105
106private:
107 void playSound();
108 uint32 mixSound();
109 void fillAudio(int16 *stream, uint len);
110
111 void stopNote(int i);
112 void playNote(int i, int freq, int vol);
113
114};
115
116} // End of namespace Agi
117
118#endif /* AGI_SOUND_SARIEN_H */
Definition: agi.h:573
Definition: sound.h:57
Definition: sound_sarien.h:68
int getRate() const override
Definition: sound_sarien.h:87
bool isStereo() const override
Definition: sound_sarien.h:79
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
Definition: sound_sarien.h:83
Definition: audiostream.h:50
Definition: mixer.h:70
Definition: mutex.h:67
Definition: agi.h:64
AgiSoundEmuType
Definition: sound.h:47
Definition: sound_sarien.h:53