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 ADL_SOUND_H
23 #define ADL_SOUND_H
24 
25 #include "audio/audiostream.h"
26 
27 #include "common/array.h"
28 #include "common/frac.h"
29 
30 namespace Adl {
31 
32 class Speaker;
33 
34 struct Tone {
35  double freq; // Hz
36  double len; // ms
37 
38  Tone(double frequency, double length) : freq(frequency), len(length) { }
39 };
40 
42 
43 class Sound : public Audio::AudioStream {
44 public:
45  Sound(const Tones &tones);
46  ~Sound() override;
47 
48  // AudioStream
49  int readBuffer(int16 *buffer, const int numSamples) override;
50  bool isStereo() const override { return false; }
51  bool endOfData() const override;
52  int getRate() const override { return _rate; }
53 
54 private:
55  const Tones &_tones;
56 
57  Speaker *_speaker;
58  int _rate;
59  uint _toneIndex;
60  int _samplesRem;
61 };
62 
63 } // End of namespace Adl
64 
65 #endif
int getRate() const override
Definition: sound.h:52
Definition: array.h:52
Definition: sound.h:34
Definition: adl.h:55
bool isStereo() const override
Definition: sound.h:50
Definition: audiostream.h:50
Definition: sound.h:43