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

Voice

Struct Voice 

Source
pub struct Voice(/* private fields */);
Expand description

A typed voice index in 0..24. Construct via the V0..V23 constants or Voice::new. All per-voice operations are methods on this type.

Implementations§

Source§

impl Voice

Source

pub const V0: Self

Voice index 0.

Source

pub const V1: Self

Voice index 1.

Source

pub const V2: Self

Voice index 2.

Source

pub const V3: Self

Voice index 3.

Source

pub const V4: Self

Voice index 4.

Source

pub const V5: Self

Voice index 5.

Source

pub const V6: Self

Voice index 6.

Source

pub const V7: Self

Voice index 7.

Source

pub const fn new(n: u8) -> Self

Build a voice by index. Panics (const-asserts) if n >= 24.

Source

pub const fn index(self) -> u8

The 0-based voice index this handle points at.

Source

pub const fn mask(self) -> u32

Bitmask this voice occupies in the 24-bit key-on / key-off register pair. Voice::V0.mask() == 0b1.

Source

pub fn set_volume(self, left: Volume, right: Volume)

Set per-voice stereo volume. The main-output mix is still modulated by set_main_volume, but each voice can have its own level.

Source

pub fn set_pitch(self, pitch: Pitch)

Set the voice’s sample-rate pitch (Q5.12). Pitch::UNITY = native 44100 Hz.

Source

pub fn set_start_addr(self, addr: SpuAddr)

Point the voice at the ADPCM sample starting at addr. Voice will begin playing from this address at the next key-on.

Source

pub fn set_loop_addr(self, addr: SpuAddr)

Set the voice’s loop (repeat) address: where playback jumps when a sample block with the loop-end flag finishes. The hardware itself rewrites this register when a block with the loop-start flag passes, so set it AFTER key-on to override; chaining two buffers’ loop addresses is how streamed audio ping-pongs without a key-off.

Source

pub fn set_adsr(self, adsr: Adsr)

Install ADSR envelope parameters on this voice.

Source

pub fn configure_sample( self, addr: SpuAddr, sample_rate_hz: u32, volume: Volume, adsr: Adsr, )

Configure this voice to play a sample already uploaded at addr.

Source

pub fn start(mask: u32)

Trigger the voices whose bits are set in mask. The SPU begins playing each voice from its configured start address, applying its ADSR attack phase.

Example: Voice::start(Voice::V0.mask() | Voice::V3.mask()).

Source

pub fn key_on(mask: u32)

👎Deprecated:

renamed to start

Renamed to start.

Source

pub fn ended_voices() -> u32

Which voices have decoded a block carrying the END flag since ENDX was last cleared, one sticky bit each.

This is the only direct evidence that a one-shot reached its own terminator. Everything else about termination has to be inferred: the repeat address says where the hardware would jump, not whether it did, and the 2026-08-03 SB2 capture read that register back as correct while voices were audibly running into the next sample anyway.

Source

pub fn clear_ended(mask: u32)

Clear the sticky END flags for the voices in mask, so the next Voice::ended_voices reports only what happened after this call.

Source

pub fn release(mask: u32)

Stop the voices whose bits are set in mask – fires the release phase of the ADSR.

Source

pub fn key_off(mask: u32)

👎Deprecated:

renamed to release

Renamed to release.

Source

pub fn set_noise_mask(mask: u32)

Route the voices whose bits are set in mask to the noise generator instead of their ADPCM data (the classic PSX percussion/wind source); voices outside mask play normally. init clears the mask. Pitch comes from the shared noise clock, set_noise_clock, not the voice’s pitch register.

Trait Implementations§

Source§

impl Clone for Voice

Source§

fn clone(&self) -> Voice

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Voice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Voice

Source§

fn eq(&self, other: &Voice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Voice

Source§

impl Eq for Voice

Source§

impl StructuralPartialEq for Voice

Auto Trait Implementations§

§

impl Freeze for Voice

§

impl RefUnwindSafe for Voice

§

impl Send for Voice

§

impl Sync for Voice

§

impl Unpin for Voice

§

impl UnsafeUnpin for Voice

§

impl UnwindSafe for Voice

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.