mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-13 20:30:07 +02:00
check for silent samples befor limiting
This commit is contained in:
parent
e69d6d8b5f
commit
7e2f1a6455
1 changed files with 7 additions and 5 deletions
|
@ -222,17 +222,19 @@ bool AudioMixerSlave::prepareMix(const SharedNodePointer& listener) {
|
||||||
stats.mixTime += mixTime.count();
|
stats.mixTime += mixTime.count();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// use the per listener AudioLimiter to render the mixed data...
|
// check for silent audio before limiting
|
||||||
listenerData->audioLimiter.render(_mixSamples, _bufferSamples, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL);
|
// limiting uses a dither and can only guarantee abs(sample) <= 1
|
||||||
|
|
||||||
// check for silent audio after the peak limiter has converted the samples
|
|
||||||
bool hasAudio = false;
|
bool hasAudio = false;
|
||||||
for (int i = 0; i < AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; ++i) {
|
for (int i = 0; i < AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; ++i) {
|
||||||
if (_bufferSamples[i] != 0) {
|
if (_mixSamples[i] != 0.0f) {
|
||||||
hasAudio = true;
|
hasAudio = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use the per listener AudioLimiter to render the mixed data
|
||||||
|
listenerData->audioLimiter.render(_mixSamples, _bufferSamples, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
return hasAudio;
|
return hasAudio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue