aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2024-07-06 10:56:15 +0000
committerDaniil Cherednik <dan.cherednik@gmail.com>2024-07-06 10:56:15 +0000
commit41705edc6d36ad013cbcb171d53891f3c33764d8 (patch)
treec88a75ab8089720d0e354037d0585eb1d51af20a /test
parent311a633f24410ce3302526941b32639aa8869654 (diff)
downloadlibgha-41705edc6d36ad013cbcb171d53891f3c33764d8.tar.gz
Make possible to use double and own fft lib.HEADmaster
Projects which use the library may have own fft librray. Projects may use double precision floating point numbers.
Diffstat (limited to 'test')
-rw-r--r--test/common.h5
-rw-r--r--test/dtmf.c16
-rw-r--r--test/main.c4
3 files changed, 11 insertions, 14 deletions
diff --git a/test/common.h b/test/common.h
index 6757422..f29461d 100644
--- a/test/common.h
+++ b/test/common.h
@@ -1,10 +1,11 @@
+#include <include/libgha.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
-static inline int compare_phase(float a, float b, float delta) {
+static inline int compare_phase(FLOAT a, FLOAT b, FLOAT delta) {
if (fabs(a - b) < delta)
return 0;
a = fmod(a + M_PI, 2 * M_PI);
@@ -15,7 +16,7 @@ static inline int compare_phase(float a, float b, float delta) {
return -1;
}
-static inline int load_file(const char* name, size_t len, size_t offset, size_t bits, float* buf)
+static inline int load_file(const char* name, size_t len, size_t offset, size_t bits, FLOAT* buf)
{
union {
char b[4];
diff --git a/test/dtmf.c b/test/dtmf.c
index ae73a6b..1a9db3f 100644
--- a/test/dtmf.c
+++ b/test/dtmf.c
@@ -1,5 +1,3 @@
-#include <include/libgha.h>
-
#include "common.h"
void usage(const char* selfname) {
@@ -12,11 +10,11 @@ void usage(const char* selfname) {
fprintf(stderr, "EXPECTED_MAGNITUDE_(LOW|HIGH) - expected magnitude (0 - 1)\n");
}
-static void calc_resuidal(float* resuidal, size_t size, void* user_ctx)
+static void calc_resuidal(FLOAT* resuidal, size_t size, void* user_ctx)
{
int i;
double s = 0.0;
- float* result = (float*)user_ctx;
+ FLOAT* result = (FLOAT*)user_ctx;
for (i = 0; i < size; i++) {
s += resuidal[i] * resuidal[i];
}
@@ -33,8 +31,8 @@ int main(int argc, char** argv) {
gha_ctx_t ctx;
- float* buf = malloc(len * sizeof(float));
- float* buf2 = malloc(len * sizeof(float));
+ FLOAT* buf = malloc(len * sizeof(FLOAT));
+ FLOAT* buf2 = malloc(len * sizeof(FLOAT));
if (!buf || !buf2)
abort();
@@ -45,10 +43,10 @@ int main(int argc, char** argv) {
}
//Make copy of data to adjust extracted params
- memcpy(buf2, buf, sizeof(float) * len);
+ memcpy(buf2, buf, sizeof(FLOAT) * len);
ctx = gha_create_ctx(len);
- float resuidal;
+ FLOAT resuidal;
gha_set_user_resuidal_cb(&calc_resuidal, &resuidal, ctx);
if (!ctx) {
fprintf(stderr, "Unable to create gha ctx\n");
@@ -59,7 +57,7 @@ int main(int argc, char** argv) {
struct gha_info res[2];
gha_extract_many_simple(buf, &res[0], 2, ctx);
- float resuidal_1 = resuidal;
+ FLOAT resuidal_1 = resuidal;
if (res[0].frequency > res[1].frequency) {
struct gha_info tmp;
diff --git a/test/main.c b/test/main.c
index c9725f0..6565ce1 100644
--- a/test/main.c
+++ b/test/main.c
@@ -1,5 +1,3 @@
-#include <include/libgha.h>
-
#include "common.h"
void usage(const char* selfname) {
@@ -24,7 +22,7 @@ int main(int argc, char** argv) {
gha_ctx_t ctx;
- float* buf = malloc(len * sizeof(float));
+ FLOAT* buf = malloc(len * sizeof(FLOAT));
if (!buf)
abort();