[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)
{
// 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);
}
}
}

View file

@ -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

View file

@ -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;
};
}