pub struct SamplerInstrument {
pub name: String,
pub origin: String,
pub description: String,
pub author: String,
pub tuning: TuningTable,
pub zones: Vec<SampleZone>,
pub zone_groups: Vec<ZoneGroup>,
pub attack: f32,
pub decay: f32,
pub sustain: f32,
pub release: f32,
pub max_voices: usize,
}Expand description
A complete sampler instrument.
Fields§
§name: StringInstrument name.
origin: StringCultural/geographic origin (e.g. “Ethiopian”, “Indian”, “Western”).
description: StringDescription.
Author.
tuning: TuningTableTuning system.
zones: Vec<SampleZone>All sample zones (legacy flat list, kept for backward compatibility).
zone_groups: Vec<ZoneGroup>Zone groups (new grouped list with round-robin support).
attack: f32ADSR envelope: attack, decay, sustain, release (seconds/level).
decay: f32§sustain: f32§release: f32§max_voices: usizeMaximum polyphony (simultaneous voices).
Implementations§
Source§impl SamplerInstrument
impl SamplerInstrument
pub fn new(name: &str) -> Self
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalize the instrument after deserialization. If zone_groups is empty, populate it from zones (each zone → ZoneGroup with Sequential mode).
Sourcepub fn find_zone(&self, note: u8, velocity: u8) -> Option<&SampleZone>
pub fn find_zone(&self, note: u8, velocity: u8) -> Option<&SampleZone>
Find the best matching zone for a note + velocity. If multiple zones match, prefer the one whose root_note is closest.
Sourcepub fn find_zone_rr<'a>(
&'a self,
note: u8,
velocity: u8,
rr_state: &mut RoundRobinState,
) -> Option<&'a SampleZone>
pub fn find_zone_rr<'a>( &'a self, note: u8, velocity: u8, rr_state: &mut RoundRobinState, ) -> Option<&'a SampleZone>
Find a zone using round-robin selection. Returns the selected zone from the first matching zone group.
Sourcepub fn add_zone(&mut self, zone: SampleZone)
pub fn add_zone(&mut self, zone: SampleZone)
Add a zone.
Trait Implementations§
Source§impl Clone for SamplerInstrument
impl Clone for SamplerInstrument
Source§fn clone(&self) -> SamplerInstrument
fn clone(&self) -> SamplerInstrument
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SamplerInstrument
impl Debug for SamplerInstrument
Source§impl<'de> Deserialize<'de> for SamplerInstrument
impl<'de> Deserialize<'de> for SamplerInstrument
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SamplerInstrument
impl RefUnwindSafe for SamplerInstrument
impl Send for SamplerInstrument
impl Sync for SamplerInstrument
impl Unpin for SamplerInstrument
impl UnsafeUnpin for SamplerInstrument
impl UnwindSafe for SamplerInstrument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more