1 #ifndef YM2413OKAZAKI_HH
2 #define YM2413OKAZAKI_HH
9 namespace YM2413Okazaki {
31 inline void setKR(uint8_t value);
33 inline void setML(uint8_t value);
35 inline void setKL(uint8_t value);
37 inline void setTL(uint8_t value);
39 inline void setWF(uint8_t value);
41 inline void setFB(uint8_t value);
43 inline void setSL(uint8_t value);
64 [[nodiscard]]
inline bool isActive()
const;
72 [[nodiscard]]
inline unsigned calc_phase(
unsigned lfo_pm);
73 template<
bool HAS_AM,
bool FIXED_ENV>
74 [[nodiscard]]
inline unsigned calc_envelope(
int lfo_am,
unsigned fixed_env);
75 template<
bool HAS_AM> [[nodiscard]]
unsigned calc_fixed_env()
const;
77 template<
bool HAS_AM,
bool FIXED_ENV>
78 [[nodiscard]]
inline int calc_slot_car(
unsigned lfo_pm,
int lfo_am,
int fm,
unsigned fixed_env);
79 template<
bool HAS_AM,
bool HAS_FB,
bool FIXED_ENV>
80 [[nodiscard]]
inline int calc_slot_mod(
unsigned lfo_pm,
int lfo_am,
unsigned fixed_env);
84 [[nodiscard]]
inline int calc_slot_cym(
unsigned phase7,
unsigned phase8);
85 [[nodiscard]]
inline int calc_slot_hat(
unsigned phase7,
unsigned phase8,
bool noise);
87 inline void updateTLL(
unsigned freq,
bool actAsCarrier);
90 inline void updateAll(
unsigned freq,
bool actAsCarrier);
92 template<
typename Archive>
93 void serialize(Archive& ar,
unsigned version);
123 inline void setSustain(
bool sustain,
bool modActAsCarrier);
129 template<
typename Archive>
130 void serialize(Archive& ar,
unsigned version);
139 void reset()
override;
140 void writePort(
bool port, uint8_t value,
int offset)
override;
141 void pokeReg(uint8_t reg, uint8_t data)
override;
142 [[nodiscard]] uint8_t
peekReg(uint8_t reg)
const override;
146 [[nodiscard]]
Patch&
getPatch(
unsigned instrument,
bool carrier);
148 template<
typename Archive>
149 void serialize(Archive& ar,
unsigned version);
152 void writeReg(uint8_t r, uint8_t data);
154 inline void keyOn_BD();
155 inline void keyOn_SD();
156 inline void keyOn_TOM();
157 inline void keyOn_HH();
158 inline void keyOn_CYM();
159 inline void keyOff_BD();
160 inline void keyOff_SD();
161 inline void keyOff_TOM();
162 inline void keyOff_HH();
163 inline void keyOff_CYM();
164 inline void setRhythmFlags(uint8_t old);
165 inline void update_key_status();
166 [[nodiscard]]
inline bool isRhythm()
const;
167 [[nodiscard]]
inline unsigned getFreq(
unsigned channel)
const;
169 template<
unsigned FLAGS>
170 inline void calcChannel(
Channel& ch,
float* buf,
unsigned num);
186 Patch patches[19][2];
190 uint8_t registerLatch;
Abstract interface for the YM2413 core.
void serialize(Archive &ar, unsigned version)
void setSustain(bool sustain, bool modActAsCarrier)
void setPatch(unsigned num, YM2413 &ym2413)
void reset(YM2413 &ym2413)
void setSL(uint8_t value)
Sets sustain level [0..15].
void setFB(uint8_t value)
Sets the amount of feedback [0..7].
Patch()
Creates an uninitialized Patch object; call initXXX() before use.
void initCarrier(const uint8_t *data)
void setTL(uint8_t value)
Set volume (total level) [0..63].
void initModulator(const uint8_t *data)
void setKL(uint8_t value)
Sets Key scale level [0..3].
void setML(uint8_t value)
Sets the frequency multiplier factor [0..15].
void setWF(uint8_t value)
Set waveform [0..1].
void setKR(uint8_t value)
Sets the Key Scale of Rate (0 or 1).
void serialize(Archive &ar, unsigned version)
void setVolume(unsigned value)
int calc_slot_snare(bool noise)
int calc_slot_mod(unsigned lfo_pm, int lfo_am, unsigned fixed_env)
void setPatch(const Patch &patch)
void updateTLL(unsigned freq, bool actAsCarrier)
void calc_envelope_outline(unsigned &out)
EnvPhaseIndex eg_phase_max
void updatePG(unsigned freq)
void updateRKS(unsigned freq)
const int * dPhaseDRTableRks
void setEnvelopeState(EnvelopeState state)
unsigned calc_envelope(int lfo_am, unsigned fixed_env)
unsigned calc_phase(unsigned lfo_pm)
unsigned calc_fixed_env() const
int calc_slot_hat(unsigned phase7, unsigned phase8, bool noise)
int calc_slot_cym(unsigned phase7, unsigned phase8)
int calc_slot_car(unsigned lfo_pm, int lfo_am, int fm, unsigned fixed_env)
void updateAll(unsigned freq, bool actAsCarrier)
void generateChannels(float *bufs[9+5], unsigned num) override
uint8_t peekReg(uint8_t reg) const override
Read from a YM2413 register (for debug).
void serialize(Archive &ar, unsigned version)
void writePort(bool port, uint8_t value, int offset) override
Write to the YM2413 register/data port.
void pokeReg(uint8_t reg, uint8_t data) override
Write to a YM2413 register (for debug).
float getAmplificationFactor() const override
Returns normalization factor.
void reset() override
Reset this YM2413 core.
Patch & getPatch(unsigned instrument, bool carrier)
This file implemented 3 utility functions:
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)