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

Sound

Struct Sound 

Source
pub struct Sound { /* private fields */ }
Expand description

A sample together with how the mixer should treat it.

Within a class a smaller prio is more important, matching WipEout’s signed priority and Quake’s channel order.

§Example

use psx_sfx::mixer::*;
use psx_sfx::Sample;
use psx_spu::SpuAddr;

let s = Sample::resident(SpuAddr::new(0x1010), 22050, 40);
let horn = Sound::one_shot(SoundId(9), s, 1).with_class(Class::Protected).with_volume(0x3000);
assert_eq!(horn.class(), Class::Protected);
assert!(!horn.is_looped());

Implementations§

Source§

impl Sound

Source

pub const fn one_shot(id: SoundId, sample: Sample, lane: u8) -> Self

A sample that plays once and ends, on lane lane.

Source

pub const fn looped(id: SoundId, sample: Sample, lane: u8) -> Self

A sample whose cooked blocks form a hardware loop, on lane lane. It plays until stopped.

Source

pub const fn with_class(self, class: Class) -> Self

Set the importance class.

Source

pub const fn with_prio(self, prio: i16) -> Self

Set the priority within the class; smaller is more important.

Source

pub const fn with_volume(self, volume: i16) -> Self

Set the default per-ear level used by Play::for_sound.

Source

pub const fn with_pitch(self, pitch_q12: u16) -> Self

Set the default pitch multiplier (4096 = as cooked).

Source

pub const fn with_duck(self, gain_q12: u16) -> Self

While this sound plays, ask for the music to be ducked to gain_q12 (4096 = no duck, 2048 = half).

Source

pub const fn id(&self) -> SoundId

The caller’s identity for this sound.

Source

pub const fn sample(&self) -> Sample

The sample.

Source

pub const fn lane(&self) -> u8

The lane this sound plays on.

Source

pub const fn class(&self) -> Class

The importance class.

Source

pub const fn prio(&self) -> i16

Priority within the class.

Source

pub const fn is_looped(&self) -> bool

Does it loop until stopped?

Trait Implementations§

Source§

impl Clone for Sound

Source§

fn clone(&self) -> Sound

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 Sound

Source§

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

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

impl Copy for Sound

Auto Trait Implementations§

§

impl Freeze for Sound

§

impl RefUnwindSafe for Sound

§

impl Send for Sound

§

impl Sync for Sound

§

impl Unpin for Sound

§

impl UnsafeUnpin for Sound

§

impl UnwindSafe for Sound

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.