pub struct OneShot { /* private fields */ }Expand description
A sample with the settings it should be played at.
Implementations§
Source§impl OneShot
impl OneShot
Sourcepub const fn new(sample: Sample, volume: Volume) -> Self
pub const fn new(sample: Sample, volume: Volume) -> Self
A one-shot at its own recorded rate, under [Adsr::default_tone].
default_tone rather than percussive: percussive self-fades in about
150 ms, which is most of a quarter-second sound. The cutoff, not the
envelope, is what stops this.
Sourcepub const fn with_volume(self, volume: Volume) -> Self
pub const fn with_volume(self, volume: Volume) -> Self
Play at a different level. For sounds whose loudness depends on what happened – how hard a hit landed, a volume setting – rather than on which sample it is.
Sourcepub const fn with_pitch(self, pitch: Pitch) -> Self
pub const fn with_pitch(self, pitch: Pitch) -> Self
Play at an explicit pitch instead of the sample’s own rate. 0x1000 is
unity; lower stretches the sound and raises how long it lasts, which
OneShot::ticks accounts for.
Sourcepub const fn ticks(&self, ticks_hz: u32) -> Option<u32>
pub const fn ticks(&self, ticks_hz: u32) -> Option<u32>
How long this will sound, in ticks of a ticks_hz clock, with any
pitch override applied. None when the sample’s length is unknown.
Sourcepub fn configure(&self, voice: Voice)
pub fn configure(&self, voice: Voice)
Point voice at this one-shot without starting it.
Separate from OneShot::play because a program that keeps one voice
per sound can set it up once at boot and then only key on. A program
sharing voices has to do both together.
Sourcepub fn play(&self, voice: Voice)
pub fn play(&self, voice: Voice)
Key this one-shot on voice.
Volume is set on every key-on rather than once at upload, because the
cutoff silences a voice by writing volume 0 and start does not
restore it. Omitting this is how the demo disc’s v0.11 pressing ended
up with a browse blip that played exactly once and never again.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OneShot
impl RefUnwindSafe for OneShot
impl Send for OneShot
impl Sync for OneShot
impl Unpin for OneShot
impl UnsafeUnpin for OneShot
impl UnwindSafe for OneShot
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)