Struct sofiza::Instrument [−][src]
pub struct Instrument { pub global: HashMap<String, Opcode>, pub groups: Vec<Group>, pub regions: Vec<Region>, pub default_path: PathBuf, // some fields omitted }
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
impl Instrument
[src]
pub fn new() -> Instrument
[src]
Creates an empty Instrument
pub fn from_file(sfz_path: &Path) -> Result<Self>
[src]
Creates an Instrument via loading and parsing some SFZ code in a file
pub fn from_sfz(sfz: &str, sfz_path: &Path) -> Result<Self>
[src]
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.
pub fn add_opcode(&mut self, opcode: &Opcode) -> Result<()>
[src]
Add an opcode, depending on context, to either the last created region, the last created group, or the global header (in that priority order)
pub fn add_opcode_global(&mut self, opcode: &Opcode)
[src]
Add an opcode to the global header
pub fn add_opcode_to_group(
&mut self,
opcode: &Opcode,
group: usize
) -> Result<()>
[src]
&mut self,
opcode: &Opcode,
group: usize
) -> Result<()>
Add an opcode to a group
pub fn add_opcode_to_region(
&mut self,
opcode: &Opcode,
region: usize
) -> Result<()>
[src]
&mut self,
opcode: &Opcode,
region: usize
) -> Result<()>
Add an opcode to a region
pub fn groups(&self) -> usize
[src]
Get the number of groups
pub fn regions(&self) -> usize
[src]
Get the number of regions
pub fn regions_in(&self, group: usize) -> Result<usize>
[src]
Get the number of regions in a group
pub fn new_group(&mut self)
[src]
Create a new empty group header in the Instrument
pub fn new_region(&mut self)
[src]
Create a new empty region header in the Instrument
The region gets associated with the last group created (if any)
pub fn set_region_group(
&mut self,
region: usize,
group: Option<usize>
) -> Result<()>
[src]
&mut self,
region: usize,
group: Option<usize>
) -> Result<()>
Set the group of a region (group can be None)
pub fn groups_iter(&self)
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Instrument
impl Send for Instrument
impl Sync for Instrument
impl Unpin for Instrument
impl UnwindSafe for Instrument
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,