This commit is contained in:
Steven Dan
2025-12-11 09:43:42 +08:00
commit d8b2974133
1822 changed files with 280037 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(app_td_block_fir)
set(APP_HW_TARGET XK-EVK-XU316)
set(APP_DEPENDENT_MODULES
"lib_audio_dsp"
"lib_logging(3.2.0)"
"lib_locks(2.2.0)"
)
set(APP_PCA_ENABLE OFF)
set(EXAMPLE_BUILD_FLAGS ${EXTRA_BUILD_FLAGS} -fcomment-asm
-Wall
-O3
-report
-lquadflash
-mcmodel=large
-g
-fxscope)
set(APP_COMPILER_FLAGS ${EXAMPLE_BUILD_FLAGS})
file(GLOB C_SRC CONFIGURE_DEPENDS RELATIVE ${CMAKE_CURRENT_LIST_DIR} src/*.c)
set(DSP_DIR build/dsp_pipeline)
set(APP_C_SRCS
"${C_SRC};${DSP_MAIN}")
set(APP_INCLUDES
src
src/core
src/extensions
${CMAKE_CURRENT_LIST_DIR}/build/dsp_pipeline)
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
XMOS_REGISTER_APP()

View File

@@ -0,0 +1,27 @@
app_fd_block_fir
---
This demonstrates the usage of a frequency domain FIR. It runs a 4096 tap
bandpass filter with a 256 sample latency. This requires around 3x less
compute than the equivalent block time domain filter, and around 6x less
compute than a single sample implementation (both VPU optimised).
To build the example, first generate the test filter `test_0` by running `make_test_filters.py`:
.. code-block:: console
cd examples/app_fd_block_fir/src
python make_test_filters.py
Then autogenerate the frequency domain filter with a frame advance of 256 samples:
.. code-block:: console
python -m audio_dsp.dsp.fd_block_fir test_0.npy 256
Finally, build the example app:
.. code-block:: console
cd ..
cmake -G "Unix Makefiles" -B build
cmake -C build

View File

@@ -0,0 +1,43 @@
// Copyright 2024-2025 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <xcore/hwtimer.h>
#include "test_0.h"
void foo(){
int32_t __attribute__((aligned (8))) new_data[test_0_TD_BLOCK_LENGTH];
//allocate a TD FIR for the example
int32_t data[test_0_DATA_BUFFER_ELEMENTS];
memset(data, 0, sizeof(data));
fd_fir_data_t fd_fir_data_test_0;
fd_block_fir_data_init(&fd_fir_data_test_0, data,
test_0_FRAME_ADVANCE,
test_0_TD_BLOCK_LENGTH,
test_0_BLOCK_COUNT);
for(int j=0;j<16;j++)
{
for(int i=0;i<test_0_FRAME_ADVANCE;i++)
new_data[i] = rand()-rand();
int32_t __attribute__((aligned (8))) fd_processed[test_0_TD_BLOCK_LENGTH] = {0};
fd_block_fir_add_data(new_data, &fd_fir_data_test_0);
fd_block_fir_compute(
fd_processed,
&fd_fir_data_test_0,
&fd_fir_filter_test_0);
}
}
int main() {
foo();
}

View File

@@ -0,0 +1,13 @@
# Copyright 2024-2025 XMOS LIMITED.
# This Software is subject to the terms of the XMOS Public Licence: Version 1.
import numpy as np
from scipy import signal
def bandpass_filters(length, count):
for i in range(count):
t = signal.firwin(length, (i + 1) / (count + 2))
name = 'test_' + str(i)
np.save(name, t)
if __name__ == '__main__':
bandpass_filters(4096, 1)