openMSX
|
#include <YM2413Okazaki.hh>
Public Member Functions | |
YM2413 () | |
void | reset () override |
Reset this YM2413 core. More... | |
void | writePort (bool port, uint8_t value, int offset) override |
Write to the YM2413 register/data port. More... | |
void | pokeReg (uint8_t reg, uint8_t data) override |
Write to a YM2413 register (for debug). More... | |
uint8_t | peekReg (uint8_t reg) const override |
Read from a YM2413 register (for debug). More... | |
void | generateChannels (float *bufs[9+5], unsigned num) override |
float | getAmplificationFactor () const override |
Returns normalization factor. More... | |
Patch & | getPatch (unsigned instrument, bool carrier) |
template<typename Archive > | |
void | serialize (Archive &ar, unsigned version) |
template<unsigned FLAGS> | |
ALWAYS_INLINE void | calcChannel (Channel &ch, float *buf, unsigned num) |
![]() | |
virtual | ~YM2413Core ()=default |
virtual void | generateChannels (float *bufs[11], unsigned num)=0 |
Generate the sound output. More... | |
virtual void | setSpeed (double) |
Sets real-time speed factor (aka the openMSX 'speed' setting). More... | |
Additional Inherited Members | |
![]() | |
static constexpr int | CLOCK_FREQ = 3579545 |
Input clock frequency. More... | |
![]() | |
YM2413Core ()=default | |
Definition at line 133 of file YM2413Okazaki.hh.
openmsx::YM2413Okazaki::YM2413::YM2413 | ( | ) |
Definition at line 655 of file YM2413Okazaki.cc.
References openmsx::YM2413Okazaki::arAdjustTab, openmsx::YM2413Okazaki::dB2LinTab, openmsx::YM2413Okazaki::dPhaseDrTab, Math::e, openmsx::YM2413Okazaki::fullSinTable, openmsx::YM2413Okazaki::halfSinTable, openmsx::YM2413Okazaki::Patch::initCarrier(), openmsx::YM2413Okazaki::Patch::initModulator(), reset(), openmsx::YM2413Okazaki::slTab, openmsx::YM2413Okazaki::tllTab, and xrange().
ALWAYS_INLINE void openmsx::YM2413Okazaki::YM2413::calcChannel | ( | Channel & | ch, |
float * | buf, | ||
unsigned | num | ||
) |
Definition at line 1067 of file YM2413Okazaki.cc.
References openmsx::YM2413Okazaki::Patch::AMPM, openmsx::YM2413Okazaki::Slot::calc_fixed_env(), openmsx::YM2413Okazaki::Slot::calc_slot_car(), openmsx::YM2413Okazaki::Slot::calc_slot_mod(), openmsx::YM2413Okazaki::Channel::car, openmsx::YM2413Okazaki::LFO_AM_TAB_ELEMENTS, openmsx::YM2413Okazaki::lfo_am_table, openmsx::YM2413Okazaki::Channel::mod, and openmsx::YM2413Okazaki::Slot::patch.
|
override |
Definition at line 1121 of file YM2413Okazaki.cc.
References openmsx::YM2413Okazaki::Patch::AMPM, openmsx::YM2413Okazaki::Slot::calc_phase(), openmsx::YM2413Okazaki::Slot::calc_slot_car(), openmsx::YM2413Okazaki::Slot::calc_slot_cym(), openmsx::YM2413Okazaki::Slot::calc_slot_hat(), openmsx::YM2413Okazaki::Slot::calc_slot_mod(), openmsx::YM2413Okazaki::Slot::calc_slot_snare(), openmsx::YM2413Okazaki::Slot::calc_slot_tom(), openmsx::YM2413Okazaki::Channel::car, openmsx::YM2413Okazaki::Slot::cPhase, openmsx::YM2413Okazaki::Patch::FB, openmsx::YM2413Okazaki::FINISH, openmsx::YM2413Okazaki::Slot::isActive(), openmsx::YM2413Okazaki::LFO_AM_TAB_ELEMENTS, openmsx::YM2413Okazaki::Channel::mod, openmsx::YM2413Okazaki::Slot::patch, openmsx::YM2413Okazaki::SETTLE, openmsx::YM2413Okazaki::Slot::state, openmsx::YM2413Okazaki::SUSHOLD, UNREACHABLE, and xrange().
|
overridevirtual |
Returns normalization factor.
The output of the generateChannels() method should still be amplified (=multiplied) with this factor to get a consistent volume level across the different implementations of the YM2413 core. This allows to internally calculate with native volume levels, and possibly results in slightly simpler and/or faster code. It's very likely that subsequent audio processing steps (like resampler, filters or volume adjustments) must anyway still multiply the output sample values, so this factor can be folded-in for free.
Implements openmsx::YM2413Core.
Definition at line 1044 of file YM2413Okazaki.cc.
References openmsx::YM2413Okazaki::DB2LIN_AMP_BITS.
Patch & openmsx::YM2413Okazaki::YM2413::getPatch | ( | unsigned | instrument, |
bool | carrier | ||
) |
Definition at line 1061 of file YM2413Okazaki.cc.
Referenced by openmsx::YM2413Okazaki::Channel::setPatch().
|
overridevirtual |
Read from a YM2413 register (for debug).
Note that the real YM2413 chip doesn't allow to read the registers. This returns the last written value or the default value if this register hasn't been written to since the last reset() call. Reading registers has no influence on the generated sound.
Implements openmsx::YM2413Core.
Definition at line 1580 of file YM2413Okazaki.cc.
|
overridevirtual |
Write to a YM2413 register (for debug).
Because of the timing constraint on writing registers via writePort(), writing registers via that way is not very suited for use in a debugger. Use this method as an alternative.
Implements openmsx::YM2413Core.
Definition at line 1370 of file YM2413Okazaki.cc.
|
overridevirtual |
Reset this YM2413 core.
Implements openmsx::YM2413Core.
Definition at line 700 of file YM2413Okazaki.cc.
References xrange().
Referenced by YM2413().
void openmsx::YM2413Okazaki::YM2413::serialize | ( | Archive & | ar, |
unsigned | version | ||
) |
Definition at line 1638 of file YM2413Okazaki.cc.
References enumerate(), openmsx::YM2413Okazaki::Patch::initCarrier(), and openmsx::YM2413Okazaki::Patch::initModulator().
|
overridevirtual |
Write to the YM2413 register/data port.
Writing to a register is a 2-step process: First write the register number to the register port (0), then write the value for that register to the data port (1). There are various timing constraits that must be taken into account (not described here).
We emulate the YM2413 as-if it generates a stream at 49.7kHz and at each step it produces one sample for each of the 9+5 sound channels. Though in reality the YM2413 spreads out the generation of the channels over time. So it's like a stream at 18 x 49.7kHz where the 9+5 channels have a fixed position in the 18 possible slots (so not all 18 slots produce a (non-zero) output).
In other words: we emulate the YM2413 18 steps at a time. Though for accurate emulation we still need to take the exact timing of register writes into account. That's what the 'offset' parameter is for. It must have a value [0..17] and indicates the sub-sample timing of the port-write.
Implements openmsx::YM2413Core.
Definition at line 1361 of file YM2413Okazaki.cc.