Skip to content

Commit

Permalink
implementing the crossfeed preset class
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmm committed Jan 15, 2025
1 parent 84925aa commit 29b9710
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/crossfeed_preset.cpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#include "crossfeed_preset.hpp"
#include <nlohmann/json_fwd.hpp>
#include <string>
#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<db::Crossfeed>(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);
}
38 changes: 38 additions & 0 deletions src/crossfeed_preset.hpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <nlohmann/json_fwd.hpp>
#include <string>
#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;
};
3 changes: 2 additions & 1 deletion src/presets_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<CrossfeedPreset>(pipeline_type, filter_name.toStdString());
return std::make_unique<CrossfeedPreset>(pipeline_type, filter_name.toStdString());
}

if (filter_name.startsWith(tags::plugin_name::BaseName::crystalizer)) {
Expand Down

0 comments on commit 29b9710

Please sign in to comment.