Module chip

Module chip 

Source
Expand description

The HuC6280’s programmable sound generator: six wavetable channels, noise, LFO, DDA (psg/chip.py).

Written (in the reference) from Hudson’s HuC6280 PSG Manual (tier 3: “manual” below) and MacDonald’s pcetech §10 and §2.4 (tier 2); where those are silent the choice is named in a comment with a U/C number (docs/m4-record.md) and may be changed by a switch. There is no hardware audio reference anywhere: every output of this module is provisional, tier 5.

Time: one step is one PSG clock, master/6 = 3.58 MHz [pcetech 2.4; the manual’s “7.16 MHz” and its formulas’ factor 2 agree]. A channel’s waveform index advances every F steps (F = the 12-bit frequency, 0 meaning 4096) [pcetech 10: $000 is the lowest frequency; manual 2.2.1: f = fmaster / (2 x 32 x F)]. The model is event-driven: output is constant between index changes.

Within a step every channel’s output is taken from the state at the start of the step and the counters then advance together (the manual says nothing of an order): ch 1’s modulation of ch 0 therefore reads ch 2’s sample before ch 2 advances in the same step.

Differences forced by Rust: the class attributes are the fields of PsgSwitches (Psg::switches), with variant("mame") and variant("mednafen") for the reference’s VARIANTS; keyon_mode is an enum. The step-stream listeners (the reference’s referee comparison, Python-side tooling) are not carried over. The host-rate arithmetic is the reference’s, in f64, operation for operation.

Structs§

Channel
Psg
PsgSwitches
The points on which the manual and pcetech are silent or the two readable emulators differ (docs/m4-record.md, C13-C23). Each default below follows the manual or pcetech where they speak, else the larger share of the sources; variant flips them to one emulator’s way.

Enums§

KeyOnMode
C22: what key-on (ON 0 -> 1) does to a waveform channel.

Constants§

NOISE_TAPS
PSG_CLOCK_DIVIDER
SILENT_UNITS