MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / Load

Method Load

plugins/base/macro-condition-audio.cpp:311–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311bool MacroConditionAudio::Load(obs_data_t *obj)
312{
313 MacroCondition::Load(obj);
314 _audioSource.Load(obj, "audioSource");
315 _monitorType = static_cast<obs_monitoring_type>(
316 obs_data_get_int(obj, "monitor"));
317 if (!obs_data_has_user_value(obj, "version")) {
318 _volumePercent = obs_data_get_int(obj, "volume");
319 _syncOffset = obs_data_get_int(obj, "syncOffset");
320 _balance = obs_data_get_double(obj, "balance");
321 } else {
322 _volumePercent.Load(obj, "volume");
323 _syncOffset.Load(obj, "syncOffset");
324 _balance.Load(obj, "balance");
325 }
326 _checkType = static_cast<Type>(obs_data_get_int(obj, "checkType"));
327 _outputCondition = static_cast<OutputCondition>(
328 obs_data_get_int(obj, "outputCondition"));
329 _volumeCondition = static_cast<VolumeCondition>(
330 obs_data_get_int(obj, "volumeCondition"));
331 _volmeter = addVolmeterToSource(this, _audioSource.GetSource());
332
333 if (obs_data_get_int(obj, "version") < 2) {
334 // Set default values for dB handling
335 _useDb = false;
336 _volumeDB = 0.0;
337
338 // In previous versions the scaling happened in CheckCondition()
339 // so these values must now be converted to enable compatibility
340 // with the decibel value based checks.
341 OBSDataAutoRelease data = obs_data_get_obj(obj, "volume");
342 auto oldFixedValue = obs_data_get_int(data, "value");
343 _volumeDB = ((double)oldFixedValue / 1.7) - 60;
344 _volumePercent = DecibelToPercent(_volumeDB) * 100;
345 } else {
346 _useDb = obs_data_get_bool(obj, "useDb");
347 _volumeDB.Load(obj, "volumeDB");
348 }
349 return true;
350}
351
352std::string MacroConditionAudio::GetShortDesc() const
353{

Callers

nothing calls this directly

Calls 3

DecibelToPercentFunction · 0.85
addVolmeterToSourceFunction · 0.70
GetSourceMethod · 0.45

Tested by

no test coverage detected