Classes | Public Types | Public Member Functions | List of all members
openmsx::YM2413NukeYKT::YM2413 Class Referencefinal

#include <YM2413NukeYKT.hh>

Inheritance diagram for openmsx::YM2413NukeYKT::YM2413:
Inheritance graph
Collaboration diagram for openmsx::YM2413NukeYKT::YM2413:
Collaboration graph

Public Types

enum class  EgState : uint8_t { attack , decay , sustain , release }
enum class  RmNum : uint8_t {
  bd0 , hh , tom , bd1 ,
  sd , tc , NUM

Public Member Functions

 YM2413 ()
void reset () override
 Reset this YM2413 core.
void writePort (bool port, uint8_t value, int cycle_offset) override
 Write to the YM2413 register/data port.
void pokeReg (uint8_t reg, uint8_t value) override
 Write to a YM2413 register (for debug).
uint8_t peekReg (uint8_t reg) const override
 Read from a YM2413 register (for debug).
void generateChannels (std::span< float *, 9+5 > out, uint32_t n) override
float getAmplificationFactor () const override
 Returns normalization factor.
void setSpeed (double speed) override
 Sets real-time speed factor (aka the openMSX 'speed' setting).
template<typename Archive >
void serialize (Archive &ar, unsigned version)
- Public Member Functions inherited from openmsx::YM2413Core
virtual ~YM2413Core ()=default
virtual void generateChannels (std::span< float *, 9+5 > bufs, unsigned num)=0
 Generate the sound output.

Additional Inherited Members

- Static Public Attributes inherited from openmsx::YM2413Core
static constexpr int CLOCK_FREQ = 3579545
 Input clock frequency.
- Protected Member Functions inherited from openmsx::YM2413Core
 YM2413Core ()=default

Detailed Description

Definition at line 71 of file YM2413NukeYKT.hh.

Member Enumeration Documentation

◆ EgState

enum class openmsx::YM2413NukeYKT::YM2413::EgState : uint8_t

Definition at line 86 of file YM2413NukeYKT.hh.

◆ RmNum

enum class openmsx::YM2413NukeYKT::YM2413::RmNum : uint8_t

Definition at line 92 of file YM2413NukeYKT.hh.

Constructor & Destructor Documentation

◆ YM2413()

openmsx::YM2413NukeYKT::YM2413::YM2413 ( )

Definition at line 115 of file

References ranges::copy(), reset(), and subspan().

Member Function Documentation

◆ generateChannels()

void openmsx::YM2413NukeYKT::YM2413::generateChannels ( std::span< float *, 9+5 >  out,
uint32_t  n 

Definition at line 815 of file

References ranges::copy(), and repeat().

◆ getAmplificationFactor()

float openmsx::YM2413NukeYKT::YM2413::getAmplificationFactor ( ) const

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 912 of file

◆ peekReg()

uint8_t openmsx::YM2413NukeYKT::YM2413::peekReg ( uint8_t  reg) const

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 907 of file

◆ pokeReg()

void openmsx::YM2413NukeYKT::YM2413::pokeReg ( uint8_t  reg,
uint8_t  value 

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 895 of file

Referenced by serialize().

◆ reset()

void openmsx::YM2413NukeYKT::YM2413::reset ( )

Reset this YM2413 core.

Implements openmsx::YM2413Core.

Definition at line 124 of file

References attack, ranges::fill(), release, and xrange().

Referenced by YM2413().

◆ serialize()

template<typename Archive >
void openmsx::YM2413NukeYKT::YM2413::serialize ( Archive &  ar,
unsigned  version 

Definition at line 943 of file

References attack, pokeReg(), and xrange().

◆ setSpeed()

void openmsx::YM2413NukeYKT::YM2413::setSpeed ( double  )

Sets real-time speed factor (aka the openMSX 'speed' setting).

The default implementation does nothing. But e.g. the NukeYKT core needs this.

Reimplemented from openmsx::YM2413Core.

Definition at line 917 of file

◆ writePort()

void openmsx::YM2413NukeYKT::YM2413::writePort ( bool  port,
uint8_t  value,
int  offset 

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 constraints 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 856 of file

The documentation for this class was generated from the following files: