├── .gitignore ├── CHANGELOG.rst ├── CMakeLists.txt ├── Jenkinsfile ├── LICENSE.rst ├── README.rst ├── doc ├── Doxyfile.inc ├── exclude_patterns.inc ├── python │ ├── README.txt │ ├── asrc_utils.py │ ├── doc_asrc.py │ └── requirements.txt └── rst │ ├── asrc_task │ ├── asrc_task.rst │ └── images │ │ ├── ASRC_block_threads.drawio │ │ ├── ASRC_block_threads.png │ │ └── asrc_task_layers.drawio.png │ ├── asynchronous_fifo │ ├── asynchronous_fifo.rst │ └── images │ │ ├── peak_fifo_48000_500ppm.png │ │ ├── phase-difference.pdf │ │ ├── phase-difference.svg │ │ ├── use-cases.pdf │ │ └── use-cases.svg │ ├── fixed_ratio_src.rst │ ├── images │ ├── asrc_structure.pdf │ ├── quad_dual_instance.pdf │ ├── src_ff3_vpu.png │ ├── src_ff3_vpu_pb.png │ ├── src_proc.pdf │ ├── src_rat_vpu.png │ ├── src_rat_vpu_pb.png │ ├── ssrc_structure.pdf │ ├── stereo_dual_instance.pdf │ └── stereo_single_instance.pdf │ ├── introduction.rst │ ├── latency_asrc.rst │ ├── lib_src.rst │ ├── multi_rate_hifi_src.rst │ ├── resource_usage_asrc.rst │ └── resource_usage_ssrc.rst ├── examples ├── CMakeLists.txt ├── app_asrc_task │ ├── CMakeLists.txt │ ├── asrc_task │ │ ├── CMakeLists.txt │ │ └── src │ │ │ ├── asrc_task_config.h │ │ │ ├── asrc_task_receive_samples.c │ │ │ ├── asrc_task_test.xc │ │ │ └── config.xscope │ └── src │ │ ├── asrc_task_config.h │ │ ├── asrc_task_receive_samples.c │ │ ├── asrc_task_test.xc │ │ └── config.xscope ├── app_asynchronous_fifo │ ├── CMakeLists.txt │ ├── asynchronous_fifo │ │ ├── CMakeLists.txt │ │ └── src │ │ │ └── asynchronous_fifo_example.c │ └── src │ │ └── asynchronous_fifo_example.c └── deps.cmake ├── lib_src ├── api │ ├── asrc_timestamp_interpolation.h │ ├── asynchronous_fifo.h │ └── src.h ├── lib_build_info.cmake ├── module_build_info └── src │ ├── asrc_task │ ├── asrc_task.c │ └── asrc_task.h │ ├── asrc_timestamp_interpolation.c │ ├── asynchronous_fifo.c │ ├── fixed_factor_of_3 │ ├── ds3 │ │ ├── FilterData │ │ │ ├── firds3_144.dat │ │ │ ├── firds3_144.sfp │ │ │ ├── firds3_b_144.dat │ │ │ └── firds3_b_144.sfp │ │ ├── src_ff3_ds3.c │ │ └── src_ff3_ds3.h │ ├── os3 │ │ ├── FilterData │ │ │ ├── firos3_144.dat │ │ │ ├── firos3_144.sfp │ │ │ ├── firos3_b_144.dat │ │ │ └── firos3_b_144.sfp │ │ ├── src_ff3_os3.c │ │ └── src_ff3_os3.h │ ├── src_ff3_fir_inner_loop_asm.S │ └── src_ff3_fir_inner_loop_asm.h │ ├── fixed_factor_of_3_voice │ ├── ds3_voice │ │ └── src_ff3v_ds3_voice.S │ ├── src_ff3v_fir.S │ ├── src_ff3v_fir.h │ ├── src_ff3v_fir.xc │ ├── src_ff3v_fir_generator.py │ └── us3_voice │ │ └── src_ff3v_us3_voice.S │ ├── fixed_factor_vpu_voice │ ├── asm │ │ ├── conv_s32_24t.S │ │ ├── conv_s32_32t.S │ │ ├── fir_s32_24t.S │ │ ├── fir_s32_32t.S │ │ ├── fir_s32_48t.S │ │ └── push_s32_48t.S │ ├── src_ff3_fir_coefs.c │ ├── src_ff3_fir_coefs.h │ ├── src_low_level.h │ ├── src_poly.h │ ├── src_rat_fir_coefs.c │ └── src_rat_fir_coefs.h │ └── multirate_hifi │ ├── FilterData │ ├── ADFir.dat │ ├── ADFir.sfp │ ├── BL.dat │ ├── BL.sfp │ ├── BL17696.dat │ ├── BL17696.sfp │ ├── BL19288.dat │ ├── BL19288.sfp │ ├── BL8848.dat │ ├── BL8848.sfp │ ├── BL9644.dat │ ├── BL9644.sfp │ ├── BLF.dat │ ├── BLF.sfp │ ├── DS.dat │ ├── DS.sfp │ ├── DS_xs3.dat │ ├── HS294.dat │ ├── HS294.sfp │ ├── HS294_xs3.dat │ ├── HS320.dat │ ├── HS320.sfp │ ├── HS320_xs3.dat │ ├── OS.dat │ ├── OS.sfp │ ├── OS_xs3.dat │ ├── UP.dat │ ├── UP.sfp │ ├── UP192176.dat │ ├── UP192176.sfp │ ├── UP192176_xs3.dat │ ├── UP4844.dat │ ├── UP4844.sfp │ ├── UP4844_xs3.dat │ ├── UPF.dat │ ├── UPF.sfp │ ├── UPF_xs3.dat │ └── UP_xs3.dat │ ├── asrc │ ├── src_mrhf_asrc.c │ ├── src_mrhf_asrc.h │ ├── src_mrhf_asrc_checks.h │ └── src_mrhf_asrc_wrapper.c │ ├── src_mrhf_adfir_inner_loop_asm.S │ ├── src_mrhf_adfir_inner_loop_asm.h │ ├── src_mrhf_adfir_inner_loop_asm_xs3.S │ ├── src_mrhf_dither_maths_asm.S │ ├── src_mrhf_filter_defs.c │ ├── src_mrhf_filter_defs.h │ ├── src_mrhf_fir.c │ ├── src_mrhf_fir.h │ ├── src_mrhf_fir_inner_loop_asm.S │ ├── src_mrhf_fir_inner_loop_asm.h │ ├── src_mrhf_fir_os_inner_loop_asm.S │ ├── src_mrhf_fir_os_inner_loop_asm.h │ ├── src_mrhf_int_arithmetic.c │ ├── src_mrhf_int_arithmetic.h │ ├── src_mrhf_spline_coeff_gen_inner_loop_asm.S │ ├── src_mrhf_spline_coeff_gen_inner_loop_asm.h │ ├── ssrc │ ├── src_mrhf_ssrc.c │ ├── src_mrhf_ssrc.h │ ├── src_mrhf_ssrc_checks.h │ └── src_mrhf_ssrc_wrapper.c │ └── use_vpu.h ├── python ├── fixed_factor_vpu_voice │ ├── __init__.py │ ├── src_ff3_fir_gen.py │ └── src_rat_fir_gen.py └── setup.py ├── settings.yml └── tests ├── CMakeLists.txt ├── hw_tests ├── CMakeLists.txt ├── asrc_task_test │ ├── CMakeLists.txt │ └── src │ │ ├── asrc_task_config.h │ │ ├── asrc_task_receive_samples.c │ │ ├── asrc_task_test.xc │ │ └── config.xscope ├── asrc_task_test_ppm │ ├── CMakeLists.txt │ ├── config.xscope │ ├── host │ │ └── vcd_to_csv.c │ └── src │ │ ├── asrc_task_config.h │ │ ├── asrc_task_receive_samples.c │ │ ├── asrc_task_test_ppm.xc │ │ └── config.xscope ├── asrc_test_xscope_fileio │ ├── CMakeLists.txt │ ├── python │ │ └── __init__.py │ └── src │ │ ├── asrc_test.c │ │ ├── config.xscope │ │ ├── file_utils │ │ ├── fileio.c │ │ └── fileio.h │ │ └── main.xc ├── asynchronous_fifo_asrc_test │ ├── CMakeLists.txt │ └── src │ │ ├── asynchronous_fifo_asrc_test.c │ │ └── config.xscope ├── test_asrc_ppm.py └── test_asrc_task.py ├── requirements.txt ├── setup.py ├── sim_tests ├── CMakeLists.txt ├── asrc_test │ ├── CMakeLists.txt │ ├── asrc_c_emulator.cmake │ └── src │ │ ├── dut │ │ └── asrc_test.xc │ │ └── model │ │ ├── Main.c │ │ ├── Main.h │ │ ├── api │ │ └── ASRC_wrapper.h │ │ └── src │ │ ├── ASRC.c │ │ ├── ASRC.h │ │ ├── ASRC_wrapper.c │ │ ├── FIR.c │ │ ├── FIR.h │ │ ├── FilterDefs.c │ │ ├── FilterDefs.h │ │ ├── IntArithmetic.c │ │ └── IntArithmetic.h ├── asrc_vpu_test │ ├── CMakeLists.txt │ └── src │ │ ├── config.xscope │ │ └── test_asrc_vpu.c ├── conftest.py ├── ds3_test │ ├── CMakeLists.txt │ └── src │ │ ├── dut │ │ └── app_ds3.xc │ │ └── model │ │ ├── FIRDS3.c │ │ ├── FIRDS3.h │ │ ├── IntArithmetic.c │ │ ├── IntArithmetic.h │ │ ├── Main.c │ │ └── Main.h ├── ds3_voice_test │ ├── CMakeLists.txt │ └── src │ │ └── app_ds3_voice.xc ├── os3_test │ ├── CMakeLists.txt │ └── src │ │ ├── dut │ │ └── app_os3.xc │ │ └── model │ │ ├── FIROS3.c │ │ ├── FIROS3.h │ │ ├── IntArithmetic.c │ │ ├── IntArithmetic.h │ │ ├── Main.c │ │ ├── Main.h │ │ └── ReadMe.txt ├── pytest.ini ├── ssrc_test │ ├── CMakeLists.txt │ └── src │ │ ├── dut │ │ └── ssrc_test.xc │ │ └── model │ │ ├── FIR.c │ │ ├── FIR.h │ │ ├── FilterDefs.c │ │ ├── FilterDefs.h │ │ ├── IntArithmetic.c │ │ ├── IntArithmetic.h │ │ ├── Main.c │ │ ├── Main.h │ │ ├── SSRC.c │ │ └── SSRC.h ├── test_hifi_ff3.py ├── test_mrhf.py ├── test_profile_asrc.py ├── test_voice_ff3_xs2.py ├── test_voice_vpu_ff3.py ├── test_voice_vpu_rat.py ├── unity_gain_voice_test │ ├── CMakeLists.txt │ └── src │ │ └── app_unity_gain_voice.xc ├── us3_voice_test │ ├── CMakeLists.txt │ └── src │ │ └── app_us3_voice.xc ├── vpu_ff3_test │ ├── CMakeLists.txt │ └── src │ │ └── fileio_app.c └── vpu_rat_test │ ├── CMakeLists.txt │ └── src │ └── fileio_app.c └── utils ├── __init__.py ├── run_xcoreai.py ├── src_input ├── im10k11k_m6dB_176.dat ├── im10k11k_m6dB_192.dat ├── im10k11k_m6dB_44.dat ├── im10k11k_m6dB_48.dat ├── im10k11k_m6dB_88.dat ├── im10k11k_m6dB_96.dat ├── im5k6k_m6dB_16.dat ├── im5k6k_m6dB_48.dat ├── s1k_0dB_16.dat ├── s1k_0dB_176.dat ├── s1k_0dB_192.dat ├── s1k_0dB_44.dat ├── s1k_0dB_48.dat ├── s1k_0dB_88.dat └── s1k_0dB_96.dat ├── src_test_utils.py └── thdncalculator.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Tmp files & logs 2 | *.settings 3 | *.bin 4 | *.zip 5 | *.log 6 | *.vcd 7 | *.swp 8 | *.*~ 9 | *.xmt 10 | *.swo 11 | *.swn 12 | *~ 13 | *.DS_Store 14 | 15 | # Python 16 | *.pyc 17 | **/*.egg-info/ 18 | **/.venv*/ 19 | 20 | # XMOS temp files 21 | **/*build*/* 22 | */bin/* 23 | **/flash_bin_node* 24 | **/fw-* 25 | **/s2l-* 26 | **/spanning-xn-* 27 | **/target-xn* 28 | *.xi 29 | *.o 30 | *.i 31 | *.a 32 | *.d 33 | *.decouple 34 | *.pca.xml 35 | **/CMakeFiles/* 36 | 37 | # XMOS binaries 38 | *.xe 39 | 40 | # Built documentation 41 | doc/_build/pdf/*.pdf 42 | **/doc/pdf/*.pdf 43 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21.0) 2 | 3 | if(NOT DEFINED XCOMMON_CMAKE_VER) 4 | project(lib_src LANGUAGES C ASM) 5 | 6 | if(PROJECT_IS_TOP_LEVEL) 7 | include(FetchContent) 8 | FetchContent_Declare( 9 | fwk_core 10 | GIT_REPOSITORY https://github.com/xmos/fwk_core.git 11 | GIT_TAG v1.0.2 12 | ) 13 | FetchContent_MakeAvailable(fwk_core) 14 | endif() 15 | 16 | # XS3 only libraries that use the Vector Processing Unit 17 | if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS3A) 18 | ## Source files 19 | file(GLOB_RECURSE LIB_C_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.c ) 20 | file(GLOB_RECURSE LIB_XC_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.xc) 21 | file(GLOB_RECURSE LIB_ASM_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.S ) 22 | 23 | set(ADDITIONAL_INCLUDE_DIRS_XS3 lib_src/src/fixed_factor_vpu_voice 24 | ) 25 | endif() 26 | 27 | 28 | if((${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS3A) OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS2A)) 29 | ## Source files 30 | file(GLOB_RECURSE LIB_C_SOURCES lib_src/src/fixed_factor_of_3/*.c 31 | lib_src/src/fixed_factor_of_3_voice/*.c 32 | lib_src/src/multirate_hifi/*.c 33 | ) 34 | file(GLOB LIB_C_SOURCES_FIFO lib_src/src/*.c 35 | ) 36 | file(GLOB_RECURSE LIB_XC_SOURCES lib_src/src/fixed_factor_of_3/*.xc 37 | lib_src/src/fixed_factor_of_3_voice/*.xc 38 | lib_src/src/multirate_hifi/*.xc 39 | ) 40 | file(GLOB_RECURSE LIB_ASM_SOURCES lib_src/src/fixed_factor_of_3/*.S 41 | lib_src/src/fixed_factor_of_3_voice/*.S 42 | lib_src/src/multirate_hifi/*.S 43 | ) 44 | 45 | ## Create library target 46 | add_library(lib_src STATIC EXCLUDE_FROM_ALL ${LIB_C_SOURCES} 47 | ${LIB_C_SOURCES_FIFO} 48 | ${LIB_C_SOURCES_XS3} 49 | ${LIB_ASM_SOURCES} 50 | ${LIB_XC_SOURCES_XS3} 51 | ${LIB_XC_SOURCES} 52 | ${LIB_ASM_SOURCES_XS3} 53 | ) 54 | 55 | target_include_directories(lib_src 56 | PUBLIC 57 | lib_src/api 58 | lib_src/src/fixed_factor_of_3 59 | lib_src/src/fixed_factor_of_3/ds3 60 | lib_src/src/fixed_factor_of_3/os3 61 | lib_src/src/fixed_factor_of_3_voice 62 | lib_src/src/fixed_factor_of_3_voice/ds3_voice 63 | lib_src/src/fixed_factor_of_3_voice/us3_voice 64 | lib_src/src/multirate_hifi 65 | lib_src/src/multirate_hifi/asrc 66 | lib_src/src/multirate_hifi/ssrc 67 | ${ADDITIONAL_INCLUDE_DIRS_XS3} 68 | ) 69 | 70 | target_compile_options(lib_src 71 | PRIVATE 72 | -O3 73 | -g 74 | ) 75 | 76 | target_link_libraries(lib_src 77 | PUBLIC 78 | # defined in fwk_core 79 | framework_core_legacy_compat 80 | ) 81 | 82 | endif() 83 | endif() 84 | -------------------------------------------------------------------------------- /doc/Doxyfile.inc: -------------------------------------------------------------------------------- 1 | # This file provides overrides to the Doxyfile configuration 2 | 3 | PROJECT_NAME = lib_src 4 | PROJECT_BRIEF = "Sample rate conversion" 5 | 6 | INPUT = ../lib_src/api ../lib_src/src ../lib_src/src/fixed_factor_vpu_voice ../lib_src/src/asrc_task 7 | 8 | PREDEFINED = C_API= EXTERN_C= UNSAFE= __DOXYGEN__=1 9 | 10 | EXTRACT_ALL = YES 11 | 12 | -------------------------------------------------------------------------------- /doc/exclude_patterns.inc: -------------------------------------------------------------------------------- 1 | # The following patterns are to be excluded from the documentation build 2 | CHANGELOG.rst 3 | LICENSE.rst 4 | 5 | # We need to ensure these are not processed twice which breaks figure numbering 6 | # They are included by multi_rate_hifi_src.rst 7 | **/resource_usage_asrc.rst 8 | **/resource_usage_ssrc.rst 9 | -------------------------------------------------------------------------------- /doc/python/README.txt: -------------------------------------------------------------------------------- 1 | INTRODUCTION 2 | ============ 3 | 4 | This folder includes a python script which runs the C emulators for the ASRC, SSRC, OS3 and DS3 modules. 5 | For each model test signals are injected - both a single tone to test the THD performance and a range of tones to 6 | observe roll-off at the top of the band. Using an un-windowed FFT the SNR and THD is calculated. 7 | The logs are scraped to extract MIPS and utilization where supported. 8 | 9 | Tests are run for all suported input and output sample freqencies, and for worst case frequency deviation. 10 | Note that not all modules support all input scenarios due to input and output rate specifications - these cases are ignored. 11 | 12 | The result of this script is the generation an `rst` file which is included into the documentation, 13 | incorporating a full set of charts and summary table. 14 | 15 | 16 | 17 | REQUIREMENTS 18 | ============ 19 | 20 | Python 3.9 or above. Make sure the dependencies listed in lib_src/requirements.txt are installed. 21 | 22 | cd ../../ 23 | pip install -r requirements.txt 24 | 25 | 26 | 27 | To run the script: 28 | 29 | python3 doc_asrc.py 30 | 31 | 32 | By default, this will create a "_build" folder, containing sub-folders: 33 | ./input all generated test files 34 | ./expected simulation output from the models 35 | ./output plots and a csv format log file 36 | ./rst a single rst file which incorporates all the plots and log file as a table 37 | -------------------------------------------------------------------------------- /doc/python/requirements.txt: -------------------------------------------------------------------------------- 1 | -e ../../python 2 | -e ../../tests 3 | 4 | -------------------------------------------------------------------------------- /doc/rst/asrc_task/images/ASRC_block_threads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/asrc_task/images/ASRC_block_threads.png -------------------------------------------------------------------------------- /doc/rst/asrc_task/images/asrc_task_layers.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/asrc_task/images/asrc_task_layers.drawio.png -------------------------------------------------------------------------------- /doc/rst/asynchronous_fifo/images/peak_fifo_48000_500ppm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/asynchronous_fifo/images/peak_fifo_48000_500ppm.png -------------------------------------------------------------------------------- /doc/rst/asynchronous_fifo/images/phase-difference.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/asynchronous_fifo/images/phase-difference.pdf -------------------------------------------------------------------------------- /doc/rst/asynchronous_fifo/images/use-cases.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/asynchronous_fifo/images/use-cases.pdf -------------------------------------------------------------------------------- /doc/rst/images/asrc_structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/asrc_structure.pdf -------------------------------------------------------------------------------- /doc/rst/images/quad_dual_instance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/quad_dual_instance.pdf -------------------------------------------------------------------------------- /doc/rst/images/src_ff3_vpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/src_ff3_vpu.png -------------------------------------------------------------------------------- /doc/rst/images/src_ff3_vpu_pb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/src_ff3_vpu_pb.png -------------------------------------------------------------------------------- /doc/rst/images/src_proc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/src_proc.pdf -------------------------------------------------------------------------------- /doc/rst/images/src_rat_vpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/src_rat_vpu.png -------------------------------------------------------------------------------- /doc/rst/images/src_rat_vpu_pb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/src_rat_vpu_pb.png -------------------------------------------------------------------------------- /doc/rst/images/ssrc_structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/ssrc_structure.pdf -------------------------------------------------------------------------------- /doc/rst/images/stereo_dual_instance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/stereo_dual_instance.pdf -------------------------------------------------------------------------------- /doc/rst/images/stereo_single_instance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/doc/rst/images/stereo_single_instance.pdf -------------------------------------------------------------------------------- /doc/rst/introduction.rst: -------------------------------------------------------------------------------- 1 | 2 | ************ 3 | Introduction 4 | ************ 5 | 6 | lib_src components 7 | ================== 8 | 9 | ``lib_src`` provides both synchronous and asynchronous audio sample rate conversion functions. 10 | 11 | ``lib_src`` includes the following components: 12 | 13 | * HiFi quality multi-rate sample rate conversion: 14 | 15 | * Synchronous Sample Rate Converter (SSRC) function 16 | * Asynchronous Sample Rate Converter (ASRC) function 17 | 18 | * HiFi quality fixed factor sample rate conversion: 19 | 20 | * Synchronous factor of 3 downsample function (``src_ds3``) 21 | * Synchronous factor of 3 oversample function (``src_os3``) 22 | 23 | * Voice quality fixed factor sample rate conversion: 24 | 25 | * Synchronous factor of 3 downsample function (``src_ds3_voice``) 26 | * Synchronous factor of 3 oversample function (``src_us3_voice``) 27 | 28 | * Voice quality fixed factor sample rate conversion optimised for XS3: 29 | 30 | * Synchronous factor of 3 downsample function (``src_ff3_96t_ds``) 31 | * Synchronous factor of 3 oversample function (``src_ff3_96t_us``) 32 | * Synchronous factor of 3/2 downsample function (``src_rat_2_3_96t_ds``) 33 | * Synchronous factor of 3/2 oversample function (``src_rat_3_2_96t_us``) 34 | 35 | * Integration support: 36 | 37 | * Asynchronous FIFO with controller for use with ASRC 38 | 39 | The component listing above includes three different component options that support fixed factor of 40 | 3 up/downsampling. To order to choose which one to use follow these steps: 41 | 42 | #. If HiFi quality (130 dB SNR) up/downsampling is required, use ``src_ds3`` or ``src_os3``. 43 | #. If voice quality (65 dB SNR) is required running on `xcore-200`, use ``src_ds3_voice`` or ``src_us3_voice``. 44 | #. If voice quality (75 dB SNR) is required running `xcore-ai`, use ``src_ff3_96t_ds`` or ``src_ff3_96t_us``. 45 | 46 | Using lib_src 47 | ============= 48 | 49 | ``lib_src`` is intended to be used with the `XCommon CMake `_ 50 | , the `XMOS` application build and dependency management system. 51 | 52 | To use this library, include ``lib_src`` in the application's ``APP_DEPENDENT_MODULES`` list, for example:: 53 | 54 | set(APP_DEPENDENT_MODULES "lib_src") 55 | 56 | Applications should then include the ``src.h`` header file. 57 | 58 | -------------------------------------------------------------------------------- /doc/rst/latency_asrc.rst: -------------------------------------------------------------------------------- 1 | .. _asrc_latency_header: 2 | 3 | 4 | The ASRC algorithm runs a series of cascaded FIR filters to perform the rate conversion including a final adaptive filter to handle the varying rate change between the input and the output. The latency or group delay through the filter depends on the input rate and output rate and the input block size. :numref:`fig_asrc_delay` quantifies the amount of latency in milliseconds seen from the filtering. For input block sizes of greater than four please add `1000 * (INPUT_BLOCK_SIZE - 4) / INPUT_SAMPLE_RATE` milliseconds to the numbers in the table. 5 | 6 | .. _fig_asrc_delay: 7 | .. list-table:: ASRC total filter delay by sample rate in milliseconds for input block size of four 8 | :header-rows: 2 9 | 10 | * - 11 | - 12 | - Output rate 13 | - 14 | - 15 | - 16 | - 17 | - 18 | * - 19 | - 20 | - 44.1 kHz 21 | - 48 kHz 22 | - 88.2 kHz 23 | - 96 kHz 24 | - 176.4 kHz 25 | - 192 kHz 26 | * - Input rate 27 | - 44.1 kHz 28 | - 0.907 29 | - 0.899 30 | - 0.896 31 | - 0.899 32 | - 0.896 33 | - 0.894 34 | * - 35 | - 48 kHz 36 | - 0.910 37 | - 0.833 38 | - 0.830 39 | - 0.823 40 | - 0.825 41 | - 0.823 42 | * - 43 | - 88.2 kHz 44 | - 0.907 45 | - 0.908 46 | - 0.454 47 | - 0.450 48 | - 0.448 49 | - 0.450 50 | * - 51 | - 96 kHz 52 | - 0.931 53 | - 0.833 54 | - 0.455 55 | - 0.417 56 | - 0.415 57 | - 0.411 58 | * - 59 | - 176.4 kHz 60 | - 0.998 61 | - 0.996 62 | - 0.317 63 | - 0.319 64 | - 0.159 65 | - 0.157 66 | * - 67 | - 192 kHz 68 | - 0.998 69 | - 0.917 70 | - 0.295 71 | - 0.292 72 | - 0.148 73 | - 0.146 74 | -------------------------------------------------------------------------------- /doc/rst/lib_src.rst: -------------------------------------------------------------------------------- 1 | ############################### 2 | lib_src: Sample rate conversion 3 | ############################### 4 | 5 | .. toctree:: 6 | :maxdepth: 3 7 | 8 | introduction 9 | multi_rate_hifi_src 10 | fixed_ratio_src 11 | asynchronous_fifo/asynchronous_fifo 12 | asrc_task/asrc_task 13 | ../python/_build/rst/allPlots 14 | -------------------------------------------------------------------------------- /doc/rst/resource_usage_ssrc.rst: -------------------------------------------------------------------------------- 1 | The SSRC algorithm runs a series of cascaded FIR filters to perform the rate conversion. This includes interpolation, decimation and bandwidth limiting filters with a final polyphase FIR filter. The last stage supports the rational rate change of 147:160 or 160:147 allowing conversion between 44.1 kHz family of sample rates to the 48 kHz family of sample rates. 2 | 3 | .. tip:: 4 | :numref:`fig_ssrc_mhz` shows the worst case MHz consumption at a given sample rate using the minimum block size of 4 input samples with dithering disabled. The MHz requirement can be reduced by around 8-12%, depending on sample rate, by increasing the input block size to 16. It is not usefully reduced by increasing block size beyond 16. 5 | 6 | .. tip:: 7 | :numref:`fig_ssrc_mhz` is timed on xcore-200. When using xcore.ai the performance requirement is roughly halved due to VPU optimisations. 8 | 9 | .. _fig_ssrc_mhz: 10 | .. list-table:: SSRC Processor Usage per Channel (MHz) for xcore-200 11 | :header-rows: 2 12 | 13 | * - 14 | - 15 | - Output rate 16 | - 17 | - 18 | - 19 | - 20 | - 21 | * - 22 | - 23 | - 44.1 kHz 24 | - 48 kHz 25 | - 88.2 kHz 26 | - 96 kHz 27 | - 176.4 kHz 28 | - 192 kHz 29 | * - Input rate 30 | - 44.1 kHz 31 | - 1 MHz 32 | - 23 MHz 33 | - 16 MHz 34 | - 26 MHz 35 | - 26 MHz 36 | - 46 MHz 37 | * - 38 | - 48 kHz 39 | - 26 MHz 40 | - 1 MHz 41 | - 28 MHz 42 | - 17 MHz 43 | - 48 MHz 44 | - 29 MHz 45 | * - 46 | - 88.2 kHz 47 | - 18 MHz 48 | - 43 MHz 49 | - 1 MHz 50 | - 46 MHz 51 | - 32 MHz 52 | - 53 MHz 53 | * - 54 | - 96 kHz 55 | - 48 MHz 56 | - 20 MHz 57 | - 52 MHz 58 | - 2 MHz 59 | - 56 MHz 60 | - 35 MHz 61 | * - 62 | - 176.4 kHz 63 | - 33 MHz 64 | - 61 MHz 65 | - 37 MHz 66 | - 67 MHz 67 | - 3 MHz 68 | - 76 MHz 69 | * - 70 | - 192 kHz 71 | - 66 MHz 72 | - 36 MHz 73 | - 70 MHz 74 | - 40 MHz 75 | - 80 MHz 76 | - 4 MHz 77 | 78 | 79 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | project(lib_src_examples) 4 | 5 | add_subdirectory(app_asynchronous_fifo) 6 | add_subdirectory(app_asrc_task) 7 | -------------------------------------------------------------------------------- /examples/app_asrc_task/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(app_asrc_task) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(APP_COMPILER_FLAGS -Os 12 | -g 13 | -Wall 14 | -Wno-xcore-fptrgroup 15 | -DDEBUG_ASRC_TASK=1 16 | -report 17 | -fcmdline-buffer-bytes=16384 18 | ) 19 | 20 | include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) 21 | 22 | set(APP_INCLUDES src) 23 | 24 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../) 25 | 26 | XMOS_REGISTER_APP() 27 | endif() 28 | -------------------------------------------------------------------------------- /examples/app_asrc_task/asrc_task/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(asrc_task) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(APP_COMPILER_FLAGS -Os 12 | -g 13 | -Wall 14 | -Wno-xcore-fptrgroup 15 | -DDEBUG_ASRC_TASK=1 16 | -report 17 | -fcmdline-buffer-bytes=16384 18 | ) 19 | 20 | include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) 21 | 22 | set(APP_INCLUDES src) 23 | 24 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../) 25 | 26 | XMOS_REGISTER_APP() 27 | endif() 28 | -------------------------------------------------------------------------------- /examples/app_asrc_task/asrc_task/src/asrc_task_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define MAX_ASRC_CHANNELS_TOTAL 8 // Used for buffer sizing and FIFO sizing (static) 5 | #define MAX_ASRC_THREADS 4 // Sets upper limit of worker threads for ASRC task 6 | #define SRC_N_IN_SAMPLES 4 // Number of samples per channel in each block passed into SRC each call 7 | // Must be a power of 2 and minimum value is 4 (due to two /2 decimation stages) 8 | // Lower improves latency and memory usage but costs MIPS 9 | #define SRC_N_OUT_IN_RATIO_MAX 5 // Max ratio between samples out:in per processing step (44.1->192 is worst case) 10 | #define SRC_DITHER_SETTING 0 // Enables or disables quantisation of output with dithering to 24b -------------------------------------------------------------------------------- /examples/app_asrc_task/asrc_task/src/asrc_task_receive_samples.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include "asrc_task.h" 5 | 6 | ASRC_TASK_ISR_CALLBACK_ATTR 7 | unsigned receive_asrc_input_samples(chanend_t c_producer, asrc_in_out_t *asrc_io, unsigned *new_input_rate){ 8 | static unsigned asrc_in_counter = 0; 9 | 10 | // Receive stream info from producer 11 | *new_input_rate = chanend_in_word(c_producer); 12 | asrc_io->input_timestamp[asrc_io->input_write_idx] = chanend_in_word(c_producer); 13 | asrc_io->input_channel_count = chanend_in_word(c_producer); 14 | 15 | // Pack into array properly LRLRLRLR or 123412341234 etc. 16 | for(int i = 0; i < asrc_io->input_channel_count; i++){ 17 | int idx = i + asrc_io->input_channel_count * asrc_in_counter; 18 | asrc_io->input_samples[asrc_io->input_write_idx][idx] = chanend_in_word(c_producer); 19 | } 20 | 21 | // Keep track of frame block to ASRC task 22 | if(++asrc_in_counter == SRC_N_IN_SAMPLES){ 23 | asrc_in_counter = 0; 24 | } 25 | 26 | return asrc_in_counter; 27 | } 28 | 29 | // Register the above function for ASRC task 30 | void setup_asrc_io_custom_callback(asrc_in_out_t *asrc_io){ 31 | init_asrc_io_callback(asrc_io, receive_asrc_input_samples); 32 | } 33 | -------------------------------------------------------------------------------- /examples/app_asrc_task/asrc_task/src/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/app_asrc_task/src/asrc_task_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define MAX_ASRC_CHANNELS_TOTAL 8 // Used for buffer sizing and FIFO sizing (static) 5 | #define MAX_ASRC_THREADS 4 // Sets upper limit of worker threads for ASRC task 6 | #define SRC_N_IN_SAMPLES 4 // Number of samples per channel in each block passed into SRC each call 7 | // Must be a power of 2 and minimum value is 4 (due to two /2 decimation stages) 8 | // Lower improves latency and memory usage but costs MIPS 9 | #define SRC_N_OUT_IN_RATIO_MAX 5 // Max ratio between samples out:in per processing step (44.1->192 is worst case) 10 | #define SRC_DITHER_SETTING 0 // Enables or disables quantisation of output with dithering to 24b -------------------------------------------------------------------------------- /examples/app_asrc_task/src/asrc_task_receive_samples.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include "asrc_task.h" 5 | 6 | ASRC_TASK_ISR_CALLBACK_ATTR 7 | unsigned receive_asrc_input_samples(chanend_t c_producer, asrc_in_out_t *asrc_io, unsigned *new_input_rate){ 8 | static unsigned asrc_in_counter = 0; 9 | 10 | // Receive stream info from producer 11 | *new_input_rate = chanend_in_word(c_producer); 12 | asrc_io->input_timestamp[asrc_io->input_write_idx] = chanend_in_word(c_producer); 13 | asrc_io->input_channel_count = chanend_in_word(c_producer); 14 | 15 | // Pack into array properly LRLRLRLR or 123412341234 etc. 16 | for(int i = 0; i < asrc_io->input_channel_count; i++){ 17 | int idx = i + asrc_io->input_channel_count * asrc_in_counter; 18 | asrc_io->input_samples[asrc_io->input_write_idx][idx] = chanend_in_word(c_producer); 19 | } 20 | 21 | // Keep track of frame block to ASRC task 22 | if(++asrc_in_counter == SRC_N_IN_SAMPLES){ 23 | asrc_in_counter = 0; 24 | } 25 | 26 | return asrc_in_counter; 27 | } 28 | 29 | // Register the above function for ASRC task 30 | void setup_asrc_io_custom_callback(asrc_in_out_t *asrc_io){ 31 | init_asrc_io_callback(asrc_io, receive_asrc_input_samples); 32 | } 33 | -------------------------------------------------------------------------------- /examples/app_asrc_task/src/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/app_asynchronous_fifo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | project(app_asynchronous_fifo) 5 | 6 | set(APP_HW_TARGET XK-EVK-XU316) 7 | 8 | set(APP_PCA_ENABLE ON) 9 | 10 | set(APP_COMPILER_FLAGS -O2 11 | -g 12 | -Wall 13 | -report 14 | ) 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) 17 | 18 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../) 19 | 20 | XMOS_REGISTER_APP() 21 | -------------------------------------------------------------------------------- /examples/app_asynchronous_fifo/asynchronous_fifo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | project(asynchronous_fifo) 5 | 6 | set(APP_HW_TARGET XK-EVK-XU316) 7 | 8 | set(APP_PCA_ENABLE ON) 9 | 10 | set(APP_COMPILER_FLAGS -O2 11 | -g 12 | -Wall 13 | -report 14 | ) 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake) 17 | 18 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../) 19 | 20 | XMOS_REGISTER_APP() 21 | -------------------------------------------------------------------------------- /examples/app_asynchronous_fifo/asynchronous_fifo/src/asynchronous_fifo_example.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "asynchronous_fifo.h" 13 | #include "asrc_timestamp_interpolation.h" 14 | 15 | #include 16 | 17 | #include "src.h" 18 | 19 | DECLARE_JOB(producer, (asynchronous_fifo_t *)); 20 | DECLARE_JOB(consumer, (asynchronous_fifo_t *)); 21 | 22 | 23 | void producer(asynchronous_fifo_t *a) { 24 | hwtimer_t tmr = hwtimer_alloc(); 25 | uint32_t now = hwtimer_get_time(tmr); 26 | int step = 2000; 27 | int error; 28 | 29 | for(int32_t i = 0; i < 1000; i++) { 30 | now += step; 31 | hwtimer_set_trigger_time(tmr, now); 32 | int ts = hwtimer_get_time(tmr); 33 | int32_t data = i * i; 34 | error = asynchronous_fifo_producer_put(a, &data, 1, ts); 35 | } 36 | hwtimer_free(tmr); 37 | } 38 | 39 | void consumer(asynchronous_fifo_t *a) { 40 | hwtimer_t tmr = hwtimer_alloc(); 41 | uint32_t now = hwtimer_get_time(tmr); 42 | int step = 2000; 43 | int32_t output_data; 44 | 45 | for(int i = 0; i < 1000; i++) { 46 | now += step; 47 | hwtimer_set_trigger_time(tmr, now); 48 | int ts = hwtimer_get_time(tmr); 49 | asynchronous_fifo_consumer_get(a, &output_data, ts); 50 | printintln(output_data); 51 | } 52 | hwtimer_free(tmr); 53 | } 54 | 55 | #define FIFO_LENGTH 100 56 | 57 | int main(void) { 58 | int64_t array[ASYNCHRONOUS_FIFO_INT64_ELEMENTS(FIFO_LENGTH, 1)]; 59 | asynchronous_fifo_t *asynchronous_fifo_state = (asynchronous_fifo_t *)array; 60 | 61 | asynchronous_fifo_init(asynchronous_fifo_state, 1, FIFO_LENGTH); 62 | asynchronous_fifo_init_PID_fs_codes(asynchronous_fifo_state, 0, 0); 63 | PAR_JOBS( 64 | PJOB(producer, (asynchronous_fifo_state)), 65 | PJOB(consumer, (asynchronous_fifo_state)) 66 | ); 67 | asynchronous_fifo_exit(asynchronous_fifo_state); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/app_asynchronous_fifo/src/asynchronous_fifo_example.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "asynchronous_fifo.h" 13 | #include "asrc_timestamp_interpolation.h" 14 | 15 | #include 16 | 17 | #include "src.h" 18 | 19 | DECLARE_JOB(producer, (asynchronous_fifo_t *)); 20 | DECLARE_JOB(consumer, (asynchronous_fifo_t *)); 21 | 22 | 23 | void producer(asynchronous_fifo_t *a) { 24 | hwtimer_t tmr = hwtimer_alloc(); 25 | uint32_t now = hwtimer_get_time(tmr); 26 | int step = 2000; 27 | int error; 28 | 29 | for(int32_t i = 0; i < 1000; i++) { 30 | now += step; 31 | hwtimer_set_trigger_time(tmr, now); 32 | int ts = hwtimer_get_time(tmr); 33 | int32_t data = i * i; 34 | error = asynchronous_fifo_producer_put(a, &data, 1, ts); 35 | } 36 | hwtimer_free(tmr); 37 | } 38 | 39 | void consumer(asynchronous_fifo_t *a) { 40 | hwtimer_t tmr = hwtimer_alloc(); 41 | uint32_t now = hwtimer_get_time(tmr); 42 | int step = 2000; 43 | int32_t output_data; 44 | 45 | for(int i = 0; i < 1000; i++) { 46 | now += step; 47 | hwtimer_set_trigger_time(tmr, now); 48 | int ts = hwtimer_get_time(tmr); 49 | asynchronous_fifo_consumer_get(a, &output_data, ts); 50 | printintln(output_data); 51 | } 52 | hwtimer_free(tmr); 53 | } 54 | 55 | #define FIFO_LENGTH 100 56 | 57 | int main(void) { 58 | int64_t array[ASYNCHRONOUS_FIFO_INT64_ELEMENTS(FIFO_LENGTH, 1)]; 59 | asynchronous_fifo_t *asynchronous_fifo_state = (asynchronous_fifo_t *)array; 60 | 61 | asynchronous_fifo_init(asynchronous_fifo_state, 1, FIFO_LENGTH); 62 | asynchronous_fifo_init_PID_fs_codes(asynchronous_fifo_state, 0, 0); 63 | PAR_JOBS( 64 | PJOB(producer, (asynchronous_fifo_state)), 65 | PJOB(consumer, (asynchronous_fifo_state)) 66 | ); 67 | asynchronous_fifo_exit(asynchronous_fifo_state); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/deps.cmake: -------------------------------------------------------------------------------- 1 | set(APP_DEPENDENT_MODULES "lib_src") 2 | -------------------------------------------------------------------------------- /lib_src/api/asrc_timestamp_interpolation.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #ifndef _asrc_timestamp_interpolation_h_ 5 | #define _asrc_timestamp_interpolation_h_ 6 | 7 | #include "src.h" 8 | 9 | #ifdef __XC__ 10 | #define UNSAFE unsafe 11 | #else 12 | #define UNSAFE 13 | #endif 14 | 15 | 16 | /** 17 | * \addtogroup src_fifo_interp src_fifo_interp 18 | * 19 | * The public API for using Asynchronous FIFO. 20 | * @{ 21 | */ 22 | 23 | /** 24 | * Function that interpolates a timestamp for a sample generated by the ASRC. 25 | * Given a measured timestamp for the sample going into the ASRC, the asrc control 26 | * structure, and the expected output frequency, this function returns a timestamp 27 | * for when the last sample was produced by the ASRC. 28 | * 29 | * @param timestamp Value of the reference clock taken when the last sample 30 | * fed into the ASRC was sampled. 31 | * 32 | * @param asrc_ctrl ASRC control block 33 | * 34 | * @param ideal_freq Expected base frequency to which the ASRC is operating; 35 | * eg, 48000 or 44100 36 | */ 37 | int asrc_timestamp_interpolation(int timestamp, asrc_ctrl_t * UNSAFE asrc_ctrl, int ideal_freq); 38 | 39 | /**@}*/ // END: addtogroup src_fifo_interp 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lib_src/lib_build_info.cmake: -------------------------------------------------------------------------------- 1 | set(LIB_NAME lib_src) 2 | set(LIB_VERSION 2.7.0) 3 | 4 | set(LIB_DEPENDENT_MODULES "lib_logging(3.3.1)") 5 | 6 | set(LIB_COMPILER_FLAGS -Wno-missing-braces -O3) 7 | 8 | set(LIB_OPTIONAL_HEADERS src_conf.h asrc_task_config.h) 9 | 10 | set(LIB_INCLUDES api 11 | src/fixed_factor_of_3 12 | src/fixed_factor_of_3/ds3 13 | src/fixed_factor_of_3/os3 14 | src/fixed_factor_of_3_voice 15 | src/multirate_hifi 16 | src/multirate_hifi/asrc 17 | src/multirate_hifi/ssrc 18 | src/fixed_factor_vpu_voice 19 | src/asrc_task) 20 | 21 | XMOS_REGISTER_MODULE() 22 | 23 | -------------------------------------------------------------------------------- /lib_src/module_build_info: -------------------------------------------------------------------------------- 1 | VERSION = 2.7.0 2 | 3 | DEPENDENT_MODULES = lib_logging(>=3.3.1) 4 | 5 | MODULE_XCC_FLAGS = $(XCC_FLAGS) \ 6 | -Wno-missing-braces \ 7 | -O3 8 | 9 | OPTIONAL_HEADERS += src_conf.h 10 | 11 | EXPORT_INCLUDE_DIRS = api \ 12 | src/fixed_factor_of_3 \ 13 | src/fixed_factor_of_3/ds3 \ 14 | src/fixed_factor_of_3/os3 \ 15 | src/fixed_factor_of_3_voice \ 16 | src/multirate_hifi \ 17 | src/multirate_hifi/asrc \ 18 | src/multirate_hifi/ssrc \ 19 | src/fixed_factor_vpu_voice \ 20 | src/asrc_task 21 | 22 | INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS) 23 | 24 | -------------------------------------------------------------------------------- /lib_src/src/asrc_timestamp_interpolation.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include 5 | #include "asrc_timestamp_interpolation.h" 6 | 7 | // TODO: replace TODO with BASE and 8/24 with division with MAX 8 | 9 | // TODO: check with 88200 and other input frequencies 10 | 11 | int asrc_timestamp_interpolation(int timestamp, asrc_ctrl_t *asrc_ctrl, int interpolation_ticks) { 12 | // iTimeInt is an 8-bit number; fract a 32 bit number, with the two we make a 16-bit 13 | // fraction that we multiply with and then shift down by 16 bits. 14 | uint32_t fraction_away_from_final_ts = (((asrc_ctrl->iTimeInt - 128) << 8) | 15 | ((asrc_ctrl->uiTimeFract >> 24) & 0xff)); 16 | int32_t left_over_ticks = (fraction_away_from_final_ts * interpolation_ticks) >> 16; 17 | return timestamp + left_over_ticks; 18 | } 19 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.dat: -------------------------------------------------------------------------------- 1 | 5169, 2 | 30344, 3 | 92411, 4 | 193562, 5 | 296359, 6 | 325691, 7 | 212464, 8 | -32886, 9 | -281088, 10 | -341418, 11 | -112035, 12 | 285533, 13 | 533339, 14 | 349745, 15 | -224229, 16 | -754969, 17 | -713889, 18 | 29781, 19 | 954818, 20 | 1207943, 21 | 354407, 22 | -1069372, 23 | -1818145, 24 | -983285, 25 | 1015273, 26 | 2503639, 27 | 1899873, 28 | -695136, 29 | -3195220, 30 | -3129965, 31 | 335, 32 | 3791335, 33 | 4673522, 34 | 1182741, 35 | -4156430, 36 | -6496184, 37 | -2964398, 38 | 4122422, 39 | 8523843, 40 | 5445729, 41 | -3488536, 42 | -10636309, 43 | -8712433, 44 | 2021617, 45 | 12663339, 46 | 12833767, 47 | 549205, 48 | -14379818, 49 | -17869463, 50 | -4551004, 51 | 15495107, 52 | 23889760, 53 | 10412643, 54 | -15628264, 55 | -31023908, 56 | -18775924, 57 | 14241822, 58 | 39569514, 59 | 30769234, 60 | -10463371, 61 | -50268906, 62 | -48765805, 63 | 2543209, 64 | 65155547, 65 | 78974912, 66 | 14229267, 67 | -91131385, 68 | -144396240, 69 | -60382423, 70 | 169204108, 71 | 453172545, 72 | 648273655, 73 | 648273655, 74 | 453172545, 75 | 169204108, 76 | -60382423, 77 | -144396240, 78 | -91131385, 79 | 14229267, 80 | 78974912, 81 | 65155547, 82 | 2543209, 83 | -48765805, 84 | -50268906, 85 | -10463371, 86 | 30769234, 87 | 39569514, 88 | 14241822, 89 | -18775924, 90 | -31023908, 91 | -15628264, 92 | 10412643, 93 | 23889760, 94 | 15495107, 95 | -4551004, 96 | -17869463, 97 | -14379818, 98 | 549205, 99 | 12833767, 100 | 12663339, 101 | 2021617, 102 | -8712433, 103 | -10636309, 104 | -3488536, 105 | 5445729, 106 | 8523843, 107 | 4122422, 108 | -2964398, 109 | -6496184, 110 | -4156430, 111 | 1182741, 112 | 4673522, 113 | 3791335, 114 | 335, 115 | -3129965, 116 | -3195220, 117 | -695136, 118 | 1899873, 119 | 2503639, 120 | 1015273, 121 | -983285, 122 | -1818145, 123 | -1069372, 124 | 354407, 125 | 1207943, 126 | 954818, 127 | 29781, 128 | -713889, 129 | -754969, 130 | -224229, 131 | 349745, 132 | 533339, 133 | 285533, 134 | -112035, 135 | -341418, 136 | -281088, 137 | -32886, 138 | 212464, 139 | 325691, 140 | 296359, 141 | 193562, 142 | 92411, 143 | 30344, 144 | 5169 145 | 146 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.sfp -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.dat: -------------------------------------------------------------------------------- 1 | -2395, 2 | -5393, 3 | -335, 4 | 30919, 5 | 106000, 6 | 220880, 7 | 330830, 8 | 356898, 9 | 231633, 10 | -34118, 11 | -315114, 12 | -418758, 13 | -215874, 14 | 223879, 15 | 613143, 16 | 611221, 17 | 97230, 18 | -651552, 19 | -1069755, 20 | -703606, 21 | 360079, 22 | 1408013, 23 | 1539614, 24 | 397969, 25 | -1370661, 26 | -2411112, 27 | -1652446, 28 | 690618, 29 | 2986814, 30 | 3260739, 31 | 821767, 32 | -2843947, 33 | -4868873, 34 | -3175486, 35 | 1562920, 36 | 5923006, 37 | 6109316, 38 | 1141587, 39 | -5743394, 40 | -9044604, 41 | -5277235, 42 | 3660474, 43 | 11106677, 44 | 10454985, 45 | 809636, 46 | -11221065, 47 | -15824164, 48 | -7781762, 49 | 8274286, 50 | 20081265, 51 | 16848614, 52 | -1306239, 53 | -21547610, 54 | -26990688, 55 | -10324408, 56 | 18264917, 57 | 36552074, 58 | 26888413, 59 | -7970879, 60 | -43212641, 61 | -48496417, 62 | -12420624, 63 | 43678793, 64 | 75992810, 65 | 49227770, 66 | -31884005, 67 | -114708797, 68 | -124890019, 69 | -13609494, 70 | 203956546, 71 | 446378886, 72 | 605431990, 73 | 605431990, 74 | 446378886, 75 | 203956546, 76 | -13609494, 77 | -124890019, 78 | -114708797, 79 | -31884005, 80 | 49227770, 81 | 75992810, 82 | 43678793, 83 | -12420624, 84 | -48496417, 85 | -43212641, 86 | -7970879, 87 | 26888413, 88 | 36552074, 89 | 18264917, 90 | -10324408, 91 | -26990688, 92 | -21547610, 93 | -1306239, 94 | 16848614, 95 | 20081265, 96 | 8274286, 97 | -7781762, 98 | -15824164, 99 | -11221065, 100 | 809636, 101 | 10454985, 102 | 11106677, 103 | 3660474, 104 | -5277235, 105 | -9044604, 106 | -5743394, 107 | 1141587, 108 | 6109316, 109 | 5923006, 110 | 1562920, 111 | -3175486, 112 | -4868873, 113 | -2843947, 114 | 821767, 115 | 3260739, 116 | 2986814, 117 | 690618, 118 | -1652446, 119 | -2411112, 120 | -1370661, 121 | 397969, 122 | 1539614, 123 | 1408013, 124 | 360079, 125 | -703606, 126 | -1069755, 127 | -651552, 128 | 97230, 129 | 611221, 130 | 613143, 131 | 223879, 132 | -215874, 133 | -418758, 134 | -315114, 135 | -34118, 136 | 231633, 137 | 356898, 138 | 330830, 139 | 220880, 140 | 106000, 141 | 30919, 142 | -335, 143 | -5393, 144 | -2395 145 | 146 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.sfp -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_FF3_DS3_H_ 4 | #define _SRC_FF3_DS3_H_ 5 | 6 | #ifdef __XC__ 7 | extern "C" { 8 | #endif 9 | 10 | #define SRC_FF3_DS3_N_COEFS 144 // Number of coefficients must be a multiple of 6 11 | 12 | /* Filters with "_b_" in their filenames have higher attenuation at 13 | * Nyquist (> 60dB compared with 20dB ) but with an earlier cutoff. 14 | */ 15 | #define SRC_FF3_DS3_COEFS_FILE "FilterData/firds3_b_144.dat" 16 | //#define SRC_FF3_DS3_COEFS_FILE "FilterData/firds3_144.dat" 17 | 18 | #ifdef __XC__ 19 | } 20 | #endif 21 | 22 | #endif // _SRC_FF3_DS3_H_ 23 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.dat: -------------------------------------------------------------------------------- 1 | 277234, 2 | 977073, 3 | -843263, 4 | 856598, 5 | -672686, 6 | 89343, 7 | 1063222, 8 | -2949854, 9 | 5699618, 10 | -9389894, 11 | 14020565, 12 | -19488553, 13 | 25571530, 14 | -31908927, 15 | 37990018, 16 | -43139454, 17 | 46485321, 18 | -46884792, 19 | 42725465, 20 | -31390114, 21 | 7629628, 22 | 42687800, 23 | -181147269, 24 | 1944820965, 25 | 507612325, 26 | -273394154, 27 | 195466641, 28 | -150806718, 29 | 118708541, 30 | -93071724, 31 | 71669280, 32 | -53608390, 33 | 38501300, 34 | -26137299, 35 | 16337186, 36 | -8893195, 37 | 3548222, 38 | 1006, 39 | -2085407, 40 | 3045819, 41 | -3208116, 42 | 2864453, 43 | -2264906, 44 | 1600018, 45 | -1024255, 46 | 637393, 47 | 580686, 48 | 15508, 49 | 91031, 50 | 889077, 51 | -98659, 52 | -336105, 53 | 1049234, 54 | -2141667, 55 | 3623829, 56 | -5454434, 57 | 7510918, 58 | -9585659, 59 | 11374005, 60 | -12469289, 61 | 12367266, 62 | -10465607, 63 | 6064852, 64 | 1647616, 65 | -13653011, 66 | 31237928, 67 | -56327772, 68 | 92307702, 69 | -146297414, 70 | 236924736, 71 | -433188720, 72 | 1359517635, 73 | 1359517635, 74 | -433188720, 75 | 236924736, 76 | -146297414, 77 | 92307702, 78 | -56327772, 79 | 31237928, 80 | -13653011, 81 | 1647616, 82 | 6064852, 83 | -10465607, 84 | 12367266, 85 | -12469289, 86 | 11374005, 87 | -9585659, 88 | 7510918, 89 | -5454434, 90 | 3623829, 91 | -2141667, 92 | 1049234, 93 | -336105, 94 | -98659, 95 | 889077, 96 | 91031, 97 | 15508, 98 | 580686, 99 | 637393, 100 | -1024255, 101 | 1600018, 102 | -2264906, 103 | 2864453, 104 | -3208116, 105 | 3045819, 106 | -2085407, 107 | 1006, 108 | 3548222, 109 | -8893195, 110 | 16337186, 111 | -26137299, 112 | 38501300, 113 | -53608390, 114 | 71669280, 115 | -93071724, 116 | 118708541, 117 | -150806718, 118 | 195466641, 119 | -273394154, 120 | 507612325, 121 | 1944820965, 122 | -181147269, 123 | 42687800, 124 | 7629628, 125 | -31390114, 126 | 42725465, 127 | -46884792, 128 | 46485321, 129 | -43139454, 130 | 37990018, 131 | -31908927, 132 | 25571530, 133 | -19488553, 134 | 14020565, 135 | -9389894, 136 | 5699618, 137 | -2949854, 138 | 1063222, 139 | 89343, 140 | -672686, 141 | 856598, 142 | -843263, 143 | 977073, 144 | 277234 145 | 146 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.sfp -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.dat: -------------------------------------------------------------------------------- 1 | -1004, 2 | 662641, 3 | 694900, 4 | -1256274, 5 | 1839429, 6 | -1954657, 7 | 1080237, 8 | 1193906, 9 | -4957339, 10 | 9782217, 11 | -14606619, 12 | 17769018, 13 | -17230183, 14 | 10981423, 15 | 2428909, 16 | -23345286, 17 | 50545842, 18 | -80972064, 19 | 109656222, 20 | -129637924, 21 | 131036378, 22 | -95652015, 23 | -40828481, 24 | 1816295970, 25 | 611869637, 26 | -344126390, 27 | 227978430, 28 | -145489250, 29 | 80665240, 30 | -30973225, 31 | -3918718, 32 | 24822859, 33 | -33663194, 34 | 33320030, 35 | -27133813, 36 | 18327949, 37 | -9526458, 38 | 2465302, 39 | 2071853, 40 | -4111983, 41 | 4224039, 42 | -3209264, 43 | 1833664, 44 | -647622, 45 | -102355, 46 | 992489, 47 | 92757, 48 | -7186, 49 | -16178, 50 | 317999, 51 | 1070693, 52 | -945343, 53 | 671637, 54 | 291690, 55 | -2110817, 56 | 4618841, 57 | -7233336, 58 | 8960442, 59 | -8531840, 60 | 4688761, 61 | 3424760, 62 | -15831706, 63 | 31364955, 64 | -47472492, 65 | 60243796, 66 | -64642830, 67 | 54794752, 68 | -23912637, 69 | -37261872, 70 | 147683310, 71 | -374670058, 72 | 1339136657, 73 | 1339136657, 74 | -374670058, 75 | 147683310, 76 | -37261872, 77 | -23912637, 78 | 54794752, 79 | -64642830, 80 | 60243796, 81 | -47472492, 82 | 31364955, 83 | -15831706, 84 | 3424760, 85 | 4688761, 86 | -8531840, 87 | 8960442, 88 | -7233336, 89 | 4618841, 90 | -2110817, 91 | 291690, 92 | 671637, 93 | -945343, 94 | 1070693, 95 | 317999, 96 | -16178, 97 | -7186, 98 | 92757, 99 | 992489, 100 | -102355, 101 | -647622, 102 | 1833664, 103 | -3209264, 104 | 4224039, 105 | -4111983, 106 | 2071853, 107 | 2465302, 108 | -9526458, 109 | 18327949, 110 | -27133813, 111 | 33320030, 112 | -33663194, 113 | 24822859, 114 | -3918718, 115 | -30973225, 116 | 80665240, 117 | -145489250, 118 | 227978430, 119 | -344126390, 120 | 611869637, 121 | 1816295970, 122 | -40828481, 123 | -95652015, 124 | 131036378, 125 | -129637924, 126 | 109656222, 127 | -80972064, 128 | 50545842, 129 | -23345286, 130 | 2428909, 131 | 10981423, 132 | -17230183, 133 | 17769018, 134 | -14606619, 135 | 9782217, 136 | -4957339, 137 | 1193906, 138 | 1080237, 139 | -1954657, 140 | 1839429, 141 | -1256274, 142 | 694900, 143 | 662641, 144 | -1004 145 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.sfp -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_FF3_OS3_H_ 4 | #define _SRC_FF3_OS3_H_ 5 | 6 | #ifdef __XC__ 7 | extern "C" { 8 | #endif 9 | 10 | #define SRC_FF3_OS3_N_COEFS 144 // Number of coefficients must be a multiple of 6 11 | #define SRC_FF3_OS3_N_PHASES 3 // Number of output phases (3 as OS3 over-sample by 3) 12 | 13 | /* Filters with "_b_" in their filenames have higher attenuation at 14 | * 8kHz (> 60dB compared with 20dB ) but with an earlier cutoff. 15 | */ 16 | // #define SRC_FF3_OS3_COEFS_FILE "FilterData/firos3_b_144.dat" 17 | #define SRC_FF3_OS3_COEFS_FILE "FilterData/firos3_144.dat" 18 | 19 | #ifdef __XC__ 20 | } 21 | #endif 22 | 23 | #endif // _SRC_FF3_OS3_H_ 24 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_FF3_FIR_INNER_LOOP_ASM_H_ 4 | #define _SRC_FF3_FIR_INNER_LOOP_ASM_H_ 5 | 6 | #define SRC_FF3_N_LOOPS_PER_ASM 12 7 | 8 | void src_ff3_fir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count); 9 | void src_ff3_fir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count); 10 | 11 | 12 | #endif // _SRC_FF3_FIR_INNER_LOOP_ASM_H_ 13 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3_voice/ds3_voice/src_ff3v_ds3_voice.S: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | .section .dp.data,"awd",@progbits 4 | .text 5 | 6 | #define STACKWORDS 4 7 | 8 | #define c0 r4 9 | #define c1 r5 10 | #define d0 r6 11 | 12 | #define s r11 13 | 14 | .cc_top src_ds3_voice_add_sample.function 15 | .globl src_ds3_voice_add_sample 16 | .align 4 17 | .type src_ds3_voice_add_sample,@function 18 | src_ds3_voice_add_sample://(int64_t sum, int32_t data[], int32_t coefs[], int32_t sample); 19 | 20 | .issue_mode dual 21 | DUALENTSP_lu6 STACKWORDS 22 | 23 | std r4, r5, sp[0] 24 | std r6, r7, sp[1] 25 | 26 | ldw s, sp[STACKWORDS+1] 27 | 28 | bl src_ff3v_fir_impl 29 | 30 | ldd r4, r5, sp[0] 31 | ldd r6, r7, sp[1] 32 | retsp STACKWORDS 33 | 34 | .src_ds3_voice_add_sample_tmp: 35 | .size src_ds3_voice_add_sample, .src_ds3_voice_add_sample_tmp-src_ds3_voice_add_sample 36 | .align 4 37 | .cc_bottom src_ds3_voice_add_sample.function 38 | 39 | .set src_ds3_voice_add_sample.nstackwords, STACKWORDS 40 | .globl src_ds3_voice_add_sample.nstackwords 41 | .set src_ds3_voice_add_sample.maxcores,1 42 | .globl src_ds3_voice_add_sample.maxcores 43 | .set src_ds3_voice_add_sample.maxtimers,0 44 | .globl src_ds3_voice_add_sample.maxtimers 45 | .set src_ds3_voice_add_sample.maxchanends,0 46 | .globl src_ds3_voice_add_sample.maxchanends 47 | 48 | .cc_top src_ds3_voice_add_final_sample.function 49 | .globl src_ds3_voice_add_final_sample 50 | .align 4 51 | .type src_ds3_voice_add_final_sample,@function 52 | src_ds3_voice_add_final_sample://(int64_t sum, int32_t data[], int32_t coefs[], int32_t sample); 53 | 54 | .issue_mode dual 55 | DUALENTSP_lu6 STACKWORDS 56 | 57 | std r4, r5, sp[0] 58 | std r6, r7, sp[1] 59 | 60 | ldw s, sp[STACKWORDS+1] 61 | 62 | bl src_ff3v_fir_impl 63 | 64 | {ldc d0, 31; nop} 65 | lextract r0, r1, r0, d0, 32 66 | 67 | ldaw s, cp[src_ff3v_fir_comp_ds] 68 | ldw s, s[0] 69 | {ldc c0, 0; ldc c1, 0} 70 | maccs c0, c1, r0, s 71 | 72 | ldaw s, cp[src_ff3v_fir_comp_q_ds] 73 | ldw s, s[0] 74 | 75 | lsats c0, c1, s 76 | lextract r0, c0, c1, s, 32 77 | 78 | ldd r4, r5, sp[0] 79 | ldd r6, r7, sp[1] 80 | {retsp STACKWORDS; ldc r1, 0} 81 | 82 | .src_ds3_voice_add_final_sample_tmp: 83 | .size src_ds3_voice_add_final_sample, .src_ds3_voice_add_final_sample_tmp-src_ds3_voice_add_final_sample 84 | .align 4 85 | .cc_bottom src_ds3_voice_add_final_sample.function 86 | 87 | .set src_ds3_voice_add_final_sample.nstackwords, STACKWORDS 88 | .globl src_ds3_voice_add_final_sample.nstackwords 89 | .set src_ds3_voice_add_final_sample.maxcores,1 90 | .globl src_ds3_voice_add_final_sample.maxcores 91 | .set src_ds3_voice_add_final_sample.maxtimers,0 92 | .globl src_ds3_voice_add_final_sample.maxtimers 93 | .set src_ds3_voice_add_final_sample.maxchanends,0 94 | .globl src_ds3_voice_add_final_sample.maxchanends 95 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.S: -------------------------------------------------------------------------------- 1 | // Copyright 2017-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | .section .dp.data,"awd",@progbits 4 | .text 5 | 6 | #define sum_l r0 7 | #define sum_h r1 8 | #define data r2 9 | #define coefs r3 10 | 11 | #define c0 r4 12 | #define c1 r5 13 | #define d0 r6 14 | #define d1 r7 15 | 16 | #define s r11 17 | 18 | #define EVEN_STEP(N) \ 19 | ldd c1, c0, coefs[N];\ 20 | maccs sum_h, sum_l, c0, s;\ 21 | ldd d1, d0, data[N];\ 22 | maccs sum_h, sum_l, c1, d0;\ 23 | std d0, s, data[N]; 24 | 25 | #define ODD_STEP(N) \ 26 | ldd c1, c0, coefs[N];\ 27 | maccs sum_h, sum_l, c0, d1;\ 28 | ldd s, d0, data[N];\ 29 | maccs sum_h, sum_l, c1, d0;\ 30 | std d0, d1, data[N]; 31 | 32 | .cc_top src_ff3v_fir_impl.function 33 | .globl src_ff3v_fir_impl 34 | .align 8 35 | .type src_ff3v_fir_impl,@function 36 | .issue_mode dual 37 | src_ff3v_fir_impl: 38 | EVEN_STEP(0); 39 | ODD_STEP(1); 40 | EVEN_STEP(2); 41 | ODD_STEP(3); 42 | EVEN_STEP(4); 43 | ODD_STEP(5); 44 | EVEN_STEP(6); 45 | ODD_STEP(7); 46 | EVEN_STEP(8); 47 | ODD_STEP(9); 48 | EVEN_STEP(10); 49 | ODD_STEP(11); 50 | {retsp 0; nop} 51 | .src_ff3v_fir_impl_tmp: 52 | .size src_ff3v_fir_impl, .src_ff3v_fir_impl_tmp-src_ff3v_fir_impl 53 | .align 4 54 | .cc_bottom src_ff3v_fir_impl.function 55 | 56 | .set src_ff3v_fir_impl.nstackwords, 0 57 | .globl src_ff3v_fir_impl.nstackwords 58 | .set src_ff3v_fir_impl.maxcores,1 59 | .globl src_ff3v_fir_impl.maxcores 60 | .set src_ff3v_fir_impl.maxtimers,0 61 | .globl src_ff3v_fir_impl.maxtimers 62 | .set src_ff3v_fir_impl.maxchanends,0 63 | .globl src_ff3v_fir_impl.maxchanends 64 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // 4 | // This file is generated using src_ff3v_fir_generator.py 5 | // 6 | // Do not modify it directly, changes may be overwritten! 7 | // 8 | 9 | #ifndef _SRC_FF3V_FIR_H_ 10 | #define _SRC_FF3V_FIR_H_ 11 | 12 | #include 13 | 14 | #define SRC_FF3V_FIR_NUM_PHASES (3) 15 | #define SRC_FF3V_FIR_TAPS_PER_PHASE (24) 16 | 17 | extern const unsigned src_ff3v_fir_comp_q_ds; 18 | extern const int32_t src_ff3v_fir_comp_ds; 19 | 20 | extern const unsigned src_ff3v_fir_comp_q_us; 21 | extern const int32_t src_ff3v_fir_comp_us; 22 | 23 | extern int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE]; 24 | 25 | #if defined(__XC__) 26 | extern const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE]; 27 | #define src_ff3v_fir_coefs src_ff3v_fir_coefs_xc 28 | #else 29 | extern const int32_t (*src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE]; 30 | #define src_ff3v_fir_coefs src_ff3v_fir_coefs_c 31 | #endif 32 | 33 | #endif // _SRC_FF3V_FIR_H_ 34 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.xc: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // 4 | // This file is generated using src_ff3v_fir_generator.py 5 | // 6 | // Do not modify it directly, changes may be overwritten! 7 | // 8 | 9 | #include "src_ff3v_fir.h" 10 | #include 11 | 12 | /** Used for FIR compensation for decimation*/ 13 | const unsigned src_ff3v_fir_comp_q_ds = 29; 14 | 15 | /** Used for FIR compensation for decimation*/ 16 | const int32_t src_ff3v_fir_comp_ds = 1112549167; 17 | 18 | /** Used for FIR compensation for upsampling*/ 19 | const unsigned src_ff3v_fir_comp_q_us = 27; 20 | 21 | /** Used for FIR compensation for upsampling*/ 22 | const int32_t src_ff3v_fir_comp_us = 834411870; 23 | 24 | /** Used for self testing src_ds3_voice and src_us3_voice functionality */ 25 | int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE] = { 26 | 1005142, 1367390, 29412, -4146838, -10154637, -14619962, 27 | -13776186, -6744830, 2692812, 8121360, 5508436, -2814524, 28 | -9285443, -7351357, 2193307, 10930750, 9953155, -1338213, 29 | -13227624, -13683020, -123797, 16201217, 19008511, 2582573, 30 | -20205295, -27041699, -6837031, 26249516, 40760231, 15085431, 31 | -37763299, -71330011, -37235961, 74585089, 219245690, 320542055, 32 | 320542055, 219245690, 74585089, -37235961, -71330011, -37763299, 33 | 15085431, 40760231, 26249516, -6837031, -27041699, -20205295, 34 | 2582573, 19008511, 16201217, -123797, -13683020, -13227624, 35 | -1338213, 9953155, 10930750, 2193307, -7351357, -9285443, 36 | -2814524, 5508436, 8121360, 2692812, -6744830, -13776186, 37 | -14619962, -10154637, -4146838, 29412, 1367390, 1005142, 38 | 39 | }; 40 | 41 | /** Coefficients for use with src_ds3_voice and src_us3_voice functions */ 42 | static const int32_t [[aligned(8)]] src_ff3v_fir_coefs_i[SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE] = { 43 | { 44 | 29412, -14619962, 2692812, -2814524, 2193307, -1338213, 45 | -123797, 2582573, -6837031, 15085431, -37235961, 320542055, 46 | 74585089, -37763299, 26249516, -20205295, 16201217, -13227624, 47 | 10930750, -9285443, 8121360, -13776186, -4146838, 1005142, 48 | }, 49 | { 50 | 1367390, -10154637, -6744830, 5508436, -7351357, 9953155, 51 | -13683020, 19008511, -27041699, 40760231, -71330011, 219245690, 52 | 219245690, -71330011, 40760231, -27041699, 19008511, -13683020, 53 | 9953155, -7351357, 5508436, -6744830, -10154637, 1367390, 54 | }, 55 | { 56 | 1005142, -4146838, -13776186, 8121360, -9285443, 10930750, 57 | -13227624, 16201217, -20205295, 26249516, -37763299, 74585089, 58 | 320542055, -37235961, 15085431, -6837031, 2582573, -123797, 59 | -1338213, 2193307, -2814524, 2692812, -14619962, 29412, 60 | }, 61 | }; 62 | 63 | unsafe { 64 | const int32_t (* unsafe src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i; 65 | } 66 | 67 | const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i; 68 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_24t.S: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define FUNCTION_NAME conv_s32_24t 5 | 6 | #define NSTACKWORDS (8) 7 | #define STACK_VEC_TMP (NSTACKWORDS - 8) 8 | 9 | #define state r0 10 | #define coef r1 11 | #define buff r2 12 | #define _32 r3 13 | 14 | .text 15 | .issue_mode dual 16 | .globl FUNCTION_NAME; 17 | .type FUNCTION_NAME,@function 18 | .align 16 19 | .cc_top FUNCTION_NAME.function,FUNCTION_NAME 20 | 21 | FUNCTION_NAME: // (int32_t * state, int32_t * coef) 22 | dualentsp NSTACKWORDS 23 | #if (defined(__XS3A__)) // Only available for XS3 with VPU 24 | // r4 - r10 are not used here 25 | 26 | // Setting up the vpu and some constants 27 | { ldaw buff, sp[STACK_VEC_TMP] ; ldc r11, 0 } 28 | { ldc _32, 32 ; vsetc r11 } 29 | { vclrdr ; mov r11, state } 30 | 31 | // Do convolution 32 | { ; vldc r11[0] } 33 | { add r11, r11, _32 ; vlmaccr coef[0] } 34 | 35 | { add coef, coef, _32 ; vldc r11[0] } 36 | { add r11, r11, _32 ; vlmaccr coef[0] } 37 | 38 | { add coef, coef, _32 ; vldc r11[0] } 39 | { ; vlmaccr coef[0] } 40 | // vR [0 - 2] has 3 macc results, store them 41 | { ; vstr buff[0] } 42 | 43 | #undef state 44 | #define out r0 45 | 46 | #undef coef 47 | #define tmp0 r1 48 | 49 | #undef _32 50 | #define tmp1 r3 51 | 52 | // Load all the results and add them together 53 | ldd out, tmp1, buff[0] 54 | 55 | { add out, out, tmp1 ; ldw tmp0, buff[2] } 56 | { add out, out, tmp0 ; } 57 | #endif // Only available for XS3 with VPU 58 | retsp NSTACKWORDS 59 | 60 | .cc_bottom FUNCTION_NAME.function; 61 | .set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords; 62 | .set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores; 63 | .set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers; 64 | .set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends; 65 | 66 | #undef FUNCTION_NAME 67 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_32t.S: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define FUNCTION_NAME conv_s32_32t 5 | 6 | #define NSTACKWORDS (8) 7 | #define STACK_VEC_TMP (NSTACKWORDS - 8) 8 | 9 | #define state r0 10 | #define coef r1 11 | #define buff r2 12 | #define _32 r3 13 | 14 | .text 15 | .issue_mode dual 16 | .globl FUNCTION_NAME; 17 | .type FUNCTION_NAME,@function 18 | .align 16 19 | .cc_top FUNCTION_NAME.function,FUNCTION_NAME 20 | 21 | FUNCTION_NAME: // (int32_t * state, int32_t * coef) 22 | dualentsp NSTACKWORDS 23 | #if (defined(__XS3A__)) // Only available for XS3 with VPU 24 | // r4 - r10 are not used here 25 | 26 | // Setting up the vpu and some constants 27 | { ldaw buff, sp[STACK_VEC_TMP] ; ldc r11, 0 } 28 | { ldc _32, 32 ; vsetc r11 } 29 | { vclrdr ; mov r11, state } 30 | 31 | // Do convolution 32 | { ; vldc r11[0] } 33 | { add r11, r11, _32 ; vlmaccr coef[0] } 34 | 35 | { add coef, coef, _32 ; vldc r11[0] } 36 | { add r11, r11, _32 ; vlmaccr coef[0] } 37 | 38 | { add coef, coef, _32 ; vldc r11[0] } 39 | { add r11, r11, _32 ; vlmaccr coef[0] } 40 | 41 | { add coef, coef, _32 ; vldc r11[0] } 42 | { ; vlmaccr coef[0] } 43 | // vR [0 - 3] has 4 macc results, store them 44 | { ; vstr buff[0] } 45 | 46 | #undef state 47 | #define out r0 48 | 49 | #undef coef 50 | #define tmp0 r1 51 | 52 | #undef _32 53 | #define tmp1 r3 54 | 55 | // Load all the results and add them together 56 | ldd out, tmp1, buff[0] 57 | 58 | { add out, out, tmp1 ; ldw tmp0, buff[2] } 59 | { add out, out, tmp0 ; ldw tmp1, buff[3] } 60 | { add out, out, tmp1 ; } 61 | #endif // Only available for XS3 with VPU 62 | retsp NSTACKWORDS 63 | 64 | .cc_bottom FUNCTION_NAME.function; 65 | .set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords; 66 | .set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores; 67 | .set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers; 68 | .set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends; 69 | 70 | #undef FUNCTION_NAME 71 | 72 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/asm/push_s32_48t.S: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define FUNCTION_NAME push_s32_48t 5 | 6 | #define NSTACKWORDS (0) 7 | 8 | #define state r0 9 | #define new_samp r1 10 | #define indx r2 11 | #define _32 r3 12 | 13 | .text 14 | .issue_mode dual 15 | .globl FUNCTION_NAME; 16 | .type FUNCTION_NAME,@function 17 | .align 16 18 | .cc_top FUNCTION_NAME.function,FUNCTION_NAME 19 | 20 | FUNCTION_NAME: // (int32_t * state, int32_t new_samp) 21 | dualentsp NSTACKWORDS 22 | #if (defined(__XS3A__)) // Only available for XS3 with VPU 23 | 24 | // r4 - r10 are not used here 25 | 26 | // Setting up the vpu and a poiter to the state[39] 27 | { ldc _32, 32 ; ldc r11, 0 } 28 | { ldc indx, 39 ; vsetc r11 } 29 | { ldaw r11, state[indx] ; } // r11 -> st[39 - 47] 30 | 31 | #undef indx 32 | #define buff r2 33 | 34 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[40 - 48] // vR has st[39 - 47] 35 | { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[31 - 39] // buff has vR 36 | 37 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[32 - 40] // vR has st[31 - 39] 38 | { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[23 - 31] // buff has vR 39 | 40 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[24 - 32] // vR has st[23 - 31] 41 | { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[15 - 23] // buff has vR 42 | 43 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[16 - 24] // vR has st[15 - 23] 44 | { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[7 - 15] // buff has vR 45 | 46 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[8 - 16] // vR has st[7 - 15] 47 | { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[-1 - 7] // buff has vR 48 | 49 | { add buff, r11, 4 ; vldr r11[0] } // buff -> st[0 - 8] // vR has st[-1 - 7] 50 | { ; vstr buff[0] } // buff has vR 51 | 52 | // put new_samp in state[0] 53 | { ; stw new_samp, state[0] } 54 | 55 | #endif // Only available for XS3 with VPU 56 | retsp NSTACKWORDS 57 | 58 | .cc_bottom FUNCTION_NAME.function; 59 | .set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords; 60 | .set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores; 61 | .set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers; 62 | .set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends; 63 | 64 | #undef FUNCTION_NAME 65 | 66 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.c: -------------------------------------------------------------------------------- 1 | // Copyright 2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | /*********************************/ 5 | /* AUTOGENERATED. DO NOT MODIFY! */ 6 | /*********************************/ 7 | 8 | // Use src_ff3_fir_gen.py script to regenare this file 9 | // python src_ff3_fir_gen.py -gc True -ntp 32 -np 3 10 | 11 | #include "src_ff3_fir_coefs.h" 12 | #include 13 | 14 | /** q31 coefficients to use for debugging ff3 sample rate conversion */ 15 | const int32_t ALIGNMENT(8) src_ff3_fir_coefs_debug[SRC_FF3_FIR_NUM_PHASES * SRC_FF3_FIR_TAPS_PER_PHASE] = { 16 | -132660, -391256, -272653, 294018, 790734, 513772, 17 | -561508, -1423266, -881735, 972885, 2366363, 1416412, 18 | -1572615, -3711773, -2165391, 2413069, 5568888, 3186277, 19 | -3557131, -8071663, -4551171, 5083569, 11392367, 6355363, 20 | -7097804, -15768801, -8734511, 9753621, 21559523, 11899941, 21 | -13298806, -29362449, -16216509, 18178957, 40294588, 22394094, 22 | -25305013, -56753765, -32043220, 36887788, 85009440, 49769829, 23 | -60002604, -148154004, -96041427, 135812786, 454448559, 683203534, 24 | 683203534, 454448559, 135812786, -96041427, -148154004, -60002604, 25 | 49769829, 85009440, 36887788, -32043220, -56753765, -25305013, 26 | 22394094, 40294588, 18178957, -16216509, -29362449, -13298806, 27 | 11899941, 21559523, 9753621, -8734511, -15768801, -7097804, 28 | 6355363, 11392367, 5083569, -4551171, -8071663, -3557131, 29 | 3186277, 5568888, 2413069, -2165391, -3711773, -1572615, 30 | 1416412, 2366363, 972885, -881735, -1423266, -561508, 31 | 513772, 790734, 294018, -272653, -391256, -132660, 32 | 33 | }; 34 | 35 | /** q30 coefficients to use for the ff3 48 - 16 kHz polyphase FIR filtering */ 36 | const int32_t ALIGNMENT(8) src_ff3_fir_coefs[SRC_FF3_FIR_NUM_PHASES][SRC_FF3_FIR_TAPS_PER_PHASE] = { 37 | { 38 | -136326, 256886, -440867, 708206, -1082695, 1593138, 39 | -2275585, 3177682, -4367255, 5949971, -8108254, 11197047, 40 | -16021610, 24884914, -48020712, 341601760, 67906392, -30001302, 41 | 18443894, -12652507, 9089479, -6649403, 4876810, -3548902, 42 | 2541785, -1778566, 1206534, -786307, 486442, -280754, 43 | 147009, -66330,}, 44 | { 45 | -195628, 395367, -711633, 1183181, -1855886, 2784444, 46 | -4035831, 5696184, -7884400, 10779762, -14681225, 20147294, 47 | -28376882, 42504720, -74077000, 227224272, 227224272, -74077000, 48 | 42504720, -28376882, 20147294, -14681225, 10779762, -7884400, 49 | 5696184, -4035831, 2784444, -1855886, 1183181, -711633, 50 | 395367, -195628,}, 51 | { 52 | -66330, 147009, -280754, 486442, -786307, 1206534, 53 | -1778566, 2541785, -3548902, 4876810, -6649403, 9089479, 54 | -12652507, 18443894, -30001302, 67906392, 341601760, -48020712, 55 | 24884914, -16021610, 11197047, -8108254, 5949971, -4367255, 56 | 3177682, -2275585, 1593138, -1082695, 708206, -440867, 57 | 256886, -136326,}, 58 | }; 59 | 60 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | /*********************************/ 5 | /* AUTOGENERATED. DO NOT MODIFY! */ 6 | /*********************************/ 7 | 8 | // Use src_ff3_fir_gen.py script to regenare this file 9 | // python src_ff3_fir_gen.py -gc True -ntp 32 -np 3 10 | 11 | #ifndef _SRC_FF3_COEFS_H_ 12 | #define _SRC_FF3_COEFS_H_ 13 | 14 | #include 15 | 16 | #ifndef ALIGNMENT 17 | # ifdef __xcore__ 18 | # define ALIGNMENT(N) __attribute__((aligned (N))) 19 | # else 20 | # define ALIGNMENT(N) 21 | # endif 22 | #endif 23 | 24 | #define SRC_FF3_FIR_NUM_PHASES (3) 25 | #define SRC_FF3_FIR_TAPS_PER_PHASE (32) 26 | 27 | /** q31 coefficients to use for debugging ff3 sample rate conversion */ 28 | extern const int32_t src_ff3_fir_coefs_debug[SRC_FF3_FIR_NUM_PHASES * SRC_FF3_FIR_TAPS_PER_PHASE]; 29 | 30 | /** q30 coefficients to use for the ff3 48 - 16 kHz polyphase FIR filtering */ 31 | extern const int32_t src_ff3_fir_coefs[SRC_FF3_FIR_NUM_PHASES][SRC_FF3_FIR_TAPS_PER_PHASE]; 32 | 33 | #endif // _SRC_FF3_COEFS_H_ 34 | 35 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/src_low_level.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #ifndef _SRC_LOW_LEVEL_H_ 5 | #define _SRC_LOW_LEVEL_H_ 6 | 7 | /** 8 | * @brief Perfoms VPU-optimised convolution for s32 type integers 9 | * 10 | * @param samples Samples array 11 | * @param coef FIR coefficients array 12 | * @note Both samples and coef has to have 24 values int32_t in them 13 | * @note Both samples and coef have to be 8 bit aligned 14 | */ 15 | int32_t conv_s32_24t(const int32_t * samples, const int32_t * coef); 16 | 17 | /** 18 | * @brief Perforns VPU-optimised FIR filtering for s32 type integers 19 | * 20 | * @param state State that keep previous samples 21 | * @param coef FIR coefficients array 22 | * @param new_samp New sample to put in the state 23 | * @note Both state and coef has to have 24 values int32_t in them 24 | * @note Both state and coef have to be 8 bit aligned 25 | */ 26 | int32_t fir_s32_24t(int32_t * state, const int32_t * coef, int32_t new_samp); 27 | 28 | /** 29 | * @brief Perfoms VPU-optimised convolution for s32 type integers 30 | * 31 | * @param samples Samples array 32 | * @param coef FIR coefficients array 33 | * @note Both samples and coef has to have 32 values int32_t in them 34 | * @note Both samples and coef have to be 8 bit aligned 35 | */ 36 | int32_t conv_s32_32t(const int32_t * samples, const int32_t * coef); 37 | 38 | /** 39 | * @brief Perforns VPU-optimised FIR filtering for s32 type integers 40 | * 41 | * @param state State that keep previous samples 42 | * @param coef FIR coefficients array 43 | * @param new_samp New sample to put in the state 44 | * @note Both state and coef has to have 32 values int32_t in them 45 | * @note Both state and coef have to be 8 bit aligned 46 | */ 47 | int32_t fir_s32_32t(int32_t * state, const int32_t * coef, int32_t new_samp); 48 | 49 | /** 50 | * @brief Perforns VPU-optimised ring buffer shift for s32 type integers 51 | * 52 | * @param state State that keep previous samples 53 | * @param new_samp New sample to put in the state 54 | * @note Both state and coef has to have 48 values int32_t in them 55 | * @note Both state and coef have to be 8 bit aligned 56 | */ 57 | void push_s32_48t(int32_t * state, int32_t new_samp); 58 | 59 | /** 60 | * @brief Perforns VPU-optimised FIR filtering for s32 type integers 61 | * 62 | * @param state State that keep previous samples 63 | * @param coef FIR coefficients array 64 | * @param new_samp New sample to put in the state 65 | * @note Both state and coef has to have 48 values int32_t in them 66 | * @note Both state and coef have to be 8 bit aligned 67 | */ 68 | int32_t fir_s32_48t(int32_t * state, const int32_t * coef, int32_t new_samp); 69 | 70 | #endif // _SRC_LOW_LEVEL_H_ 71 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.c: -------------------------------------------------------------------------------- 1 | // Copyright 2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | /*********************************/ 5 | /* AUTOGENERATED. DO NOT MODIFY! */ 6 | /*********************************/ 7 | 8 | // Use src_rat_fir_gen.py script to regenare this file 9 | // python src_rat_fir_gen.py -gc True -nt 96 10 | 11 | #include "src_rat_fir_coefs.h" 12 | #include 13 | 14 | /** q30 coefficients to use for the 48 -> 32 kHz polyphase rational factor downsampling */ 15 | const int32_t ALIGNMENT(8) src_rat_fir_ds_coefs[SRC_RAT_FIR_NUM_PHASES_DS][SRC_RAT_FIR_TAPS_PER_PHASE_DS] = { 16 | { 17 | -37518, -12954, 215278, -239478, -263107, 939176, 18 | -724308, -879964, 2499126, -1681211, -2092592, 5401196, 19 | -3401730, -4251005, 10510310, -6447506, -8092907, 19936433, 20 | -12408241, -16117127, 42378484, -29745967, -48209846, 227198230, 21 | 341824286, 67661646, -73999660, 25030944, 18189153, -28205672, 22 | 11237632, 8863615, -14437276, 5881230, 4701938, -7597786, 23 | 3022648, 2420957, -3741363, 1394185, 1128882, -1587718, 24 | 513087, 436331, -497504, 103937, 112484, -52024, 25 | }, 26 | { 27 | -52024, 112484, 103937, -497504, 436331, 513087, 28 | -1587718, 1128882, 1394185, -3741363, 2420957, 3022648, 29 | -7597786, 4701938, 5881230, -14437276, 8863615, 11237632, 30 | -28205672, 18189153, 25030944, -73999660, 67661646, 341824286, 31 | 227198230, -48209846, -29745967, 42378484, -16117127, -12408241, 32 | 19936433, -8092907, -6447506, 10510310, -4251005, -3401730, 33 | 5401196, -2092592, -1681211, 2499126, -879964, -724308, 34 | 939176, -263107, -239478, 215278, -12954, -37518, 35 | }, 36 | 37 | }; 38 | 39 | /** q30 coefficients to use for the 32 -> 48 kHz polyphase rational factor upsampling */ 40 | const int32_t ALIGNMENT(8) src_rat_fir_us_coefs[SRC_RAT_FIR_NUM_PHASES_US][SRC_RAT_FIR_TAPS_PER_PHASE_US] = { 41 | { 42 | -37518, 112484, -239478, 436331, -724308, 1128882, 43 | -1681211, 2420957, -3401730, 4701938, -6447506, 8863615, 44 | -12408241, 18189153, -29745967, 67661646, 341824286, -48209846, 45 | 25030944, -16117127, 11237632, -8092907, 5881230, -4251005, 46 | 3022648, -2092592, 1394185, -879964, 513087, -263107, 47 | 103937, -12954,}, 48 | { 49 | -52024, 215278, -497504, 939176, -1587718, 2499126, 50 | -3741363, 5401196, -7597786, 10510310, -14437276, 19936433, 51 | -28205672, 42378484, -73999660, 227198230, 227198230, -73999660, 52 | 42378484, -28205672, 19936433, -14437276, 10510310, -7597786, 53 | 5401196, -3741363, 2499126, -1587718, 939176, -497504, 54 | 215278, -52024,}, 55 | { 56 | -12954, 103937, -263107, 513087, -879964, 1394185, 57 | -2092592, 3022648, -4251005, 5881230, -8092907, 11237632, 58 | -16117127, 25030944, -48209846, 341824286, 67661646, -29745967, 59 | 18189153, -12408241, 8863615, -6447506, 4701938, -3401730, 60 | 2420957, -1681211, 1128882, -724308, 436331, -239478, 61 | 112484, -37518,}, 62 | 63 | }; 64 | 65 | -------------------------------------------------------------------------------- /lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | /*********************************/ 5 | /* AUTOGENERATED. DO NOT MODIFY! */ 6 | /*********************************/ 7 | 8 | // Use src_rat_fir_gen.py script to regenare this file 9 | // python src_rat_fir_gen.py -gc True -nt 96 10 | 11 | #ifndef _SRC_RAT_COEFS_H_ 12 | #define _SRC_RAT_COEFS_H_ 13 | 14 | #include 15 | 16 | #ifndef ALIGNMENT 17 | # ifdef __xcore__ 18 | # define ALIGNMENT(N) __attribute__((aligned (N))) 19 | # else 20 | # define ALIGNMENT(N) 21 | # endif 22 | #endif 23 | 24 | #define SRC_RAT_FIR_NUM_TAPS (96) 25 | #define SRC_RAT_FIR_NUM_PHASES_DS (2) 26 | #define SRC_RAT_FIR_TAPS_PER_PHASE_DS (48) 27 | #define SRC_RAT_FIR_NUM_PHASES_US (3) 28 | #define SRC_RAT_FIR_TAPS_PER_PHASE_US (32) 29 | 30 | /** q30 coefficients to use for the 48 -> 32 kHz polyphase rational factor downsampling */ 31 | extern const int32_t src_rat_fir_ds_coefs[SRC_RAT_FIR_NUM_PHASES_DS][SRC_RAT_FIR_TAPS_PER_PHASE_DS]; 32 | 33 | /** q30 coefficients to use for the 32 -> 48 kHz polyphase rational factor upsampling */ 34 | extern const int32_t src_rat_fir_us_coefs[SRC_RAT_FIR_NUM_PHASES_US][SRC_RAT_FIR_TAPS_PER_PHASE_US]; 35 | 36 | #endif // _SRC_RAT_COEFS_H_ 37 | 38 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/ADFir.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/ADFir.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL.dat: -------------------------------------------------------------------------------- 1 | 4088, 2 | 22877, 3 | 52232, 4 | 39434, 5 | -78700, 6 | -243544, 7 | -252954, 8 | -27713, 9 | 159917, 10 | 11679, 11 | -247994, 12 | -115799, 13 | 280399, 14 | 215609, 15 | -331505, 16 | -372434, 17 | 355994, 18 | 570721, 19 | -353726, 20 | -821909, 21 | 305399, 22 | 1125237, 23 | -196031, 24 | -1481866, 25 | 5661, 26 | 1888156, 27 | 286348, 28 | -2337707, 29 | -702275, 30 | 2820706, 31 | 1266261, 32 | -3322723, 33 | -2003426, 34 | 3824366, 35 | 2939148, 36 | -4301558, 37 | -4099418, 38 | 4724959, 39 | 5511147, 40 | -5058453, 41 | -7200672, 42 | 5260641, 43 | 9196546, 44 | -5281702, 45 | -11528466, 46 | 5063974, 47 | 14230831, 48 | -4538510, 49 | -17345088, 50 | 3622234, 51 | 20926099, 52 | -2210550, 53 | -25049741, 54 | 168488, 55 | 29830877, 56 | 2691385, 57 | -35448388, 58 | -6643064, 59 | 42198718, 60 | 12119856, 61 | -50601866, 62 | -19870719, 63 | 61638261, 64 | 31333255, 65 | -77371075, 66 | -49706192, 67 | 102912632, 68 | 83869448, 69 | -155144075, 70 | -171137264, 71 | 341165288, 72 | 946048435, 73 | 946048435, 74 | 341165288, 75 | -171137264, 76 | -155144075, 77 | 83869448, 78 | 102912632, 79 | -49706192, 80 | -77371075, 81 | 31333255, 82 | 61638261, 83 | -19870719, 84 | -50601866, 85 | 12119856, 86 | 42198718, 87 | -6643064, 88 | -35448388, 89 | 2691385, 90 | 29830877, 91 | 168488, 92 | -25049741, 93 | -2210550, 94 | 20926099, 95 | 3622234, 96 | -17345088, 97 | -4538510, 98 | 14230831, 99 | 5063974, 100 | -11528466, 101 | -5281702, 102 | 9196546, 103 | 5260641, 104 | -7200672, 105 | -5058453, 106 | 5511147, 107 | 4724959, 108 | -4099418, 109 | -4301558, 110 | 2939148, 111 | 3824366, 112 | -2003426, 113 | -3322723, 114 | 1266261, 115 | 2820706, 116 | -702275, 117 | -2337707, 118 | 286348, 119 | 1888156, 120 | 5661, 121 | -1481866, 122 | -196031, 123 | 1125237, 124 | 305399, 125 | -821909, 126 | -353726, 127 | 570721, 128 | 355994, 129 | -372434, 130 | -331505, 131 | 215609, 132 | 280399, 133 | -115799, 134 | -247994, 135 | 11679, 136 | 159917, 137 | -27713, 138 | -252954, 139 | -243544, 140 | -78700, 141 | 39434, 142 | 52232, 143 | 22877, 144 | 4088 145 | 146 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BL.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL17696.dat: -------------------------------------------------------------------------------- 1 | -1117, 2 | -20789, 3 | -104563, 4 | -248552, 5 | -275739, 6 | -518, 7 | 313715, 8 | 100974, 9 | -444773, 10 | -261674, 11 | 639567, 12 | 522899, 13 | -898939, 14 | -917421, 15 | 1236966, 16 | 1484442, 17 | -1674924, 18 | -2268886, 19 | 2244218, 20 | 3325127, 21 | -2984006, 22 | -4713060, 23 | 3947654, 24 | 6501796, 25 | -5205187, 26 | -8772111, 27 | 6847790, 28 | 11620391, 29 | -8996993, 30 | -15169026, 31 | 11818150, 32 | 19584412, 33 | -15546572, 34 | -25113744, 35 | 20535742, 36 | 32156256, 37 | -27360568, 38 | -41419315, 39 | 37053292, 40 | 54295953, 41 | -51719275, 42 | -73935958, 43 | 76503994, 44 | 109171276, 45 | -128308655, 46 | -197270553, 47 | 314240051, 48 | 972732959, 49 | 972732959, 50 | 314240051, 51 | -197270553, 52 | -128308655, 53 | 109171276, 54 | 76503994, 55 | -73935958, 56 | -51719275, 57 | 54295953, 58 | 37053292, 59 | -41419315, 60 | -27360568, 61 | 32156256, 62 | 20535742, 63 | -25113744, 64 | -15546572, 65 | 19584412, 66 | 11818150, 67 | -15169026, 68 | -8996993, 69 | 11620391, 70 | 6847790, 71 | -8772111, 72 | -5205187, 73 | 6501796, 74 | 3947654, 75 | -4713060, 76 | -2984006, 77 | 3325127, 78 | 2244218, 79 | -2268886, 80 | -1674924, 81 | 1484442, 82 | 1236966, 83 | -917421, 84 | -898939, 85 | 522899, 86 | 639567, 87 | -261674, 88 | -444773, 89 | 100974, 90 | 313715, 91 | -518, 92 | -275739, 93 | -248552, 94 | -104563, 95 | -20789, 96 | -1117 97 | 98 | 99 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL17696.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BL17696.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL19288.dat: -------------------------------------------------------------------------------- 1 | -4645, 2 | -34627, 3 | -121873, 4 | -255124, 5 | -313951, 6 | -134826, 7 | 239381, 8 | 418282, 9 | 33106, 10 | -611393, 11 | -593447, 12 | 424684, 13 | 1255738, 14 | 387480, 15 | -1550783, 16 | -1769181, 17 | 899245, 18 | 3196527, 19 | 1061162, 20 | -3710721, 21 | -4089453, 22 | 2248181, 23 | 7107296, 24 | 1783622, 25 | -8324569, 26 | -7893262, 27 | 5816842, 28 | 14158481, 29 | 1542334, 30 | -17434813, 31 | -13110148, 32 | 14228176, 33 | 25887415, 34 | -2070594, 35 | -34671418, 36 | -19013059, 37 | 33047779, 38 | 45464162, 39 | -14912345, 40 | -69903246, 41 | -24270718, 42 | 81278345, 43 | 88130370, 44 | -63022593, 45 | -187932622, 46 | -27393757, 47 | 422184387, 48 | 825512011, 49 | 825512011, 50 | 422184387, 51 | -27393757, 52 | -187932622, 53 | -63022593, 54 | 88130370, 55 | 81278345, 56 | -24270718, 57 | -69903246, 58 | -14912345, 59 | 45464162, 60 | 33047779, 61 | -19013059, 62 | -34671418, 63 | -2070594, 64 | 25887415, 65 | 14228176, 66 | -13110148, 67 | -17434813, 68 | 1542334, 69 | 14158481, 70 | 5816842, 71 | -7893262, 72 | -8324569, 73 | 1783622, 74 | 7107296, 75 | 2248181, 76 | -4089453, 77 | -3710721, 78 | 1061162, 79 | 3196527, 80 | 899245, 81 | -1769181, 82 | -1550783, 83 | 387480, 84 | 1255738, 85 | 424684, 86 | -593447, 87 | -611393, 88 | 33106, 89 | 418282, 90 | 239381, 91 | -134826, 92 | -313951, 93 | -255124, 94 | -121873, 95 | -34627, 96 | -4645 97 | 98 | 99 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL19288.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BL19288.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL8848.dat: -------------------------------------------------------------------------------- 1 | -3374, 2 | -23170, 3 | -67557, 4 | -98445, 5 | -48088, 6 | 55788, 7 | 61905, 8 | -59427, 9 | -83688, 10 | 80349, 11 | 117138, 12 | -116641, 13 | -161513, 14 | 173531, 15 | 215329, 16 | -259234, 17 | -275040, 18 | 384016, 19 | 333659, 20 | -559462, 21 | -379455, 22 | 797203, 23 | 394532, 24 | -1107274, 25 | -353894, 26 | 1495685, 27 | 224986, 28 | -1961331, 29 | 32067, 30 | 2492632, 31 | -462887, 32 | -3063711, 33 | 1116156, 34 | 3630844, 35 | -2039529, 36 | -4129707, 37 | 3273810, 38 | 4473254, 39 | -4846478, 40 | -4551791, 41 | 6763702, 42 | 4234319, 43 | -9002434, 44 | -3372049, 45 | 11502693, 46 | 1803707, 47 | -14160509, 48 | 638323, 49 | 16822358, 50 | -4121519, 51 | -19280231, 52 | 8808906, 53 | 21266396, 54 | -14860533, 55 | -22446420, 56 | 22444260, 57 | 22403212, 58 | -31765652, 59 | -20598112, 60 | 43139303, 61 | 16282458, 62 | -57144732, 63 | -8273713, 64 | 75009578, 65 | -5648084, 66 | -99689379, 67 | 30697421, 68 | 139804702, 69 | -83792254, 70 | -232409627, 71 | 272000845, 72 | 1011799927, 73 | 1011799927, 74 | 272000845, 75 | -232409627, 76 | -83792254, 77 | 139804702, 78 | 30697421, 79 | -99689379, 80 | -5648084, 81 | 75009578, 82 | -8273713, 83 | -57144732, 84 | 16282458, 85 | 43139303, 86 | -20598112, 87 | -31765652, 88 | 22403212, 89 | 22444260, 90 | -22446420, 91 | -14860533, 92 | 21266396, 93 | 8808906, 94 | -19280231, 95 | -4121519, 96 | 16822358, 97 | 638323, 98 | -14160509, 99 | 1803707, 100 | 11502693, 101 | -3372049, 102 | -9002434, 103 | 4234319, 104 | 6763702, 105 | -4551791, 106 | -4846478, 107 | 4473254, 108 | 3273810, 109 | -4129707, 110 | -2039529, 111 | 3630844, 112 | 1116156, 113 | -3063711, 114 | -462887, 115 | 2492632, 116 | 32067, 117 | -1961331, 118 | 224986, 119 | 1495685, 120 | -353894, 121 | -1107274, 122 | 394532, 123 | 797203, 124 | -379455, 125 | -559462, 126 | 333659, 127 | 384016, 128 | -275040, 129 | -259234, 130 | 215329, 131 | 173531, 132 | -161513, 133 | -116641, 134 | 117138, 135 | 80349, 136 | -83688, 137 | -59427, 138 | 61905, 139 | 55788, 140 | -48088, 141 | -98445, 142 | -67557, 143 | -23170, 144 | -3374 145 | 146 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL8848.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BL8848.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL9644.dat: -------------------------------------------------------------------------------- 1 | -182, 2 | 2544, 3 | 21626, 4 | 76339, 5 | 158711, 6 | 201631, 7 | 122946, 8 | -52702, 9 | -153378, 10 | -42386, 11 | 151703, 12 | 137378, 13 | -116793, 14 | -241279, 15 | 23802, 16 | 328888, 17 | 138014, 18 | -360973, 19 | -359372, 20 | 294107, 21 | 606350, 22 | -92924, 23 | -821012, 24 | -257289, 25 | 927210, 26 | 738746, 27 | -842380, 28 | -1292546, 29 | 495512, 30 | 1817473, 31 | 152248, 32 | -2177534, 33 | -1087457, 34 | 2219075, 35 | 2228439, 36 | -1797580, 37 | -3419049, 38 | 810534, 39 | 4435538, 40 | 768522, 41 | -5008223, 42 | -2860338, 43 | 4858259, 44 | 5261820, 45 | -3746090, 46 | -7645302, 47 | 1525586, 48 | 9578883, 49 | 1803738, 50 | -10569171, 51 | -6055512, 52 | 10123800, 53 | 10834713, 54 | -7827607, 55 | -15541614, 56 | 3423465, 57 | 19404411, 58 | 3113042, 59 | -21538673, 60 | -11515548, 61 | 21026636, 62 | 21193553, 63 | -17003723, 64 | -31226670, 65 | 8733526, 66 | 40379969, 67 | 4355176, 68 | -47118279, 69 | -22712435, 70 | 49563148, 71 | 46882048, 72 | -45242128, 73 | -78140943, 74 | 30140798, 75 | 120532115, 76 | 5117674, 77 | -189683718, 78 | -97955888, 79 | 391387187, 80 | 882608112, 81 | 882608112, 82 | 391387187, 83 | -97955888, 84 | -189683718, 85 | 5117674, 86 | 120532115, 87 | 30140798, 88 | -78140943, 89 | -45242128, 90 | 46882048, 91 | 49563148, 92 | -22712435, 93 | -47118279, 94 | 4355176, 95 | 40379969, 96 | 8733526, 97 | -31226670, 98 | -17003723, 99 | 21193553, 100 | 21026636, 101 | -11515548, 102 | -21538673, 103 | 3113042, 104 | 19404411, 105 | 3423465, 106 | -15541614, 107 | -7827607, 108 | 10834713, 109 | 10123800, 110 | -6055512, 111 | -10569171, 112 | 1803738, 113 | 9578883, 114 | 1525586, 115 | -7645302, 116 | -3746090, 117 | 5261820, 118 | 4858259, 119 | -2860338, 120 | -5008223, 121 | 768522, 122 | 4435538, 123 | 810534, 124 | -3419049, 125 | -1797580, 126 | 2228439, 127 | 2219075, 128 | -1087457, 129 | -2177534, 130 | 152248, 131 | 1817473, 132 | 495512, 133 | -1292546, 134 | -842380, 135 | 738746, 136 | 927210, 137 | -257289, 138 | -821012, 139 | -92924, 140 | 606350, 141 | 294107, 142 | -359372, 143 | -360973, 144 | 138014, 145 | 328888, 146 | 23802, 147 | -241279, 148 | -116793, 149 | 137378, 150 | 151703, 151 | -42386, 152 | -153378, 153 | -52702, 154 | 122946, 155 | 201631, 156 | 158711, 157 | 76339, 158 | 21626, 159 | 2544, 160 | -182 161 | 162 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BL9644.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BL9644.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BLF.dat: -------------------------------------------------------------------------------- 1 | -4555, 2 | -38349, 3 | -141754, 4 | -291162, 5 | -314466, 6 | -39602, 7 | 337431, 8 | 272680, 9 | -333361, 10 | -609228, 11 | 173131, 12 | 1022738, 13 | 257203, 14 | -1405464, 15 | -1035381, 16 | 1589908, 17 | 2184266, 18 | -1356294, 19 | -3638331, 20 | 459446, 21 | 5216781, 22 | 1329759, 23 | -6610050, 24 | -4174607, 25 | 7380247, 26 | 8114804, 27 | -6983751, 28 | -13013074, 29 | 4811593, 30 | 18513029, 31 | -239251, 32 | -24010548, 33 | -7325623, 34 | 28638180, 35 | 18423301, 36 | -31242886, 37 | -33590787, 38 | 30305055, 39 | 53568329, 40 | -23654282, 41 | -79920770, 42 | 7493849, 43 | 117044265, 44 | 27438670, 45 | -180953872, 46 | -118563479, 47 | 377829021, 48 | 900224220, 49 | 900224220, 50 | 377829021, 51 | -118563479, 52 | -180953872, 53 | 27438670, 54 | 117044265, 55 | 7493849, 56 | -79920770, 57 | -23654282, 58 | 53568329, 59 | 30305055, 60 | -33590787, 61 | -31242886, 62 | 18423301, 63 | 28638180, 64 | -7325623, 65 | -24010548, 66 | -239251, 67 | 18513029, 68 | 4811593, 69 | -13013074, 70 | -6983751, 71 | 8114804, 72 | 7380247, 73 | -4174607, 74 | -6610050, 75 | 1329759, 76 | 5216781, 77 | 459446, 78 | -3638331, 79 | -1356294, 80 | 2184266, 81 | 1589908, 82 | -1035381, 83 | -1405464, 84 | 257203, 85 | 1022738, 86 | 173131, 87 | -609228, 88 | -333361, 89 | 272680, 90 | 337431, 91 | -39602, 92 | -314466, 93 | -291162, 94 | -141754, 95 | -38349, 96 | -4555 97 | 98 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/BLF.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/BLF.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/DS.dat: -------------------------------------------------------------------------------- 1 | -62335, 2 | -489750, 3 | -1433845, 4 | -1195758, 5 | 3186235, 6 | 8050435, 7 | -121030, 8 | -21202136, 9 | -18248715, 10 | 33831679, 11 | 65164653, 12 | -25857487, 13 | -158473440, 14 | -54171497, 15 | 395230691, 16 | 849032692, 17 | 849032692, 18 | 395230691, 19 | -54171497, 20 | -158473440, 21 | -25857487, 22 | 65164653, 23 | 33831679, 24 | -18248715, 25 | -21202136, 26 | -121030, 27 | 8050435, 28 | 3186235, 29 | -1195758, 30 | -1433845, 31 | -489750, 32 | -62335 33 | 34 | 35 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/DS.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/DS.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/DS_xs3.dat: -------------------------------------------------------------------------------- 1 | -62335, 2 | -1433845, 3 | 3186235, 4 | -121030, 5 | -18248715, 6 | 65164653, 7 | -158473440, 8 | 395230691, 9 | -489750, 10 | -1195758, 11 | 8050435, 12 | -21202136, 13 | 33831679, 14 | -25857487, 15 | -54171497, 16 | 849032692, 17 | 849032692, 18 | -54171497, 19 | -25857487, 20 | 33831679, 21 | -21202136, 22 | 8050435, 23 | -1195758, 24 | -489750, 25 | 395230691, 26 | -158473440, 27 | 65164653, 28 | -18248715, 29 | -121030, 30 | 3186235, 31 | -1433845, 32 | -62335, 33 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/HS294.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/HS294.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/HS320.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/HS320.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/OS.dat: -------------------------------------------------------------------------------- 1 | -124669, 2 | -979501, 3 | -2867689, 4 | -2391516, 5 | 6372470, 6 | 16100869, 7 | -242060, 8 | -42404272, 9 | -36497430, 10 | 67663358, 11 | 130329305, 12 | -51714975, 13 | -316946879, 14 | -108342995, 15 | 790461382, 16 | 1698065385, 17 | 1698065385, 18 | 790461382, 19 | -108342995, 20 | -316946879, 21 | -51714975, 22 | 130329305, 23 | 67663358, 24 | -36497430, 25 | -42404272, 26 | -242060, 27 | 16100869, 28 | 6372470, 29 | -2391516, 30 | -2867689, 31 | -979501, 32 | -124669 33 | 34 | 35 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/OS.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/OS.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/OS_xs3.dat: -------------------------------------------------------------------------------- 1 | -124669, 2 | -2867689, 3 | 6372470, 4 | -242060, 5 | -36497430, 6 | 130329305, 7 | -316946879, 8 | 790461382, 9 | -979501, 10 | -2391516, 11 | 16100869, 12 | -42404272, 13 | 67663358, 14 | -51714975, 15 | -108342995, 16 | 1698065385, 17 | 1698065385, 18 | -108342995, 19 | -51714975, 20 | 67663358, 21 | -42404272, 22 | 16100869, 23 | -2391516, 24 | -979501, 25 | 790461382, 26 | -316946879, 27 | 130329305, 28 | -36497430, 29 | -242060, 30 | 6372470, 31 | -2867689, 32 | -124669, 33 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP.dat: -------------------------------------------------------------------------------- 1 | 8176, 2 | 45754, 3 | 104463, 4 | 78869, 5 | -157400, 6 | -487088, 7 | -505907, 8 | -55426, 9 | 319834, 10 | 23357, 11 | -495989, 12 | -231597, 13 | 560799, 14 | 431217, 15 | -663010, 16 | -744868, 17 | 711987, 18 | 1141441, 19 | -707452, 20 | -1643818, 21 | 610799, 22 | 2250475, 23 | -392062, 24 | -2963731, 25 | 11322, 26 | 3776312, 27 | 572695, 28 | -4675414, 29 | -1404551, 30 | 5641413, 31 | 2532522, 32 | -6645447, 33 | -4006851, 34 | 7648732, 35 | 5878297, 36 | -8603117, 37 | -8198836, 38 | 9449918, 39 | 11022295, 40 | -10116907, 41 | -14401345, 42 | 10521283, 43 | 18393091, 44 | -10563404, 45 | -23056931, 46 | 10127948, 47 | 28461662, 48 | -9077021, 49 | -34690176, 50 | 7244467, 51 | 41852199, 52 | -4421100, 53 | -50099481, 54 | 336976, 55 | 59661753, 56 | 5382770, 57 | -70896775, 58 | -13286127, 59 | 84397436, 60 | 24239711, 61 | -101203733, 62 | -39741438, 63 | 123276521, 64 | 62666511, 65 | -154742150, 66 | -99412383, 67 | 205825264, 68 | 167738895, 69 | -310288150, 70 | -342274527, 71 | 682330577, 72 | 1892096869, 73 | 1892096869, 74 | 682330577, 75 | -342274527, 76 | -310288150, 77 | 167738895, 78 | 205825264, 79 | -99412383, 80 | -154742150, 81 | 62666511, 82 | 123276521, 83 | -39741438, 84 | -101203733, 85 | 24239711, 86 | 84397436, 87 | -13286127, 88 | -70896775, 89 | 5382770, 90 | 59661753, 91 | 336976, 92 | -50099481, 93 | -4421100, 94 | 41852199, 95 | 7244467, 96 | -34690176, 97 | -9077021, 98 | 28461662, 99 | 10127948, 100 | -23056931, 101 | -10563404, 102 | 18393091, 103 | 10521283, 104 | -14401345, 105 | -10116907, 106 | 11022295, 107 | 9449918, 108 | -8198836, 109 | -8603117, 110 | 5878297, 111 | 7648732, 112 | -4006851, 113 | -6645447, 114 | 2532522, 115 | 5641413, 116 | -1404551, 117 | -4675414, 118 | 572695, 119 | 3776312, 120 | 11322, 121 | -2963731, 122 | -392062, 123 | 2250475, 124 | 610799, 125 | -1643818, 126 | -707452, 127 | 1141441, 128 | 711987, 129 | -744868, 130 | -663010, 131 | 431217, 132 | 560799, 133 | -231597, 134 | -495989, 135 | 23357, 136 | 319834, 137 | -55426, 138 | -505907, 139 | -487088, 140 | -157400, 141 | 78869, 142 | 104463, 143 | 45754, 144 | 8176 145 | 146 | 147 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/UP.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP192176.dat: -------------------------------------------------------------------------------- 1 | -9289, 2 | -69253, 3 | -243747, 4 | -510249, 5 | -627902, 6 | -269652, 7 | 478763, 8 | 836564, 9 | 66212, 10 | -1222785, 11 | -1186895, 12 | 849369, 13 | 2511477, 14 | 774961, 15 | -3101566, 16 | -3538362, 17 | 1798490, 18 | 6393054, 19 | 2122325, 20 | -7421443, 21 | -8178905, 22 | 4496362, 23 | 14214592, 24 | 3567244, 25 | -16649137, 26 | -15786525, 27 | 11633685, 28 | 28316963, 29 | 3084667, 30 | -34869625, 31 | -26220297, 32 | 28456353, 33 | 51774830, 34 | -4141189, 35 | -69342837, 36 | -38026118, 37 | 66095558, 38 | 90928323, 39 | -29824690, 40 | -139806492, 41 | -48541436, 42 | 162556690, 43 | 176260739, 44 | -126045185, 45 | -375865245, 46 | -54787514, 47 | 844368773, 48 | 1651024023, 49 | 1651024023, 50 | 844368773, 51 | -54787514, 52 | -375865245, 53 | -126045185, 54 | 176260739, 55 | 162556690, 56 | -48541436, 57 | -139806492, 58 | -29824690, 59 | 90928323, 60 | 66095558, 61 | -38026118, 62 | -69342837, 63 | -4141189, 64 | 51774830, 65 | 28456353, 66 | -26220297, 67 | -34869625, 68 | 3084667, 69 | 28316963, 70 | 11633685, 71 | -15786525, 72 | -16649137, 73 | 3567244, 74 | 14214592, 75 | 4496362, 76 | -8178905, 77 | -7421443, 78 | 2122325, 79 | 6393054, 80 | 1798490, 81 | -3538362, 82 | -3101566, 83 | 774961, 84 | 2511477, 85 | 849369, 86 | -1186895, 87 | -1222785, 88 | 66212, 89 | 836564, 90 | 478763, 91 | -269652, 92 | -627902, 93 | -510249, 94 | -243747, 95 | -69253, 96 | -9289 97 | 98 | 99 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP192176.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/UP192176.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP192176_xs3.dat: -------------------------------------------------------------------------------- 1 | -9289, 2 | -243747, 3 | -627902, 4 | 478763, 5 | 66212, 6 | -1186895, 7 | 2511477, 8 | -3101566, 9 | -69253, 10 | -510249, 11 | -269652, 12 | 836564, 13 | -1222785, 14 | 849369, 15 | 774961, 16 | -3538362, 17 | 1798490, 18 | 2122325, 19 | -8178905, 20 | 14214592, 21 | -16649137, 22 | 11633685, 23 | 3084667, 24 | -26220297, 25 | 6393054, 26 | -7421443, 27 | 4496362, 28 | 3567244, 29 | -15786525, 30 | 28316963, 31 | -34869625, 32 | 28456353, 33 | 51774830, 34 | -69342837, 35 | 66095558, 36 | -29824690, 37 | -48541436, 38 | 176260739, 39 | -375865245, 40 | 844368773, 41 | -4141189, 42 | -38026118, 43 | 90928323, 44 | -139806492, 45 | 162556690, 46 | -126045185, 47 | -54787514, 48 | 1651024023, 49 | 1651024023, 50 | -54787514, 51 | -126045185, 52 | 162556690, 53 | -139806492, 54 | 90928323, 55 | -38026118, 56 | -4141189, 57 | 844368773, 58 | -375865245, 59 | 176260739, 60 | -48541436, 61 | -29824690, 62 | 66095558, 63 | -69342837, 64 | 51774830, 65 | 28456353, 66 | -34869625, 67 | 28316963, 68 | -15786525, 69 | 3567244, 70 | 4496362, 71 | -7421443, 72 | 6393054, 73 | -26220297, 74 | 3084667, 75 | 11633685, 76 | -16649137, 77 | 14214592, 78 | -8178905, 79 | 2122325, 80 | 1798490, 81 | -3538362, 82 | 774961, 83 | 849369, 84 | -1222785, 85 | 836564, 86 | -269652, 87 | -510249, 88 | -69253, 89 | -3101566, 90 | 2511477, 91 | -1186895, 92 | 66212, 93 | 478763, 94 | -627902, 95 | -243747, 96 | -9289, 97 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP4844.dat: -------------------------------------------------------------------------------- 1 | -365, 2 | 5087, 3 | 43252, 4 | 152679, 5 | 317422, 6 | 403262, 7 | 245893, 8 | -105404, 9 | -306756, 10 | -84773, 11 | 303406, 12 | 274756, 13 | -233586, 14 | -482558, 15 | 47603, 16 | 657776, 17 | 276028, 18 | -721946, 19 | -718745, 20 | 588214, 21 | 1212699, 22 | -185848, 23 | -1642025, 24 | -514578, 25 | 1854419, 26 | 1477492, 27 | -1684759, 28 | -2585093, 29 | 991024, 30 | 3634946, 31 | 304496, 32 | -4355068, 33 | -2174914, 34 | 4438149, 35 | 4456879, 36 | -3595159, 37 | -6838098, 38 | 1621069, 39 | 8871076, 40 | 1537045, 41 | -10016447, 42 | -5720677, 43 | 9716518, 44 | 10523641, 45 | -7492179, 46 | -15290603, 47 | 3051173, 48 | 19157766, 49 | 3607477, 50 | -21138341, 51 | -12111024, 52 | 20247600, 53 | 21669427, 54 | -15655214, 55 | -31083229, 56 | 6846930, 57 | 38808823, 58 | 6226085, 59 | -43077345, 60 | -23031095, 61 | 42053271, 62 | 42387107, 63 | -34007445, 64 | -62453340, 65 | 17467052, 66 | 80759937, 67 | 8710352, 68 | -94236559, 69 | -45424870, 70 | 99126296, 71 | 93764097, 72 | -90484256, 73 | -156281886, 74 | 60281596, 75 | 241064230, 76 | 10235348, 77 | -379367437, 78 | -195911776, 79 | 782774374, 80 | 1765216224, 81 | 1765216224, 82 | 782774374, 83 | -195911776, 84 | -379367437, 85 | 10235348, 86 | 241064230, 87 | 60281596, 88 | -156281886, 89 | -90484256, 90 | 93764097, 91 | 99126296, 92 | -45424870, 93 | -94236559, 94 | 8710352, 95 | 80759937, 96 | 17467052, 97 | -62453340, 98 | -34007445, 99 | 42387107, 100 | 42053271, 101 | -23031095, 102 | -43077345, 103 | 6226085, 104 | 38808823, 105 | 6846930, 106 | -31083229, 107 | -15655214, 108 | 21669427, 109 | 20247600, 110 | -12111024, 111 | -21138341, 112 | 3607477, 113 | 19157766, 114 | 3051173, 115 | -15290603, 116 | -7492179, 117 | 10523641, 118 | 9716518, 119 | -5720677, 120 | -10016447, 121 | 1537045, 122 | 8871076, 123 | 1621069, 124 | -6838098, 125 | -3595159, 126 | 4456879, 127 | 4438149, 128 | -2174914, 129 | -4355068, 130 | 304496, 131 | 3634946, 132 | 991024, 133 | -2585093, 134 | -1684759, 135 | 1477492, 136 | 1854419, 137 | -514578, 138 | -1642025, 139 | -185848, 140 | 1212699, 141 | 588214, 142 | -718745, 143 | -721946, 144 | 276028, 145 | 657776, 146 | 47603, 147 | -482558, 148 | -233586, 149 | 274756, 150 | 303406, 151 | -84773, 152 | -306756, 153 | -105404, 154 | 245893, 155 | 403262, 156 | 317422, 157 | 152679, 158 | 43252, 159 | 5087, 160 | -365 161 | 162 | 163 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP4844.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/UP4844.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP4844_xs3.dat: -------------------------------------------------------------------------------- 1 | -365, 2 | 43252, 3 | 317422, 4 | 245893, 5 | -306756, 6 | 303406, 7 | -233586, 8 | 47603, 9 | 5087, 10 | 152679, 11 | 403262, 12 | -105404, 13 | -84773, 14 | 274756, 15 | -482558, 16 | 657776, 17 | 276028, 18 | -718745, 19 | 1212699, 20 | -1642025, 21 | 1854419, 22 | -1684759, 23 | 991024, 24 | 304496, 25 | -721946, 26 | 588214, 27 | -185848, 28 | -514578, 29 | 1477492, 30 | -2585093, 31 | 3634946, 32 | -4355068, 33 | -2174914, 34 | 4456879, 35 | -6838098, 36 | 8871076, 37 | -10016447, 38 | 9716518, 39 | -7492179, 40 | 3051173, 41 | 4438149, 42 | -3595159, 43 | 1621069, 44 | 1537045, 45 | -5720677, 46 | 10523641, 47 | -15290603, 48 | 19157766, 49 | 3607477, 50 | -12111024, 51 | 21669427, 52 | -31083229, 53 | 38808823, 54 | -43077345, 55 | 42053271, 56 | -34007445, 57 | -21138341, 58 | 20247600, 59 | -15655214, 60 | 6846930, 61 | 6226085, 62 | -23031095, 63 | 42387107, 64 | -62453340, 65 | 17467052, 66 | 8710352, 67 | -45424870, 68 | 93764097, 69 | -156281886, 70 | 241064230, 71 | -379367437, 72 | 782774374, 73 | 80759937, 74 | -94236559, 75 | 99126296, 76 | -90484256, 77 | 60281596, 78 | 10235348, 79 | -195911776, 80 | 1765216224, 81 | 1765216224, 82 | -195911776, 83 | 10235348, 84 | 60281596, 85 | -90484256, 86 | 99126296, 87 | -94236559, 88 | 80759937, 89 | 782774374, 90 | -379367437, 91 | 241064230, 92 | -156281886, 93 | 93764097, 94 | -45424870, 95 | 8710352, 96 | 17467052, 97 | -62453340, 98 | 42387107, 99 | -23031095, 100 | 6226085, 101 | 6846930, 102 | -15655214, 103 | 20247600, 104 | -21138341, 105 | -34007445, 106 | 42053271, 107 | -43077345, 108 | 38808823, 109 | -31083229, 110 | 21669427, 111 | -12111024, 112 | 3607477, 113 | 19157766, 114 | -15290603, 115 | 10523641, 116 | -5720677, 117 | 1537045, 118 | 1621069, 119 | -3595159, 120 | 4438149, 121 | 3051173, 122 | -7492179, 123 | 9716518, 124 | -10016447, 125 | 8871076, 126 | -6838098, 127 | 4456879, 128 | -2174914, 129 | -4355068, 130 | 3634946, 131 | -2585093, 132 | 1477492, 133 | -514578, 134 | -185848, 135 | 588214, 136 | -721946, 137 | 304496, 138 | 991024, 139 | -1684759, 140 | 1854419, 141 | -1642025, 142 | 1212699, 143 | -718745, 144 | 276028, 145 | 657776, 146 | -482558, 147 | 274756, 148 | -84773, 149 | -105404, 150 | 403262, 151 | 152679, 152 | 5087, 153 | 47603, 154 | -233586, 155 | 303406, 156 | -306756, 157 | 245893, 158 | 317422, 159 | 43252, 160 | -365, 161 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UPF.dat: -------------------------------------------------------------------------------- 1 | -9110, 2 | -76699, 3 | -283508, 4 | -582324, 5 | -628931, 6 | -79203, 7 | 674861, 8 | 545360, 9 | -666721, 10 | -1218455, 11 | 346261, 12 | 2045476, 13 | 514406, 14 | -2810927, 15 | -2070761, 16 | 3179817, 17 | 4368532, 18 | -2712589, 19 | -7276663, 20 | 918891, 21 | 10433562, 22 | 2659518, 23 | -13220100, 24 | -8349213, 25 | 14760495, 26 | 16229609, 27 | -13967503, 28 | -26026147, 29 | 9623187, 30 | 37026057, 31 | -478501, 32 | -48021095, 33 | -14651246, 34 | 57276361, 35 | 36846603, 36 | -62485772, 37 | -67181575, 38 | 60610109, 39 | 107136658, 40 | -47308565, 41 | -159841541, 42 | 14987698, 43 | 234088529, 44 | 54877341, 45 | -361907745, 46 | -237126959, 47 | 755658043, 48 | 1800448439, 49 | 1800448439, 50 | 755658043, 51 | -237126959, 52 | -361907745, 53 | 54877341, 54 | 234088529, 55 | 14987698, 56 | -159841541, 57 | -47308565, 58 | 107136658, 59 | 60610109, 60 | -67181575, 61 | -62485772, 62 | 36846603, 63 | 57276361, 64 | -14651246, 65 | -48021095, 66 | -478501, 67 | 37026057, 68 | 9623187, 69 | -26026147, 70 | -13967503, 71 | 16229609, 72 | 14760495, 73 | -8349213, 74 | -13220100, 75 | 2659518, 76 | 10433562, 77 | 918891, 78 | -7276663, 79 | -2712589, 80 | 4368532, 81 | 3179817, 82 | -2070761, 83 | -2810927, 84 | 514406, 85 | 2045476, 86 | 346261, 87 | -1218455, 88 | -666721, 89 | 545360, 90 | 674861, 91 | -79203, 92 | -628931, 93 | -582324, 94 | -283508, 95 | -76699, 96 | -9110 97 | 98 | 99 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UPF.sfp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/lib_src/src/multirate_hifi/FilterData/UPF.sfp -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UPF_xs3.dat: -------------------------------------------------------------------------------- 1 | -9110, 2 | -283508, 3 | -628931, 4 | 674861, 5 | -666721, 6 | 346261, 7 | 514406, 8 | -2070761, 9 | -76699, 10 | -582324, 11 | -79203, 12 | 545360, 13 | -1218455, 14 | 2045476, 15 | -2810927, 16 | 3179817, 17 | 4368532, 18 | -7276663, 19 | 10433562, 20 | -13220100, 21 | 14760495, 22 | -13967503, 23 | 9623187, 24 | -478501, 25 | -2712589, 26 | 918891, 27 | 2659518, 28 | -8349213, 29 | 16229609, 30 | -26026147, 31 | 37026057, 32 | -48021095, 33 | -14651246, 34 | 36846603, 35 | -67181575, 36 | 107136658, 37 | -159841541, 38 | 234088529, 39 | -361907745, 40 | 755658043, 41 | 57276361, 42 | -62485772, 43 | 60610109, 44 | -47308565, 45 | 14987698, 46 | 54877341, 47 | -237126959, 48 | 1800448439, 49 | 1800448439, 50 | -237126959, 51 | 54877341, 52 | 14987698, 53 | -47308565, 54 | 60610109, 55 | -62485772, 56 | 57276361, 57 | 755658043, 58 | -361907745, 59 | 234088529, 60 | -159841541, 61 | 107136658, 62 | -67181575, 63 | 36846603, 64 | -14651246, 65 | -48021095, 66 | 37026057, 67 | -26026147, 68 | 16229609, 69 | -8349213, 70 | 2659518, 71 | 918891, 72 | -2712589, 73 | -478501, 74 | 9623187, 75 | -13967503, 76 | 14760495, 77 | -13220100, 78 | 10433562, 79 | -7276663, 80 | 4368532, 81 | 3179817, 82 | -2810927, 83 | 2045476, 84 | -1218455, 85 | 545360, 86 | -79203, 87 | -582324, 88 | -76699, 89 | -2070761, 90 | 514406, 91 | 346261, 92 | -666721, 93 | 674861, 94 | -628931, 95 | -283508, 96 | -9110, 97 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/FilterData/UP_xs3.dat: -------------------------------------------------------------------------------- 1 | 8176, 2 | 104463, 3 | -157400, 4 | -505907, 5 | 319834, 6 | -495989, 7 | 560799, 8 | -663010, 9 | 45754, 10 | 78869, 11 | -487088, 12 | -55426, 13 | 23357, 14 | -231597, 15 | 431217, 16 | -744868, 17 | 711987, 18 | -707452, 19 | 610799, 20 | -392062, 21 | 11322, 22 | 572695, 23 | -1404551, 24 | 2532522, 25 | 1141441, 26 | -1643818, 27 | 2250475, 28 | -2963731, 29 | 3776312, 30 | -4675414, 31 | 5641413, 32 | -6645447, 33 | -4006851, 34 | 5878297, 35 | -8198836, 36 | 11022295, 37 | -14401345, 38 | 18393091, 39 | -23056931, 40 | 28461662, 41 | 7648732, 42 | -8603117, 43 | 9449918, 44 | -10116907, 45 | 10521283, 46 | -10563404, 47 | 10127948, 48 | -9077021, 49 | -34690176, 50 | 41852199, 51 | -50099481, 52 | 59661753, 53 | -70896775, 54 | 84397436, 55 | -101203733, 56 | 123276521, 57 | 7244467, 58 | -4421100, 59 | 336976, 60 | 5382770, 61 | -13286127, 62 | 24239711, 63 | -39741438, 64 | 62666511, 65 | -154742150, 66 | 205825264, 67 | -310288150, 68 | 682330577, 69 | 1892096869, 70 | -342274527, 71 | 167738895, 72 | -99412383, 73 | -99412383, 74 | 167738895, 75 | -342274527, 76 | 1892096869, 77 | 682330577, 78 | -310288150, 79 | 205825264, 80 | -154742150, 81 | 62666511, 82 | -39741438, 83 | 24239711, 84 | -13286127, 85 | 5382770, 86 | 336976, 87 | -4421100, 88 | 7244467, 89 | 123276521, 90 | -101203733, 91 | 84397436, 92 | -70896775, 93 | 59661753, 94 | -50099481, 95 | 41852199, 96 | -34690176, 97 | -9077021, 98 | 10127948, 99 | -10563404, 100 | 10521283, 101 | -10116907, 102 | 9449918, 103 | -8603117, 104 | 7648732, 105 | 28461662, 106 | -23056931, 107 | 18393091, 108 | -14401345, 109 | 11022295, 110 | -8198836, 111 | 5878297, 112 | -4006851, 113 | -6645447, 114 | 5641413, 115 | -4675414, 116 | 3776312, 117 | -2963731, 118 | 2250475, 119 | -1643818, 120 | 1141441, 121 | 2532522, 122 | -1404551, 123 | 572695, 124 | 11322, 125 | -392062, 126 | 610799, 127 | -707452, 128 | 711987, 129 | -744868, 130 | 431217, 131 | -231597, 132 | 23357, 133 | -55426, 134 | -487088, 135 | 78869, 136 | 45754, 137 | -663010, 138 | 560799, 139 | -495989, 140 | 319834, 141 | -505907, 142 | -157400, 143 | 104463, 144 | 8176, 145 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_checks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_MRHF_ASRC_CHECKS_H_ 4 | #define _SRC_MRHF_ASRC_CHECKS_H_ 5 | 6 | #include "src.h" 7 | 8 | //Compile time checks on SRC configuration defines 9 | #if (ASRC_N_CHANNELS % ASRC_N_INSTANCES != 0) 10 | #error "Each core must process an integer number of channels. Check ASRC_N_CHANNELS & ASRC_N_INSTANCES." 11 | #endif 12 | #if (ASRC_N_CHANNELS < ASRC_N_INSTANCES) 13 | #error "Each instance (logical core) must process at least one channel. Check ASRC_N_CHANNELS & ASRC_N_INSTANCES." 14 | #endif 15 | #if (ASRC_N_INSTANCES < 1) 16 | #error "Number of instances (logical cores) must be at least 1. Check ASRC_N_INSTANCES." 17 | #endif 18 | #if (ASRC_N_CHANNELS < 1) 19 | #error "Number of audio channels must be at least 1. Check ASRC_N_CHANNELS." 20 | #endif 21 | #if (ASRC_N_IN_SAMPLES < 4) 22 | #error "Number of input audio samples in each block must be at least 4. Check ASRC_N_IN_SAMPLES." 23 | #endif 24 | #if ((ASRC_N_IN_SAMPLES & (ASRC_N_IN_SAMPLES - 1)) != 0) 25 | #error "Number of input audio samples in each block must be a power of two. Check ASRC_N_IN_SAMPLES." 26 | #endif 27 | #if (ASRC_N_OUT_IN_RATIO_MAX < 5) 28 | #warning "SRC buffering configured so that fs out <= 4 * fs in" 29 | #endif 30 | #if (ASRC_N_OUT_IN_RATIO_MAX < 3) 31 | #warning "SRC buffering configured so that fs out <= 2 * fs in" 32 | #endif 33 | #if (ASRC_N_OUT_IN_RATIO_MAX < 1) 34 | #warning "SRC buffering configured so that fs out <= fs in" 35 | #endif 36 | 37 | #endif // _SRC_MRHF_ASRC_CHECKS_H_ 38 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_ 4 | #define _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_ 5 | 6 | void src_mrhf_adfir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count); 7 | void src_mrhf_adfir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count); 8 | void src_mrhf_adfir_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count); 9 | 10 | #endif // _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_ 11 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/src_mrhf_dither_maths_asm.S: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | .section .dp.data,"awd",@progbits 4 | .text 5 | 6 | .cc_top dither_maths_asm.function 7 | .globl dither_maths_asm 8 | .align 8 9 | .type dither_maths_asm,@function 10 | 11 | dither_maths_asm: 12 | 13 | #define piData r0 14 | #define ACCh r1 15 | #define ACCl r2 16 | 17 | 18 | //In 32b words 19 | #define stack_size 0 20 | 21 | #if 0 22 | .issue_mode dual 23 | //Push registers 24 | DUALENTSP_lu6 stack_size 25 | std r4, r5, sp[0] 26 | std r6, r7, sp[1] 27 | std r8, r9, sp[2] 28 | 29 | //push return value pointers onto stack. Frees up r2 30 | //Divide counter by 8 31 | {stw iDataRet_p, sp[6]; shr counter, counter, 3} 32 | 33 | //Constant for adding onto stuff. Gets updated later 34 | ldc step, 0x40 35 | 36 | //Initilise MACC regsiters to zero 37 | {ldc Acc0_h, 0; ldc Acc0_l, 0} 38 | 39 | ldd iData0, iData1, piData_p[0] 40 | ldd iCoef0, iCoef1, piCoefs_p[0] 41 | maccs Acc0_h, Acc0_l, iData0, iCoef0 42 | maccs Acc0_h, Acc0_l, iData1, iCoef1 43 | 44 | //pop return value pointer from stack so we can use it to write back 45 | //Write back the two return values 46 | {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3) 47 | 48 | lsats Acc0_h, Acc0_l, r3 //Saturate first 49 | lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract 50 | stw iData0, iDataRet_p[0] 51 | 52 | //Pop registers 53 | ldd r4, r5, sp[0] 54 | ldd r6, r7, sp[1] 55 | ldd r8, r9, sp[2] 56 | retsp stack_size 57 | #endif 58 | .atmp: 59 | .size dither_maths_asm, .atmp-dither_maths_asm 60 | .align 8 61 | .cc_bottom dither_maths_asm.function 62 | 63 | .set dither_maths_asm.nstackwords, stack_size 64 | .globl dither_maths_asm.nstackwords 65 | .set dither_maths_asm.maxcores, 1 66 | .globl dither_maths_asm.maxcores 67 | .set dither_maths_asm.maxtimers,0 68 | .globl dither_maths_asm.maxtimers 69 | .set dither_maths_asm.maxchanends,0 70 | .globl dither_maths_asm.maxchanends 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_MRHF_FIR_INNER_LOOP_ASM_H_ 4 | #define _SRC_MRHF_FIR_INNER_LOOP_ASM_H_ 5 | 6 | void src_mrhf_fir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count); 7 | void src_mrhf_fir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count); 8 | void src_mrhf_fir_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count); 9 | 10 | #endif // _SRC_MRHF_FIR_INNER_LOOP_ASM_H_ 11 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_ 4 | #define SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_ 5 | 6 | void src_mrhf_fir_os_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count); 7 | void src_mrhf_fir_os_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count); 8 | void src_mrhf_fir_os_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count); 9 | 10 | #endif // SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_ 11 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_ 4 | #define SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_ 5 | 6 | void src_mrhf_spline_coeff_gen_inner_loop_asm(int *piPhase0, int *iH, int* piADCoefs, const int n_taps); 7 | void src_mrhf_spline_coeff_gen_inner_loop_asm_xs3(int *piPhase0, int *iH, int* piADCoefs, const int n_taps); 8 | 9 | #endif // SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_ 10 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_checks.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _SRC_MRHF_SSRC_CHECKS_H_ 4 | #define _SRC_MRHF_SSRC_CHECKS_H_ 5 | 6 | #include "src_mrhf_ssrc.h" 7 | 8 | //Compile time checks on SRC configuration defines 9 | #if (SSRC_N_CHANNELS % SSRC_N_INSTANCES != 0) 10 | #error "Each core must process an integer number of channels. Check SSRC_N_CHANNELS & SSRC_N_INSTANCES." 11 | #endif 12 | #if (SSRC_N_CHANNELS < SSRC_N_INSTANCES) 13 | #error "Each instance (logical core) must process at least one channel. Check SSRC_N_CHANNELS & SSRC_N_INSTANCES." 14 | #endif 15 | #if (SSRC_N_INSTANCES < 1) 16 | #error "Number of instances (logical cores) must be at least 1. Check SSRC_N_INSTANCES." 17 | #endif 18 | #if (SSRC_N_CHANNELS < 1) 19 | #error "Number of audio channels must be at least 1. Check SSRC_N_CHANNELS." 20 | #endif 21 | #if (SSRC_N_IN_SAMPLES < 4) 22 | #error "Number of input audio samples in each block must be at least 4. Check SSRC_N_IN_SAMPLES." 23 | #endif 24 | #if ((SSRC_N_IN_SAMPLES & (SSRC_N_IN_SAMPLES - 1)) != 0) 25 | #error "Number of input audio samples in each block must be a power of two. Check SSRC_N_IN_SAMPLES." 26 | #endif 27 | #if (SSRC_N_OUT_IN_RATIO_MAX < 5) 28 | #warning "SRC buffering configured so that fs out <= 4 * fs in" 29 | #endif 30 | #if (SSRC_N_OUT_IN_RATIO_MAX < 3) 31 | #warning "SRC buffering configured so that fs out <= 2 * fs in" 32 | #endif 33 | #if (SSRC_N_OUT_IN_RATIO_MAX < 1) 34 | #warning "SRC buffering configured so that fs out <= fs in" 35 | #endif 36 | 37 | #endif // _SRC_MRHF_SSRC_CHECKS_H_ 38 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_wrapper.c: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2021 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // General includes 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "debug_print.h" 10 | 11 | // SSRC includes 12 | #include "src.h" 13 | 14 | static void ssrc_error(int code) 15 | { 16 | debug_printf("SSRC_proc Error code %d\n", code); 17 | delay_milliseconds(1); //Allow xscope to display message before quit 18 | _Exit(code); 19 | } 20 | 21 | 22 | void ssrc_init(const fs_code_t sr_in, const fs_code_t sr_out, ssrc_ctrl_t *ssrc_ctrl, 23 | const unsigned n_channels_per_instance, const unsigned n_in_samples, const dither_flag_t dither_on_off) 24 | { 25 | SSRCReturnCodes_t ret_code; 26 | unsigned ui; 27 | 28 | //Check to see if n_channels_per_instance, n_in_samples are reasonable 29 | if ((n_in_samples & 0x1) || (n_in_samples < 4)) ssrc_error(100); 30 | if (n_channels_per_instance < 1) ssrc_error(101); 31 | 32 | for(ui = 0; ui < n_channels_per_instance; ui++) 33 | { 34 | // Set number of channels per instance 35 | ssrc_ctrl[ui].uiNchannels = n_channels_per_instance; 36 | 37 | // Set number of samples 38 | ssrc_ctrl[ui].uiNInSamples = n_in_samples; 39 | 40 | // Set dither flag and random seeds 41 | ssrc_ctrl[ui].uiDitherOnOff = dither_on_off; 42 | ssrc_ctrl[ui].uiRndSeedInit = 12345 * ui; //Some randomish numbers. Value not critical 43 | 44 | // Set the sample rate codes 45 | ssrc_ctrl[ui].eInFs = (int)sr_in; 46 | ssrc_ctrl[ui].eOutFs = (int)sr_out; 47 | 48 | // Init SSRC instances 49 | ret_code = SSRC_init(&ssrc_ctrl[ui]) ; 50 | if(ret_code != SSRC_NO_ERROR) ssrc_error(ret_code); 51 | } 52 | } 53 | 54 | unsigned ssrc_process(int in_buff[], int out_buff[], ssrc_ctrl_t *ssrc_ctrl){ 55 | 56 | unsigned ui; 57 | unsigned n_samps_out; 58 | 59 | // Get the number of channels per instance from first channel 60 | const unsigned n_channels_per_instance = ssrc_ctrl[0].uiNchannels; 61 | 62 | for(ui = 0; ui < n_channels_per_instance; ui++) 63 | { 64 | ssrc_ctrl[ui].piIn = in_buff + ui; 65 | ssrc_ctrl[ui].piOut = out_buff + ui; 66 | if(SSRC_proc(&ssrc_ctrl[ui]) != SSRC_NO_ERROR) ssrc_error(0); 67 | n_samps_out = (*ssrc_ctrl[ui].puiNOutSamples); 68 | } 69 | return n_samps_out; 70 | } 71 | -------------------------------------------------------------------------------- /lib_src/src/multirate_hifi/use_vpu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef SRC_USE_VPU 4 | #if defined(__XS3A__) 5 | #define SRC_USE_VPU 1 6 | #else 7 | #define SRC_USE_VPU 0 8 | #endif 9 | #else 10 | #if(defined(__XS2A__) && (SRC_USE_VPU != 0)) 11 | #error VPU optimisation in lib_src is only available on XS3 (xcore.ai) architecture 12 | #endif 13 | #endif 14 | -------------------------------------------------------------------------------- /python/fixed_factor_vpu_voice/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/python/fixed_factor_vpu_voice/__init__.py -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020-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_src', 14 | packages=setuptools.find_packages(), 15 | install_requires=[ 16 | 'matplotlib==3.9.2', 17 | 'numpy==2.1.1', 18 | 'soundfile==0.12.1', 19 | 'scipy==1.14.1', 20 | 'mpmath==1.3.0', 21 | 'bitstring==4.2.3' 22 | ], 23 | dependency_links=[ 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /settings.yml: -------------------------------------------------------------------------------- 1 | # This file relates to internal XMOS infrastructure and should be ignored by external users 2 | --- 3 | lib_name: lib_src 4 | project: '{{lib_name}}' 5 | title: '{{lib_name}}: Sample rate conversion' 6 | version: 2.7.0 7 | 8 | documentation: 9 | exclude_patterns_path: doc/exclude_patterns.inc 10 | root_doc: doc/rst/lib_src.rst 11 | cognidox_part_number: XM-010383-UG 12 | doxygen_projects: 13 | lib_src: 14 | doxyfile_path: doc/Doxyfile.inc 15 | pdfs: 16 | doc/rst/lib_src.rst: 17 | pdf_title: '{{title}}' 18 | pdf_filename: '{{lib_name}}_v{{version}}' 19 | README.rst: 20 | pdf_title: '{{title}} (README)' 21 | pdf_filename: '{{lib_name}}_v{{version}}_readme' 22 | pdf_short: yes 23 | software: 24 | cognidox_part_number: XM-010388-SM 25 | 26 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | project(lib_src_tests) 4 | 5 | add_subdirectory(sim_tests) 6 | add_subdirectory(hw_tests) 7 | -------------------------------------------------------------------------------- /tests/hw_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | project(lib_src_hw_tests) 4 | 5 | add_subdirectory(asrc_task_test) 6 | add_subdirectory(asrc_task_test_ppm) 7 | add_subdirectory(asrc_test_xscope_fileio) 8 | add_subdirectory(asynchronous_fifo_asrc_test) 9 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(asrc_task_test) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(APP_COMPILER_FLAGS -Os 12 | -g 13 | -Wall 14 | -Wno-xcore-fptrgroup 15 | -DASRC_TASK_CONFIG=1 16 | -DDEBUG_ASRC_TASK=1 17 | -report 18 | -fcmdline-buffer-bytes=16384 19 | ) 20 | 21 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 22 | 23 | set(APP_INCLUDES src) 24 | 25 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 26 | 27 | XMOS_REGISTER_APP() 28 | endif() 29 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test/src/asrc_task_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define MAX_ASRC_CHANNELS_TOTAL 8 // Used for buffer sizing and FIFO sizing (static) 5 | #define MAX_ASRC_THREADS 4 // Sets upper limit of worker threads for ASRC task 6 | #define SRC_N_IN_SAMPLES 4 // Number of samples per channel in each block passed into SRC each call 7 | // Must be a power of 2 and minimum value is 4 (due to two /2 decimation stages) 8 | // Lower improves latency and memory usage but costs MIPS 9 | #define SRC_N_OUT_IN_RATIO_MAX 5 // Max ratio between samples out:in per processing step (44.1->192 is worst case) 10 | #define SRC_DITHER_SETTING 0 // Enables or disables quantisation of output with dithering to 24b -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test/src/asrc_task_receive_samples.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include "asrc_task.h" 5 | 6 | ASRC_TASK_ISR_CALLBACK_ATTR 7 | unsigned receive_asrc_input_samples(chanend_t c_producer, asrc_in_out_t *asrc_io, unsigned *new_input_rate){ 8 | static unsigned asrc_in_counter = 0; 9 | 10 | // Receive stream info from producer 11 | *new_input_rate = chanend_in_word(c_producer); 12 | asrc_io->input_timestamp[asrc_io->input_write_idx] = chanend_in_word(c_producer); 13 | asrc_io->input_channel_count = chanend_in_word(c_producer); 14 | 15 | // Pack into array properly LRLRLRLR or 123412341234 etc. 16 | for(int i = 0; i < asrc_io->input_channel_count; i++){ 17 | int idx = i + asrc_io->input_channel_count * asrc_in_counter; 18 | asrc_io->input_samples[asrc_io->input_write_idx][idx] = chanend_in_word(c_producer); 19 | } 20 | 21 | // Keep track of frame block to ASRC task 22 | if(++asrc_in_counter == SRC_N_IN_SAMPLES){ 23 | asrc_in_counter = 0; 24 | } 25 | 26 | return asrc_in_counter; 27 | } 28 | 29 | // Register the above function for ASRC task 30 | void setup_asrc_io_custom_callback(asrc_in_out_t *asrc_io){ 31 | init_asrc_io_callback(asrc_io, receive_asrc_input_samples); 32 | } 33 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test/src/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test_ppm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(asrc_task_test_ppm) 6 | 7 | set(APP_HW_TARGET XCORE-AI-EXPLORER) 8 | 9 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 10 | 11 | set(APP_XSCOPE_SRCS src/config.xscope) 12 | 13 | set(COMPILER_FLAGS_COMMON -O3 14 | -g 15 | -report 16 | -DASRC_TASK_CONFIG=1 # Enables user setting of ASRC configuration 17 | -DDEBUG_ASRC_TASK=0 # Prints cycle usage 18 | -fcmdline-buffer-bytes=16384 19 | ) 20 | 21 | set(APP_COMPILER_FLAGS_STEP ${COMPILER_FLAGS_COMMON} 22 | -DDO_STEP=1 23 | ) 24 | 25 | set(APP_COMPILER_FLAGS_SINE ${COMPILER_FLAGS_COMMON} 26 | -DDO_SINE=1 27 | ) 28 | 29 | # Needed by this application and not part of src library 30 | set(APP_C_SRCS ../../../lib_src/src/asrc_task/asrc_task.c src/asrc_task_receive_samples.c) 31 | 32 | set(APP_INCLUDES src/ 33 | ../../../lib_src/src/asrc_task/) 34 | 35 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 36 | 37 | XMOS_REGISTER_APP() 38 | endif() 39 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test_ppm/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test_ppm/src/asrc_task_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #define MAX_ASRC_CHANNELS_TOTAL 1 // Used for buffer sizing and FIFO sizing (static) 5 | #define MAX_ASRC_THREADS 1 // Sets upper limit of worker threads for ASRC task 6 | #define SRC_N_IN_SAMPLES 4 // Number of samples per channel in each block passed into SRC each call 7 | // Must be a power of 2 and minimum value is 4 (due to two /2 decimation stages) 8 | // Lower improves latency and memory usage but costs MIPS 9 | #define SRC_N_OUT_IN_RATIO_MAX 5 // Max ratio between samples out:in per processing step (44.1->192 is worst case) 10 | #define SRC_DITHER_SETTING 0 // Enables or disables quantisation of output with dithering to 24b -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test_ppm/src/asrc_task_receive_samples.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include "asrc_task.h" 5 | 6 | ASRC_TASK_ISR_CALLBACK_ATTR 7 | unsigned receive_asrc_input_samples(chanend_t c_producer, asrc_in_out_t *asrc_io, unsigned *new_input_rate){ 8 | static unsigned asrc_in_counter = 0; 9 | 10 | // Receive stream info from producer 11 | *new_input_rate = chanend_in_word(c_producer); 12 | asrc_io->input_timestamp[asrc_io->input_write_idx] = chanend_in_word(c_producer); 13 | asrc_io->input_channel_count = chanend_in_word(c_producer); 14 | 15 | // Pack into array properly LRLRLRLR or 123412341234 etc. 16 | for(int i = 0; i < asrc_io->input_channel_count; i++){ 17 | int idx = i + asrc_io->input_channel_count * asrc_in_counter; 18 | asrc_io->input_samples[asrc_io->input_write_idx][idx] = chanend_in_word(c_producer); 19 | } 20 | 21 | // Keep track of frame block to ASRC task 22 | if(++asrc_in_counter == SRC_N_IN_SAMPLES){ 23 | asrc_in_counter = 0; 24 | } 25 | 26 | return asrc_in_counter; 27 | } 28 | 29 | // Register the above function for ASRC task 30 | void setup_asrc_io_custom_callback(asrc_in_out_t *asrc_io){ 31 | init_asrc_io_callback(asrc_io, receive_asrc_input_samples); 32 | } 33 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_task_test_ppm/src/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/hw_tests/asrc_test_xscope_fileio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 6 | 7 | project(asrc_test_xscope_fileio) 8 | set(APP_HW_TARGET XK-EVK-XU316) 9 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 10 | list(APPEND APP_DEPENDENT_MODULES "xscope_fileio(1.2.0)") 11 | 12 | set(APP_COMPILER_FLAGS -Os 13 | -g 14 | -Wall 15 | -Wno-xcore-fptrgroup 16 | -report 17 | -fcmdline-buffer-bytes=2048 18 | -DXSCOPE 19 | -DTEST_WAV_XSCOPE=1 20 | ) 21 | 22 | set(APP_XC_SRCS src/main.xc) 23 | file(GLOB_RECURSE APP_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src/*.c) 24 | set(APP_C_SRCS ${APP_SOURCES}) 25 | set(APP_INCLUDES src/file_utils) 26 | XMOS_REGISTER_APP() 27 | endif() 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_test_xscope_fileio/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmos/lib_src/1d4e49541bbb97d489834f0524732d3285181e58/tests/hw_tests/asrc_test_xscope_fileio/python/__init__.py -------------------------------------------------------------------------------- /tests/hw_tests/asrc_test_xscope_fileio/src/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_test_xscope_fileio/src/file_utils/fileio.c: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include "fileio.h" 5 | 6 | int file_open(file_t *fp, const char* name, const char *mode) { 7 | #if TEST_WAV_XSCOPE 8 | fp->xscope_file = xscope_open_file(name, (char*)mode); 9 | #else 10 | if(!strcmp(mode, "rb")) { 11 | fp->file = open(name, O_RDONLY); 12 | if(fp->file == -1) {return -1;} 13 | } 14 | else if(!strcmp(mode, "wb")) { 15 | fp->file = open(name, O_WRONLY|O_CREAT, 0644); 16 | if(fp->file == -1) {return -1;} 17 | } 18 | else { 19 | assert((0) && "invalid file open mode specified. Only 'rb' and 'wb' modes supported"); 20 | } 21 | #endif 22 | return 0; 23 | } 24 | 25 | void file_seek(file_t *fp, long int offset, int origin) { 26 | #if TEST_WAV_XSCOPE 27 | xscope_fseek(&fp->xscope_file, offset, origin); 28 | #else 29 | lseek(fp->file, offset, origin); 30 | #endif 31 | } 32 | 33 | int get_current_file_offset(file_t *fp) { 34 | #if TEST_WAV_XSCOPE 35 | int current_offset = xscope_ftell(&fp->xscope_file); 36 | #else 37 | int current_offset = lseek(fp->file, 0, SEEK_CUR); 38 | #endif 39 | return current_offset; 40 | } 41 | 42 | int get_file_size(file_t *fp) { 43 | #if TEST_WAV_XSCOPE 44 | //find the current offset in the file 45 | int current_offset = xscope_ftell(&fp->xscope_file); 46 | //go to the end 47 | xscope_fseek(&fp->xscope_file, 0, SEEK_END); 48 | //get offset which will be file size 49 | int size = xscope_ftell(&fp->xscope_file); 50 | //return back to the original offset 51 | xscope_fseek(&fp->xscope_file, current_offset, SEEK_SET); 52 | #else 53 | //find the current offset in the file 54 | int current_offset = lseek(fp->file, 0, SEEK_CUR); 55 | //get file size 56 | int size = lseek(fp->file, 0, SEEK_END); 57 | //go back to original offset 58 | lseek(fp->file, current_offset, SEEK_SET); 59 | #endif 60 | return size; 61 | } 62 | 63 | void file_read(file_t *fp, void *buf, size_t count) { 64 | #if TEST_WAV_XSCOPE 65 | xscope_fread(&fp->xscope_file, (uint8_t*)buf, count); 66 | #else 67 | read(fp->file, buf, count); 68 | #endif 69 | } 70 | 71 | void file_write(file_t *fp, void *buf, size_t count) { 72 | #if TEST_WAV_XSCOPE 73 | xscope_fwrite(&fp->xscope_file, (uint8_t*)buf, count); 74 | #else 75 | write(fp->file, buf, count); 76 | #endif 77 | } 78 | 79 | void file_close(file_t *fp) { 80 | #if !TEST_WAV_XSCOPE 81 | close(fp->file); 82 | #else 83 | //files are closed by a single call to xscope_close_all_files() 84 | #endif 85 | } 86 | 87 | void shutdown_session() { 88 | //Needed for XSCOPE_ID_HOST_QUIT in xscope_close_all_files() 89 | #if TEST_WAV_XSCOPE 90 | xscope_close_all_files(); 91 | #endif 92 | } 93 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_test_xscope_fileio/src/file_utils/fileio.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef FILEIO_H 4 | #define FILEIO_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #if TEST_WAV_XSCOPE 11 | #include "xscope_io_device.h" 12 | #endif 13 | #include 14 | #include 15 | 16 | typedef union { 17 | int file; 18 | #if TEST_WAV_XSCOPE 19 | xscope_file_t xscope_file; 20 | #endif 21 | }file_t; 22 | 23 | 24 | int file_open(file_t *fp, const char* name, const char *mode); 25 | void file_read(file_t *fp, void *buf, size_t count); 26 | void file_write(file_t *fp, void *buf, size_t count); 27 | void file_seek(file_t *fp, long int offset, int origin); 28 | void file_close(file_t *fp); 29 | void shutdown_session(); //Needed for XSCOPE_ID_HOST_QUIT in xscope_close_all_files() 30 | 31 | int get_current_file_offset(file_t *fp); 32 | int get_file_size(file_t *fp); 33 | #endif 34 | -------------------------------------------------------------------------------- /tests/hw_tests/asrc_test_xscope_fileio/src/main.xc: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // General includes 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #if TEST_WAV_XSCOPE 14 | #include "xscope_io_device.h" 15 | #endif 16 | 17 | // ASRC includes 18 | #include "src.h" 19 | 20 | #define ASRC_N_CHANNELS 2 //Total number of audio channels to be processed by SRC (minimum 1) 21 | #define ASRC_N_INSTANCES 1 //Number of instances (each usuall run a logical core) used to process audio (minimum 1) 22 | #define ASRC_CHANNELS_PER_INSTANCE (ASRC_N_CHANNELS/ASRC_N_INSTANCES) 23 | //Calcualted number of audio channels processed by each core 24 | #define ASRC_N_IN_SAMPLES 4 //Number of samples per channel in each block passed into SRC each call 25 | //Must be a power of 2 and minimum value is 4 (due to two /2 decimation stages) 26 | #define ASRC_N_OUT_IN_RATIO_MAX 5 //Max ratio between samples out:in per processing step (44.1->192 is worst case) 27 | #define ASRC_DITHER_SETTING OFF 28 | 29 | #include "src_mrhf_asrc_checks.h" //Do some checking on the defines above 30 | 31 | //Global deviation ratio from nominal sample rate in/out ratio. Initialise to invalid. 32 | double fFsRatioDeviation = (double)-1.0000; 33 | 34 | extern void parse_args(); 35 | extern void parse_args(); 36 | extern void dsp_slave(chanend c_dsp); 37 | extern void dsp_mgr(chanend c_dsp[], double fFsRatioDeviation); 38 | 39 | int main() 40 | { 41 | chan xscope_chan; 42 | chan c_dsp[ASRC_N_INSTANCES]; 43 | par 44 | { 45 | #if TEST_WAV_XSCOPE 46 | xscope_host_data(xscope_chan); 47 | #endif 48 | on tile[1]: { 49 | parse_args(); 50 | par { 51 | par (unsigned i=0; i 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 | -------------------------------------------------------------------------------- /tests/requirements.txt: -------------------------------------------------------------------------------- 1 | -e ../python 2 | -e . 3 | -------------------------------------------------------------------------------- /tests/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020-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_src_tests', 14 | packages=setuptools.find_packages(), 15 | install_requires=[ 16 | 'pytest==8.3.3', 17 | 'pytest-xdist==3.6.1', 18 | 'matplotlib==3.9.2', 19 | 'numpy==2.1.1', 20 | 'soundfile==0.12.1', 21 | 'scipy==1.14.1', 22 | 'mpmath==1.3.0', 23 | 'bitstring==4.2.3' 24 | ], 25 | dependency_links=[ 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /tests/sim_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | project(lib_src_sim_tests) 4 | 5 | add_subdirectory(asrc_test) 6 | add_subdirectory(asrc_vpu_test) 7 | add_subdirectory(ds3_test) 8 | add_subdirectory(ds3_voice_test) 9 | add_subdirectory(os3_test) 10 | add_subdirectory(ssrc_test) 11 | add_subdirectory(unity_gain_voice_test) 12 | add_subdirectory(us3_voice_test) 13 | add_subdirectory(vpu_ff3_test) 14 | add_subdirectory(vpu_rat_test) 15 | -------------------------------------------------------------------------------- /tests/sim_tests/asrc_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 5 | 6 | project(asrc_test) 7 | 8 | if(NOT BUILD_NATIVE) # dut 9 | set(APP_HW_TARGET XK-EVK-XU316) 10 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 11 | 12 | set(APP_COMPILER_FLAGS -Os 13 | -g 14 | -Wall 15 | -Wno-xcore-fptrgroup 16 | -report 17 | -fcmdline-buffer-bytes=2048 18 | ) 19 | set(APP_XC_SRCS src/dut/asrc_test.xc) 20 | set(APP_C_SRCS "") 21 | set(APP_INCLUDES src/dut) 22 | 23 | else() # golden reference 24 | 25 | set(APP_COMPILER_FLAGS -Os 26 | -D__int64=int64_t 27 | ) 28 | file(GLOB_RECURSE APP_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src/model/*.c) 29 | set(APP_XC_SRCS "") 30 | set(APP_C_SRCS ${APP_SOURCES}) 31 | set(APP_INCLUDES src/model 32 | src/model/api 33 | src/model/src 34 | ../../../lib_src/src/multirate_hifi) 35 | set(APP_XSCOPE_SRCS "") 36 | endif() 37 | 38 | XMOS_REGISTER_APP() 39 | 40 | -------------------------------------------------------------------------------- /tests/sim_tests/asrc_test/asrc_c_emulator.cmake: -------------------------------------------------------------------------------- 1 | set(LIB_NAME asrc_c_emulator_lib) 2 | add_library(${LIB_NAME} STATIC) 3 | 4 | target_sources(${LIB_NAME} 5 | PRIVATE 6 | ${CMAKE_CURRENT_LIST_DIR}/model/src/ASRC_wrapper.c 7 | ${CMAKE_CURRENT_LIST_DIR}/model/src/ASRC.c 8 | ${CMAKE_CURRENT_LIST_DIR}/model/src/FilterDefs.c 9 | ${CMAKE_CURRENT_LIST_DIR}/model/src/FIR.c 10 | ${CMAKE_CURRENT_LIST_DIR}/model/src/IntArithmetic.c 11 | ) 12 | 13 | target_include_directories(${LIB_NAME} 14 | PRIVATE 15 | ${CMAKE_CURRENT_LIST_DIR}/model/src 16 | ${CMAKE_CURRENT_LIST_DIR}/../../lib_src/src/multirate_hifi) 17 | 18 | target_include_directories(${LIB_NAME} 19 | PUBLIC 20 | ${CMAKE_CURRENT_LIST_DIR}/model/api 21 | ) 22 | 23 | target_compile_definitions(${LIB_NAME} 24 | PUBLIC 25 | __int64=int64_t 26 | ) 27 | 28 | target_compile_options(${LIB_NAME} 29 | PRIVATE 30 | -Os 31 | -g 32 | -fPIC 33 | ) 34 | -------------------------------------------------------------------------------- /tests/sim_tests/asrc_test/src/model/Main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: Main.h 7 | // 8 | // Main definition file for the ASRC demonstration program 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _MAIN_H_ 17 | #define _MAIN_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | #define APPLICATION "ASRC_demo" 25 | #define VERSION "Version 1.0" 26 | #define COPYRIGHT "(c) Digimath, 2015" 27 | #define FATAL 0 28 | #define WARNING 1 29 | 30 | 31 | 32 | // =========================================================================== 33 | // 34 | // Function prototypes 35 | // 36 | // =========================================================================== 37 | void ParseCmdLine(char *input); 38 | void ShowHelp(); 39 | void ShowUsage(); 40 | void HandleError(char *pzErrorMessage, short sErrorType); 41 | 42 | #endif // _MAIN_H_ -------------------------------------------------------------------------------- /tests/sim_tests/asrc_test/src/model/api/ASRC_wrapper.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #ifndef _ASRC_WRAPPER_H_ 4 | #define _ASRC_WRAPPER_H_ 5 | 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define MAX_ASRC_N_IO_CHANNELS (2) 13 | 14 | // Sampling rate codes 15 | // ------------------- 16 | typedef enum _ASRCFs 17 | { 18 | ASRC_FS_44 = 0, // Fs = 44.1kHz code 19 | ASRC_FS_48 = 1, // Fs = 48kHz code 20 | ASRC_FS_88 = 2, // Fs = 88.2kHz code 21 | ASRC_FS_96 = 3, // Fs = 96kHz code 22 | ASRC_FS_176 = 4, // Fs = 176.4kHz code 23 | ASRC_FS_192 = 5, // Fs = 192kHz code 24 | } ASRCFs_t; 25 | #define ASRC_N_FS (ASRC_FS_192 + 1) 26 | #define ASRC_FS_MIN ASRC_FS_44 27 | #define ASRC_FS_MAX ASRC_FS_192 28 | 29 | // Parameter values 30 | // ---------------- 31 | #define ASRC_ON 1 32 | #define ASRC_OFF 0 33 | #define ASRC_DITHER_OFF ASRC_OFF 34 | #define ASRC_DITHER_ON ASRC_ON 35 | 36 | typedef struct { 37 | float fCycleCountF1F2; // Variable to hold cycle count for MIPS estimations for F1 and F2 stages 38 | float fCycleCountF3AdaptiveCoefs; // Variable to hold cycle count for MIPS estimations for F3 adaptive filters computation 39 | float fCycleCountF3; // Variable to hold cycle count for MIPS estimations for F3 computation 40 | float fCycleCountDither; // Variable to hold cycle count for MIPS estimations for dither computation 41 | }ASRCCtrl_profile_only_t; 42 | 43 | uint64_t wrapper_asrc_init( 44 | ASRCCtrl_profile_only_t* (*profile_info_ptr)[MAX_ASRC_N_IO_CHANNELS], // Pointer to array of pointers 45 | unsigned uiInFs, 46 | unsigned uiOutFs, 47 | unsigned uiNInSamples, 48 | unsigned num_io_channels, 49 | unsigned num_channels_per_asrc_instance, 50 | unsigned dither_on_off, 51 | unsigned *rand_seed); 52 | 53 | unsigned wrapper_asrc_process( 54 | int *piIn, 55 | int *piOut, 56 | uint64_t fs_ratio 57 | ); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | #endif 63 | -------------------------------------------------------------------------------- /tests/sim_tests/asrc_test/src/model/src/IntArithmetic.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: IntArithmetic.h 7 | // 8 | // Integer arithmetic definition file for the ASRC 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _INT_ARITHMETIC_H_ 17 | #define _INT_ARITHMETIC_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | 25 | 26 | 27 | // =========================================================================== 28 | // 29 | // Variables 30 | // 31 | // =========================================================================== 32 | 33 | 34 | // =========================================================================== 35 | // 36 | // TypeDefs 37 | // 38 | // =========================================================================== 39 | // To avoid C type definitions when including this file from assembler 40 | #ifndef INCLUDE_FROM_ASM 41 | 42 | 43 | // =========================================================================== 44 | // 45 | // Function prototypes 46 | // 47 | // =========================================================================== 48 | 49 | // ==================================================================== // 50 | // Function: MACC // 51 | // Description: 32i x 32i -> 64i Multiply-Accumulate // 52 | // ==================================================================== // 53 | void MACC(__int64* plAcc, int ix, int iy); 54 | 55 | // ==================================================================== // 56 | // Function: LMUL // 57 | // Description: 32i x 32i +32i + 32i -> 64i Multiply (and add) // 58 | // ==================================================================== // 59 | void LMUL(__int64* plAcc, int ix, int iy, int ic, int id); 60 | 61 | // ==================================================================== // 62 | // Function: LATS30 // 63 | // Description: Saturate 64i to 2^62-1, -2^62 // 64 | // ==================================================================== // 65 | #define MAX_VAL64_30 (__int64)0x3FFFFFFFFFFFFFFF 66 | #define MIN_VAL64_30 (__int64)0xC000000000000000 67 | void LSAT30(__int64 *plx); 68 | 69 | // ==================================================================== // 70 | // Function: EXT30 // 71 | // Description: Extracts bits [62-31] into 32i // 72 | // ==================================================================== // 73 | void EXT30(int *pr, __int64 lx); 74 | 75 | // ==================================================================== // 76 | // Function: LATS29 // 77 | // Description: Saturate 64i to 2^61-1, -2^61 // 78 | // ==================================================================== // 79 | #define MAX_VAL64_29 (__int64)0x1FFFFFFFFFFFFFFF 80 | #define MIN_VAL64_29 (__int64)0xE000000000000000 81 | void LSAT29(__int64 *plx); 82 | 83 | // ==================================================================== // 84 | // Function: EXT29 // 85 | // Description: Extracts bits [61-30] into 32i // 86 | // ==================================================================== // 87 | void EXT29(int *pr, __int64 lx); 88 | 89 | #endif // nINCLUDE_FROM_ASM 90 | 91 | #endif // _INT_ARITHMETIC_H_ -------------------------------------------------------------------------------- /tests/sim_tests/asrc_vpu_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(asrc_vpu_test) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(APP_COMPILER_FLAGS -O2 12 | -fxscope 13 | ) 14 | 15 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 16 | 17 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 18 | 19 | XMOS_REGISTER_APP() 20 | endif() 21 | -------------------------------------------------------------------------------- /tests/sim_tests/asrc_vpu_test/src/config.xscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/sim_tests/conftest.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 XMOS LIMITED. 2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | import pytest 4 | from utils.src_test_utils import generate_mips_report 5 | 6 | def pytest_sessionfinish(session, exitstatus): 7 | """ 8 | Called after whole test run finished, right before 9 | returning the exit status to the system. 10 | """ 11 | # Ensure we play nicely with xdist 12 | if not hasattr(session.config, "workerinput"): 13 | pass 14 | 15 | for mips_report_type in ["ssrc", "asrc"]: 16 | generate_mips_report(mips_report_type) 17 | -------------------------------------------------------------------------------- /tests/sim_tests/ds3_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 5 | project(ds3_test) 6 | 7 | if(NOT BUILD_NATIVE) 8 | set(APP_HW_TARGET XK-EVK-XU316) 9 | 10 | set(APP_COMPILER_FLAGS -Os 11 | -g 12 | -Wall 13 | -Wno-xcore-fptrgroup 14 | -report 15 | -fcmdline-buffer-bytes=2048 16 | ) 17 | 18 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 19 | 20 | set(APP_XC_SRCS src/dut/app_ds3.xc) 21 | set(APP_C_SRCS "") 22 | else() 23 | set(APP_COMPILER_FLAGS -Os 24 | -D__int64=int64_t 25 | ) 26 | file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src/model/*.c) 27 | set(APP_XC_SRCS "") 28 | set(APP_C_SRCS ${APP_SOURCES}) 29 | set(APP_INCLUDES src/model 30 | ../../../lib_src/src/fixed_factor_of_3/ds3) 31 | endif() 32 | 33 | XMOS_REGISTER_APP() 34 | -------------------------------------------------------------------------------- /tests/sim_tests/ds3_test/src/dut/app_ds3.xc: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // Downsample by factor of 3 example 4 | // Uses Signed 32b Integer format 5 | 6 | // Include files 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "src.h" 12 | 13 | #define NUM_CHANNELS 2 14 | #define NUM_OUTPUT_SAMPLES 256 15 | 16 | #define NUM_IN_SAMPLES 800 17 | // 0db 1KHz 48KHz sinewave - pure tone test 18 | int32_t s1k_0db_48[NUM_IN_SAMPLES]; 19 | // -6db 5/6KHz 48KHz sinewaves - intermodulation test 20 | int32_t im5k6k_m6dB_48[NUM_IN_SAMPLES]; 21 | 22 | void read_dat_file(char *fname, int32_t data[], size_t n) 23 | { 24 | FILE * movable InFileDat; 25 | if ((InFileDat = fopen((char *)fname, "rt")) == NULL) 26 | { 27 | printf("Error while opening input file, %s", fname); 28 | exit(1); 29 | } 30 | for(int i = 0; i < n; i++) 31 | { 32 | if(fscanf(InFileDat, "%i\n", &data[i]) == EOF) 33 | { 34 | printf("Error while reading input file, %s at line %d", fname, i); 35 | exit(1); 36 | } 37 | // printf("read: %d\n", data[i]); 38 | } 39 | fclose(move(InFileDat)); 40 | } 41 | 42 | 43 | int main(void) 44 | { 45 | read_dat_file("../../../src_input/s1k_0dB_48.dat", s1k_0db_48, NUM_IN_SAMPLES); 46 | read_dat_file("../../../src_input/im5k6k_m6dB_48.dat", im5k6k_m6dB_48, NUM_IN_SAMPLES); 47 | 48 | 49 | unsafe { 50 | src_ff3_return_code_t return_code = SRC_FF3_NO_ERROR; 51 | 52 | // Input data for both channels 53 | const int32_t * unsafe input_data[NUM_CHANNELS] = {s1k_0db_48, im5k6k_m6dB_48}; 54 | 55 | // Output samples 56 | int32_t output_data[NUM_CHANNELS]; 57 | 58 | // DS3 instances variables 59 | // ----------------------- 60 | // State and Control structures (one for each channel) 61 | int src_ds3_delay[NUM_CHANNELS][SRC_FF3_DS3_N_COEFS<<1]; 62 | src_ds3_ctrl_t src_ds3_ctrl[NUM_CHANNELS]; 63 | 64 | //Init DS3 65 | for (int i=0; i 64i Multiply-Accumulate // 52 | // ==================================================================== // 53 | void MACC(__int64* plAcc, int ix, int iy); 54 | 55 | // ==================================================================== // 56 | // Function: LATS30 // 57 | // Description: Saturate 64i to 2^62-1, -2^62 // 58 | // ==================================================================== // 59 | #define MAX_VAL64 (__int64)0x3FFFFFFFFFFFFFFF 60 | #define MIN_VAL64 (__int64)0xC000000000000000 61 | void LSAT30(__int64 *plx); 62 | 63 | // ==================================================================== // 64 | // Function: EXT30 // 65 | // Description: Extracts bits [62-31] into 32i // 66 | // ==================================================================== // 67 | void EXT30(int *pr, __int64 lx); 68 | 69 | // ==================================================================== // 70 | // Function: LATS27 // 71 | // Description: Saturate 64i to 2^60-1, -2^60 // 72 | // (Result from 4.28 x 1.31 multiplication // 73 | // ==================================================================== // 74 | #define MAX_VAL64_28 (__int64)0x0FFFFFFFFFFFFFFF 75 | #define MIN_VAL64_28 (__int64)0xF000000000000000 76 | void LSAT28(__int64 *plx); 77 | 78 | // ==================================================================== // 79 | // Function: EXT27 // 80 | // Description: Extracts bits [59-28] into 32i // 81 | // ==================================================================== // 82 | void EXT28(int *pr, __int64 lx); 83 | 84 | #endif // nINCLUDE_FROM_ASM 85 | 86 | #endif // _INT_ARITHMETIC_H_ -------------------------------------------------------------------------------- /tests/sim_tests/ds3_test/src/model/Main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: Main.h 7 | // 8 | // Main definition file for the DS3 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _MAIN_H_ 17 | #define _MAIN_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | #define APPLICATION "DS3" 25 | #define VERSION "Version 1.0" 26 | #define COPYRIGHT "(c) Digimath, 2015" 27 | #define FATAL 0 28 | #define WARNING 1 29 | 30 | 31 | 32 | // =========================================================================== 33 | // 34 | // Function prototypes 35 | // 36 | // =========================================================================== 37 | void ParseCmdLine(char *input); 38 | void ShowHelp(); 39 | void ShowUsage(); 40 | void HandleError(char *pzErrorMessage, short sErrorType); 41 | 42 | #endif // _MAIN_H_ -------------------------------------------------------------------------------- /tests/sim_tests/ds3_voice_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | set(APP_PCA_ENABLE ON) 6 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 7 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 8 | set(APP_INCLUDES src) 9 | 10 | set(ARCH xs2 xs3) 11 | 12 | foreach(arch ${ARCH}) 13 | if(arch STREQUAL "xs3") 14 | set(target "XK-EVK-XU316") 15 | elseif(arch STREQUAL "xs2") 16 | set(target "XCORE-200-EXPLORER") 17 | endif() 18 | project(ds3_voice_test) 19 | set(APP_HW_TARGET ${target}) 20 | set(APP_COMPILER_FLAGS_${arch} -O3 21 | -g 22 | -report 23 | -mno-dual-issue 24 | ) 25 | XMOS_REGISTER_APP() 26 | unset(APP_COMPILER_FLAGS_${arch}) 27 | endforeach() 28 | endif() 29 | -------------------------------------------------------------------------------- /tests/sim_tests/ds3_voice_test/src/app_ds3_voice.xc: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "src.h" 9 | 10 | #define NUM_OF_TAPS (SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE) 11 | 12 | static int pseudo_random(unsigned &x) 13 | { 14 | crc32(x, -1, 0xEB31D82E); 15 | return (int)x; 16 | } 17 | 18 | int main() 19 | { 20 | unsigned x = 1; 21 | 22 | int32_t data_debug[NUM_OF_TAPS]; 23 | memset(data_debug, 0, sizeof(data_debug)); 24 | 25 | int32_t data[SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE]; 26 | memset(data, 0, sizeof(data)); 27 | 28 | for (unsigned r = 0; r < (NUM_OF_TAPS*8); r++) 29 | { 30 | int64_t sum = 0; 31 | 32 | int32_t d = pseudo_random(x); 33 | sum = src_ds3_voice_add_sample(sum, data[0], src_ff3v_fir_coefs[0], d); 34 | for (unsigned i = (NUM_OF_TAPS-1); i > 0; i--) 35 | { 36 | data_debug[i] = data_debug[i-1]; 37 | } 38 | data_debug[0] = d; 39 | 40 | d = pseudo_random(x); 41 | sum = src_ds3_voice_add_sample(sum, data[1], src_ff3v_fir_coefs[1], d); 42 | for (unsigned i = (NUM_OF_TAPS-1); i > 0; i--) 43 | { 44 | data_debug[i] = data_debug[i-1]; 45 | } 46 | data_debug[0] = d; 47 | 48 | d = pseudo_random(x); 49 | sum = src_ds3_voice_add_final_sample(sum, data[2], src_ff3v_fir_coefs[2], d); 50 | for (unsigned i = (NUM_OF_TAPS-1); i > 0; i--) 51 | { 52 | data_debug[i] = data_debug[i-1]; 53 | } 54 | data_debug[0] = d; 55 | 56 | int64_t sum_debug = 0; 57 | for (unsigned i = 0; i < NUM_OF_TAPS; i++) 58 | { 59 | sum_debug += (int64_t)src_ff3v_fir_coefs_debug[i]*(int64_t)data_debug[i]; 60 | } 61 | sum_debug >>= 31; 62 | 63 | sum_debug = (int32_t)(((int64_t)sum_debug * (int64_t)src_ff3v_fir_comp_ds)>>src_ff3v_fir_comp_q_ds); 64 | 65 | if ((int32_t)sum != (int32_t)sum_debug) 66 | { 67 | printf("Error\n"); 68 | return 1; 69 | } 70 | 71 | } 72 | printf("Success\n"); 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /tests/sim_tests/os3_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | 5 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 6 | project(os3_test) 7 | 8 | if(NOT BUILD_NATIVE) 9 | set(APP_HW_TARGET XK-EVK-XU316) 10 | 11 | set(APP_COMPILER_FLAGS -Os 12 | -g 13 | -Wall 14 | -Wno-xcore-fptrgroup 15 | -report 16 | -fcmdline-buffer-bytes=2048 17 | ) 18 | 19 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 20 | 21 | set(APP_XC_SRCS src/dut/app_os3.xc) 22 | set(APP_C_SRCS "") 23 | else() 24 | set(APP_COMPILER_FLAGS -Os 25 | -D__int64=int64_t 26 | ) 27 | file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src/model/*.c) 28 | set(APP_XC_SRCS "") 29 | set(APP_C_SRCS ${APP_SOURCES}) 30 | set(APP_INCLUDES src/model 31 | ../../../lib_src/src/fixed_factor_of_3/os3) 32 | endif() 33 | 34 | XMOS_REGISTER_APP() 35 | -------------------------------------------------------------------------------- /tests/sim_tests/os3_test/src/model/IntArithmetic.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: IntArithmetic.h 7 | // 8 | // Integer arithmetic definition file for the SSRC 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _INT_ARITHMETIC_H_ 17 | #define _INT_ARITHMETIC_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | 25 | 26 | 27 | // =========================================================================== 28 | // 29 | // Variables 30 | // 31 | // =========================================================================== 32 | 33 | 34 | // =========================================================================== 35 | // 36 | // TypeDefs 37 | // 38 | // =========================================================================== 39 | // To avoid C type definitions when including this file from assembler 40 | #ifndef INCLUDE_FROM_ASM 41 | 42 | 43 | // =========================================================================== 44 | // 45 | // Function prototypes 46 | // 47 | // =========================================================================== 48 | 49 | // ==================================================================== // 50 | // Function: MACC // 51 | // Description: 32i x 32i -> 64i Multiply-Accumulate // 52 | // ==================================================================== // 53 | void MACC(__int64* plAcc, int ix, int iy); 54 | 55 | // ==================================================================== // 56 | // Function: LATS30 // 57 | // Description: Saturate 64i to 2^62-1, -2^62 // 58 | // ==================================================================== // 59 | #define MAX_VAL64 (__int64)0x3FFFFFFFFFFFFFFF 60 | #define MIN_VAL64 (__int64)0xC000000000000000 61 | void LSAT30(__int64 *plx); 62 | 63 | // ==================================================================== // 64 | // Function: EXT30 // 65 | // Description: Extracts bits [62-31] into 32i // 66 | // ==================================================================== // 67 | void EXT30(int *pr, __int64 lx); 68 | 69 | // ==================================================================== // 70 | // Function: LATS27 // 71 | // Description: Saturate 64i to 2^60-1, -2^60 // 72 | // (Result from 4.28 x 1.31 multiplication // 73 | // ==================================================================== // 74 | #define MAX_VAL64_28 (__int64)0x0FFFFFFFFFFFFFFF 75 | #define MIN_VAL64_28 (__int64)0xF000000000000000 76 | void LSAT28(__int64 *plx); 77 | 78 | // ==================================================================== // 79 | // Function: EXT27 // 80 | // Description: Extracts bits [59-28] into 32i // 81 | // ==================================================================== // 82 | void EXT28(int *pr, __int64 lx); 83 | 84 | #endif // nINCLUDE_FROM_ASM 85 | 86 | #endif // _INT_ARITHMETIC_H_ -------------------------------------------------------------------------------- /tests/sim_tests/os3_test/src/model/Main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: Main.h 7 | // 8 | // Main definition file for the OS3 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _MAIN_H_ 17 | #define _MAIN_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | #define APPLICATION "OS3" 25 | #define VERSION "Version 1.0" 26 | #define COPYRIGHT "(c) Digimath, 2015" 27 | #define FATAL 0 28 | #define WARNING 1 29 | 30 | 31 | 32 | // =========================================================================== 33 | // 34 | // Function prototypes 35 | // 36 | // =========================================================================== 37 | void ParseCmdLine(char *input); 38 | void ShowHelp(); 39 | void ShowUsage(); 40 | void HandleError(char *pzErrorMessage, short sErrorType); 41 | 42 | #endif // _MAIN_H_ -------------------------------------------------------------------------------- /tests/sim_tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | prepare:things to run before the main DUT test, like gen golden or build bins 4 | main:the main DUT test itself 5 | -------------------------------------------------------------------------------- /tests/sim_tests/ssrc_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | 5 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 6 | project(ssrc_test) 7 | 8 | if(NOT BUILD_NATIVE) 9 | set(APP_HW_TARGET XK-EVK-XU316) 10 | 11 | set(APP_COMPILER_FLAGS -Os 12 | -g 13 | -Wall 14 | -Wno-xcore-fptrgroup 15 | -report 16 | -fcmdline-buffer-bytes=2048 17 | ) 18 | 19 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 20 | 21 | set(APP_XC_SRCS src/dut/ssrc_test.xc) 22 | set(APP_C_SRCS "") 23 | else() 24 | set(APP_COMPILER_FLAGS -Os 25 | -D__int64=int64_t 26 | ) 27 | 28 | file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src/model/*.c) 29 | set(APP_XC_SRCS "") 30 | set(APP_C_SRCS ${APP_SOURCES}) 31 | set(APP_INCLUDES src/model 32 | ../../../lib_src/src/multirate_hifi) 33 | endif() 34 | 35 | XMOS_REGISTER_APP() 36 | -------------------------------------------------------------------------------- /tests/sim_tests/ssrc_test/src/model/IntArithmetic.c: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: IntArithmetic.c 7 | // 8 | // Integer arithmetic implementation file for the SSRC 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | 17 | // =========================================================================== 18 | // 19 | // Includes 20 | // 21 | // =========================================================================== 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // Integer arithmetic includes 28 | #include "IntArithmetic.h" 29 | 30 | // =========================================================================== 31 | // 32 | // Defines 33 | // 34 | // =========================================================================== 35 | 36 | 37 | 38 | 39 | // =========================================================================== 40 | // 41 | // Variables 42 | // 43 | // =========================================================================== 44 | 45 | 46 | 47 | // =========================================================================== 48 | // 49 | // Local Functions prototypes 50 | // 51 | // =========================================================================== 52 | 53 | 54 | 55 | 56 | // =========================================================================== 57 | // 58 | // Functions implementations 59 | // 60 | // =========================================================================== 61 | 62 | // ==================================================================== // 63 | // Function: MACC // 64 | // Description: 32i x 32i -> 64i Multiply-Accumulate // 65 | // ==================================================================== // 66 | void MACC(__int64* plAcc, int ix, int iy) 67 | { 68 | *plAcc += (__int64)ix * (__int64)iy; 69 | } 70 | 71 | 72 | // ==================================================================== // 73 | // Function: LATS30 // 74 | // Description: Saturate 64i to 2^62-1, -2^62 // 75 | // ==================================================================== // 76 | #define MAX_VAL64 (__int64)0x3FFFFFFFFFFFFFFF 77 | #define MIN_VAL64 (__int64)0xC000000000000000 78 | void LSAT30(__int64 *plx) 79 | { 80 | if(*plx > MAX_VAL64) 81 | *plx = MAX_VAL64; 82 | if(*plx < MIN_VAL64) 83 | *plx = MIN_VAL64; 84 | } 85 | 86 | 87 | // ==================================================================== // 88 | // Function: EXT30 // 89 | // Description: Extracts bits [62-31] into 32i // 90 | // ==================================================================== // 91 | void EXT30(int *pr, __int64 lx) 92 | { 93 | *pr = (int)(lx>>31); 94 | } 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /tests/sim_tests/ssrc_test/src/model/IntArithmetic.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: IntArithmetic.h 7 | // 8 | // Integer arithmetic definition file for the SSRC 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _INT_ARITHMETIC_H_ 17 | #define _INT_ARITHMETIC_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | 25 | 26 | 27 | // =========================================================================== 28 | // 29 | // Variables 30 | // 31 | // =========================================================================== 32 | 33 | 34 | // =========================================================================== 35 | // 36 | // TypeDefs 37 | // 38 | // =========================================================================== 39 | // To avoid C type definitions when including this file from assembler 40 | #ifndef INCLUDE_FROM_ASM 41 | 42 | 43 | // =========================================================================== 44 | // 45 | // Function prototypes 46 | // 47 | // =========================================================================== 48 | 49 | // ==================================================================== // 50 | // Function: MACC // 51 | // Description: 32i x 32i -> 64i Multiply-Accumulate // 52 | // ==================================================================== // 53 | void MACC(__int64* plAcc, int ix, int iy); 54 | 55 | // ==================================================================== // 56 | // Function: LATS30 // 57 | // Description: Saturate 64i to 2^62-1, -2^62 // 58 | // ==================================================================== // 59 | #define MAX_VAL64 (__int64)0x3FFFFFFFFFFFFFFF 60 | #define MIN_VAL64 (__int64)0xC000000000000000 61 | void LSAT30(__int64 *plx); 62 | 63 | // ==================================================================== // 64 | // Function: EXT30 // 65 | // Description: Extracts bits [62-31] into 32i // 66 | // ==================================================================== // 67 | void EXT30(int *pr, __int64 lx); 68 | 69 | #endif // nINCLUDE_FROM_ASM 70 | 71 | #endif // _INT_ARITHMETIC_H_ -------------------------------------------------------------------------------- /tests/sim_tests/ssrc_test/src/model/Main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | // =========================================================================== 4 | // =========================================================================== 5 | // 6 | // File: Main.h 7 | // 8 | // Main definition file for the SSRC demonstration program 9 | // 10 | // Target: MS Windows 11 | // Version: 1.0 12 | // 13 | // =========================================================================== 14 | // =========================================================================== 15 | 16 | #ifndef _MAIN_H_ 17 | #define _MAIN_H_ 18 | 19 | // =========================================================================== 20 | // 21 | // Defines 22 | // 23 | // =========================================================================== 24 | #define APPLICATION "SSRC_demo" 25 | #define VERSION "Version 1.0" 26 | #define COPYRIGHT "(c) Digimath, 2015" 27 | #define FATAL 0 28 | #define WARNING 1 29 | 30 | 31 | 32 | // =========================================================================== 33 | // 34 | // Function prototypes 35 | // 36 | // =========================================================================== 37 | void ParseCmdLine(char *input); 38 | void ShowHelp(); 39 | void ShowUsage(); 40 | void HandleError(char *pzErrorMessage, short sErrorType); 41 | 42 | #endif // _MAIN_H_ -------------------------------------------------------------------------------- /tests/sim_tests/test_hifi_ff3.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 XMOS LIMITED. 2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | """ 5 | Test verify the operation of both SSRC and ASRC (which belong to the multi-rate HiFi SRC collection) 6 | """ 7 | 8 | import pytest 9 | from utils.src_test_utils import gen_golden, run_dut, build_firmware_xcommon_cmake, build_host_app_xcommon_cmake 10 | from pathlib import Path 11 | 12 | NUM_SAMPLES_TO_PROCESS = 256 13 | 14 | @pytest.mark.prepare 15 | @pytest.mark.parametrize("src_type", ["ds3", "os3"]) 16 | def test_prepare(src_type): 17 | """ Builds firmware and host reference and generates the golden reference signals on the host """ 18 | host_app = build_host_app_xcommon_cmake(Path(__file__).parent / f"{src_type}_test") 19 | build_firmware_xcommon_cmake(Path(__file__).parent / f"{src_type}_test") 20 | sr_in = 16000 if src_type == "os3" else 48000 21 | sr_out = 48000 if src_type == "os3" else 16000 22 | gen_golden(host_app, src_type, NUM_SAMPLES_TO_PROCESS, [sr_in], [sr_out], None) 23 | 24 | 25 | @pytest.mark.main 26 | @pytest.mark.parametrize("src_type", ["ds3", "os3"]) 27 | def test_hifi_ff3(src_type): 28 | """ Runs the signal through the simulator via an xcore test app and compares to golden ref """ 29 | file_path = Path(__file__).parent 30 | xe = file_path / f"{src_type}_test" / "bin" / f"{src_type}_test.xe" 31 | sr_in = 16000 if src_type == "os3" else 48000 32 | sr_out = 48000 if src_type == "os3" else 16000 33 | run_dut(xe, sr_in, sr_out, src_type, NUM_SAMPLES_TO_PROCESS) 34 | -------------------------------------------------------------------------------- /tests/sim_tests/test_mrhf.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016-2024 XMOS LIMITED. 2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | """ 5 | Test verify the operation of both SSRC and ASRC (which belong to the multi-rate HiFi SRC collection) 6 | """ 7 | 8 | import pytest 9 | from utils.src_test_utils import gen_golden, run_dut, build_firmware_xcommon_cmake, build_host_app_xcommon_cmake 10 | from pathlib import Path 11 | 12 | 13 | NUM_SAMPLES_TO_PROCESS = 256 14 | SR_LIST = (44100, 48000, 88200, 96000, 176400, 192000) 15 | ASRC_DEVIATIONS = ("1.000000", "0.990099", "1.009999") 16 | 17 | 18 | @pytest.mark.prepare 19 | @pytest.mark.parametrize("src_type", ["ssrc", "asrc"]) 20 | def test_prepare(src_type): 21 | """ Builds firmware and host reference and generates the golden reference signals on the host """ 22 | host_app = build_host_app_xcommon_cmake(Path(__file__).parent / f"{src_type}_test") 23 | build_firmware_xcommon_cmake(Path(__file__).parent / f"{src_type}_test") 24 | gen_golden(host_app, src_type, NUM_SAMPLES_TO_PROCESS, SR_LIST, SR_LIST, ASRC_DEVIATIONS if src_type == "asrc" else None) 25 | 26 | 27 | @pytest.mark.main 28 | @pytest.mark.parametrize("sr_out", SR_LIST) 29 | @pytest.mark.parametrize("sr_in", SR_LIST) 30 | def test_ssrc(sr_in, sr_out): 31 | """ Runs the signal through the simulator via an xcore test app and compares to golden ref """ 32 | file_path = Path(__file__).parent 33 | xe = file_path / "ssrc_test" / "bin" / "ssrc_test.xe" 34 | run_dut(xe, sr_in, sr_out, "ssrc", NUM_SAMPLES_TO_PROCESS, compare_mode='abs_diff') 35 | 36 | 37 | @pytest.mark.main 38 | @pytest.mark.parametrize("sr_out", SR_LIST) 39 | @pytest.mark.parametrize("sr_in", SR_LIST) 40 | @pytest.mark.parametrize("fs_deviation", ASRC_DEVIATIONS) 41 | def test_asrc(sr_in, sr_out, fs_deviation): 42 | """ Runs the signal through the simulator via an xcore test app and compares to golden ref """ 43 | file_path = Path(__file__).parent 44 | xe = file_path / "asrc_test" / "bin" / "asrc_test.xe" 45 | run_dut(xe, sr_in, sr_out, "asrc", NUM_SAMPLES_TO_PROCESS, fs_deviation=fs_deviation, compare_mode='abs_diff') 46 | -------------------------------------------------------------------------------- /tests/sim_tests/test_voice_ff3_xs2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 XMOS LIMITED. 2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | """ 5 | Wrapper to run the legacy ff3 voice tests so we get a nice test report in Jenkins 6 | """ 7 | 8 | import pytest 9 | import subprocess 10 | from pathlib import Path 11 | from utils.src_test_utils import build_firmware_xcommon_cmake 12 | 13 | @pytest.mark.prepare 14 | @pytest.mark.parametrize("testname", ["ds3_voice_test", "us3_voice_test", "unity_gain_voice_test"]) 15 | def test_prepare(testname): 16 | """ Build firmware """ 17 | build_firmware_xcommon_cmake(Path(__file__).parent / testname) 18 | 19 | 20 | @pytest.mark.main 21 | @pytest.mark.parametrize("voice_test", ["ds3_voice_test", "us3_voice_test", "unity_gain_voice_test"]) 22 | @pytest.mark.parametrize("arch", ["xs2"]) 23 | def test_voice_ff3_xs2(voice_test, arch): 24 | """ Runs the signal through the simulator via an xcore test app and compares to golden ref """ 25 | 26 | file_dir = Path(__file__).parent 27 | xe = file_dir / voice_test / "bin" / arch / f"{voice_test}_{arch}.xe" 28 | cmd = f"xsim {xe}" 29 | 30 | print(f"Running: {cmd}") 31 | output = subprocess.run(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) 32 | print(output.stdout) 33 | assert output.returncode == 0 34 | -------------------------------------------------------------------------------- /tests/sim_tests/unity_gain_voice_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | set(APP_PCA_ENABLE ON) 6 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 7 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 8 | set(APP_INCLUDES src) 9 | 10 | set(ARCH xs2 xs3) 11 | 12 | foreach(arch ${ARCH}) 13 | if(arch STREQUAL "xs3") 14 | set(target "XK-EVK-XU316") 15 | elseif(arch STREQUAL "xs2") 16 | set(target "XCORE-200-EXPLORER") 17 | endif() 18 | project(unity_gain_voice_test) 19 | set(APP_HW_TARGET ${target}) 20 | set(APP_COMPILER_FLAGS_${arch} -O3 21 | -g 22 | -report 23 | -mno-dual-issue 24 | ) 25 | XMOS_REGISTER_APP() 26 | unset(APP_COMPILER_FLAGS_${arch}) 27 | endforeach() 28 | endif() 29 | -------------------------------------------------------------------------------- /tests/sim_tests/unity_gain_voice_test/src/app_unity_gain_voice.xc: -------------------------------------------------------------------------------- 1 | // Copyright 2017-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include /* abs */ 9 | #include /* log10 */ 10 | 11 | #define debug_printf printf 12 | 13 | #include "src.h" 14 | 15 | #define MAX_DIFF_DB (-20) 16 | #define NUM_OF_TAPS (SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE) 17 | #define NUM_OF_SAMPLES (NUM_OF_TAPS + 1) 18 | #define MIN_VALUE (1000000) 19 | #define NUM_OF_TESTS (32) 20 | 21 | void process_results(int32_t in_val, int32_t out_val, int is_upsampling) { 22 | // calculate the attenuation in dB 23 | float atten = fabs(in_val) / fabs(out_val); 24 | float atten_db = 20 * log10 (atten); 25 | debug_printf("\nDC Attenuation: %f dB\n", atten_db); 26 | atten_db = 0; // added this line to avoid warning about unused variable when DEBUG_PRINT is set to 0 27 | 28 | // calculate the difference in dB 29 | float diff = fabs(in_val - out_val) / fabs(in_val); 30 | float diff_db = 20 * log10 (diff); 31 | debug_printf("Difference: %f dB\n", diff_db); 32 | char* sampling_str = "downsampling"; 33 | if (is_upsampling) { 34 | sampling_str = "upsampling"; 35 | } 36 | // evaluate the difference 37 | if (diff_db>MAX_DIFF_DB){ 38 | printf("Error: the difference for %s is %f dB, max value is %d dB\n", sampling_str, diff_db, MAX_DIFF_DB); 39 | exit(1); 40 | } 41 | } 42 | 43 | int main() 44 | { 45 | int32_t d = INT_MIN; 46 | 47 | for (uint32_t num_tests = 0; num_tests < NUM_OF_TESTS; num_tests++) { 48 | // increment the value the test 49 | d = d + INT_MAX/NUM_OF_TESTS; 50 | 51 | // skip lower valies 52 | if (abs(d) 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define debug_printf printf 10 | 11 | #include "src.h" 12 | 13 | #define NUM_OF_TAPS (SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE) 14 | 15 | static int pseudo_random(unsigned &x) 16 | { 17 | crc32(x, -1, 0xEB31D82E); 18 | return (int)x; 19 | } 20 | // function to clamp a int64 value 21 | int64_t int64_clamp(int64_t val) 22 | { 23 | if (val>INT_MAX) { 24 | val = INT_MAX; 25 | debug_printf("\nWarning: positive overflow\n"); 26 | } 27 | 28 | if (val 0; i--) 52 | { 53 | data_debug[i] = data_debug[i-1]; 54 | } 55 | data_debug[0] = d; 56 | 57 | int64_t sum_debug = 0; 58 | for (unsigned i = 0; i < NUM_OF_TAPS; i++) 59 | { 60 | sum_debug += (int64_t)src_ff3v_fir_coefs_debug[i]*(int64_t)data_debug[i]; 61 | } 62 | sum_debug >>= 31; 63 | sum_debug = (int64_t)(((int64_t)sum_debug * (int64_t)src_ff3v_fir_comp_us )>>src_ff3v_fir_comp_q_us); 64 | 65 | // clamp the number if it overflows 66 | sum_debug = int64_clamp(sum_debug); 67 | 68 | if ((int32_t)sample != (int32_t)sum_debug) 69 | { 70 | printf("Error\n"); 71 | return 1; 72 | } 73 | 74 | for(unsigned r = 1; r < SRC_FF3V_FIR_NUM_PHASES; r++) { 75 | int32_t sample = src_us3_voice_get_next_sample(data, src_ff3v_fir_coefs[2-r]); 76 | for (unsigned i = (NUM_OF_TAPS-1); i > 0; i--) 77 | { 78 | data_debug[i] = data_debug[i-1]; 79 | } 80 | data_debug[0] = 0; 81 | 82 | int64_t sum_debug = 0; 83 | for (unsigned i = 0; i < NUM_OF_TAPS; i++) 84 | { 85 | sum_debug += (int64_t)src_ff3v_fir_coefs_debug[i]*(int64_t)data_debug[i]; 86 | } 87 | sum_debug >>= 31; 88 | sum_debug = (int64_t)(((int64_t)sum_debug * (int64_t)src_ff3v_fir_comp_us )>>src_ff3v_fir_comp_q_us); 89 | 90 | 91 | // clamp the number if it overflows 92 | sum_debug = int64_clamp(sum_debug); 93 | 94 | if ((int32_t)sample != (int32_t)sum_debug) 95 | { 96 | printf("Error\n"); 97 | return 1; 98 | } 99 | } 100 | 101 | } 102 | printf("Success\n"); 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /tests/sim_tests/vpu_ff3_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(vpu_ff3_test) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 12 | 13 | set(NUMTAPS 72 96) 14 | set(NUM_PHASES 3) 15 | 16 | foreach(taps ${NUMTAPS}) 17 | math(EXPR taps_per_phase "${taps} / ${NUM_PHASES}" OUTPUT_FORMAT DECIMAL) 18 | set( AUTOGEN_DIR ${CMAKE_CURRENT_LIST_DIR}/src/src.autogen ) 19 | file(RELATIVE_PATH REL_AUTOGEN_DIR ${CMAKE_CURRENT_LIST_DIR} ${AUTOGEN_DIR}) 20 | 21 | set(AUTOGEN_C_FILE ${AUTOGEN_DIR}/test_src_${taps}t_coefs.c) 22 | set(REL_AUTOGEN_C_FILE ${REL_AUTOGEN_DIR}/test_src_${taps}t_coefs.c) 23 | 24 | set(AUTOGEN_H_FILE ${AUTOGEN_DIR}/test_src_${taps}t_coefs.h) 25 | 26 | set(COEF_FILE_GEN_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/../../../python/fixed_factor_vpu_voice/src_ff3_fir_gen.py) 27 | set(COEF_FILE_GEN_ARGS --output_dir ${AUTOGEN_DIR} --gen_c_files --num_taps_per_phase ${taps_per_phase} --num_phases ${NUM_PHASES} --name test_src_${taps}t) 28 | 29 | message(STATUS "args = ${COEF_FILE_GEN_ARGS}") 30 | 31 | add_custom_command( 32 | OUTPUT ${AUTOGEN_C_FILE} 33 | COMMAND python ${COEF_FILE_GEN_SCRIPT} ${COEF_FILE_GEN_ARGS} 34 | DEPENDS ${COEF_FILE_GEN_SCRIPT} 35 | COMMENT "Generate ff3 filter coefficients file" 36 | VERBATIM 37 | ) 38 | 39 | add_custom_target(filter_coef_generation_${taps}t 40 | DEPENDS ${AUTOGEN_C_FILE}) 41 | 42 | 43 | set(APP_COMPILER_FLAGS_${taps}t "-g" 44 | "-O3" 45 | "-mno-dual-issue" 46 | "-DNUM_TAPS=${taps}" 47 | ) 48 | 49 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 50 | 51 | set(APP_XC_SRCS "") 52 | set(APP_C_SRCS src/fileio_app.c ${REL_AUTOGEN_C_FILE}) 53 | set(APP_INCLUDES ${REL_AUTOGEN_DIR}) 54 | 55 | XMOS_REGISTER_APP() 56 | 57 | unset(APP_COMPILER_FLAGS_${taps}t) 58 | 59 | foreach(target ${APP_BUILD_TARGETS}) 60 | add_dependencies(${target} filter_coef_generation_${taps}t) 61 | endforeach() 62 | 63 | endforeach() 64 | endif() 65 | 66 | -------------------------------------------------------------------------------- /tests/sim_tests/vpu_ff3_test/src/fileio_app.c: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "src_poly.h" 9 | #if (NUM_TAPS == 96) 10 | #include "test_src_96t_coefs.h" 11 | #define downsample src_ff3_96t_ds 12 | #define upsample src_ff3_96t_us 13 | #define do_fir fir_s32_32t 14 | #define do_conv conv_s32_32t 15 | #define coefs test_src_96t_coefs 16 | #define NUM_PHASES TEST_SRC_96T_NUM_PHASES 17 | #define NUM_TAPS_PER_PHASE TEST_SRC_96T_TAPS_PER_PHASE 18 | #elif (NUM_TAPS == 72) 19 | #include "test_src_72t_coefs.h" 20 | #define downsample src_ff3_72t_ds 21 | #define upsample src_ff3_72t_us 22 | #define do_fir fir_s32_24t 23 | #define do_conv conv_s32_24t 24 | #define coefs test_src_72t_coefs 25 | #define NUM_PHASES TEST_SRC_72T_NUM_PHASES 26 | #define NUM_TAPS_PER_PHASE TEST_SRC_72T_TAPS_PER_PHASE 27 | #else 28 | #error Number of taps not supported 29 | #endif 30 | 31 | 32 | const char bin_in_48k[70] = "sig_48k.bin\0"; 33 | const char bin_out_16k[70] = "sig_c_16k.bin\0"; 34 | const char bin_out_48k[70] = "sig_c_48k.bin\0"; 35 | 36 | FILE * open_(const char * filename, const char * mode) 37 | { 38 | FILE * fp = fopen(filename, mode); 39 | if(fp == NULL) 40 | { 41 | printf("Error while opening file\n"); 42 | printf("%s\n", filename); 43 | exit(1); 44 | } 45 | return fp; 46 | } 47 | 48 | int main() 49 | { 50 | int32_t ALIGNMENT(8) state_ds[NUM_PHASES][NUM_TAPS_PER_PHASE] = {{0}}; 51 | int32_t ALIGNMENT(8) state_us[NUM_TAPS_PER_PHASE] = {0}; 52 | FILE * in_48k_fp = open_(bin_in_48k, "rb"); 53 | FILE * out_16k_fp = open_(bin_out_16k, "wb"); 54 | FILE * out_48k_fp = open_(bin_out_48k, "wb"); 55 | 56 | fseek(in_48k_fp, 0, SEEK_END); 57 | int in_len = ftell(in_48k_fp) / sizeof(int32_t); 58 | fseek(in_48k_fp, 0, SEEK_SET); 59 | int out_len = in_len / NUM_PHASES; 60 | 61 | for(int i = 0; i < out_len ; i ++) 62 | { 63 | int32_t in_48k[3] = {0}; 64 | int32_t out_16k[1] = {0}; 65 | int32_t out_48k[3] = {0}; 66 | int64_t acc = 0; 67 | 68 | fread(in_48k, sizeof(int32_t), 3, in_48k_fp); 69 | 70 | // Not testing the high-level API for now 71 | //downsample(in_48k, out_16k, coefs, state_ds); 72 | acc += do_fir(state_ds[0], &coefs[0][0], in_48k[0]); 73 | acc += do_fir(state_ds[1], &coefs[1][0], in_48k[1]); 74 | acc += do_fir(state_ds[2], &coefs[2][0], in_48k[2]); 75 | out_16k[0] = (int32_t)acc; 76 | 77 | 78 | fwrite(out_16k, sizeof(int32_t), 1, out_16k_fp); 79 | 80 | // Not testing the high-level API for now 81 | //upsample(out_16k, out_48k, coefs, state_us); 82 | out_48k[0] = do_fir(state_us, &coefs[2][0], out_16k[0]) * 3; 83 | out_48k[1] = do_conv(state_us, &coefs[1][0]) * 3; 84 | out_48k[2] = do_conv(state_us, &coefs[0][0]) * 3; 85 | 86 | fwrite(out_48k, sizeof(int32_t), 3, out_48k_fp); 87 | } 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /tests/sim_tests/vpu_rat_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) 3 | 4 | if(NOT BUILD_NATIVE) 5 | project(vpu_rat_test) 6 | 7 | set(APP_HW_TARGET XK-EVK-XU316) 8 | 9 | set(APP_PCA_ENABLE ON) 10 | 11 | set(APP_COMPILER_FLAGS "-g" 12 | "-O3" 13 | "-mno-dual-issue" 14 | ) 15 | 16 | include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) 17 | 18 | set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../) 19 | 20 | XMOS_REGISTER_APP() 21 | endif() 22 | -------------------------------------------------------------------------------- /tests/sim_tests/vpu_rat_test/src/fileio_app.c: -------------------------------------------------------------------------------- 1 | // Copyright 2023-2024 XMOS LIMITED. 2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "src_poly.h" 9 | #include "src_rat_fir_coefs.h" 10 | 11 | const char bin_in_48k[70] = "sig_48k.bin\0"; 12 | const char bin_out_32k[70] = "sig_c_32k.bin\0"; 13 | const char bin_out_48k[70] = "sig_c_48k.bin\0"; 14 | 15 | FILE * open_(const char * filename, const char * mode) 16 | { 17 | FILE * fp = fopen(filename, mode); 18 | if(fp == NULL) 19 | { 20 | printf("Error while opening file\n"); 21 | printf("%s\n", filename); 22 | exit(1); 23 | } 24 | return fp; 25 | } 26 | 27 | int main() 28 | { 29 | int32_t ALIGNMENT(8) state_ds[SRC_RAT_FIR_TAPS_PER_PHASE_DS] = {0}; 30 | int32_t ALIGNMENT(8) state_us[SRC_RAT_FIR_TAPS_PER_PHASE_US] = {0}; 31 | FILE * in_48k_fp = open_(bin_in_48k, "rb"); 32 | FILE * out_32k_fp = open_(bin_out_32k, "wb"); 33 | FILE * out_48k_fp = open_(bin_out_48k, "wb"); 34 | 35 | fseek(in_48k_fp, 0, SEEK_END); 36 | int in_len = ftell(in_48k_fp) / sizeof(int32_t); 37 | fseek(in_48k_fp, 0, SEEK_SET); 38 | int loop_len = in_len / 3; 39 | 40 | for(size_t i = 0; i < loop_len ; i ++) 41 | { 42 | int32_t in_48k[3] = {0}; 43 | int32_t out_32k[2] = {0}; 44 | int32_t out_48k[3] = {0}; 45 | fread(in_48k, sizeof(int32_t), 3, in_48k_fp); 46 | 47 | src_rat_2_3_96t_ds(in_48k, out_32k, src_rat_fir_ds_coefs, state_ds); 48 | 49 | fwrite(out_32k, sizeof(int32_t), 2, out_32k_fp); 50 | 51 | src_rat_3_2_96t_us(out_32k, out_48k, src_rat_fir_us_coefs, state_us); 52 | 53 | fwrite(out_48k, sizeof(int32_t), 3, out_48k_fp); 54 | } 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /tests/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 XMOS LIMITED. 2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1. 3 | 4 | --------------------------------------------------------------------------------