-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
218 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(NeFFT VERSION 1.0) | ||
|
||
if(CMAKE_TOOLCHAIN_FILE) | ||
get_filename_component(CMAKE_TOOLCHAIN_FILE_NAME ${CMAKE_TOOLCHAIN_FILE} NAME) | ||
find_file(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE_NAME} PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH) | ||
message(STATUS "CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") | ||
endif() | ||
|
||
|
||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) | ||
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) | ||
set(CMAKE_BUILD_TYPE RELEASE) | ||
set(CMAKE_C_FLAGS "-Wall -O3 -lm") | ||
set(CMAKE_CXX_FLAGS "-Wall -O3 -lm") | ||
|
||
add_subdirectory(src) | ||
|
||
add_executable(test_fft test/test_fft.c) | ||
target_link_libraries(test_fft PUBLIC NeFFT m) |
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
set(FFT_BASE_SRC NE10_fft.c) | ||
|
||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm) | ||
list(APPEND FFT_BASE_SRC | ||
NE10_fft_float32.c | ||
NE10_fft_generic_float32.c | ||
NE10_fft_float32.neon.c | ||
NE10_fft_float32.neonintrinsic.c | ||
) | ||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES aarch64) | ||
list(APPEND FFT_BASE_SRC | ||
NE10_fft_float32.c | ||
NE10_fft_generic_float32.c | ||
NE10_rfft_float32.c | ||
NE10_rfft_float32.neonintrinsic.c | ||
) | ||
else() | ||
list(APPEND FFT_BASE_SRC | ||
NE10_fft_float32.c | ||
NE10_fft_generic_float32.c | ||
) | ||
endif() | ||
|
||
add_library(NeFFT STATIC ${FFT_BASE_SRC}) | ||
|
||
target_include_directories(NeFFT | ||
PUBLIC | ||
${PROJECT_SOURCE_DIR}/include | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,133 @@ | ||
/* | ||
* Name: fft-test.c | ||
* Description: neon fft test | ||
* Author: Ryuk | ||
* Date: 04/05/2021 | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "NE10_dsp.h" | ||
|
||
#if __ARM_NEON | ||
#warning neon | ||
#else | ||
#warning c | ||
#endif | ||
|
||
#define DEBUG (1) | ||
#define WAV (1) | ||
#define FRAME_SIZE (64) | ||
#define INT_16 (32768) | ||
|
||
int main() | ||
{ | ||
char inFileName[512]; | ||
char outFileName[512]; | ||
|
||
short input[FRAME_SIZE]; | ||
short output[FRAME_SIZE]; | ||
|
||
FILE *in; | ||
FILE *out; | ||
|
||
#if WAV | ||
sprintf(inFileName, "%s", "./sample/fft-test.wav"); | ||
sprintf(outFileName, "%s", "./sample/output.wav"); | ||
#else | ||
sprintf(inFileName, "%s", "../sample/fft-test.pcm"); | ||
sprintf(outFileName, "%s", "../sample/output.pcm"); | ||
#endif | ||
|
||
printf("Open %s\n", inFileName); | ||
in = fopen(inFileName, "rb"); | ||
if(in == NULL) | ||
{ | ||
perror("Error: "); | ||
return -1; | ||
} | ||
|
||
printf("Open %s\n", outFileName); | ||
out = fopen(outFileName, "wb"); | ||
if(out == NULL) | ||
{ | ||
perror("Error: "); | ||
return -1; | ||
} | ||
|
||
#if WAV | ||
fread(input, 44, sizeof(short), in); | ||
fwrite(input, 44, sizeof(short), out); | ||
#endif | ||
|
||
int nfft = FRAME_SIZE; | ||
float *inData = (float *)calloc(FRAME_SIZE, sizeof(float)); | ||
float *outData = (float *)calloc(FRAME_SIZE + 2, sizeof(float)); | ||
|
||
ne10_fft_cfg_float32_t cfg; | ||
cfg = ne10_fft_alloc_r2c_float32(nfft); | ||
|
||
while(fread(input, FRAME_SIZE, sizeof(short), in)) | ||
{ | ||
memset(inData, 0, sizeof(inData)); | ||
memset(outData, 0, sizeof(outData)); | ||
|
||
#if DEBUG | ||
printf("Before FFT\n"); | ||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
printf("%d:%d\t", i, input[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
|
||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
inData[i] = (float)(input[i]) / INT_16; | ||
} | ||
|
||
#if __ARM_NEON | ||
ne10_fft_r2c_1d_float32_neon(outData, inData, cfg); | ||
#else | ||
ne10_fft_r2c_1d_float32_c(outData, inData, cfg); | ||
#endif | ||
|
||
#if DEBUG | ||
printf("After FFT\n"); | ||
for(int i=0; i<FRAME_SIZE+2; i++) | ||
{ | ||
printf("%d:%f\t", i, outData[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
|
||
#if __ARM_NEON | ||
ne10_fft_c2r_1d_float32_neon(inData, outData, cfg); | ||
#else | ||
ne10_fft_r2c_1d_float32_c(outData, inData, cfg); | ||
#endif | ||
|
||
#if DEBUG | ||
printf("After IFFT\n"); | ||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
output[i] = (short)(inData[i] * INT_16); | ||
printf("%d:%d\t", i, output[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
fwrite(output, FRAME_SIZE, sizeof(short), out); | ||
} | ||
|
||
free(inData); | ||
free(outData); | ||
ne10_fft_destroy_r2c_float32(cfg); | ||
|
||
fclose(in); | ||
fclose(out); | ||
|
||
printf("Program Finished\n"); | ||
return 0; | ||
} | ||
/* | ||
* Name: fft-test.c | ||
* Description: neon fft test | ||
* Author: Ryuk | ||
* Date: 04/05/2021 | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "NE10_dsp.h" | ||
|
||
#if __ARM_NEON | ||
#warning neon | ||
#else | ||
#warning c | ||
#endif | ||
|
||
#define DEBUG (1) | ||
#define WAV (1) | ||
#define FRAME_SIZE (64) | ||
#define INT_16 (32768) | ||
|
||
int main() | ||
{ | ||
char inFileName[512]; | ||
char outFileName[512]; | ||
|
||
short input[FRAME_SIZE]; | ||
short output[FRAME_SIZE]; | ||
|
||
FILE *in; | ||
FILE *out; | ||
|
||
#if WAV | ||
sprintf(inFileName, "%s", "./sample/fft-test.wav"); | ||
sprintf(outFileName, "%s", "./sample/output.wav"); | ||
#else | ||
sprintf(inFileName, "%s", "../sample/fft-test.pcm"); | ||
sprintf(outFileName, "%s", "../sample/output.pcm"); | ||
#endif | ||
|
||
printf("Open %s\n", inFileName); | ||
in = fopen(inFileName, "rb"); | ||
if(in == NULL) | ||
{ | ||
perror("Error: "); | ||
return -1; | ||
} | ||
|
||
printf("Open %s\n", outFileName); | ||
out = fopen(outFileName, "wb"); | ||
if(out == NULL) | ||
{ | ||
perror("Error: "); | ||
return -1; | ||
} | ||
|
||
#if WAV | ||
fread(input, 44, sizeof(short), in); | ||
fwrite(input, 44, sizeof(short), out); | ||
#endif | ||
|
||
int nfft = FRAME_SIZE; | ||
float *inData = (float *)calloc(FRAME_SIZE, sizeof(float)); | ||
float *outData = (float *)calloc(FRAME_SIZE + 2, sizeof(float)); | ||
|
||
ne10_fft_cfg_float32_t cfg; | ||
cfg = ne10_fft_alloc_r2c_float32(nfft); | ||
|
||
while(fread(input, FRAME_SIZE, sizeof(short), in)) | ||
{ | ||
memset(inData, 0, sizeof(inData)); | ||
memset(outData, 0, sizeof(outData)); | ||
|
||
#if DEBUG | ||
printf("Before FFT\n"); | ||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
printf("%d:%d\t", i, input[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
|
||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
inData[i] = (float)(input[i]) / INT_16; | ||
} | ||
|
||
#if __ARM_NEON | ||
ne10_fft_r2c_1d_float32_neon(outData, inData, cfg); | ||
#else | ||
ne10_fft_r2c_1d_float32_c(outData, inData, cfg); | ||
#endif | ||
|
||
#if DEBUG | ||
printf("After FFT\n"); | ||
for(int i=0; i<FRAME_SIZE+2; i++) | ||
{ | ||
printf("%d:%f\t", i, outData[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
|
||
#if __ARM_NEON | ||
ne10_fft_c2r_1d_float32_neon(inData, outData, cfg); | ||
#else | ||
ne10_fft_r2c_1d_float32_c(outData, inData, cfg); | ||
#endif | ||
|
||
#if DEBUG | ||
printf("After IFFT\n"); | ||
for(int i=0; i<FRAME_SIZE; i++) | ||
{ | ||
output[i] = (short)(inData[i] * INT_16); | ||
printf("%d:%d\t", i, output[i]); | ||
} | ||
printf("\n"); | ||
#endif | ||
fwrite(output, FRAME_SIZE, sizeof(short), out); | ||
} | ||
|
||
free(inData); | ||
free(outData); | ||
ne10_fft_destroy_r2c_float32(cfg); | ||
|
||
fclose(in); | ||
fclose(out); | ||
|
||
printf("Program Finished\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_PROCESSOR aarch64) | ||
|
||
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") | ||
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") | ||
|
||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
|
||
set(CMAKE_C_FLAGS "-march=armv8-a") | ||
set(CMAKE_CXX_FLAGS "-march=armv8-a") | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nodefaultlibs -fno-builtin -fno-stack-protector -nostdinc++ -lc") | ||
|
||
# cache flags | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") | ||
|
Oops, something went wrong.