mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 14:59:14 +02:00
Merge pull request #2454 from birarda/audio-scaling
change audio-mixer cutoff scaling to be exponential
This commit is contained in:
commit
321930cec8
1 changed files with 2 additions and 7 deletions
|
@ -383,7 +383,6 @@ void AudioMixer::run() {
|
||||||
|
|
||||||
const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f;
|
const float STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.10f;
|
||||||
const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f;
|
const float BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD = 0.20f;
|
||||||
const float CUTOFF_DELTA = 0.02f;
|
|
||||||
|
|
||||||
const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES;
|
const float CURRENT_FRAME_RATIO = 1.0f / TRAILING_AVERAGE_FRAMES;
|
||||||
const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO;
|
const float PREVIOUS_FRAMES_RATIO = 1.0f - CURRENT_FRAME_RATIO;
|
||||||
|
@ -401,18 +400,14 @@ void AudioMixer::run() {
|
||||||
if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) {
|
if (framesSinceCutoffEvent >= TRAILING_AVERAGE_FRAMES) {
|
||||||
if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) {
|
if (_trailingSleepRatio <= STRUGGLE_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD) {
|
||||||
// we're struggling - change our min required loudness to reduce some load
|
// we're struggling - change our min required loudness to reduce some load
|
||||||
audabilityCutoffRatio += CUTOFF_DELTA;
|
audabilityCutoffRatio = audabilityCutoffRatio + (0.5f * (1.0f - audabilityCutoffRatio));
|
||||||
|
|
||||||
if (audabilityCutoffRatio >= 1) {
|
|
||||||
audabilityCutoffRatio = 1 - CUTOFF_DELTA;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
qDebug() << "Mixer is struggling, sleeping" << _trailingSleepRatio * 100 << "% of frame time. Old cutoff was"
|
||||||
<< lastCutoffRatio << "and is now" << audabilityCutoffRatio;
|
<< lastCutoffRatio << "and is now" << audabilityCutoffRatio;
|
||||||
hasRatioChanged = true;
|
hasRatioChanged = true;
|
||||||
} else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && audabilityCutoffRatio != 0) {
|
} else if (_trailingSleepRatio >= BACK_OFF_TRIGGER_SLEEP_PERCENTAGE_THRESHOLD && audabilityCutoffRatio != 0) {
|
||||||
// we've recovered and can back off the required loudness
|
// we've recovered and can back off the required loudness
|
||||||
audabilityCutoffRatio -= CUTOFF_DELTA;
|
audabilityCutoffRatio = audabilityCutoffRatio - (1.0f - audabilityCutoffRatio);
|
||||||
|
|
||||||
if (audabilityCutoffRatio < 0) {
|
if (audabilityCutoffRatio < 0) {
|
||||||
audabilityCutoffRatio = 0;
|
audabilityCutoffRatio = 0;
|
||||||
|
|
Loading…
Reference in a new issue