Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiPerttu committed Apr 8, 2024
1 parent 500b54e commit 5e86b62
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl Net48 {
let node_index = self.node_index[&node];
assert_eq!(unit.inputs(), self.vertex[node_index].inputs());
assert_eq!(unit.outputs(), self.vertex[node_index].outputs());
unit.set_sample_rate(self.sample_rate);
std::mem::swap(&mut self.vertex[node_index].unit, &mut unit);
self.vertex[node_index].changed = self.revision;
unit
Expand Down Expand Up @@ -987,13 +988,19 @@ impl AudioUnit48 for Net48 {
}

fn set_sample_rate(&mut self, sample_rate: f64) {
self.sample_rate = sample_rate;
for vertex in &mut self.vertex {
vertex.unit.set_sample_rate(sample_rate);
}
// Take the opportunity to unload some calculations.
if !self.is_ordered() {
self.determine_order();
if self.sample_rate != sample_rate {
self.sample_rate = sample_rate;
for vertex in &mut self.vertex {
vertex.unit.set_sample_rate(sample_rate);
// Sample rate change counts as a change because
// we cannot change sample rate in the backend
// - it may allocate.
vertex.changed = self.revision;
}
// Take the opportunity to unload some calculations.
if !self.is_ordered() {
self.determine_order();
}
}
}

Expand Down

0 comments on commit 5e86b62

Please sign in to comment.