0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

Fix audio meters so that volume is applied linearly.

This commit is contained in:
HomeWorld 2014-07-14 21:12:53 +03:00
parent 37828ce26d
commit 6b284d9e58
2 changed files with 13 additions and 5 deletions

View File

@ -565,8 +565,15 @@ static void calc_volume_levels(struct obs_source *source, float *array,
max_val = fmaxf(max_val, val_pow2);
}
rms_val = to_db(sqrtf(sum_val / (float)count) * volume);
max_val = to_db(sqrtf(max_val) * volume);
/*
We want the volume meters scale linearly in respect to current
volume, so, no need to apply volume here.
*/
UNUSED_PARAMETER(volume);
rms_val = to_db(sqrtf(sum_val / (float)count));
max_val = to_db(sqrtf(max_val));
if (max_val > source->vol_max)
source->vol_max = max_val;

View File

@ -74,10 +74,11 @@ void VolControl::VolumeLevel(float mag, float peak, float peakHold)
/* only update after a certain amount of time */
if ((curMeterTime - lastMeterTime) > UPDATE_INTERVAL_MS) {
float vol = (float)slider->value() * 0.01f;
lastMeterTime = curMeterTime;
volMeter->setLevels(DBToLinear(mag),
DBToLinear(peak),
DBToLinear(peakHold));
volMeter->setLevels(DBToLinear(mag) * vol,
DBToLinear(peak) * vol,
DBToLinear(peakHold) * vol);
}
}