|
| 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 | +} |
0 commit comments