From 77e138a77bf8ad41611474753d3b205dd4817934 Mon Sep 17 00:00:00 2001 From: tomara_x <86204514+tomara-x@users.noreply.github.com> Date: Sun, 19 May 2024 20:11:45 +0300 Subject: [PATCH] only allow one seq event per index we don't want to be ticking the same network more than once every sample also reset when the event is added --- src/nodes.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nodes.rs b/src/nodes.rs index 054cb77..6111b7b 100644 --- a/src/nodes.rs +++ b/src/nodes.rs @@ -67,6 +67,13 @@ impl AudioNode for Seq { ) -> Frame { // triggered, add an event if input[0] != 0. { + // remove existing events for that index + self.events.retain(|&x| x.0 != input[1] as usize); + // reset the net + if let Some(network) = self.nets.get_mut(input[1] as usize) { + network.reset(); + } + // push the new event self.events.push(( input[1] as usize, (input[2] * 44100.).round() as usize, @@ -83,7 +90,6 @@ impl AudioNode for Seq { if let Some(network) = self.nets.get_mut(i.0) { network.tick(&[], &mut buffer); out[0] += buffer[0]; - if i.2 == 1 { network.reset(); } } i.2 -= 1; } else {