mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
Fix for mixer clipping bug that's causing audio to crackle
This commit is contained in:
parent
8b6e5c8ef1
commit
4e13b625ca
@ -105,7 +105,7 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
peak += srcmix->currentInput->peak * srcmix->gain;
|
float mixPeak = srcmix->currentInput->peak * srcmix->gain;
|
||||||
|
|
||||||
if (srcmix->currentInput->channels == 1) {
|
if (srcmix->currentInput->channels == 1) {
|
||||||
for (int i = 0; i < nBufferFrames; i++) {
|
for (int i = 0; i < nBufferFrames; i++) {
|
||||||
@ -122,6 +122,10 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
srcmix->audioQueuePtr = 0;
|
srcmix->audioQueuePtr = 0;
|
||||||
|
float srcPeak = srcmix->currentInput->peak * srcmix->gain;
|
||||||
|
if (mixPeak < srcPeak) {
|
||||||
|
mixPeak = srcPeak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
||||||
float v = srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
float v = srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
||||||
@ -145,6 +149,10 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
srcmix->audioQueuePtr = 0;
|
srcmix->audioQueuePtr = 0;
|
||||||
|
float srcPeak = srcmix->currentInput->peak * srcmix->gain;
|
||||||
|
if (mixPeak < srcPeak) {
|
||||||
|
mixPeak = srcPeak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
if (srcmix->currentInput && srcmix->currentInput->data.size()) {
|
||||||
out[i] = out[i] + srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
out[i] = out[i] + srcmix->currentInput->data[srcmix->audioQueuePtr] * srcmix->gain;
|
||||||
@ -153,13 +161,14 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peak += mixPeak;
|
||||||
|
}
|
||||||
|
|
||||||
if (peak > 1.0) {
|
if (peak > 1.0) {
|
||||||
for (int i = 0; i < nBufferFrames * 2; i++) {
|
for (int i = 0; i < nBufferFrames * 2; i++) {
|
||||||
out[i] /= peak;
|
out[i] /= peak;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +191,8 @@ void DemodulatorThread::threadMain() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
amOutputCeilMA = amOutputCeilMA + (amOutputCeil - amOutputCeilMA) * 0.05;
|
amOutputCeilMA = amOutputCeilMA + (amOutputCeil - amOutputCeilMA) * 0.025;
|
||||||
amOutputCeilMAA = amOutputCeilMAA + (amOutputCeilMA - amOutputCeilMAA) * 0.05;
|
amOutputCeilMAA = amOutputCeilMAA + (amOutputCeilMA - amOutputCeilMAA) * 0.025;
|
||||||
|
|
||||||
amOutputCeil = 0;
|
amOutputCeil = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user