Skip to main content

Cbin

Struct Cbin 

Source
pub struct Cbin<B> {
    pub header: Header,
    pub body: B,
}
Expand description

One decoded file: its header and its body.

Derefs to the body: the body is the entity, and the container is its file identity, so file.center_panel reads as the entity access it is.

Fields§

§header: Header§body: B

Implementations§

Source§

impl<B: Body> Cbin<B>

Source

pub fn write_to(&self, w: &mut (impl Write + Seek)) -> Result<(), Error>

Source§

impl Cbin<SampleV3>

Source

pub fn name(&self) -> Result<String, Error>

The instrument’s main name.

Source

pub fn sub_name(&self) -> Result<String, Error>

The sub name — the string after the _ in the vendor’s filenames. Empty on files that carry none.

It starts where the main name’s field ends. Where it ends is unmapped, so this reads to the terminator with no field bound behind it and there is no setter.

Source

pub fn stroke_count(&self) -> usize

How many strokes the body carries — one stk section each.

Source

pub fn zones(&self) -> Result<Vec<ZoneV3>, Error>

Keyboard zones, in stored order, which is usually high to low; map v14 files occur in both orders and a record states its own notes. Each zone is verified against the stroke it names.

Source

pub fn sty(&self) -> Result<Sty, Error>

The instrument’s default sound preset, under the schema its section version selects.

Source

pub fn meta(&self) -> Result<Meta, Error>

The chain’s own length, as its closing meta section states it.

Source

pub fn chain_len_before_meta(&self) -> usize

The length meta should state: every section ahead of it on the wire.

Source

pub fn zone_table(&self) -> Result<Table, Error>

The zone table, located the same way Self::zones locates it.

Carries the record layout and, through zone::Table::key_map, what the map’s per-key table holds.

Source

pub fn set_name(&mut self, name: &str) -> Result<(), Error>

Renames in place, NUL-padding the rest of the main-name field. The sub-name is a separate field and is left alone.

Source

pub fn zones_are_editable(&self) -> bool

Whether this body’s zones can be retuned and remapped.

True wherever the zone table reads and, if the map also describes the keyboard note by note, that table can be recomputed from the layout.

Source

pub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>

Sets one zone’s top note, in Self::zones order. The strokes are untouched.

Source

pub fn set_zone_low_note(&mut self, index: usize, note: u8) -> Result<(), Error>

Sets one zone’s lowest note, on the layouts that store one.

Source

pub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>

Retunes one zone by moving the note its sample plays untransposed at.

⚠️ The root key is stored twice — once in the stroke, once duplicated into the zone record — and the table stops reading if the two disagree, so both move here or neither does.

Source

pub fn stroke_streams(&self) -> Vec<(usize, &[u8])>

Every stroke’s encoded stream with its offset from the start of the body, in file order.

The offset is the base the stroke’s own codec::Directory is written against, so a caller checking those pointers needs this pairing rather than the payload alone. Decode the streams with codec::Layout::from_version(self.header.version).

Source

pub fn zone_stream(&self, index: usize) -> Result<(usize, &[u8]), Error>

One zone’s encoded stream, in Self::zones order. Decode it with codec::Layout::from_version(self.header.version).

Paired by the global id the zone record names, so it is safe on library content whose strokes are not in zone order.

Source§

impl Cbin<Sample>

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes, recomputing the checksum over the body it just produced.

Source

pub fn name(&self) -> Result<String, Error>

Instrument name, as the Nord display shows it.

The editor composes this from separate Main, Sub and Aux fields joined with _, so an empty Sub shows up as a doubled underscore rather than a typo.

⚠️ Empty on Chain::Early, whose 18-byte hdr has no name field at all — those instruments carry no name and Self::set_name has nowhere to put one. Ask Self::chain before reporting the empty string as the name.

Source

pub fn set_name(&mut self, name: &str) -> Result<(), Error>

Renames in place, NUL-padding the rest of the field.

Source

