So much better

This commit is contained in:
2026-01-26 02:24:04 +01:00
parent bde64e7dc5
commit 1b32a91b0d
16 changed files with 714 additions and 135 deletions

View File

@@ -1,10 +1,10 @@
mod file;
mod project;
pub const MAX_BANKS: usize = 16;
pub const MAX_PATTERNS: usize = 16;
pub const MAX_BANKS: usize = 32;
pub const MAX_PATTERNS: usize = 32;
pub const MAX_STEPS: usize = 128;
pub const DEFAULT_LENGTH: usize = 16;
pub use file::{load, save, FileError};
pub use project::{Bank, Pattern, PatternSpeed, Project, Step};
pub use project::{Bank, LaunchQuantization, Pattern, PatternSpeed, Project, Step, SyncMode};

View File

@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::{DEFAULT_LENGTH, MAX_BANKS, MAX_PATTERNS, MAX_STEPS};
#[derive(Clone, Copy, Serialize, Deserialize, Default, PartialEq)]
#[derive(Clone, Copy, Serialize, Deserialize, Default, PartialEq, Eq)]
pub enum PatternSpeed {
Eighth, // 1/8x
Quarter, // 1/4x
@@ -79,6 +79,75 @@ impl PatternSpeed {
}
}
#[derive(Clone, Copy, Serialize, Deserialize, Default, PartialEq, Eq)]
pub enum LaunchQuantization {
Immediate,
Beat,
#[default]
Bar,
Bars2,
Bars4,
Bars8,
}
impl LaunchQuantization {
pub fn label(&self) -> &'static str {
match self {
Self::Immediate => "Immediate",
Self::Beat => "Beat",
Self::Bar => "1 Bar",
Self::Bars2 => "2 Bars",
Self::Bars4 => "4 Bars",
Self::Bars8 => "8 Bars",
}
}
pub fn next(&self) -> Self {
match self {
Self::Immediate => Self::Beat,
Self::Beat => Self::Bar,
Self::Bar => Self::Bars2,
Self::Bars2 => Self::Bars4,
Self::Bars4 => Self::Bars8,
Self::Bars8 => Self::Bars8,
}
}
pub fn prev(&self) -> Self {
match self {
Self::Immediate => Self::Immediate,
Self::Beat => Self::Immediate,
Self::Bar => Self::Beat,
Self::Bars2 => Self::Bar,
Self::Bars4 => Self::Bars2,
Self::Bars8 => Self::Bars4,
}
}
}
#[derive(Clone, Copy, Serialize, Deserialize, Default, PartialEq, Eq)]
pub enum SyncMode {
#[default]
Reset,
PhaseLock,
}
impl SyncMode {
pub fn label(&self) -> &'static str {
match self {
Self::Reset => "Reset",
Self::PhaseLock => "Phase-Lock",
}
}
pub fn toggle(&self) -> Self {
match self {
Self::Reset => Self::PhaseLock,
Self::PhaseLock => Self::Reset,
}
}
}
#[derive(Clone, Serialize, Deserialize)]
pub struct Step {
pub active: bool,
@@ -108,6 +177,10 @@ pub struct Pattern {
pub speed: PatternSpeed,
#[serde(default)]
pub name: Option<String>,
#[serde(default)]
pub quantization: LaunchQuantization,
#[serde(default)]
pub sync_mode: SyncMode,
}
impl Default for Pattern {
@@ -117,6 +190,8 @@ impl Default for Pattern {
length: DEFAULT_LENGTH,
speed: PatternSpeed::default(),
name: None,
quantization: LaunchQuantization::default(),
sync_mode: SyncMode::default(),
}
}
}