add phrase uuids; implement comparisons

This commit is contained in:
🪞👃🪞 2024-10-08 18:15:41 +03:00
parent 5b2b04dcf9
commit 690a8e8f24
6 changed files with 40 additions and 19 deletions

View file

@ -23,6 +23,7 @@ pub struct PhrasePool<E: Engine> {
/// A MIDI sequence.
#[derive(Debug)]
pub struct Phrase {
pub uuid: uuid::Uuid,
/// Name of phrase
pub name: Arc<RwLock<String>>,
/// Temporal resolution in pulses per quarter note
@ -121,6 +122,7 @@ impl Phrase {
name: &str, loop_on: bool, length: usize, notes: Option<PhraseData>
) -> Self {
Self {
uuid: uuid::Uuid::new_v4(),
name: Arc::new(RwLock::new(name.into())),
ppq: PPQ,
length,
@ -185,6 +187,12 @@ impl Phrase {
}
}
}
impl std::cmp::PartialEq for Phrase {
fn eq (&self, other: &Self) -> bool {
self.uuid == other.uuid
}
}
impl Eq for Phrase {}
impl<E: Engine> PhrasePlayer<E> {
pub fn new (name: &str) -> Self {
Self {