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
impl Pitch
Sourcepub const OCTAVE_DOWN: Self
pub const OCTAVE_DOWN: Self
0x0800 – one octave below recorded rate.
Sourcepub const fn raw_value(self) -> u16
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.
Sourcepub const fn for_frequency(target_hz: u32, base_hz: u32) -> Self
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.
Sourcepub const fn for_sample_rate(sample_rate_hz: u32) -> Self
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.
Trait Implementations§
impl Copy for Pitch
impl Eq for Pitch
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 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
Mutably borrows from an owned value. Read more
§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)
🔬This is a nightly-only experimental API. (
clone_to_uninit)