P2a: eight-bar arrangement with four editable sections
This commit is contained in:
@@ -353,9 +353,9 @@ impl AudioState {
|
||||
return;
|
||||
};
|
||||
let vein_index = material
|
||||
.pattern
|
||||
.rows
|
||||
.sections
|
||||
.iter()
|
||||
.flat_map(|section| §ion.rows)
|
||||
.find(|row| {
|
||||
row.face.as_ref().is_some_and(|reference| {
|
||||
reference.core == core && reference.face == face
|
||||
@@ -374,6 +374,8 @@ impl AudioState {
|
||||
}
|
||||
}
|
||||
AudioCommand::SetMaterial(material) => {
|
||||
let total = material.sections.len().max(1) * LOOP_STEPS;
|
||||
self.step %= total;
|
||||
self.material = Some(material);
|
||||
}
|
||||
}
|
||||
@@ -436,19 +438,24 @@ impl AudioState {
|
||||
|
||||
fn trigger_step(&mut self) {
|
||||
let step = self.step;
|
||||
let (plan, count) = {
|
||||
let (plan, count, section_count) = {
|
||||
let material = self.material.as_ref().cloned();
|
||||
let pattern = material
|
||||
.as_ref()
|
||||
.map(|material| &material.pattern)
|
||||
.unwrap_or(&self.fallback);
|
||||
let (sections, section_count) = match material.as_ref() {
|
||||
Some(material) if !material.sections.is_empty() => {
|
||||
(material.sections.as_slice(), material.sections.len())
|
||||
}
|
||||
_ => (std::slice::from_ref(&self.fallback), 4),
|
||||
};
|
||||
let section = (step / LOOP_STEPS) % section_count;
|
||||
let pattern = sections.get(section).unwrap_or(&self.fallback);
|
||||
let pattern_step = step % LOOP_STEPS;
|
||||
let mut plan: [StepTrigger; 8] = [(0, 0, None); 8];
|
||||
let mut count = 0;
|
||||
for row in &pattern.rows {
|
||||
if count >= plan.len() {
|
||||
break;
|
||||
}
|
||||
let velocity = row.velocities.get(step).copied().unwrap_or(0);
|
||||
let velocity = row.velocities.get(pattern_step).copied().unwrap_or(0);
|
||||
if velocity == 0 {
|
||||
continue;
|
||||
}
|
||||
@@ -464,7 +471,7 @@ impl AudioState {
|
||||
plan[count] = (row.vein.index(), velocity, face);
|
||||
count += 1;
|
||||
}
|
||||
(plan, count)
|
||||
(plan, count, section_count)
|
||||
};
|
||||
for (vein_index, velocity, face) in plan.into_iter().take(count) {
|
||||
if let Some((core_index, face_index)) = face {
|
||||
@@ -474,7 +481,7 @@ impl AudioState {
|
||||
}
|
||||
}
|
||||
self.bar = step as f32 / STEPS_PER_BAR as f32 + 1.0;
|
||||
self.step = (step + 1) % LOOP_STEPS;
|
||||
self.step = (step + 1) % (section_count * LOOP_STEPS);
|
||||
}
|
||||
|
||||
fn render<T>(&mut self, data: &mut [T], levels: &Levels)
|
||||
|
||||
Reference in New Issue
Block a user