Fixing subtle bugs

This commit is contained in:
2026-01-27 13:40:52 +01:00
parent 574625735b
commit a3a39ea28e
8 changed files with 194 additions and 55 deletions

View File

@@ -35,11 +35,13 @@ impl From<&Project> for ProjectFile {
impl From<ProjectFile> for Project {
fn from(file: ProjectFile) -> Self {
Self {
let mut project = Self {
banks: file.banks,
sample_paths: file.sample_paths,
tempo: file.tempo,
}
};
project.normalize();
project
}
}

View File

@@ -282,4 +282,14 @@ impl Project {
pub fn pattern_at_mut(&mut self, bank: usize, pattern: usize) -> &mut Pattern {
&mut self.banks[bank].patterns[pattern]
}
pub fn normalize(&mut self) {
self.banks.resize_with(MAX_BANKS, Bank::default);
for bank in &mut self.banks {
bank.patterns.resize_with(MAX_PATTERNS, Pattern::default);
for pattern in &mut bank.patterns {
pattern.steps.resize_with(MAX_STEPS, Step::default);
}
}
}
}