aboutsummaryrefslogtreecommitdiffstats
path: root/src/gha.c
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2018-11-03 21:17:03 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2018-11-03 21:17:03 +0300
commitd8502a297b556cb06bf59bd00b2524931a8f034a (patch)
treed2633c73f96b0e05f0dcc246d4465cee35aa4a43 /src/gha.c
parentf054da2e4b4138c987c0b4f760b16c092664cb98 (diff)
downloadlibgha-d8502a297b556cb06bf59bd00b2524931a8f034a.tar.gz
A bit more clean api
Diffstat (limited to 'src/gha.c')
-rw-r--r--src/gha.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gha.c b/src/gha.c
index b4baca8..39812ea 100644
--- a/src/gha.c
+++ b/src/gha.c
@@ -17,7 +17,7 @@ struct gha_ctx {
FLOAT* tmp_buf;
};
-static void gha_init_window(gha_ctx* ctx)
+static void gha_init_window(gha_ctx_t ctx)
{
size_t i;
size_t n = ctx->size + 1;
@@ -26,9 +26,9 @@ static void gha_init_window(gha_ctx* ctx)
}
}
-gha_ctx* gha_create_ctx(size_t size)
+gha_ctx_t gha_create_ctx(size_t size)
{
- gha_ctx* ctx = malloc(sizeof(struct gha_ctx));
+ gha_ctx_t ctx = malloc(sizeof(struct gha_ctx));
if (!ctx)
return NULL;
@@ -70,7 +70,7 @@ exit_free_gha_ctx:
return NULL;
}
-void gha_free_ctx(gha_ctx* ctx)
+void gha_free_ctx(gha_ctx_t ctx)
{
free(ctx->fft_out);
free(ctx->tmp_buf);
@@ -80,7 +80,7 @@ void gha_free_ctx(gha_ctx* ctx)
free(ctx);
}
-static size_t gha_estimate_bin(gha_ctx* ctx)
+static size_t gha_estimate_bin(gha_ctx_t ctx)
{
size_t i, end;
size_t j = 0;
@@ -156,7 +156,7 @@ static void gha_search_omega_newton(const FLOAT* pcm, size_t bin, size_t size, s
// Last iteration
if (loop == MAX_LOOPS) {
- result->freq = omega_rad;
+ result->frequency = omega_rad;
//assume zero-phase sine
result->phase = M_PI / 2 - atan(Xi / Xr);
if (Xr < 0)
@@ -186,7 +186,7 @@ static void gha_estimate_magnitude(const FLOAT* pcm, const FLOAT* regen, size_t
result->magnitude = t1 / t2;
}
-void gha_analyze_one(const FLOAT* pcm, struct gha_info* info, gha_ctx* ctx)
+void gha_analyze_one(const FLOAT* pcm, struct gha_info* info, gha_ctx_t ctx)
{
int i = 0;
int bin = 0;
@@ -199,11 +199,11 @@ void gha_analyze_one(const FLOAT* pcm, struct gha_info* info, gha_ctx* ctx)
bin = gha_estimate_bin(ctx);
gha_search_omega_newton(ctx->tmp_buf, bin, ctx->size, info);
- gha_generate_sine(ctx->tmp_buf, ctx->size, info->freq, info->phase);
+ gha_generate_sine(ctx->tmp_buf, ctx->size, info->frequency, info->phase);
gha_estimate_magnitude(pcm, ctx->tmp_buf, ctx->size, info);
}
-void gha_extract_one(FLOAT* pcm, struct gha_info* info, gha_ctx* ctx)
+void gha_extract_one(FLOAT* pcm, struct gha_info* info, gha_ctx_t ctx)
{
int i;
FLOAT magnitude;