#include "modules/audio_processing/ns/noise_suppressor.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include "modules/audio_processing/ns/fast_math.h"
#include "rtc_base/checks.h"
namespace webrtc {
namespace {
size_t NumBandsForRate(size_t sample_rate_hz) { … }
constexpr size_t kMaxNumChannelsOnStack = …;
size_t NumChannelsOnHeap(size_t num_channels) { … }
constexpr std::array<float, 96> kBlocks160w256FirstHalf = …;
void ApplyFilterBankWindow(rtc::ArrayView<float, kFftSize> x) { … }
void FormExtendedFrame(rtc::ArrayView<const float, kNsFrameSize> frame,
rtc::ArrayView<float, kFftSize - kNsFrameSize> old_data,
rtc::ArrayView<float, kFftSize> extended_frame) { … }
void OverlapAndAdd(rtc::ArrayView<const float, kFftSize> extended_frame,
rtc::ArrayView<float, kOverlapSize> overlap_memory,
rtc::ArrayView<float, kNsFrameSize> output_frame) { … }
void DelaySignal(rtc::ArrayView<const float, kNsFrameSize> frame,
rtc::ArrayView<float, kFftSize - kNsFrameSize> delay_buffer,
rtc::ArrayView<float, kNsFrameSize> delayed_frame) { … }
float ComputeEnergyOfExtendedFrame(rtc::ArrayView<const float, kFftSize> x) { … }
float ComputeEnergyOfExtendedFrame(
rtc::ArrayView<const float, kNsFrameSize> frame,
rtc::ArrayView<float, kFftSize - kNsFrameSize> old_data) { … }
void ComputeMagnitudeSpectrum(
rtc::ArrayView<const float, kFftSize> real,
rtc::ArrayView<const float, kFftSize> imag,
rtc::ArrayView<float, kFftSizeBy2Plus1> signal_spectrum) { … }
void ComputeSnr(rtc::ArrayView<const float, kFftSizeBy2Plus1> filter,
rtc::ArrayView<const float> prev_signal_spectrum,
rtc::ArrayView<const float> signal_spectrum,
rtc::ArrayView<const float> prev_noise_spectrum,
rtc::ArrayView<const float> noise_spectrum,
rtc::ArrayView<float> prior_snr,
rtc::ArrayView<float> post_snr) { … }
float ComputeUpperBandsGain(
float minimum_attenuating_gain,
rtc::ArrayView<const float, kFftSizeBy2Plus1> filter,
rtc::ArrayView<const float> speech_probability,
rtc::ArrayView<const float, kFftSizeBy2Plus1> prev_analysis_signal_spectrum,
rtc::ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum) { … }
}
NoiseSuppressor::ChannelState::ChannelState(
const SuppressionParams& suppression_params,
size_t num_bands)
: … { … }
NoiseSuppressor::NoiseSuppressor(const NsConfig& config,
size_t sample_rate_hz,
size_t num_channels)
: … { … }
void NoiseSuppressor::AggregateWienerFilters(
rtc::ArrayView<float, kFftSizeBy2Plus1> filter) const { … }
void NoiseSuppressor::Analyze(const AudioBuffer& audio) { … }
void NoiseSuppressor::Process(AudioBuffer* audio) { … }
}