Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
51c2341
audio: webrtc_aec: tune the float AEC delay and reference level
singalsu Dec 4, 2026
994c23f
audio: webrtc_aec: wrap new and delete for Zephyr minimal libcpp
singalsu Dec 3, 2026
2161e00
audio: webrtc_aec: downmix multi-channel microphone for mono output
singalsu Dec 3, 2026
3aee3d5
audio: webrtc_aec: report the backend memory usage
singalsu Dec 3, 2026
4bff56f
audio: webrtc_aec: add Kconfig to build AEC3 with the hardware FPU
singalsu Dec 3, 2026
b50625c
app: add a WebRTC AEC3 built-in overlay
singalsu Dec 3, 2026
ad6a2c6
audio: webrtc_aec: free the old AEC3 instance before re-creating it
singalsu Dec 4, 2026
4e5da03
audio: webrtc_aec: add AEC3 filter, adaptation, delay and linear outp…
singalsu Dec 4, 2026
824134d
audio: webrtc_aec: trace the AEC3 metrics and ERLE
singalsu Dec 4, 2026
efd6951
audio: webrtc_aec: create the AEC3 instance into a memory arena
singalsu Dec 4, 2026
cea7470
app: webrtc_aec3_static_overlay: settings for real time stereo AEC3
singalsu Dec 3, 2026
431d875
audio: webrtc_aec: allocate per instance memory in prepare
singalsu Dec 4, 2026
4cd96b8
audio: webrtc_aec: build several backends and select one in prepare
singalsu Dec 4, 2026
2d760df
west.yml: bump webrtc-apm to df7293e5dd71
singalsu Dec 4, 2026
3fda11a
audio: webrtc_aec: add a bytes control for the instance configuration
singalsu Dec 4, 2026
284a78c
topology2: webrtc-aec: add the configuration bytes control and blobs
singalsu Dec 4, 2026
c2d3c52
topology2: sdw-amp-aec: add stereo echo reference AEC version
singalsu Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions app/webrtc_aec3_static_overlay.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# WebRTC AEC3 built into the base firmware. AEC3 supports a stereo echo
# reference with a mono microphone (2R x 1C).
#
# The AEC3 tuning here is the default of an instance. The bytes control of
# the instance overrides it, e.g. the topology "wov" blob has the same
# settings, see src/audio/webrtc_aec/tune/sof_webrtc_aec_blobs.m.

CONFIG_COMP_WEBRTC_AEC=y
CONFIG_WEBRTC_AEC_BACKEND_AEC3=y
CONFIG_WEBRTC_AEC_SAMPLE_RATE_HZ=16000
# With the stereo content detector AEC3 starts with a mono render path and
# allocates the multichannel one when stereo content appears, peaking at about
# 870 kB for 2R x 1C. Without it the multichannel path is created at once and
# stays at about 600 kB.
CONFIG_WEBRTC_AEC_STEREO_CONTENT_DETECT=n
# Soft-float AEC3 2R x 1C needs about 600 MCPS, more than real time.
CONFIG_WEBRTC_AEC_AEC3_HW_FPU=y

# With a playing reference the adaptive filters dominate the load. A 32 ms
# refined filter and a 16 ms coarse filter, instead of 48 ms for both.
CONFIG_WEBRTC_AEC_AEC3_FILTER_BLOCKS=8
CONFIG_WEBRTC_AEC_AEC3_COARSE_FILTER_BLOCKS=4

# Feed the keyword recognizer the linear AEC output, without the residual
# echo suppressor artefacts. The suppressor is not run.
CONFIG_WEBRTC_AEC_AEC3_LINEAR_OUTPUT=y

# Half speed converged state adaptation for a more stable filter
CONFIG_WEBRTC_AEC_AEC3_ADAPT_RATE_PCT=50

# The AEC3 matched filter delay search takes about 160 of 205 MCPS. Use a
# fixed delay instead. On PTL with the 8 ms mic delay AEC3 measured 16 ms,
# a fixed 4 - 18 ms cancels it, 8 ms leaves margin both ways.
CONFIG_WEBRTC_AEC_AEC3_EXTERNAL_DELAY_EST=y
CONFIG_WEBRTC_AEC_AEC3_DELAY_MS=8

# Allocate the AEC3 instance as one 640 kB block in prepare, so that a lack
# of memory fails the stream start instead of panicking the DSP.
CONFIG_WEBRTC_AEC_AEC3_ARENA_SIZE=655360

# AEC3 is allocated from the system heap, the topology DP heap size is used
# only with CONFIG_USERSPACE. Make room for 2R x 1C AEC3.
CONFIG_SOF_ZEPHYR_HEAP_SIZE=0x100000

# siggen in the echo reference pipeline
CONFIG_COMP_TONE=y

