Commit 6a652e93 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3487] Improve notch filter for DC component removal

parent 99743b43
...@@ -1125,9 +1125,15 @@ void AlsaLayer::audioCallback(void) ...@@ -1125,9 +1125,15 @@ void AlsaLayer::audioCallback(void)
} else { } else {
int sampleready = AudioLayer::_echoCanceller->processAudio(in, echoCancelledMic, toPut);
SFLDataFormat* filter_out = (SFLDataFormat*) malloc (framesPerBufferAlsa * sizeof (SFLDataFormat));
_audiofilter->processAudio (in, filter_out, toPut);
int sampleready = AudioLayer::_echoCanceller->processAudio(filter_out, echoCancelledMic, toPut);
getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof(SFLDataFormat), 100); getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof(SFLDataFormat), 100);
free(rsmpl_out);
} }
} }
......
...@@ -77,7 +77,7 @@ void DcBlocker::process (SFLDataFormat *data, int nbBytes) ...@@ -77,7 +77,7 @@ void DcBlocker::process (SFLDataFormat *data, int nbBytes)
int nbSamples = nbBytes / sizeof(SFLDataFormat); int nbSamples = nbBytes / sizeof(SFLDataFormat);
for (int i = 0; i < nbSamples; i++) { for (int i = 0; i < nbSamples; i++) {
_debug("i: %d", i);
_x = data[i]; _x = data[i];
_y = (SFLDataFormat) ( (float) _x - (float) _xm1 + 0.9999 * (float) _ym1); _y = (SFLDataFormat) ( (float) _x - (float) _xm1 + 0.9999 * (float) _ym1);
...@@ -89,6 +89,22 @@ void DcBlocker::process (SFLDataFormat *data, int nbBytes) ...@@ -89,6 +89,22 @@ void DcBlocker::process (SFLDataFormat *data, int nbBytes)
} }
} }
int DcBlocker::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) { return 0;} int DcBlocker::process(SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes) {
int nbSamples = nbBytes / sizeof(SFLDataFormat);
for (int i = 0; i < nbSamples; i++) {
_x = inputData[i];
_y = (SFLDataFormat) ( (float) _x - (float) _xm1 + 0.9999 * (float) _ym1);
_xm1 = _x;
_ym1 = _y;
outputData[i] = _y;
}
return 0;
}
void DcBlocker::process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {} void DcBlocker::process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {}
...@@ -981,11 +981,18 @@ void PulseLayer::readFromMic (void) ...@@ -981,11 +981,18 @@ void PulseLayer::readFromMic (void)
} else { } else {
SFLDataFormat* filter_out = (SFLDataFormat*) pa_xmalloc (r);
// remove dc offset
_audiofilter->processAudio((SFLDataFormat *)data, filter_out, r);
// echo cancellation processing // echo cancellation processing
int sampleready = _echoCanceller->processAudio((SFLDataFormat *)data, echoCancelledMic, r); int sampleready = _echoCanceller->processAudio((SFLDataFormat *)data, echoCancelledMic, r);
// no resampling required // no resampling required
getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100); getMainBuffer()->putData (echoCancelledMic, sampleready*sizeof (SFLDataFormat), 100);
pa_xfree(filter_out);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment