├── .gitignore ├── libs └── webrtc-audio-processing │ ├── ChangeLog │ ├── src │ ├── modules │ │ ├── Makefile.am │ │ ├── audio_processing │ │ │ ├── OWNERS │ │ │ ├── test │ │ │ │ ├── android │ │ │ │ │ └── apmtest │ │ │ │ │ │ ├── jni │ │ │ │ │ │ └── Application.mk │ │ │ │ │ │ ├── res │ │ │ │ │ │ └── values │ │ │ │ │ │ │ └── strings.xml │ │ │ │ │ │ ├── default.properties │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ └── unittest.proto │ │ │ ├── aecm │ │ │ │ ├── Makefile.am │ │ │ │ └── aecm.gypi │ │ │ ├── agc │ │ │ │ ├── Makefile.am │ │ │ │ ├── agc.gypi │ │ │ │ └── digital_agc.h │ │ │ ├── utility │ │ │ │ ├── Makefile.am │ │ │ │ ├── fft4g.h │ │ │ │ ├── util.gypi │ │ │ │ └── ring_buffer.h │ │ │ ├── aec │ │ │ │ ├── Makefile.am │ │ │ │ ├── aec.gypi │ │ │ │ ├── resampler.h │ │ │ │ └── aec_rdft.h │ │ │ ├── ns │ │ │ │ ├── Makefile.am │ │ │ │ ├── ns.gypi │ │ │ │ ├── noise_suppression.c │ │ │ │ ├── noise_suppression_x.c │ │ │ │ ├── defines.h │ │ │ │ ├── nsx_defines.h │ │ │ │ └── interface │ │ │ │ │ ├── noise_suppression.h │ │ │ │ │ └── noise_suppression_x.h │ │ │ ├── debug.proto │ │ │ ├── splitting_filter.cc │ │ │ ├── high_pass_filter_impl.h │ │ │ ├── noise_suppression_impl.h │ │ │ ├── level_estimator_impl.h │ │ │ ├── processing_component.h │ │ │ ├── voice_detection_impl.h │ │ │ ├── splitting_filter.h │ │ │ ├── echo_control_mobile_impl.h │ │ │ ├── audio_buffer.h │ │ │ ├── Makefile.am │ │ │ ├── gain_control_impl.h │ │ │ ├── echo_cancellation_impl.h │ │ │ ├── processing_component.cc │ │ │ ├── apm_tests.gypi │ │ │ ├── audio_processing_impl.h │ │ │ └── audio_processing.gypi │ │ └── interface │ │ │ └── module.h │ ├── Makefile.am │ ├── common_audio │ │ ├── Makefile.am │ │ ├── vad │ │ │ ├── Makefile.am │ │ │ └── main │ │ │ │ ├── test │ │ │ │ └── unit_test │ │ │ │ │ ├── unit_test.h │ │ │ │ │ └── unit_test.cc │ │ │ │ └── source │ │ │ │ ├── vad.gypi │ │ │ │ ├── vad_gmm.h │ │ │ │ ├── vad_sp.h │ │ │ │ ├── vad_gmm.c │ │ │ │ └── vad_defines.h │ │ └── signal_processing_library │ │ │ ├── main │ │ │ ├── source │ │ │ │ ├── spl_version.c │ │ │ │ ├── webrtc_fft_t_rad.c │ │ │ │ ├── energy.c │ │ │ │ ├── sqrt_of_one_minus_x_squared.c │ │ │ │ ├── get_hanning_window.c │ │ │ │ ├── get_scaling_square.c │ │ │ │ ├── complex_bit_reverse.c │ │ │ │ ├── filter_ar_fast_q12.c │ │ │ │ ├── min_max_operations_neon.c │ │ │ │ ├── randomization_functions.c │ │ │ │ ├── filter_ma_fast_q12.c │ │ │ │ ├── refl_coef_to_lpc.c │ │ │ │ ├── spl_sqrt_floor.c │ │ │ │ ├── downsample_fast.c │ │ │ │ ├── resample_by_2_internal.h │ │ │ │ ├── lpc_to_refl_coef.c │ │ │ │ ├── spl.gypi │ │ │ │ ├── hanning_table.c │ │ │ │ ├── dot_product_with_scale.c │ │ │ │ ├── copy_set_operations.c │ │ │ │ ├── filter_ar.c │ │ │ │ ├── auto_corr_to_refl_coef.c │ │ │ │ ├── cos_table.c │ │ │ │ ├── sin_table.c │ │ │ │ ├── auto_correlation.c │ │ │ │ └── division_operations.c │ │ │ ├── test │ │ │ │ └── unit_test │ │ │ │ │ └── unit_test.h │ │ │ └── interface │ │ │ │ ├── spl_inl_armv7.h │ │ │ │ └── spl_inl.h │ │ │ └── Makefile.am │ └── system_wrappers │ │ ├── OWNERS │ │ ├── Makefile.am │ │ ├── source │ │ ├── critical_section.cc │ │ ├── critical_section_windows.cc │ │ ├── critical_section_posix.cc │ │ ├── critical_section_posix.h │ │ ├── critical_section_windows.h │ │ └── cpu_features.cc │ │ └── interface │ │ ├── cpu_features_wrapper.h │ │ └── critical_section_wrapper.h │ ├── autogen.sh │ ├── Makefile.am │ ├── NEWS │ ├── AUTHORS │ ├── webrtc-audio-processing.pc.in │ ├── PATENTS │ ├── COPYING │ ├── README │ └── configure.ac ├── .project ├── .settings └── language.settings.xml ├── src ├── ofxEchoCancel.h └── ofxEchoCancel.cpp ├── addon_config.mk └── .cproject /.gitignore: -------------------------------------------------------------------------------- 1 | example 2 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = audio_processing 2 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = common_audio system_wrappers modules 2 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = signal_processing_library vad 2 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/OWNERS: -------------------------------------------------------------------------------- 1 | andrew@webrtc.org 2 | bjornv@webrtc.org 3 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/test/android/apmtest/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_PLATFORM := android-9 2 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | libtoolize 3 | aclocal 4 | automake --add-missing --copy 5 | autoconf 6 | ./configure ${@} 7 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src 2 | 3 | pkgconfigdir = $(libdir)/pkgconfig 4 | pkgconfig_DATA = webrtc-audio-processing.pc 5 | 6 | EXTRA_DIST = PATENTS 7 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/NEWS: -------------------------------------------------------------------------------- 1 | Release 0.1 2 | ----------- 3 | 4 | Initial release, consisting of the WebRTC AudioProcessing module with a 5 | distributor-friendly build system. 6 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/OWNERS: -------------------------------------------------------------------------------- 1 | henrike@webrtc.org 2 | pwestin@webrtc.org 3 | perkj@webrtc.org 4 | henrika@webrtc.org 5 | henrikg@webrtc.org 6 | mflodman@webrtc.org 7 | niklas.enbom@webrtc.org -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/test/android/apmtest/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | apmtest 4 | 5 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | 6 | # autofoo-based build system 7 | Arun Raghavan 8 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/webrtc-audio-processing.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: webrtc-audio-processing 7 | Description: WebRTC Audio Processing library 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lwebrtc_audio_processing 10 | Cflags: -I${includedir}/webrtc_audio_processing 11 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aecm/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libaecm.la 2 | 3 | libaecm_la_SOURCES = interface/echo_control_mobile.h \ 4 | echo_control_mobile.c \ 5 | aecm_core.c \ 6 | aecm_core.h 7 | libaecm_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 8 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 9 | -I$(top_srcdir)/src/modules/audio_processing/utility 10 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/agc/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libagc.la 2 | 3 | libagc_la_SOURCES = interface/gain_control.h \ 4 | analog_agc.c \ 5 | analog_agc.h \ 6 | digital_agc.c \ 7 | digital_agc.h 8 | libagc_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 9 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 10 | -I$(top_srcdir)/src/modules/audio_processing/utility 11 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/utility/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libapm_util.la 2 | 3 | libapm_util_la_SOURCES = delay_estimator_float.c \ 4 | delay_estimator_float.h \ 5 | delay_estimator.c \ 6 | delay_estimator.h \ 7 | fft4g.c \ 8 | fft4g.h \ 9 | ring_buffer.c \ 10 | ring_buffer.h 11 | libapm_util_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 12 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface 13 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/test/android/apmtest/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-9 12 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libvad.la 2 | 3 | libvad_la_SOURCES = main/interface/webrtc_vad.h \ 4 | main/source/webrtc_vad.c \ 5 | main/source/vad_core.c \ 6 | main/source/vad_core.h \ 7 | main/source/vad_defines.h \ 8 | main/source/vad_filterbank.c \ 9 | main/source/vad_filterbank.h \ 10 | main/source/vad_gmm.c \ 11 | main/source/vad_gmm.h \ 12 | main/source/vad_sp.c \ 13 | main/source/vad_sp.h 14 | libvad_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 15 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface 16 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aec/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libaec.la 2 | 3 | libaec_la_SOURCES = interface/echo_cancellation.h \ 4 | echo_cancellation.c \ 5 | aec_core.h \ 6 | aec_core.c \ 7 | aec_core_sse2.c \ 8 | aec_rdft.h \ 9 | aec_rdft.c \ 10 | aec_rdft_sse2.c \ 11 | resampler.h \ 12 | resampler.c 13 | libaec_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 14 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 15 | -I$(top_srcdir)/src/system_wrappers/interface \ 16 | -I$(top_srcdir)/src/modules/audio_processing/utility 17 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libsystem_wrappers.la 2 | 3 | libsystem_wrappers_la_SOURCES = interface/cpu_features_wrapper.h \ 4 | interface/critical_section_wrapper.h \ 5 | source/cpu_features.cc \ 6 | source/critical_section.cc \ 7 | source/critical_section_posix.h \ 8 | source/critical_section_windows.h 9 | # This assumes that we want the POSIX implementation -- should eventually be 10 | # converted to a conditional to include Windows support 11 | libsystem_wrappers_la_SOURCES += source/critical_section_posix.cc 12 | libsystem_wrappers_la_CXXFLAGS = $(AM_CXXFLAGS) $(COMMON_CXXFLAGS) \ 13 | -I$(srcdir)/interface 14 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/utility/fft4g.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_FFT4G_H_ 13 | 14 | void rdft(int, int, float *, int *, float *); 15 | void cdft(int, int, float *, int *, float *); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libns.la libns_fix.la 2 | 3 | libns_la_SOURCES = interface/noise_suppression.h \ 4 | noise_suppression.c \ 5 | windows_private.h \ 6 | defines.h \ 7 | ns_core.c \ 8 | ns_core.h 9 | libns_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 10 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 11 | -I$(top_srcdir)/src/modules/audio_processing/utility 12 | 13 | libns_fix_la_SOURCES = interface/noise_suppression_x.h \ 14 | noise_suppression_x.c \ 15 | nsx_defines.h \ 16 | nsx_core.c \ 17 | nsx_core.h 18 | libns_fix_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) \ 19 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 20 | -I$(top_srcdir)/src/modules/audio_processing/utility 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ofxEchoCancel 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/test/unit_test/unit_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This header file includes the declaration of the VAD unit test. 14 | */ 15 | 16 | #ifndef WEBRTC_VAD_UNIT_TEST_H_ 17 | #define WEBRTC_VAD_UNIT_TEST_H_ 18 | 19 | #include 20 | 21 | class VadTest : public ::testing::Test { 22 | protected: 23 | VadTest(); 24 | virtual void SetUp(); 25 | virtual void TearDown(); 26 | }; 27 | 28 | #endif // WEBRTC_VAD_UNIT_TEST_H_ 29 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/spl_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_get_version(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include 19 | #include "signal_processing_library.h" 20 | 21 | WebRtc_Word16 WebRtcSpl_get_version(char* version, WebRtc_Word16 length_in_bytes) 22 | { 23 | strncpy(version, "1.2.0", length_in_bytes); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/critical_section.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #if defined(_WIN32) 12 | #include 13 | #include "critical_section_windows.h" 14 | #else 15 | #include "critical_section_posix.h" 16 | #endif 17 | 18 | namespace webrtc { 19 | CriticalSectionWrapper* CriticalSectionWrapper::CreateCriticalSection() 20 | { 21 | #ifdef _WIN32 22 | return new CriticalSectionWindows(); 23 | #else 24 | return new CriticalSectionPosix(); 25 | #endif 26 | } 27 | } // namespace webrtc 28 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/debug.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option optimize_for = LITE_RUNTIME; 3 | package webrtc.audioproc; 4 | 5 | message Init { 6 | optional int32 sample_rate = 1; 7 | optional int32 device_sample_rate = 2; 8 | optional int32 num_input_channels = 3; 9 | optional int32 num_output_channels = 4; 10 | optional int32 num_reverse_channels = 5; 11 | } 12 | 13 | message ReverseStream { 14 | optional bytes data = 1; 15 | } 16 | 17 | message Stream { 18 | optional bytes input_data = 1; 19 | optional bytes output_data = 2; 20 | optional int32 delay = 3; 21 | optional sint32 drift = 4; 22 | optional int32 level = 5; 23 | } 24 | 25 | message Event { 26 | enum Type { 27 | INIT = 0; 28 | REVERSE_STREAM = 1; 29 | STREAM = 2; 30 | } 31 | 32 | required Type type = 1; 33 | 34 | optional Init init = 2; 35 | optional ReverseStream reverse_stream = 3; 36 | optional Stream stream = 4; 37 | } 38 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/test/unit_test/unit_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * This header file contains the function WebRtcSpl_CopyFromBeginU8(). 13 | * The description header can be found in signal_processing_library.h 14 | * 15 | */ 16 | 17 | #ifndef WEBRTC_SPL_UNIT_TEST_H_ 18 | #define WEBRTC_SPL_UNIT_TEST_H_ 19 | 20 | #include 21 | 22 | class SplTest: public ::testing::Test 23 | { 24 | protected: 25 | SplTest(); 26 | virtual void SetUp(); 27 | virtual void TearDown(); 28 | }; 29 | 30 | #endif // WEBRTC_SPL_UNIT_TEST_H_ 31 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "critical_section_windows.h" 12 | 13 | namespace webrtc { 14 | CriticalSectionWindows::CriticalSectionWindows() 15 | { 16 | InitializeCriticalSection(&crit); 17 | } 18 | 19 | CriticalSectionWindows::~CriticalSectionWindows() 20 | { 21 | DeleteCriticalSection(&crit); 22 | } 23 | 24 | void 25 | CriticalSectionWindows::Enter() 26 | { 27 | EnterCriticalSection(&crit); 28 | } 29 | 30 | void 31 | CriticalSectionWindows::Leave() 32 | { 33 | LeaveCriticalSection(&crit); 34 | } 35 | } // namespace webrtc 36 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/webrtc_fft_t_rad.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the Q14 radix-2 tables used in ARM9E optimization routines. 14 | * 15 | */ 16 | 17 | extern const unsigned short t_Q14S_rad8[2]; 18 | const unsigned short t_Q14S_rad8[2] = { 0x0000,0x2d41 }; 19 | 20 | //extern const int t_Q30S_rad8[2]; 21 | //const int t_Q30S_rad8[2] = { 0x00000000,0x2d413ccd }; 22 | 23 | extern const unsigned short t_Q14R_rad8[2]; 24 | const unsigned short t_Q14R_rad8[2] = { 0x2d41,0x2d41 }; 25 | 26 | //extern const int t_Q30R_rad8[2]; 27 | //const int t_Q30R_rad8[2] = { 0x2d413ccd,0x2d413ccd }; 28 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/agc/agc.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'agc', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 16 | ], 17 | 'include_dirs': [ 18 | 'interface', 19 | ], 20 | 'direct_dependent_settings': { 21 | 'include_dirs': [ 22 | 'interface', 23 | ], 24 | }, 25 | 'sources': [ 26 | 'interface/gain_control.h', 27 | 'analog_agc.c', 28 | 'analog_agc.h', 29 | 'digital_agc.c', 30 | 'digital_agc.h', 31 | ], 32 | }, 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aecm/aecm.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'aecm', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 16 | 'apm_util' 17 | ], 18 | 'include_dirs': [ 19 | 'interface', 20 | ], 21 | 'direct_dependent_settings': { 22 | 'include_dirs': [ 23 | 'interface', 24 | ], 25 | }, 26 | 'sources': [ 27 | 'interface/echo_control_mobile.h', 28 | 'echo_control_mobile.c', 29 | 'aecm_core.c', 30 | 'aecm_core.h', 31 | ], 32 | }, 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_posix.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "critical_section_posix.h" 12 | 13 | namespace webrtc { 14 | CriticalSectionPosix::CriticalSectionPosix() 15 | { 16 | pthread_mutexattr_t attr; 17 | pthread_mutexattr_init(&attr); 18 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 19 | pthread_mutex_init(&_mutex, &attr); 20 | } 21 | 22 | CriticalSectionPosix::~CriticalSectionPosix() 23 | { 24 | pthread_mutex_destroy(&_mutex); 25 | } 26 | 27 | void 28 | CriticalSectionPosix::Enter() 29 | { 30 | pthread_mutex_lock(&_mutex); 31 | } 32 | 33 | void 34 | CriticalSectionPosix::Leave() 35 | { 36 | pthread_mutex_unlock(&_mutex); 37 | } 38 | } // namespace webrtc 39 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 13 | 14 | #include "critical_section_wrapper.h" 15 | 16 | #include 17 | 18 | namespace webrtc { 19 | class CriticalSectionPosix : public CriticalSectionWrapper 20 | { 21 | public: 22 | CriticalSectionPosix(); 23 | 24 | virtual ~CriticalSectionPosix(); 25 | 26 | virtual void Enter(); 27 | virtual void Leave(); 28 | 29 | private: 30 | pthread_mutex_t _mutex; 31 | friend class ConditionVariablePosix; 32 | }; 33 | } // namespace webrtc 34 | 35 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_POSIX_H_ 36 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_ 13 | 14 | #include "typedefs.h" 15 | #include "critical_section_wrapper.h" 16 | #include 17 | 18 | namespace webrtc { 19 | class CriticalSectionWindows : public CriticalSectionWrapper 20 | { 21 | public: 22 | CriticalSectionWindows(); 23 | 24 | virtual ~CriticalSectionWindows(); 25 | 26 | virtual void Enter(); 27 | virtual void Leave(); 28 | 29 | private: 30 | CRITICAL_SECTION crit; 31 | 32 | friend class ConditionVariableWindows; 33 | }; 34 | } // namespace webrtc 35 | 36 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CRITICAL_SECTION_WINDOWS_H_ 37 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/utility/util.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'apm_util', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 16 | ], 17 | 'direct_dependent_settings': { 18 | 'include_dirs': [ 19 | '.', 20 | ], 21 | }, 22 | 'sources': [ 23 | 'delay_estimator_float.c', 24 | 'delay_estimator_float.h', 25 | 'delay_estimator.c', 26 | 'delay_estimator.h', 27 | 'fft4g.c', 28 | 'fft4g.h', 29 | 'ring_buffer.c', 30 | 'ring_buffer.h', 31 | ], 32 | }, 33 | ], 34 | } 35 | 36 | # Local Variables: 37 | # tab-width:2 38 | # indent-tabs-mode:nil 39 | # End: 40 | # vim: set expandtab tabstop=2 shiftwidth=2: 41 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aec/aec.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'aec', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 16 | 'apm_util' 17 | ], 18 | 'include_dirs': [ 19 | 'interface', 20 | ], 21 | 'direct_dependent_settings': { 22 | 'include_dirs': [ 23 | 'interface', 24 | ], 25 | }, 26 | 'sources': [ 27 | 'interface/echo_cancellation.h', 28 | 'echo_cancellation.c', 29 | 'aec_core.h', 30 | 'aec_core.c', 31 | 'aec_core_sse2.c', 32 | 'aec_rdft.h', 33 | 'aec_rdft.c', 34 | 'aec_rdft_sse2.c', 35 | 'resampler.h', 36 | 'resampler.c', 37 | ], 38 | }, 39 | ], 40 | } 41 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/interface/cpu_features_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 13 | 14 | #if defined(__cplusplus) || defined(c_plusplus) 15 | extern "C" { 16 | #endif 17 | 18 | // list of features. 19 | typedef enum { 20 | kSSE2, 21 | kSSE3 22 | } CPUFeature; 23 | 24 | typedef int (*WebRtc_CPUInfo)(CPUFeature feature); 25 | // returns true if the CPU supports the feature. 26 | extern WebRtc_CPUInfo WebRtc_GetCPUInfo; 27 | // No CPU feature is available => straight C path. 28 | extern WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM; 29 | 30 | #if defined(__cplusplus) || defined(c_plusplus) 31 | } // extern "C" 32 | #endif 33 | 34 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CPU_FEATURES_WRAPPER_H_ 35 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/energy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_Energy(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | WebRtc_Word32 WebRtcSpl_Energy(WebRtc_Word16* vector, int vector_length, int* scale_factor) 21 | { 22 | WebRtc_Word32 en = 0; 23 | int i; 24 | int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); 25 | int looptimes = vector_length; 26 | WebRtc_Word16 *vectorptr = vector; 27 | 28 | for (i = 0; i < looptimes; i++) 29 | { 30 | en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling); 31 | vectorptr++; 32 | } 33 | *scale_factor = scaling; 34 | 35 | return en; 36 | } 37 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/sqrt_of_one_minus_x_squared.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_SqrtOfOneMinusXSquared(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16 *xQ15, int vector_length, 21 | WebRtc_Word16 *yQ15) 22 | { 23 | WebRtc_Word32 sq; 24 | int m; 25 | WebRtc_Word16 tmp; 26 | 27 | for (m = 0; m < vector_length; m++) 28 | { 29 | tmp = xQ15[m]; 30 | sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30 31 | sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 32 | sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 33 | yQ15[m] = (WebRtc_Word16)sq; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/source/vad.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'vad', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | 'spl', 16 | ], 17 | 'include_dirs': [ 18 | '../interface', 19 | ], 20 | 'direct_dependent_settings': { 21 | 'include_dirs': [ 22 | '../interface', 23 | ], 24 | }, 25 | 'sources': [ 26 | '../interface/webrtc_vad.h', 27 | 'webrtc_vad.c', 28 | 'vad_core.c', 29 | 'vad_core.h', 30 | 'vad_defines.h', 31 | 'vad_filterbank.c', 32 | 'vad_filterbank.h', 33 | 'vad_gmm.c', 34 | 'vad_gmm.h', 35 | 'vad_sp.c', 36 | 'vad_sp.h', 37 | ], 38 | }, 39 | ], 40 | } 41 | 42 | # Local Variables: 43 | # tab-width:2 44 | # indent-tabs-mode:nil 45 | # End: 46 | # vim: set expandtab tabstop=2 shiftwidth=2: 47 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/get_hanning_window.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_GetHanningWindow(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_GetHanningWindow(WebRtc_Word16 *v, WebRtc_Word16 size) 21 | { 22 | int jj; 23 | WebRtc_Word16 *vptr1; 24 | 25 | WebRtc_Word32 index; 26 | WebRtc_Word32 factor = ((WebRtc_Word32)0x40000000); 27 | 28 | factor = WebRtcSpl_DivW32W16(factor, size); 29 | if (size < 513) 30 | index = (WebRtc_Word32)-0x200000; 31 | else 32 | index = (WebRtc_Word32)-0x100000; 33 | vptr1 = v; 34 | 35 | for (jj = 0; jj < size; jj++) 36 | { 37 | index += factor; 38 | (*vptr1++) = WebRtcSpl_kHanningTable[index >> 22]; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/test/unittest.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option optimize_for = LITE_RUNTIME; 3 | package webrtc.audioproc; 4 | 5 | message Test { 6 | optional int32 num_reverse_channels = 1; 7 | optional int32 num_input_channels = 2; 8 | optional int32 num_output_channels = 3; 9 | optional int32 sample_rate = 4; 10 | 11 | message Frame { 12 | } 13 | 14 | repeated Frame frame = 5; 15 | 16 | optional int32 analog_level_average = 6; 17 | optional int32 max_output_average = 7; 18 | 19 | optional int32 has_echo_count = 8; 20 | optional int32 has_voice_count = 9; 21 | optional int32 is_saturated_count = 10; 22 | 23 | message Statistic { 24 | optional int32 instant = 1; 25 | optional int32 average = 2; 26 | optional int32 maximum = 3; 27 | optional int32 minimum = 4; 28 | } 29 | 30 | message EchoMetrics { 31 | optional Statistic residual_echo_return_loss = 1; 32 | optional Statistic echo_return_loss = 2; 33 | optional Statistic echo_return_loss_enhancement = 3; 34 | optional Statistic a_nlp = 4; 35 | } 36 | 37 | optional EchoMetrics echo_metrics = 11; 38 | 39 | message DelayMetrics { 40 | optional int32 median = 1; 41 | optional int32 std = 2; 42 | } 43 | 44 | optional DelayMetrics delay_metrics = 12; 45 | } 46 | 47 | message OutputData { 48 | repeated Test test = 1; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/splitting_filter.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "splitting_filter.h" 12 | #include "signal_processing_library.h" 13 | 14 | namespace webrtc { 15 | 16 | void SplittingFilterAnalysis(const WebRtc_Word16* in_data, 17 | WebRtc_Word16* low_band, 18 | WebRtc_Word16* high_band, 19 | WebRtc_Word32* filter_state1, 20 | WebRtc_Word32* filter_state2) 21 | { 22 | WebRtcSpl_AnalysisQMF(in_data, low_band, high_band, filter_state1, filter_state2); 23 | } 24 | 25 | void SplittingFilterSynthesis(const WebRtc_Word16* low_band, 26 | const WebRtc_Word16* high_band, 27 | WebRtc_Word16* out_data, 28 | WebRtc_Word32* filt_state1, 29 | WebRtc_Word32* filt_state2) 30 | { 31 | WebRtcSpl_SynthesisQMF(low_band, high_band, out_data, filt_state1, filt_state2); 32 | } 33 | } // namespace webrtc 34 | -------------------------------------------------------------------------------- /src/ofxEchoCancel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ofxEchoCancel.h 3 | * 4 | * Created on: Oct 3, 2013 5 | * Author: arturo 6 | */ 7 | 8 | #ifndef OFXECHOCANCEL_H_ 9 | #define OFXECHOCANCEL_H_ 10 | 11 | #include "modules/audio_processing/interface/audio_processing.h" 12 | #include "modules/interface/module_common_types.h" 13 | #include "ofParameter.h" 14 | #include "ofConstants.h" 15 | #include "ofParameterGroup.h" 16 | 17 | class ofxEchoCancel { 18 | public: 19 | ofxEchoCancel(); 20 | virtual ~ofxEchoCancel(); 21 | 22 | void setup(); 23 | void analyzeReverse(webrtc::AudioFrame & frame); 24 | void process(webrtc::AudioFrame & frame); 25 | 26 | webrtc::AudioProcessing* getAudioProcessing(); 27 | 28 | ofParameter echoCancelEnabled; 29 | ofParameter gainControlEnabled; 30 | ofParameter noiseSuppressionEnabled; 31 | ofParameter highPassFilterEnabled; 32 | ofParameter voiceDetectionEnabled; 33 | ofParameter driftCompensationEnabled; 34 | ofParameterGroup parameters; 35 | 36 | private: 37 | void echoCancelEnabledChanged(bool & enabled); 38 | void gainControlEnabledChanged(bool & enabled); 39 | void noiseSuppressionEnabledChanged(bool & enabled); 40 | void highPassFilterEnabledChanged(bool & enabled); 41 | void voiceDetectionEnabledChanged(bool & enabled); 42 | void driftCompensationEnabledChanged(bool & enabled); 43 | 44 | webrtc::AudioProcessing* ap; 45 | webrtc::AudioFrame remoteFrame, localFrame; 46 | }; 47 | 48 | #endif /* OFXECHOCANCEL_H_ */ 49 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the WebRTC code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the WebRTC code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the WebRTC code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the WebRTC code package or any code incorporated 20 | within this implementation of the WebRTC code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the WebRTC code package shall terminate as 24 | of the date such litigation is filed. 25 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/get_scaling_square.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_GetScalingSquare(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | int WebRtcSpl_GetScalingSquare(WebRtc_Word16 *in_vector, int in_vector_length, int times) 21 | { 22 | int nbits = WebRtcSpl_GetSizeInBits(times); 23 | int i; 24 | WebRtc_Word16 smax = -1; 25 | WebRtc_Word16 sabs; 26 | WebRtc_Word16 *sptr = in_vector; 27 | int t; 28 | int looptimes = in_vector_length; 29 | 30 | for (i = looptimes; i > 0; i--) 31 | { 32 | sabs = (*sptr > 0 ? *sptr++ : -*sptr++); 33 | smax = (sabs > smax ? sabs : smax); 34 | } 35 | t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); 36 | 37 | if (smax == 0) 38 | { 39 | return 0; // Since norm(0) returns 0 40 | } else 41 | { 42 | return (t > nbits) ? 0 : nbits - t; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aec/resampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_RESAMPLER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_RESAMPLER_H_ 13 | 14 | enum { kResamplingDelay = 1 }; 15 | 16 | // Unless otherwise specified, functions return 0 on success and -1 on error 17 | int WebRtcAec_CreateResampler(void **resampInst); 18 | int WebRtcAec_InitResampler(void *resampInst, int deviceSampleRateHz); 19 | int WebRtcAec_FreeResampler(void *resampInst); 20 | 21 | // Estimates skew from raw measurement. 22 | int WebRtcAec_GetSkew(void *resampInst, int rawSkew, float *skewEst); 23 | 24 | // Resamples input using linear interpolation. 25 | // Returns size of resampled array. 26 | int WebRtcAec_ResampleLinear(void *resampInst, 27 | const short *inspeech, 28 | int size, 29 | float skew, 30 | short *outspeech); 31 | 32 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_RESAMPLER_H_ 33 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/complex_bit_reverse.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_ComplexBitReverse(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_ComplexBitReverse(WebRtc_Word16 frfi[], int stages) 21 | { 22 | int mr, nn, n, l, m; 23 | WebRtc_Word16 tr, ti; 24 | 25 | n = 1 << stages; 26 | 27 | mr = 0; 28 | nn = n - 1; 29 | 30 | // decimation in time - re-order data 31 | for (m = 1; m <= nn; ++m) 32 | { 33 | l = n; 34 | do 35 | { 36 | l >>= 1; 37 | } while (mr + l > nn); 38 | mr = (mr & (l - 1)) + l; 39 | 40 | if (mr <= m) 41 | continue; 42 | 43 | tr = frfi[2 * m]; 44 | frfi[2 * m] = frfi[2 * mr]; 45 | frfi[2 * mr] = tr; 46 | 47 | ti = frfi[2 * m + 1]; 48 | frfi[2 * m + 1] = frfi[2 * mr + 1]; 49 | frfi[2 * mr + 1] = ti; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/test/android/apmtest/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/README: -------------------------------------------------------------------------------- 1 | About 2 | ===== 3 | 4 | This is meant to be a more Linux packaging friendly copy of the AudioProcessing 5 | module from the WebRTC[1] project. The ideal case is that we make no changes to 6 | the code to make tracking upstream code easy. 7 | 8 | This package currently only includes the AudioProcessing bits, but I am very 9 | open to collaborating with other projects that wish to distribute other bits of 10 | the code and hopefully eventually have a single point of packaging all the 11 | WebRTC code to help people reuse the code and avoid keeping private copies in 12 | several different projects. 13 | 14 | [1] http://code.google.com/p/webrtc/ 15 | 16 | Feedback 17 | ======== 18 | 19 | Patches, suggestions welcome. You can send them to the PulseAudio mailing 20 | list[2] or to me at the address below. 21 | 22 | -- Arun Raghavan 23 | 24 | [2] http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss 25 | 26 | Notes 27 | ===== 28 | 29 | Assembling some quick notes on maintaining this tree vs. the original WebRTC 30 | project source code. 31 | 32 | 1. Running meld on a pristine tree's src/ vs. the same directory in the WebRTC 33 | code should produce a fairly easy-to-parse set of differences that can be 34 | merged. I've kept the test code out for now, but this might get merged in 35 | the future. The .gyp/.gypi files are included to make tracking addition and 36 | removal of files easy to track. 37 | 38 | 2. Be sure to keep the keep the comment on top of the version field in 39 | configure.ac up-to-date so that it's easy to track what changes went in at 40 | what point. 41 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/utility/ring_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * Specifies the interface for the AEC generic buffer. 13 | */ 14 | 15 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 16 | #define WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 17 | 18 | // Determines buffer datatype 19 | typedef short bufdata_t; 20 | 21 | // Unless otherwise specified, functions return 0 on success and -1 on error 22 | int WebRtcApm_CreateBuffer(void **bufInst, int size); 23 | int WebRtcApm_InitBuffer(void *bufInst); 24 | int WebRtcApm_FreeBuffer(void *bufInst); 25 | 26 | // Returns number of samples read 27 | int WebRtcApm_ReadBuffer(void *bufInst, bufdata_t *data, int size); 28 | 29 | // Returns number of samples written 30 | int WebRtcApm_WriteBuffer(void *bufInst, const bufdata_t *data, int size); 31 | 32 | // Returns number of samples flushed 33 | int WebRtcApm_FlushBuffer(void *bufInst, int size); 34 | 35 | // Returns number of samples stuffed 36 | int WebRtcApm_StuffBuffer(void *bufInst, int size); 37 | 38 | // Returns number of samples in buffer 39 | int WebRtcApm_get_buffer_size(const void *bufInst); 40 | 41 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_UTILITY_RING_BUFFER_H_ 42 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/configure.ac: -------------------------------------------------------------------------------- 1 | # Revision changelog (version - date, svn rev. from upstream that was merged) 2 | # 0.1 - 21 Oct 2011, r789 3 | AC_INIT([webrtc-audio-processing], [0.1]) 4 | AM_INIT_AUTOMAKE([dist-xz tar-ustar]) 5 | 6 | AC_SUBST(LIBWEBRTC_AUDIO_PROCESSING_VERSION_INFO, [0:0:0]) 7 | 8 | AM_SILENT_RULES([yes]) 9 | 10 | AC_PROG_CC 11 | AC_PROG_CXX 12 | AC_PROG_LIBTOOL 13 | AC_PROG_INSTALL 14 | 15 | AC_LANG_C 16 | AC_LANG_CPLUSPLUS 17 | 18 | AC_ARG_WITH([ns-mode], 19 | AS_HELP_STRING([--with-ns-mode=float|fixed], [Noise suppresion mode to use. Default is float])) 20 | 21 | AS_CASE(["x${with_ns_mode}"], 22 | ["fixed"], [NS_FIXED=1], 23 | ["float"], [NS_FIXED=0], 24 | [NS_FIXED=0]) 25 | AM_CONDITIONAL(NS_FIXED, [test "x${NS_FIXED}" = "x1"]) 26 | 27 | COMMON_CFLAGS="-DNDEBUG -I\$(srcdir)/interface -I\$(srcdir)/main/interface -I\$(top_srcdir)/src -I\$(top_srcdir)/src/modules/interface" 28 | COMMON_CXXFLAGS="-DNDEBUG -I\$(srcdir)/interface -I\$(srcdir)/main/interface -I\$(top_srcdir)/src -I\$(top_srcdir)/src/modules/interface" 29 | AC_SUBST([COMMON_CFLAGS]) 30 | AC_SUBST([COMMON_CXXFLAGS]) 31 | 32 | AC_CONFIG_FILES([ 33 | webrtc-audio-processing.pc 34 | Makefile 35 | src/Makefile 36 | src/common_audio/Makefile 37 | src/common_audio/signal_processing_library/Makefile 38 | src/common_audio/vad/Makefile 39 | src/system_wrappers/Makefile 40 | src/modules/Makefile 41 | src/modules/audio_processing/Makefile 42 | src/modules/audio_processing/utility/Makefile 43 | src/modules/audio_processing/ns/Makefile 44 | src/modules/audio_processing/aec/Makefile 45 | src/modules/audio_processing/aecm/Makefile 46 | src/modules/audio_processing/agc/Makefile 47 | ]) 48 | 49 | AC_OUTPUT 50 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/filter_ar_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_FilterARFastQ12(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_FilterARFastQ12(WebRtc_Word16 *in, WebRtc_Word16 *out, WebRtc_Word16 *A, 21 | WebRtc_Word16 A_length, WebRtc_Word16 length) 22 | { 23 | WebRtc_Word32 o; 24 | int i, j; 25 | 26 | WebRtc_Word16 *x_ptr = &in[0]; 27 | WebRtc_Word16 *filtered_ptr = &out[0]; 28 | 29 | for (i = 0; i < length; i++) 30 | { 31 | // Calculate filtered[i] 32 | G_CONST WebRtc_Word16 *a_ptr = &A[0]; 33 | WebRtc_Word16 *state_ptr = &out[i - 1]; 34 | 35 | o = WEBRTC_SPL_MUL_16_16(*x_ptr++, *a_ptr++); 36 | 37 | for (j = 1; j < A_length; j++) 38 | { 39 | o -= WEBRTC_SPL_MUL_16_16(*a_ptr++,*state_ptr--); 40 | } 41 | 42 | // Saturate the output 43 | o = WEBRTC_SPL_SAT((WebRtc_Word32)134215679, o, (WebRtc_Word32)-134217728); 44 | 45 | *filtered_ptr++ = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); 46 | } 47 | 48 | return; 49 | } 50 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/ns.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'ns', 13 | 'type': '<(library)', 14 | 'dependencies': [ 15 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 16 | 'apm_util' 17 | ], 18 | 'include_dirs': [ 19 | 'interface', 20 | ], 21 | 'direct_dependent_settings': { 22 | 'include_dirs': [ 23 | 'interface', 24 | ], 25 | }, 26 | 'sources': [ 27 | 'interface/noise_suppression.h', 28 | 'noise_suppression.c', 29 | 'windows_private.h', 30 | 'defines.h', 31 | 'ns_core.c', 32 | 'ns_core.h', 33 | ], 34 | }, 35 | { 36 | 'target_name': 'ns_fix', 37 | 'type': '<(library)', 38 | 'dependencies': [ 39 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 40 | ], 41 | 'include_dirs': [ 42 | 'interface', 43 | ], 44 | 'direct_dependent_settings': { 45 | 'include_dirs': [ 46 | 'interface', 47 | ], 48 | }, 49 | 'sources': [ 50 | 'interface/noise_suppression_x.h', 51 | 'noise_suppression_x.c', 52 | 'nsx_defines.h', 53 | 'nsx_core.c', 54 | 'nsx_core.h', 55 | ], 56 | }, 57 | ], 58 | } 59 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/min_max_operations_neon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #if (defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM_NEON)) 12 | 13 | #include 14 | 15 | #include "signal_processing_library.h" 16 | 17 | // Maximum absolute value of word16 vector. 18 | WebRtc_Word16 WebRtcSpl_MaxAbsValueW16(const WebRtc_Word16* vector, 19 | WebRtc_Word16 length) { 20 | WebRtc_Word32 temp_max = 0; 21 | WebRtc_Word32 abs_val; 22 | WebRtc_Word16 tot_max; 23 | int i; 24 | 25 | __asm__("vmov.i16 d25, #0" : : : "d25"); 26 | 27 | for (i = 0; i < length - 7; i += 8) { 28 | __asm__("vld1.16 {d26, d27}, [%0]" : : "r"(&vector[i]) : "q13"); 29 | __asm__("vabs.s16 q13, q13" : : : "q13"); 30 | __asm__("vpmax.s16 d26, d27" : : : "q13"); 31 | __asm__("vpmax.s16 d25, d26" : : : "d25", "d26"); 32 | } 33 | __asm__("vpmax.s16 d25, d25" : : : "d25"); 34 | __asm__("vpmax.s16 d25, d25" : : : "d25"); 35 | __asm__("vmov.s16 %0, d25[0]" : "=r"(temp_max): : "d25"); 36 | 37 | for (; i < length; i++) { 38 | abs_val = WEBRTC_SPL_ABS_W32((vector[i])); 39 | if (abs_val > temp_max) { 40 | temp_max = abs_val; 41 | } 42 | } 43 | tot_max = (WebRtc_Word16)WEBRTC_SPL_MIN(temp_max, WEBRTC_SPL_WORD16_MAX); 44 | return tot_max; 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/randomization_functions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains implementations of the randomization functions 14 | * WebRtcSpl_IncreaseSeed() 15 | * WebRtcSpl_RandU() 16 | * WebRtcSpl_RandN() 17 | * WebRtcSpl_RandUArray() 18 | * 19 | * The description header can be found in signal_processing_library.h 20 | * 21 | */ 22 | 23 | #include "signal_processing_library.h" 24 | 25 | WebRtc_UWord32 WebRtcSpl_IncreaseSeed(WebRtc_UWord32 *seed) 26 | { 27 | seed[0] = (seed[0] * ((WebRtc_Word32)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1); 28 | return seed[0]; 29 | } 30 | 31 | WebRtc_Word16 WebRtcSpl_RandU(WebRtc_UWord32 *seed) 32 | { 33 | return (WebRtc_Word16)(WebRtcSpl_IncreaseSeed(seed) >> 16); 34 | } 35 | 36 | WebRtc_Word16 WebRtcSpl_RandN(WebRtc_UWord32 *seed) 37 | { 38 | return WebRtcSpl_kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23]; 39 | } 40 | 41 | // Creates an array of uniformly distributed variables 42 | WebRtc_Word16 WebRtcSpl_RandUArray(WebRtc_Word16* vector, 43 | WebRtc_Word16 vector_length, 44 | WebRtc_UWord32* seed) 45 | { 46 | int i; 47 | for (i = 0; i < vector_length; i++) 48 | { 49 | vector[i] = WebRtcSpl_RandU(seed); 50 | } 51 | return vector_length; 52 | } 53 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/source/vad_gmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This header file includes the description of the internal VAD call 14 | * WebRtcVad_GaussianProbability. 15 | */ 16 | 17 | #ifndef WEBRTC_VAD_GMM_H_ 18 | #define WEBRTC_VAD_GMM_H_ 19 | 20 | #include "typedefs.h" 21 | 22 | /**************************************************************************** 23 | * WebRtcVad_GaussianProbability(...) 24 | * 25 | * This function calculates the probability for the value 'in_sample', given that in_sample 26 | * comes from a normal distribution with mean 'mean' and standard deviation 'std'. 27 | * 28 | * Input: 29 | * - in_sample : Input sample in Q4 30 | * - mean : mean value in the statistical model, Q7 31 | * - std : standard deviation, Q7 32 | * 33 | * Output: 34 | * 35 | * - delta : Value used when updating the model, Q11 36 | * 37 | * Return: 38 | * - out : out = 1/std * exp(-(x-m)^2/(2*std^2)); 39 | * Probability for x. 40 | * 41 | */ 42 | WebRtc_Word32 WebRtcVad_GaussianProbability(WebRtc_Word16 in_sample, 43 | WebRtc_Word16 mean, 44 | WebRtc_Word16 std, 45 | WebRtc_Word16 *delta); 46 | 47 | #endif // WEBRTC_VAD_GMM_H_ 48 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/filter_ma_fast_q12.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_FilterMAFastQ12(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_ptr, 21 | WebRtc_Word16* out_ptr, 22 | WebRtc_Word16* B, 23 | WebRtc_Word16 B_length, 24 | WebRtc_Word16 length) 25 | { 26 | WebRtc_Word32 o; 27 | int i, j; 28 | for (i = 0; i < length; i++) 29 | { 30 | G_CONST WebRtc_Word16* b_ptr = &B[0]; 31 | G_CONST WebRtc_Word16* x_ptr = &in_ptr[i]; 32 | 33 | o = (WebRtc_Word32)0; 34 | 35 | for (j = 0; j < B_length; j++) 36 | { 37 | o += WEBRTC_SPL_MUL_16_16(*b_ptr++, *x_ptr--); 38 | } 39 | 40 | // If output is higher than 32768, saturate it. Same with negative side 41 | // 2^27 = 134217728, which corresponds to 32768 in Q12 42 | 43 | // Saturate the output 44 | o = WEBRTC_SPL_SAT((WebRtc_Word32)134215679, o, (WebRtc_Word32)-134217728); 45 | 46 | *out_ptr++ = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); 47 | } 48 | return; 49 | } 50 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/refl_coef_to_lpc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_ReflCoefToLpc(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16 *k, int use_order, WebRtc_Word16 *a) 21 | { 22 | WebRtc_Word16 any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; 23 | WebRtc_Word16 *aptr, *aptr2, *anyptr; 24 | G_CONST WebRtc_Word16 *kptr; 25 | int m, i; 26 | 27 | kptr = k; 28 | *a = 4096; // i.e., (Word16_MAX >> 3)+1. 29 | *any = *a; 30 | a[1] = WEBRTC_SPL_RSHIFT_W16((*k), 3); 31 | 32 | for (m = 1; m < use_order; m++) 33 | { 34 | kptr++; 35 | aptr = a; 36 | aptr++; 37 | aptr2 = &a[m]; 38 | anyptr = any; 39 | anyptr++; 40 | 41 | any[m + 1] = WEBRTC_SPL_RSHIFT_W16((*kptr), 3); 42 | for (i = 0; i < m; i++) 43 | { 44 | *anyptr = (*aptr) 45 | + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15); 46 | anyptr++; 47 | aptr++; 48 | aptr2--; 49 | } 50 | 51 | aptr = a; 52 | anyptr = any; 53 | for (i = 0; i < (m + 2); i++) 54 | { 55 | *aptr = *anyptr; 56 | aptr++; 57 | anyptr++; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/spl_sqrt_floor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | /* 12 | * This file contains the function WebRtcSpl_SqrtFloor(). 13 | * The description header can be found in signal_processing_library.h 14 | * 15 | */ 16 | 17 | #include "signal_processing_library.h" 18 | 19 | #define WEBRTC_SPL_SQRT_ITER(N) \ 20 | try1 = root + (1 << (N)); \ 21 | if (value >= try1 << (N)) \ 22 | { \ 23 | value -= try1 << (N); \ 24 | root |= 2 << (N); \ 25 | } 26 | 27 | // (out) Square root of input parameter 28 | WebRtc_Word32 WebRtcSpl_SqrtFloor(WebRtc_Word32 value) 29 | { 30 | // new routine for performance, 4 cycles/bit in ARM 31 | // output precision is 16 bits 32 | 33 | WebRtc_Word32 root = 0, try1; 34 | 35 | WEBRTC_SPL_SQRT_ITER (15); 36 | WEBRTC_SPL_SQRT_ITER (14); 37 | WEBRTC_SPL_SQRT_ITER (13); 38 | WEBRTC_SPL_SQRT_ITER (12); 39 | WEBRTC_SPL_SQRT_ITER (11); 40 | WEBRTC_SPL_SQRT_ITER (10); 41 | WEBRTC_SPL_SQRT_ITER ( 9); 42 | WEBRTC_SPL_SQRT_ITER ( 8); 43 | WEBRTC_SPL_SQRT_ITER ( 7); 44 | WEBRTC_SPL_SQRT_ITER ( 6); 45 | WEBRTC_SPL_SQRT_ITER ( 5); 46 | WEBRTC_SPL_SQRT_ITER ( 4); 47 | WEBRTC_SPL_SQRT_ITER ( 3); 48 | WEBRTC_SPL_SQRT_ITER ( 2); 49 | WEBRTC_SPL_SQRT_ITER ( 1); 50 | WEBRTC_SPL_SQRT_ITER ( 0); 51 | 52 | return root >> 1; 53 | } 54 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/noise_suppression.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "noise_suppression.h" 15 | #include "ns_core.h" 16 | #include "defines.h" 17 | 18 | int WebRtcNs_get_version(char* versionStr, short length) { 19 | const char version[] = "NS 2.2.0"; 20 | const short versionLen = (short)strlen(version) + 1; // +1: null-termination 21 | 22 | if (versionStr == NULL) { 23 | return -1; 24 | } 25 | 26 | if (versionLen > length) { 27 | return -1; 28 | } 29 | 30 | strncpy(versionStr, version, versionLen); 31 | 32 | return 0; 33 | } 34 | 35 | int WebRtcNs_Create(NsHandle** NS_inst) { 36 | *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t)); 37 | if (*NS_inst != NULL) { 38 | (*(NSinst_t**)NS_inst)->initFlag = 0; 39 | return 0; 40 | } else { 41 | return -1; 42 | } 43 | 44 | } 45 | 46 | int WebRtcNs_Free(NsHandle* NS_inst) { 47 | free(NS_inst); 48 | return 0; 49 | } 50 | 51 | 52 | int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) { 53 | return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs); 54 | } 55 | 56 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) { 57 | return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode); 58 | } 59 | 60 | 61 | int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H, 62 | short* outframe, short* outframe_H) { 63 | return WebRtcNs_ProcessCore( 64 | (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H); 65 | } 66 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/high_pass_filter_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_HIGH_PASS_FILTER_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_HIGH_PASS_FILTER_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class HighPassFilterImpl : public HighPassFilter, 22 | public ProcessingComponent { 23 | public: 24 | explicit HighPassFilterImpl(const AudioProcessingImpl* apm); 25 | virtual ~HighPassFilterImpl(); 26 | 27 | int ProcessCaptureAudio(AudioBuffer* audio); 28 | 29 | // HighPassFilter implementation. 30 | virtual bool is_enabled() const; 31 | 32 | // ProcessingComponent implementation. 33 | virtual int get_version(char* version, int version_len_bytes) const; 34 | 35 | private: 36 | // HighPassFilter implementation. 37 | virtual int Enable(bool enable); 38 | 39 | // ProcessingComponent implementation. 40 | virtual void* CreateHandle() const; 41 | virtual int InitializeHandle(void* handle) const; 42 | virtual int ConfigureHandle(void* handle) const; 43 | virtual int DestroyHandle(void* handle) const; 44 | virtual int num_handles_required() const; 45 | virtual int GetHandleError(void* handle) const; 46 | 47 | const AudioProcessingImpl* apm_; 48 | }; 49 | } // namespace webrtc 50 | 51 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_HIGH_PASS_FILTER_IMPL_H_ 52 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libspl.la 2 | 3 | libspl_la_SOURCES = main/interface/signal_processing_library.h \ 4 | main/interface/spl_inl.h \ 5 | main/source/auto_corr_to_refl_coef.c \ 6 | main/source/auto_correlation.c \ 7 | main/source/complex_fft.c \ 8 | main/source/complex_ifft.c \ 9 | main/source/complex_bit_reverse.c \ 10 | main/source/copy_set_operations.c \ 11 | main/source/cos_table.c \ 12 | main/source/cross_correlation.c \ 13 | main/source/division_operations.c \ 14 | main/source/dot_product_with_scale.c \ 15 | main/source/downsample_fast.c \ 16 | main/source/energy.c \ 17 | main/source/filter_ar.c \ 18 | main/source/filter_ar_fast_q12.c \ 19 | main/source/filter_ma_fast_q12.c \ 20 | main/source/get_hanning_window.c \ 21 | main/source/get_scaling_square.c \ 22 | main/source/hanning_table.c \ 23 | main/source/ilbc_specific_functions.c \ 24 | main/source/levinson_durbin.c \ 25 | main/source/lpc_to_refl_coef.c \ 26 | main/source/min_max_operations.c \ 27 | main/source/randn_table.c \ 28 | main/source/randomization_functions.c \ 29 | main/source/refl_coef_to_lpc.c \ 30 | main/source/resample.c \ 31 | main/source/resample_48khz.c \ 32 | main/source/resample_by_2.c \ 33 | main/source/resample_by_2_internal.c \ 34 | main/source/resample_by_2_internal.h \ 35 | main/source/resample_fractional.c \ 36 | main/source/sin_table.c \ 37 | main/source/sin_table_1024.c \ 38 | main/source/spl_sqrt.c \ 39 | main/source/spl_sqrt_floor.c \ 40 | main/source/spl_version.c \ 41 | main/source/splitting_filter.c \ 42 | main/source/sqrt_of_one_minus_x_squared.c \ 43 | main/source/vector_scaling_operations.c 44 | libspl_la_CFLAGS = $(AM_CFLAGS) $(COMMON_CFLAGS) 45 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/downsample_fast.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_DownsampleFast(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | int WebRtcSpl_DownsampleFast(WebRtc_Word16 *in_ptr, WebRtc_Word16 in_length, 21 | WebRtc_Word16 *out_ptr, WebRtc_Word16 out_length, 22 | WebRtc_Word16 *B, WebRtc_Word16 B_length, WebRtc_Word16 factor, 23 | WebRtc_Word16 delay) 24 | { 25 | WebRtc_Word32 o; 26 | int i, j; 27 | 28 | WebRtc_Word16 *downsampled_ptr = out_ptr; 29 | WebRtc_Word16 *b_ptr; 30 | WebRtc_Word16 *x_ptr; 31 | WebRtc_Word16 endpos = delay 32 | + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(factor, (out_length - 1)) + 1; 33 | 34 | if (in_length < endpos) 35 | { 36 | return -1; 37 | } 38 | 39 | for (i = delay; i < endpos; i += factor) 40 | { 41 | b_ptr = &B[0]; 42 | x_ptr = &in_ptr[i]; 43 | 44 | o = (WebRtc_Word32)2048; // Round val 45 | 46 | for (j = 0; j < B_length; j++) 47 | { 48 | o += WEBRTC_SPL_MUL_16_16(*b_ptr++, *x_ptr--); 49 | } 50 | 51 | o = WEBRTC_SPL_RSHIFT_W32(o, 12); 52 | 53 | // If output is higher than 32768, saturate it. Same with negative side 54 | 55 | *downsampled_ptr++ = WebRtcSpl_SatW32ToW16(o); 56 | } 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/noise_suppression_x.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "noise_suppression_x.h" 15 | #include "nsx_core.h" 16 | #include "nsx_defines.h" 17 | 18 | int WebRtcNsx_get_version(char* versionStr, short length) { 19 | const char version[] = "NS\t3.1.0"; 20 | const short versionLen = (short)strlen(version) + 1; // +1: null-termination 21 | 22 | if (versionStr == NULL) { 23 | return -1; 24 | } 25 | 26 | if (versionLen > length) { 27 | return -1; 28 | } 29 | 30 | strncpy(versionStr, version, versionLen); 31 | 32 | return 0; 33 | } 34 | 35 | int WebRtcNsx_Create(NsxHandle** nsxInst) { 36 | *nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t)); 37 | if (*nsxInst != NULL) { 38 | (*(NsxInst_t**)nsxInst)->initFlag = 0; 39 | return 0; 40 | } else { 41 | return -1; 42 | } 43 | 44 | } 45 | 46 | int WebRtcNsx_Free(NsxHandle* nsxInst) { 47 | free(nsxInst); 48 | return 0; 49 | } 50 | 51 | int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs) { 52 | return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs); 53 | } 54 | 55 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) { 56 | return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode); 57 | } 58 | 59 | int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame, 60 | short* speechFrameHB, short* outFrame, 61 | short* outFrameHB) { 62 | return WebRtcNsx_ProcessCore( 63 | (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/noise_suppression_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_NOISE_SUPPRESSION_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_NOISE_SUPPRESSION_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class NoiseSuppressionImpl : public NoiseSuppression, 22 | public ProcessingComponent { 23 | public: 24 | explicit NoiseSuppressionImpl(const AudioProcessingImpl* apm); 25 | virtual ~NoiseSuppressionImpl(); 26 | 27 | int ProcessCaptureAudio(AudioBuffer* audio); 28 | 29 | // NoiseSuppression implementation. 30 | virtual bool is_enabled() const; 31 | 32 | // ProcessingComponent implementation. 33 | virtual int get_version(char* version, int version_len_bytes) const; 34 | 35 | private: 36 | // NoiseSuppression implementation. 37 | virtual int Enable(bool enable); 38 | virtual int set_level(Level level); 39 | virtual Level level() const; 40 | 41 | // ProcessingComponent implementation. 42 | virtual void* CreateHandle() const; 43 | virtual int InitializeHandle(void* handle) const; 44 | virtual int ConfigureHandle(void* handle) const; 45 | virtual int DestroyHandle(void* handle) const; 46 | virtual int num_handles_required() const; 47 | virtual int GetHandleError(void* handle) const; 48 | 49 | const AudioProcessingImpl* apm_; 50 | Level level_; 51 | }; 52 | } // namespace webrtc 53 | 54 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_NOISE_SUPPRESSION_IMPL_H_ 55 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/level_estimator_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_LEVEL_ESTIMATOR_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_LEVEL_ESTIMATOR_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class LevelEstimatorImpl : public LevelEstimator, 22 | public ProcessingComponent { 23 | public: 24 | explicit LevelEstimatorImpl(const AudioProcessingImpl* apm); 25 | virtual ~LevelEstimatorImpl(); 26 | 27 | int AnalyzeReverseStream(AudioBuffer* audio); 28 | int ProcessCaptureAudio(AudioBuffer* audio); 29 | 30 | // LevelEstimator implementation. 31 | virtual bool is_enabled() const; 32 | 33 | // ProcessingComponent implementation. 34 | virtual int get_version(char* version, int version_len_bytes) const; 35 | 36 | private: 37 | // LevelEstimator implementation. 38 | virtual int Enable(bool enable); 39 | virtual int GetMetrics(Metrics* metrics, Metrics* reverse_metrics); 40 | 41 | // ProcessingComponent implementation. 42 | virtual void* CreateHandle() const; 43 | virtual int InitializeHandle(void* handle) const; 44 | virtual int ConfigureHandle(void* handle) const; 45 | virtual int DestroyHandle(void* handle) const; 46 | virtual int num_handles_required() const; 47 | virtual int GetHandleError(void* handle) const; 48 | 49 | const AudioProcessingImpl* apm_; 50 | }; 51 | } // namespace webrtc 52 | 53 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_LEVEL_ESTIMATOR_IMPL_H_ 54 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/interface/critical_section_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ 12 | #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ 13 | 14 | // If the critical section is heavily contended it may be beneficial to use 15 | // read/write locks instead. 16 | 17 | #include "common_types.h" 18 | 19 | namespace webrtc { 20 | class CriticalSectionWrapper 21 | { 22 | public: 23 | // Factory method, constructor disabled 24 | static CriticalSectionWrapper* CreateCriticalSection(); 25 | 26 | virtual ~CriticalSectionWrapper() {} 27 | 28 | // Tries to grab lock, beginning of a critical section. Will wait for the 29 | // lock to become available if the grab failed. 30 | virtual void Enter() = 0; 31 | 32 | // Returns a grabbed lock, end of critical section. 33 | virtual void Leave() = 0; 34 | }; 35 | 36 | // RAII extension of the critical section. Prevents Enter/Leave missmatches and 37 | // provides more compact critical section syntax. 38 | class CriticalSectionScoped 39 | { 40 | public: 41 | CriticalSectionScoped(CriticalSectionWrapper& critsec) 42 | : 43 | _ptrCritSec(&critsec) 44 | { 45 | _ptrCritSec->Enter(); 46 | } 47 | 48 | ~CriticalSectionScoped() 49 | { 50 | if (_ptrCritSec) 51 | { 52 | Leave(); 53 | } 54 | } 55 | 56 | private: 57 | void Leave() 58 | { 59 | _ptrCritSec->Leave(); 60 | _ptrCritSec = 0; 61 | } 62 | 63 | CriticalSectionWrapper* _ptrCritSec; 64 | }; 65 | } // namespace webrtc 66 | #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_CRITICAL_SECTION_WRAPPER_H_ 67 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/processing_component.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_PROCESSING_COMPONENT_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_PROCESSING_COMPONENT_H_ 13 | 14 | #include 15 | 16 | #include "audio_processing.h" 17 | 18 | namespace webrtc { 19 | class AudioProcessingImpl; 20 | 21 | /*template 22 | class ComponentHandle { 23 | public: 24 | ComponentHandle(); 25 | virtual ~ComponentHandle(); 26 | 27 | virtual int Create() = 0; 28 | virtual T* ptr() const = 0; 29 | };*/ 30 | 31 | class ProcessingComponent { 32 | public: 33 | explicit ProcessingComponent(const AudioProcessingImpl* apm); 34 | virtual ~ProcessingComponent(); 35 | 36 | virtual int Initialize(); 37 | virtual int Destroy(); 38 | virtual int get_version(char* version, int version_len_bytes) const = 0; 39 | 40 | protected: 41 | virtual int Configure(); 42 | int EnableComponent(bool enable); 43 | bool is_component_enabled() const; 44 | void* handle(int index) const; 45 | int num_handles() const; 46 | 47 | private: 48 | virtual void* CreateHandle() const = 0; 49 | virtual int InitializeHandle(void* handle) const = 0; 50 | virtual int ConfigureHandle(void* handle) const = 0; 51 | virtual int DestroyHandle(void* handle) const = 0; 52 | virtual int num_handles_required() const = 0; 53 | virtual int GetHandleError(void* handle) const = 0; 54 | 55 | const AudioProcessingImpl* apm_; 56 | std::vector handles_; 57 | bool initialized_; 58 | bool enabled_; 59 | int num_handles_; 60 | }; 61 | } // namespace webrtc 62 | 63 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_PROCESSING_COMPONENT_H__ 64 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/source/vad_sp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This header file includes the VAD internal calls for Downsampling and FindMinimum. 14 | * Specific function calls are given below. 15 | */ 16 | 17 | #ifndef WEBRTC_VAD_SP_H_ 18 | #define WEBRTC_VAD_SP_H_ 19 | 20 | #include "vad_core.h" 21 | 22 | /**************************************************************************** 23 | * WebRtcVad_Downsampling(...) 24 | * 25 | * Downsamples the signal a factor 2, eg. 32->16 or 16->8 26 | * 27 | * Input: 28 | * - signal_in : Input signal 29 | * - in_length : Length of input signal in samples 30 | * 31 | * Input & Output: 32 | * - filter_state : Filter state for first all-pass filters 33 | * 34 | * Output: 35 | * - signal_out : Downsampled signal (of length len/2) 36 | */ 37 | void WebRtcVad_Downsampling(WebRtc_Word16* signal_in, 38 | WebRtc_Word16* signal_out, 39 | WebRtc_Word32* filter_state, 40 | int in_length); 41 | 42 | /**************************************************************************** 43 | * WebRtcVad_FindMinimum(...) 44 | * 45 | * Find the five lowest values of x in 100 frames long window. Return a mean 46 | * value of these five values. 47 | * 48 | * Input: 49 | * - feature_value : Feature value 50 | * - channel : Channel number 51 | * 52 | * Input & Output: 53 | * - inst : State information 54 | * 55 | * Output: 56 | * return value : Weighted minimum value for a moving window. 57 | */ 58 | WebRtc_Word16 WebRtcVad_FindMinimum(VadInstT* inst, WebRtc_Word16 feature_value, int channel); 59 | 60 | #endif // WEBRTC_VAD_SP_H_ 61 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/resample_by_2_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This header file contains some internal resampling functions. 14 | * 15 | */ 16 | 17 | #ifndef WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 18 | #define WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 19 | 20 | #include "typedefs.h" 21 | 22 | /******************************************************************* 23 | * resample_by_2_fast.c 24 | * Functions for internal use in the other resample functions 25 | ******************************************************************/ 26 | void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, 27 | WebRtc_Word32 *state); 28 | 29 | void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, 30 | WebRtc_Word32 *out, WebRtc_Word32 *state); 31 | 32 | void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, 33 | WebRtc_Word32 *out, WebRtc_Word32 *state); 34 | 35 | void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word32 *out, 36 | WebRtc_Word32 *state); 37 | 38 | void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, 39 | WebRtc_Word16 *out, WebRtc_Word32 *state); 40 | 41 | void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, 42 | WebRtc_Word32* out, WebRtc_Word32* state); 43 | 44 | void WebRtcSpl_LPBy2IntToInt(const WebRtc_Word32* in, WebRtc_Word32 len, WebRtc_Word32* out, 45 | WebRtc_Word32* state); 46 | 47 | #endif // WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ 48 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/aec/aec_rdft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 13 | 14 | // These intrinsics were unavailable before VS 2008. 15 | // TODO(andrew): move to a common file. 16 | #if defined(_MSC_VER) && _MSC_VER < 1500 17 | #include 18 | static __inline __m128 _mm_castsi128_ps(__m128i a) { return *(__m128*)&a; } 19 | static __inline __m128i _mm_castps_si128(__m128 a) { return *(__m128i*)&a; } 20 | #endif 21 | 22 | #ifdef _MSC_VER /* visual c++ */ 23 | # define ALIGN16_BEG __declspec(align(16)) 24 | # define ALIGN16_END 25 | #else /* gcc or icc */ 26 | # define ALIGN16_BEG 27 | # define ALIGN16_END __attribute__((aligned(16))) 28 | #endif 29 | 30 | // constants shared by all paths (C, SSE2). 31 | extern float rdft_w[64]; 32 | // constants used by the C path. 33 | extern float rdft_wk3ri_first[32]; 34 | extern float rdft_wk3ri_second[32]; 35 | // constants used by SSE2 but initialized in C path. 36 | extern float rdft_wk1r[32]; 37 | extern float rdft_wk2r[32]; 38 | extern float rdft_wk3r[32]; 39 | extern float rdft_wk1i[32]; 40 | extern float rdft_wk2i[32]; 41 | extern float rdft_wk3i[32]; 42 | extern float cftmdl_wk1r[4]; 43 | 44 | // code path selection function pointers 45 | typedef void (*rft_sub_128_t)(float *a); 46 | extern rft_sub_128_t rftfsub_128; 47 | extern rft_sub_128_t rftbsub_128; 48 | extern rft_sub_128_t cft1st_128; 49 | extern rft_sub_128_t cftmdl_128; 50 | 51 | // entry points 52 | void aec_rdft_init(void); 53 | void aec_rdft_init_sse2(void); 54 | void aec_rdft_forward_128(float *a); 55 | void aec_rdft_inverse_128(float *a); 56 | 57 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_MAIN_SOURCE_AEC_RDFT_H_ 58 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/lpc_to_refl_coef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_LpcToReflCoef(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | #define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50 21 | 22 | void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* a16, int use_order, WebRtc_Word16* k16) 23 | { 24 | int m, k; 25 | WebRtc_Word32 tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER]; 26 | WebRtc_Word32 tmp_inv_denom32; 27 | WebRtc_Word16 tmp_inv_denom16; 28 | 29 | k16[use_order - 1] = WEBRTC_SPL_LSHIFT_W16(a16[use_order], 3); //Q12<<3 => Q15 30 | for (m = use_order - 1; m > 0; m--) 31 | { 32 | // (1 - k^2) in Q30 33 | tmp_inv_denom32 = ((WebRtc_Word32)1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); 34 | // (1 - k^2) in Q15 35 | tmp_inv_denom16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp_inv_denom32, 15); 36 | 37 | for (k = 1; k <= m; k++) 38 | { 39 | // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); 40 | 41 | // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 42 | tmp32[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)a16[k], 16) 43 | - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1); 44 | 45 | tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 46 | } 47 | 48 | for (k = 1; k < m; k++) 49 | { 50 | a16[k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q13>>1 => Q12 51 | } 52 | 53 | tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191); 54 | k16[m - 1] = (WebRtc_Word16)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15 55 | } 56 | return; 57 | } 58 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/system_wrappers/source/cpu_features.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Parts of this file derived from Chromium's base/cpu.cc. 12 | 13 | #include "cpu_features_wrapper.h" 14 | 15 | #include "typedefs.h" 16 | 17 | #if defined(WEBRTC_ARCH_X86_FAMILY) 18 | #if defined(_MSC_VER) 19 | #include 20 | #endif 21 | #endif 22 | 23 | // No CPU feature is available => straight C path. 24 | int GetCPUInfoNoASM(CPUFeature feature) { 25 | (void)feature; 26 | return 0; 27 | } 28 | 29 | #if defined(WEBRTC_ARCH_X86_FAMILY) 30 | #ifndef _MSC_VER 31 | // Intrinsic for "cpuid". 32 | #if defined(__pic__) && defined(__i386__) 33 | static inline void __cpuid(int cpu_info[4], int info_type) { 34 | __asm__ volatile ( 35 | "mov %%ebx, %%edi\n" 36 | "cpuid\n" 37 | "xchg %%edi, %%ebx\n" 38 | : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 39 | : "a"(info_type)); 40 | } 41 | #else 42 | static inline void __cpuid(int cpu_info[4], int info_type) { 43 | __asm__ volatile ( 44 | "cpuid\n" 45 | : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 46 | : "a"(info_type)); 47 | } 48 | #endif 49 | #endif // _MSC_VER 50 | #endif // WEBRTC_ARCH_X86_FAMILY 51 | 52 | #if defined(WEBRTC_ARCH_X86_FAMILY) 53 | // Actual feature detection for x86. 54 | static int GetCPUInfo(CPUFeature feature) { 55 | int cpu_info[4]; 56 | __cpuid(cpu_info, 1); 57 | if (feature == kSSE2) { 58 | return 0 != (cpu_info[3] & 0x04000000); 59 | } 60 | if (feature == kSSE3) { 61 | return 0 != (cpu_info[2] & 0x00000001); 62 | } 63 | return 0; 64 | } 65 | #else 66 | // Default to straight C for other platforms. 67 | static int GetCPUInfo(CPUFeature feature) { 68 | (void)feature; 69 | return 0; 70 | } 71 | #endif 72 | 73 | WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo; 74 | WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM; 75 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/spl.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'targets': [ 11 | { 12 | 'target_name': 'spl', 13 | 'type': '<(library)', 14 | 'include_dirs': [ 15 | '../interface', 16 | ], 17 | 'direct_dependent_settings': { 18 | 'include_dirs': [ 19 | '../interface', 20 | ], 21 | }, 22 | 'sources': [ 23 | '../interface/signal_processing_library.h', 24 | '../interface/spl_inl.h', 25 | 'auto_corr_to_refl_coef.c', 26 | 'auto_correlation.c', 27 | 'complex_fft.c', 28 | 'complex_ifft.c', 29 | 'complex_bit_reverse.c', 30 | 'copy_set_operations.c', 31 | 'cos_table.c', 32 | 'cross_correlation.c', 33 | 'division_operations.c', 34 | 'dot_product_with_scale.c', 35 | 'downsample_fast.c', 36 | 'energy.c', 37 | 'filter_ar.c', 38 | 'filter_ar_fast_q12.c', 39 | 'filter_ma_fast_q12.c', 40 | 'get_hanning_window.c', 41 | 'get_scaling_square.c', 42 | 'hanning_table.c', 43 | 'ilbc_specific_functions.c', 44 | 'levinson_durbin.c', 45 | 'lpc_to_refl_coef.c', 46 | 'min_max_operations.c', 47 | 'randn_table.c', 48 | 'randomization_functions.c', 49 | 'refl_coef_to_lpc.c', 50 | 'resample.c', 51 | 'resample_48khz.c', 52 | 'resample_by_2.c', 53 | 'resample_by_2_internal.c', 54 | 'resample_by_2_internal.h', 55 | 'resample_fractional.c', 56 | 'sin_table.c', 57 | 'sin_table_1024.c', 58 | 'spl_sqrt.c', 59 | 'spl_sqrt_floor.c', 60 | 'spl_version.c', 61 | 'splitting_filter.c', 62 | 'sqrt_of_one_minus_x_squared.c', 63 | 'vector_scaling_operations.c', 64 | ], 65 | }, 66 | ], 67 | } 68 | 69 | # Local Variables: 70 | # tab-width:2 71 | # indent-tabs-mode:nil 72 | # End: 73 | # vim: set expandtab tabstop=2 shiftwidth=2: 74 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/voice_detection_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_VOICE_DETECTION_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_VOICE_DETECTION_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class VoiceDetectionImpl : public VoiceDetection, 22 | public ProcessingComponent { 23 | public: 24 | explicit VoiceDetectionImpl(const AudioProcessingImpl* apm); 25 | virtual ~VoiceDetectionImpl(); 26 | 27 | int ProcessCaptureAudio(AudioBuffer* audio); 28 | 29 | // VoiceDetection implementation. 30 | virtual bool is_enabled() const; 31 | 32 | // ProcessingComponent implementation. 33 | virtual int Initialize(); 34 | virtual int get_version(char* version, int version_len_bytes) const; 35 | 36 | private: 37 | // VoiceDetection implementation. 38 | virtual int Enable(bool enable); 39 | virtual int set_stream_has_voice(bool has_voice); 40 | virtual bool stream_has_voice() const; 41 | virtual int set_likelihood(Likelihood likelihood); 42 | virtual Likelihood likelihood() const; 43 | virtual int set_frame_size_ms(int size); 44 | virtual int frame_size_ms() const; 45 | 46 | // ProcessingComponent implementation. 47 | virtual void* CreateHandle() const; 48 | virtual int InitializeHandle(void* handle) const; 49 | virtual int ConfigureHandle(void* handle) const; 50 | virtual int DestroyHandle(void* handle) const; 51 | virtual int num_handles_required() const; 52 | virtual int GetHandleError(void* handle) const; 53 | 54 | const AudioProcessingImpl* apm_; 55 | bool stream_has_voice_; 56 | bool using_external_vad_; 57 | Likelihood likelihood_; 58 | int frame_size_ms_; 59 | int frame_size_samples_; 60 | }; 61 | } // namespace webrtc 62 | 63 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_VOICE_DETECTION_IMPL_H_ 64 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/interface/module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef MODULES_INTERFACE_MODULE_H_ 12 | #define MODULES_INTERFACE_MODULE_H_ 13 | 14 | #include 15 | 16 | #include "typedefs.h" 17 | 18 | namespace webrtc { 19 | 20 | class Module { 21 | public: 22 | // Returns version of the module and its components. 23 | virtual int32_t Version(char* version, 24 | uint32_t& remaining_buffer_in_bytes, 25 | uint32_t& position) const = 0; 26 | 27 | // Change the unique identifier of this object. 28 | virtual int32_t ChangeUniqueId(const int32_t id) = 0; 29 | 30 | // Returns the number of milliseconds until the module want a worker 31 | // thread to call Process. 32 | virtual int32_t TimeUntilNextProcess() = 0; 33 | 34 | // Process any pending tasks such as timeouts. 35 | virtual int32_t Process() = 0; 36 | 37 | protected: 38 | virtual ~Module() {} 39 | }; 40 | 41 | // Reference counted version of the module interface. 42 | class RefCountedModule : public Module { 43 | public: 44 | // Increase the reference count by one. 45 | // Returns the incremented reference count. 46 | // TODO(perkj): Make this pure virtual when Chromium have implemented 47 | // reference counting ADM and Video capture module. 48 | virtual int32_t AddRef() { 49 | assert(!"Not implemented."); 50 | return 1; 51 | } 52 | 53 | // Decrease the reference count by one. 54 | // Returns the decreased reference count. 55 | // Returns 0 if the last reference was just released. 56 | // When the reference count reach 0 the object will self-destruct. 57 | // TODO(perkj): Make this pure virtual when Chromium have implemented 58 | // reference counting ADM and Video capture module. 59 | virtual int32_t Release() { 60 | assert(!"Not implemented."); 61 | return 1; 62 | } 63 | 64 | protected: 65 | virtual ~RefCountedModule() {} 66 | }; 67 | 68 | } // namespace webrtc 69 | 70 | #endif // MODULES_INTERFACE_MODULE_H_ 71 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/splitting_filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_SPLITTING_FILTER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_SPLITTING_FILTER_H_ 13 | 14 | #include "typedefs.h" 15 | #include "signal_processing_library.h" 16 | 17 | namespace webrtc { 18 | /* 19 | * SplittingFilterbank_analysisQMF(...) 20 | * 21 | * Splits a super-wb signal into two subbands: 0-8 kHz and 8-16 kHz. 22 | * 23 | * Input: 24 | * - in_data : super-wb audio signal 25 | * 26 | * Input & Output: 27 | * - filt_state1: Filter state for first all-pass filter 28 | * - filt_state2: Filter state for second all-pass filter 29 | * 30 | * Output: 31 | * - low_band : The signal from the 0-4 kHz band 32 | * - high_band : The signal from the 4-8 kHz band 33 | */ 34 | void SplittingFilterAnalysis(const WebRtc_Word16* in_data, 35 | WebRtc_Word16* low_band, 36 | WebRtc_Word16* high_band, 37 | WebRtc_Word32* filt_state1, 38 | WebRtc_Word32* filt_state2); 39 | 40 | /* 41 | * SplittingFilterbank_synthesisQMF(...) 42 | * 43 | * Combines the two subbands (0-8 and 8-16 kHz) into a super-wb signal. 44 | * 45 | * Input: 46 | * - low_band : The signal with the 0-8 kHz band 47 | * - high_band : The signal with the 8-16 kHz band 48 | * 49 | * Input & Output: 50 | * - filt_state1: Filter state for first all-pass filter 51 | * - filt_state2: Filter state for second all-pass filter 52 | * 53 | * Output: 54 | * - out_data : super-wb speech signal 55 | */ 56 | void SplittingFilterSynthesis(const WebRtc_Word16* low_band, 57 | const WebRtc_Word16* high_band, 58 | WebRtc_Word16* out_data, 59 | WebRtc_Word32* filt_state1, 60 | WebRtc_Word32* filt_state2); 61 | } // namespace webrtc 62 | 63 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_SPLITTING_FILTER_H_ 64 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/echo_control_mobile_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CONTROL_MOBILE_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CONTROL_MOBILE_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class EchoControlMobileImpl : public EchoControlMobile, 22 | public ProcessingComponent { 23 | public: 24 | explicit EchoControlMobileImpl(const AudioProcessingImpl* apm); 25 | virtual ~EchoControlMobileImpl(); 26 | 27 | int ProcessRenderAudio(const AudioBuffer* audio); 28 | int ProcessCaptureAudio(AudioBuffer* audio); 29 | 30 | // EchoControlMobile implementation. 31 | virtual bool is_enabled() const; 32 | 33 | // ProcessingComponent implementation. 34 | virtual int Initialize(); 35 | virtual int get_version(char* version, int version_len_bytes) const; 36 | 37 | private: 38 | // EchoControlMobile implementation. 39 | virtual int Enable(bool enable); 40 | virtual int set_routing_mode(RoutingMode mode); 41 | virtual RoutingMode routing_mode() const; 42 | virtual int enable_comfort_noise(bool enable); 43 | virtual bool is_comfort_noise_enabled() const; 44 | virtual int SetEchoPath(const void* echo_path, size_t size_bytes); 45 | virtual int GetEchoPath(void* echo_path, size_t size_bytes) const; 46 | 47 | // ProcessingComponent implementation. 48 | virtual void* CreateHandle() const; 49 | virtual int InitializeHandle(void* handle) const; 50 | virtual int ConfigureHandle(void* handle) const; 51 | virtual int DestroyHandle(void* handle) const; 52 | virtual int num_handles_required() const; 53 | virtual int GetHandleError(void* handle) const; 54 | 55 | const AudioProcessingImpl* apm_; 56 | RoutingMode routing_mode_; 57 | bool comfort_noise_enabled_; 58 | unsigned char* external_echo_path_; 59 | }; 60 | } // namespace webrtc 61 | 62 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CONTROL_MOBILE_IMPL_H_ 63 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/audio_buffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ 13 | 14 | #include "module_common_types.h" 15 | #include "typedefs.h" 16 | 17 | namespace webrtc { 18 | 19 | struct AudioChannel; 20 | struct SplitAudioChannel; 21 | 22 | class AudioBuffer { 23 | public: 24 | AudioBuffer(int max_num_channels, int samples_per_channel); 25 | virtual ~AudioBuffer(); 26 | 27 | int num_channels() const; 28 | int samples_per_channel() const; 29 | int samples_per_split_channel() const; 30 | 31 | WebRtc_Word16* data(int channel) const; 32 | WebRtc_Word16* low_pass_split_data(int channel) const; 33 | WebRtc_Word16* high_pass_split_data(int channel) const; 34 | WebRtc_Word16* mixed_low_pass_data(int channel) const; 35 | WebRtc_Word16* low_pass_reference(int channel) const; 36 | 37 | WebRtc_Word32* analysis_filter_state1(int channel) const; 38 | WebRtc_Word32* analysis_filter_state2(int channel) const; 39 | WebRtc_Word32* synthesis_filter_state1(int channel) const; 40 | WebRtc_Word32* synthesis_filter_state2(int channel) const; 41 | 42 | void set_activity(AudioFrame::VADActivity activity); 43 | AudioFrame::VADActivity activity(); 44 | 45 | void DeinterleaveFrom(AudioFrame* audioFrame); 46 | void InterleaveTo(AudioFrame* audioFrame) const; 47 | void Mix(int num_mixed_channels); 48 | void CopyAndMixLowPass(int num_mixed_channels); 49 | void CopyLowPassToReference(); 50 | 51 | private: 52 | const int max_num_channels_; 53 | int num_channels_; 54 | int num_mixed_channels_; 55 | int num_mixed_low_pass_channels_; 56 | const int samples_per_channel_; 57 | int samples_per_split_channel_; 58 | bool reference_copied_; 59 | AudioFrame::VADActivity activity_; 60 | 61 | WebRtc_Word16* data_; 62 | // TODO(andrew): use vectors here. 63 | AudioChannel* channels_; 64 | SplitAudioChannel* split_channels_; 65 | // TODO(andrew): improve this, we don't need the full 32 kHz space here. 66 | AudioChannel* mixed_low_pass_channels_; 67 | AudioChannel* low_pass_reference_channels_; 68 | }; 69 | } // namespace webrtc 70 | 71 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_BUFFER_H_ 72 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = utility ns aec aecm agc 2 | lib_LTLIBRARIES = libwebrtc_audio_processing.la 3 | 4 | if NS_FIXED 5 | COMMON_CXXFLAGS += -DWEBRTC_NS_FIXED=1 6 | NS_LIB = libns_fix 7 | else 8 | COMMON_CXXFLAGS += -DWEBRTC_NS_FLOAT=1 9 | NS_LIB = libns 10 | endif 11 | 12 | webrtcincludedir = $(includedir)/webrtc_audio_processing 13 | webrtcinclude_HEADERS = $(top_srcdir)/src/typedefs.h \ 14 | $(top_srcdir)/src/modules/interface/module.h \ 15 | interface/audio_processing.h \ 16 | $(top_srcdir)/src/common_types.h \ 17 | $(top_srcdir)/src/modules/interface/module_common_types.h 18 | 19 | libwebrtc_audio_processing_la_SOURCES = interface/audio_processing.h \ 20 | audio_buffer.cc \ 21 | audio_buffer.h \ 22 | audio_processing_impl.cc \ 23 | audio_processing_impl.h \ 24 | echo_cancellation_impl.cc \ 25 | echo_cancellation_impl.h \ 26 | echo_control_mobile_impl.cc \ 27 | echo_control_mobile_impl.h \ 28 | gain_control_impl.cc \ 29 | gain_control_impl.h \ 30 | high_pass_filter_impl.cc \ 31 | high_pass_filter_impl.h \ 32 | level_estimator_impl.cc \ 33 | level_estimator_impl.h \ 34 | noise_suppression_impl.cc \ 35 | noise_suppression_impl.h \ 36 | splitting_filter.cc \ 37 | splitting_filter.h \ 38 | processing_component.cc \ 39 | processing_component.h \ 40 | voice_detection_impl.cc \ 41 | voice_detection_impl.h 42 | libwebrtc_audio_processing_la_CXXFLAGS = $(AM_CXXFLAGS) $(COMMON_CXXFLAGS) \ 43 | -I$(top_srcdir)/src/common_audio/signal_processing_library/main/interface \ 44 | -I$(top_srcdir)/src/common_audio/vad/main/interface \ 45 | -I$(top_srcdir)/src/system_wrappers/interface \ 46 | -I$(top_srcdir)/src/modules/audio_processing/utility \ 47 | -I$(top_srcdir)/src/modules/audio_processing/ns/interface \ 48 | -I$(top_srcdir)/src/modules/audio_processing/aec/interface \ 49 | -I$(top_srcdir)/src/modules/audio_processing/aecm/interface \ 50 | -I$(top_srcdir)/src/modules/audio_processing/agc/interface 51 | libwebrtc_audio_processing_la_LIBADD = $(top_builddir)/src/system_wrappers/libsystem_wrappers.la \ 52 | $(top_builddir)/src/common_audio/signal_processing_library/libspl.la \ 53 | $(top_builddir)/src/common_audio/vad/libvad.la \ 54 | $(top_builddir)/src/modules/audio_processing/utility/libapm_util.la \ 55 | $(top_builddir)/src/modules/audio_processing/ns/$(NS_LIB).la \ 56 | $(top_builddir)/src/modules/audio_processing/aec/libaec.la \ 57 | $(top_builddir)/src/modules/audio_processing/aecm/libaecm.la \ 58 | $(top_builddir)/src/modules/audio_processing/agc/libagc.la 59 | libwebrtc_audio_processing_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBWEBRTC_AUDIO_PROCESSING_VERSION_INFO) 60 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/hanning_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the Hanning table with 256 entries. 14 | * 15 | */ 16 | 17 | #include "signal_processing_library.h" 18 | 19 | // Hanning table with 256 entries 20 | WebRtc_Word16 WebRtcSpl_kHanningTable[] = { 21 | 1, 2, 6, 10, 15, 22, 30, 39, 22 | 50, 62, 75, 89, 104, 121, 138, 157, 23 | 178, 199, 222, 246, 271, 297, 324, 353, 24 | 383, 413, 446, 479, 513, 549, 586, 624, 25 | 663, 703, 744, 787, 830, 875, 920, 967, 26 | 1015, 1064, 1114, 1165, 1218, 1271, 1325, 1381, 27 | 1437, 1494, 1553, 1612, 1673, 1734, 1796, 1859, 28 | 1924, 1989, 2055, 2122, 2190, 2259, 2329, 2399, 29 | 2471, 2543, 2617, 2691, 2765, 2841, 2918, 2995, 30 | 3073, 3152, 3232, 3312, 3393, 3475, 3558, 3641, 31 | 3725, 3809, 3895, 3980, 4067, 4154, 4242, 4330, 32 | 4419, 4509, 4599, 4689, 4781, 4872, 4964, 5057, 33 | 5150, 5244, 5338, 5432, 5527, 5622, 5718, 5814, 34 | 5910, 6007, 6104, 6202, 6299, 6397, 6495, 6594, 35 | 6693, 6791, 6891, 6990, 7090, 7189, 7289, 7389, 36 | 7489, 7589, 7690, 7790, 7890, 7991, 8091, 8192, 37 | 8293, 8393, 8494, 8594, 8694, 8795, 8895, 8995, 38 | 9095, 9195, 9294, 9394, 9493, 9593, 9691, 9790, 39 | 9889, 9987, 10085, 10182, 10280, 10377, 10474, 10570, 40 | 10666, 10762, 10857, 10952, 11046, 11140, 11234, 11327, 41 | 11420, 11512, 11603, 11695, 11785, 11875, 11965, 12054, 42 | 12142, 12230, 12317, 12404, 12489, 12575, 12659, 12743, 43 | 12826, 12909, 12991, 13072, 13152, 13232, 13311, 13389, 44 | 13466, 13543, 13619, 13693, 13767, 13841, 13913, 13985, 45 | 14055, 14125, 14194, 14262, 14329, 14395, 14460, 14525, 46 | 14588, 14650, 14711, 14772, 14831, 14890, 14947, 15003, 47 | 15059, 15113, 15166, 15219, 15270, 15320, 15369, 15417, 48 | 15464, 15509, 15554, 15597, 15640, 15681, 15721, 15760, 49 | 15798, 15835, 15871, 15905, 15938, 15971, 16001, 16031, 50 | 16060, 16087, 16113, 16138, 16162, 16185, 16206, 16227, 51 | 16246, 16263, 16280, 16295, 16309, 16322, 16334, 16345, 52 | 16354, 16362, 16369, 16374, 16378, 16382, 16383, 16384 53 | }; 54 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/dot_product_with_scale.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_DotProductWithScale(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | WebRtc_Word32 WebRtcSpl_DotProductWithScale(WebRtc_Word16 *vector1, WebRtc_Word16 *vector2, 21 | int length, int scaling) 22 | { 23 | WebRtc_Word32 sum; 24 | int i; 25 | #ifdef _ARM_OPT_ 26 | #pragma message("NOTE: _ARM_OPT_ optimizations are used") 27 | WebRtc_Word16 len4 = (length >> 2) << 2; 28 | #endif 29 | 30 | sum = 0; 31 | 32 | #ifndef _ARM_OPT_ 33 | for (i = 0; i < length; i++) 34 | { 35 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1++, *vector2++, scaling); 36 | } 37 | #else 38 | if (scaling == 0) 39 | { 40 | for (i = 0; i < len4; i = i + 4) 41 | { 42 | sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2); 43 | vector1++; 44 | vector2++; 45 | sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2); 46 | vector1++; 47 | vector2++; 48 | sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2); 49 | vector1++; 50 | vector2++; 51 | sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2); 52 | vector1++; 53 | vector2++; 54 | } 55 | 56 | for (i = len4; i < length; i++) 57 | { 58 | sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2); 59 | vector1++; 60 | vector2++; 61 | } 62 | } 63 | else 64 | { 65 | for (i = 0; i < len4; i = i + 4) 66 | { 67 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling); 68 | vector1++; 69 | vector2++; 70 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling); 71 | vector1++; 72 | vector2++; 73 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling); 74 | vector1++; 75 | vector2++; 76 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling); 77 | vector1++; 78 | vector2++; 79 | } 80 | 81 | for (i = len4; i < length; i++) 82 | { 83 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling); 84 | vector1++; 85 | vector2++; 86 | } 87 | } 88 | #endif 89 | 90 | return sum; 91 | } 92 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 13 | 14 | //#define PROCESS_FLOW_0 // Use the traditional method. 15 | //#define PROCESS_FLOW_1 // Use traditional with DD estimate of prior SNR. 16 | #define PROCESS_FLOW_2 // Use the new method of speech/noise classification. 17 | 18 | #define BLOCKL_MAX 160 // max processing block length: 160 19 | #define ANAL_BLOCKL_MAX 256 // max analysis block length: 256 20 | #define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1 21 | 22 | #define QUANTILE (float)0.25 23 | 24 | #define SIMULT 3 25 | #define END_STARTUP_LONG 200 26 | #define END_STARTUP_SHORT 50 27 | #define FACTOR (float)40.0 28 | #define WIDTH (float)0.01 29 | 30 | #define SMOOTH (float)0.75 // filter smoothing 31 | // Length of fft work arrays. 32 | #define IP_LENGTH (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2)) 33 | #define W_LENGTH (ANAL_BLOCKL_MAX >> 1) 34 | 35 | //PARAMETERS FOR NEW METHOD 36 | #define DD_PR_SNR (float)0.98 // DD update of prior SNR 37 | #define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90) 38 | #define SPECT_FL_TAVG (float)0.30 // tavg parameter for spectral flatness measure 39 | #define SPECT_DIFF_TAVG (float)0.30 // tavg parameter for spectral difference measure 40 | #define PRIOR_UPDATE (float)0.10 // update parameter of prior model 41 | #define NOISE_UPDATE (float)0.90 // update parameter for noise 42 | #define SPEECH_UPDATE (float)0.99 // update parameter when likely speech 43 | #define WIDTH_PR_MAP (float)4.0 // width parameter in sigmoid map for prior model 44 | #define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature 45 | #define SF_FEATURE_THR (float)0.5 // default threshold for Spectral Flatness feature 46 | #define SD_FEATURE_THR (float)0.5 // default threshold for Spectral Difference feature 47 | #define PROB_RANGE (float)0.20 // probability threshold for noise state in 48 | // speech/noise likelihood 49 | #define HIST_PAR_EST 1000 // histogram size for estimation of parameters 50 | #define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate 51 | // 52 | #define B_LIM (float)0.5 // threshold in final energy gain factor calculation 53 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_ 54 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/gain_control_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 13 | 14 | #include 15 | 16 | #include "audio_processing.h" 17 | #include "processing_component.h" 18 | 19 | namespace webrtc { 20 | class AudioProcessingImpl; 21 | class AudioBuffer; 22 | 23 | class GainControlImpl : public GainControl, 24 | public ProcessingComponent { 25 | public: 26 | explicit GainControlImpl(const AudioProcessingImpl* apm); 27 | virtual ~GainControlImpl(); 28 | 29 | int ProcessRenderAudio(AudioBuffer* audio); 30 | int AnalyzeCaptureAudio(AudioBuffer* audio); 31 | int ProcessCaptureAudio(AudioBuffer* audio); 32 | 33 | // ProcessingComponent implementation. 34 | virtual int Initialize(); 35 | virtual int get_version(char* version, int version_len_bytes) const; 36 | 37 | // GainControl implementation. 38 | virtual bool is_enabled() const; 39 | virtual int stream_analog_level(); 40 | 41 | private: 42 | // GainControl implementation. 43 | virtual int Enable(bool enable); 44 | virtual int set_stream_analog_level(int level); 45 | virtual int set_mode(Mode mode); 46 | virtual Mode mode() const; 47 | virtual int set_target_level_dbfs(int level); 48 | virtual int target_level_dbfs() const; 49 | virtual int set_compression_gain_db(int gain); 50 | virtual int compression_gain_db() const; 51 | virtual int enable_limiter(bool enable); 52 | virtual bool is_limiter_enabled() const; 53 | virtual int set_analog_level_limits(int minimum, int maximum); 54 | virtual int analog_level_minimum() const; 55 | virtual int analog_level_maximum() const; 56 | virtual bool stream_is_saturated() const; 57 | 58 | // ProcessingComponent implementation. 59 | virtual void* CreateHandle() const; 60 | virtual int InitializeHandle(void* handle) const; 61 | virtual int ConfigureHandle(void* handle) const; 62 | virtual int DestroyHandle(void* handle) const; 63 | virtual int num_handles_required() const; 64 | virtual int GetHandleError(void* handle) const; 65 | 66 | const AudioProcessingImpl* apm_; 67 | Mode mode_; 68 | int minimum_capture_level_; 69 | int maximum_capture_level_; 70 | bool limiter_enabled_; 71 | int target_level_dbfs_; 72 | int compression_gain_db_; 73 | std::vector capture_levels_; 74 | int analog_capture_level_; 75 | bool was_analog_level_set_; 76 | bool stream_is_saturated_; 77 | }; 78 | } // namespace webrtc 79 | 80 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 81 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/echo_cancellation_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CANCELLATION_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CANCELLATION_IMPL_H_ 13 | 14 | #include "audio_processing.h" 15 | #include "processing_component.h" 16 | 17 | namespace webrtc { 18 | class AudioProcessingImpl; 19 | class AudioBuffer; 20 | 21 | class EchoCancellationImpl : public EchoCancellation, 22 | public ProcessingComponent { 23 | public: 24 | explicit EchoCancellationImpl(const AudioProcessingImpl* apm); 25 | virtual ~EchoCancellationImpl(); 26 | 27 | int ProcessRenderAudio(const AudioBuffer* audio); 28 | int ProcessCaptureAudio(AudioBuffer* audio); 29 | 30 | // EchoCancellation implementation. 31 | virtual bool is_enabled() const; 32 | virtual int device_sample_rate_hz() const; 33 | virtual int stream_drift_samples() const; 34 | 35 | // ProcessingComponent implementation. 36 | virtual int Initialize(); 37 | virtual int get_version(char* version, int version_len_bytes) const; 38 | 39 | private: 40 | // EchoCancellation implementation. 41 | virtual int Enable(bool enable); 42 | virtual int enable_drift_compensation(bool enable); 43 | virtual bool is_drift_compensation_enabled() const; 44 | virtual int set_device_sample_rate_hz(int rate); 45 | virtual int set_stream_drift_samples(int drift); 46 | virtual int set_suppression_level(SuppressionLevel level); 47 | virtual SuppressionLevel suppression_level() const; 48 | virtual int enable_metrics(bool enable); 49 | virtual bool are_metrics_enabled() const; 50 | virtual bool stream_has_echo() const; 51 | virtual int GetMetrics(Metrics* metrics); 52 | virtual int enable_delay_logging(bool enable); 53 | virtual bool is_delay_logging_enabled() const; 54 | virtual int GetDelayMetrics(int* median, int* std); 55 | 56 | // ProcessingComponent implementation. 57 | virtual void* CreateHandle() const; 58 | virtual int InitializeHandle(void* handle) const; 59 | virtual int ConfigureHandle(void* handle) const; 60 | virtual int DestroyHandle(void* handle) const; 61 | virtual int num_handles_required() const; 62 | virtual int GetHandleError(void* handle) const; 63 | 64 | const AudioProcessingImpl* apm_; 65 | bool drift_compensation_enabled_; 66 | bool metrics_enabled_; 67 | SuppressionLevel suppression_level_; 68 | int device_sample_rate_hz_; 69 | int stream_drift_samples_; 70 | bool was_stream_drift_set_; 71 | bool stream_has_echo_; 72 | bool delay_logging_enabled_; 73 | }; 74 | } // namespace webrtc 75 | 76 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_ECHO_CANCELLATION_IMPL_H_ 77 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/source/vad_gmm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file includes the implementation of the internal VAD call 14 | * WebRtcVad_GaussianProbability. For function description, see vad_gmm.h. 15 | */ 16 | 17 | #include "vad_gmm.h" 18 | 19 | #include "signal_processing_library.h" 20 | #include "typedefs.h" 21 | 22 | static const WebRtc_Word32 kCompVar = 22005; 23 | // Constant log2(exp(1)) in Q12 24 | static const WebRtc_Word16 kLog10Const = 5909; 25 | 26 | WebRtc_Word32 WebRtcVad_GaussianProbability(WebRtc_Word16 in_sample, 27 | WebRtc_Word16 mean, 28 | WebRtc_Word16 std, 29 | WebRtc_Word16 *delta) 30 | { 31 | WebRtc_Word16 tmp16, tmpDiv, tmpDiv2, expVal, tmp16_1, tmp16_2; 32 | WebRtc_Word32 tmp32, y32; 33 | 34 | // Calculate tmpDiv=1/std, in Q10 35 | tmp32 = (WebRtc_Word32)WEBRTC_SPL_RSHIFT_W16(std,1) + (WebRtc_Word32)131072; // 1 in Q17 36 | tmpDiv = (WebRtc_Word16)WebRtcSpl_DivW32W16(tmp32, std); // Q17/Q7 = Q10 37 | 38 | // Calculate tmpDiv2=1/std^2, in Q14 39 | tmp16 = WEBRTC_SPL_RSHIFT_W16(tmpDiv, 2); // From Q10 to Q8 40 | tmpDiv2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16, tmp16, 2); // (Q8 * Q8)>>2 = Q14 41 | 42 | tmp16 = WEBRTC_SPL_LSHIFT_W16(in_sample, 3); // Q7 43 | tmp16 = tmp16 - mean; // Q7 - Q7 = Q7 44 | 45 | // To be used later, when updating noise/speech model 46 | // delta = (x-m)/std^2, in Q11 47 | *delta = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmpDiv2, tmp16, 10); //(Q14*Q7)>>10 = Q11 48 | 49 | // Calculate tmp32=(x-m)^2/(2*std^2), in Q10 50 | tmp32 = (WebRtc_Word32)WEBRTC_SPL_MUL_16_16_RSFT(*delta, tmp16, 9); // One shift for /2 51 | 52 | // Calculate expVal ~= exp(-(x-m)^2/(2*std^2)) ~= exp2(-log2(exp(1))*tmp32) 53 | if (tmp32 < kCompVar) 54 | { 55 | // Calculate tmp16 = log2(exp(1))*tmp32 , in Q10 56 | tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16)tmp32, 57 | kLog10Const, 12); 58 | tmp16 = -tmp16; 59 | tmp16_2 = (WebRtc_Word16)(0x0400 | (tmp16 & 0x03FF)); 60 | tmp16_1 = (WebRtc_Word16)(tmp16 ^ 0xFFFF); 61 | tmp16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(tmp16_1, 10); 62 | tmp16 += 1; 63 | // Calculate expVal=log2(-tmp32), in Q10 64 | expVal = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)tmp16_2, tmp16); 65 | 66 | } else 67 | { 68 | expVal = 0; 69 | } 70 | 71 | // Calculate y32=(1/std)*exp(-(x-m)^2/(2*std^2)), in Q20 72 | y32 = WEBRTC_SPL_MUL_16_16(tmpDiv, expVal); // Q10 * Q10 = Q20 73 | 74 | return y32; // Q20 75 | } 76 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/processing_component.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "processing_component.h" 12 | 13 | #include 14 | 15 | #include "audio_processing_impl.h" 16 | 17 | namespace webrtc { 18 | 19 | ProcessingComponent::ProcessingComponent(const AudioProcessingImpl* apm) 20 | : apm_(apm), 21 | initialized_(false), 22 | enabled_(false), 23 | num_handles_(0) {} 24 | 25 | ProcessingComponent::~ProcessingComponent() { 26 | assert(initialized_ == false); 27 | } 28 | 29 | int ProcessingComponent::Destroy() { 30 | while (!handles_.empty()) { 31 | DestroyHandle(handles_.back()); 32 | handles_.pop_back(); 33 | } 34 | initialized_ = false; 35 | 36 | return apm_->kNoError; 37 | } 38 | 39 | int ProcessingComponent::EnableComponent(bool enable) { 40 | if (enable && !enabled_) { 41 | enabled_ = enable; // Must be set before Initialize() is called. 42 | 43 | int err = Initialize(); 44 | if (err != apm_->kNoError) { 45 | enabled_ = false; 46 | return err; 47 | } 48 | } else { 49 | enabled_ = enable; 50 | } 51 | 52 | return apm_->kNoError; 53 | } 54 | 55 | bool ProcessingComponent::is_component_enabled() const { 56 | return enabled_; 57 | } 58 | 59 | void* ProcessingComponent::handle(int index) const { 60 | assert(index < num_handles_); 61 | return handles_[index]; 62 | } 63 | 64 | int ProcessingComponent::num_handles() const { 65 | return num_handles_; 66 | } 67 | 68 | int ProcessingComponent::Initialize() { 69 | if (!enabled_) { 70 | return apm_->kNoError; 71 | } 72 | 73 | num_handles_ = num_handles_required(); 74 | if (num_handles_ > static_cast(handles_.size())) { 75 | handles_.resize(num_handles_, NULL); 76 | } 77 | 78 | assert(static_cast(handles_.size()) >= num_handles_); 79 | for (int i = 0; i < num_handles_; i++) { 80 | if (handles_[i] == NULL) { 81 | handles_[i] = CreateHandle(); 82 | if (handles_[i] == NULL) { 83 | return apm_->kCreationFailedError; 84 | } 85 | } 86 | 87 | int err = InitializeHandle(handles_[i]); 88 | if (err != apm_->kNoError) { 89 | return GetHandleError(handles_[i]); 90 | } 91 | } 92 | 93 | initialized_ = true; 94 | return Configure(); 95 | } 96 | 97 | int ProcessingComponent::Configure() { 98 | if (!initialized_) { 99 | return apm_->kNoError; 100 | } 101 | 102 | assert(static_cast(handles_.size()) >= num_handles_); 103 | for (int i = 0; i < num_handles_; i++) { 104 | int err = ConfigureHandle(handles_[i]); 105 | if (err != apm_->kNoError) { 106 | return GetHandleError(handles_[i]); 107 | } 108 | } 109 | 110 | return apm_->kNoError; 111 | } 112 | } // namespace webrtc 113 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/agc/digital_agc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_DIGITAL_AGC_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_DIGITAL_AGC_H_ 13 | 14 | #ifdef AGC_DEBUG 15 | #include 16 | #endif 17 | #include "typedefs.h" 18 | #include "signal_processing_library.h" 19 | 20 | // the 32 most significant bits of A(19) * B(26) >> 13 21 | #define AGC_MUL32(A, B) (((B)>>13)*(A) + ( ((0x00001FFF & (B))*(A)) >> 13 )) 22 | // C + the 32 most significant bits of A * B 23 | #define AGC_SCALEDIFF32(A, B, C) ((C) + ((B)>>16)*(A) + ( ((0x0000FFFF & (B))*(A)) >> 16 )) 24 | 25 | typedef struct 26 | { 27 | WebRtc_Word32 downState[8]; 28 | WebRtc_Word16 HPstate; 29 | WebRtc_Word16 counter; 30 | WebRtc_Word16 logRatio; // log( P(active) / P(inactive) ) (Q10) 31 | WebRtc_Word16 meanLongTerm; // Q10 32 | WebRtc_Word32 varianceLongTerm; // Q8 33 | WebRtc_Word16 stdLongTerm; // Q10 34 | WebRtc_Word16 meanShortTerm; // Q10 35 | WebRtc_Word32 varianceShortTerm; // Q8 36 | WebRtc_Word16 stdShortTerm; // Q10 37 | } AgcVad_t; // total = 54 bytes 38 | 39 | typedef struct 40 | { 41 | WebRtc_Word32 capacitorSlow; 42 | WebRtc_Word32 capacitorFast; 43 | WebRtc_Word32 gain; 44 | WebRtc_Word32 gainTable[32]; 45 | WebRtc_Word16 gatePrevious; 46 | WebRtc_Word16 agcMode; 47 | AgcVad_t vadNearend; 48 | AgcVad_t vadFarend; 49 | #ifdef AGC_DEBUG 50 | FILE* logFile; 51 | int frameCounter; 52 | #endif 53 | } DigitalAgc_t; 54 | 55 | WebRtc_Word32 WebRtcAgc_InitDigital(DigitalAgc_t *digitalAgcInst, WebRtc_Word16 agcMode); 56 | 57 | WebRtc_Word32 WebRtcAgc_ProcessDigital(DigitalAgc_t *digitalAgcInst, const WebRtc_Word16 *inNear, 58 | const WebRtc_Word16 *inNear_H, WebRtc_Word16 *out, 59 | WebRtc_Word16 *out_H, WebRtc_UWord32 FS, 60 | WebRtc_Word16 lowLevelSignal); 61 | 62 | WebRtc_Word32 WebRtcAgc_AddFarendToDigital(DigitalAgc_t *digitalAgcInst, const WebRtc_Word16 *inFar, 63 | WebRtc_Word16 nrSamples); 64 | 65 | void WebRtcAgc_InitVad(AgcVad_t *vadInst); 66 | 67 | WebRtc_Word16 WebRtcAgc_ProcessVad(AgcVad_t *vadInst, // (i) VAD state 68 | const WebRtc_Word16 *in, // (i) Speech signal 69 | WebRtc_Word16 nrSamples); // (i) number of samples 70 | 71 | WebRtc_Word32 WebRtcAgc_CalculateGainTable(WebRtc_Word32 *gainTable, // Q16 72 | WebRtc_Word16 compressionGaindB, // Q0 (in dB) 73 | WebRtc_Word16 targetLevelDbfs,// Q0 (in dB) 74 | WebRtc_UWord8 limiterEnable, WebRtc_Word16 analogTarget); 75 | 76 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_MAIN_SOURCE_ANALOG_AGC_H_ 77 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/copy_set_operations.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the implementation of functions 14 | * WebRtcSpl_MemSetW16() 15 | * WebRtcSpl_MemSetW32() 16 | * WebRtcSpl_MemCpyReversedOrder() 17 | * WebRtcSpl_CopyFromEndW16() 18 | * WebRtcSpl_ZerosArrayW16() 19 | * WebRtcSpl_ZerosArrayW32() 20 | * WebRtcSpl_OnesArrayW16() 21 | * WebRtcSpl_OnesArrayW32() 22 | * 23 | * The description header can be found in signal_processing_library.h 24 | * 25 | */ 26 | 27 | #include 28 | #include "signal_processing_library.h" 29 | 30 | 31 | void WebRtcSpl_MemSetW16(WebRtc_Word16 *ptr, WebRtc_Word16 set_value, int length) 32 | { 33 | int j; 34 | WebRtc_Word16 *arrptr = ptr; 35 | 36 | for (j = length; j > 0; j--) 37 | { 38 | *arrptr++ = set_value; 39 | } 40 | } 41 | 42 | void WebRtcSpl_MemSetW32(WebRtc_Word32 *ptr, WebRtc_Word32 set_value, int length) 43 | { 44 | int j; 45 | WebRtc_Word32 *arrptr = ptr; 46 | 47 | for (j = length; j > 0; j--) 48 | { 49 | *arrptr++ = set_value; 50 | } 51 | } 52 | 53 | void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* dest, WebRtc_Word16* source, int length) 54 | { 55 | int j; 56 | WebRtc_Word16* destPtr = dest; 57 | WebRtc_Word16* sourcePtr = source; 58 | 59 | for (j = 0; j < length; j++) 60 | { 61 | *destPtr-- = *sourcePtr++; 62 | } 63 | } 64 | 65 | WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 *vector_in, 66 | WebRtc_Word16 length, 67 | WebRtc_Word16 samples, 68 | WebRtc_Word16 *vector_out) 69 | { 70 | // Copy the last of the input vector to vector_out 71 | WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); 72 | 73 | return samples; 74 | } 75 | 76 | WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) 77 | { 78 | WebRtcSpl_MemSetW16(vector, 0, length); 79 | return length; 80 | } 81 | 82 | WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) 83 | { 84 | WebRtcSpl_MemSetW32(vector, 0, length); 85 | return length; 86 | } 87 | 88 | WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) 89 | { 90 | WebRtc_Word16 i; 91 | WebRtc_Word16 *tmpvec = vector; 92 | for (i = 0; i < length; i++) 93 | { 94 | *tmpvec++ = 1; 95 | } 96 | return length; 97 | } 98 | 99 | WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) 100 | { 101 | WebRtc_Word16 i; 102 | WebRtc_Word32 *tmpvec = vector; 103 | for (i = 0; i < length; i++) 104 | { 105 | *tmpvec++ = 1; 106 | } 107 | return length; 108 | } 109 | -------------------------------------------------------------------------------- /src/ofxEchoCancel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ofxEchoCancel.cpp 3 | * 4 | * Created on: Oct 3, 2013 5 | * Author: arturo 6 | */ 7 | 8 | #include "ofxEchoCancel.h" 9 | 10 | ofxEchoCancel::ofxEchoCancel() 11 | :ap(NULL){ 12 | 13 | } 14 | 15 | ofxEchoCancel::~ofxEchoCancel() { 16 | } 17 | 18 | void ofxEchoCancel::setup(){ 19 | ap = webrtc::AudioProcessing::Create(0); 20 | ap->Initialize(); 21 | ap->set_num_channels(1,1); 22 | ap->set_num_reverse_channels(2); 23 | ap->set_sample_rate_hz(32000); 24 | 25 | ap->echo_cancellation()->Enable(true); 26 | ap->echo_cancellation()->set_suppression_level(webrtc::EchoCancellation::kHighSuppression); 27 | ap->echo_cancellation()->enable_drift_compensation(false); 28 | ap->echo_cancellation()->set_device_sample_rate_hz(44100); 29 | 30 | ap->gain_control()->Enable(true); 31 | ap->gain_control()->set_mode(webrtc::GainControl::kAdaptiveAnalog); 32 | ap->gain_control()->set_analog_level_limits(0, 0x10000U-1); 33 | 34 | ap->noise_suppression()->Enable(true); 35 | ap->noise_suppression()->set_level(webrtc::NoiseSuppression::kVeryHigh); 36 | 37 | ap->high_pass_filter()->Enable(true); 38 | 39 | ap->voice_detection()->Enable(true); 40 | ap->voice_detection()->set_likelihood(webrtc::VoiceDetection::kLowLikelihood); 41 | 42 | parameters.setName("echo cancel"); 43 | parameters.add(echoCancelEnabled.set("echoCancelEnabled",true)); 44 | parameters.add(gainControlEnabled.set("gainControlEnabled",true)); 45 | parameters.add(noiseSuppressionEnabled.set("noiseSuppressionEnabled",true)); 46 | parameters.add(highPassFilterEnabled.set("highPassFilterEnabled",true)); 47 | parameters.add(voiceDetectionEnabled.set("voiceDetectionEnabled",true)); 48 | parameters.add(driftCompensationEnabled.set("driftCompensationEnabled",false)); 49 | 50 | 51 | echoCancelEnabled.addListener(this,&ofxEchoCancel::echoCancelEnabledChanged); 52 | gainControlEnabled.addListener(this,&ofxEchoCancel::gainControlEnabledChanged); 53 | noiseSuppressionEnabled.addListener(this,&ofxEchoCancel::noiseSuppressionEnabledChanged); 54 | highPassFilterEnabled.addListener(this,&ofxEchoCancel::highPassFilterEnabledChanged); 55 | voiceDetectionEnabled.addListener(this,&ofxEchoCancel::voiceDetectionEnabledChanged); 56 | driftCompensationEnabled.addListener(this,&ofxEchoCancel::driftCompensationEnabledChanged); 57 | } 58 | 59 | void ofxEchoCancel::analyzeReverse(webrtc::AudioFrame & frame){ 60 | if(echoCancelEnabled || gainControlEnabled) 61 | ap->AnalyzeReverseStream(&frame); 62 | } 63 | 64 | void ofxEchoCancel::process(webrtc::AudioFrame & frame){ 65 | ap->ProcessStream(&frame); 66 | } 67 | 68 | webrtc::AudioProcessing* ofxEchoCancel::getAudioProcessing(){ 69 | return ap; 70 | } 71 | 72 | void ofxEchoCancel::echoCancelEnabledChanged(bool & enabled){ 73 | ap->echo_cancellation()->Enable(enabled); 74 | } 75 | 76 | void ofxEchoCancel::gainControlEnabledChanged(bool & enabled){ 77 | ap->gain_control()->Enable(enabled); 78 | } 79 | 80 | void ofxEchoCancel::noiseSuppressionEnabledChanged(bool & enabled){ 81 | ap->noise_suppression()->Enable(enabled); 82 | } 83 | 84 | void ofxEchoCancel::highPassFilterEnabledChanged(bool & enabled){ 85 | ap->high_pass_filter()->Enable(enabled); 86 | } 87 | 88 | void ofxEchoCancel::voiceDetectionEnabledChanged(bool & enabled){ 89 | ap->voice_detection()->Enable(enabled); 90 | } 91 | 92 | void ofxEchoCancel::driftCompensationEnabledChanged(bool & enabled){ 93 | ap->echo_cancellation()->enable_drift_compensation(enabled); 94 | } 95 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/filter_ar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_FilterAR(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* a, 21 | int a_length, 22 | G_CONST WebRtc_Word16* x, 23 | int x_length, 24 | WebRtc_Word16* state, 25 | int state_length, 26 | WebRtc_Word16* state_low, 27 | int state_low_length, 28 | WebRtc_Word16* filtered, 29 | WebRtc_Word16* filtered_low, 30 | int filtered_low_length) 31 | { 32 | WebRtc_Word32 o; 33 | WebRtc_Word32 oLOW; 34 | int i, j, stop; 35 | G_CONST WebRtc_Word16* x_ptr = &x[0]; 36 | WebRtc_Word16* filteredFINAL_ptr = filtered; 37 | WebRtc_Word16* filteredFINAL_LOW_ptr = filtered_low; 38 | 39 | for (i = 0; i < x_length; i++) 40 | { 41 | // Calculate filtered[i] and filtered_low[i] 42 | G_CONST WebRtc_Word16* a_ptr = &a[1]; 43 | WebRtc_Word16* filtered_ptr = &filtered[i - 1]; 44 | WebRtc_Word16* filtered_low_ptr = &filtered_low[i - 1]; 45 | WebRtc_Word16* state_ptr = &state[state_length - 1]; 46 | WebRtc_Word16* state_low_ptr = &state_low[state_length - 1]; 47 | 48 | o = (WebRtc_Word32)(*x_ptr++) << 12; 49 | oLOW = (WebRtc_Word32)0; 50 | 51 | stop = (i < a_length) ? i + 1 : a_length; 52 | for (j = 1; j < stop; j++) 53 | { 54 | o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *filtered_ptr--); 55 | oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *filtered_low_ptr--); 56 | } 57 | for (j = i + 1; j < a_length; j++) 58 | { 59 | o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *state_ptr--); 60 | oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *state_low_ptr--); 61 | } 62 | 63 | o += (oLOW >> 12); 64 | *filteredFINAL_ptr = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); 65 | *filteredFINAL_LOW_ptr++ = (WebRtc_Word16)(o - ((WebRtc_Word32)(*filteredFINAL_ptr++) 66 | << 12)); 67 | } 68 | 69 | // Save the filter state 70 | if (x_length >= state_length) 71 | { 72 | WebRtcSpl_CopyFromEndW16(filtered, x_length, a_length - 1, state); 73 | WebRtcSpl_CopyFromEndW16(filtered_low, x_length, a_length - 1, state_low); 74 | } else 75 | { 76 | for (i = 0; i < state_length - x_length; i++) 77 | { 78 | state[i] = state[i + x_length]; 79 | state_low[i] = state_low[i + x_length]; 80 | } 81 | for (i = 0; i < x_length; i++) 82 | { 83 | state[state_length - x_length + i] = filtered[i]; 84 | state[state_length - x_length + i] = filtered_low[i]; 85 | } 86 | } 87 | 88 | return x_length; 89 | } 90 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/source/vad_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This header file includes the macros used in VAD. 14 | */ 15 | 16 | #ifndef WEBRTC_VAD_DEFINES_H_ 17 | #define WEBRTC_VAD_DEFINES_H_ 18 | 19 | #define NUM_CHANNELS 6 // Eight frequency bands 20 | #define NUM_MODELS 2 // Number of Gaussian models 21 | #define NUM_TABLE_VALUES NUM_CHANNELS * NUM_MODELS 22 | 23 | #define MIN_ENERGY 10 24 | #define ALPHA1 6553 // 0.2 in Q15 25 | #define ALPHA2 32439 // 0.99 in Q15 26 | #define NSP_MAX 6 // Maximum number of VAD=1 frames in a row counted 27 | #define MIN_STD 384 // Minimum standard deviation 28 | // Mode 0, Quality thresholds - Different thresholds for the different frame lengths 29 | #define INDIVIDUAL_10MS_Q 24 30 | #define INDIVIDUAL_20MS_Q 21 // (log10(2)*66)<<2 ~=16 31 | #define INDIVIDUAL_30MS_Q 24 32 | 33 | #define TOTAL_10MS_Q 57 34 | #define TOTAL_20MS_Q 48 35 | #define TOTAL_30MS_Q 57 36 | 37 | #define OHMAX1_10MS_Q 8 // Max Overhang 1 38 | #define OHMAX2_10MS_Q 14 // Max Overhang 2 39 | #define OHMAX1_20MS_Q 4 // Max Overhang 1 40 | #define OHMAX2_20MS_Q 7 // Max Overhang 2 41 | #define OHMAX1_30MS_Q 3 42 | #define OHMAX2_30MS_Q 5 43 | 44 | // Mode 1, Low bitrate thresholds - Different thresholds for the different frame lengths 45 | #define INDIVIDUAL_10MS_LBR 37 46 | #define INDIVIDUAL_20MS_LBR 32 47 | #define INDIVIDUAL_30MS_LBR 37 48 | 49 | #define TOTAL_10MS_LBR 100 50 | #define TOTAL_20MS_LBR 80 51 | #define TOTAL_30MS_LBR 100 52 | 53 | #define OHMAX1_10MS_LBR 8 // Max Overhang 1 54 | #define OHMAX2_10MS_LBR 14 // Max Overhang 2 55 | #define OHMAX1_20MS_LBR 4 56 | #define OHMAX2_20MS_LBR 7 57 | 58 | #define OHMAX1_30MS_LBR 3 59 | #define OHMAX2_30MS_LBR 5 60 | 61 | // Mode 2, Very aggressive thresholds - Different thresholds for the different frame lengths 62 | #define INDIVIDUAL_10MS_AGG 82 63 | #define INDIVIDUAL_20MS_AGG 78 64 | #define INDIVIDUAL_30MS_AGG 82 65 | 66 | #define TOTAL_10MS_AGG 285 //580 67 | #define TOTAL_20MS_AGG 260 68 | #define TOTAL_30MS_AGG 285 69 | 70 | #define OHMAX1_10MS_AGG 6 // Max Overhang 1 71 | #define OHMAX2_10MS_AGG 9 // Max Overhang 2 72 | #define OHMAX1_20MS_AGG 3 73 | #define OHMAX2_20MS_AGG 5 74 | 75 | #define OHMAX1_30MS_AGG 2 76 | #define OHMAX2_30MS_AGG 3 77 | 78 | // Mode 3, Super aggressive thresholds - Different thresholds for the different frame lengths 79 | #define INDIVIDUAL_10MS_VAG 94 80 | #define INDIVIDUAL_20MS_VAG 94 81 | #define INDIVIDUAL_30MS_VAG 94 82 | 83 | #define TOTAL_10MS_VAG 1100 //1700 84 | #define TOTAL_20MS_VAG 1050 85 | #define TOTAL_30MS_VAG 1100 86 | 87 | #define OHMAX1_10MS_VAG 6 // Max Overhang 1 88 | #define OHMAX2_10MS_VAG 9 // Max Overhang 2 89 | #define OHMAX1_20MS_VAG 3 90 | #define OHMAX2_20MS_VAG 5 91 | 92 | #define OHMAX1_30MS_VAG 2 93 | #define OHMAX2_30MS_VAG 3 94 | 95 | #endif // WEBRTC_VAD_DEFINES_H_ 96 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/auto_corr_to_refl_coef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_AutoCorrToReflCoef(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32 *R, int use_order, WebRtc_Word16 *K) 21 | { 22 | int i, n; 23 | WebRtc_Word16 tmp; 24 | G_CONST WebRtc_Word32 *rptr; 25 | WebRtc_Word32 L_num, L_den; 26 | WebRtc_Word16 *acfptr, *pptr, *wptr, *p1ptr, *w1ptr, ACF[WEBRTC_SPL_MAX_LPC_ORDER], 27 | P[WEBRTC_SPL_MAX_LPC_ORDER], W[WEBRTC_SPL_MAX_LPC_ORDER]; 28 | 29 | // Initialize loop and pointers. 30 | acfptr = ACF; 31 | rptr = R; 32 | pptr = P; 33 | p1ptr = &P[1]; 34 | w1ptr = &W[1]; 35 | wptr = w1ptr; 36 | 37 | // First loop; n=0. Determine shifting. 38 | tmp = WebRtcSpl_NormW32(*R); 39 | *acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); 40 | *pptr++ = *acfptr++; 41 | 42 | // Initialize ACF, P and W. 43 | for (i = 1; i <= use_order; i++) 44 | { 45 | *acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); 46 | *wptr++ = *acfptr; 47 | *pptr++ = *acfptr++; 48 | } 49 | 50 | // Compute reflection coefficients. 51 | for (n = 1; n <= use_order; n++, K++) 52 | { 53 | tmp = WEBRTC_SPL_ABS_W16(*p1ptr); 54 | if (*P < tmp) 55 | { 56 | for (i = n; i <= use_order; i++) 57 | *K++ = 0; 58 | 59 | return; 60 | } 61 | 62 | // Division: WebRtcSpl_div(tmp, *P) 63 | *K = 0; 64 | if (tmp != 0) 65 | { 66 | L_num = tmp; 67 | L_den = *P; 68 | i = 15; 69 | while (i--) 70 | { 71 | (*K) <<= 1; 72 | L_num <<= 1; 73 | if (L_num >= L_den) 74 | { 75 | L_num -= L_den; 76 | (*K)++; 77 | } 78 | } 79 | if (*p1ptr > 0) 80 | *K = -*K; 81 | } 82 | 83 | // Last iteration; don't do Schur recursion. 84 | if (n == use_order) 85 | return; 86 | 87 | // Schur recursion. 88 | pptr = P; 89 | wptr = w1ptr; 90 | tmp = (WebRtc_Word16)(((WebRtc_Word32)*p1ptr * (WebRtc_Word32)*K + 16384) >> 15); 91 | *pptr = WEBRTC_SPL_ADD_SAT_W16( *pptr, tmp ); 92 | pptr++; 93 | for (i = 1; i <= use_order - n; i++) 94 | { 95 | tmp = (WebRtc_Word16)(((WebRtc_Word32)*wptr * (WebRtc_Word32)*K + 16384) >> 15); 96 | *pptr = WEBRTC_SPL_ADD_SAT_W16( *(pptr+1), tmp ); 97 | pptr++; 98 | tmp = (WebRtc_Word16)(((WebRtc_Word32)*pptr * (WebRtc_Word32)*K + 16384) >> 15); 99 | *wptr = WEBRTC_SPL_ADD_SAT_W16( *wptr, tmp ); 100 | wptr++; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/cos_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the 360 degree cos table. 14 | * 15 | */ 16 | 17 | #include "signal_processing_library.h" 18 | 19 | WebRtc_Word16 WebRtcSpl_kCosTable[] = { 20 | 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, 21 | 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, 22 | 7791, 7745, 7697, 7647, 7595, 7540, 7483, 7424, 7362, 23 | 7299, 7233, 7164, 7094, 7021, 6947, 6870, 6791, 6710, 24 | 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991, 5892, 25 | 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, 26 | 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 27 | 3719, 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667, 28 | 2531, 2395, 2258, 2120, 1981, 1842, 1703, 1563, 1422, 29 | 1281, 1140, 998, 856, 713, 571, 428, 285, 142, 30 | 0, -142, -285, -428, -571, -713, -856, -998, -1140, 31 | -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, 32 | -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591, 33 | -3719, -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698, 34 | -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586, -5690, 35 | -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455, -6542, 36 | -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233, 37 | -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, 38 | -7791, -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067, 39 | -8091, -8112, -8130, -8147, -8160, -8172, -8180, -8187, -8190, 40 | -8191, -8190, -8187, -8180, -8172, -8160, -8147, -8130, -8112, 41 | -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834, 42 | -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, 43 | -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710, 44 | -6627, -6542, -6455, -6366, -6275, -6182, -6087, -5991, -5892, 45 | -5792, -5690, -5586, -5481, -5374, -5265, -5155, -5043, -4930, 46 | -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971, -3845, 47 | -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667, 48 | -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, 49 | -1281, -1140, -998, -856, -713, -571, -428, -285, -142, 50 | 0, 142, 285, 428, 571, 713, 856, 998, 1140, 51 | 1281, 1422, 1563, 1703, 1842, 1981, 2120, 2258, 2395, 52 | 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591, 53 | 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698, 54 | 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586, 5690, 55 | 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542, 56 | 6627, 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233, 57 | 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745, 58 | 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067, 59 | 8091, 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190 60 | }; 61 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/nsx_defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ 13 | 14 | #define ANAL_BLOCKL_MAX 256 // max analysis block length 15 | #define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1 16 | #define SIMULT 3 17 | #define END_STARTUP_LONG 200 18 | #define END_STARTUP_SHORT 50 19 | #define FACTOR_Q16 (WebRtc_Word32)2621440 // 40 in Q16 20 | #define FACTOR_Q7 (WebRtc_Word16)5120 // 40 in Q7 21 | #define FACTOR_Q7_STARTUP (WebRtc_Word16)1024 // 8 in Q7 22 | #define WIDTH_Q8 3 // 0.01 in Q8 (or 25 ) 23 | //PARAMETERS FOR NEW METHOD 24 | #define DD_PR_SNR_Q11 2007 // ~= Q11(0.98) DD update of prior SNR 25 | #define ONE_MINUS_DD_PR_SNR_Q11 41 // DD update of prior SNR 26 | #define SPECT_FLAT_TAVG_Q14 4915 // (0.30) tavg parameter for spectral flatness measure 27 | #define SPECT_DIFF_TAVG_Q8 77 // (0.30) tavg parameter for spectral flatness measure 28 | #define PRIOR_UPDATE_Q14 1638 // Q14(0.1) update parameter of prior model 29 | #define NOISE_UPDATE_Q8 26 // 26 ~= Q8(0.1) update parameter for noise 30 | // probability threshold for noise state in speech/noise likelihood 31 | #define ONE_MINUS_PROB_RANGE_Q8 205 // 205 ~= Q8(0.8) 32 | #define HIST_PAR_EST 1000 // histogram size for estimation of parameters 33 | //FEATURE EXTRACTION CONFIG 34 | //bin size of histogram 35 | #define BIN_SIZE_LRT 10 36 | //scale parameters: multiply dominant peaks of the histograms by scale factor to obtain 37 | // thresholds for prior model 38 | #define FACTOR_1_LRT_DIFF 6 //for LRT and spectral difference (5 times bigger) 39 | //for spectral_flatness: used when noise is flatter than speech (10 times bigger) 40 | #define FACTOR_2_FLAT_Q10 922 41 | //peak limit for spectral flatness (varies between 0 and 1) 42 | #define THRES_PEAK_FLAT 24 // * 2 * BIN_SIZE_FLAT_FX 43 | //limit on spacing of two highest peaks in histogram: spacing determined by bin size 44 | #define LIM_PEAK_SPACE_FLAT_DIFF 4 // * 2 * BIN_SIZE_DIFF_FX 45 | //limit on relevance of second peak: 46 | #define LIM_PEAK_WEIGHT_FLAT_DIFF 2 47 | #define THRES_FLUCT_LRT 10240 //=20 * inst->modelUpdate; fluctuation limit of LRT feat. 48 | //limit on the max and min values for the feature thresholds 49 | #define MAX_FLAT_Q10 38912 // * 2 * BIN_SIZE_FLAT_FX 50 | #define MIN_FLAT_Q10 4096 // * 2 * BIN_SIZE_FLAT_FX 51 | #define MAX_DIFF 100 // * 2 * BIN_SIZE_DIFF_FX 52 | #define MIN_DIFF 16 // * 2 * BIN_SIZE_DIFF_FX 53 | //criteria of weight of histogram peak to accept/reject feature 54 | #define THRES_WEIGHT_FLAT_DIFF 154//(int)(0.3*(inst->modelUpdate)) for flatness and difference 55 | // 56 | #define STAT_UPDATES 9 // Update every 512 = 1 << 9 block 57 | #define ONE_MINUS_GAMMA_PAUSE_Q8 13 // ~= Q8(0.05) update for conservative noise estimate 58 | #define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 3 // ~= Q8(0.01) update for transition and noise region 59 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ 60 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/sin_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the 360 degree sine table. 14 | * 15 | */ 16 | 17 | #include "signal_processing_library.h" 18 | 19 | WebRtc_Word16 WebRtcSpl_kSinTable[] = { 20 | 0, 142, 285, 428, 571, 713, 856, 998, 1140, 21 | 1281, 1422, 1563, 1703, 1842, 1981, 2120, 2258, 2395, 22 | 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591, 23 | 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698, 24 | 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586, 5690, 25 | 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542, 26 | 6627, 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233, 27 | 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745, 28 | 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067, 29 | 8091, 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190, 30 | 8191, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, 31 | 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, 32 | 7791, 7745, 7697, 7647, 7595, 7540, 7483, 7424, 7362, 33 | 7299, 7233, 7164, 7094, 7021, 6947, 6870, 6791, 6710, 34 | 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991, 5892, 35 | 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, 36 | 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 37 | 3719, 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667, 38 | 2531, 2395, 2258, 2120, 1981, 1842, 1703, 1563, 1422, 39 | 1281, 1140, 998, 856, 713, 571, 428, 285, 142, 40 | 0, -142, -285, -428, -571, -713, -856, -998, -1140, 41 | -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, 42 | -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591, 43 | -3719, -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698, 44 | -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586, -5690, 45 | -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455, -6542, 46 | -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233, 47 | -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, 48 | -7791, -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067, 49 | -8091, -8112, -8130, -8147, -8160, -8172, -8180, -8187, -8190, 50 | -8191, -8190, -8187, -8180, -8172, -8160, -8147, -8130, -8112, 51 | -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834, 52 | -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, 53 | -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710, 54 | -6627, -6542, -6455, -6366, -6275, -6182, -6087, -5991, -5892, 55 | -5792, -5690, -5586, -5481, -5374, -5265, -5155, -5043, -4930, 56 | -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971, -3845, 57 | -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667, 58 | -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, 59 | -1281, -1140, -998, -856, -713, -571, -428, -285, -142 60 | }; 61 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/apm_tests.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'variables': { 11 | 'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out', 12 | 'protoc_out_relpath': 'webrtc/audio_processing', 13 | }, 14 | 'targets': [ 15 | { 16 | 'target_name': 'audioproc_unittest', 17 | 'type': 'executable', 18 | 'conditions': [ 19 | ['prefer_fixed_point==1', { 20 | 'defines': ['WEBRTC_APM_UNIT_TEST_FIXED_PROFILE'], 21 | }, { 22 | 'defines': ['WEBRTC_APM_UNIT_TEST_FLOAT_PROFILE'], 23 | }], 24 | ], 25 | 'dependencies': [ 26 | 'audioproc_unittest_proto', 27 | 'audio_processing', 28 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 29 | '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', 30 | '<(webrtc_root)/../test/test.gyp:test_support', 31 | '<(webrtc_root)/../testing/gtest.gyp:gtest', 32 | '<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite', 33 | ], 34 | 'include_dirs': [ 35 | '<(webrtc_root)/../testing/gtest/include', 36 | '<(protoc_out_dir)', 37 | ], 38 | 'sources': [ 39 | 'test/unit_test.cc', 40 | '<(protoc_out_dir)/<(protoc_out_relpath)/unittest.pb.cc', 41 | '<(protoc_out_dir)/<(protoc_out_relpath)/unittest.pb.h', 42 | ], 43 | }, 44 | { 45 | # Protobuf compiler / generate rule for audioproc_unittest 46 | 'target_name': 'audioproc_unittest_proto', 47 | 'type': 'none', 48 | 'variables': { 49 | 'proto_relpath': 50 | '<(webrtc_root)/modules/audio_processing/test', 51 | }, 52 | 'sources': [ 53 | '<(proto_relpath)/unittest.proto', 54 | ], 55 | 'rules': [ 56 | { 57 | 'rule_name': 'genproto', 58 | 'extension': 'proto', 59 | 'inputs': [ 60 | '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', 61 | ], 62 | 'outputs': [ 63 | '<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.cc', 64 | '<(protoc_out_dir)/<(RULE_INPUT_ROOT).pb.h', 65 | ], 66 | 'action': [ 67 | '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', 68 | '--proto_path=<(proto_relpath)', 69 | '<(proto_relpath)/<(RULE_INPUT_NAME)', 70 | '--cpp_out=<(protoc_out_dir)/<(protoc_out_relpath)', 71 | ], 72 | 'message': 'Generating C++ code from <(RULE_INPUT_PATH)', 73 | }, 74 | ], 75 | 'dependencies': [ 76 | '<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protoc#host', 77 | ], 78 | # This target exports a hard dependency because it generates header 79 | # files. 80 | 'hard_dependency': 1, 81 | }, 82 | { 83 | 'target_name': 'audioproc_process_test', 84 | 'type': 'executable', 85 | 'dependencies': [ 86 | 'audio_processing', 87 | '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', 88 | '<(webrtc_root)/../testing/gtest.gyp:gtest', 89 | '<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite', 90 | ], 91 | 'include_dirs': [ 92 | '<(webrtc_root)/../testing/gtest/include', 93 | '<(protoc_out_dir)', 94 | ], 95 | 'sources': [ 96 | 'test/process_test.cc', 97 | ], 98 | }, 99 | ], 100 | } 101 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/interface/noise_suppression.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | typedef struct NsHandleT NsHandle; 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | * This function returns the version number of the code. 24 | * 25 | * Input: 26 | * - version : Pointer to a character array where the version 27 | * info is stored. 28 | * - length : Length of version. 29 | * 30 | * Return value : 0 - Ok 31 | * -1 - Error (probably length is not sufficient) 32 | */ 33 | int WebRtcNs_get_version(char* version, short length); 34 | 35 | 36 | /* 37 | * This function creates an instance to the noise reduction structure 38 | * 39 | * Input: 40 | * - NS_inst : Pointer to noise reduction instance that should be 41 | * created 42 | * 43 | * Output: 44 | * - NS_inst : Pointer to created noise reduction instance 45 | * 46 | * Return value : 0 - Ok 47 | * -1 - Error 48 | */ 49 | int WebRtcNs_Create(NsHandle** NS_inst); 50 | 51 | 52 | /* 53 | * This function frees the dynamic memory of a specified Noise Reduction 54 | * instance. 55 | * 56 | * Input: 57 | * - NS_inst : Pointer to NS instance that should be freed 58 | * 59 | * Return value : 0 - Ok 60 | * -1 - Error 61 | */ 62 | int WebRtcNs_Free(NsHandle* NS_inst); 63 | 64 | 65 | /* 66 | * This function initializes a NS instance 67 | * 68 | * Input: 69 | * - NS_inst : Instance that should be initialized 70 | * - fs : sampling frequency 71 | * 72 | * Output: 73 | * - NS_inst : Initialized instance 74 | * 75 | * Return value : 0 - Ok 76 | * -1 - Error 77 | */ 78 | int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs); 79 | 80 | /* 81 | * This changes the aggressiveness of the noise suppression method. 82 | * 83 | * Input: 84 | * - NS_inst : Instance that should be initialized 85 | * - mode : 0: Mild, 1: Medium , 2: Aggressive 86 | * 87 | * Output: 88 | * - NS_inst : Initialized instance 89 | * 90 | * Return value : 0 - Ok 91 | * -1 - Error 92 | */ 93 | int WebRtcNs_set_policy(NsHandle* NS_inst, int mode); 94 | 95 | 96 | /* 97 | * This functions does Noise Suppression for the inserted speech frame. The 98 | * input and output signals should always be 10ms (80 or 160 samples). 99 | * 100 | * Input 101 | * - NS_inst : NS Instance. Needs to be initiated before call. 102 | * - spframe : Pointer to speech frame buffer for L band 103 | * - spframe_H : Pointer to speech frame buffer for H band 104 | * - fs : sampling frequency 105 | * 106 | * Output: 107 | * - NS_inst : Updated NS instance 108 | * - outframe : Pointer to output frame for L band 109 | * - outframe_H : Pointer to output frame for H band 110 | * 111 | * Return value : 0 - OK 112 | * -1 - Error 113 | */ 114 | int WebRtcNs_Process(NsHandle* NS_inst, 115 | short* spframe, 116 | short* spframe_H, 117 | short* outframe, 118 | short* outframe_H); 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_H_ 125 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/ns/interface/noise_suppression_x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_X_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_X_H_ 13 | 14 | #include "typedefs.h" 15 | 16 | typedef struct NsxHandleT NsxHandle; 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* 23 | * This function returns the version number of the code. 24 | * 25 | * Input: 26 | * - version : Pointer to a character array where the version 27 | * info is stored. 28 | * - length : Length of version. 29 | * 30 | * Return value : 0 - Ok 31 | * -1 - Error (probably length is not sufficient) 32 | */ 33 | int WebRtcNsx_get_version(char* version, short length); 34 | 35 | 36 | /* 37 | * This function creates an instance to the noise reduction structure 38 | * 39 | * Input: 40 | * - nsxInst : Pointer to noise reduction instance that should be 41 | * created 42 | * 43 | * Output: 44 | * - nsxInst : Pointer to created noise reduction instance 45 | * 46 | * Return value : 0 - Ok 47 | * -1 - Error 48 | */ 49 | int WebRtcNsx_Create(NsxHandle** nsxInst); 50 | 51 | 52 | /* 53 | * This function frees the dynamic memory of a specified Noise Suppression 54 | * instance. 55 | * 56 | * Input: 57 | * - nsxInst : Pointer to NS instance that should be freed 58 | * 59 | * Return value : 0 - Ok 60 | * -1 - Error 61 | */ 62 | int WebRtcNsx_Free(NsxHandle* nsxInst); 63 | 64 | 65 | /* 66 | * This function initializes a NS instance 67 | * 68 | * Input: 69 | * - nsxInst : Instance that should be initialized 70 | * - fs : sampling frequency 71 | * 72 | * Output: 73 | * - nsxInst : Initialized instance 74 | * 75 | * Return value : 0 - Ok 76 | * -1 - Error 77 | */ 78 | int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs); 79 | 80 | /* 81 | * This changes the aggressiveness of the noise suppression method. 82 | * 83 | * Input: 84 | * - nsxInst : Instance that should be initialized 85 | * - mode : 0: Mild, 1: Medium , 2: Aggressive 86 | * 87 | * Output: 88 | * - nsxInst : Initialized instance 89 | * 90 | * Return value : 0 - Ok 91 | * -1 - Error 92 | */ 93 | int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode); 94 | 95 | /* 96 | * This functions does noise suppression for the inserted speech frame. The 97 | * input and output signals should always be 10ms (80 or 160 samples). 98 | * 99 | * Input 100 | * - nsxInst : NSx instance. Needs to be initiated before call. 101 | * - speechFrame : Pointer to speech frame buffer for L band 102 | * - speechFrameHB : Pointer to speech frame buffer for H band 103 | * - fs : sampling frequency 104 | * 105 | * Output: 106 | * - nsxInst : Updated NSx instance 107 | * - outFrame : Pointer to output frame for L band 108 | * - outFrameHB : Pointer to output frame for H band 109 | * 110 | * Return value : 0 - OK 111 | * -1 - Error 112 | */ 113 | int WebRtcNsx_Process(NsxHandle* nsxInst, 114 | short* speechFrame, 115 | short* speechFrameHB, 116 | short* outFrame, 117 | short* outFrameHB); 118 | 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_INTERFACE_NOISE_SUPPRESSION_X_H_ 124 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/vad/main/test/unit_test/unit_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file includes the implementation of the VAD unit tests. 14 | */ 15 | 16 | #include 17 | #include "unit_test.h" 18 | #include "webrtc_vad.h" 19 | 20 | 21 | class VadEnvironment : public ::testing::Environment { 22 | public: 23 | virtual void SetUp() { 24 | } 25 | 26 | virtual void TearDown() { 27 | } 28 | }; 29 | 30 | VadTest::VadTest() 31 | { 32 | } 33 | 34 | void VadTest::SetUp() { 35 | } 36 | 37 | void VadTest::TearDown() { 38 | } 39 | 40 | TEST_F(VadTest, ApiTest) { 41 | VadInst *vad_inst; 42 | int i, j, k; 43 | short zeros[960]; 44 | short speech[960]; 45 | char version[32]; 46 | 47 | // Valid test cases 48 | int fs[3] = {8000, 16000, 32000}; 49 | int nMode[4] = {0, 1, 2, 3}; 50 | int framelen[3][3] = {{80, 160, 240}, 51 | {160, 320, 480}, {320, 640, 960}} ; 52 | int vad_counter = 0; 53 | 54 | memset(zeros, 0, sizeof(short) * 960); 55 | memset(speech, 1, sizeof(short) * 960); 56 | speech[13] = 1374; 57 | speech[73] = -3747; 58 | 59 | 60 | 61 | // WebRtcVad_get_version() 62 | WebRtcVad_get_version(version); 63 | //printf("API Test for %s\n", version); 64 | 65 | // Null instance tests 66 | EXPECT_EQ(-1, WebRtcVad_Create(NULL)); 67 | EXPECT_EQ(-1, WebRtcVad_Init(NULL)); 68 | EXPECT_EQ(-1, WebRtcVad_Assign(NULL, NULL)); 69 | EXPECT_EQ(-1, WebRtcVad_Free(NULL)); 70 | EXPECT_EQ(-1, WebRtcVad_set_mode(NULL, nMode[0])); 71 | EXPECT_EQ(-1, WebRtcVad_Process(NULL, fs[0], speech, framelen[0][0])); 72 | 73 | 74 | EXPECT_EQ(WebRtcVad_Create(&vad_inst), 0); 75 | 76 | // Not initialized tests 77 | EXPECT_EQ(-1, WebRtcVad_Process(vad_inst, fs[0], speech, framelen[0][0])); 78 | EXPECT_EQ(-1, WebRtcVad_set_mode(vad_inst, nMode[0])); 79 | 80 | // WebRtcVad_Init() tests 81 | EXPECT_EQ(WebRtcVad_Init(vad_inst), 0); 82 | 83 | // WebRtcVad_set_mode() tests 84 | EXPECT_EQ(-1, WebRtcVad_set_mode(vad_inst, -1)); 85 | EXPECT_EQ(-1, WebRtcVad_set_mode(vad_inst, 4)); 86 | 87 | for (i = 0; i < sizeof(nMode)/sizeof(nMode[0]); i++) { 88 | EXPECT_EQ(WebRtcVad_set_mode(vad_inst, nMode[i]), 0); 89 | } 90 | 91 | // WebRtcVad_Process() tests 92 | EXPECT_EQ(-1, WebRtcVad_Process(vad_inst, fs[0], NULL, framelen[0][0])); 93 | EXPECT_EQ(-1, WebRtcVad_Process(vad_inst, 12000, speech, framelen[0][0])); 94 | EXPECT_EQ(-1, WebRtcVad_Process(vad_inst, fs[0], speech, framelen[1][1])); 95 | EXPECT_EQ(WebRtcVad_Process(vad_inst, fs[0], zeros, framelen[0][0]), 0); 96 | for (i = 0; i < sizeof(fs)/sizeof(fs[0]); i++) { 97 | for (j = 0; j < sizeof(framelen[0])/sizeof(framelen[0][0]); j++) { 98 | for (k = 0; k < sizeof(nMode)/sizeof(nMode[0]); k++) { 99 | EXPECT_EQ(WebRtcVad_set_mode(vad_inst, nMode[k]), 0); 100 | // printf("%d\n", WebRtcVad_Process(vad_inst, fs[i], speech, framelen[i][j])); 101 | if (vad_counter < 9) 102 | { 103 | EXPECT_EQ(WebRtcVad_Process(vad_inst, fs[i], speech, framelen[i][j]), 1); 104 | } else 105 | { 106 | EXPECT_EQ(WebRtcVad_Process(vad_inst, fs[i], speech, framelen[i][j]), 0); 107 | } 108 | vad_counter++; 109 | } 110 | } 111 | } 112 | 113 | EXPECT_EQ(0, WebRtcVad_Free(vad_inst)); 114 | 115 | } 116 | 117 | int main(int argc, char** argv) { 118 | ::testing::InitGoogleTest(&argc, argv); 119 | VadEnvironment* env = new VadEnvironment; 120 | ::testing::AddGlobalTestEnvironment(env); 121 | 122 | return RUN_ALL_TESTS(); 123 | } 124 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/audio_processing_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_ 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_ 13 | 14 | #include 15 | #include 16 | 17 | #include "audio_processing.h" 18 | 19 | namespace webrtc { 20 | namespace audioproc { 21 | class Event; 22 | } // audioproc 23 | class AudioBuffer; 24 | class CriticalSectionWrapper; 25 | class EchoCancellationImpl; 26 | class EchoControlMobileImpl; 27 | class FileWrapper; 28 | class GainControlImpl; 29 | class HighPassFilterImpl; 30 | class LevelEstimatorImpl; 31 | class NoiseSuppressionImpl; 32 | class ProcessingComponent; 33 | class VoiceDetectionImpl; 34 | 35 | class AudioProcessingImpl : public AudioProcessing { 36 | public: 37 | enum { 38 | kSampleRate8kHz = 8000, 39 | kSampleRate16kHz = 16000, 40 | kSampleRate32kHz = 32000 41 | }; 42 | 43 | explicit AudioProcessingImpl(int id); 44 | virtual ~AudioProcessingImpl(); 45 | 46 | CriticalSectionWrapper* crit() const; 47 | 48 | int split_sample_rate_hz() const; 49 | bool was_stream_delay_set() const; 50 | 51 | // AudioProcessing methods. 52 | virtual int Initialize(); 53 | virtual int InitializeLocked(); 54 | virtual int set_sample_rate_hz(int rate); 55 | virtual int sample_rate_hz() const; 56 | virtual int set_num_channels(int input_channels, int output_channels); 57 | virtual int num_input_channels() const; 58 | virtual int num_output_channels() const; 59 | virtual int set_num_reverse_channels(int channels); 60 | virtual int num_reverse_channels() const; 61 | virtual int ProcessStream(AudioFrame* frame); 62 | virtual int AnalyzeReverseStream(AudioFrame* frame); 63 | virtual int set_stream_delay_ms(int delay); 64 | virtual int stream_delay_ms() const; 65 | virtual int StartDebugRecording(const char filename[kMaxFilenameSize]); 66 | virtual int StopDebugRecording(); 67 | virtual EchoCancellation* echo_cancellation() const; 68 | virtual EchoControlMobile* echo_control_mobile() const; 69 | virtual GainControl* gain_control() const; 70 | virtual HighPassFilter* high_pass_filter() const; 71 | virtual LevelEstimator* level_estimator() const; 72 | virtual NoiseSuppression* noise_suppression() const; 73 | virtual VoiceDetection* voice_detection() const; 74 | 75 | // Module methods. 76 | virtual WebRtc_Word32 Version(WebRtc_Word8* version, 77 | WebRtc_UWord32& remainingBufferInBytes, 78 | WebRtc_UWord32& position) const; 79 | virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); 80 | 81 | private: 82 | int WriteMessageToDebugFile(); 83 | int WriteInitMessage(); 84 | 85 | int id_; 86 | 87 | EchoCancellationImpl* echo_cancellation_; 88 | EchoControlMobileImpl* echo_control_mobile_; 89 | GainControlImpl* gain_control_; 90 | HighPassFilterImpl* high_pass_filter_; 91 | LevelEstimatorImpl* level_estimator_; 92 | NoiseSuppressionImpl* noise_suppression_; 93 | VoiceDetectionImpl* voice_detection_; 94 | 95 | std::list component_list_; 96 | 97 | FileWrapper* debug_file_; 98 | audioproc::Event* event_msg_; // Protobuf message. 99 | std::string event_str_; // Memory for protobuf serialization. 100 | CriticalSectionWrapper* crit_; 101 | 102 | AudioBuffer* render_audio_; 103 | AudioBuffer* capture_audio_; 104 | 105 | int sample_rate_hz_; 106 | int split_sample_rate_hz_; 107 | int samples_per_channel_; 108 | int stream_delay_ms_; 109 | bool was_stream_delay_set_; 110 | 111 | int num_reverse_channels_; 112 | int num_input_channels_; 113 | int num_output_channels_; 114 | }; 115 | } // namespace webrtc 116 | 117 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_AUDIO_PROCESSING_IMPL_H_ 118 | -------------------------------------------------------------------------------- /addon_config.mk: -------------------------------------------------------------------------------- 1 | # All variables and this file are optional, if they are not present the PG and the 2 | # makefiles will try to parse the correct values from the file system. 3 | # 4 | # Variables that specify exclusions can use % as a wildcard to specify that anything in 5 | # that position will match. A partial path can also be specified to, for example, exclude 6 | # a whole folder from the parsed paths from the file system 7 | # 8 | # Variables can be specified using = or += 9 | # = will clear the contents of that variable both specified from the file or the ones parsed 10 | # from the file system 11 | # += will add the values to the previous ones in the file or the ones parsed from the file 12 | # system 13 | # 14 | # The PG can be used to detect errors in this file, just create a new project with this addon 15 | # and the PG will write to the console the kind of error and in which line it is 16 | 17 | meta: 18 | ADDON_NAME = ofxEchoCancel 19 | ADDON_DESCRIPTION = Addon for echo and noise cancellation based on google's webrtc code for audio processing 20 | ADDON_AUTHOR = Arturo Castro 21 | ADDON_TAGS = "audio" "echo cancel" "noise cancel" 22 | ADDON_URL = http://github.com/arturoc/ofxEchoCancel 23 | 24 | common: 25 | # dependencies with other addons, a list of them separated by spaces 26 | # or use += in several lines 27 | ADDON_DEPENDENCIES = 28 | 29 | # include search paths, this will be usually parsed from the file system 30 | # but if the addon or addon libraries need special search paths they can be 31 | # specified here separated by spaces or one per line using += 32 | # ADDON_INCLUDES = 33 | 34 | # any special flag that should be passed to the compiler when using this 35 | # addon 36 | ADDON_CFLAGS = -DWEBRTC_NS_FLOAT -DNDEBUG 37 | 38 | # any special flag that should be passed to the linker when using this 39 | # addon, also used for system libraries with -lname 40 | # ADDON_LDFLAGS = 41 | 42 | # linux only, any library that should be included in the project using 43 | # pkg-config 44 | # ADDON_PKG_CONFIG_LIBRARIES = 45 | 46 | # osx/iOS only, any framework that should be included in the project 47 | # ADDON_FRAMEWORKS = 48 | 49 | # source files, these will be usually parsed from the file system looking 50 | # in the src folders in libs and the root of the addon. if your addon needs 51 | # to include files in different places or a different set of files per platform 52 | # they can be specified here 53 | # ADDON_SOURCES = 54 | 55 | # some addons need resources to be copied to the bin/data folder of the project 56 | # specify here any files that need to be copied, you can use wildcards like * and ? 57 | # ADDON_DATA = 58 | 59 | # when parsing the file system looking for libraries exclude this for all or 60 | # a specific platform 61 | # ADDON_LIBS_EXCLUDE = 62 | 63 | # when parsing the file system looking for sources exclude this for all or 64 | # a specific platform 65 | ADDON_SOURCES_EXCLUDE = libs/webrtc-audio-processing/src/modules/audio_processing/test/% 66 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/common_audio/vad/main/test/% 67 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/test/% 68 | 69 | # when parsing the file system looking for include paths exclude this for all or 70 | # a specific platform 71 | # ADDON_INCLUDES_EXCLUDE = 72 | 73 | linux: 74 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 75 | 76 | linux64: 77 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 78 | 79 | linuxarmv6l: 80 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 81 | 82 | linuxarmv7l: 83 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 84 | 85 | win_cb: 86 | 87 | vs: 88 | 89 | android/armeabi: 90 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 91 | 92 | android/armeabi-v7a: 93 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 94 | 95 | osx: 96 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 97 | 98 | ios: 99 | ADDON_SOURCES_EXCLUDE += libs/webrtc-audio-processing/src/system_wrappers/source/critical_section_windows.cc 100 | 101 | 102 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/interface/spl_inl_armv7.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | // This header file includes the inline functions for ARM processors in 13 | // the fix point signal processing library. 14 | 15 | #ifndef WEBRTC_SPL_SPL_INL_ARMV7_H_ 16 | #define WEBRTC_SPL_SPL_INL_ARMV7_H_ 17 | 18 | static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_32_RSFT16(WebRtc_Word16 a, 19 | WebRtc_Word32 b) { 20 | WebRtc_Word32 tmp; 21 | __asm__("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a)); 22 | return tmp; 23 | } 24 | 25 | static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32(WebRtc_Word16 a, 26 | WebRtc_Word16 b, 27 | WebRtc_Word32 c) { 28 | WebRtc_Word32 tmp; 29 | __asm__("pkhbt %0, %1, %2, lsl #16" : "=r"(tmp) : "r"(b), "r"(a)); 30 | __asm__("smmul %0, %1, %2":"=r"(tmp):"r"(tmp), "r"(c)); 31 | return tmp; 32 | } 33 | 34 | static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32BI(WebRtc_Word32 a, 35 | WebRtc_Word32 b) { 36 | WebRtc_Word32 tmp; 37 | __asm__("smmul %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); 38 | return tmp; 39 | } 40 | 41 | static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_16(WebRtc_Word16 a, 42 | WebRtc_Word16 b) { 43 | WebRtc_Word32 tmp; 44 | __asm__("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); 45 | return tmp; 46 | } 47 | 48 | static __inline int32_t WebRtc_MulAccumW16(int16_t a, 49 | int16_t b, 50 | int32_t c) { 51 | int32_t tmp = 0; 52 | __asm__("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c)); 53 | return tmp; 54 | } 55 | 56 | static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, 57 | WebRtc_Word16 b) { 58 | WebRtc_Word32 s_sum; 59 | 60 | __asm__("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b)); 61 | 62 | return (WebRtc_Word16) s_sum; 63 | } 64 | 65 | static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, 66 | WebRtc_Word32 l_var2) { 67 | WebRtc_Word32 l_sum; 68 | 69 | __asm__("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2)); 70 | 71 | return l_sum; 72 | } 73 | 74 | static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, 75 | WebRtc_Word16 var2) { 76 | WebRtc_Word32 s_sub; 77 | 78 | __asm__("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2)); 79 | 80 | return (WebRtc_Word16)s_sub; 81 | } 82 | 83 | static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, 84 | WebRtc_Word32 l_var2) { 85 | WebRtc_Word32 l_sub; 86 | 87 | __asm__("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2)); 88 | 89 | return l_sub; 90 | } 91 | 92 | static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { 93 | WebRtc_Word32 tmp; 94 | 95 | __asm__("clz %0, %1":"=r"(tmp):"r"(n)); 96 | 97 | return (WebRtc_Word16)(32 - tmp); 98 | } 99 | 100 | static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { 101 | WebRtc_Word32 tmp; 102 | 103 | if (a <= 0) a ^= 0xFFFFFFFF; 104 | 105 | __asm__("clz %0, %1":"=r"(tmp):"r"(a)); 106 | 107 | return tmp - 1; 108 | } 109 | 110 | static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { 111 | int tmp; 112 | 113 | if (a == 0) return 0; 114 | 115 | __asm__("clz %0, %1":"=r"(tmp):"r"(a)); 116 | 117 | return tmp; 118 | } 119 | 120 | static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { 121 | WebRtc_Word32 tmp; 122 | 123 | if (a <= 0) a ^= 0xFFFFFFFF; 124 | 125 | __asm__("clz %0, %1":"=r"(tmp):"r"(a)); 126 | 127 | return tmp - 17; 128 | } 129 | 130 | static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { 131 | WebRtc_Word16 out16; 132 | 133 | __asm__("ssat %r0, #16, %r1" : "=r"(out16) : "r"(value32)); 134 | 135 | return out16; 136 | } 137 | #endif // WEBRTC_SPL_SPL_INL_ARMV7_H_ 138 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/auto_correlation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains the function WebRtcSpl_AutoCorrelation(). 14 | * The description header can be found in signal_processing_library.h 15 | * 16 | */ 17 | 18 | #include "signal_processing_library.h" 19 | 20 | int WebRtcSpl_AutoCorrelation(G_CONST WebRtc_Word16* in_vector, 21 | int in_vector_length, 22 | int order, 23 | WebRtc_Word32* result, 24 | int* scale) 25 | { 26 | WebRtc_Word32 sum; 27 | int i, j; 28 | WebRtc_Word16 smax; // Sample max 29 | G_CONST WebRtc_Word16* xptr1; 30 | G_CONST WebRtc_Word16* xptr2; 31 | WebRtc_Word32* resultptr; 32 | int scaling = 0; 33 | 34 | #ifdef _ARM_OPT_ 35 | #pragma message("NOTE: _ARM_OPT_ optimizations are used") 36 | WebRtc_Word16 loops4; 37 | #endif 38 | 39 | if (order < 0) 40 | order = in_vector_length; 41 | 42 | // Find the max. sample 43 | smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length); 44 | 45 | // In order to avoid overflow when computing the sum we should scale the samples so that 46 | // (in_vector_length * smax * smax) will not overflow. 47 | 48 | if (smax == 0) 49 | { 50 | scaling = 0; 51 | } else 52 | { 53 | int nbits = WebRtcSpl_GetSizeInBits(in_vector_length); // # of bits in the sum loop 54 | int t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); // # of bits to normalize smax 55 | 56 | if (t > nbits) 57 | { 58 | scaling = 0; 59 | } else 60 | { 61 | scaling = nbits - t; 62 | } 63 | 64 | } 65 | 66 | resultptr = result; 67 | 68 | // Perform the actual correlation calculation 69 | for (i = 0; i < order + 1; i++) 70 | { 71 | int loops = (in_vector_length - i); 72 | sum = 0; 73 | xptr1 = in_vector; 74 | xptr2 = &in_vector[i]; 75 | #ifndef _ARM_OPT_ 76 | for (j = loops; j > 0; j--) 77 | { 78 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1++, *xptr2++, scaling); 79 | } 80 | #else 81 | loops4 = (loops >> 2) << 2; 82 | 83 | if (scaling == 0) 84 | { 85 | for (j = 0; j < loops4; j = j + 4) 86 | { 87 | sum += WEBRTC_SPL_MUL_16_16(*xptr1, *xptr2); 88 | xptr1++; 89 | xptr2++; 90 | sum += WEBRTC_SPL_MUL_16_16(*xptr1, *xptr2); 91 | xptr1++; 92 | xptr2++; 93 | sum += WEBRTC_SPL_MUL_16_16(*xptr1, *xptr2); 94 | xptr1++; 95 | xptr2++; 96 | sum += WEBRTC_SPL_MUL_16_16(*xptr1, *xptr2); 97 | xptr1++; 98 | xptr2++; 99 | } 100 | 101 | for (j = loops4; j < loops; j++) 102 | { 103 | sum += WEBRTC_SPL_MUL_16_16(*xptr1, *xptr2); 104 | xptr1++; 105 | xptr2++; 106 | } 107 | } 108 | else 109 | { 110 | for (j = 0; j < loops4; j = j + 4) 111 | { 112 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1, *xptr2, scaling); 113 | xptr1++; 114 | xptr2++; 115 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1, *xptr2, scaling); 116 | xptr1++; 117 | xptr2++; 118 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1, *xptr2, scaling); 119 | xptr1++; 120 | xptr2++; 121 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1, *xptr2, scaling); 122 | xptr1++; 123 | xptr2++; 124 | } 125 | 126 | for (j = loops4; j < loops; j++) 127 | { 128 | sum += WEBRTC_SPL_MUL_16_16_RSFT(*xptr1, *xptr2, scaling); 129 | xptr1++; 130 | xptr2++; 131 | } 132 | } 133 | 134 | #endif 135 | *resultptr++ = sum; 136 | } 137 | 138 | *scale = scaling; 139 | 140 | return order + 1; 141 | } 142 | -------------------------------------------------------------------------------- /.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/source/division_operations.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | /* 13 | * This file contains implementations of the divisions 14 | * WebRtcSpl_DivU32U16() 15 | * WebRtcSpl_DivW32W16() 16 | * WebRtcSpl_DivW32W16ResW16() 17 | * WebRtcSpl_DivResultInQ31() 18 | * WebRtcSpl_DivW32HiLow() 19 | * 20 | * The description header can be found in signal_processing_library.h 21 | * 22 | */ 23 | 24 | #include "signal_processing_library.h" 25 | 26 | WebRtc_UWord32 WebRtcSpl_DivU32U16(WebRtc_UWord32 num, WebRtc_UWord16 den) 27 | { 28 | // Guard against division with 0 29 | if (den != 0) 30 | { 31 | return (WebRtc_UWord32)(num / den); 32 | } else 33 | { 34 | return (WebRtc_UWord32)0xFFFFFFFF; 35 | } 36 | } 37 | 38 | WebRtc_Word32 WebRtcSpl_DivW32W16(WebRtc_Word32 num, WebRtc_Word16 den) 39 | { 40 | // Guard against division with 0 41 | if (den != 0) 42 | { 43 | return (WebRtc_Word32)(num / den); 44 | } else 45 | { 46 | return (WebRtc_Word32)0x7FFFFFFF; 47 | } 48 | } 49 | 50 | WebRtc_Word16 WebRtcSpl_DivW32W16ResW16(WebRtc_Word32 num, WebRtc_Word16 den) 51 | { 52 | // Guard against division with 0 53 | if (den != 0) 54 | { 55 | return (WebRtc_Word16)(num / den); 56 | } else 57 | { 58 | return (WebRtc_Word16)0x7FFF; 59 | } 60 | } 61 | 62 | WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den) 63 | { 64 | WebRtc_Word32 L_num = num; 65 | WebRtc_Word32 L_den = den; 66 | WebRtc_Word32 div = 0; 67 | int k = 31; 68 | int change_sign = 0; 69 | 70 | if (num == 0) 71 | return 0; 72 | 73 | if (num < 0) 74 | { 75 | change_sign++; 76 | L_num = -num; 77 | } 78 | if (den < 0) 79 | { 80 | change_sign++; 81 | L_den = -den; 82 | } 83 | while (k--) 84 | { 85 | div <<= 1; 86 | L_num <<= 1; 87 | if (L_num >= L_den) 88 | { 89 | L_num -= L_den; 90 | div++; 91 | } 92 | } 93 | if (change_sign == 1) 94 | { 95 | div = -div; 96 | } 97 | return div; 98 | } 99 | 100 | WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi, 101 | WebRtc_Word16 den_low) 102 | { 103 | WebRtc_Word16 approx, tmp_hi, tmp_low, num_hi, num_low; 104 | WebRtc_Word32 tmpW32; 105 | 106 | approx = (WebRtc_Word16)WebRtcSpl_DivW32W16((WebRtc_Word32)0x1FFFFFFF, den_hi); 107 | // result in Q14 (Note: 3FFFFFFF = 0.5 in Q30) 108 | 109 | // tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30) 110 | tmpW32 = (WEBRTC_SPL_MUL_16_16(den_hi, approx) << 1) 111 | + ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1); 112 | // tmpW32 = den * approx 113 | 114 | tmpW32 = (WebRtc_Word32)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx)) 115 | 116 | // Store tmpW32 in hi and low format 117 | tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); 118 | tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 119 | - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); 120 | 121 | // tmpW32 = 1/den in Q29 122 | tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx) 123 | >> 15)) << 1); 124 | 125 | // 1/den in hi and low format 126 | tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); 127 | tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 128 | - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); 129 | 130 | // Store num in hi and low format 131 | num_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(num, 16); 132 | num_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((num 133 | - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)num_hi, 16)), 1); 134 | 135 | // num * (1/den) by 32 bit multiplication (result in Q28) 136 | 137 | tmpW32 = (WEBRTC_SPL_MUL_16_16(num_hi, tmp_hi) + (WEBRTC_SPL_MUL_16_16(num_hi, tmp_low) 138 | >> 15) + (WEBRTC_SPL_MUL_16_16(num_low, tmp_hi) >> 15)); 139 | 140 | // Put result in Q31 (convert from Q28) 141 | tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); 142 | 143 | return tmpW32; 144 | } 145 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/modules/audio_processing/audio_processing.gypi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'variables': { 11 | 'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out', 12 | 'protoc_out_relpath': 'webrtc/audio_processing', 13 | }, 14 | 'targets': [ 15 | { 16 | 'target_name': 'audio_processing', 17 | 'type': '<(library)', 18 | 'conditions': [ 19 | ['prefer_fixed_point==1', { 20 | 'dependencies': ['ns_fix'], 21 | 'defines': ['WEBRTC_NS_FIXED'], 22 | }, { 23 | 'dependencies': ['ns'], 24 | 'defines': ['WEBRTC_NS_FLOAT'], 25 | }], 26 | ['build_with_chromium==1', { 27 | 'dependencies': [ 28 | '<(webrtc_root)/../protobuf/protobuf.gyp:protobuf_lite', 29 | ], 30 | }, { 31 | 'dependencies': [ 32 | '<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protobuf_lite', 33 | ], 34 | }], 35 | ], 36 | 'dependencies': [ 37 | 'debug_proto', 38 | 'aec', 39 | 'aecm', 40 | 'agc', 41 | '<(webrtc_root)/common_audio/common_audio.gyp:spl', 42 | '<(webrtc_root)/common_audio/common_audio.gyp:vad', 43 | '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', 44 | ], 45 | 'include_dirs': [ 46 | 'interface', 47 | '../interface', 48 | '<(protoc_out_dir)', 49 | ], 50 | 'direct_dependent_settings': { 51 | 'include_dirs': [ 52 | 'interface', 53 | '../interface', 54 | ], 55 | }, 56 | 'sources': [ 57 | 'interface/audio_processing.h', 58 | 'audio_buffer.cc', 59 | 'audio_buffer.h', 60 | 'audio_processing_impl.cc', 61 | 'audio_processing_impl.h', 62 | 'echo_cancellation_impl.cc', 63 | 'echo_cancellation_impl.h', 64 | 'echo_control_mobile_impl.cc', 65 | 'echo_control_mobile_impl.h', 66 | 'gain_control_impl.cc', 67 | 'gain_control_impl.h', 68 | 'high_pass_filter_impl.cc', 69 | 'high_pass_filter_impl.h', 70 | 'level_estimator_impl.cc', 71 | 'level_estimator_impl.h', 72 | 'noise_suppression_impl.cc', 73 | 'noise_suppression_impl.h', 74 | 'splitting_filter.cc', 75 | 'splitting_filter.h', 76 | 'processing_component.cc', 77 | 'processing_component.h', 78 | 'voice_detection_impl.cc', 79 | 'voice_detection_impl.h', 80 | '<(protoc_out_dir)/<(protoc_out_relpath)/debug.pb.cc', 81 | '<(protoc_out_dir)/<(protoc_out_relpath)/debug.pb.h', 82 | ], 83 | }, 84 | { 85 | # Protobuf compiler / generate rule for audio_processing 86 | 'target_name': 'debug_proto', 87 | 'type': 'none', 88 | 'variables': { 89 | 'proto_relpath': '<(webrtc_root)/modules/audio_processing', 90 | }, 91 | 'sources': [ 92 | '<(proto_relpath)/debug.proto', 93 | ], 94 | 'rules': [ 95 | { 96 | 'rule_name': 'genproto', 97 | 'extension': 'proto', 98 | 'inputs': [ 99 | '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', 100 | ], 101 | 'outputs': [ 102 | '<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.cc', 103 | '<(protoc_out_dir)/<(protoc_out_relpath)/<(RULE_INPUT_ROOT).pb.h', 104 | ], 105 | 'action': [ 106 | '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', 107 | '--proto_path=<(proto_relpath)', 108 | '<(proto_relpath)/<(RULE_INPUT_NAME)', 109 | '--cpp_out=<(protoc_out_dir)/<(protoc_out_relpath)', 110 | ], 111 | 'message': 'Generating C++ code from <(RULE_INPUT_PATH)', 112 | }, 113 | ], 114 | 'conditions': [ 115 | ['build_with_chromium==1', { 116 | 'dependencies': [ 117 | '<(webrtc_root)/../protobuf/protobuf.gyp:protoc#host', 118 | ], 119 | }, { 120 | 'dependencies': [ 121 | '<(webrtc_root)/../third_party/protobuf/protobuf.gyp:protoc#host', 122 | ], 123 | }], 124 | ], 125 | # This target exports a hard dependency because it generates header 126 | # files. 127 | 'hard_dependency': 1, 128 | }, 129 | ], 130 | } 131 | -------------------------------------------------------------------------------- /libs/webrtc-audio-processing/src/common_audio/signal_processing_library/main/interface/spl_inl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | 12 | // This header file includes the inline functions in 13 | // the fix point signal processing library. 14 | 15 | #ifndef WEBRTC_SPL_SPL_INL_H_ 16 | #define WEBRTC_SPL_SPL_INL_H_ 17 | 18 | #ifdef WEBRTC_ARCH_ARM_V7A 19 | #include "spl_inl_armv7.h" 20 | #else 21 | 22 | static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { 23 | WebRtc_Word16 out16 = (WebRtc_Word16) value32; 24 | 25 | if (value32 > 32767) 26 | out16 = 32767; 27 | else if (value32 < -32768) 28 | out16 = -32768; 29 | 30 | return out16; 31 | } 32 | 33 | static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, 34 | WebRtc_Word16 b) { 35 | return WebRtcSpl_SatW32ToW16((WebRtc_Word32) a + (WebRtc_Word32) b); 36 | } 37 | 38 | static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, 39 | WebRtc_Word32 l_var2) { 40 | WebRtc_Word32 l_sum; 41 | 42 | // perform long addition 43 | l_sum = l_var1 + l_var2; 44 | 45 | // check for under or overflow 46 | if (WEBRTC_SPL_IS_NEG(l_var1)) { 47 | if (WEBRTC_SPL_IS_NEG(l_var2) && !WEBRTC_SPL_IS_NEG(l_sum)) { 48 | l_sum = (WebRtc_Word32)0x80000000; 49 | } 50 | } else { 51 | if (!WEBRTC_SPL_IS_NEG(l_var2) && WEBRTC_SPL_IS_NEG(l_sum)) { 52 | l_sum = (WebRtc_Word32)0x7FFFFFFF; 53 | } 54 | } 55 | 56 | return l_sum; 57 | } 58 | 59 | static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, 60 | WebRtc_Word16 var2) { 61 | return WebRtcSpl_SatW32ToW16((WebRtc_Word32) var1 - (WebRtc_Word32) var2); 62 | } 63 | 64 | static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, 65 | WebRtc_Word32 l_var2) { 66 | WebRtc_Word32 l_diff; 67 | 68 | // perform subtraction 69 | l_diff = l_var1 - l_var2; 70 | 71 | // check for underflow 72 | if ((l_var1 < 0) && (l_var2 > 0) && (l_diff > 0)) 73 | l_diff = (WebRtc_Word32)0x80000000; 74 | // check for overflow 75 | if ((l_var1 > 0) && (l_var2 < 0) && (l_diff < 0)) 76 | l_diff = (WebRtc_Word32)0x7FFFFFFF; 77 | 78 | return l_diff; 79 | } 80 | 81 | static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { 82 | int bits; 83 | 84 | if (0xFFFF0000 & n) { 85 | bits = 16; 86 | } else { 87 | bits = 0; 88 | } 89 | if (0x0000FF00 & (n >> bits)) bits += 8; 90 | if (0x000000F0 & (n >> bits)) bits += 4; 91 | if (0x0000000C & (n >> bits)) bits += 2; 92 | if (0x00000002 & (n >> bits)) bits += 1; 93 | if (0x00000001 & (n >> bits)) bits += 1; 94 | 95 | return bits; 96 | } 97 | 98 | static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { 99 | int zeros; 100 | 101 | if (a <= 0) a ^= 0xFFFFFFFF; 102 | 103 | if (!(0xFFFF8000 & a)) { 104 | zeros = 16; 105 | } else { 106 | zeros = 0; 107 | } 108 | if (!(0xFF800000 & (a << zeros))) zeros += 8; 109 | if (!(0xF8000000 & (a << zeros))) zeros += 4; 110 | if (!(0xE0000000 & (a << zeros))) zeros += 2; 111 | if (!(0xC0000000 & (a << zeros))) zeros += 1; 112 | 113 | return zeros; 114 | } 115 | 116 | static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { 117 | int zeros; 118 | 119 | if (a == 0) return 0; 120 | 121 | if (!(0xFFFF0000 & a)) { 122 | zeros = 16; 123 | } else { 124 | zeros = 0; 125 | } 126 | if (!(0xFF000000 & (a << zeros))) zeros += 8; 127 | if (!(0xF0000000 & (a << zeros))) zeros += 4; 128 | if (!(0xC0000000 & (a << zeros))) zeros += 2; 129 | if (!(0x80000000 & (a << zeros))) zeros += 1; 130 | 131 | return zeros; 132 | } 133 | 134 | static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { 135 | int zeros; 136 | 137 | if (a <= 0) a ^= 0xFFFF; 138 | 139 | if (!(0xFF80 & a)) { 140 | zeros = 8; 141 | } else { 142 | zeros = 0; 143 | } 144 | if (!(0xF800 & (a << zeros))) zeros += 4; 145 | if (!(0xE000 & (a << zeros))) zeros += 2; 146 | if (!(0xC000 & (a << zeros))) zeros += 1; 147 | 148 | return zeros; 149 | } 150 | 151 | static __inline int32_t WebRtc_MulAccumW16(int16_t a, 152 | int16_t b, 153 | int32_t c) { 154 | return (a * b + c); 155 | } 156 | 157 | #endif // WEBRTC_ARCH_ARM_V7A 158 | 159 | #endif // WEBRTC_SPL_SPL_INL_H_ 160 | --------------------------------------------------------------------------------