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

Hw

Trait Hw 

Source
pub trait Hw {
    // Required methods
    fn configure(
        &mut self,
        voice: u8,
        sample: &Sample,
        looped: bool,
        pitch_q12: u16,
    );
    fn set_volume(&mut self, voice: u8, left: i16, right: i16);
    fn set_pitch(&mut self, voice: u8, pitch_q12: u16);
    fn key_on(&mut self, mask: u32);
    fn key_off(&mut self, mask: u32);
}
Expand description

What the mixer needs from a sound chip.

Voice numbers are 0..24. Masks have bit n set for voice n.

§Example

use psx_sfx::hw::{Hw, NullHw};

let mut hw = NullHw;
hw.key_off(0b101); // accepted and ignored

Required Methods§

Source

fn configure( &mut self, voice: u8, sample: &Sample, looped: bool, pitch_q12: u16, )

Point voice at sample without starting it. looped selects the hardware-loop setup; a one-shot also gets its repeat address written so it parks on silence. pitch_q12 is a multiplier of the cooked rate (4096 plays it as recorded).

Source

fn set_volume(&mut self, voice: u8, left: i16, right: i16)

Write a voice’s left and right volume (signed SPU levels, already scaled by the master volume).

Source

fn set_pitch(&mut self, voice: u8, pitch_q12: u16)

Change a playing voice’s pitch multiplier (4096 = as cooked).

Source

fn key_on(&mut self, mask: u32)

Key on every voice in mask.

Source

fn key_off(&mut self, mask: u32)

Key off (release) every voice in mask.

Implementors§

Source§

impl Hw for NullHw

Source§

impl<const CAP: usize> Hw for Recorder<CAP>