pub fn chain(&self) -> Result<Chain, Error>

Which narrow chain this body’s sections form, from the map section’s own version. An unknown one refuses rather than decoding on a guess; the section chain, the name and the checksum still read.

Source

pub fn zones(&self) -> Result<Vec<Zone>, Error>

Keyboard zones, high to low.

Source

pub fn sty(&self) -> Result<StyV2, Error>

The instrument’s default sound preset — nine enum-quantised bytes.

Source

pub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>

Sets one zone’s top note. The strokes are untouched.

Source

pub fn key_table(&self) -> Result<KeyTable, Error>

The keyboard map: the instrument’s gain and detune, and one record per MIDI note.

Source

pub fn set_key_table(&mut self, table: &KeyTable) -> Result<(), Error>

Replaces the keyboard map. The zone table and the strokes are untouched.

Source

pub fn strokes(&self) -> Result<Vec<Stroke>, Error>

One stroke per zone, in Self::zones order — which is not file order.

Each zone names its stroke by id, and only instruments built in a single editor pass have those ids running parallel to the sections. Zipping this against zones() is therefore safe; indexing it as “the nth stk section” is not.

Source

pub fn stroke_streams(&self) -> Vec<(usize, &[u8])>

Every stroke’s encoded stream with its offset from the start of the body, in file order.

The offset is the base the stroke’s own codec::Directory is written against, so a caller checking those pointers needs this pairing rather than the payload alone.

Source

pub fn zone_stream(&self, index: usize) -> Result<(usize, &[u8]), Error>

One zone’s encoded stream, in Self::zones order, ready for codec::decode.

Paired by stroke id like Self::strokes, so it is safe on library content that the editor did not build in a single pass.

Source

pub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>

Retunes one zone by moving the note its sample plays untransposed at.

index is into Self::zones, matching Self::set_zone_top_note — so the stroke it reaches is the one that zone names, not the nth section. The two are the same file order only for instruments the editor built in a single pass.

Source

pub fn categories(&self) -> Vec<String>

Category labels, as stored in cat: length-prefixed strings.

Trait Implementations§

Source§

impl<B: Debug> Debug for Cbin<B>

Source§

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

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

impl<B> Deref for Cbin<B>

Source§

type Target = B

The resulting type after dereferencing.
Source§

fn deref(&self) -> &B

Dereferences the value.
Source§

impl<B> DerefMut for Cbin<B>

Source§

fn deref_mut(&mut self) -> &mut B

Mutably dereferences the value.
Source§

impl Item<RangedU16Pair<BANK_COUNT, SLOT_COUNT>> for Cbin<Song>

Source§

impl Item<RangedU16Pair<BANK_COUNT, SLOT_COUNT>> for Cbin<Program>

⚠️ Programs and live slots are one type, so a ne5l file placed in a program Bank lands wherever its live slot number falls in the program space. The tag in the header is what tells the two apart.

Source§

impl Registry for Cbin<Program>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<Settings>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<Program>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<Program>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<SynthPreset>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<Program>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<OrganPreset>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<PianoPreset>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.
Source§

impl Registry for Cbin<SynthPreset>

Source§

fn fields(&self) -> Vec<Field>

Every settable field, described under its full path.
Source§

fn field_values(&self) -> Vec<FieldValue>

Every registered field’s current value, in declaration order.
Source§

fn set_field(&mut self, path: &str, value: &str) -> Result<(), FieldError>

Set one field by its full path.

Auto Trait Implementations§

§

impl<B> Freeze for Cbin<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Cbin<B>
where B: RefUnwindSafe,

§

impl<B> Send for Cbin<B>
where B: Send,

§

impl<B> Sync for Cbin<B>
where B: Sync,

§

impl<B> Unpin for Cbin<B>
where B: Unpin,

§

impl<B> UnsafeUnpin for Cbin<B>
where B: UnsafeUnpin,

§

impl<B> UnwindSafe for Cbin<B>
where B: UnwindSafe,

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.