Module cdda

Module cdda 

Source
Expand description

CD-DA: the audio player behind AUDIO START/END/PAUSE, READ SUBQ, $1805-$1806 and the audio source the board mixes (cdda.py).

Time is exact and lazy: the player keeps an anchor (the master clock at which a given sample of a given sector played) and computes the position for any mclk, so playback does not depend on how often the host asks for samples. 44,100 stereo samples a second, 588 per 2352-byte sector, 75 sectors a second [hw: Red Book]. Samples are signed 16-bit little-endian pairs.

What is not modelled (U9): the drive’s subchannel Q stream (the BIOS’s $1807 read and its IRQ bit 0x10), the DAC’s filtering (Mednafen filters, Mesen2 resamples with a Hermite kernel), and the real fader curve: the times are the Hudson BIOS manual’s 6 s / 2.5 s (tier 3; pcetech’s tier-2 “about 8 seconds” / “about 2 seconds” is the pcetech_fade switch) and the shape between is linear here (Mesen2 fades 1% per 60 ms / 25 ms, i.e. 6 s / 2.5 s; MAME calls its own fader “sketchy and unchecked against real HW”).

Differences forced by Rust:

  • The fader is its own value (Fader), shared by the player and the ADPCM unit through an Rc<Cell<_>>: both are audio sources the mixer borrows at once, and the reference’s ADPCM source calls unit.cdda.fade_gain. The reference’s class attributes (FADE_*, PCETECH_*) are the fader’s fields; SUBQ_STATUS is the player’s subq_status.
  • on_good_status (the reference’s callback into the SCSI bus) is a count, good_status_due, that the bus takes after each run_to and answers in the same place. take_samples (the mixer’s call) also runs the player’s events, as the reference’s does; the board has always run the unit up to its clock before it mixes, so nothing fires there.
  • The decoded sector kept between samples (_cache) is not part of a save state.

Structs§

CddaPlayer
Fader
The $180F fader: the register, when its timer started, and the fade times.

Enums§

EndMode
Status

Constants§

SAMPLES_PER_SECTOR
SAMPLE_HZ