# 1 s ERLE trace, read by the WoV AEC stress test script
CONFIG_WEBRTC_AEC_ERLE_TRACE=y
65 changes: 35 additions & 30 deletions src/audio/webrtc_aec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ else()
endif()

if(CONFIG_WEBRTC_AEC_BACKEND_AEC3)
if(CONFIG_WEBRTC_AEC_AEC3_HW_FPU)
set(_clang_fp_flags "")
endif()

if(DEFINED CONFIG_SOC_TOOLCHAIN_NAME)
set(_xtensa_target "${CONFIG_SOC_TOOLCHAIN_NAME}")
else()
Expand Down Expand Up @@ -69,12 +73,20 @@ else()
# Minimal C++ runtime, new/delete, and exception stubs are provided in webrtc_aec3_shims.cpp.

add_local_sources(sof
webrtc_aec-aec3.c
webrtc_aec-math.c
webrtc_aec3_wrapper.cpp
webrtc_aec3_shims.cpp
)

# The Zephyr minimal C++ library (CONFIG_CPP, e.g. for MWW) also defines
# the global new and delete operators. Wrap them so that the AEC3
# allocations use the module heap versions in webrtc_aec3_shims.cpp.
if(CONFIG_MINIMAL_LIBCPP)
foreach(_sym _Znwj _Znaj _ZnwjRKSt9nothrow_t _ZnajRKSt9nothrow_t
_ZdlPv _ZdaPv _ZdlPvj _ZdaPvj)
zephyr_link_libraries(-Wl,--wrap=${_sym})
endforeach()
endif()

file(GLOB _aec3_srcs
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec3/*.cc"
)
Expand Down Expand Up @@ -103,22 +115,36 @@ else()
TARGET_DIRECTORY modules_sof
PROPERTIES COMPILE_OPTIONS "-std=c++17;-fno-exceptions;-fno-rtti;-O3;${_no_vectorize_flags};${_clang_fp_flags};-DWEBRTC_POSIX;-DWEBRTC_ARCH_GENERIC;-DWEBRTC_APM_DEBUG_DUMP=0;-DRTC_DISABLE_METRICS;-DNDEBUG;-Wno-macro-redefined;-Wno-unused-function;-Wno-double-promotion"
)
elseif(CONFIG_WEBRTC_AEC_BACKEND_FLOAT)
add_local_sources(sof webrtc_aec-aec.c webrtc_aec-math.c)
add_local_sources(sof
endif()

# The C backends, all selected backends are built in. The module
# selects the backend of an instance in prepare().
set(_backend_glue "")
set(_backend_apm_srcs "")
if(CONFIG_WEBRTC_AEC_BACKEND_AEC3)
list(APPEND _backend_glue ${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aec3.c)
endif()
if(CONFIG_WEBRTC_AEC_BACKEND_FLOAT)
list(APPEND _backend_glue ${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aec.c)
list(APPEND _backend_apm_srcs
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/echo_cancellation.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_core.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_rdft.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_resampler.c"
)
else()
add_local_sources(sof webrtc_aec-aecm.c)
add_local_sources(sof
endif()
if(CONFIG_WEBRTC_AEC_BACKEND_AEC3 OR CONFIG_WEBRTC_AEC_BACKEND_FLOAT)
list(APPEND _backend_glue ${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-math.c)
endif()
if(CONFIG_WEBRTC_AEC_BACKEND_AECM)
list(APPEND _backend_glue ${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aecm.c)
list(APPEND _backend_apm_srcs
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/echo_control_mobile.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/aecm_core.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/aecm_core_c.c"
)
endif()
add_local_sources(sof ${_backend_glue} ${_backend_apm_srcs})

add_local_sources(sof webrtc_aec-shims.c)
add_local_sources(sof
Expand Down Expand Up @@ -174,28 +200,7 @@ else()
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-shims.c
)

if(CONFIG_WEBRTC_AEC_BACKEND_AEC3)
list(APPEND _webrtc_aec_srcs
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aec3.c
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-math.c
)
elseif(CONFIG_WEBRTC_AEC_BACKEND_FLOAT)
list(APPEND _webrtc_aec_srcs
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aec.c
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-math.c
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/echo_cancellation.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_core.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_rdft.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aec/aec_resampler.c"
)
else()
list(APPEND _webrtc_aec_srcs
${CMAKE_CURRENT_SOURCE_DIR}/webrtc_aec-aecm.c
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/echo_control_mobile.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/aecm_core.c"
"${SOF_WEBRTC_APM_SRC_DIR}/webrtc/modules/audio_processing/aecm/aecm_core_c.c"
)
endif()
list(APPEND _webrtc_aec_srcs ${_backend_glue} ${_backend_apm_srcs})

set_source_files_properties(
${_webrtc_aec_srcs}
Expand Down
Loading
Loading