diff --git a/src/contents/ui/Convolver.qml b/src/contents/ui/Convolver.qml index 67be94731..218a3d859 100644 --- a/src/contents/ui/Convolver.qml +++ b/src/contents/ui/Convolver.qml @@ -185,6 +185,8 @@ Kirigami.ScrollablePage { } else { convolverChart.xUnit = "s"; convolverChart.updateData(chartChannel.left ? pluginBackend.chartMagL : pluginBackend.chartMagR); + spectrumLogScale.checked = false; + convolverChart.logarithimicHorizontalAxis = checked; } } }, diff --git a/src/contents/ui/EeChart.qml b/src/contents/ui/EeChart.qml index 36e26005f..60a94b458 100644 --- a/src/contents/ui/EeChart.qml +++ b/src/contents/ui/EeChart.qml @@ -26,10 +26,13 @@ Item { readonly property real yMinLog: Math.log10(yMin) readonly property real yMaxLog: Math.log10(yMax) readonly property color backgroundRectColor: Kirigami.Theme.backgroundColor - property var inputData: [] - function updateData(newData) { - inputData = newData; + function updateData(inputData) { + //We do not want the object received as argument to be modified here + let newData = []; + for (let n = 0; n < inputData.length; n++) { + newData.push(inputData[n]); + } let minX = Number.POSITIVE_INFINITY; let maxX = Number.NEGATIVE_INFINITY; let minY = Number.POSITIVE_INFINITY; diff --git a/src/contents/ui/PageStreamsEffects.qml b/src/contents/ui/PageStreamsEffects.qml index 24b001336..f9392e9a5 100644 --- a/src/contents/ui/PageStreamsEffects.qml +++ b/src/contents/ui/PageStreamsEffects.qml @@ -419,6 +419,7 @@ Kirigami.Page { logarithimicHorizontalAxis: DB.Manager.spectrum.logarithimicHorizontalAxis dynamicYScale: DB.Manager.spectrum.dynamicYScale xUnit: "Hz" + visible: DB.Manager.spectrum.state Component.onCompleted: { headerFrameAnimation.start(); } diff --git a/src/spectrum.cpp b/src/spectrum.cpp index 83429ff9d..7e6e87c1a 100644 --- a/src/spectrum.cpp +++ b/src/spectrum.cpp @@ -32,6 +32,7 @@ #include #include #include +#include "easyeffects_db_spectrum.h" #include "lv2_wrapper.hpp" #include "pipeline_type.hpp" #include "plugin_base.hpp" @@ -42,6 +43,7 @@ Spectrum::Spectrum(const std::string& tag, pw::Manager* pipe_manager, PipelineType pipe_type, QString instance_id) : PluginBase(tag, "spectrum", tags::plugin_package::Package::ee, instance_id, pipe_manager, pipe_type), fftw_ready(true) { + bypass = !db::Spectrum::state(); // Precompute the Hann window, which is an expensive operation. // https://en.wikipedia.org/wiki/Hann_function for (size_t n = 0; n < n_bands; n++) { @@ -76,12 +78,7 @@ Spectrum::Spectrum(const std::string& tag, pw::Manager* pipe_manager, PipelineTy // lv2_wrapper->bind_key_int<"time_l", "avsync-delay">(settings); // lv2_wrapper->bind_key_int<"time_r", "avsync-delay">(settings); - // g_signal_connect(settings, "changed::show", G_CALLBACK(+[](GSettings* settings, char* key, gpointer user_data) { - // auto* self = static_cast(user_data); - - // self->bypass = g_settings_get_boolean(settings, key) == 0; - // }), - // this); + connect(db::Spectrum::self(), &db::Spectrum::stateChanged, [&]() { bypass = !db::Spectrum::state(); }); } Spectrum::~Spectrum() { @@ -128,8 +125,8 @@ void Spectrum::process(std::span& left_in, std::span& right_in, std::span& left_out, std::span& right_out) { - std::copy(left_in.begin(), left_in.end(), left_out.begin()); - std::copy(right_in.begin(), right_in.end(), right_out.begin()); + std::ranges::copy(left_in, left_out.begin()); + std::ranges::copy(right_in, right_out.begin()); if (bypass || !fftw_ready) { return; @@ -259,7 +256,7 @@ auto Spectrum::compute_magnitudes() -> std::tuple> { fftwf_execute(plan); for (uint i = 0U; i < output.size(); i++) { - float sqr = complex_output[i][0] * complex_output[i][0] + complex_output[i][1] * complex_output[i][1]; + float sqr = (complex_output[i][0] * complex_output[i][0]) + (complex_output[i][1] * complex_output[i][1]); sqr /= static_cast(output.size() * output.size());