Audacity 3.2.0
Classes | Functions | Variables
DynamicRangeProcessorUtils::anonymous_namespace{DynamicRangeProcessorUtils.cpp} Namespace Reference

Classes

struct  SettingDescription
 

Functions

template<typename Struct >
std::optional< Struct > Deserialize (const std::string &str, const std::vector< SettingDescription< Struct > > &settings)
 
template<typename Struct >
std::vector< Preset< Struct > > GetPresets (const std::vector< SettingDescription< Struct > > &settingDescriptions, const std::vector< Detail::SerializedPreset > &serializedPresets)
 

Variables

static const std::vector< SettingDescription< CompressorSettings > > compressorSettingDescriptions
 
const std::vector< SettingDescription< LimiterSettings > > limiterSettingDescriptions
 

Function Documentation

◆ Deserialize()

template<typename Struct >
std::optional< Struct > DynamicRangeProcessorUtils::anonymous_namespace{DynamicRangeProcessorUtils.cpp}::Deserialize ( const std::string &  str,
const std::vector< SettingDescription< Struct > > &  settings 
)

Definition at line 57 of file DynamicRangeProcessorUtils.cpp.

60{
61 Struct settingStruct;
62
63 const std::regex pattern(R"((\w+)=\"(-?\d+\.?\d*)\")");
64
65 // Create an unordered_map to store the key-value pairs
66 std::unordered_map<std::string, std::string> values;
67
68 const auto begin = std::sregex_iterator(str.begin(), str.end(), pattern);
69 const auto end = std::sregex_iterator();
70
71 for (auto it = begin; it != end; ++it)
72 {
73 const std::smatch match = *it;
74 values[match[1].str()] = match[2].str();
75 }
76
77 if (std::any_of(
78 settings.begin(), settings.end(), [&values](const auto& setting) {
79 return values.find(setting.key) == values.end();
80 }))
81 return {};
82
83 for (const auto& setting : settings)
84 try
85 {
86 settingStruct.*(setting.mem) = std::stod(values.at(setting.key));
87 }
88 catch (...)
89 {
90 return {};
91 }
92
93 return settingStruct;
94}
#define str(a)
const wxChar * values
static Settings & settings()
Definition: TrackInfo.cpp:51
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), details::end(), settings(), str, and values.

Here is the call graph for this function:

◆ GetPresets()

template<typename Struct >
std::vector< Preset< Struct > > DynamicRangeProcessorUtils::anonymous_namespace{DynamicRangeProcessorUtils.cpp}::GetPresets ( const std::vector< SettingDescription< Struct > > &  settingDescriptions,
const std::vector< Detail::SerializedPreset > &  serializedPresets 
)

Definition at line 97 of file DynamicRangeProcessorUtils.cpp.

100{
101 std::vector<Preset<Struct>> presets;
102 for (const auto& serialized : serializedPresets)
103 if (
104 const auto preset =
105 Deserialize<Struct>(serialized.settings, settingDescriptions))
106 presets.push_back({ serialized.name, *preset });
107
108 return presets;
109}
ReverbSettings preset
Definition: ReverbBase.cpp:25

References preset.

Variable Documentation

◆ compressorSettingDescriptions

const std::vector<SettingDescription<CompressorSettings> > DynamicRangeProcessorUtils::anonymous_namespace{DynamicRangeProcessorUtils.cpp}::compressorSettingDescriptions
static
Initial value:
{
{ &CompressorSettings::thresholdDb, "thresholdDb" },
{ &CompressorSettings::makeupGainDb, "makeupGainDb" },
{ &CompressorSettings::kneeWidthDb, "kneeWidthDb" },
{ &CompressorSettings::compressionRatio, "compressionRatio" },
{ &CompressorSettings::lookaheadMs, "lookaheadMs" },
{ &CompressorSettings::attackMs, "attackMs" },
{ &CompressorSettings::releaseMs, "releaseMs" },
{ &CompressorSettings::showInput, "showInput" },
{ &CompressorSettings::showOutput, "showOutput" },
{ &CompressorSettings::showActual, "showActual" },
{ &CompressorSettings::showTarget, "showTarget" },
}

Definition at line 29 of file DynamicRangeProcessorUtils.cpp.

Referenced by DynamicRangeProcessorUtils::GetCompressorPresets().

◆ limiterSettingDescriptions

const std::vector<SettingDescription<LimiterSettings> > DynamicRangeProcessorUtils::anonymous_namespace{DynamicRangeProcessorUtils.cpp}::limiterSettingDescriptions