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: BImplementations§
Source§impl Cbin<SampleV3>
impl Cbin<SampleV3>
Sourcepub fn sub_name(&self) -> Result<String, Error>
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.
Sourcepub fn stroke_count(&self) -> usize
pub fn stroke_count(&self) -> usize
How many strokes the body carries — one stk section each.
Sourcepub fn zones(&self) -> Result<Vec<ZoneV3>, Error>
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.
Sourcepub fn sty(&self) -> Result<Sty, Error>
pub fn sty(&self) -> Result<Sty, Error>
The instrument’s default sound preset, under the schema its section version selects.
Sourcepub fn meta(&self) -> Result<Meta, Error>
pub fn meta(&self) -> Result<Meta, Error>
The chain’s own length, as its closing meta section states it.
Sourcepub fn chain_len_before_meta(&self) -> usize
pub fn chain_len_before_meta(&self) -> usize
The length meta should state: every section ahead of it on the wire.
Sourcepub fn zone_table(&self) -> Result<Table, Error>
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.
Sourcepub fn set_name(&mut self, name: &str) -> Result<(), Error>
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.
Sourcepub fn zones_are_editable(&self) -> bool
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.
Sourcepub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>
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.
Sourcepub fn set_zone_low_note(&mut self, index: usize, note: u8) -> Result<(), Error>
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.
Sourcepub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>
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.
Sourcepub fn stroke_streams(&self) -> Vec<(usize, &[u8])>
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).
Sourcepub fn zone_stream(&self, index: usize) -> Result<(usize, &[u8]), Error>
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>
impl Cbin<Sample>
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn to_bytes(&self) -> Result<Vec<u8>, Error>
Serializes, recomputing the checksum over the body it just produced.
Sourcepub fn name(&self) -> Result<String, Error>
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.
Sourcepub fn set_name(&mut self, name: &str) -> Result<(), Error>
pub fn set_name(&mut self, name: &str) -> Result<(), Error>
Renames in place, NUL-padding the rest of the field.
Sourcepub fn chain(&self) -> Result<Chain, Error>
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.
Sourcepub fn sty(&self) -> Result<StyV2, Error>
pub fn sty(&self) -> Result<StyV2, Error>
The instrument’s default sound preset — nine enum-quantised bytes.
Sourcepub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>
pub fn set_zone_top_note(&mut self, index: usize, note: u8) -> Result<(), Error>
Sets one zone’s top note. The strokes are untouched.
Sourcepub fn key_table(&self) -> Result<KeyTable, Error>
pub fn key_table(&self) -> Result<KeyTable, Error>
The keyboard map: the instrument’s gain and detune, and one record per MIDI note.
Sourcepub fn set_key_table(&mut self, table: &KeyTable) -> Result<(), Error>
pub fn set_key_table(&mut self, table: &KeyTable) -> Result<(), Error>
Replaces the keyboard map. The zone table and the strokes are untouched.
Sourcepub fn strokes(&self) -> Result<Vec<Stroke>, Error>
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.
Sourcepub fn stroke_streams(&self) -> Vec<(usize, &[u8])>
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.
Sourcepub fn zone_stream(&self, index: usize) -> Result<(usize, &[u8]), Error>
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.
Sourcepub fn set_root_key(&mut self, index: usize, note: u8) -> Result<(), Error>
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.
Sourcepub fn categories(&self) -> Vec<String>
pub fn categories(&self) -> Vec<String>
Category labels, as stored in cat: length-prefixed strings.
Trait Implementations§
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.
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.