Fixing subtle bugs
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user