init
This commit is contained in:
44
lib_audio_dsp/test/utils/src/calc_alpha.c
Normal file
44
lib_audio_dsp/test/utils/src/calc_alpha.c
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/helpers.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
printf("inlen %d", in_len);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0;
|
||||
int32_t samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = calc_alpha(48000.0, samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(int32_t), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
42
lib_audio_dsp/test/utils/src/compressor_ratio.c
Normal file
42
lib_audio_dsp/test/utils/src/compressor_ratio.c
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/helpers.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0, samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = rms_compressor_slope_from_ratio(samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(float), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
43
lib_audio_dsp/test/utils/src/db_gain.c
Normal file
43
lib_audio_dsp/test/utils/src/db_gain.c
Normal 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 <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/signal_chain.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0;
|
||||
int32_t samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = adsp_dB_to_gain(samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(int32_t), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
42
lib_audio_dsp/test/utils/src/expander_ratio.c
Normal file
42
lib_audio_dsp/test/utils/src/expander_ratio.c
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/helpers.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0, samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = peak_expander_slope_from_ratio(samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(float), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
43
lib_audio_dsp/test/utils/src/peak_threshold.c
Normal file
43
lib_audio_dsp/test/utils/src/peak_threshold.c
Normal 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 <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/helpers.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0;
|
||||
int32_t samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = calculate_peak_threshold(samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(int32_t), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
43
lib_audio_dsp/test/utils/src/rms_threshold.c
Normal file
43
lib_audio_dsp/test/utils/src/rms_threshold.c
Normal 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 <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/helpers.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / sizeof(float);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp = 0;
|
||||
int32_t samp_out = 0;
|
||||
fread(&samp, sizeof(float), 1, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = calculate_rms_threshold(samp);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(int32_t), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
lib_audio_dsp/test/utils/src/time_samples.c
Normal file
44
lib_audio_dsp/test/utils/src/time_samples.c
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "control/signal_chain.h"
|
||||
|
||||
FILE * _fopen(char * fname, char* mode) {
|
||||
FILE * fp = fopen(fname, mode);
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("Error opening a file\n");
|
||||
exit(1);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE * in = _fopen("test_vector.bin", "rb");
|
||||
FILE * out = _fopen("out_vector.bin", "wb");
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
int in_len = ftell(in) / (2.0f*sizeof(float));
|
||||
printf("inlen %d", in_len);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
for (unsigned i = 0; i < in_len; i++)
|
||||
{
|
||||
float samp[2] = {0};
|
||||
int32_t samp_out = 0;
|
||||
fread(&samp, sizeof(float), 2, in);
|
||||
//printf("%ld ", samp);
|
||||
samp_out = time_to_samples(48000.0, samp[0], (time_units_t)samp[1]);
|
||||
//printf("%ld ", samp_out);
|
||||
fwrite(&samp_out, sizeof(int32_t), 1, out);
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user