/* * Copyright (c) 2025 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef MODULES_AUDIO_PROCESSING_CAPTURE_MIXER_ENERGY_ESTIMATOR_H_ #define MODULES_AUDIO_PROCESSING_CAPTURE_MIXER_ENERGY_ESTIMATOR_H_ #include #include #include "api/array_view.h" namespace webrtc { // Estimates the average energy of two audio channels, compensating for DC // offsets. class AverageEnergyEstimator { public: // Constructs an AverageEnergyEstimator. AverageEnergyEstimator(); AverageEnergyEstimator(const AverageEnergyEstimator&) = delete; AverageEnergyEstimator& operator=(const AverageEnergyEstimator&) = delete; // Updates the average energy estimates for the two channels. // `channel0` and `channel1` contain the samples of the two channels. // `dc_levels` contains the estimated DC offsets for the two channels, which // are subtracted from the samples before energy calculation. void Update(ArrayView channel0, ArrayView channel1, ArrayView dc_levels); // Returns the current average energy estimates for the two channels. ArrayView GetChannelEnergies() const { return average_energy_in_channels_; } private: std::array average_energy_in_channels_; }; } // namespace webrtc #endif // MODULES_AUDIO_PROCESSING_CAPTURE_MIXER_ENERGY_ESTIMATOR_H_