QtFM::ChipCore Class
The ChipCore class is the interface of a chip emulation core. More…
| Header | #include <QtFM> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::FM) |
| Module | Nt FM C++ Classes |
List of all members, including inherited members
Public Functions
| virtual | ~ChipCore() |
| virtual ChipType | type() const |
| virtual int | nativeRate() const |
| virtual void | reset() |
| virtual void | write(quint16 reg, quint8 value) |
| virtual void | generate(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
QtFM::ChipCore::~ChipCore()
Destroys the core.
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.
void QtFM::ChipCore::generate(qint32 *stereo, int frames)
Writes the next frames frames of interleaved stereo into stereo.
int QtFM::ChipCore::nativeRate() const
Returns the rate in Hz at which the chip produces samples: 49716 for the OPL2 and OPL3.
void QtFM::ChipCore::reset()
Resets every register and silences the chip.
ChipType QtFM::ChipCore::type() const
Returns the chip that the core emulates.
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.