use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const MAESTRO_PACK: Pack = Pack {
name: "maestro",
version: "3.0.0",
license: "CC-BY-NC-SA-4.0",
files: &[PackFile {
name: "maestro-v3.0.0-midi.zip",
size: 58_416_533,
shake256: "7f85aca2ee4358bcd87417cac9817121edc3ae83b48dcb248571a5b2e064a24d",
urls: &[
"https://storage.googleapis.com/magentadata/datasets/maestro/v3.0.0/maestro-v3.0.0-midi.zip",
],
}],
};
pub const DEFAULT_SEQ_LEN: usize = 25;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MaestroSplit {
#[default]
Train,
Validation,
Test,
}
#[derive(Clone, Debug)]
pub struct MaestroConfig {
pub split: MaestroSplit,
pub seq_len: usize,
pub cache_dir: Option<PathBuf>,
}
impl Default for MaestroConfig {
fn default() -> Self {
Self {
split: MaestroSplit::Train,
seq_len: DEFAULT_SEQ_LEN,
cache_dir: None,
}
}
}
impl MaestroConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::Maestro {
#[inline]
pub fn load(config: &MaestroConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &MaestroConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &MaestroConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}