From 1970b5c624d217d159b7d4c05da5960e2d9aff2b Mon Sep 17 00:00:00 2001 From: thibaudk Date: Mon, 14 Oct 2024 21:41:27 +0100 Subject: [PATCH] [modulation] serviceable but inconsistent --- Senior/SeniorModel.cpp | 31 ++++++++++++++++++++++--------- Senior/SeniorModel.hpp | 8 +++----- Senior/SeniorUi.hpp | 1 + 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Senior/SeniorModel.cpp b/Senior/SeniorModel.cpp index 7e04fc4..9d6a4fe 100644 --- a/Senior/SeniorModel.cpp +++ b/Senior/SeniorModel.cpp @@ -6,13 +6,6 @@ namespace Ottobit { void Senior::operator()(tick t) { - // Only compute bit_factor when the control changes - if (inputs.bits != previous_bits) - { - set_bit_factor(); - previous_bits = inputs.bits; - } - // Only compute skipped_frames when the control changes if (inputs.s_rate != previous_rate) { @@ -20,6 +13,13 @@ void Senior::operator()(tick t) previous_rate = inputs.s_rate; } + // Only compute bit_factor when the control changes + if (inputs.bits != previous_bits) + { + set_bit_factor(); + previous_bits = inputs.bits; + } + // Process the input buffer for(int i{0}; i < inputs.audio.channels; i++) { @@ -44,9 +44,22 @@ void Senior::operator()(tick t) else { lfo.set(inputs.freq, phases[i], 0); - fms[i].delay(lfo.cos() * inputs.depth + .5); + + if (inputs.am_fm < 1.f) + { + double amp = (inputs.am_fm * 0.5) + (inputs.depth * 0.5); + out[j] = current_frame * ((lfo.cos() * amp) + (1 - amp)); + } + else + { + double amp = lfo.cos() * inputs.depth; + fms[i].delay(amp * .0025 + 1); + double am = current_frame * (amp + (1 - inputs.depth)); + double fm = fms[i](current_frame); + out[j] = (am * (2 - inputs.am_fm)) + (fm * (inputs.am_fm - 1)); + } + phases[i] = lfo.phase(); - out[j] = fms[i](current_frame); } } } diff --git a/Senior/SeniorModel.hpp b/Senior/SeniorModel.hpp index e9d5396..da2ce62 100644 --- a/Senior/SeniorModel.hpp +++ b/Senior/SeniorModel.hpp @@ -41,11 +41,9 @@ public: { using mapper = log_map; } freq; - struct : halp::knob_f32<"DEPTH", halp::range{.min = .0, .max = 1., .init = 0.}> - { - using mapper = log_map; - } - depth; + + halp::knob_f32<"DEPTH", halp::range{.min = 0., .max = 1., .init = 0.}> depth; + halp::knob_f32<"AM/RING/FM", halp::range{.min = 0., .max = 2., .init = 0.}> am_fm; } inputs; struct diff --git a/Senior/SeniorUi.hpp b/Senior/SeniorUi.hpp index c3c2951..a31008b 100644 --- a/Senior/SeniorUi.hpp +++ b/Senior/SeniorUi.hpp @@ -25,6 +25,7 @@ struct Senior::ui halp_meta(layout, hbox) halp::item<&ins::depth> depth; halp::item<&ins::freq> freq; + halp::item<&ins::am_fm> am_fm; } mod; }; }