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

Pitch

Struct Pitch 

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

Q5.12 pitch / sample-rate multiplier. 0x1000 = play at the sample’s recorded rate. Halving = one octave down, doubling = one octave up.

Implementations§

Source§

impl Pitch

Source

pub const UNITY: Self

0x1000 – play at the sample’s native 44100 Hz rate.

Source

pub const OCTAVE_DOWN: Self

0x0800 – one octave below recorded rate.

Source

pub const OCTAVE_UP: Self

0x2000 – one octave above recorded rate.

Source

pub const MAX: Self

Hardware cap (14-bit field). Higher values clamp.

Source

pub const fn raw(v: u16) -> Self

Raw constructor. Values above 0x3FFF clamp on hardware.

Source

pub const fn raw_value(self) -> u16

The raw register value, as Pitch::raw took it. Callers scaling a duration by pitch need the number back: at half unity a sample lasts twice as long, and a cutoff that ignores that clips the sound.

Source

pub const fn for_frequency(target_hz: u32, base_hz: u32) -> Self

Pitch that makes a native-rate sine loop play at hz_num / hz_den where the loop’s natural frequency is base_hz. Integer-only so no_std users can compute at compile time.

Source

pub const fn for_sample_rate(sample_rate_hz: u32) -> Self

Pitch that plays a decoded sample stream at its declared source rate. 44100 maps to Pitch::UNITY.

Source

pub const fn as_u16(self) -> u16

Underlying 14-bit value.

Trait Implementations§

Source§

impl Clone for Pitch

Source§

fn clone(&self) -> Pitch

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 Pitch

Source§

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

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

impl PartialEq for Pitch

Source§

fn eq(&self, other: &Pitch) -> 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 Pitch

Source§

impl Eq for Pitch

Source§

impl StructuralPartialEq for Pitch

Auto Trait Implementations§

§

impl Freeze for Pitch

§

impl RefUnwindSafe for Pitch

§

impl Send for Pitch

§

impl Sync for Pitch

§

impl Unpin for Pitch

§

impl UnsafeUnpin for Pitch

§

impl UnwindSafe for Pitch

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.