Struct sofiza::Instrument
source · [−]pub struct Instrument {
pub global: HashMap<String, Opcode>,
pub groups: Vec<Group>,
pub regions: Vec<Region>,
pub default_path: PathBuf,
/* private fields */
}
Expand description
Represents the SFZ instrument parsed
All units in the sfz format are in real-world values: Frequencies are expressed in Hertz, pitches in cents, amplitudes in percentage and volumes in decibels.
Notes are expressed in MIDI Note Numbers, or in note names according to the International Pitch Notation (IPN) convention. According to this rules, middle C in the keyboard is C4 and the MIDI note number 60.
Fields
global: HashMap<String, Opcode>
The default opcodes for this instrument.
groups: Vec<Group>
The list of groups.
The opcodes in a group overrides those in global, for the associated region.
regions: Vec<Region>
The list of regions.
The opcodes in a region overrides those in global and in its group.
default_path: PathBuf
The default path.
Implementations
sourceimpl Instrument
impl Instrument
sourcepub fn new() -> Instrument
pub fn new() -> Instrument
Creates an empty Instrument
sourcepub fn from_file(sfz_path: &Path) -> Result<Self>
pub fn from_file(sfz_path: &Path) -> Result<Self>
Creates an Instrument via loading and parsing some SFZ code in a file
sourcepub fn from_sfz(sfz: &str, sfz_path: &Path) -> Result<Self>
pub fn from_sfz(sfz: &str, sfz_path: &Path) -> Result<Self>
Creates an Instrument via parsing some SFZ code in a string
sfz_path would be the root location from where to find the samples and default_path opcode value is appended to it.
sourcepub fn add_opcode(&mut self, opcode: &Opcode) -> Result<()>
pub fn add_opcode(&mut self, opcode: &Opcode) -> Result<()>
Add an opcode, depending on context, to either the last created region, the last created group, or the global header (in that priority order)
sourcepub fn add_opcode_global(&mut self, opcode: &Opcode)
pub fn add_opcode_global(&mut self, opcode: &Opcode)
Add an opcode to the global header
sourcepub fn add_opcode_to_group(&mut self, opcode: &Opcode, group: usize) -> Result<()>
pub fn add_opcode_to_group(&mut self, opcode: &Opcode, group: usize) -> Result<()>
Add an opcode to a group
sourcepub fn add_opcode_to_region(
&mut self,
opcode: &Opcode,
region: usize
) -> Result<()>
pub fn add_opcode_to_region(
&mut self,
opcode: &Opcode,
region: usize
) -> Result<()>
Add an opcode to a region
sourcepub fn regions_in(&self, group: usize) -> Result<usize>
pub fn regions_in(&self, group: usize) -> Result<usize>
Get the number of regions in a group
sourcepub fn new_region(&mut self)
pub fn new_region(&mut self)
Create a new empty region header in the Instrument
The region gets associated with the last group created (if any)
sourcepub fn set_region_group(
&mut self,
region: usize,
group: Option<usize>
) -> Result<()>
pub fn set_region_group(
&mut self,
region: usize,
group: Option<usize>
) -> Result<()>
Set the group of a region (group can be None)
pub fn groups_iter(&self)
Trait Implementations
sourceimpl Clone for Instrument
impl Clone for Instrument
sourcefn clone(&self) -> Instrument
fn clone(&self) -> Instrument
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more