28 [[nodiscard]] uint8_t
readRegister(
unsigned reg, EmuTime::param time);
29 [[nodiscard]] uint8_t
peekRegister(
unsigned reg, EmuTime::param time)
const;
30 void writeRegister(
unsigned reg, uint8_t value, EmuTime::param time);
31 void reset(EmuTime::param time);
33 template<
typename Archive>
34 void serialize(Archive& ar,
unsigned version);
39 void setPeriod(
int value);
40 [[nodiscard]]
unsigned getNextEventTime()
const;
41 void advanceFast(
unsigned duration);
43 template<
typename Archive>
44 void serialize(Archive& ar,
unsigned version);
47 Generator() =
default;
63 class ToneGenerator :
public Generator {
72 void advance(
unsigned duration);
74 void doNextEvent(
const AY8910& ay8910);
78 [[nodiscard]]
bool getOutput()
const {
return output; }
80 template<
typename Archive>
81 void serialize(Archive& ar,
unsigned version);
84 [[nodiscard]]
int getDetune(
const AY8910& ay8910);
89 unsigned vibratoCount = 0;
90 unsigned detuneCount = 0;
97 class NoiseGenerator :
public Generator {
105 void advance(
unsigned duration);
111 [[nodiscard]]
bool getOutput()
const {
return random & 1; }
113 template<
typename Archive>
114 void serialize(Archive& ar,
unsigned version);
123 [[nodiscard]]
auto getEnvVolTable()
const {
return envVolTable; }
124 [[nodiscard]]
float getVolume(
unsigned chan)
const;
125 void setChannelVolume(
unsigned chan,
unsigned value);
126 [[nodiscard]]
bool followsEnvelope(
unsigned chan)
const;
130 std::span<const float, 32> envVolTable;
131 std::array<float, 3> vol;
132 std::array<bool, 3> envChan;
137 explicit Envelope(std::span<const float, 32> envVolTable);
139 void setPeriod(
int value);
140 void setShape(
unsigned shape);
141 [[nodiscard]]
bool isChanging()
const;
142 void advance(
unsigned duration);
143 [[nodiscard]]
float getVolume()
const;
145 [[nodiscard]]
unsigned getNextEventTime()
const;
146 void advanceFast(
unsigned duration);
149 template<
typename Archive>
150 void serialize(Archive& ar,
unsigned version);
153 void doSteps(
int steps);
156 std::span<const float, 32> envVolTable;
161 bool hold =
false, alternate =
false, holding =
false;
165 void generateChannels(std::span<float*> bufs,
unsigned num)
override;
166 [[nodiscard]]
float getAmplificationFactorImpl()
const override;
171 void wrtReg(
unsigned reg, uint8_t value, EmuTime::param time);
178 [[nodiscard]] uint8_t read(
unsigned address, EmuTime::param time)
override;
179 void write(
unsigned address, uint8_t value, EmuTime::param time)
override;
187 std::array<ToneGenerator, 3> tone;
188 NoiseGenerator noise;
191 std::array<uint8_t, 16> regs;
193 const bool ignorePortDirections;