Skip to content

Commit

Permalink
Add "drain" option to all structures
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Dec 11, 2024
1 parent 298549a commit 753b239
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions amm_sdk/src/storage/midi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,4 @@ mod test {
// TODO: Implement tuplets
// TODO: Attempt to implement dynamics
// TODO: Attempt to implement mordents, trills, and other ornaments based on timing data
// IDEA: Pre-create timeslices for min note lengths (associate each slice with MIDI tick start time), round note start time to nearest timeslice start time and add note to slice (but how handle tuplets?, maybe add a flag if suspected tuplet because note falls in 1/3 or 2/3 or expected timeslice time and then check for consecutive flags?)
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/chord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ impl Chord {
self.modifications.iter()
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, ChordContent> {
self.content.drain(..)
}

#[must_use]
pub fn to_timeslice(&self) -> Timeslice {
let mut timeslice = Timeslice::new();
Expand Down
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/multivoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ impl MultiVoice {
.collect(),
}
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, MultiVoiceContent> {
self.content.drain(..)
}
}

impl IntoIterator for MultiVoice {
Expand Down
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ impl Part {
.iter()
.flat_map(|PartContent::Section(section)| section.iter_timeslices())
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, PartContent> {
self.content.drain(..)
}
}

impl IntoIterator for Part {
Expand Down
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/phrase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ impl Phrase {
modifications: &self.modifications,
}
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, PhraseContent> {
self.content.drain(..)
}
}

impl IntoIterator for Phrase {
Expand Down
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ impl Section {
processing_staves: false,
}
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, SectionContent> {
self.content.drain(..)
}
}

impl IntoIterator for Section {
Expand Down
5 changes: 5 additions & 0 deletions amm_sdk/src/structure/staff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ impl Staff {
child_multivoice: None,
}
}

#[must_use]
pub fn drain(&mut self) -> alloc::vec::Drain<'_, StaffContent> {
self.content.drain(..)
}
}

impl IntoIterator for Staff {
Expand Down

0 comments on commit 753b239

Please sign in to comment.