MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / loadOne

Function loadOne

src/core/AudioEngine.cpp:3266–3307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3264}
3265
3266void loadOne(ClientEq& eq, const char* tag)
3267{
3268 auto& s = AppSettings::instance();
3269 const bool enabled = s.value(ceqKey(tag, "Enabled"), "False").toString() == "True";
3270 const int savedCount = std::clamp(
3271 s.value(ceqKey(tag, "BandCount"), "0").toString().toInt(),
3272 0, ClientEq::kMaxBands);
3273 const float masterGain = std::clamp(
3274 s.value(ceqKey(tag, "MasterGain"), "1.0").toString().toFloat(),
3275 0.0f, 4.0f);
3276 const int familyIdx = std::clamp(
3277 s.value(ceqKey(tag, "FilterFamily"), "0").toString().toInt(), 0, 3);
3278 eq.setEnabled(enabled);
3279 eq.setMasterGain(masterGain);
3280 eq.setFilterFamily(static_cast<ClientEq::FilterFamily>(familyIdx));
3281
3282 // Fixed 8-slot layout. If the user's saved state has fewer bands,
3283 // we keep their saved ones in slots [0, savedCount) and pad the
3284 // remaining slots with the default Logic-Pro-style templates, all
3285 // disabled. Existing users migrate in place — their configured
3286 // bands survive, they just gain a few untouched defaults next to them.
3287 const int activeCount = ClientEq::kDefaultBandCount;
3288 eq.setActiveBandCount(activeCount);
3289
3290 for (int i = 0; i < activeCount; ++i) {
3291 ClientEq::BandParams p;
3292 if (i < savedCount) {
3293 p.freqHz = s.value(ceqBandKey(tag, i, "Freq"), "1000").toString().toFloat();
3294 p.gainDb = s.value(ceqBandKey(tag, i, "Gain"), "0").toString().toFloat();
3295 p.q = s.value(ceqBandKey(tag, i, "Q"), "0.707").toString().toFloat();
3296 p.type = static_cast<ClientEq::FilterType>(
3297 s.value(ceqBandKey(tag, i, "Type"), "0").toString().toInt());
3298 p.enabled = s.value(ceqBandKey(tag, i, "BandEn"), "True").toString() == "True";
3299 p.slopeDbPerOct = std::clamp(
3300 s.value(ceqBandKey(tag, i, "Slope"), "12").toString().toInt(),
3301 12, 48);
3302 } else {
3303 p = ClientEq::defaultBand(i); // disabled by default
3304 }
3305 eq.setBand(i, p);
3306 }
3307}
3308
3309void saveOne(const ClientEq& eq, const char* tag)
3310{

Callers 1

loadClientEqSettingsMethod · 0.85

Calls 9

ceqKeyFunction · 0.85
ceqBandKeyFunction · 0.85
setMasterGainMethod · 0.80
setFilterFamilyMethod · 0.80
setActiveBandCountMethod · 0.80
setBandMethod · 0.80
toStringMethod · 0.45
valueMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected