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

Creates an empty Instrument

Creates an Instrument via loading and parsing some SFZ code in a file

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.

Add an opcode, depending on context, to either the last created region, the last created group, or the global header (in that priority order)

Add an opcode to the global header

Add an opcode to a group

Add an opcode to a region

Get the number of groups

Get the number of regions

Get the number of regions in a group

Create a new empty group header in the Instrument

Create a new empty region header in the Instrument

The region gets associated with the last group created (if any)

Set the group of a region (group can be None)

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.