[modulation] serviceable but inconsistent

This commit is contained in:
thibaud keller 2024-10-14 21:41:27 +01:00
parent 9568198a1c
commit 1970b5c624
3 changed files with 26 additions and 14 deletions

View file

@ -6,13 +6,6 @@ namespace Ottobit
{ {
void Senior::operator()(tick t) 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 // Only compute skipped_frames when the control changes
if (inputs.s_rate != previous_rate) if (inputs.s_rate != previous_rate)
{ {
@ -20,6 +13,13 @@ void Senior::operator()(tick t)
previous_rate = inputs.s_rate; 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 // Process the input buffer
for(int i{0}; i < inputs.audio.channels; i++) for(int i{0}; i < inputs.audio.channels; i++)
{ {
@ -44,9 +44,22 @@ void Senior::operator()(tick t)
else else
{ {
lfo.set(inputs.freq, phases[i], 0); 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(); phases[i] = lfo.phase();
out[j] = fms[i](current_frame);
} }
} }
} }

View file

@ -41,11 +41,9 @@ public:
{ {
using mapper = log_map; using mapper = log_map;
} freq; } freq;
struct : halp::knob_f32<"DEPTH", halp::range{.min = .0, .max = 1., .init = 0.}>
{ halp::knob_f32<"DEPTH", halp::range{.min = 0., .max = 1., .init = 0.}> depth;
using mapper = log_map; halp::knob_f32<"AM/RING/FM", halp::range{.min = 0., .max = 2., .init = 0.}> am_fm;
}
depth;
} inputs; } inputs;
struct struct

View file

@ -25,6 +25,7 @@ struct Senior::ui
halp_meta(layout, hbox) halp_meta(layout, hbox)
halp::item<&ins::depth> depth; halp::item<&ins::depth> depth;
halp::item<&ins::freq> freq; halp::item<&ins::freq> freq;
halp::item<&ins::am_fm> am_fm;
} mod; } mod;
}; };
} }