Update to current webrtc library
This is from the upstream library commit id 3326535126e435f1ba647885ce43a8f0f3d317eb, corresponding to Chromium 88.0.4290.1.
This commit is contained in:
112
webrtc/modules/audio_processing/transient/BUILD.gn
Normal file
112
webrtc/modules/audio_processing/transient/BUILD.gn
Normal file
@ -0,0 +1,112 @@
|
||||
# Copyright (c) 2020 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.
|
||||
|
||||
import("../../../webrtc.gni")
|
||||
|
||||
rtc_source_set("transient_suppressor_api") {
|
||||
sources = [ "transient_suppressor.h" ]
|
||||
}
|
||||
|
||||
rtc_library("transient_suppressor_impl") {
|
||||
visibility = [
|
||||
"..:optionally_built_submodule_creators",
|
||||
":transient_suppression_test",
|
||||
":transient_suppression_unittests",
|
||||
":click_annotate",
|
||||
]
|
||||
sources = [
|
||||
"common.h",
|
||||
"daubechies_8_wavelet_coeffs.h",
|
||||
"dyadic_decimator.h",
|
||||
"moving_moments.cc",
|
||||
"moving_moments.h",
|
||||
"transient_detector.cc",
|
||||
"transient_detector.h",
|
||||
"transient_suppressor_impl.cc",
|
||||
"transient_suppressor_impl.h",
|
||||
"windows_private.h",
|
||||
"wpd_node.cc",
|
||||
"wpd_node.h",
|
||||
"wpd_tree.cc",
|
||||
"wpd_tree.h",
|
||||
]
|
||||
deps = [
|
||||
":transient_suppressor_api",
|
||||
"../../../common_audio:common_audio",
|
||||
"../../../common_audio:common_audio_c",
|
||||
"../../../common_audio:fir_filter",
|
||||
"../../../common_audio:fir_filter_factory",
|
||||
"../../../common_audio/third_party/ooura:fft_size_256",
|
||||
"../../../rtc_base:checks",
|
||||
"../../../rtc_base:gtest_prod",
|
||||
"../../../rtc_base:logging",
|
||||
]
|
||||
}
|
||||
|
||||
if (rtc_include_tests) {
|
||||
rtc_executable("click_annotate") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"click_annotate.cc",
|
||||
"file_utils.cc",
|
||||
"file_utils.h",
|
||||
]
|
||||
deps = [
|
||||
":transient_suppressor_impl",
|
||||
"..:audio_processing",
|
||||
"../../../rtc_base/system:file_wrapper",
|
||||
"../../../system_wrappers",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_executable("transient_suppression_test") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"file_utils.cc",
|
||||
"file_utils.h",
|
||||
"transient_suppression_test.cc",
|
||||
]
|
||||
deps = [
|
||||
":transient_suppressor_impl",
|
||||
"..:audio_processing",
|
||||
"../../../common_audio",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../rtc_base/system:file_wrapper",
|
||||
"../../../system_wrappers",
|
||||
"../../../test:fileutils",
|
||||
"../../../test:test_support",
|
||||
"../agc:level_estimation",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("transient_suppression_unittests") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"dyadic_decimator_unittest.cc",
|
||||
"file_utils.cc",
|
||||
"file_utils.h",
|
||||
"file_utils_unittest.cc",
|
||||
"moving_moments_unittest.cc",
|
||||
"transient_detector_unittest.cc",
|
||||
"transient_suppressor_unittest.cc",
|
||||
"wpd_node_unittest.cc",
|
||||
"wpd_tree_unittest.cc",
|
||||
]
|
||||
deps = [
|
||||
":transient_suppressor_impl",
|
||||
"../../../rtc_base:stringutils",
|
||||
"../../../rtc_base/system:file_wrapper",
|
||||
"../../../test:fileutils",
|
||||
"../../../test:test_support",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
}
|
@ -11,14 +11,13 @@
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "modules/audio_processing/transient/file_utils.h"
|
||||
#include "modules/audio_processing/transient/transient_detector.h"
|
||||
#include "rtc_base/system/file_wrapper.h"
|
||||
|
||||
using rtc::scoped_ptr;
|
||||
using webrtc::FileWrapper;
|
||||
using webrtc::TransientDetector;
|
||||
|
||||
@ -40,16 +39,14 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
scoped_ptr<FileWrapper> pcm_file(FileWrapper::Create());
|
||||
pcm_file->OpenFile(argv[1], true, false, false);
|
||||
if (!pcm_file->Open()) {
|
||||
FileWrapper pcm_file = FileWrapper::OpenReadOnly(argv[1]);
|
||||
if (!pcm_file.is_open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scoped_ptr<FileWrapper> dat_file(FileWrapper::Create());
|
||||
dat_file->OpenFile(argv[2], false, false, false);
|
||||
if (!dat_file->Open()) {
|
||||
FileWrapper dat_file = FileWrapper::OpenWriteOnly(argv[2]);
|
||||
if (!dat_file.is_open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
@ -69,14 +66,12 @@ int main(int argc, char* argv[]) {
|
||||
TransientDetector detector(sample_rate_hz);
|
||||
int lost_packets = 0;
|
||||
size_t audio_buffer_length = chunk_size_ms * sample_rate_hz / 1000;
|
||||
scoped_ptr<float[]> audio_buffer(new float[audio_buffer_length]);
|
||||
std::unique_ptr<float[]> audio_buffer(new float[audio_buffer_length]);
|
||||
std::vector<float> send_times;
|
||||
|
||||
// Read first buffer from the PCM test file.
|
||||
size_t file_samples_read = ReadInt16FromFileToFloatBuffer(
|
||||
pcm_file.get(),
|
||||
audio_buffer_length,
|
||||
audio_buffer.get());
|
||||
&pcm_file, audio_buffer_length, audio_buffer.get());
|
||||
for (int time = 0; file_samples_read > 0; time += chunk_size_ms) {
|
||||
// Pad the rest of the buffer with zeros.
|
||||
for (size_t i = file_samples_read; i < audio_buffer_length; ++i) {
|
||||
@ -93,22 +88,20 @@ int main(int argc, char* argv[]) {
|
||||
send_times.push_back(value);
|
||||
|
||||
// Read next buffer from the PCM test file.
|
||||
file_samples_read = ReadInt16FromFileToFloatBuffer(pcm_file.get(),
|
||||
audio_buffer_length,
|
||||
audio_buffer.get());
|
||||
file_samples_read = ReadInt16FromFileToFloatBuffer(
|
||||
&pcm_file, audio_buffer_length, audio_buffer.get());
|
||||
}
|
||||
|
||||
size_t floats_written = WriteFloatBufferToFile(dat_file.get(),
|
||||
send_times.size(),
|
||||
&send_times[0]);
|
||||
size_t floats_written =
|
||||
WriteFloatBufferToFile(&dat_file, send_times.size(), &send_times[0]);
|
||||
|
||||
if (floats_written == 0) {
|
||||
printf("\nThe send times could not be written to DAT file\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pcm_file->CloseFile();
|
||||
dat_file->CloseFile();
|
||||
pcm_file.Close();
|
||||
dat_file.Close();
|
||||
|
||||
return lost_packets;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
namespace webrtc {
|
||||
namespace ts {
|
||||
|
||||
@ -22,6 +22,6 @@ enum {
|
||||
kSampleRate48kHz = 48000
|
||||
};
|
||||
|
||||
} // namespace ts
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
} // namespace ts
|
||||
} // namespace webrtc
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
// This header file defines the coefficients of the FIR based approximation of
|
||||
// the Meyer Wavelet
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
|
||||
// Decomposition coefficients Daubechies 8.
|
||||
|
||||
@ -19,45 +19,26 @@ namespace webrtc {
|
||||
|
||||
const int kDaubechies8CoefficientsLength = 16;
|
||||
|
||||
const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength]
|
||||
= {
|
||||
-5.44158422430816093862e-02f,
|
||||
3.12871590914465924627e-01f,
|
||||
-6.75630736298012846142e-01f,
|
||||
5.85354683654869090148e-01f,
|
||||
1.58291052560238926228e-02f,
|
||||
-2.84015542962428091389e-01f,
|
||||
-4.72484573997972536787e-04f,
|
||||
1.28747426620186011803e-01f,
|
||||
1.73693010020221083600e-02f,
|
||||
-4.40882539310647192377e-02f,
|
||||
-1.39810279170155156436e-02f,
|
||||
8.74609404701565465445e-03f,
|
||||
4.87035299301066034600e-03f,
|
||||
-3.91740372995977108837e-04f,
|
||||
-6.75449405998556772109e-04f,
|
||||
-1.17476784002281916305e-04f
|
||||
};
|
||||
const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength] = {
|
||||
-5.44158422430816093862e-02f, 3.12871590914465924627e-01f,
|
||||
-6.75630736298012846142e-01f, 5.85354683654869090148e-01f,
|
||||
1.58291052560238926228e-02f, -2.84015542962428091389e-01f,
|
||||
-4.72484573997972536787e-04f, 1.28747426620186011803e-01f,
|
||||
1.73693010020221083600e-02f, -4.40882539310647192377e-02f,
|
||||
-1.39810279170155156436e-02f, 8.74609404701565465445e-03f,
|
||||
4.87035299301066034600e-03f, -3.91740372995977108837e-04f,
|
||||
-6.75449405998556772109e-04f, -1.17476784002281916305e-04f};
|
||||
|
||||
const float kDaubechies8LowPassCoefficients[kDaubechies8CoefficientsLength] = {
|
||||
-1.17476784002281916305e-04f,
|
||||
6.75449405998556772109e-04f,
|
||||
-3.91740372995977108837e-04f,
|
||||
-4.87035299301066034600e-03f,
|
||||
8.74609404701565465445e-03f,
|
||||
1.39810279170155156436e-02f,
|
||||
-4.40882539310647192377e-02f,
|
||||
-1.73693010020221083600e-02f,
|
||||
1.28747426620186011803e-01f,
|
||||
4.72484573997972536787e-04f,
|
||||
-2.84015542962428091389e-01f,
|
||||
-1.58291052560238926228e-02f,
|
||||
5.85354683654869090148e-01f,
|
||||
6.75630736298012846142e-01f,
|
||||
3.12871590914465924627e-01f,
|
||||
5.44158422430816093862e-02f
|
||||
};
|
||||
-1.17476784002281916305e-04f, 6.75449405998556772109e-04f,
|
||||
-3.91740372995977108837e-04f, -4.87035299301066034600e-03f,
|
||||
8.74609404701565465445e-03f, 1.39810279170155156436e-02f,
|
||||
-4.40882539310647192377e-02f, -1.73693010020221083600e-02f,
|
||||
1.28747426620186011803e-01f, 4.72484573997972536787e-04f,
|
||||
-2.84015542962428091389e-01f, -1.58291052560238926228e-02f,
|
||||
5.85354683654869090148e-01f, 6.75630736298012846142e-01f,
|
||||
3.12871590914465924627e-01f, 5.44158422430816093862e-02f};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_DAUBECHIES_8_WAVELET_COEFFS_H_
|
||||
|
@ -8,13 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
// Provides a set of static methods to perform dyadic decimations.
|
||||
|
||||
namespace webrtc {
|
||||
@ -44,7 +42,7 @@ inline size_t GetOutLengthToDyadicDecimate(size_t in_length,
|
||||
// GetOutLengthToDyadicDecimate().
|
||||
// Must be previously allocated.
|
||||
// Returns the number of output samples, -1 on error.
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
static size_t DyadicDecimate(const T* in,
|
||||
size_t in_length,
|
||||
bool odd_sequence,
|
||||
@ -67,4 +65,4 @@ static size_t DyadicDecimate(const T* in,
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_DYADIC_DECIMATOR_H_
|
||||
|
@ -8,11 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
#include "modules/audio_processing/transient/file_utils.h"
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include <memory>
|
||||
|
||||
#include "rtc_base/system/file_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -79,11 +79,11 @@ int ConvertDoubleToByteArray(double value, uint8_t out_bytes[8]) {
|
||||
size_t ReadInt16BufferFromFile(FileWrapper* file,
|
||||
size_t length,
|
||||
int16_t* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
|
||||
size_t int16s_read = 0;
|
||||
|
||||
@ -105,11 +105,11 @@ size_t ReadInt16BufferFromFile(FileWrapper* file,
|
||||
size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file,
|
||||
size_t length,
|
||||
float* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
std::unique_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
|
||||
size_t int16s_read = ReadInt16BufferFromFile(file, length, buffer16.get());
|
||||
|
||||
@ -123,11 +123,11 @@ size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file,
|
||||
size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file,
|
||||
size_t length,
|
||||
double* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
std::unique_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
|
||||
size_t int16s_read = ReadInt16BufferFromFile(file, length, buffer16.get());
|
||||
|
||||
@ -141,11 +141,11 @@ size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file,
|
||||
size_t ReadFloatBufferFromFile(FileWrapper* file,
|
||||
size_t length,
|
||||
float* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
|
||||
size_t floats_read = 0;
|
||||
|
||||
@ -164,11 +164,11 @@ size_t ReadFloatBufferFromFile(FileWrapper* file,
|
||||
size_t ReadDoubleBufferFromFile(FileWrapper* file,
|
||||
size_t length,
|
||||
double* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
|
||||
size_t doubles_read = 0;
|
||||
|
||||
@ -187,11 +187,11 @@ size_t ReadDoubleBufferFromFile(FileWrapper* file,
|
||||
size_t WriteInt16BufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
const int16_t* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
|
||||
size_t int16s_written = 0;
|
||||
|
||||
@ -211,11 +211,11 @@ size_t WriteInt16BufferToFile(FileWrapper* file,
|
||||
size_t WriteFloatBufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
const float* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
|
||||
size_t floats_written = 0;
|
||||
|
||||
@ -234,11 +234,11 @@ size_t WriteFloatBufferToFile(FileWrapper* file,
|
||||
size_t WriteDoubleBufferToFile(FileWrapper* file,
|
||||
size_t length,
|
||||
const double* buffer) {
|
||||
if (!file || !file->Open() || !buffer || length <= 0) {
|
||||
if (!file || !file->is_open() || !buffer || length <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
|
||||
size_t doubles_written = 0;
|
||||
|
||||
|
@ -8,13 +8,12 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "rtc_base/system/file_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -115,4 +114,4 @@ size_t WriteDoubleBufferToFile(FileWrapper* file,
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_FILE_UTILS_H_
|
||||
|
@ -8,21 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
#include "modules/audio_processing/transient/moving_moments.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
MovingMoments::MovingMoments(size_t length)
|
||||
: length_(length),
|
||||
queue_(),
|
||||
sum_(0.0),
|
||||
sum_of_squares_(0.0) {
|
||||
assert(length > 0);
|
||||
: length_(length), queue_(), sum_(0.0), sum_of_squares_(0.0) {
|
||||
RTC_DCHECK_GT(length, 0);
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
queue_.push(0.0);
|
||||
}
|
||||
@ -30,9 +26,14 @@ MovingMoments::MovingMoments(size_t length)
|
||||
|
||||
MovingMoments::~MovingMoments() {}
|
||||
|
||||
void MovingMoments::CalculateMoments(const float* in, size_t in_length,
|
||||
float* first, float* second) {
|
||||
assert(in && in_length > 0 && first && second);
|
||||
void MovingMoments::CalculateMoments(const float* in,
|
||||
size_t in_length,
|
||||
float* first,
|
||||
float* second) {
|
||||
RTC_DCHECK(in);
|
||||
RTC_DCHECK_GT(in_length, 0);
|
||||
RTC_DCHECK(first);
|
||||
RTC_DCHECK(second);
|
||||
|
||||
for (size_t i = 0; i < in_length; ++i) {
|
||||
const float old_value = queue_.front();
|
||||
@ -42,7 +43,7 @@ void MovingMoments::CalculateMoments(const float* in, size_t in_length,
|
||||
sum_ += in[i] - old_value;
|
||||
sum_of_squares_ += in[i] * in[i] - old_value * old_value;
|
||||
first[i] = sum_ / length_;
|
||||
second[i] = sum_of_squares_ / length_;
|
||||
second[i] = std::max(0.f, sum_of_squares_ / length_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Calculates the first and second moments for each value of a buffer taking
|
||||
@ -33,8 +33,10 @@ class MovingMoments {
|
||||
|
||||
// Calculates the new values using |in|. Results will be in the out buffers.
|
||||
// |first| and |second| must be allocated with at least |in_length|.
|
||||
void CalculateMoments(const float* in, size_t in_length,
|
||||
float* first, float* second);
|
||||
void CalculateMoments(const float* in,
|
||||
size_t in_length,
|
||||
float* first,
|
||||
float* second);
|
||||
|
||||
private:
|
||||
size_t length_;
|
||||
@ -48,5 +50,4 @@ class MovingMoments {
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
|
@ -8,17 +8,20 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
#include "modules/audio_processing/transient/transient_detector.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/common.h"
|
||||
#include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h"
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "modules/audio_processing/transient/common.h"
|
||||
#include "modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h"
|
||||
#include "modules/audio_processing/transient/moving_moments.h"
|
||||
#include "modules/audio_processing/transient/wpd_node.h"
|
||||
#include "modules/audio_processing/transient/wpd_tree.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -34,10 +37,10 @@ TransientDetector::TransientDetector(int sample_rate_hz)
|
||||
chunks_at_startup_left_to_delete_(kChunksAtStartupLeftToDelete),
|
||||
reference_energy_(1.f),
|
||||
using_reference_(false) {
|
||||
assert(sample_rate_hz == ts::kSampleRate8kHz ||
|
||||
sample_rate_hz == ts::kSampleRate16kHz ||
|
||||
sample_rate_hz == ts::kSampleRate32kHz ||
|
||||
sample_rate_hz == ts::kSampleRate48kHz);
|
||||
RTC_DCHECK(sample_rate_hz == ts::kSampleRate8kHz ||
|
||||
sample_rate_hz == ts::kSampleRate16kHz ||
|
||||
sample_rate_hz == ts::kSampleRate32kHz ||
|
||||
sample_rate_hz == ts::kSampleRate48kHz);
|
||||
int samples_per_transient = sample_rate_hz * kTransientLengthMs / 1000;
|
||||
// Adjustment to avoid data loss while downsampling, making
|
||||
// |samples_per_chunk_| and |samples_per_transient| always divisible by
|
||||
@ -49,8 +52,7 @@ TransientDetector::TransientDetector(int sample_rate_hz)
|
||||
wpd_tree_.reset(new WPDTree(samples_per_chunk_,
|
||||
kDaubechies8HighPassCoefficients,
|
||||
kDaubechies8LowPassCoefficients,
|
||||
kDaubechies8CoefficientsLength,
|
||||
kLevels));
|
||||
kDaubechies8CoefficientsLength, kLevels));
|
||||
for (size_t i = 0; i < kLeaves; ++i) {
|
||||
moving_moments_[i].reset(
|
||||
new MovingMoments(samples_per_transient / kLeaves));
|
||||
@ -70,7 +72,8 @@ float TransientDetector::Detect(const float* data,
|
||||
size_t data_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length) {
|
||||
assert(data && data_length == samples_per_chunk_);
|
||||
RTC_DCHECK(data);
|
||||
RTC_DCHECK_EQ(samples_per_chunk_, data_length);
|
||||
|
||||
// TODO(aluebs): Check if these errors can logically happen and if not assert
|
||||
// on them.
|
||||
@ -83,8 +86,7 @@ float TransientDetector::Detect(const float* data,
|
||||
for (size_t i = 0; i < kLeaves; ++i) {
|
||||
WPDNode* leaf = wpd_tree_->NodeAt(kLevels, i);
|
||||
|
||||
moving_moments_[i]->CalculateMoments(leaf->data(),
|
||||
tree_leaves_data_length_,
|
||||
moving_moments_[i]->CalculateMoments(leaf->data(), tree_leaves_data_length_,
|
||||
first_moments_.get(),
|
||||
second_moments_.get());
|
||||
|
||||
@ -124,8 +126,9 @@ float TransientDetector::Detect(const float* data,
|
||||
const float kVerticalScaling = 0.5f;
|
||||
const float kVerticalShift = 1.f;
|
||||
|
||||
result = (cos(result * horizontal_scaling + kHorizontalShift)
|
||||
+ kVerticalShift) * kVerticalScaling;
|
||||
result = (std::cos(result * horizontal_scaling + kHorizontalShift) +
|
||||
kVerticalShift) *
|
||||
kVerticalScaling;
|
||||
result *= result;
|
||||
}
|
||||
|
||||
@ -158,10 +161,10 @@ float TransientDetector::ReferenceDetectionValue(const float* data,
|
||||
using_reference_ = false;
|
||||
return 1.f;
|
||||
}
|
||||
assert(reference_energy_ != 0);
|
||||
float result = 1.f / (1.f + exp(kReferenceNonLinearity *
|
||||
(kEnergyRatioThreshold -
|
||||
reference_energy / reference_energy_)));
|
||||
RTC_DCHECK_NE(0, reference_energy_);
|
||||
float result = 1.f / (1.f + std::exp(kReferenceNonLinearity *
|
||||
(kEnergyRatioThreshold -
|
||||
reference_energy / reference_energy_)));
|
||||
reference_energy_ =
|
||||
kMemory * reference_energy_ + (1.f - kMemory) * reference_energy;
|
||||
|
||||
|
@ -8,14 +8,16 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
#include "modules/audio_processing/transient/moving_moments.h"
|
||||
#include "modules/audio_processing/transient/wpd_tree.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -55,14 +57,14 @@ class TransientDetector {
|
||||
|
||||
size_t samples_per_chunk_;
|
||||
|
||||
rtc::scoped_ptr<WPDTree> wpd_tree_;
|
||||
std::unique_ptr<WPDTree> wpd_tree_;
|
||||
size_t tree_leaves_data_length_;
|
||||
|
||||
// A MovingMoments object is needed for each leaf in the WPD tree.
|
||||
rtc::scoped_ptr<MovingMoments> moving_moments_[kLeaves];
|
||||
std::unique_ptr<MovingMoments> moving_moments_[kLeaves];
|
||||
|
||||
rtc::scoped_ptr<float[]> first_moments_;
|
||||
rtc::scoped_ptr<float[]> second_moments_;
|
||||
std::unique_ptr<float[]> first_moments_;
|
||||
std::unique_ptr<float[]> second_moments_;
|
||||
|
||||
// Stores the last calculated moments from the previous detection.
|
||||
float last_first_moment_[kLeaves];
|
||||
@ -84,4 +86,4 @@ class TransientDetector {
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2020 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
|
||||
@ -8,30 +8,24 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#ifndef WEBRTC_AUDIO_PROCESSING_ONLY_BUILD
|
||||
#include "webrtc/test/testsupport/gtest_prod_util.h"
|
||||
#endif
|
||||
#include "webrtc/typedefs.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class TransientDetector;
|
||||
|
||||
// Detects transients in an audio stream and suppress them using a simple
|
||||
// restoration algorithm that attenuates unexpected spikes in the spectrum.
|
||||
class TransientSuppressor {
|
||||
public:
|
||||
TransientSuppressor();
|
||||
~TransientSuppressor();
|
||||
virtual ~TransientSuppressor() {}
|
||||
|
||||
int Initialize(int sample_rate_hz, int detector_rate_hz, int num_channels);
|
||||
virtual int Initialize(int sample_rate_hz,
|
||||
int detector_rate_hz,
|
||||
int num_channels) = 0;
|
||||
|
||||
// Processes a |data| chunk, and returns it with keystrokes suppressed from
|
||||
// it. The float format is assumed to be int16 ranged. If there are more than
|
||||
@ -50,75 +44,17 @@ class TransientSuppressor {
|
||||
// always be set to 1.
|
||||
// |key_pressed| determines if a key was pressed on this audio chunk.
|
||||
// Returns 0 on success and -1 otherwise.
|
||||
int Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed);
|
||||
|
||||
private:
|
||||
#ifndef WEBRTC_AUDIO_PROCESSING_ONLY_BUILD
|
||||
FRIEND_TEST_ALL_PREFIXES(TransientSuppressorTest,
|
||||
TypingDetectionLogicWorksAsExpectedForMono);
|
||||
#endif
|
||||
void Suppress(float* in_ptr, float* spectral_mean, float* out_ptr);
|
||||
|
||||
void UpdateKeypress(bool key_pressed);
|
||||
void UpdateRestoration(float voice_probability);
|
||||
|
||||
void UpdateBuffers(float* data);
|
||||
|
||||
void HardRestoration(float* spectral_mean);
|
||||
void SoftRestoration(float* spectral_mean);
|
||||
|
||||
rtc::scoped_ptr<TransientDetector> detector_;
|
||||
|
||||
size_t data_length_;
|
||||
size_t detection_length_;
|
||||
size_t analysis_length_;
|
||||
size_t buffer_delay_;
|
||||
size_t complex_analysis_length_;
|
||||
int num_channels_;
|
||||
// Input buffer where the original samples are stored.
|
||||
rtc::scoped_ptr<float[]> in_buffer_;
|
||||
rtc::scoped_ptr<float[]> detection_buffer_;
|
||||
// Output buffer where the restored samples are stored.
|
||||
rtc::scoped_ptr<float[]> out_buffer_;
|
||||
|
||||
// Arrays for fft.
|
||||
rtc::scoped_ptr<size_t[]> ip_;
|
||||
rtc::scoped_ptr<float[]> wfft_;
|
||||
|
||||
rtc::scoped_ptr<float[]> spectral_mean_;
|
||||
|
||||
// Stores the data for the fft.
|
||||
rtc::scoped_ptr<float[]> fft_buffer_;
|
||||
|
||||
rtc::scoped_ptr<float[]> magnitudes_;
|
||||
|
||||
const float* window_;
|
||||
|
||||
rtc::scoped_ptr<float[]> mean_factor_;
|
||||
|
||||
float detector_smoothed_;
|
||||
|
||||
int keypress_counter_;
|
||||
int chunks_since_keypress_;
|
||||
bool detection_enabled_;
|
||||
bool suppression_enabled_;
|
||||
|
||||
bool use_hard_restoration_;
|
||||
int chunks_since_voice_change_;
|
||||
|
||||
uint32_t seed_;
|
||||
|
||||
bool using_reference_;
|
||||
virtual int Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed) = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
|
@ -8,24 +8,26 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "modules/audio_processing/transient/transient_suppressor_impl.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <deque>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/fft4g.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "webrtc/modules/audio_processing/transient/common.h"
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
#include "webrtc/modules/audio_processing/ns/windows_private.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "common_audio/third_party/ooura/fft_size_256/fft4g.h"
|
||||
#include "modules/audio_processing/transient/common.h"
|
||||
#include "modules/audio_processing/transient/transient_detector.h"
|
||||
#include "modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "modules/audio_processing/transient/windows_private.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -44,7 +46,7 @@ float ComplexMagnitude(float a, float b) {
|
||||
|
||||
} // namespace
|
||||
|
||||
TransientSuppressor::TransientSuppressor()
|
||||
TransientSuppressorImpl::TransientSuppressorImpl()
|
||||
: data_length_(0),
|
||||
detection_length_(0),
|
||||
analysis_length_(0),
|
||||
@ -60,14 +62,13 @@ TransientSuppressor::TransientSuppressor()
|
||||
use_hard_restoration_(false),
|
||||
chunks_since_voice_change_(0),
|
||||
seed_(182),
|
||||
using_reference_(false) {
|
||||
}
|
||||
using_reference_(false) {}
|
||||
|
||||
TransientSuppressor::~TransientSuppressor() {}
|
||||
TransientSuppressorImpl::~TransientSuppressorImpl() {}
|
||||
|
||||
int TransientSuppressor::Initialize(int sample_rate_hz,
|
||||
int detection_rate_hz,
|
||||
int num_channels) {
|
||||
int TransientSuppressorImpl::Initialize(int sample_rate_hz,
|
||||
int detection_rate_hz,
|
||||
int num_channels) {
|
||||
switch (sample_rate_hz) {
|
||||
case ts::kSampleRate8kHz:
|
||||
analysis_length_ = 128u;
|
||||
@ -101,26 +102,23 @@ int TransientSuppressor::Initialize(int sample_rate_hz,
|
||||
detector_.reset(new TransientDetector(detection_rate_hz));
|
||||
data_length_ = sample_rate_hz * ts::kChunkSizeMs / 1000;
|
||||
if (data_length_ > analysis_length_) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
buffer_delay_ = analysis_length_ - data_length_;
|
||||
|
||||
complex_analysis_length_ = analysis_length_ / 2 + 1;
|
||||
assert(complex_analysis_length_ >= kMaxVoiceBin);
|
||||
RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin);
|
||||
num_channels_ = num_channels;
|
||||
in_buffer_.reset(new float[analysis_length_ * num_channels_]);
|
||||
memset(in_buffer_.get(),
|
||||
0,
|
||||
memset(in_buffer_.get(), 0,
|
||||
analysis_length_ * num_channels_ * sizeof(in_buffer_[0]));
|
||||
detection_length_ = detection_rate_hz * ts::kChunkSizeMs / 1000;
|
||||
detection_buffer_.reset(new float[detection_length_]);
|
||||
memset(detection_buffer_.get(),
|
||||
0,
|
||||
memset(detection_buffer_.get(), 0,
|
||||
detection_length_ * sizeof(detection_buffer_[0]));
|
||||
out_buffer_.reset(new float[analysis_length_ * num_channels_]);
|
||||
memset(out_buffer_.get(),
|
||||
0,
|
||||
memset(out_buffer_.get(), 0,
|
||||
analysis_length_ * num_channels_ * sizeof(out_buffer_[0]));
|
||||
// ip[0] must be zero to trigger initialization using rdft().
|
||||
size_t ip_length = 2 + sqrtf(analysis_length_);
|
||||
@ -129,14 +127,12 @@ int TransientSuppressor::Initialize(int sample_rate_hz,
|
||||
wfft_.reset(new float[complex_analysis_length_ - 1]);
|
||||
memset(wfft_.get(), 0, (complex_analysis_length_ - 1) * sizeof(wfft_[0]));
|
||||
spectral_mean_.reset(new float[complex_analysis_length_ * num_channels_]);
|
||||
memset(spectral_mean_.get(),
|
||||
0,
|
||||
memset(spectral_mean_.get(), 0,
|
||||
complex_analysis_length_ * num_channels_ * sizeof(spectral_mean_[0]));
|
||||
fft_buffer_.reset(new float[analysis_length_ + 2]);
|
||||
memset(fft_buffer_.get(), 0, (analysis_length_ + 2) * sizeof(fft_buffer_[0]));
|
||||
magnitudes_.reset(new float[complex_analysis_length_]);
|
||||
memset(magnitudes_.get(),
|
||||
0,
|
||||
memset(magnitudes_.get(), 0,
|
||||
complex_analysis_length_ * sizeof(magnitudes_[0]));
|
||||
mean_factor_.reset(new float[complex_analysis_length_]);
|
||||
|
||||
@ -146,9 +142,9 @@ int TransientSuppressor::Initialize(int sample_rate_hz,
|
||||
for (size_t i = 0; i < complex_analysis_length_; ++i) {
|
||||
mean_factor_[i] =
|
||||
kFactorHeight /
|
||||
(1.f + exp(kLowSlope * static_cast<int>(i - kMinVoiceBin))) +
|
||||
(1.f + std::exp(kLowSlope * static_cast<int>(i - kMinVoiceBin))) +
|
||||
kFactorHeight /
|
||||
(1.f + exp(kHighSlope * static_cast<int>(kMaxVoiceBin - i)));
|
||||
(1.f + std::exp(kHighSlope * static_cast<int>(kMaxVoiceBin - i)));
|
||||
}
|
||||
detector_smoothed_ = 0.f;
|
||||
keypress_counter_ = 0;
|
||||
@ -162,15 +158,15 @@ int TransientSuppressor::Initialize(int sample_rate_hz,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TransientSuppressor::Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed) {
|
||||
int TransientSuppressorImpl::Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed) {
|
||||
if (!data || data_length != data_length_ || num_channels != num_channels_ ||
|
||||
detection_length != detection_length_ || voice_probability < 0 ||
|
||||
voice_probability > 1) {
|
||||
@ -190,8 +186,8 @@ int TransientSuppressor::Suppress(float* data,
|
||||
detection_data = &in_buffer_[buffer_delay_];
|
||||
}
|
||||
|
||||
float detector_result = detector_->Detect(
|
||||
detection_data, detection_length, reference_data, reference_length);
|
||||
float detector_result = detector_->Detect(detection_data, detection_length,
|
||||
reference_data, reference_length);
|
||||
if (detector_result < 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -229,9 +225,9 @@ int TransientSuppressor::Suppress(float* data,
|
||||
// This should only be called when detection is enabled. UpdateBuffers() must
|
||||
// have been called. At return, |out_buffer_| will be filled with the
|
||||
// processed output.
|
||||
void TransientSuppressor::Suppress(float* in_ptr,
|
||||
float* spectral_mean,
|
||||
float* out_ptr) {
|
||||
void TransientSuppressorImpl::Suppress(float* in_ptr,
|
||||
float* spectral_mean,
|
||||
float* out_ptr) {
|
||||
// Go to frequency domain.
|
||||
for (size_t i = 0; i < analysis_length_; ++i) {
|
||||
// TODO(aluebs): Rename windows
|
||||
@ -247,8 +243,8 @@ void TransientSuppressor::Suppress(float* in_ptr,
|
||||
fft_buffer_[1] = 0.f;
|
||||
|
||||
for (size_t i = 0; i < complex_analysis_length_; ++i) {
|
||||
magnitudes_[i] = ComplexMagnitude(fft_buffer_[i * 2],
|
||||
fft_buffer_[i * 2 + 1]);
|
||||
magnitudes_[i] =
|
||||
ComplexMagnitude(fft_buffer_[i * 2], fft_buffer_[i * 2 + 1]);
|
||||
}
|
||||
// Restore audio if necessary.
|
||||
if (suppression_enabled_) {
|
||||
@ -269,11 +265,7 @@ void TransientSuppressor::Suppress(float* in_ptr,
|
||||
// Put R[n/2] back in fft_buffer_[1].
|
||||
fft_buffer_[1] = fft_buffer_[analysis_length_];
|
||||
|
||||
WebRtc_rdft(analysis_length_,
|
||||
-1,
|
||||
fft_buffer_.get(),
|
||||
ip_.get(),
|
||||
wfft_.get());
|
||||
WebRtc_rdft(analysis_length_, -1, fft_buffer_.get(), ip_.get(), wfft_.get());
|
||||
const float fft_scaling = 2.f / analysis_length_;
|
||||
|
||||
for (size_t i = 0; i < analysis_length_; ++i) {
|
||||
@ -281,7 +273,7 @@ void TransientSuppressor::Suppress(float* in_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
void TransientSuppressor::UpdateKeypress(bool key_pressed) {
|
||||
void TransientSuppressorImpl::UpdateKeypress(bool key_pressed) {
|
||||
const int kKeypressPenalty = 1000 / ts::kChunkSizeMs;
|
||||
const int kIsTypingThreshold = 1000 / ts::kChunkSizeMs;
|
||||
const int kChunksUntilNotTyping = 4000 / ts::kChunkSizeMs; // 4 seconds.
|
||||
@ -295,16 +287,15 @@ void TransientSuppressor::UpdateKeypress(bool key_pressed) {
|
||||
|
||||
if (keypress_counter_ > kIsTypingThreshold) {
|
||||
if (!suppression_enabled_) {
|
||||
LOG(LS_INFO) << "[ts] Transient suppression is now enabled.";
|
||||
RTC_LOG(LS_INFO) << "[ts] Transient suppression is now enabled.";
|
||||
}
|
||||
suppression_enabled_ = true;
|
||||
keypress_counter_ = 0;
|
||||
}
|
||||
|
||||
if (detection_enabled_ &&
|
||||
++chunks_since_keypress_ > kChunksUntilNotTyping) {
|
||||
if (detection_enabled_ && ++chunks_since_keypress_ > kChunksUntilNotTyping) {
|
||||
if (suppression_enabled_) {
|
||||
LOG(LS_INFO) << "[ts] Transient suppression is now disabled.";
|
||||
RTC_LOG(LS_INFO) << "[ts] Transient suppression is now disabled.";
|
||||
}
|
||||
detection_enabled_ = false;
|
||||
suppression_enabled_ = false;
|
||||
@ -312,7 +303,7 @@ void TransientSuppressor::UpdateKeypress(bool key_pressed) {
|
||||
}
|
||||
}
|
||||
|
||||
void TransientSuppressor::UpdateRestoration(float voice_probability) {
|
||||
void TransientSuppressorImpl::UpdateRestoration(float voice_probability) {
|
||||
const int kHardRestorationOffsetDelay = 3;
|
||||
const int kHardRestorationOnsetDelay = 80;
|
||||
|
||||
@ -335,28 +326,24 @@ void TransientSuppressor::UpdateRestoration(float voice_probability) {
|
||||
|
||||
// Shift buffers to make way for new data. Must be called after
|
||||
// |detection_enabled_| is updated by UpdateKeypress().
|
||||
void TransientSuppressor::UpdateBuffers(float* data) {
|
||||
void TransientSuppressorImpl::UpdateBuffers(float* data) {
|
||||
// TODO(aluebs): Change to ring buffer.
|
||||
memmove(in_buffer_.get(),
|
||||
&in_buffer_[data_length_],
|
||||
memmove(in_buffer_.get(), &in_buffer_[data_length_],
|
||||
(buffer_delay_ + (num_channels_ - 1) * analysis_length_) *
|
||||
sizeof(in_buffer_[0]));
|
||||
// Copy new chunk to buffer.
|
||||
for (int i = 0; i < num_channels_; ++i) {
|
||||
memcpy(&in_buffer_[buffer_delay_ + i * analysis_length_],
|
||||
&data[i * data_length_],
|
||||
data_length_ * sizeof(*data));
|
||||
&data[i * data_length_], data_length_ * sizeof(*data));
|
||||
}
|
||||
if (detection_enabled_) {
|
||||
// Shift previous chunk in out buffer.
|
||||
memmove(out_buffer_.get(),
|
||||
&out_buffer_[data_length_],
|
||||
memmove(out_buffer_.get(), &out_buffer_[data_length_],
|
||||
(buffer_delay_ + (num_channels_ - 1) * analysis_length_) *
|
||||
sizeof(out_buffer_[0]));
|
||||
// Initialize new chunk in out buffer.
|
||||
for (int i = 0; i < num_channels_; ++i) {
|
||||
memset(&out_buffer_[buffer_delay_ + i * analysis_length_],
|
||||
0,
|
||||
memset(&out_buffer_[buffer_delay_ + i * analysis_length_], 0,
|
||||
data_length_ * sizeof(out_buffer_[0]));
|
||||
}
|
||||
}
|
||||
@ -366,16 +353,16 @@ void TransientSuppressor::UpdateBuffers(float* data) {
|
||||
// Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds
|
||||
// the spectral mean. The attenuation depends on |detector_smoothed_|.
|
||||
// If a restoration takes place, the |magnitudes_| are updated to the new value.
|
||||
void TransientSuppressor::HardRestoration(float* spectral_mean) {
|
||||
void TransientSuppressorImpl::HardRestoration(float* spectral_mean) {
|
||||
const float detector_result =
|
||||
1.f - pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f);
|
||||
1.f - std::pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f);
|
||||
// To restore, we get the peaks in the spectrum. If higher than the previous
|
||||
// spectral mean we adjust them.
|
||||
for (size_t i = 0; i < complex_analysis_length_; ++i) {
|
||||
if (magnitudes_[i] > spectral_mean[i] && magnitudes_[i] > 0) {
|
||||
// RandU() generates values on [0, int16::max()]
|
||||
const float phase = 2 * ts::kPi * WebRtcSpl_RandU(&seed_) /
|
||||
std::numeric_limits<int16_t>::max();
|
||||
std::numeric_limits<int16_t>::max();
|
||||
const float scaled_mean = detector_result * spectral_mean[i];
|
||||
|
||||
fft_buffer_[i * 2] = (1 - detector_result) * fft_buffer_[i * 2] +
|
||||
@ -393,7 +380,7 @@ void TransientSuppressor::HardRestoration(float* spectral_mean) {
|
||||
// the spectral mean and that is lower than some function of the current block
|
||||
// frequency mean. The attenuation depends on |detector_smoothed_|.
|
||||
// If a restoration takes place, the |magnitudes_| are updated to the new value.
|
||||
void TransientSuppressor::SoftRestoration(float* spectral_mean) {
|
||||
void TransientSuppressorImpl::SoftRestoration(float* spectral_mean) {
|
||||
// Get the spectral magnitude mean of the current block.
|
||||
float block_frequency_mean = 0;
|
||||
for (size_t i = kMinVoiceBin; i < kMaxVoiceBin; ++i) {
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2013 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_TRANSIENT_TRANSIENT_SUPPRESSOR_IMPL_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_IMPL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "rtc_base/gtest_prod_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class TransientDetector;
|
||||
|
||||
// Detects transients in an audio stream and suppress them using a simple
|
||||
// restoration algorithm that attenuates unexpected spikes in the spectrum.
|
||||
class TransientSuppressorImpl : public TransientSuppressor {
|
||||
public:
|
||||
TransientSuppressorImpl();
|
||||
~TransientSuppressorImpl() override;
|
||||
|
||||
int Initialize(int sample_rate_hz,
|
||||
int detector_rate_hz,
|
||||
int num_channels) override;
|
||||
|
||||
// Processes a |data| chunk, and returns it with keystrokes suppressed from
|
||||
// it. The float format is assumed to be int16 ranged. If there are more than
|
||||
// one channel, the chunks are concatenated one after the other in |data|.
|
||||
// |data_length| must be equal to |data_length_|.
|
||||
// |num_channels| must be equal to |num_channels_|.
|
||||
// A sub-band, ideally the higher, can be used as |detection_data|. If it is
|
||||
// NULL, |data| is used for the detection too. The |detection_data| is always
|
||||
// assumed mono.
|
||||
// If a reference signal (e.g. keyboard microphone) is available, it can be
|
||||
// passed in as |reference_data|. It is assumed mono and must have the same
|
||||
// length as |data|. NULL is accepted if unavailable.
|
||||
// This suppressor performs better if voice information is available.
|
||||
// |voice_probability| is the probability of voice being present in this chunk
|
||||
// of audio. If voice information is not available, |voice_probability| must
|
||||
// always be set to 1.
|
||||
// |key_pressed| determines if a key was pressed on this audio chunk.
|
||||
// Returns 0 on success and -1 otherwise.
|
||||
int Suppress(float* data,
|
||||
size_t data_length,
|
||||
int num_channels,
|
||||
const float* detection_data,
|
||||
size_t detection_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length,
|
||||
float voice_probability,
|
||||
bool key_pressed) override;
|
||||
|
||||
private:
|
||||
FRIEND_TEST_ALL_PREFIXES(TransientSuppressorImplTest,
|
||||
TypingDetectionLogicWorksAsExpectedForMono);
|
||||
void Suppress(float* in_ptr, float* spectral_mean, float* out_ptr);
|
||||
|
||||
void UpdateKeypress(bool key_pressed);
|
||||
void UpdateRestoration(float voice_probability);
|
||||
|
||||
void UpdateBuffers(float* data);
|
||||
|
||||
void HardRestoration(float* spectral_mean);
|
||||
void SoftRestoration(float* spectral_mean);
|
||||
|
||||
std::unique_ptr<TransientDetector> detector_;
|
||||
|
||||
size_t data_length_;
|
||||
size_t detection_length_;
|
||||
size_t analysis_length_;
|
||||
size_t buffer_delay_;
|
||||
size_t complex_analysis_length_;
|
||||
int num_channels_;
|
||||
// Input buffer where the original samples are stored.
|
||||
std::unique_ptr<float[]> in_buffer_;
|
||||
std::unique_ptr<float[]> detection_buffer_;
|
||||
// Output buffer where the restored samples are stored.
|
||||
std::unique_ptr<float[]> out_buffer_;
|
||||
|
||||
// Arrays for fft.
|
||||
std::unique_ptr<size_t[]> ip_;
|
||||
std::unique_ptr<float[]> wfft_;
|
||||
|
||||
std::unique_ptr<float[]> spectral_mean_;
|
||||
|
||||
// Stores the data for the fft.
|
||||
std::unique_ptr<float[]> fft_buffer_;
|
||||
|
||||
std::unique_ptr<float[]> magnitudes_;
|
||||
|
||||
const float* window_;
|
||||
|
||||
std::unique_ptr<float[]> mean_factor_;
|
||||
|
||||
float detector_smoothed_;
|
||||
|
||||
int keypress_counter_;
|
||||
int chunks_since_keypress_;
|
||||
bool detection_enabled_;
|
||||
bool suppression_enabled_;
|
||||
|
||||
bool use_hard_restoration_;
|
||||
int chunks_since_voice_change_;
|
||||
|
||||
uint32_t seed_;
|
||||
|
||||
bool using_reference_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_IMPL_H_
|
557
webrtc/modules/audio_processing/transient/windows_private.h
Normal file
557
webrtc/modules/audio_processing/transient/windows_private.h
Normal file
@ -0,0 +1,557 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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_TRANSIENT_WINDOWS_PRIVATE_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_WINDOWS_PRIVATE_H_
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Hanning window for 4ms 16kHz
|
||||
static const float kHanning64w128[128] = {
|
||||
0.00000000000000f, 0.02454122852291f, 0.04906767432742f, 0.07356456359967f,
|
||||
0.09801714032956f, 0.12241067519922f, 0.14673047445536f, 0.17096188876030f,
|
||||
0.19509032201613f, 0.21910124015687f, 0.24298017990326f, 0.26671275747490f,
|
||||
0.29028467725446f, 0.31368174039889f, 0.33688985339222f, 0.35989503653499f,
|
||||
0.38268343236509f, 0.40524131400499f, 0.42755509343028f, 0.44961132965461f,
|
||||
0.47139673682600f, 0.49289819222978f, 0.51410274419322f, 0.53499761988710f,
|
||||
0.55557023301960f, 0.57580819141785f, 0.59569930449243f, 0.61523159058063f,
|
||||
0.63439328416365f, 0.65317284295378f, 0.67155895484702f, 0.68954054473707f,
|
||||
0.70710678118655f, 0.72424708295147f, 0.74095112535496f, 0.75720884650648f,
|
||||
0.77301045336274f, 0.78834642762661f, 0.80320753148064f, 0.81758481315158f,
|
||||
0.83146961230255f, 0.84485356524971f, 0.85772861000027f, 0.87008699110871f,
|
||||
0.88192126434835f, 0.89322430119552f, 0.90398929312344f, 0.91420975570353f,
|
||||
0.92387953251129f, 0.93299279883474f, 0.94154406518302f, 0.94952818059304f,
|
||||
0.95694033573221f, 0.96377606579544f, 0.97003125319454f, 0.97570213003853f,
|
||||
0.98078528040323f, 0.98527764238894f, 0.98917650996478f, 0.99247953459871f,
|
||||
0.99518472667220f, 0.99729045667869f, 0.99879545620517f, 0.99969881869620f,
|
||||
1.00000000000000f, 0.99969881869620f, 0.99879545620517f, 0.99729045667869f,
|
||||
0.99518472667220f, 0.99247953459871f, 0.98917650996478f, 0.98527764238894f,
|
||||
0.98078528040323f, 0.97570213003853f, 0.97003125319454f, 0.96377606579544f,
|
||||
0.95694033573221f, 0.94952818059304f, 0.94154406518302f, 0.93299279883474f,
|
||||
0.92387953251129f, 0.91420975570353f, 0.90398929312344f, 0.89322430119552f,
|
||||
0.88192126434835f, 0.87008699110871f, 0.85772861000027f, 0.84485356524971f,
|
||||
0.83146961230255f, 0.81758481315158f, 0.80320753148064f, 0.78834642762661f,
|
||||
0.77301045336274f, 0.75720884650648f, 0.74095112535496f, 0.72424708295147f,
|
||||
0.70710678118655f, 0.68954054473707f, 0.67155895484702f, 0.65317284295378f,
|
||||
0.63439328416365f, 0.61523159058063f, 0.59569930449243f, 0.57580819141785f,
|
||||
0.55557023301960f, 0.53499761988710f, 0.51410274419322f, 0.49289819222978f,
|
||||
0.47139673682600f, 0.44961132965461f, 0.42755509343028f, 0.40524131400499f,
|
||||
0.38268343236509f, 0.35989503653499f, 0.33688985339222f, 0.31368174039889f,
|
||||
0.29028467725446f, 0.26671275747490f, 0.24298017990326f, 0.21910124015687f,
|
||||
0.19509032201613f, 0.17096188876030f, 0.14673047445536f, 0.12241067519922f,
|
||||
0.09801714032956f, 0.07356456359967f, 0.04906767432742f, 0.02454122852291f};
|
||||
|
||||
// hybrib Hanning & flat window
|
||||
static const float kBlocks80w128[128] = {
|
||||
0.00000000f, 0.03271908f, 0.06540313f, 0.09801714f, 0.13052619f,
|
||||
0.16289547f, 0.19509032f, 0.22707626f, 0.25881905f, 0.29028468f,
|
||||
0.32143947f, 0.35225005f, 0.38268343f, 0.41270703f, 0.44228869f,
|
||||
0.47139674f, 0.50000000f, 0.52806785f, 0.55557023f, 0.58247770f,
|
||||
0.60876143f, 0.63439328f, 0.65934582f, 0.68359230f, 0.70710678f,
|
||||
0.72986407f, 0.75183981f, 0.77301045f, 0.79335334f, 0.81284668f,
|
||||
0.83146961f, 0.84920218f, 0.86602540f, 0.88192126f, 0.89687274f,
|
||||
0.91086382f, 0.92387953f, 0.93590593f, 0.94693013f, 0.95694034f,
|
||||
0.96592583f, 0.97387698f, 0.98078528f, 0.98664333f, 0.99144486f,
|
||||
0.99518473f, 0.99785892f, 0.99946459f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 0.99946459f, 0.99785892f, 0.99518473f, 0.99144486f,
|
||||
0.98664333f, 0.98078528f, 0.97387698f, 0.96592583f, 0.95694034f,
|
||||
0.94693013f, 0.93590593f, 0.92387953f, 0.91086382f, 0.89687274f,
|
||||
0.88192126f, 0.86602540f, 0.84920218f, 0.83146961f, 0.81284668f,
|
||||
0.79335334f, 0.77301045f, 0.75183981f, 0.72986407f, 0.70710678f,
|
||||
0.68359230f, 0.65934582f, 0.63439328f, 0.60876143f, 0.58247770f,
|
||||
0.55557023f, 0.52806785f, 0.50000000f, 0.47139674f, 0.44228869f,
|
||||
0.41270703f, 0.38268343f, 0.35225005f, 0.32143947f, 0.29028468f,
|
||||
0.25881905f, 0.22707626f, 0.19509032f, 0.16289547f, 0.13052619f,
|
||||
0.09801714f, 0.06540313f, 0.03271908f};
|
||||
|
||||
// hybrib Hanning & flat window
|
||||
static const float kBlocks160w256[256] = {
|
||||
0.00000000f, 0.01636173f, 0.03271908f, 0.04906767f, 0.06540313f,
|
||||
0.08172107f, 0.09801714f, 0.11428696f, 0.13052619f, 0.14673047f,
|
||||
0.16289547f, 0.17901686f, 0.19509032f, 0.21111155f, 0.22707626f,
|
||||
0.24298018f, 0.25881905f, 0.27458862f, 0.29028468f, 0.30590302f,
|
||||
0.32143947f, 0.33688985f, 0.35225005f, 0.36751594f, 0.38268343f,
|
||||
0.39774847f, 0.41270703f, 0.42755509f, 0.44228869f, 0.45690388f,
|
||||
0.47139674f, 0.48576339f, 0.50000000f, 0.51410274f, 0.52806785f,
|
||||
0.54189158f, 0.55557023f, 0.56910015f, 0.58247770f, 0.59569930f,
|
||||
0.60876143f, 0.62166057f, 0.63439328f, 0.64695615f, 0.65934582f,
|
||||
0.67155895f, 0.68359230f, 0.69544264f, 0.70710678f, 0.71858162f,
|
||||
0.72986407f, 0.74095113f, 0.75183981f, 0.76252720f, 0.77301045f,
|
||||
0.78328675f, 0.79335334f, 0.80320753f, 0.81284668f, 0.82226822f,
|
||||
0.83146961f, 0.84044840f, 0.84920218f, 0.85772861f, 0.86602540f,
|
||||
0.87409034f, 0.88192126f, 0.88951608f, 0.89687274f, 0.90398929f,
|
||||
0.91086382f, 0.91749450f, 0.92387953f, 0.93001722f, 0.93590593f,
|
||||
0.94154407f, 0.94693013f, 0.95206268f, 0.95694034f, 0.96156180f,
|
||||
0.96592583f, 0.97003125f, 0.97387698f, 0.97746197f, 0.98078528f,
|
||||
0.98384601f, 0.98664333f, 0.98917651f, 0.99144486f, 0.99344778f,
|
||||
0.99518473f, 0.99665524f, 0.99785892f, 0.99879546f, 0.99946459f,
|
||||
0.99986614f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 0.99986614f, 0.99946459f, 0.99879546f, 0.99785892f,
|
||||
0.99665524f, 0.99518473f, 0.99344778f, 0.99144486f, 0.98917651f,
|
||||
0.98664333f, 0.98384601f, 0.98078528f, 0.97746197f, 0.97387698f,
|
||||
0.97003125f, 0.96592583f, 0.96156180f, 0.95694034f, 0.95206268f,
|
||||
0.94693013f, 0.94154407f, 0.93590593f, 0.93001722f, 0.92387953f,
|
||||
0.91749450f, 0.91086382f, 0.90398929f, 0.89687274f, 0.88951608f,
|
||||
0.88192126f, 0.87409034f, 0.86602540f, 0.85772861f, 0.84920218f,
|
||||
0.84044840f, 0.83146961f, 0.82226822f, 0.81284668f, 0.80320753f,
|
||||
0.79335334f, 0.78328675f, 0.77301045f, 0.76252720f, 0.75183981f,
|
||||
0.74095113f, 0.72986407f, 0.71858162f, 0.70710678f, 0.69544264f,
|
||||
0.68359230f, 0.67155895f, 0.65934582f, 0.64695615f, 0.63439328f,
|
||||
0.62166057f, 0.60876143f, 0.59569930f, 0.58247770f, 0.56910015f,
|
||||
0.55557023f, 0.54189158f, 0.52806785f, 0.51410274f, 0.50000000f,
|
||||
0.48576339f, 0.47139674f, 0.45690388f, 0.44228869f, 0.42755509f,
|
||||
0.41270703f, 0.39774847f, 0.38268343f, 0.36751594f, 0.35225005f,
|
||||
0.33688985f, 0.32143947f, 0.30590302f, 0.29028468f, 0.27458862f,
|
||||
0.25881905f, 0.24298018f, 0.22707626f, 0.21111155f, 0.19509032f,
|
||||
0.17901686f, 0.16289547f, 0.14673047f, 0.13052619f, 0.11428696f,
|
||||
0.09801714f, 0.08172107f, 0.06540313f, 0.04906767f, 0.03271908f,
|
||||
0.01636173f};
|
||||
|
||||
// hybrib Hanning & flat window: for 20ms
|
||||
static const float kBlocks320w512[512] = {
|
||||
0.00000000f, 0.00818114f, 0.01636173f, 0.02454123f, 0.03271908f,
|
||||
0.04089475f, 0.04906767f, 0.05723732f, 0.06540313f, 0.07356456f,
|
||||
0.08172107f, 0.08987211f, 0.09801714f, 0.10615561f, 0.11428696f,
|
||||
0.12241068f, 0.13052619f, 0.13863297f, 0.14673047f, 0.15481816f,
|
||||
0.16289547f, 0.17096189f, 0.17901686f, 0.18705985f, 0.19509032f,
|
||||
0.20310773f, 0.21111155f, 0.21910124f, 0.22707626f, 0.23503609f,
|
||||
0.24298018f, 0.25090801f, 0.25881905f, 0.26671276f, 0.27458862f,
|
||||
0.28244610f, 0.29028468f, 0.29810383f, 0.30590302f, 0.31368174f,
|
||||
0.32143947f, 0.32917568f, 0.33688985f, 0.34458148f, 0.35225005f,
|
||||
0.35989504f, 0.36751594f, 0.37511224f, 0.38268343f, 0.39022901f,
|
||||
0.39774847f, 0.40524131f, 0.41270703f, 0.42014512f, 0.42755509f,
|
||||
0.43493645f, 0.44228869f, 0.44961133f, 0.45690388f, 0.46416584f,
|
||||
0.47139674f, 0.47859608f, 0.48576339f, 0.49289819f, 0.50000000f,
|
||||
0.50706834f, 0.51410274f, 0.52110274f, 0.52806785f, 0.53499762f,
|
||||
0.54189158f, 0.54874927f, 0.55557023f, 0.56235401f, 0.56910015f,
|
||||
0.57580819f, 0.58247770f, 0.58910822f, 0.59569930f, 0.60225052f,
|
||||
0.60876143f, 0.61523159f, 0.62166057f, 0.62804795f, 0.63439328f,
|
||||
0.64069616f, 0.64695615f, 0.65317284f, 0.65934582f, 0.66547466f,
|
||||
0.67155895f, 0.67759830f, 0.68359230f, 0.68954054f, 0.69544264f,
|
||||
0.70129818f, 0.70710678f, 0.71286806f, 0.71858162f, 0.72424708f,
|
||||
0.72986407f, 0.73543221f, 0.74095113f, 0.74642045f, 0.75183981f,
|
||||
0.75720885f, 0.76252720f, 0.76779452f, 0.77301045f, 0.77817464f,
|
||||
0.78328675f, 0.78834643f, 0.79335334f, 0.79830715f, 0.80320753f,
|
||||
0.80805415f, 0.81284668f, 0.81758481f, 0.82226822f, 0.82689659f,
|
||||
0.83146961f, 0.83598698f, 0.84044840f, 0.84485357f, 0.84920218f,
|
||||
0.85349396f, 0.85772861f, 0.86190585f, 0.86602540f, 0.87008699f,
|
||||
0.87409034f, 0.87803519f, 0.88192126f, 0.88574831f, 0.88951608f,
|
||||
0.89322430f, 0.89687274f, 0.90046115f, 0.90398929f, 0.90745693f,
|
||||
0.91086382f, 0.91420976f, 0.91749450f, 0.92071783f, 0.92387953f,
|
||||
0.92697940f, 0.93001722f, 0.93299280f, 0.93590593f, 0.93875641f,
|
||||
0.94154407f, 0.94426870f, 0.94693013f, 0.94952818f, 0.95206268f,
|
||||
0.95453345f, 0.95694034f, 0.95928317f, 0.96156180f, 0.96377607f,
|
||||
0.96592583f, 0.96801094f, 0.97003125f, 0.97198664f, 0.97387698f,
|
||||
0.97570213f, 0.97746197f, 0.97915640f, 0.98078528f, 0.98234852f,
|
||||
0.98384601f, 0.98527764f, 0.98664333f, 0.98794298f, 0.98917651f,
|
||||
0.99034383f, 0.99144486f, 0.99247953f, 0.99344778f, 0.99434953f,
|
||||
0.99518473f, 0.99595331f, 0.99665524f, 0.99729046f, 0.99785892f,
|
||||
0.99836060f, 0.99879546f, 0.99916346f, 0.99946459f, 0.99969882f,
|
||||
0.99986614f, 0.99996653f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f, 1.00000000f,
|
||||
1.00000000f, 0.99996653f, 0.99986614f, 0.99969882f, 0.99946459f,
|
||||
0.99916346f, 0.99879546f, 0.99836060f, 0.99785892f, 0.99729046f,
|
||||
0.99665524f, 0.99595331f, 0.99518473f, 0.99434953f, 0.99344778f,
|
||||
0.99247953f, 0.99144486f, 0.99034383f, 0.98917651f, 0.98794298f,
|
||||
0.98664333f, 0.98527764f, 0.98384601f, 0.98234852f, 0.98078528f,
|
||||
0.97915640f, 0.97746197f, 0.97570213f, 0.97387698f, 0.97198664f,
|
||||
0.97003125f, 0.96801094f, 0.96592583f, 0.96377607f, 0.96156180f,
|
||||
0.95928317f, 0.95694034f, 0.95453345f, 0.95206268f, 0.94952818f,
|
||||
0.94693013f, 0.94426870f, 0.94154407f, 0.93875641f, 0.93590593f,
|
||||
0.93299280f, 0.93001722f, 0.92697940f, 0.92387953f, 0.92071783f,
|
||||
0.91749450f, 0.91420976f, 0.91086382f, 0.90745693f, 0.90398929f,
|
||||
0.90046115f, 0.89687274f, 0.89322430f, 0.88951608f, 0.88574831f,
|
||||
0.88192126f, 0.87803519f, 0.87409034f, 0.87008699f, 0.86602540f,
|
||||
0.86190585f, 0.85772861f, 0.85349396f, 0.84920218f, 0.84485357f,
|
||||
0.84044840f, 0.83598698f, 0.83146961f, 0.82689659f, 0.82226822f,
|
||||
0.81758481f, 0.81284668f, 0.80805415f, 0.80320753f, 0.79830715f,
|
||||
0.79335334f, 0.78834643f, 0.78328675f, 0.77817464f, 0.77301045f,
|
||||
0.76779452f, 0.76252720f, 0.75720885f, 0.75183981f, 0.74642045f,
|
||||
0.74095113f, 0.73543221f, 0.72986407f, 0.72424708f, 0.71858162f,
|
||||
0.71286806f, 0.70710678f, 0.70129818f, 0.69544264f, 0.68954054f,
|
||||
0.68359230f, 0.67759830f, 0.67155895f, 0.66547466f, 0.65934582f,
|
||||
0.65317284f, 0.64695615f, 0.64069616f, 0.63439328f, 0.62804795f,
|
||||
0.62166057f, 0.61523159f, 0.60876143f, 0.60225052f, 0.59569930f,
|
||||
0.58910822f, 0.58247770f, 0.57580819f, 0.56910015f, 0.56235401f,
|
||||
0.55557023f, 0.54874927f, 0.54189158f, 0.53499762f, 0.52806785f,
|
||||
0.52110274f, 0.51410274f, 0.50706834f, 0.50000000f, 0.49289819f,
|
||||
0.48576339f, 0.47859608f, 0.47139674f, 0.46416584f, 0.45690388f,
|
||||
0.44961133f, 0.44228869f, 0.43493645f, 0.42755509f, 0.42014512f,
|
||||
0.41270703f, 0.40524131f, 0.39774847f, 0.39022901f, 0.38268343f,
|
||||
0.37511224f, 0.36751594f, 0.35989504f, 0.35225005f, 0.34458148f,
|
||||
0.33688985f, 0.32917568f, 0.32143947f, 0.31368174f, 0.30590302f,
|
||||
0.29810383f, 0.29028468f, 0.28244610f, 0.27458862f, 0.26671276f,
|
||||
0.25881905f, 0.25090801f, 0.24298018f, 0.23503609f, 0.22707626f,
|
||||
0.21910124f, 0.21111155f, 0.20310773f, 0.19509032f, 0.18705985f,
|
||||
0.17901686f, 0.17096189f, 0.16289547f, 0.15481816f, 0.14673047f,
|
||||
0.13863297f, 0.13052619f, 0.12241068f, 0.11428696f, 0.10615561f,
|
||||
0.09801714f, 0.08987211f, 0.08172107f, 0.07356456f, 0.06540313f,
|
||||
0.05723732f, 0.04906767f, 0.04089475f, 0.03271908f, 0.02454123f,
|
||||
0.01636173f, 0.00818114f};
|
||||
|
||||
// Hanning window: for 15ms at 16kHz with symmetric zeros
|
||||
static const float kBlocks240w512[512] = {
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00654494f, 0.01308960f, 0.01963369f,
|
||||
0.02617695f, 0.03271908f, 0.03925982f, 0.04579887f, 0.05233596f,
|
||||
0.05887080f, 0.06540313f, 0.07193266f, 0.07845910f, 0.08498218f,
|
||||
0.09150162f, 0.09801714f, 0.10452846f, 0.11103531f, 0.11753740f,
|
||||
0.12403446f, 0.13052620f, 0.13701233f, 0.14349262f, 0.14996676f,
|
||||
0.15643448f, 0.16289547f, 0.16934951f, 0.17579629f, 0.18223552f,
|
||||
0.18866697f, 0.19509032f, 0.20150533f, 0.20791170f, 0.21430916f,
|
||||
0.22069745f, 0.22707628f, 0.23344538f, 0.23980446f, 0.24615330f,
|
||||
0.25249159f, 0.25881904f, 0.26513544f, 0.27144045f, 0.27773386f,
|
||||
0.28401536f, 0.29028466f, 0.29654160f, 0.30278578f, 0.30901700f,
|
||||
0.31523499f, 0.32143945f, 0.32763019f, 0.33380687f, 0.33996925f,
|
||||
0.34611708f, 0.35225007f, 0.35836795f, 0.36447051f, 0.37055743f,
|
||||
0.37662852f, 0.38268346f, 0.38872197f, 0.39474389f, 0.40074885f,
|
||||
0.40673664f, 0.41270703f, 0.41865975f, 0.42459452f, 0.43051112f,
|
||||
0.43640924f, 0.44228873f, 0.44814920f, 0.45399052f, 0.45981237f,
|
||||
0.46561453f, 0.47139674f, 0.47715878f, 0.48290035f, 0.48862126f,
|
||||
0.49432120f, 0.50000000f, 0.50565743f, 0.51129311f, 0.51690692f,
|
||||
0.52249855f, 0.52806789f, 0.53361452f, 0.53913832f, 0.54463905f,
|
||||
0.55011642f, 0.55557024f, 0.56100029f, 0.56640625f, 0.57178795f,
|
||||
0.57714522f, 0.58247769f, 0.58778524f, 0.59306765f, 0.59832460f,
|
||||
0.60355598f, 0.60876143f, 0.61394083f, 0.61909395f, 0.62422055f,
|
||||
0.62932038f, 0.63439333f, 0.63943899f, 0.64445734f, 0.64944810f,
|
||||
0.65441096f, 0.65934587f, 0.66425246f, 0.66913062f, 0.67398012f,
|
||||
0.67880076f, 0.68359232f, 0.68835455f, 0.69308740f, 0.69779050f,
|
||||
0.70246369f, 0.70710677f, 0.71171963f, 0.71630198f, 0.72085363f,
|
||||
0.72537440f, 0.72986406f, 0.73432255f, 0.73874950f, 0.74314487f,
|
||||
0.74750835f, 0.75183982f, 0.75613910f, 0.76040596f, 0.76464027f,
|
||||
0.76884186f, 0.77301043f, 0.77714598f, 0.78124821f, 0.78531694f,
|
||||
0.78935206f, 0.79335338f, 0.79732066f, 0.80125386f, 0.80515265f,
|
||||
0.80901700f, 0.81284672f, 0.81664157f, 0.82040149f, 0.82412618f,
|
||||
0.82781565f, 0.83146966f, 0.83508795f, 0.83867061f, 0.84221727f,
|
||||
0.84572780f, 0.84920216f, 0.85264021f, 0.85604161f, 0.85940641f,
|
||||
0.86273444f, 0.86602545f, 0.86927933f, 0.87249607f, 0.87567532f,
|
||||
0.87881714f, 0.88192129f, 0.88498765f, 0.88801610f, 0.89100653f,
|
||||
0.89395881f, 0.89687276f, 0.89974827f, 0.90258533f, 0.90538365f,
|
||||
0.90814316f, 0.91086388f, 0.91354549f, 0.91618794f, 0.91879123f,
|
||||
0.92135513f, 0.92387950f, 0.92636442f, 0.92880958f, 0.93121493f,
|
||||
0.93358046f, 0.93590593f, 0.93819135f, 0.94043654f, 0.94264150f,
|
||||
0.94480604f, 0.94693011f, 0.94901365f, 0.95105654f, 0.95305866f,
|
||||
0.95501995f, 0.95694035f, 0.95881975f, 0.96065807f, 0.96245527f,
|
||||
0.96421117f, 0.96592581f, 0.96759909f, 0.96923089f, 0.97082120f,
|
||||
0.97236991f, 0.97387701f, 0.97534233f, 0.97676587f, 0.97814763f,
|
||||
0.97948742f, 0.98078531f, 0.98204112f, 0.98325491f, 0.98442656f,
|
||||
0.98555607f, 0.98664331f, 0.98768836f, 0.98869103f, 0.98965138f,
|
||||
0.99056935f, 0.99144489f, 0.99227792f, 0.99306846f, 0.99381649f,
|
||||
0.99452192f, 0.99518472f, 0.99580491f, 0.99638247f, 0.99691731f,
|
||||
0.99740952f, 0.99785894f, 0.99826562f, 0.99862951f, 0.99895066f,
|
||||
0.99922901f, 0.99946457f, 0.99965733f, 0.99980724f, 0.99991435f,
|
||||
0.99997860f, 1.00000000f, 0.99997860f, 0.99991435f, 0.99980724f,
|
||||
0.99965733f, 0.99946457f, 0.99922901f, 0.99895066f, 0.99862951f,
|
||||
0.99826562f, 0.99785894f, 0.99740946f, 0.99691731f, 0.99638247f,
|
||||
0.99580491f, 0.99518472f, 0.99452192f, 0.99381644f, 0.99306846f,
|
||||
0.99227792f, 0.99144489f, 0.99056935f, 0.98965138f, 0.98869103f,
|
||||
0.98768836f, 0.98664331f, 0.98555607f, 0.98442656f, 0.98325491f,
|
||||
0.98204112f, 0.98078525f, 0.97948742f, 0.97814757f, 0.97676587f,
|
||||
0.97534227f, 0.97387695f, 0.97236991f, 0.97082120f, 0.96923089f,
|
||||
0.96759909f, 0.96592581f, 0.96421117f, 0.96245521f, 0.96065807f,
|
||||
0.95881969f, 0.95694029f, 0.95501995f, 0.95305860f, 0.95105648f,
|
||||
0.94901365f, 0.94693011f, 0.94480604f, 0.94264150f, 0.94043654f,
|
||||
0.93819129f, 0.93590593f, 0.93358046f, 0.93121493f, 0.92880952f,
|
||||
0.92636436f, 0.92387950f, 0.92135507f, 0.91879123f, 0.91618794f,
|
||||
0.91354543f, 0.91086382f, 0.90814310f, 0.90538365f, 0.90258527f,
|
||||
0.89974827f, 0.89687276f, 0.89395875f, 0.89100647f, 0.88801610f,
|
||||
0.88498759f, 0.88192123f, 0.87881714f, 0.87567532f, 0.87249595f,
|
||||
0.86927933f, 0.86602539f, 0.86273432f, 0.85940641f, 0.85604161f,
|
||||
0.85264009f, 0.84920216f, 0.84572780f, 0.84221715f, 0.83867055f,
|
||||
0.83508795f, 0.83146954f, 0.82781565f, 0.82412612f, 0.82040137f,
|
||||
0.81664157f, 0.81284660f, 0.80901700f, 0.80515265f, 0.80125374f,
|
||||
0.79732066f, 0.79335332f, 0.78935200f, 0.78531694f, 0.78124815f,
|
||||
0.77714586f, 0.77301049f, 0.76884180f, 0.76464021f, 0.76040596f,
|
||||
0.75613904f, 0.75183970f, 0.74750835f, 0.74314481f, 0.73874938f,
|
||||
0.73432249f, 0.72986400f, 0.72537428f, 0.72085363f, 0.71630186f,
|
||||
0.71171951f, 0.70710677f, 0.70246363f, 0.69779032f, 0.69308734f,
|
||||
0.68835449f, 0.68359220f, 0.67880070f, 0.67398006f, 0.66913044f,
|
||||
0.66425240f, 0.65934575f, 0.65441096f, 0.64944804f, 0.64445722f,
|
||||
0.63943905f, 0.63439327f, 0.62932026f, 0.62422055f, 0.61909389f,
|
||||
0.61394072f, 0.60876143f, 0.60355592f, 0.59832448f, 0.59306765f,
|
||||
0.58778518f, 0.58247757f, 0.57714522f, 0.57178789f, 0.56640613f,
|
||||
0.56100023f, 0.55557019f, 0.55011630f, 0.54463905f, 0.53913826f,
|
||||
0.53361434f, 0.52806783f, 0.52249849f, 0.51690674f, 0.51129305f,
|
||||
0.50565726f, 0.50000006f, 0.49432117f, 0.48862115f, 0.48290038f,
|
||||
0.47715873f, 0.47139663f, 0.46561456f, 0.45981231f, 0.45399037f,
|
||||
0.44814920f, 0.44228864f, 0.43640912f, 0.43051112f, 0.42459446f,
|
||||
0.41865960f, 0.41270703f, 0.40673658f, 0.40074870f, 0.39474386f,
|
||||
0.38872188f, 0.38268328f, 0.37662849f, 0.37055734f, 0.36447033f,
|
||||
0.35836792f, 0.35224995f, 0.34611690f, 0.33996922f, 0.33380675f,
|
||||
0.32763001f, 0.32143945f, 0.31523487f, 0.30901679f, 0.30278572f,
|
||||
0.29654145f, 0.29028472f, 0.28401530f, 0.27773371f, 0.27144048f,
|
||||
0.26513538f, 0.25881892f, 0.25249159f, 0.24615324f, 0.23980433f,
|
||||
0.23344538f, 0.22707619f, 0.22069728f, 0.21430916f, 0.20791161f,
|
||||
0.20150517f, 0.19509031f, 0.18866688f, 0.18223536f, 0.17579627f,
|
||||
0.16934940f, 0.16289529f, 0.15643445f, 0.14996666f, 0.14349243f,
|
||||
0.13701232f, 0.13052608f, 0.12403426f, 0.11753736f, 0.11103519f,
|
||||
0.10452849f, 0.09801710f, 0.09150149f, 0.08498220f, 0.07845904f,
|
||||
0.07193252f, 0.06540315f, 0.05887074f, 0.05233581f, 0.04579888f,
|
||||
0.03925974f, 0.03271893f, 0.02617695f, 0.01963361f, 0.01308943f,
|
||||
0.00654493f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f};
|
||||
|
||||
// Hanning window: for 30ms with 1024 fft with symmetric zeros at 16kHz
|
||||
static const float kBlocks480w1024[1024] = {
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00327249f, 0.00654494f,
|
||||
0.00981732f, 0.01308960f, 0.01636173f, 0.01963369f, 0.02290544f,
|
||||
0.02617695f, 0.02944817f, 0.03271908f, 0.03598964f, 0.03925982f,
|
||||
0.04252957f, 0.04579887f, 0.04906768f, 0.05233596f, 0.05560368f,
|
||||
0.05887080f, 0.06213730f, 0.06540313f, 0.06866825f, 0.07193266f,
|
||||
0.07519628f, 0.07845910f, 0.08172107f, 0.08498218f, 0.08824237f,
|
||||
0.09150162f, 0.09475989f, 0.09801714f, 0.10127335f, 0.10452846f,
|
||||
0.10778246f, 0.11103531f, 0.11428697f, 0.11753740f, 0.12078657f,
|
||||
0.12403446f, 0.12728101f, 0.13052620f, 0.13376999f, 0.13701233f,
|
||||
0.14025325f, 0.14349262f, 0.14673047f, 0.14996676f, 0.15320145f,
|
||||
0.15643448f, 0.15966582f, 0.16289547f, 0.16612339f, 0.16934951f,
|
||||
0.17257382f, 0.17579629f, 0.17901687f, 0.18223552f, 0.18545224f,
|
||||
0.18866697f, 0.19187967f, 0.19509032f, 0.19829889f, 0.20150533f,
|
||||
0.20470962f, 0.20791170f, 0.21111156f, 0.21430916f, 0.21750447f,
|
||||
0.22069745f, 0.22388805f, 0.22707628f, 0.23026206f, 0.23344538f,
|
||||
0.23662618f, 0.23980446f, 0.24298020f, 0.24615330f, 0.24932377f,
|
||||
0.25249159f, 0.25565669f, 0.25881904f, 0.26197866f, 0.26513544f,
|
||||
0.26828939f, 0.27144045f, 0.27458861f, 0.27773386f, 0.28087610f,
|
||||
0.28401536f, 0.28715158f, 0.29028466f, 0.29341471f, 0.29654160f,
|
||||
0.29966527f, 0.30278578f, 0.30590302f, 0.30901700f, 0.31212768f,
|
||||
0.31523499f, 0.31833893f, 0.32143945f, 0.32453656f, 0.32763019f,
|
||||
0.33072028f, 0.33380687f, 0.33688986f, 0.33996925f, 0.34304500f,
|
||||
0.34611708f, 0.34918544f, 0.35225007f, 0.35531089f, 0.35836795f,
|
||||
0.36142117f, 0.36447051f, 0.36751595f, 0.37055743f, 0.37359497f,
|
||||
0.37662852f, 0.37965801f, 0.38268346f, 0.38570479f, 0.38872197f,
|
||||
0.39173502f, 0.39474389f, 0.39774847f, 0.40074885f, 0.40374491f,
|
||||
0.40673664f, 0.40972406f, 0.41270703f, 0.41568562f, 0.41865975f,
|
||||
0.42162940f, 0.42459452f, 0.42755508f, 0.43051112f, 0.43346250f,
|
||||
0.43640924f, 0.43935132f, 0.44228873f, 0.44522133f, 0.44814920f,
|
||||
0.45107228f, 0.45399052f, 0.45690390f, 0.45981237f, 0.46271592f,
|
||||
0.46561453f, 0.46850815f, 0.47139674f, 0.47428030f, 0.47715878f,
|
||||
0.48003215f, 0.48290035f, 0.48576337f, 0.48862126f, 0.49147385f,
|
||||
0.49432120f, 0.49716330f, 0.50000000f, 0.50283140f, 0.50565743f,
|
||||
0.50847799f, 0.51129311f, 0.51410276f, 0.51690692f, 0.51970553f,
|
||||
0.52249855f, 0.52528602f, 0.52806789f, 0.53084403f, 0.53361452f,
|
||||
0.53637928f, 0.53913832f, 0.54189163f, 0.54463905f, 0.54738063f,
|
||||
0.55011642f, 0.55284631f, 0.55557024f, 0.55828828f, 0.56100029f,
|
||||
0.56370628f, 0.56640625f, 0.56910014f, 0.57178795f, 0.57446963f,
|
||||
0.57714522f, 0.57981455f, 0.58247769f, 0.58513463f, 0.58778524f,
|
||||
0.59042960f, 0.59306765f, 0.59569931f, 0.59832460f, 0.60094351f,
|
||||
0.60355598f, 0.60616195f, 0.60876143f, 0.61135441f, 0.61394083f,
|
||||
0.61652070f, 0.61909395f, 0.62166059f, 0.62422055f, 0.62677383f,
|
||||
0.62932038f, 0.63186020f, 0.63439333f, 0.63691956f, 0.63943899f,
|
||||
0.64195162f, 0.64445734f, 0.64695615f, 0.64944810f, 0.65193301f,
|
||||
0.65441096f, 0.65688187f, 0.65934587f, 0.66180271f, 0.66425246f,
|
||||
0.66669512f, 0.66913062f, 0.67155898f, 0.67398012f, 0.67639405f,
|
||||
0.67880076f, 0.68120021f, 0.68359232f, 0.68597710f, 0.68835455f,
|
||||
0.69072467f, 0.69308740f, 0.69544262f, 0.69779050f, 0.70013082f,
|
||||
0.70246369f, 0.70478904f, 0.70710677f, 0.70941699f, 0.71171963f,
|
||||
0.71401459f, 0.71630198f, 0.71858168f, 0.72085363f, 0.72311789f,
|
||||
0.72537440f, 0.72762316f, 0.72986406f, 0.73209721f, 0.73432255f,
|
||||
0.73653996f, 0.73874950f, 0.74095118f, 0.74314487f, 0.74533057f,
|
||||
0.74750835f, 0.74967808f, 0.75183982f, 0.75399351f, 0.75613910f,
|
||||
0.75827658f, 0.76040596f, 0.76252723f, 0.76464027f, 0.76674515f,
|
||||
0.76884186f, 0.77093029f, 0.77301043f, 0.77508241f, 0.77714598f,
|
||||
0.77920127f, 0.78124821f, 0.78328675f, 0.78531694f, 0.78733873f,
|
||||
0.78935206f, 0.79135692f, 0.79335338f, 0.79534125f, 0.79732066f,
|
||||
0.79929149f, 0.80125386f, 0.80320752f, 0.80515265f, 0.80708915f,
|
||||
0.80901700f, 0.81093621f, 0.81284672f, 0.81474853f, 0.81664157f,
|
||||
0.81852591f, 0.82040149f, 0.82226825f, 0.82412618f, 0.82597536f,
|
||||
0.82781565f, 0.82964706f, 0.83146966f, 0.83328325f, 0.83508795f,
|
||||
0.83688378f, 0.83867061f, 0.84044838f, 0.84221727f, 0.84397703f,
|
||||
0.84572780f, 0.84746957f, 0.84920216f, 0.85092574f, 0.85264021f,
|
||||
0.85434544f, 0.85604161f, 0.85772866f, 0.85940641f, 0.86107504f,
|
||||
0.86273444f, 0.86438453f, 0.86602545f, 0.86765707f, 0.86927933f,
|
||||
0.87089235f, 0.87249607f, 0.87409031f, 0.87567532f, 0.87725097f,
|
||||
0.87881714f, 0.88037390f, 0.88192129f, 0.88345921f, 0.88498765f,
|
||||
0.88650668f, 0.88801610f, 0.88951612f, 0.89100653f, 0.89248741f,
|
||||
0.89395881f, 0.89542055f, 0.89687276f, 0.89831537f, 0.89974827f,
|
||||
0.90117162f, 0.90258533f, 0.90398932f, 0.90538365f, 0.90676826f,
|
||||
0.90814316f, 0.90950841f, 0.91086388f, 0.91220951f, 0.91354549f,
|
||||
0.91487163f, 0.91618794f, 0.91749454f, 0.91879123f, 0.92007810f,
|
||||
0.92135513f, 0.92262226f, 0.92387950f, 0.92512691f, 0.92636442f,
|
||||
0.92759192f, 0.92880958f, 0.93001723f, 0.93121493f, 0.93240267f,
|
||||
0.93358046f, 0.93474817f, 0.93590593f, 0.93705362f, 0.93819135f,
|
||||
0.93931901f, 0.94043654f, 0.94154406f, 0.94264150f, 0.94372880f,
|
||||
0.94480604f, 0.94587320f, 0.94693011f, 0.94797695f, 0.94901365f,
|
||||
0.95004016f, 0.95105654f, 0.95206273f, 0.95305866f, 0.95404440f,
|
||||
0.95501995f, 0.95598525f, 0.95694035f, 0.95788521f, 0.95881975f,
|
||||
0.95974404f, 0.96065807f, 0.96156180f, 0.96245527f, 0.96333838f,
|
||||
0.96421117f, 0.96507370f, 0.96592581f, 0.96676767f, 0.96759909f,
|
||||
0.96842021f, 0.96923089f, 0.97003126f, 0.97082120f, 0.97160077f,
|
||||
0.97236991f, 0.97312868f, 0.97387701f, 0.97461486f, 0.97534233f,
|
||||
0.97605932f, 0.97676587f, 0.97746199f, 0.97814763f, 0.97882277f,
|
||||
0.97948742f, 0.98014158f, 0.98078531f, 0.98141843f, 0.98204112f,
|
||||
0.98265332f, 0.98325491f, 0.98384601f, 0.98442656f, 0.98499662f,
|
||||
0.98555607f, 0.98610497f, 0.98664331f, 0.98717111f, 0.98768836f,
|
||||
0.98819500f, 0.98869103f, 0.98917651f, 0.98965138f, 0.99011570f,
|
||||
0.99056935f, 0.99101239f, 0.99144489f, 0.99186671f, 0.99227792f,
|
||||
0.99267852f, 0.99306846f, 0.99344778f, 0.99381649f, 0.99417448f,
|
||||
0.99452192f, 0.99485862f, 0.99518472f, 0.99550015f, 0.99580491f,
|
||||
0.99609905f, 0.99638247f, 0.99665523f, 0.99691731f, 0.99716878f,
|
||||
0.99740952f, 0.99763954f, 0.99785894f, 0.99806762f, 0.99826562f,
|
||||
0.99845290f, 0.99862951f, 0.99879545f, 0.99895066f, 0.99909520f,
|
||||
0.99922901f, 0.99935216f, 0.99946457f, 0.99956632f, 0.99965733f,
|
||||
0.99973762f, 0.99980724f, 0.99986613f, 0.99991435f, 0.99995178f,
|
||||
0.99997860f, 0.99999464f, 1.00000000f, 0.99999464f, 0.99997860f,
|
||||
0.99995178f, 0.99991435f, 0.99986613f, 0.99980724f, 0.99973762f,
|
||||
0.99965733f, 0.99956632f, 0.99946457f, 0.99935216f, 0.99922901f,
|
||||
0.99909520f, 0.99895066f, 0.99879545f, 0.99862951f, 0.99845290f,
|
||||
0.99826562f, 0.99806762f, 0.99785894f, 0.99763954f, 0.99740946f,
|
||||
0.99716872f, 0.99691731f, 0.99665523f, 0.99638247f, 0.99609905f,
|
||||
0.99580491f, 0.99550015f, 0.99518472f, 0.99485862f, 0.99452192f,
|
||||
0.99417448f, 0.99381644f, 0.99344778f, 0.99306846f, 0.99267852f,
|
||||
0.99227792f, 0.99186671f, 0.99144489f, 0.99101239f, 0.99056935f,
|
||||
0.99011564f, 0.98965138f, 0.98917651f, 0.98869103f, 0.98819494f,
|
||||
0.98768836f, 0.98717111f, 0.98664331f, 0.98610497f, 0.98555607f,
|
||||
0.98499656f, 0.98442656f, 0.98384601f, 0.98325491f, 0.98265326f,
|
||||
0.98204112f, 0.98141843f, 0.98078525f, 0.98014158f, 0.97948742f,
|
||||
0.97882277f, 0.97814757f, 0.97746193f, 0.97676587f, 0.97605932f,
|
||||
0.97534227f, 0.97461486f, 0.97387695f, 0.97312862f, 0.97236991f,
|
||||
0.97160077f, 0.97082120f, 0.97003126f, 0.96923089f, 0.96842015f,
|
||||
0.96759909f, 0.96676761f, 0.96592581f, 0.96507365f, 0.96421117f,
|
||||
0.96333838f, 0.96245521f, 0.96156180f, 0.96065807f, 0.95974404f,
|
||||
0.95881969f, 0.95788515f, 0.95694029f, 0.95598525f, 0.95501995f,
|
||||
0.95404440f, 0.95305860f, 0.95206267f, 0.95105648f, 0.95004016f,
|
||||
0.94901365f, 0.94797695f, 0.94693011f, 0.94587314f, 0.94480604f,
|
||||
0.94372880f, 0.94264150f, 0.94154406f, 0.94043654f, 0.93931895f,
|
||||
0.93819129f, 0.93705362f, 0.93590593f, 0.93474817f, 0.93358046f,
|
||||
0.93240267f, 0.93121493f, 0.93001723f, 0.92880952f, 0.92759192f,
|
||||
0.92636436f, 0.92512691f, 0.92387950f, 0.92262226f, 0.92135507f,
|
||||
0.92007804f, 0.91879123f, 0.91749448f, 0.91618794f, 0.91487157f,
|
||||
0.91354543f, 0.91220951f, 0.91086382f, 0.90950835f, 0.90814310f,
|
||||
0.90676820f, 0.90538365f, 0.90398932f, 0.90258527f, 0.90117157f,
|
||||
0.89974827f, 0.89831525f, 0.89687276f, 0.89542055f, 0.89395875f,
|
||||
0.89248741f, 0.89100647f, 0.88951600f, 0.88801610f, 0.88650662f,
|
||||
0.88498759f, 0.88345915f, 0.88192123f, 0.88037384f, 0.87881714f,
|
||||
0.87725091f, 0.87567532f, 0.87409031f, 0.87249595f, 0.87089223f,
|
||||
0.86927933f, 0.86765701f, 0.86602539f, 0.86438447f, 0.86273432f,
|
||||
0.86107504f, 0.85940641f, 0.85772860f, 0.85604161f, 0.85434544f,
|
||||
0.85264009f, 0.85092574f, 0.84920216f, 0.84746951f, 0.84572780f,
|
||||
0.84397697f, 0.84221715f, 0.84044844f, 0.83867055f, 0.83688372f,
|
||||
0.83508795f, 0.83328319f, 0.83146954f, 0.82964706f, 0.82781565f,
|
||||
0.82597530f, 0.82412612f, 0.82226813f, 0.82040137f, 0.81852591f,
|
||||
0.81664157f, 0.81474847f, 0.81284660f, 0.81093609f, 0.80901700f,
|
||||
0.80708915f, 0.80515265f, 0.80320752f, 0.80125374f, 0.79929143f,
|
||||
0.79732066f, 0.79534125f, 0.79335332f, 0.79135686f, 0.78935200f,
|
||||
0.78733861f, 0.78531694f, 0.78328675f, 0.78124815f, 0.77920121f,
|
||||
0.77714586f, 0.77508223f, 0.77301049f, 0.77093029f, 0.76884180f,
|
||||
0.76674509f, 0.76464021f, 0.76252711f, 0.76040596f, 0.75827658f,
|
||||
0.75613904f, 0.75399339f, 0.75183970f, 0.74967796f, 0.74750835f,
|
||||
0.74533057f, 0.74314481f, 0.74095106f, 0.73874938f, 0.73653996f,
|
||||
0.73432249f, 0.73209721f, 0.72986400f, 0.72762305f, 0.72537428f,
|
||||
0.72311789f, 0.72085363f, 0.71858162f, 0.71630186f, 0.71401453f,
|
||||
0.71171951f, 0.70941705f, 0.70710677f, 0.70478898f, 0.70246363f,
|
||||
0.70013070f, 0.69779032f, 0.69544268f, 0.69308734f, 0.69072461f,
|
||||
0.68835449f, 0.68597704f, 0.68359220f, 0.68120021f, 0.67880070f,
|
||||
0.67639399f, 0.67398006f, 0.67155886f, 0.66913044f, 0.66669512f,
|
||||
0.66425240f, 0.66180259f, 0.65934575f, 0.65688181f, 0.65441096f,
|
||||
0.65193301f, 0.64944804f, 0.64695609f, 0.64445722f, 0.64195150f,
|
||||
0.63943905f, 0.63691956f, 0.63439327f, 0.63186014f, 0.62932026f,
|
||||
0.62677372f, 0.62422055f, 0.62166059f, 0.61909389f, 0.61652064f,
|
||||
0.61394072f, 0.61135429f, 0.60876143f, 0.60616189f, 0.60355592f,
|
||||
0.60094339f, 0.59832448f, 0.59569913f, 0.59306765f, 0.59042960f,
|
||||
0.58778518f, 0.58513451f, 0.58247757f, 0.57981461f, 0.57714522f,
|
||||
0.57446963f, 0.57178789f, 0.56910002f, 0.56640613f, 0.56370628f,
|
||||
0.56100023f, 0.55828822f, 0.55557019f, 0.55284619f, 0.55011630f,
|
||||
0.54738069f, 0.54463905f, 0.54189152f, 0.53913826f, 0.53637916f,
|
||||
0.53361434f, 0.53084403f, 0.52806783f, 0.52528596f, 0.52249849f,
|
||||
0.51970541f, 0.51690674f, 0.51410276f, 0.51129305f, 0.50847787f,
|
||||
0.50565726f, 0.50283122f, 0.50000006f, 0.49716327f, 0.49432117f,
|
||||
0.49147379f, 0.48862115f, 0.48576325f, 0.48290038f, 0.48003212f,
|
||||
0.47715873f, 0.47428021f, 0.47139663f, 0.46850798f, 0.46561456f,
|
||||
0.46271589f, 0.45981231f, 0.45690379f, 0.45399037f, 0.45107210f,
|
||||
0.44814920f, 0.44522130f, 0.44228864f, 0.43935123f, 0.43640912f,
|
||||
0.43346232f, 0.43051112f, 0.42755505f, 0.42459446f, 0.42162928f,
|
||||
0.41865960f, 0.41568545f, 0.41270703f, 0.40972400f, 0.40673658f,
|
||||
0.40374479f, 0.40074870f, 0.39774850f, 0.39474386f, 0.39173496f,
|
||||
0.38872188f, 0.38570464f, 0.38268328f, 0.37965804f, 0.37662849f,
|
||||
0.37359491f, 0.37055734f, 0.36751580f, 0.36447033f, 0.36142117f,
|
||||
0.35836792f, 0.35531086f, 0.35224995f, 0.34918529f, 0.34611690f,
|
||||
0.34304500f, 0.33996922f, 0.33688980f, 0.33380675f, 0.33072016f,
|
||||
0.32763001f, 0.32453656f, 0.32143945f, 0.31833887f, 0.31523487f,
|
||||
0.31212750f, 0.30901679f, 0.30590302f, 0.30278572f, 0.29966521f,
|
||||
0.29654145f, 0.29341453f, 0.29028472f, 0.28715155f, 0.28401530f,
|
||||
0.28087601f, 0.27773371f, 0.27458847f, 0.27144048f, 0.26828936f,
|
||||
0.26513538f, 0.26197854f, 0.25881892f, 0.25565651f, 0.25249159f,
|
||||
0.24932374f, 0.24615324f, 0.24298008f, 0.23980433f, 0.23662600f,
|
||||
0.23344538f, 0.23026201f, 0.22707619f, 0.22388794f, 0.22069728f,
|
||||
0.21750426f, 0.21430916f, 0.21111152f, 0.20791161f, 0.20470949f,
|
||||
0.20150517f, 0.19829892f, 0.19509031f, 0.19187963f, 0.18866688f,
|
||||
0.18545210f, 0.18223536f, 0.17901689f, 0.17579627f, 0.17257376f,
|
||||
0.16934940f, 0.16612324f, 0.16289529f, 0.15966584f, 0.15643445f,
|
||||
0.15320137f, 0.14996666f, 0.14673033f, 0.14349243f, 0.14025325f,
|
||||
0.13701232f, 0.13376991f, 0.13052608f, 0.12728085f, 0.12403426f,
|
||||
0.12078657f, 0.11753736f, 0.11428688f, 0.11103519f, 0.10778230f,
|
||||
0.10452849f, 0.10127334f, 0.09801710f, 0.09475980f, 0.09150149f,
|
||||
0.08824220f, 0.08498220f, 0.08172106f, 0.07845904f, 0.07519618f,
|
||||
0.07193252f, 0.06866808f, 0.06540315f, 0.06213728f, 0.05887074f,
|
||||
0.05560357f, 0.05233581f, 0.04906749f, 0.04579888f, 0.04252954f,
|
||||
0.03925974f, 0.03598953f, 0.03271893f, 0.02944798f, 0.02617695f,
|
||||
0.02290541f, 0.01963361f, 0.01636161f, 0.01308943f, 0.00981712f,
|
||||
0.00654493f, 0.00327244f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
|
||||
0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_WINDOWS_PRIVATE_H_
|
@ -8,29 +8,30 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
#include "modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/fir_filter.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
#include "common_audio/fir_filter.h"
|
||||
#include "common_audio/fir_filter_factory.h"
|
||||
#include "modules/audio_processing/transient/dyadic_decimator.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
WPDNode::WPDNode(size_t length,
|
||||
const float* coefficients,
|
||||
size_t coefficients_length)
|
||||
: // The data buffer has parent data length to be able to contain and filter
|
||||
// it.
|
||||
: // The data buffer has parent data length to be able to contain and
|
||||
// filter it.
|
||||
data_(new float[2 * length + 1]),
|
||||
length_(length),
|
||||
filter_(FIRFilter::Create(coefficients,
|
||||
coefficients_length,
|
||||
2 * length + 1)) {
|
||||
assert(length > 0 && coefficients && coefficients_length > 0);
|
||||
filter_(
|
||||
CreateFirFilter(coefficients, coefficients_length, 2 * length + 1)) {
|
||||
RTC_DCHECK_GT(length, 0);
|
||||
RTC_DCHECK(coefficients);
|
||||
RTC_DCHECK_GT(coefficients_length, 0);
|
||||
memset(data_.get(), 0.f, (2 * length + 1) * sizeof(data_[0]));
|
||||
}
|
||||
|
||||
@ -46,8 +47,8 @@ int WPDNode::Update(const float* parent_data, size_t parent_data_length) {
|
||||
|
||||
// Decimate data.
|
||||
const bool kOddSequence = true;
|
||||
size_t output_samples = DyadicDecimate(
|
||||
data_.get(), parent_data_length, kOddSequence, data_.get(), length_);
|
||||
size_t output_samples = DyadicDecimate(data_.get(), parent_data_length,
|
||||
kOddSequence, data_.get(), length_);
|
||||
if (output_samples != length_) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -8,11 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include <memory>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -36,11 +35,11 @@ class WPDNode {
|
||||
size_t length() const { return length_; }
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<float[]> data_;
|
||||
std::unique_ptr<float[]> data_;
|
||||
size_t length_;
|
||||
rtc::scoped_ptr<FIRFilter> filter_;
|
||||
std::unique_ptr<FIRFilter> filter_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
|
@ -8,31 +8,30 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
#include "modules/audio_processing/transient/wpd_tree.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
#include "modules/audio_processing/transient/wpd_node.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
|
||||
const float* low_pass_coefficients, size_t coefficients_length,
|
||||
WPDTree::WPDTree(size_t data_length,
|
||||
const float* high_pass_coefficients,
|
||||
const float* low_pass_coefficients,
|
||||
size_t coefficients_length,
|
||||
int levels)
|
||||
: data_length_(data_length),
|
||||
levels_(levels),
|
||||
num_nodes_((1 << (levels + 1)) - 1) {
|
||||
assert(data_length > (static_cast<size_t>(1) << levels) &&
|
||||
high_pass_coefficients &&
|
||||
low_pass_coefficients &&
|
||||
levels > 0);
|
||||
RTC_DCHECK_GT(data_length, (static_cast<size_t>(1) << levels));
|
||||
RTC_DCHECK(high_pass_coefficients);
|
||||
RTC_DCHECK(low_pass_coefficients);
|
||||
RTC_DCHECK_GT(levels, 0);
|
||||
// Size is 1 more, so we can use the array as 1-based. nodes_[0] is never
|
||||
// allocated.
|
||||
nodes_.reset(new rtc::scoped_ptr<WPDNode>[num_nodes_ + 1]);
|
||||
nodes_.reset(new std::unique_ptr<WPDNode>[num_nodes_ + 1]);
|
||||
|
||||
// Create the first node
|
||||
const float kRootCoefficient = 1.f; // Identity Coefficient.
|
||||
@ -66,10 +65,10 @@ WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
|
||||
WPDTree::~WPDTree() {}
|
||||
|
||||
WPDNode* WPDTree::NodeAt(int level, int index) {
|
||||
const int kNumNodesAtLevel = 1 << level;
|
||||
if (level < 0 || level > levels_ || index < 0 || index >= kNumNodesAtLevel) {
|
||||
if (level < 0 || level > levels_ || index < 0 || index >= 1 << level) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nodes_[(1 << level) + index].get();
|
||||
}
|
||||
|
||||
@ -99,8 +98,8 @@ int WPDTree::Update(const float* data, size_t data_length) {
|
||||
index_left_child = index * 2;
|
||||
index_right_child = index_left_child + 1;
|
||||
|
||||
update_result = nodes_[index_left_child]->Update(
|
||||
nodes_[index]->data(), nodes_[index]->length());
|
||||
update_result = nodes_[index_left_child]->Update(nodes_[index]->data(),
|
||||
nodes_[index]->length());
|
||||
if (update_result != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -8,11 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -46,9 +49,7 @@ class WPDTree {
|
||||
~WPDTree();
|
||||
|
||||
// Returns the number of nodes at any given level.
|
||||
static int NumberOfNodesAtLevel(int level) {
|
||||
return 1 << level;
|
||||
}
|
||||
static int NumberOfNodesAtLevel(int level) { return 1 << level; }
|
||||
|
||||
// Returns a pointer to the node at the given level and index(of that level).
|
||||
// Level goes from 0 to levels().
|
||||
@ -83,9 +84,9 @@ class WPDTree {
|
||||
size_t data_length_;
|
||||
int levels_;
|
||||
int num_nodes_;
|
||||
rtc::scoped_ptr<rtc::scoped_ptr<WPDNode>[]> nodes_;
|
||||
std::unique_ptr<std::unique_ptr<WPDNode>[]> nodes_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
|
Reference in New Issue
Block a user