-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move filter channel-specific configuration.
- Loading branch information
Showing
9 changed files
with
264 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//========================================================================== | ||
// Name: FilterConfiguration.cpp | ||
// Purpose: Implements the filter configuration for FreeDV | ||
// Created: July 2, 2023 | ||
// Authors: Mooneer Salem | ||
// | ||
// License: | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2.1, | ||
// as published by the Free Software Foundation. This program 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 this program; if not, see <http://www.gnu.org/licenses/>. | ||
// | ||
//========================================================================== | ||
|
||
#include "FilterConfiguration.h" | ||
|
||
DEFINE_FILTER_CONFIG_NAMES(MicIn); | ||
DEFINE_FILTER_CONFIG_NAMES(SpkOut); | ||
|
||
void FilterConfiguration::load(wxConfigBase* config) | ||
{ | ||
micInChannel.load(config); | ||
spkOutChannel.load(config); | ||
} | ||
|
||
void FilterConfiguration::save(wxConfigBase* config) | ||
{ | ||
micInChannel.save(config); | ||
spkOutChannel.save(config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
//========================================================================== | ||
// Name: FilterConfiguration.h | ||
// Purpose: Implements the filter configuration for FreeDV | ||
// Created: July 2, 2023 | ||
// Authors: Mooneer Salem | ||
// | ||
// License: | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2.1, | ||
// as published by the Free Software Foundation. This program 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 this program; if not, see <http://www.gnu.org/licenses/>. | ||
// | ||
//========================================================================== | ||
|
||
#ifndef FILTER_CONFIGURATION_H | ||
#define FILTER_CONFIGURATION_H | ||
|
||
#include "WxWidgetsConfigStore.h" | ||
#include "ConfigurationDataElement.h" | ||
|
||
class FilterConfiguration : public WxWidgetsConfigStore | ||
{ | ||
public: | ||
enum Channel { MicIn, SpkOut }; | ||
|
||
template<FilterConfiguration::Channel ChannelId> | ||
class FilterChannelConfigName | ||
{ | ||
public: | ||
static const char* GetBassFreqHzConfigName() { assert(0); } | ||
static const char* GetBassGaindBConfigName() { assert(0); } | ||
static const char* GetTrebleFreqHzConfigName() { assert(0); } | ||
static const char* GetTrebleGaindBConfigName() { assert(0); } | ||
static const char* GetMidFreqHzConfigName() { assert(0); } | ||
static const char* GetMidGaindBConfigName() { assert(0); } | ||
static const char* GetMidQConfigName() { assert(0); } | ||
static const char* GetVolInDBConfigName() { assert(0); } | ||
static const char* GetEQEnableConfigName() { assert(0); } | ||
}; | ||
|
||
template<FilterConfiguration::Channel ChannelId> | ||
class FilterChannel : public WxWidgetsConfigStore | ||
{ | ||
public: | ||
FilterChannel(); | ||
virtual ~FilterChannel() = default; | ||
|
||
ConfigurationDataElement<float> bassFreqHz; | ||
ConfigurationDataElement<float> bassGaindB; | ||
ConfigurationDataElement<float> trebleFreqHz; | ||
ConfigurationDataElement<float> trebleGaindB; | ||
ConfigurationDataElement<float> midFreqHz; | ||
ConfigurationDataElement<float> midGainDB; | ||
ConfigurationDataElement<float> midQ; | ||
ConfigurationDataElement<float> volInDB; | ||
ConfigurationDataElement<bool> eqEnable; | ||
|
||
virtual void load(wxConfigBase* config) override; | ||
virtual void save(wxConfigBase* config) override; | ||
}; | ||
|
||
FilterConfiguration() = default; | ||
virtual ~FilterConfiguration() = default; | ||
|
||
FilterChannel<MicIn> micInChannel; | ||
FilterChannel<SpkOut> spkOutChannel; | ||
|
||
virtual void load(wxConfigBase* config) override; | ||
virtual void save(wxConfigBase* config) override; | ||
}; | ||
|
||
#define DECLARE_FILTER_CONFIG_NAME(type, name) \ | ||
template<> \ | ||
const char* FilterConfiguration::FilterChannelConfigName<FilterConfiguration::type>::Get ## name ## ConfigName() | ||
|
||
#define DECLARE_FILTER_CONFIG_NAMES(type) \ | ||
DECLARE_FILTER_CONFIG_NAME(type, BassFreqHz); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, BassGaindB); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, TrebleFreqHz); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, TrebleGaindB); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, MidFreqHz); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, MidGaindB); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, MidQ); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, VolInDB); \ | ||
DECLARE_FILTER_CONFIG_NAME(type, EQEnable); | ||
|
||
#define DEFINE_FILTER_CONFIG_NAME(type, name) \ | ||
DECLARE_FILTER_CONFIG_NAME(type, name) { return "/Filter/" #type #name; } | ||
|
||
#define DEFINE_FILTER_CONFIG_NAMES(type) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, BassFreqHz) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, BassGaindB) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, TrebleFreqHz) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, TrebleGaindB) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, MidFreqHz) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, MidGaindB) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, MidQ) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, VolInDB) \ | ||
DEFINE_FILTER_CONFIG_NAME(type, EQEnable) | ||
|
||
DECLARE_FILTER_CONFIG_NAMES(MicIn); | ||
DECLARE_FILTER_CONFIG_NAMES(SpkOut); | ||
|
||
template<FilterConfiguration::Channel ChannelId> | ||
FilterConfiguration::FilterChannel<ChannelId>::FilterChannel() | ||
: bassFreqHz(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetBassFreqHzConfigName(), 1) | ||
, bassGaindB(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetBassGaindBConfigName(), ((long)0)/10.0) | ||
, trebleFreqHz(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetTrebleFreqHzConfigName(), 1) | ||
, trebleGaindB(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetTrebleGaindBConfigName(), ((long)0)/10.0) | ||
, midFreqHz(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetMidFreqHzConfigName(), 1) | ||
, midGainDB(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetMidGaindBConfigName(), ((long)0)/10.0) | ||
, midQ(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetMidQConfigName(), ((long)100)/100.0) | ||
, volInDB(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetVolInDBConfigName(), ((long)0)/10.0) | ||
, eqEnable(FilterConfiguration::FilterChannelConfigName<ChannelId>::GetEQEnableConfigName(), false) | ||
{ | ||
// empty | ||
} | ||
|
||
template<FilterConfiguration::Channel ChannelId> | ||
void FilterConfiguration::FilterChannel<ChannelId>::load(wxConfigBase* config) | ||
{ | ||
load_(config, bassFreqHz); | ||
load_(config, bassGaindB); | ||
load_(config, trebleFreqHz); | ||
load_(config, trebleGaindB); | ||
load_(config, midFreqHz); | ||
load_(config, midGainDB); | ||
load_(config, midQ); | ||
load_(config, volInDB); | ||
load_(config, eqEnable); | ||
} | ||
|
||
template<FilterConfiguration::Channel ChannelId> | ||
void FilterConfiguration::FilterChannel<ChannelId>::save(wxConfigBase* config) | ||
{ | ||
save_(config, bassFreqHz); | ||
save_(config, bassGaindB); | ||
save_(config, trebleFreqHz); | ||
save_(config, trebleGaindB); | ||
save_(config, midFreqHz); | ||
save_(config, midGainDB); | ||
save_(config, midQ); | ||
save_(config, volInDB); | ||
save_(config, eqEnable); | ||
} | ||
|
||
#endif // FILTER_CONFIGURATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.