File size: 4,344 Bytes
b50f2a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// Copyright © 2025 Agora
// This file is part of TEN Framework, an open source project.
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to the "LICENSE" file in the root directory for more information.
//
#ifndef __STFT_H__
#define __STFT_H__

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#define AUP_STFT_MAX_FFTSZ (4096)

// Configuration Parameters, which impacts dynamic memory occupation, can only
// be set during allocation
typedef struct Analyzer_StaticCfg_ {
  int win_len;
  int hop_size;
  int fft_size;
  const float* ana_win_coeff;
} Analyzer_StaticCfg;

// Spectrum are assumed to be generated with time-domain samples in [-32768,
// 32767] WITH LEC blowup protection Note: the input timeSignal has to be in
// 16KHz sampling-rate
typedef struct Analyzer_InputData_ {
  float* input;
  int iLength;
} Analyzer_InputData;

typedef struct Analyzer_OutputData_ {
  float* output;  // externally provided buffe
  int oLength;    // externally provided buffer length
} Analyzer_OutputData;

#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************************

 * AUP_Analyzer_create(...)

 *

 * This function creats a state handler from nothing, which is NOT ready for

 * processing

 *

 * Input:

 *

 * Output:

 *      - stPtr         : buffer to store the returned state handler

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_create(void** stPtr);

/****************************************************************************

 * AUP_Analyzer_destroy(...)

 *

 * destroy PE instance, and releasing all the dynamically allocated memory

 *

 * Input:

 *      - stPtr         : buffer of State Handler, after this method, this

 *                        handler won't be usable anymore

 *

 * Output:

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_destroy(void** stPtr);

/****************************************************************************

 * AUP_Analyzer_memAllocate(...)

 *

 * This function sets Static Config params and does memory allocation

 * operation, will lose the dynamCfg values

 *

 * Input:

 *      - stPtr         : State Handler which was returned by _create

 *      - pCfg          : static configuration parameters

 *

 * Output:

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_memAllocate(void* stPtr, const Analyzer_StaticCfg* pCfg);

/****************************************************************************

 * AUP_Analyzer_init(...)

 *

 * This function resets (initialize) the PE module and gets it prepared for

 * processing

 *

 * Input:

 *      - stPtr         : State Handler which has gone through create and

 *                        memAllocate

 *

 * Output:

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_init(void* stPtr);

/****************************************************************************

 * AUP_Analyzer_getStaticCfg(...)

 *

 * This function get static configuration status from PE module

 *

 * Input:

 *      - stPtr         : State Handler which has gone through create and

 *                        memAllocate

 *

 * Output:

 *      - pCfg          : configuration content

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_getStaticCfg(const void* stPtr, Analyzer_StaticCfg* pCfg);

/****************************************************************************

 * AUP_Analyzer_proc(...)

 *

 * process a single frame

 *

 * Input:

 *      - stPtr         : State Handler which has gone through create and

 *                        memAllocate and reset

 *      - pCtrl         : per-frame variable control parameters

 *      - pIn           : input data stream

 *

 * Output:

 *      - pOut          : output data (mask, highband time-domain gain etc.)

 *

 * Return value         :  0 - Ok

 *                        -1 - Error

 */
int AUP_Analyzer_proc(void* stPtr, const Analyzer_InputData* pIn,

                      Analyzer_OutputData* pOut);

#ifdef __cplusplus
}
#endif
#endif  // __STFT_H__