libobs, UI: Add true peak measurements

Add a new algorithm to calculate the true-peak. It implements the
Whittaker- Shannon interpolation from four samples to create 4
intermediate samples (5 x oversampling) inbetween the middle two
samples.

With 4 samples and 4 intermediate samples the algorithm can be
implemented as a 4x4 vector-matrix cross product, which is ideal for
SSE.

I've also replaced the sample-peak algorithm using SSE as well to
improve performance.

Closes obsproject/obs-studio#1189
This commit is contained in:
Tjienta Vara 2018-01-19 22:57:36 +01:00 • committed by jp9000
commit b0f94afaf2
9 changed files with 417 additions and 45 deletions

View file

@ -388,6 +388,29 @@ void OBSBasic::UpdateVolumeControlsDecayRate()
}
}
void OBSBasic::UpdateVolumeControlsPeakMeterType()
{
uint32_t peakMeterTypeIdx = config_get_uint(basicConfig, "Audio",
"PeakMeterType");
enum obs_peak_meter_type peakMeterType;
switch (peakMeterTypeIdx) {
case 0:
peakMeterType = SAMPLE_PEAK_METER;
break;
case 1:
peakMeterType = TRUE_PEAK_METER;
break;
default:
peakMeterType = SAMPLE_PEAK_METER;
break;
}
for (size_t i = 0; i < volumes.size(); i++) {
volumes[i]->setPeakMeterType(peakMeterType);
}
}
void OBSBasic::ClearVolumeControls()
{
VolControl *control;
@ -1153,6 +1176,7 @@ bool OBSBasic::InitBasicConfigDefaults()
"Stereo");
config_set_default_double(basicConfig, "Audio", "MeterDecayRate",
VOLUME_METER_DECAY_FAST);
config_set_default_uint (basicConfig, "Audio", "PeakMeterType", 0);
return true;
}
@ -2507,6 +2531,25 @@ void OBSBasic::ActivateAudioSource(OBSSource source)
double meterDecayRate = config_get_double(basicConfig, "Audio",
"MeterDecayRate");
vol->SetMeterDecayRate(meterDecayRate);
uint32_t peakMeterTypeIdx = config_get_uint(basicConfig, "Audio",
"PeakMeterType");
enum obs_peak_meter_type peakMeterType;
switch (peakMeterTypeIdx) {
case 0:
peakMeterType = SAMPLE_PEAK_METER;
break;
case 1:
peakMeterType = TRUE_PEAK_METER;
break;
default:
peakMeterType = SAMPLE_PEAK_METER;
break;
}
vol->setPeakMeterType(peakMeterType);
vol->setContextMenuPolicy(Qt::CustomContextMenu);
connect(vol, &QWidget::customContextMenuRequested,