pub struct Preset {
pub name: String,
pub instrument: String,
pub layout: String,
pub param_count: usize,
pub params: Vec<f32>,
pub discrete: Vec<SessionSelector>,
pub version: u32,
}Expand description
A single stored preset.
instrument, param_count, layout and version are all redundant with
the file they sit in — deliberately. A preset that gets hand-copied between
files, or survives a parameter layout change, still carries enough to be
refused rather than loaded into the wrong panel, and enough to say which
format wrote it rather than inheriting the claim of the file it landed in.
Fields§
§name: String§instrument: String§layout: StringFingerprint of the parameter layout this was saved against.
param_count: usize§params: Vec<f32>§discrete: Vec<SessionSelector>Where every selector on this panel was pointing, by position rather than by knob fraction. Empty in version 1 presets.
The same shape the session format stores, and the same type: one spelling of “this control was on position 3” for both files, so a change to how positions are counted cannot move one and leave the other behind.
version: u32The format version that wrote this preset. Absent in version 1 files.
Implementations§
Source§impl Preset
impl Preset
Sourcepub fn check(
&self,
instrument: InstrumentType,
want_count: usize,
) -> Result<(), PresetError>
pub fn check( &self, instrument: InstrumentType, want_count: usize, ) -> Result<(), PresetError>
Whether this preset can be loaded into instrument’s current panel of
want_count controls. Refuses rather than truncating or padding: a
block that is the wrong length or the wrong order is a different panel,
and copying it in slot by slot produces a plausible wrong sound with
nothing on screen to say so.
Sourcepub fn resolve(&self, instrument: InstrumentType) -> LoadedPreset
pub fn resolve(&self, instrument: InstrumentType) -> LoadedPreset
The panel to apply, with every selector put back where it was pointing.
The stored fractions go in first and the positions are written over
them, so a control the preset has no position for — anything a version 1
preset holds, or a switch added since — keeps its fraction rather than
being reset to a default. Call check first: this
assumes the block belongs to instrument.