pub struct PresetFile {
pub version: u32,
pub instrument: String,
pub presets: Vec<Preset>,
}Expand description
One instrument’s bank of user presets.
Fields§
§version: u32§instrument: StringInstrument key this file belongs to, matching the .phos spelling.
presets: Vec<Preset>Implementations§
Source§impl PresetFile
impl PresetFile
pub fn new(instrument: InstrumentType) -> Self
Sourcepub fn find(&self, name: &str) -> Option<usize>
pub fn find(&self, name: &str) -> Option<usize>
Index of the preset with this name, if the bank holds one.
Names are compared after trimming, so “ pad“ and “pad “ are the same slot rather than two rows the player cannot tell apart.
Sourcepub fn store(
&mut self,
name: &str,
instrument: InstrumentType,
params: &[f32],
) -> Result<StoreOutcome, PresetError>
pub fn store( &mut self, name: &str, instrument: InstrumentType, params: &[f32], ) -> Result<StoreOutcome, PresetError>
Store params under name.
A name already in the bank rewrites that slot in place rather than
adding a second row: the browser lists by name, so two rows called
“warm pad” are two rows the player cannot choose between, and d
would delete an arbitrary one of them. Callers are expected to confirm
before overwriting — find says whether they need to.
Sourcepub fn remove(&mut self, index: usize) -> Option<Preset>
pub fn remove(&mut self, index: usize) -> Option<Preset>
Remove the preset at index, returning it.
Sourcepub fn params_at(
&self,
index: usize,
instrument: InstrumentType,
want_count: usize,
) -> Option<Result<LoadedPreset, PresetError>>
pub fn params_at( &self, index: usize, instrument: InstrumentType, want_count: usize, ) -> Option<Result<LoadedPreset, PresetError>>
The parameter block at index, if it is safe to load into this
instrument’s current panel.
Owned rather than borrowed because the block that comes back is not the block on disk: every selector is repointed at the position the preset named, which for a bank that has changed size is a different fraction from the one that was stored.
Trait Implementations§
Source§impl Clone for PresetFile
impl Clone for PresetFile
Source§fn clone(&self) -> PresetFile
fn clone(&self) -> PresetFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more