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
impl Voice
Sourcepub const fn mask(self) -> u32
pub const fn mask(self) -> u32
Bitmask this voice occupies in the 24-bit key-on / key-off
register pair. Voice::V0.mask() == 0b1.
Sourcepub fn set_volume(self, left: Volume, right: Volume)
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.
Sourcepub fn set_pitch(self, pitch: Pitch)
pub fn set_pitch(self, pitch: Pitch)
Set the voice’s sample-rate pitch (Q5.12). Pitch::UNITY
= native 44100 Hz.
Sourcepub fn set_start_addr(self, addr: SpuAddr)
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.
Sourcepub fn set_loop_addr(self, addr: SpuAddr)
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.
Sourcepub fn configure_sample(
self,
addr: SpuAddr,
sample_rate_hz: u32,
volume: Volume,
adsr: Adsr,
)
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.
Sourcepub fn start(mask: u32)
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()).
Sourcepub fn ended_voices() -> u32
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.
Sourcepub fn clear_ended(mask: u32)
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.
Sourcepub fn release(mask: u32)
pub fn release(mask: u32)
Stop the voices whose bits are set in mask – fires the
release phase of the ADSR.
Sourcepub fn set_noise_mask(mask: u32)
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§
impl Copy for Voice
impl Eq for Voice
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)