Skip to content

Commit

Permalink
Easier to switch between CNG impls for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kcoul committed Feb 26, 2022
1 parent 4f2fd59 commit 62814fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
17 changes: 10 additions & 7 deletions audio_processing/aec3/echo_remover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "audio_processing/aec3/aec3_common.h"
#include "audio_processing/aec3/aec3_fft.h"
#include "audio_processing/aec3/aec_state.h"
//#include "audio_processing/aec3/comfort_noise_generator.h"
#include "audio_processing/aec3/comfort_noise_generator.h"
#include "audio_processing/aec3/false_comfort_noise_generator.h"
#include "audio_processing/aec3/scaled_comfort_noise_generator.h"
#include "audio_processing/aec3/echo_path_variability.h"
#include "audio_processing/aec3/echo_remover_metrics.h"
Expand Down Expand Up @@ -151,7 +152,9 @@ class EchoRemoverImpl final : public EchoRemover {
const bool use_shadow_filter_output_;
Subtractor subtractor_;
SuppressionGain suppression_gain_;
ScaledComfortNoiseGenerator scng_;
//ComfortNoiseGenerator cng_;
FalseComfortNoiseGenerator cng_;
//ScaledComfortNoiseGenerator cng_;
SuppressionFilter suppression_filter_;
RenderSignalAnalyzer render_signal_analyzer_;
ResidualEchoEstimator residual_echo_estimator_;
Expand Down Expand Up @@ -201,7 +204,7 @@ EchoRemoverImpl::EchoRemoverImpl(const EchoCanceller3Config& config,
optimization_,
sample_rate_hz,
num_capture_channels),
scng_(optimization_, num_capture_channels_),
cng_(optimization_, num_capture_channels_),
suppression_filter_(optimization_,
sample_rate_hz_,
num_capture_channels_),
Expand Down Expand Up @@ -395,7 +398,7 @@ void EchoRemoverImpl::ProcessCapture(
residual_echo_estimator_.Estimate(aec_state_, *render_buffer, S2_linear, Y2,
R2);

scng_.Compute(aec_state_.SaturatedCapture(), Y2, comfort_noise,
cng_.Compute(aec_state_.SaturatedCapture(), Y2, comfort_noise,
high_band_comfort_noise);

if (aec_state_.UsableLinearEstimate()) {
Expand All @@ -415,22 +418,22 @@ void EchoRemoverImpl::ProcessCapture(
float high_bands_gain;
std::array<float, kFftLengthBy2Plus1> G;
suppression_gain_.GetGain(nearend_spectrum, echo_spectrum, R2,
scng_.NoiseSpectrum(), render_signal_analyzer_,
cng_.NoiseSpectrum(), render_signal_analyzer_,
aec_state_, x, &high_bands_gain, &G);

suppression_filter_.ApplyGain(comfort_noise, high_band_comfort_noise, G,
high_bands_gain, Y_fft, y);

// Update the metrics.
metrics_.Update(aec_state_, scng_.NoiseSpectrum()[0], G);
metrics_.Update(aec_state_, cng_.NoiseSpectrum()[0], G);

// Debug outputs for the purpose of development and analysis.
data_dumper_->DumpWav("aec3_echo_estimate", kBlockSize,
&subtractor_output[0].s_main[0], 16000, 1);
data_dumper_->DumpRaw("aec3_output", (*y)[0][0]);
data_dumper_->DumpRaw("aec3_narrow_render",
render_signal_analyzer_.NarrowPeakBand() ? 1 : 0);
data_dumper_->DumpRaw("aec3_N2", scng_.NoiseSpectrum()[0]);
data_dumper_->DumpRaw("aec3_N2", cng_.NoiseSpectrum()[0]);
data_dumper_->DumpRaw("aec3_suppressor_gain", G);
data_dumper_->DumpWav("aec3_output",
rtc::ArrayView<const float>(&(*y)[0][0][0], kBlockSize),
Expand Down
4 changes: 3 additions & 1 deletion audio_processing/aec3/scaled_comfort_noise_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ void ScaledComfortNoiseGenerator::Compute(
// Limit the noise to a floor matching a WGN input of -96 dBFS.
// NOTE: This means that the noise shall be *no less* than -96 dBFS, there is no limit on maximum
constexpr float kNoiseFloor = 17.1267f; //dBu???
constexpr float kNoiseCeiling = 10.0f;

//TODO: This code does not accomplish the intended goal, there is no advantage over FCNG currently.
constexpr float kNoiseCeiling = 4.0f;

for (size_t ch = 0; ch < num_capture_channels_; ++ch) {
for (auto& n : N2_[ch]) {
Expand Down
2 changes: 1 addition & 1 deletion demo/demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ int main(int argc, char* argv[])
wav_write_close(h_linear_out);

return 0;
}
}

0 comments on commit 62814fd

Please sign in to comment.