Skip to content

Commit 365ae7c

Browse files
committed
implementing the filter preset class
1 parent 29b9710 commit 365ae7c

File tree

5 files changed

+132
-104
lines changed

5 files changed

+132
-104
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ target_sources(easyeffects PRIVATE
3333
exciter.cpp
3434
exciter_preset.cpp
3535
filter.cpp
36+
filter_preset.cpp
3637
fir_filter_bandpass.cpp
3738
fir_filter_base.cpp
3839
fir_filter_highpass.cpp

src/contents/kcfg/easyeffects_db_filter.kcfg

+17-103
Original file line numberDiff line numberDiff line change
@@ -23,118 +23,32 @@
2323
<max>36</max>
2424
<default>0</default>
2525
</entry>
26-
<entry name="type" type="Enum">
26+
<entry name="typeLabels" type="StringList">
27+
<default>Low-pass,High-pass,Low-shelf,Bell,Band-pass,Notch,Resonance,Ladder-pass,Ladder-rejection,All-pass</default>
28+
</entry>
29+
<entry name="type" type="Int">
2730
<label>Type</label>
28-
<choices>
29-
<choice name="lowPass">
30-
<label>Low-pass</label>
31-
</choice>
32-
<choice name="highPass">
33-
<label>High-pass</label>
34-
</choice>
35-
<choice name="lowShelf">
36-
<label>Low-shelf</label>
37-
</choice>
38-
<choice name="highShelf">
39-
<label>High-shelf</label>
40-
</choice>
41-
<choice name="bell">
42-
<label>Bell</label>
43-
</choice>
44-
<choice name="bandPass">
45-
<label>Band-pass</label>
46-
</choice>
47-
<choice name="notch">
48-
<label>Notch</label>
49-
</choice>
50-
<choice name="resonance">
51-
<label>Resonance</label>
52-
</choice>
53-
<choice name="ladderPass">
54-
<label>Ladder-pass</label>
55-
</choice>
56-
<choice name="ladderRejection">
57-
<label>Ladder-rejection</label>
58-
</choice>
59-
<choice name="allPass">
60-
<label>All-pass</label>
61-
</choice>
62-
</choices>
6331
<default>0</default>
6432
</entry>
65-
<entry name="equalMode" type="Enum">
33+
<entry name="equalModeLabels" type="StringList">
34+
<default>IIR,FIR,FFT,SPM</default>
35+
</entry>
36+
<entry name="equalMode" type="Int">
6637
<label>Equalizer Mode</label>
67-
<choices>
68-
<choice name="iir">
69-
<label>IIR</label>
70-
</choice>
71-
<choice name="fir">
72-
<label>FIR</label>
73-
</choice>
74-
<choice name="fft">
75-
<label>FFT</label>
76-
</choice>
77-
<choice name="spm">
78-
<label>SPM</label>
79-
</choice>
80-
</choices>
8138
<default>0</default>
8239
</entry>
83-
<entry name="mode" type="Enum">
40+
<entry name="modeLabels" type="StringList">
41+
<default>RLC (BT),RLC (MT),BWC (BT),BWC (MT),LRX (BT),LRX (MT),APO (DR)</default>
42+
</entry>
43+
<entry name="mode" type="Int">
8444
<label>Filter Mode</label>
85-
<choices>
86-
<choice name="rlcBt">
87-
<label>RLC (BT)</label>
88-
</choice>
89-
<choice name="rlcMt">
90-
<label>RLC (MT)</label>
91-
</choice>
92-
<choice name="bwcBt">
93-
<label>BWC (BT)</label>
94-
</choice>
95-
<choice name="bwcMt">
96-
<label>BWC (MT)</label>
97-
</choice>
98-
<choice name="lrxBt">
99-
<label>LRX (BT)</label>
100-
</choice>
101-
<choice name="lrxMt">
102-
<label>LRX (MT)</label>
103-
</choice>
104-
<choice name="apoDr">
105-
<label>APO (DR)</label>
106-
</choice>
107-
</choices>
10845
<default>0</default>
10946
</entry>
110-
<entry name="slope" type="Enum">
47+
<entry name="slopeLabels" type="StringList">
48+
<default>x1,x2,x3,x4,x6,x8,x8,x12,x12,x16</default>
49+
</entry>
50+
<entry name="slope" type="Int">
11151
<label>Slope</label>
112-
<choices>
113-
<choice name="x1">
114-
<label>x1</label>
115-
</choice>
116-
<choice name="x2">
117-
<label>x2</label>
118-
</choice>
119-
<choice name="x3">
120-
<label>x3</label>
121-
</choice>
122-
<choice name="x4">
123-
<label>x4</label>
124-
</choice>
125-
<choice name="x6">
126-
<label>x6</label>
127-
</choice>
128-
<choice name="x8">
129-
<label>x8</label>
130-
</choice>
131-
<choice name="x12">
132-
<label>x12</label>
133-
</choice>
134-
<choice name="x16">
135-
<label>x16</label>
136-
</choice>
137-
</choices>
13852
<default>0</default>
13953
</entry>
14054
<entry name="frequency" type="Double">
@@ -168,4 +82,4 @@
16882
<default>0</default>
16983
</entry>
17084
</group>
171-
</kcfg>
85+
</kcfg>

src/filter_preset.cpp

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 "filter_preset.hpp"
21+
#include <nlohmann/json_fwd.hpp>
22+
#include <string>
23+
#include "easyeffects_db_filter.h"
24+
#include "pipeline_type.hpp"
25+
#include "plugin_preset_base.hpp"
26+
#include "presets_macros.hpp"
27+
28+
FilterPreset::FilterPreset(PipelineType pipeline_type, const std::string& instance_name)
29+
: PluginPresetBase(pipeline_type, instance_name) {
30+
settings = get_db_instance<db::Filter>(pipeline_type);
31+
}
32+
33+
void FilterPreset::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]["frequency"] = settings->frequency();
41+
42+
json[section][instance_name]["width"] = settings->width();
43+
44+
json[section][instance_name]["gain"] = settings->gain();
45+
46+
json[section][instance_name]["quality"] = settings->quality();
47+
48+
json[section][instance_name]["balance"] = settings->balance();
49+
50+
json[section][instance_name]["type"] = settings->defaultTypeLabelsValue()[settings->type()].toStdString();
51+
52+
json[section][instance_name]["mode"] = settings->defaultModeLabelsValue()[settings->mode()].toStdString();
53+
54+
json[section][instance_name]["equal-mode"] =
55+
settings->defaultEqualModeLabelsValue()[settings->equalMode()].toStdString();
56+
57+
json[section][instance_name]["slope"] = settings->defaultSlopeLabelsValue()[settings->slope()].toStdString();
58+
}
59+
60+
void FilterPreset::load(const nlohmann::json& json) {
61+
UPDATE_PROPERTY("bypass", Bypass);
62+
UPDATE_PROPERTY("input-gain", InputGain);
63+
UPDATE_PROPERTY("output-gain", OutputGain);
64+
UPDATE_PROPERTY("frequency", Frequency);
65+
UPDATE_PROPERTY("width", Width);
66+
UPDATE_PROPERTY("gain", Gain);
67+
UPDATE_PROPERTY("quality", Quality);
68+
UPDATE_PROPERTY("balance", Balance);
69+
70+
UPDATE_ENUM_LIKE_PROPERTY("type", Type);
71+
UPDATE_ENUM_LIKE_PROPERTY("mode", Mode);
72+
UPDATE_ENUM_LIKE_PROPERTY("equal-mode", EqualMode);
73+
UPDATE_ENUM_LIKE_PROPERTY("slope", Slope);
74+
}

src/filter_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_filter.h"
25+
#include "pipeline_type.hpp"
26+
#include "plugin_preset_base.hpp"
27+
28+
class FilterPreset : public PluginPresetBase {
29+
public:
30+
explicit FilterPreset(PipelineType pipeline_type, const std::string& instance_name);
31+
32+
private:
33+
db::Filter* 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_streaminputs.h"
5151
#include "easyeffects_db_streamoutputs.h"
5252
#include "exciter_preset.hpp"
53+
#include "filter_preset.hpp"
5354
#include "limiter_preset.hpp"
5455
#include "maximizer_preset.hpp"
5556
#include "pipeline_type.hpp"
@@ -1305,7 +1306,7 @@ auto Manager::create_wrapper(const PipelineType& pipeline_type, const QString& f
13051306
}
13061307

13071308
if (filter_name.startsWith(tags::plugin_name::BaseName::filter)) {
1308-
// return std::make_unique<FilterPreset>(pipeline_type, filter_name.toStdString());
1309+
return std::make_unique<FilterPreset>(pipeline_type, filter_name.toStdString());
13091310
}
13101311

13111312
if (filter_name.startsWith(tags::plugin_name::BaseName::gate)) {

0 commit comments

Comments
 (0)