Skip to content

Commit 84925aa

Browse files
committed
implementing the maximizer preset class
1 parent e057ceb commit 84925aa

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ target_sources(easyeffects PRIVATE
4545
lv2_wrapper.cpp
4646
main.cpp
4747
maximizer.cpp
48+
maximizer_preset.cpp
4849
output_level.cpp
4950
plugin_base.cpp
5051
plugin_preset_base.cpp

src/maximizer_preset.cpp

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright © 2017-2024 Wellington Wallace
3+
*
4+
* This file is part of Easy Effects.
5+
*
6+
* Easy Effects is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Easy Effects is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Easy Effects. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "maximizer_preset.hpp"
21+
#include <nlohmann/json_fwd.hpp>
22+
#include <string>
23+
#include "easyeffects_db_maximizer.h"
24+
#include "pipeline_type.hpp"
25+
#include "plugin_preset_base.hpp"
26+
#include "presets_macros.hpp"
27+
28+
MaximizerPreset::MaximizerPreset(PipelineType pipeline_type, const std::string& instance_name)
29+
: PluginPresetBase(pipeline_type, instance_name) {
30+
settings = get_db_instance<db::Maximizer>(pipeline_type);
31+
}
32+
33+
void MaximizerPreset::save(nlohmann::json& json) {
34+
json[section][instance_name]["bypass"] = settings->bypass();
35+
36+
json[section][instance_name]["input-gain"] = settings->inputGain();
37+
38+
json[section][instance_name]["output-gain"] = settings->outputGain();
39+
40+
json[section][instance_name]["release"] = settings->release();
41+
42+
json[section][instance_name]["threshold"] = settings->threshold();
43+
}
44+
45+
void MaximizerPreset::load(const nlohmann::json& json) {
46+
UPDATE_PROPERTY("bypass", Bypass);
47+
UPDATE_PROPERTY("input-gain", InputGain);
48+
UPDATE_PROPERTY("output-gain", OutputGain);
49+
UPDATE_PROPERTY("release", Release);
50+
UPDATE_PROPERTY("threshold", Threshold);
51+
}

src/maximizer_preset.hpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright © 2017-2024 Wellington Wallace
3+
*
4+
* This file is part of Easy Effects.
5+
*
6+
* Easy Effects is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Easy Effects is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Easy Effects. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
#pragma once
21+
22+
#include <nlohmann/json_fwd.hpp>
23+
#include <string>
24+
#include "easyeffects_db_maximizer.h"
25+
#include "pipeline_type.hpp"
26+
#include "plugin_preset_base.hpp"
27+
28+
class MaximizerPreset : public PluginPresetBase {
29+
public:
30+
explicit MaximizerPreset(PipelineType pipeline_type, const std::string& instance_name);
31+
32+
private:
33+
db::Maximizer* settings = nullptr;
34+
35+
void save(nlohmann::json& json) override;
36+
37+
void load(const nlohmann::json& json) override;
38+
};

src/presets_manager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "easyeffects_db_streamoutputs.h"
5151
#include "exciter_preset.hpp"
5252
#include "limiter_preset.hpp"
53+
#include "maximizer_preset.hpp"
5354
#include "pipeline_type.hpp"
5455
#include "plugin_preset_base.hpp"
5556
#include "presets_list_model.hpp"
@@ -1323,7 +1324,7 @@ auto Manager::create_wrapper(const PipelineType& pipeline_type, const QString& f
13231324
}
13241325

13251326
if (filter_name.startsWith(tags::plugin_name::BaseName::maximizer)) {
1326-
// return std::make_unique<MaximizerPreset>(pipeline_type, filter_name.toStdString());
1327+
return std::make_unique<MaximizerPreset>(pipeline_type, filter_name.toStdString());
13271328
}
13281329

13291330
if (filter_name.startsWith(tags::plugin_name::BaseName::multibandCompressor)) {

0 commit comments

Comments
 (0)