6.0.0-rc4Source

QtFM::ChipCore Class

The ChipCore class is the interface of a chip emulation core. More…

Header#include <QtFM>
CMaketarget_link_libraries(app PRIVATE Nt::FM)
ModuleNt FM C++ Classes

List of all members, including inherited members

Public Functions

virtual ~ChipCore()
virtual ChipTypetype() const
virtual intnativeRate() const
virtual voidreset()
virtual voidwrite(quint16 reg, quint8 value)
virtual voidgenerate(qint32 *stereo, int frames)

Static Public Members

std::unique_ptr<ChipCore>create(ChipType type)

Detailed Description

A core models a sound chip at its native rate: write() sets a register, and generate() produces the next frames of stereo output, in the chip's own 16-bit-scale integers. The engine resamples it to its own rate. create() makes the built-in cores: an OPL2 or an OPL3, emulated by Nt FM's own clean-room model of the chips.

std::unique_ptr<QtFM::ChipCore> opl = QtFM::ChipCore::create(QtFM::ChipType::OPL2);
opl->write(0x20, 0x01); // and so on, as an AdLib driver would

Differences from Qt

The OPLL, OPN2 and OPM have no core yet; nor does the SN76489 that VGM files of the Mega Drive also use. The OPL model is not cycle-accurate.

Member Function Documentation

[virtual] QtFM::ChipCore::~ChipCore()

Destroys the core.

[static] std::unique_ptr<ChipCore> QtFM::ChipCore::create(ChipType type)

Returns a new core for type, or nullptr if Nt FM has none: ChipType::OPL2 and ChipType::OPL3 have one.

[virtual] void QtFM::ChipCore::generate(qint32 *stereo, int frames)

Writes the next frames frames of interleaved stereo into stereo.

[virtual] int QtFM::ChipCore::nativeRate() const

Returns the rate in Hz at which the chip produces samples: 49716 for the OPL2 and OPL3.

[virtual] void QtFM::ChipCore::reset()

Resets every register and silences the chip.

[virtual] ChipType QtFM::ChipCore::type() const

Returns the chip that the core emulates.

[virtual] void QtFM::ChipCore::write(quint16 reg, quint8 value)

Writes value to the register reg. Registers of the second bank of the OPL3 are 0x100 to 0x1FF.