aboutsummaryrefslogtreecommitdiffstats
path: root/include/libgha.h
blob: 10c56254af2cfabd9cfc4ef912ffb7508f019308 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef LIBGHA_H
#define LIBGHA_h

#define FLOAT float

#include <stddef.h>

typedef struct gha_ctx *gha_ctx_t;

struct gha_info {
	FLOAT frequency;
	FLOAT phase;
	FLOAT magnitude;
};

/*
 * Create context to perform GHA, size is number of samples provided to analyze.
 * Size must be even
 *
 * Returns null in case of fail.
 */
gha_ctx_t gha_create_ctx(size_t size);

/*
 * Free GHA context
 */
void gha_free_ctx(gha_ctx_t ctx);

/*
 * Performs one GHA step for given PCM signal,
 * the result will be writen in to given gha_info structure
 *
 * Complexity: O(n * log(n)),
 * where n is number of samples to anayze
 */
void gha_analyze_one(const FLOAT* pcm, struct gha_info* info, gha_ctx_t ctx);

/*
 * Performs one GHA step and extracts analysed harmonic from given PCM signal
 * the result will be writen in to given gha_info structure
 *
 * Complexity: O(n * log(n)),
 * where n is number of samples to anayze
 */
void gha_extract_one(FLOAT* pcm, struct gha_info* info, gha_ctx_t ctx);

/*
 * Performs k GHA steps and extracts analysed harmonics from given PCM signal.
 *
 * The result will be writen in to given gha_info structures
 * corresponding ammount of memory should be allocated (k * sizeof(struct gha_info))
 *
 * Effectively this function is equivalent of calling gha_extract_one k times
 *
 * Complexity: O(n * log(n) * K),
 * where n is number of samples to anayze, k is number of harmonics to extract
 *
 */
void gha_extract_many_simple(FLOAT* pcm, struct gha_info* info, size_t k, gha_ctx_t ctx);

#endif