Skip to main content

Step

Struct Step 

Source
pub struct Step {
    pub on: bool,
    pub octave: u8,
    pub key: u8,
    pub chord: u8,
    pub voicing: u8,
    pub accent: bool,
    pub gate: u8,
    pub reserved: [u8; 2],
}
Expand description

One cell of the grid.

Nine bytes, laid out so that the whole pattern is a plain block of memory that can be memcpy’d to the audio thread. reserved is room for the two per-step features that are already designed and not yet built — probability and ratchets — so that adding them later is not a change to the size of anything.

Fields§

§on: bool

Whether this step fires.

§octave: u8

Octave part of the pitch: the note is octave * 12 + key. The UI presents one pitch control; the storage stays split because that is what a mode-quantised walk needs.

§key: u8

Pitch class part of the pitch, 0..=11.

§chord: u8

Which Chord this step plays, by Chord::index.

§voicing: u8§accent: bool

Whether the step takes the pattern’s accent velocity rather than its base velocity. Per-step numeric velocity is a later change to this same field and needs no migration.

§gate: u8

Gate length as a percentage of the step, or Step::TIE.

§reserved: [u8; 2]

Probability and ratchets, when they arrive.

Implementations§

Source§

impl Step

Source

pub const TIE: u8 = 255

A gate that holds the note until the lane’s next onset.

255 rather than a separate field because a gate is one control: the UI walks it up through the percentages and off the end into the tie, which is where a player expects to find it.

Source

pub const MIN_GATE: u8 = 5

Shortest gate. Below this the note-off arrives before an envelope has opened and the step is inaudible, which reads as a broken step.

Source

pub const MAX_GATE: u8 = 200

Longest gate: twice the step, so a step can hold through the next one.

Source

pub const ROOT_BELOW: u8 = 0b0000_0100

Bit in Step::voicing that doubles the root an octave below.

Independent of the voicing rather than four more entries in the list, because it composes with all of them.

Source

pub const fn silent() -> Self

A step that is off, at middle C, one note, half gate.

Source

pub fn root(self) -> u8

The root note this step plays, clamped into the MIDI range.

Source

pub fn chord_kind(self) -> Chord

Source

pub fn voicing_kind(self) -> Voicing

Source

pub fn root_below(self) -> bool

Source

pub fn gate_ticks(self, ticks_per_step: i64) -> Option<i64>

How long this step holds, in ticks — or None when it is tied and only the lane’s next onset ends it.

The gate is clamped here rather than where it is written, so that a value out of range can only ever shorten or lengthen a note rather than produce one with a negative length.

Trait Implementations§

Source§

impl Clone for Step

Source§

fn clone(&self) -> Step

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 Step

Source§

impl Debug for Step

Source§

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

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

impl Default for Step

Source§

fn default() -> Self

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

impl Eq for Step

Source§

impl PartialEq for Step

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Step

Auto Trait Implementations§

§

impl Freeze for Step

§

impl RefUnwindSafe for Step

§

impl Send for Step

§

impl Sync for Step

§

impl Unpin for Step

§

impl UnsafeUnpin for Step

§

impl UnwindSafe for Step

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, <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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more