[ui] sliders update ui (while playing)

This commit is contained in:
thibaud keller 2024-10-25 20:09:59 +01:00
parent c3adc2be38
commit 2c17c57580
3 changed files with 25 additions and 20 deletions

View file

@ -4,15 +4,6 @@ namespace Amuencha
{
void Analyser::operator()(halp::tick t)
{
if (inputs.min != previous_min ||
inputs.max != previous_max)
{
send_message(processor_to_ui{.min = inputs.min,
.max = inputs.max});
previous_min = inputs.min;
previous_max = inputs.max;
}
// Process the input buffer
auto* in = inputs.audio[0];

View file

@ -20,8 +20,22 @@ public:
struct ins
{
halp::fixed_audio_bus<"Input", double, 1> audio;
halp::hslider_i32<"Min", halp::range{.min = 0, .max = 127, .init = 24}> min;
halp::hslider_i32<"Max", halp::range{.min = 0, .max = 127, .init = 72}> max;
struct : halp::hslider_i32<"Min", halp::range{.min = 0, .max = 127, .init = 24}>
{
void update(Analyser& self)
{
self.send_message({.min = this->value, .max = self.inputs.max.value});
}
} min;
struct : halp::hslider_i32<"Min", halp::range{.min = 0, .max = 127, .init = 72}>
{
void update(Analyser& self)
{
self.send_message({.min = self.inputs.min.value, .max = this->value});
}
} max;
// halp::hslider_i32<"Min", halp::range{.min = 0, .max = 127, .init = 24}> min;
// halp::hslider_i32<"Max", halp::range{.min = 0, .max = 127, .init = 72}> max;
} inputs;
// This one will be memcpy'd as it is a trivial type
@ -52,9 +66,6 @@ public:
// UI is defined in another file to keep things clear.
struct ui;
private:
double previous_min{24}, previous_max{72};
};
}

View file

@ -99,18 +99,21 @@ void Amuencha::SpiralDisplay::power_handler(int ID, const std::vector<float> &re
// reassigned frequencies are never too far off the original
//if (rf>display_bins[idx] && rf<display_bins[idx+1]) ri = idx;
//else...
while (rf<display_bins[ri])
while (rf < display_bins[ri])
{
--ri;
if (ri==-1) break;
if (ri == -1) break;
}
if (ri==-1) continue; // ignore this frequency, it is below display min
while (rf>display_bins[ri+1])
if (ri == -1) continue; // ignore this frequency, it is below display min
while (rf > display_bins[ri+1])
{
++ri;
if (ri==nidx) break;
if (ri == nidx) break;
}
if (ri==nidx) continue; // ignore this frequency, it is above display max
if (ri == nidx) continue; // ignore this frequency, it is above display max
// Normalization:
// - for a given frequency, the sine/window size dependency was already