scummvm/engines/adl/sound.h

67 lines
1.7 KiB
C
Raw Normal View History

2016-03-15 19:06:03 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
2017-01-13 18:59:04 +00:00
#ifndef ADL_SOUND_H
#define ADL_SOUND_H
2016-03-15 19:06:03 +00:00
2017-01-13 18:59:04 +00:00
#include "audio/audiostream.h"
2016-03-15 19:06:03 +00:00
2017-01-13 18:59:04 +00:00
#include "common/array.h"
#include "common/frac.h"
2016-03-15 19:06:03 +00:00
namespace Adl {
2017-01-13 18:59:04 +00:00
class Speaker;
struct Tone {
double freq; // Hz
double len; // ms
Tone(double frequency, double length) : freq(frequency), len(length) { }
};
typedef Common::Array<Tone> Tones;
class Sound : public Audio::AudioStream {
2016-03-15 19:06:03 +00:00
public:
2017-01-13 18:59:04 +00:00
Sound(const Tones &tones);
2020-02-09 11:05:27 +00:00
~Sound() override;
2016-03-15 19:06:03 +00:00
2017-01-13 18:59:04 +00:00
// AudioStream
2020-02-09 11:05:27 +00:00
int readBuffer(int16 *buffer, const int numSamples) override;
bool isStereo() const override { return false; }
bool endOfData() const override;
int getRate() const override { return _rate; }
2016-03-15 19:06:03 +00:00
private:
2017-01-13 18:59:04 +00:00
const Tones &_tones;
Speaker *_speaker;
int _rate;
uint _toneIndex;
int _samplesRem;
2016-03-15 19:06:03 +00:00
};
} // End of namespace Adl
#endif