Skip to main content

ControlKind

Enum ControlKind 

Source
pub enum ControlKind {
    Toggle,
    Selector,
    Knob(Unit),
    Bipolar(Unit),
    Drawbar {
        bars: u8,
        rank: Option<u8>,
        bits_per_bar: u8,
        order: PackedOrder,
    },
    Morph {
        of: Option<&'static str>,
    },
    Pattern {
        steps: u8,
        bits_per_step: u8,
        order: PackedOrder,
    },
    Reference(Library),
    Shift(Unit),
    Number,
}
Expand description

What the panel puts under a reader’s finger.

The registry already says where a field sits and which values it takes; this says what kind of thing it is, so a caller can choose a widget without a table of field names beside it. It comes from the field’s type, so a field gets it right by being declared with the type that matches the control — a bool is a button, a Level is a knob.

Variants§

§

Toggle

A two-state button. Its two states may have names — see the field’s legal values.

§

Selector

A selector over a fixed set of named values.

§

Knob(Unit)

A continuous knob or slider, reading in unit.

§

Bipolar(Unit)

A knob whose musical zero is its centre, reading in unit either side.

§

Drawbar

One or more drawbars, each 0..=8, drawn as bars rather than numbers.

Fields

§bars: u8

How many bars the field holds, in register order. The Stage models give each bar its own field and the Electro 5 packs a whole register into one, so this is what tells a caller which it is holding.

§rank: Option<u8>

Where the field’s first bar sits in the register: 1 is the leftmost bar, 9 the rightmost of a nine-bar manual. A whole register starts at 1 and a single Stage bar carries its own position.

⚠️ A position, not a pitch. Which harmonic each position draws is the organ model’s business — the B3’s 16’/5⅓’/8’ series is not the Vox’s or the Farfisa’s, and the same nine positions serve all of them here — so labelling them is for a caller that knows which model the field belongs to.

None where the declaration does not place the bar in a register at all: the Electro 5’s bass manual, whose two bars nothing establishes the position of.

§bits_per_bar: u8

Bits one bar occupies.

§order: PackedOrder

Which end of the field the first bar sits at. Only meaningful above one bar, and the reason it is here: the Electro 5 packs its nine nibbles high-first while the arpeggiator packs its steps low-first, so a caller reading one by the other’s convention draws the register mirrored.

§

Morph

The value a performance control morphs its parent parameter to. Belongs on that parent’s control, not on one of its own.

Fields

§of: Option<&'static str>

The parent parameter’s field name, as a sibling of this field — the full path is this field’s path with its last segment replaced, which is what FieldSpec::morph_parent does.

None where the body declares no parameter under the name this slot’s own name implies, so the slot stands alone until one is placed beside it.

§

Pattern

A per-step pattern grid: steps steps of bits_per_step bits, the first step at the order end.

Fields

§steps: u8
§bits_per_step: u8
§

Reference(Library)

An opaque id into one of the instrument’s libraries.

§

Shift(Unit)

A signed shift, reading in unit.

§

Number

An integer nothing has been claimed about — the default, and a standing invitation to give the field a type that says more.

Implementations§

Source§

impl ControlKind

Source

pub const fn morphing(self, parent: &'static str) -> ControlKind

Name the parent a morph slot morphs — the sibling field, not a path.

#[bitbody] applies this from the field’s own name, and only where the body really declares that sibling. Every other kind is returned unchanged, so a field named like a morph slot but typed as something else keeps what its type said.

Source

pub const fn ranked(self, rank: u8) -> ControlKind

Place a drawbar in its register: rank 1 is the leftmost bar.

Applied by #[bitbody] from a …_N field name, and ignored by every other kind — a field whose name happens to end in a digit is not a drawbar unless its type says so.

Trait Implementations§

Source§

impl Clone for ControlKind

Source§

fn clone(&self) -> ControlKind

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 ControlKind

Source§

impl Debug for ControlKind

Source§

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

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

impl Eq for ControlKind

Source§

impl Hash for ControlKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ControlKind

Source§

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

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<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<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<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> 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.