From 1d595fe52f72790866983956103c3bb686e5a780 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sat, 13 Aug 2022 11:33:50 +0200 Subject: [PATCH] fix 'det' parameter of MidiP --- CHANGELOG.md | 2 +- src/chain_builder.rs | 17 +++++++++++++++++ src/dsp/node_midip.rs | 2 +- tests/node_midip.rs | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad79887..3e90038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ parameter was changed or modulated at runtime. * Bugfix: Found a bug in cubic interpolation in the sample player and similar bugs in the delay line (and all-pass & comb filters). Refactored the cubic interpolation and tested it seperately now. +* Change: Moved DSP code over to `synfx-dsp` crate. * Feature: Matrix::get\_connections() returns information about the connections to the adjacent cells. * Feature: Added the MatrixCellChain abstraction for easy creation of DSP @@ -15,5 +16,4 @@ chains on the hexagonal Matrix. * Feature: Added Scope DSP node and NodeConfigurator/Matrix API for retrieving the scope handles for access to it's capture buffers. * Feature: Added WBlockDSP visual programming language utilizing the `synfx-dsp-jit` crate. -* Change: Moved DSP code over to `synfx-dsp` crate. * Feature: Added the `FormFM` node that was contributed by Dimas Leenman (aka Skythedragon). diff --git a/src/chain_builder.rs b/src/chain_builder.rs index 4ad0d72..150da5e 100644 --- a/src/chain_builder.rs +++ b/src/chain_builder.rs @@ -120,6 +120,23 @@ impl MatrixCellChain { self } + /// Sets the normalized value of the current parameter cell's parameter. + /// + /// The current parameter cell is set automatically when a new node is added. + /// Alternatively you can use [MatrixCellChain::params_for_idx] to set the current + /// parameter cell. + pub fn set_norm(&mut self, param: &str, norm: f32) -> &mut Self { + let link = self.chain.get_mut(self.param_idx).expect("Correct parameter idx"); + + if let Some(pid) = link.cell.node_id().inp_param(param) { + link.params.push((pid, SAtom::param(norm as f32))); + } else { + self.error = Some(ChainError::UnknownInput(link.cell.node_id(), param.to_string())); + } + + self + } + /// Sets the atom value of the current parameter cell's parameter. /// /// The current parameter cell is set automatically when a new node is added. diff --git a/src/dsp/node_midip.rs b/src/dsp/node_midip.rs index c1adfd2..2713038 100644 --- a/src/dsp/node_midip.rs +++ b/src/dsp/node_midip.rs @@ -112,7 +112,7 @@ impl DspNode for MidiP { let chan = ectx.note_buffer.get_chan_at(channel, frame as u8); let note = (chan.note as f32 - 69.0) / 120.0; - let note = note + denorm::MidiP::det(det, frame); + let note = note + det.read(frame); freq.write(frame, note); if chan.gate & 0x10 > 0 { diff --git a/tests/node_midip.rs b/tests/node_midip.rs index ba9392f..8ddc0b2 100644 --- a/tests/node_midip.rs +++ b/tests/node_midip.rs @@ -75,7 +75,7 @@ fn check_node_midip_pitch_det() { let mut chain = MatrixCellChain::new(CellDir::B); chain .node_out("midip", "freq") - .set_denorm("det", 0.1) + .set_norm("det", 0.1) .node_inp("out", "ch1") .place(&mut matrix, 0, 0) .unwrap();