Skip to main content

CellEvent

Enum CellEvent 

Source
pub enum CellEvent {
    None,
    NoteOn {
        pitch: Pitch,
        velocity: Volume,
    },
    NoteOnGhost {
        pitch: Pitch,
        velocity: Volume,
    },
    InstrReset,
    NoteOff {
        retrig: bool,
    },
    NoteCut,
    NoteFade,
}
Expand description

Unified pattern-cell event.

The variants encode every (note column, instrument column) combination an XM/IT/S3M/MOD cell can carry, plus the ghost-vs-fresh distinction (whether the instrument column was non-empty on the trigger row).

VariantNote sourceInstr-col source
Self::NoneEmptyabsent
Self::NoteOnPlay(p)present
Self::NoteOnGhostPlay(p)absent
Self::InstrResetEmptypresent
Self::NoteOff { retrig: false }KeyOff (===)absent
Self::NoteOff { retrig: true }KeyOff (===)present
Self::NoteCut^^^*
Self::NoteFade~~~*

NoteOff::retrig is a semantic distinction, not a quirk. === xx with an instrument column re-triggers the instrument and then immediately fires key_off: a one-tick attack followed by release — universal to XM/IT/S3M.

Variants§

§

None

Nothing on this cell — both columns empty.

§

NoteOn

Fresh trigger: play pitch with velocity, reset envelopes and sample. Instrument column is present; the actual instrument value comes from Track.instrument.

Fields

§pitch: Pitch
§velocity: Volume
§

NoteOnGhost

Ghost trigger: play pitch with velocity without resetting the live voice (TRIGGER_KEEP_VOLUME). Instrument column is empty; the current voice is reused for the new pitch.

Fields

§pitch: Pitch
§velocity: Volume
§

InstrReset

Instrument column present but note column empty: reload instrument defaults without re-pitching. Drives tick0_change_instr(true) on the channel.

§

NoteOff

Release (KeyOff column, ===).

retrig = false (no instrument column): plain key_off(0). retrig = true (instrument column present): re-trigger the instrument with KEEP_PERIOD, then key_off(0) — a click attack followed by release on the same row. Universal to XM/IT/S3M.

Fields

§retrig: bool
§

NoteCut

Hard cut (^^^). Volume → 0 immediately. The actual cut work happens via the row’s TrackEffect::NoteCut effect; the note-column ^^^ is inert at dispatch.

§

NoteFade

Start fadeout without releasing the envelope (~~~). IT-style note-column event; behaves identically regardless of instrument-column state.

Implementations§

Source§

impl CellEvent

Source

pub fn from_columns( note: CellNote, instrument: Option<usize>, velocity: Volume, ) -> Self

Build a CellEvent from the three pattern-editor columns: note, instrument, velocity.

This is the single mapping site between the column-oriented representation (still used by importers and pattern-editor UIs) and the typed variant. See crate::tracker::import::unit::TrackImportUnit for the importer-side column trio.

Source

pub fn pitch(&self) -> Option<Pitch>

Pitch carried by note-on variants; None otherwise.

Source

pub fn velocity(&self) -> Volume

Trigger velocity for Self::NoteOn / Self::NoteOnGhost. Volume::FULL for any other variant — non-trigger cells have no meaningful velocity, and downstream code that always multiplies by velocity sees a no-op.

Source

pub fn has_instrument_column(&self) -> bool

true when the originating cell had a non-empty instrument column.

Source

pub fn is_trigger(&self) -> bool

true for variants that fire a fresh playback trigger (NoteOn / NoteOnGhost).

Source

pub fn is_release(&self) -> bool

true for variants that release / cut / fade the held note (NoteOff / NoteCut / NoteFade).

Source

pub fn to_cell_note(&self) -> CellNote

Project onto a CellNote enum (note-column only). Useful for debug printers and UI code that surfaces the soundtracker-style --- / C-5 / === / ^^^ / ~~~ notation. Lossy: discards the retrig flag of Self::NoteOff and flattens Self::InstrReset back onto CellNote::Empty.

Trait Implementations§

Source§

impl Clone for CellEvent

Source§

fn clone(&self) -> CellEvent

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 Copy for CellEvent

Source§

impl Debug for CellEvent

Source§

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

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

impl Default for CellEvent

Source§

fn default() -> CellEvent

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

impl<'de> Deserialize<'de> for CellEvent

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 CellEvent

Source§

impl PartialEq for CellEvent

Source§

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

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 CellEvent

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.