pub struct Spu(/* private fields */);Expand description
The SPU’s memory-moving driver: it owns the SPU’s DMA channel, so the one operation that copies RAM into sound RAM, the ADPCM upload, is a method here and the borrow checker sees a second uploader.
The voice, volume and reverb registers are free functions in this crate: writing one cannot touch RAM, so they need no owner yet.
let mut spu = psx_spu::Spu::new(peripherals.spu_dma);
spu.upload_adpcm(SpuAddr::new(0x1010), &TONE_SAMPLE);Implementations§
Source§impl Spu
impl Spu
Sourcepub fn new(dma: SpuDma) -> Self
pub fn new(dma: SpuDma) -> Self
Take over the SPU: reset it to a sane playable state and write the silence block every one-shot’s repeat address points at.
Sets:
- SPUCNT: enable, unmute, default reverb off, CD audio off
- Main volume: max
- Every voice: silenced (volume 0, ADSR release fire, key-off)
- Reverb input and wet-output depth, pitch-mod, and noise: all disabled
- Transfer mode: “normal” (the upload path we expose)
Call once at boot before any voice operations.
Sourcepub fn upload_adpcm(&mut self, dest: SpuAddr, bytes: &[u8])
pub fn upload_adpcm(&mut self, dest: SpuAddr, bytes: &[u8])
Upload ADPCM sample bytes to SPU RAM.
Goes over DMA channel 4 when bytes is word-aligned and a whole number
of words, which is fast and the only reliable path past the 32-halfword
transfer FIFO, and otherwise falls back to the manual-transfer (PIO)
path, one halfword per write.
bytes must be a multiple of 2 (one halfword per two bytes).
dest must be 8-byte-aligned (the SPU voice-start register’s
resolution) and above the silence block.
§Panics
If bytes is odd in length, or dest overlaps the silence block at
0x1000.