Skip to main content

Sfx

Struct Sfx 

Source
pub struct Sfx {
    pub notes: [Note; 32],
    pub speed: u8,
    pub loop_start: u8,
    pub loop_end: u8,
    pub noiz: bool,
    pub buzz: bool,
    pub detune: u8,
    pub reverb: u8,
    pub dampen: u8,
    pub custom_wave: Option<CustomWave>,
}
Expand description

One sound effect: 32 steps played at a configurable speed.

Fields§

§notes: [Note; 32]§speed: u8

Duration of one step in 1/128ths of a second (1..=255).

§loop_start: u8

Loop start step. Looping is active when loop_end > loop_start.

§loop_end: u8

Loop end step (exclusive).

§noiz: bool

Per-SFX filter switches, matching PICO-8’s: replace the noise voice with pure white noise.

§buzz: bool

Buzzier, harmonically richer timbre.

§detune: u8

Detune a second voice against the first. 0 off; 1 a slight, flange-like detune; 2 an octave-ish second voice.

§reverb: u8

Echo with a short delay. 0 off; 1/2 are the two delay lengths.

§dampen: u8

Low-pass softening. 0 off; 1/2 are the two strengths.

§custom_wave: Option<CustomWave>

Some only for slots 0..8 that are drawn-waveform instruments.

Implementations§

Source§

impl Sfx

Source

pub fn is_empty(&self) -> bool

True when no step is audible — used to skip empty slots.

Source

pub fn set_filters(&mut self, byte: u8)

Set the filter switches from PICO-8’s packed filter byte (the 65th byte of an on-cart SFX): bit 1 noiz, bit 2 buzz, then base-3 digits for detune (÷8), reverb (÷24) and dampen (÷72). Bit 0 is PICO-8’s editor mode and carries no sound, so it is ignored.

Source

pub fn filters_byte(&self) -> u8

PICO-8’s packed filter byte — the inverse of Sfx::set_filters: bit 1 noiz, bit 2 buzz, then base-3 digits for detune (x8), reverb (x24) and dampen (x72). Bit 0 (PICO-8’s editor mode) is always left clear.

Trait Implementations§

Source§

impl Clone for Sfx

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sfx

Source§

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

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

impl Default for Sfx

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Sfx

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Sfx

Source§

impl PartialEq for Sfx

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Sfx

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Sfx

Auto Trait Implementations§

§

impl Freeze for Sfx

§

impl RefUnwindSafe for Sfx

§

impl Send for Sfx

§

impl Sync for Sfx

§

impl Unpin for Sfx

§

impl UnsafeUnpin for Sfx

§

impl UnwindSafe for Sfx

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.