├── lib_agc
├── doc
│ └── rst
│ │ ├── xdoc.conf
│ │ ├── index.rst
│ │ └── agc-internals.rst
├── .xproject
├── .makefile
├── module_build_info
├── generate_config.py
├── .project
├── api
│ ├── agc_control_map.h
│ ├── agc.h
│ └── agc_control.h
├── config
│ └── agc_2ch.json
└── src
│ ├── agc_ch_state.h
│ ├── agc_control_map.xc
│ ├── agc_control.xc
│ └── agc.xc
├── python
├── __init__.py
├── setup.py
├── test_wav_agc.py
└── agc.py
├── .github
└── ISSUE_TEMPLATE
│ ├── missing-c-api.md
│ ├── missing-xcore-test.md
│ ├── missing-application-note.md
│ ├── top-level-readme-not-compliant.md
│ ├── test-not-compliant.md
│ ├── example-not-compliant.md
│ └── application-note-not-compliant.md
├── cmake_utils
├── xc
│ ├── CMakeTestXCCompiler.cmake
│ ├── CMakeXCCompiler.cmake.in
│ ├── CMakeDetermineXCCompiler.cmake
│ └── CMakeXCInformation.cmake
├── xmos_toolchain.cmake
├── agc.cmake
└── xmos_utils.cmake
├── .gitignore
├── tests
├── test_wav_agc
│ ├── src
│ │ ├── agc_conf.h
│ │ ├── process_wav_conf.h
│ │ └── test_wav_agc.xc
│ ├── README.md
│ ├── config.xscope
│ ├── .project
│ ├── CMakeLists.txt
│ └── wscript
└── agc_unit_tests
│ ├── src
│ ├── agc_unit_tests.h
│ ├── agc_conf.h
│ └── test_agc.xc
│ ├── README.md
│ ├── config.xscope
│ ├── CMakeLists.txt
│ ├── generate_unity_runners.py
│ ├── conftest.py
│ └── wscript
├── README.rst
├── requirements.txt
├── Jenkinsfile
├── CHANGELOG.rst
└── LICENSE.rst
/lib_agc/doc/rst/xdoc.conf:
--------------------------------------------------------------------------------
1 | XMOSNEWSTYLE = 1
2 | DOXYGEN_DIRS=../../api
3 |
--------------------------------------------------------------------------------
/python/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2018-2021 XMOS LIMITED.
2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
--------------------------------------------------------------------------------
/lib_agc/.xproject:
--------------------------------------------------------------------------------
1 |
2 | lib_agc
3 | 0.0.1dbbe4eb2632
4 |
--------------------------------------------------------------------------------
/lib_agc/.makefile:
--------------------------------------------------------------------------------
1 | all:
2 | @echo "** Module only - only builds as part of application **"
3 |
4 |
5 | clean:
6 | @echo "** Module only - only builds as part of application **"
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/missing-c-api.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Missing C API Issue
3 | about: Template for a Missing C API issue report
4 | title: Missing C API
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/cmake_utils/xc/CMakeTestXCCompiler.cmake:
--------------------------------------------------------------------------------
1 | if(CMAKE_XC_COMPILER_FORCED)
2 | # The compiler configuration was forced by the user.
3 | # Assume the user has configured all compiler information.
4 | set(CMAKE_XC_COMPILER_WORKS TRUE CACHE INTERNAL "")
5 | return()
6 | endif()
7 |
--------------------------------------------------------------------------------
/lib_agc/doc/rst/index.rst:
--------------------------------------------------------------------------------
1 | .. include:: ../../../README.rst
2 |
3 | Usage
4 | -----
5 |
6 | .. include:: agc-internals.rst
7 |
8 | |newpage|
9 |
10 | |appendix|
11 |
12 | Known Issues
13 | ------------
14 |
15 | None
16 |
17 | .. include:: ../../../CHANGELOG.rst
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/missing-xcore-test.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Missing xCore Test Issue
3 | about: Template for a Missing xCore test issue report
4 | title: Missing xCore test
5 | labels: testing
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/missing-application-note.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Missing Application Note
3 | about: Template for a Missing Application Note issue report
4 | title: Missing Application Note
5 | labels: documentation
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/cmake_utils/xc/CMakeXCCompiler.cmake.in:
--------------------------------------------------------------------------------
1 | set(CMAKE_XC_COMPILER "@CMAKE_XC_COMPILER@")
2 | set(CMAKE_XC_COMPILER_LOADED 1)
3 | set(CMAKE_XC_SOURCE_FILE_EXTENSIONS @CMAKE_XC_SOURCE_FILE_EXTENSIONS@)
4 | set(CMAKE_XC_OUTPUT_EXTENSION @CMAKE_XC_OUTPUT_EXTENSION@)
5 | set(CMAKE_XC_COMPILER_ENV_VAR "@CMAKE_XC_COMPILER_ENV_VAR@")
6 |
7 | set(CMAKE_LINKER "@CMAKE_LINKER@")
8 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/top-level-readme-not-compliant.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Top-level README Issue
3 | about: Template for the top-level README issue report
4 | title: Top-level README not compliant
5 | labels: documentation
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 | **Issues:**
12 |
13 | - xdoc-custom RST directives used in the README
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/.build*/*
2 | **/bin/*
3 | *.o
4 | *.xe
5 | *.vcd
6 | *.xi
7 | *.i
8 | *.a
9 | **/_build/
10 | **/build/
11 | **/run_*.log
12 | **/pdf/*
13 | **/html/*
14 | *.pyc
15 | **/.settings*
16 | Installs/*
17 | test_results.csv
18 | *.log
19 | .DS_Store
20 | xscope.xmt
21 | *.xc.pca.xml
22 | *.xc.pca.xml.decouple
23 | *.xc.d
24 | **/.lock-waf_darwin_build
25 | **/*.egg-info/
26 | */.venv/*
27 | Pipfile.lock
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/test-not-compliant.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Test Issue
3 | about: Template for a Test issue report
4 | title: tests/XXX does not build or fails
5 | labels: testing
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
12 |
13 | **Issues:**
14 |
15 | - Test not compiling for xcore-ai
16 | - Test not running successfully on xcore-ai
17 |
--------------------------------------------------------------------------------
/tests/test_wav_agc/src/agc_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2017-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef AGC_CONF_H_
5 | #define AGC_CONF_H_
6 |
7 | #define AGC_FRAME_ADVANCE (240)
8 | #define AGC_PROC_FRAME_LENGTH (AGC_FRAME_ADVANCE)
9 |
10 | #define AGC_INPUT_CHANNELS (2)
11 | #define AGC_CHANNEL_PAIRS ((AGC_INPUT_CHANNELS+1)/2)
12 |
13 | #endif /* AGC_CONF_H_ */
14 |
--------------------------------------------------------------------------------
/lib_agc/module_build_info:
--------------------------------------------------------------------------------
1 | VERSION = 8.2.0
2 |
3 | DEPENDENT_MODULES = lib_dsp(>=6.0.1) \
4 | lib_voice_toolbox(>=8.0.0) \
5 | lib_vad(>=1.0.3)) \
6 | audio_test_tools(>=4.2.0)
7 |
8 | MODULE_XCC_FLAGS = $(XCC_FLAGS) \
9 | -O2
10 |
11 | OPTIONAL_HEADERS += agc_conf.h
12 |
13 | EXPORT_INCLUDE_DIRS = api \
14 | src
15 |
16 | INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS)
17 |
18 | SOURCE_DIRS = src
19 |
--------------------------------------------------------------------------------
/tests/test_wav_agc/src/process_wav_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2018-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #ifndef _PROCESS_WAV_CONF_H
4 | #define _PROCESS_WAV_CONF_H
5 |
6 | #define ATT_PW_INPUT_CHANNELS (2)
7 | #define ATT_PW_OUTPUT_CHANNELS (2)
8 | #define ATT_PW_PROC_FRAME_LENGTH (480)
9 | #define ATT_PW_FRAME_ADVANCE (240)
10 | #define ATT_PW_INPUT_FILE_NAME "input.wav"
11 | #define ATT_PW_OUTPUT_FILE_NAME "output.wav"
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/example-not-compliant.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Example Issue
3 | about: Template for an example issue report
4 | title: examples/xxx Example not compliant
5 | labels: documentation
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
12 |
13 | **Issues:**
14 |
15 | - convert example to Application Note
16 | - xdoc-custom RST directives used in the README
17 | - example code not compiling for xcore-ai
18 | - example code not running successfully on xcore-ai
19 |
--------------------------------------------------------------------------------
/lib_agc/generate_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright 2019-2021 XMOS LIMITED.
3 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
4 | from pathlib import Path
5 | from json_utils import JsonHandler
6 |
7 | module_dir = Path(__file__).parent
8 | file_conv = JsonHandler(str((module_dir / 'config/agc_2ch.json').resolve()),
9 | False)
10 | file_conv.create_header_file(
11 | str((module_dir / 'api/agc.h').resolve()),
12 | [str((module_dir / '../tests/test_wav_agc/src/agc_conf.h').resolve())]
13 | )
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/application-note-not-compliant.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Application Note Issue
3 | about: Template for an Application note issue report
4 | title: examples/ANXXXXX Application Note not compliant
5 | labels: documentation
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
12 |
13 | **Issues:**
14 |
15 | - xdoc-custom RST directives used in the Application Note README
16 | - application note code not compiling for xcore-ai
17 | - application note code not running successfully on xcore-ai
18 |
--------------------------------------------------------------------------------
/tests/agc_unit_tests/src/agc_unit_tests.h:
--------------------------------------------------------------------------------
1 | // Copyright 2018-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #ifndef AGC_UNIT_TESTS_H_
4 | #define AGC_UNIT_TESTS_H_
5 |
6 | #include "unity.h"
7 |
8 | #ifdef __XC__
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include
15 |
16 | #include "audio_test_tools.h"
17 | #include "voice_toolbox.h"
18 |
19 | #include "agc.h"
20 | #include "agc_control.h"
21 |
22 | #define TEST_ASM 1
23 |
24 | #endif // __XC__
25 |
26 | #endif /* AGC_UNIT_TESTS_H_ */
27 |
--------------------------------------------------------------------------------
/cmake_utils/xc/CMakeDetermineXCCompiler.cmake:
--------------------------------------------------------------------------------
1 | if(DEFINED XMOS_TOOLS_PATH)
2 | set(CMAKE_XC_COMPILER "${XMOS_TOOLS_PATH}/xcc")
3 | else()
4 | set(CMAKE_XC_COMPILER "$ENV{XMOS_TOOL_PATH}/bin/xcc")
5 | endif()
6 | mark_as_advanced(CMAKE_XC_COMPILER)
7 |
8 | set(CMAKE_XC_SOURCE_FILE_EXTENSIONS xc;XC CACHE INTERNAL "")
9 | set(CMAKE_XC_OUTPUT_EXTENSION .obj CACHE INTERNAL "")
10 | set(CMAKE_XC_COMPILER_ENV_VAR "XC" CACHE INTERNAL "")
11 | set(CMAKE_XC_LINKER_PREFERENCE 99 CACHE INTERNAL "")
12 | set(CMAKE_XC_LINKER_PREFERENCE_PROPAGATES 1 CACHE INTERNAL "")
13 |
14 | # Configure variables set in this file for fast reload later on
15 | configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeXCCompiler.cmake.in
16 | ${CMAKE_PLATFORM_INFO_DIR}/CMakeXCCompiler.cmake)
17 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | Automatic Gain Control Library
2 | ==============================
3 |
4 | Summary
5 | -------
6 |
7 | This library implements an automatic gain control algorithm. Given a stream
8 | of audio samples in the time domain, it dynamically adapts the gain such that
9 | voice content maintains a specified output level.
10 |
11 | Features
12 | ........
13 |
14 | * Supports multiple audio channels.
15 | * Configurable adaptive or fixed gain.
16 | * Configurable initial and maximum gain values.
17 | * Soft limiter applied to output.
18 |
19 | Software version and dependencies
20 | .................................
21 |
22 | The CHANGELOG contains information about the current and previous versions.
23 | For a list of direct dependencies, look for DEPENDENT_MODULES in lib_agc/module_build_info.
24 |
--------------------------------------------------------------------------------
/tests/agc_unit_tests/README.md:
--------------------------------------------------------------------------------
1 | # agc_unit_tests test application
2 |
3 | This example builds the agc_unit_tests application
4 |
5 | ## Prerequisites for building
6 |
7 | [XMOS Toolchain 15.0.3](https://www.xmos.com/software/tools/) or newer.
8 |
9 | Install [CMake](https://cmake.org/download/) version 3.13 or newer.
10 |
11 | ## Building for xCORE
12 |
13 | Set environment variable for lib_agc path:
14 |
15 | > export AGC_PATH=
16 |
17 | cd to lib_agc/tests/agc_unit_tests
18 |
19 | Run cmake and build
20 |
21 | > cmake .
22 | > make
23 |
24 | ## Run on hardware
25 |
26 | Ensure your XCORE AI EXPLORER board is powered up and connected to the XTAG debugger.
27 | Make sure the input.wav file is copied into the build directory
28 |
29 | > pytest -n 1
30 |
31 |
32 | You should see the tests collected by pytest pass
33 |
--------------------------------------------------------------------------------
/tests/test_wav_agc/README.md:
--------------------------------------------------------------------------------
1 | # test_wav_agc test application
2 |
3 | This example builds the test_wav_agc.xe application
4 |
5 | ## Prerequisites for building
6 |
7 | [XMOS Toolchain 15.0.3](https://www.xmos.com/software/tools/) or newer.
8 |
9 | Install [CMake](https://cmake.org/download/) version 3.13 or newer.
10 |
11 | ## Building for xCORE
12 |
13 | Set environment variable for lib_agc path:
14 |
15 | > export AGC_PATH=
16 |
17 | cd to lib_agc/tests/test_wav_agc
18 |
19 | Run cmake and build
20 |
21 | > cmake . -B build
22 | > cd build
23 | > make
24 |
25 | ## Run on hardware
26 |
27 | Ensure your XCORE AI EXPLORER board is powered up and connected to the XTAG debugger.
28 | Make sure the input.wav file is copied into the build directory
29 |
30 | > xrun --xscope test_wav_agc.xe
31 |
32 |
33 | You should see an output.wav file generated with the test_wav_agc output.
34 |
--------------------------------------------------------------------------------
/tests/test_wav_agc/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/tests/agc_unit_tests/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/lib_agc/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | lib_agc
4 |
5 |
6 |
7 |
8 |
9 | com.xmos.cdt.core.ModulePathBuilder
10 |
11 |
12 |
13 |
14 | com.xmos.cdt.core.LegacyProjectCheckerBuilder
15 |
16 |
17 |
18 |
19 | com.xmos.cdt.core.ProjectInfoSyncBuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
25 | clean,full,incremental,
26 |
27 |
28 |
29 |
30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
31 | full,incremental,
32 |
33 |
34 |
35 |
36 |
37 | org.eclipse.cdt.core.cnature
38 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
39 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
40 | com.xmos.cdt.core.XdeProjectNature
41 |
42 |
43 |
--------------------------------------------------------------------------------
/tests/test_wav_agc/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | test_wav_agc
4 |
5 |
6 |
7 |
8 |
9 | com.xmos.cdt.core.ProjectInfoSyncBuilder
10 |
11 |
12 |
13 |
14 | com.xmos.cdt.core.LegacyProjectCheckerBuilder
15 |
16 |
17 |
18 |
19 | com.xmos.cdt.core.ModulePathBuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
25 | clean,full,incremental,
26 |
27 |
28 |
29 |
30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
31 | full,incremental,
32 |
33 |
34 |
35 |
36 |
37 | org.eclipse.cdt.core.cnature
38 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
39 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
40 | com.xmos.cdt.core.XdeProjectNature
41 |
42 |
43 |
--------------------------------------------------------------------------------
/python/setup.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019-2024 XMOS LIMITED.
2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | import setuptools
4 |
5 | # Another repository might depend on python code defined in this one. The
6 | # procedure to set up a suitable python environment for that repository may
7 | # pip-install this one as editable using this setup.py file. To minimise the
8 | # chance of version conflicts while ensuring a minimal degree of conformity,
9 | # the 3rd-party modules listed here require the same major version and at
10 | # least the same minor version as specified in the requirements.txt file.
11 | # The same modules should appear in the requirements.txt file as given below.
12 | setuptools.setup(
13 | name='lib_agc',
14 | packages=setuptools.find_packages(),
15 | install_requires=[
16 | 'flake8~=3.8',
17 | 'matplotlib~=3.3',
18 | 'numpy~=1.18',
19 | 'pylint~=2.5',
20 | 'pytest~=6.0',
21 | 'pytest-xdist~=1.34',
22 | 'scipy~=1.4',
23 | 'webrtcvad~=2.0',
24 | 'audio_test_tools',
25 | 'lib_vad',
26 | 'lib_voice_toolbox',
27 | ],
28 | dependency_links=[
29 | './../../audio_test_tools/python#egg=audio_test_tools',
30 | './../../lib_voice_toolbox#egg=lib_voice_toolbox',
31 | './../../lib_vad/python#egg=lib_vad',
32 | ],
33 | )
34 |
--------------------------------------------------------------------------------
/cmake_utils/xc/CMakeXCInformation.cmake:
--------------------------------------------------------------------------------
1 | include(CMakeLanguageInformation)
2 | include(CMakeCommonLanguageInclude)
3 |
4 | if(NOT CMAKE_INCLUDE_FLAG_XC)
5 | set(CMAKE_INCLUDE_FLAG_XC ${CMAKE_INCLUDE_FLAG_C})
6 | endif()
7 |
8 | set(CMAKE_XC_FLAGS_INIT "$ENV{XCFLAGS} ${CMAKE_XC_FLAGS_INIT}")
9 |
10 | # Create a static archive incrementally for large object file counts.
11 | # If CMAKE_CXX_CREATE_STATIC_LIBRARY is set it will override these.
12 | if(NOT DEFINED CMAKE_XC_ARCHIVE_CREATE)
13 | set(CMAKE_XC_ARCHIVE_CREATE " qc ")
14 | endif()
15 | if(NOT DEFINED CMAKE_XC_ARCHIVE_APPEND)
16 | set(CMAKE_XC_ARCHIVE_APPEND " q ")
17 | endif()
18 | if(NOT DEFINED CMAKE_XC_ARCHIVE_FINISH)
19 | set(CMAKE_XC_ARCHIVE_FINISH " ")
20 | endif()
21 |
22 | # Compile an XC file into an object file
23 | if(NOT CMAKE_XC_COMPILE_OBJECT)
24 | set(CMAKE_XC_COMPILE_OBJECT
25 | " -o