From 29b971044237c15c3e943635d2e499deba9f8139 Mon Sep 17 00:00:00 2001 From: wwmm Date: Wed, 15 Jan 2025 11:39:37 -0300 Subject: [PATCH] implementing the crossfeed preset class --- src/CMakeLists.txt | 1 + src/crossfeed_preset.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ src/crossfeed_preset.hpp | 38 ++++++++++++++++++++++++++++++ src/presets_manager.cpp | 3 ++- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/crossfeed_preset.cpp create mode 100644 src/crossfeed_preset.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0f2c1edb..80ea4bb04 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,7 @@ target_sources(easyeffects PRIVATE command_line_parser.cpp compressor.cpp crossfeed.cpp + crossfeed_preset.cpp crystalizer.cpp crystalizer_preset.cpp db_manager.cpp diff --git a/src/crossfeed_preset.cpp b/src/crossfeed_preset.cpp new file mode 100644 index 000000000..6a41a5468 --- /dev/null +++ b/src/crossfeed_preset.cpp @@ -0,0 +1,51 @@ +/* + * Copyright © 2017-2024 Wellington Wallace + * + * This file is part of Easy Effects. + * + * Easy Effects is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy Effects is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy Effects. If not, see . + */ + +#include "crossfeed_preset.hpp" +#include +#include +#include "easyeffects_db_crossfeed.h" +#include "pipeline_type.hpp" +#include "plugin_preset_base.hpp" +#include "presets_macros.hpp" + +CrossfeedPreset::CrossfeedPreset(PipelineType pipeline_type, const std::string& instance_name) + : PluginPresetBase(pipeline_type, instance_name) { + settings = get_db_instance(pipeline_type); +} + +void CrossfeedPreset::save(nlohmann::json& json) { + json[section][instance_name]["bypass"] = settings->bypass(); + + json[section][instance_name]["input-gain"] = settings->inputGain(); + + json[section][instance_name]["output-gain"] = settings->outputGain(); + + json[section][instance_name]["fcut"] = settings->fcut(); + + json[section][instance_name]["feed"] = settings->feed(); +} + +void CrossfeedPreset::load(const nlohmann::json& json) { + UPDATE_PROPERTY("bypass", Bypass); + UPDATE_PROPERTY("input-gain", InputGain); + UPDATE_PROPERTY("output-gain", OutputGain); + UPDATE_PROPERTY("fcut", Fcut); + UPDATE_PROPERTY("feed", Feed); +} diff --git a/src/crossfeed_preset.hpp b/src/crossfeed_preset.hpp new file mode 100644 index 000000000..1501f029c --- /dev/null +++ b/src/crossfeed_preset.hpp @@ -0,0 +1,38 @@ +/* + * Copyright © 2017-2024 Wellington Wallace + * + * This file is part of Easy Effects. + * + * Easy Effects is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy Effects is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy Effects. If not, see . + */ + +#pragma once + +#include +#include +#include "easyeffects_db_crossfeed.h" +#include "pipeline_type.hpp" +#include "plugin_preset_base.hpp" + +class CrossfeedPreset : public PluginPresetBase { + public: + explicit CrossfeedPreset(PipelineType pipeline_type, const std::string& instance_name); + + private: + db::Crossfeed* settings = nullptr; + + void save(nlohmann::json& json) override; + + void load(const nlohmann::json& json) override; +}; diff --git a/src/presets_manager.cpp b/src/presets_manager.cpp index e46bb2c75..90e5be957 100644 --- a/src/presets_manager.cpp +++ b/src/presets_manager.cpp @@ -44,6 +44,7 @@ #include "autogain_preset.hpp" #include "bass_enhancer_preset.hpp" #include "config.h" +#include "crossfeed_preset.hpp" #include "crystalizer_preset.hpp" #include "easyeffects_db.h" #include "easyeffects_db_streaminputs.h" @@ -1268,7 +1269,7 @@ auto Manager::create_wrapper(const PipelineType& pipeline_type, const QString& f } if (filter_name.startsWith(tags::plugin_name::BaseName::crossfeed)) { - // return std::make_unique(pipeline_type, filter_name.toStdString()); + return std::make_unique(pipeline_type, filter_name.toStdString()); } if (filter_name.startsWith(tags::plugin_name::BaseName::crystalizer)) {