ScummVM API documentation
saud_stream.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#ifndef SCUMM_SMUSH_SAUD_STREAM_H
22#define SCUMM_SMUSH_SAUD_STREAM_H
23
24#include "audio/audiostream.h"
25#include "common/array.h"
26#include "common/mutex.h"
27#include "scumm/smush/saud.h"
28
29namespace Audio {
30class RateConverter;
31}
32
33namespace Scumm {
34
36public:
38 void reset();
39 byte variable(byte id) const;
40
41private:
42 friend class SaudStream;
43 Common::Mutex _mutex;
44 byte _variables[256];
45 int _masterVolume;
46};
47
48// Plays an in-memory SAUD through the same STRK interpreter as RebelAudio.
49// The caller keeps samples, script and shared state alive until playback stops.
51public:
52 enum { kRate = 22050 };
53 SaudStream(const Common::Array<byte> &samples, const Common::Array<byte> &script,
54 uint rate, SaudStreamState &state, byte volume, int8 pan);
55 ~SaudStream() override;
56
57 int readBuffer(int16 *buffer, int numSamples) override;
58 bool isStereo() const override { return true; }
59 int getRate() const override { return kRate; }
60 bool endOfData() const override { return _ended; }
61 // Advance the script and audio together before handing the stream to the mixer.
62 void skip(uint64 frames);
63
64private:
65 bool startSpan(const SaudSpan &span);
66
67 const Common::Array<byte> &_samples;
68 SaudStreamState &_state;
69 SaudScript _script;
71 Audio::RateConverter *_converter;
72 byte _volume, _pan;
73 bool _ended;
74};
75
76} // End of namespace Scumm
77
78#endif
Definition: audiostream.h:50
Definition: rate.h:93
Definition: mutex.h:67
Definition: saud.h:74
Definition: saud_stream.h:50
bool isStereo() const override
Definition: saud_stream.h:58
int getRate() const override
Definition: saud_stream.h:59
bool endOfData() const override
Definition: saud_stream.h:60
int readBuffer(int16 *buffer, int numSamples) override
Definition: saud_stream.h:35
Definition: system.h:39
Definition: actor.h:30
Definition: saud.h:66