This repository has no description
1use super::audio::Stem;
2use serde::{Deserialize, Serialize};
3use std::{collections::HashMap, path::PathBuf};
4
5pub type TimestampMS = usize;
6
7pub trait Syncable {
8 fn new(path: impl Into<PathBuf>) -> Self;
9 fn load(&self, progress: Option<&indicatif::ProgressBar>) -> SyncData;
10}
11
12#[derive(Debug, Default, Serialize, Deserialize)]
13pub struct SyncData {
14 pub stems: HashMap<String, Stem>,
15 pub markers: HashMap<TimestampMS, String>,
16 pub bpm: Option<usize>,
17}
18
19impl SyncData {
20 pub fn union(self, other: SyncData) -> Self {
21 let mut combined = Self::default();
22
23 combined.bpm = other.bpm.or(self.bpm);
24
25 combined.stems.extend(self.stems);
26 combined.stems.extend(other.stems);
27
28 combined.markers.extend(self.markers);
29 combined.markers.extend(other.markers);
30
31 combined
32 }
33}