pub struct Part {
pub name: Option<String>,
pub instrument: Option<String>,
pub channel: Option<u8>,
pub offset: Fraction,
pub events: Vec<MusicalEvent>,
pub context_changes: Vec<ContextChange>,
pub staves: Vec<Staff>,
}Expand description
A musical part representing a single instrument or voice in an ensemble.
Parts can contain events directly or organize them into multiple staves (e.g., piano parts typically have two staves for left and right hands).
Fields§
§name: Option<String>§instrument: Option<String>§channel: Option<u8>§offset: Fraction§events: Vec<MusicalEvent>§context_changes: Vec<ContextChange>§staves: Vec<Staff>Implementations§
Source§impl Part
impl Part
pub fn new(name: Option<String>) -> Self
pub fn set_instrument(&mut self, instrument: String)
pub fn with_instrument(self, instrument: String) -> Self
pub fn set_channel(&mut self, channel: u8)
pub fn with_channel(self, channel: u8) -> Self
pub fn set_offset(&mut self, offset: Fraction)
pub fn with_offset(self, offset: Fraction) -> Self
pub fn add_event(&mut self, event: MusicalEvent)
pub fn with_event(self, event: MusicalEvent) -> Self
pub fn add_staff(&mut self, staff: Staff)
pub fn with_staff(self, staff: Staff) -> Self
pub fn add_context_change(&mut self, change: ContextChange)
pub fn with_context_change(self, change: ContextChange) -> Self
Sourcepub fn all_events(&self) -> Vec<&MusicalEvent>
pub fn all_events(&self) -> Vec<&MusicalEvent>
Returns references to all events in this part, including those in staves.
Sourcepub fn total_event_count(&self) -> usize
pub fn total_event_count(&self) -> usize
Counts all atomic events in this part (including nested sequences).
pub fn total_duration(&self) -> Fraction
Sourcepub fn merge(&self, other: &Part) -> Part
pub fn merge(&self, other: &Part) -> Part
Merges another part into this one, appending its content.
The events, staves, and context changes from the other part are appended
to this one, with their timing adjusted to occur after this part’s content
has finished.
§Arguments
other- The part to merge into this one.
§Returns
A new Part containing the merged musical content.
Trait Implementations§
impl StructuralPartialEq for Part
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnsafeUnpin for Part
impl UnwindSafe for Part
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