aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2018-11-03 00:25:30 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2018-11-03 00:32:39 +0300
commitf91a13ba50ea7645b59eea632f6d0ff541800674 (patch)
tree3e86c8a9df8e1f0beba2192f32daa23361ace680 /src
parentea08660cc9e28a44a1512a5a56f85e7258d9832d (diff)
downloadlibgha-f91a13ba50ea7645b59eea632f6d0ff541800674.tar.gz
Add function to extract analysed harmonic from given pcm
Added dtmf analysation example
Diffstat (limited to 'src')
-rw-r--r--src/gha.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gha.c b/src/gha.c
index e2c0686..b4baca8 100644
--- a/src/gha.c
+++ b/src/gha.c
@@ -202,3 +202,14 @@ void gha_analyze_one(const FLOAT* pcm, struct gha_info* info, gha_ctx* ctx)
gha_generate_sine(ctx->tmp_buf, ctx->size, info->freq, 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)
+{
+ int i;
+ FLOAT magnitude;
+ gha_analyze_one(pcm, info, ctx);
+ magnitude = info->magnitude;
+
+ for (i = 0; i < ctx->size; i++)
+ pcm[i] -= ctx->tmp_buf[i] * magnitude;
+}