From 549aa8888d8a9bccbbcaa77e5f60e0b1d2e5eafc Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Tue, 16 Aug 2022 03:53:41 +0200 Subject: [PATCH] Finished gate len for MidiP --- src/dsp/node_midip.rs | 8 ++++---- tests/node_midip.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dsp/node_midip.rs b/src/dsp/node_midip.rs index cb40826..cdd7c90 100644 --- a/src/dsp/node_midip.rs +++ b/src/dsp/node_midip.rs @@ -157,14 +157,12 @@ impl DspNode for MidiP { } else { self.cur_gate = 1; } - println!("NOTE ON"); self.trig_sig.trigger(); self.gate_sig.trigger(); self.cur_note = note; self.cur_vel = vel; } HxMidiEvent::NoteOff { channel, note } => { - println!("NOTE OFF"); if channel != midip_channel { continue; } @@ -182,11 +180,13 @@ impl DspNode for MidiP { gate.write(frame, self.trig_sig.next()); } 2 => { - println!("GOGOGO {} {}", gate_len, self.next_gate); if self.next_gate > 0 { gate.write(frame, 0.0); + self.cur_gate = 0; } else { - gate.write(frame, self.gate_sig.next(gate_len)); + let gsig = self.gate_sig.next(gate_len); + self.cur_gate = gsig.ceil() as u8; + gate.write(frame, gsig); } } _ => { diff --git a/tests/node_midip.rs b/tests/node_midip.rs index d21ced1..2833e28 100644 --- a/tests/node_midip.rs +++ b/tests/node_midip.rs @@ -227,7 +227,7 @@ fn check_node_midip_gate_test() { ); let changes = collect_signal_changes_both_edges(&ch1[..], 1); - assert_eq!(changes, vec![(100, 100), (145, -100)]); + assert_eq!(changes, vec![(100, 100), (120, -100), (121, 100), (166, -100)]); // // Now test without the trigger signal: // node_pset_s(&mut matrix, "midip", 0, "gmode", 0);