Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module audio

Module audio 

Source
Expand description

CD-DA playback helpers: a start-handshake state machine and an audio-anchored clock.

Both are extractions of code that at least three projects grew independently (gh-psx, the magikarp example, the engine’s private CddaPlayer), and both encode silicon findings that are expensive to rediscover:

  • Starting CD-DA after the no-BIOS fast boot needs the drive PRIMED: SetMode -> Demute -> Play, with a GetStat drain AFTER each command (a GetStat immediately before a command wedges the controller instead), a cold-drive delay before the first command, and retry pacing between attempts. PlaybackStarter is that machine.
  • A song clock read from the vblank counter drifts off the audio (the display and the CD run on different oscillators), while GetlocP alone is jittery and coarse (75 Hz). PlaybackClock anchors on GetlocP and interpolates with ticks, with a deadband, spike confirmation, and monotonic output.

Both are poll-driven: call them once per frame/tick with your tick counter. Neither takes an interrupt or blocks beyond the bounded command spins.

Structs§

EndDetector
Track-end detection that survives real drive behaviour.
PlaybackClock
Audio-anchored song clock: GetlocP anchor + tick interpolation.
PlaybackStarter
Poll-driven CD-DA start handshake (SetMode -> Demute -> Play).

Constants§

COLD_DRIVE_DELAY_TICKS
Ticks to wait before the very first command: hammering CD commands while the drive is still cold from boot can wedge it (observed on silicon).
DEFAULT_COMMAND_SPINS
Per-command response spin budget. Generous; the drive answers far sooner.