aboutsummaryrefslogtreecommitdiff
path: root/arch/all/ensigdsp-sh/include/ensigdsp.h
blob: c24cdfc607422070f5dc9135bf328074b9896532 (plain)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* ****************************************************************************
 * Ensigma DSP library.
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 * ************************************************************************* */
#include <fixed.h>
__BEGIN_DECLS
#ifdef _DSPC

/* ************************************************************************* */
/*  Useful things                                                            */
/* ************************************************************************* */
/* Macros */
# define BIQUAD_SIZE   6 /* no. coefficients in an IIR biquad */
# define EDSP_OK       0
# define EDSP_BAD_ARG  1
# define EDSP_NO_HEAP  2
# define EFFTALLSCALE  (-1L)
# define EFFTMIDSCALE  0x55555555L
# define EFFTNOSCALE   0x00000000L

/* Globals
 * These variables are for the internal use of the FFT functions only.
 * They should not be accessed by user programs. */

extern long max_fft_size;
extern short *twtble;
/* ************************************************************************* */
/*  Fourier transforms                                                       */
/* ************************************************************************* */
/* Complex */
extern int FftComplex _OF((__X __fixed __op_x[], __Y __fixed __op_y[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __size, long __scale)) __THROW;
extern int FftInComplex _OF((__X __fixed __data_x[], __Y __fixed __data_y[],
	long __size, long __scale)) __THROW;

/* Real */
extern int FftReal _OF((__X __fixed __op_x[], __Y __fixed __op_y[],
	const __fixed __ip[],
	long __size, long __scale)) __THROW;
extern int FftInReal _OF((__X __fixed __data_x[], __Y __fixed __data_y[],
	long __size, long __scale, int __ip_all_x)) __THROW;

/* Complex bis? */
extern int IfftComplex _OF((__X __fixed __op_x[], __Y __fixed __op_y[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __size, long __scale)) __THROW;
extern int IfftInComplex _OF((__X __fixed __data_x[], __Y __fixed __data_y[],
	long __size, long __scale)) __THROW;

/* Real bis? */
extern int IfftReal _OF((__X __fixed __op_x[], __Y __fixed __op_y[],
	__X __fixed __ip_x[], __Y __fixed __ip_y[],
	long __size, long __scale, int __op_all_x)) __THROW;
extern int IfftInReal _OF((__X __fixed __data_x[], __Y __fixed __data_y[],
	long __size, long __scale, int __op_all_x)) __THROW;

/* Initialize/deinitialize Fourier transformation? */
extern int  InitFft _OF((long __max_size)) __THROW;
extern void FreeFft _OF((void)) __THROW;

/* ?? */
extern int LogMagnitude _OF((__fixed __output[],
	__X __fixed __ip_x[], __Y __fixed __ip_y[],
	long __no_elements, float __fscale)) __THROW;
/* ************************************************************************* */
/*  Window functions                                                         */
/* ************************************************************************* */
extern int GenBlackman _OF((__fixed __output[], long __win_size)) __THROW;
extern int GenHamming  _OF((__fixed __output[], long __win_size)) __THROW;
extern int GenHanning  _OF((__fixed __output[], long __win_size)) __THROW;
extern int GenTriangle _OF((__fixed __output[], long __win_size)) __THROW;

/* ************************************************************************* */
/*  Filters                                                                  */
/* ************************************************************************* */
/* The coefficients must be supplied in X and the workspace in Y.
 * If it is straightforward we can support the opposite, i.e. Xworkspace
 * and Ycoeff. */

extern int InitFir _OF((__Y __fixed **__workspace, long __no_coeffs)) __THROW;
extern int FreeFir _OF((__Y __fixed **__workspace, long __no_coeffs)) __THROW;

extern int InitIir _OF((__Y __fixed **__workspace, long __no_sections))
	__THROW;
extern int FreeIir _OF((__Y __fixed **__workspace, long __no_sections))
	__THROW;

extern int InitDIir _OF((__Y long __fixed **__workspace, long __no_sections))
	__THROW;
extern int FreeDIir _OF((__Y long __fixed **__workspace, long __no_sections))
	__THROW;

extern int InitLms _OF((__Y __fixed **__workspace, long __no_coeffs)) __THROW;
extern int FreeLms _OF((__Y __fixed **__workspace, long __no_coeffs)) __THROW;

extern int Fir  _OF((__fixed __output[], const __fixed __input[],
	long __no_samples,
	const __X __fixed __coeff[], long __no_coeffs, int __res_shift,
	__Y __fixed *__workspace)) __THROW;
extern int Fir1 _OF((short *__output, short __input,
	const short __coeff[], /* X memory */
	long __no_coeffs, int __res_shift,
	short *__workspace /* Y memory */
	)) __THROW;

extern int Iir  _OF((__fixed __output[], const __fixed __input[],
	long __no_samples, const __X __fixed __coeff[], long __no_sections,
	__Y __fixed *__workspace)) __THROW;
extern int Iir1 _OF((short *__output, short __input,
	const short __coeff[], /* X memory */
	long __no_sections, short *__workspace /* Y memory */
	)) __THROW;

extern int DIir  _OF((__fixed __output[], const __fixed __input[],
	long __no_samples,
	const __X long __fixed __coeff[], long __no_sections,
	__Y long __fixed *__workspace)) __THROW;
extern int DIir1 _OF((short *__output, const short __input,
	const long __coeff[], /* X memory */
	long __no_sections,
	long *__workspace /* Y memory */
	)) __THROW;

extern int Lms  _OF((__fixed __output[], const __fixed __input[],
	const __fixed __ref_output[], long __no_samples,
	__X __fixed __coeff[], long __no_coeffs, int __res_shift,
	short __conv_fact, __Y __fixed *__workspace)) __THROW;
extern int Lms1 _OF((short *__output, short __input, short __ref_output,
	short __coeff[], /* X memory */
	long __no_coeffs, int __res_shift,
	short __conv_fact,
	short *__workspace /* Y memory */
	)) __THROW;
/* ************************************************************************* */
/*  Convolution and Correlation                                              */
/* ************************************************************************* */
extern int ConvComplete _OF((__fixed __output[],
	__X __fixed __ip_x[], __Y __fixed __ip_y[],
	long __x_size, long __y_size, int __res_shift)) __THROW;
extern int ConvCyclic   _OF((__fixed __output[],
	__X __fixed __ip_x[], __Y __fixed __ip_y[],
	long __size, int __res_shift)) __THROW;
extern int ConvPartial  _OF((__fixed __output[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __x_size, long __y_size, int __res_shift)) __THROW;
extern int Correlate    _OF((__fixed __output[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __x_size, long __y_size, long __no_corr,
	int __x_is_larger, int __res_shift)) __THROW;
extern int CorrCyclic   _OF((__fixed __output[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __size, int __reverse, int __res_shift)) __THROW;
/* ************************************************************************* */
/*  Miscallaneous                                                            */
/* ************************************************************************* */
/* Noise? */
extern int GenGWnoise _OF((__fixed __output[], long __no_samples,
	float __variance)) __THROW;

/* Statistical things */
extern int MinI  _OF((__fixed **__min_ptr, __fixed __input[],
	long __no_elements, int __src_is_x)) __THROW;
extern int MaxI  _OF((__fixed **__max_ptr, __fixed __input[],
	long __no_elements, int __src_is_x)) __THROW;
extern int PeakI _OF((__fixed **__peak_ptr, __fixed __input[],
	long __no_elements, int __src_is_x)) __THROW;
extern int Mean  _OF((__fixed *__mean, const __fixed __input[],
	long __no_elements, int __src_is_x)) __THROW;
extern int Variance OF((long __fixed *__variance, __fixed *__mean,
	const __fixed __input[], long __no_elements, int __src_is_x)) __THROW;

/* Vector/matrix operations */
extern int VectorMult _OF((__fixed __output[],
	const __X __fixed __ip_x[], const __Y __fixed __ip_y[],
	long __no_elements, int __res_shift)) __THROW;
extern int MatrixMult _OF((void *__op_matrix,
	const __X void *__ip_x, const __Y void *__ip_y,
	long __m, long __n, long __p, int __x_first, int __res_shift)) __THROW;

/* Power? */
extern int MsPower _OF((long __fixed *__output, const __fixed __input[],
	long __no_elements, int __src_is_x)) __THROW;

/* Limit */
extern int Limit _OF((__fixed __data_xy[], long __no_elements,
	int __data_is_x)) __THROW;

/* Copies */
extern int CopyXtoY _OF((__Y __fixed __op_y[], const __X __fixed __ip_x[],
	long __n)) __THROW;
extern int CopyYtoX _OF((__X __fixed __op_x[], const __Y __fixed __ip_y[],
	long __n));

extern int CopyToX _OF((__X __fixed __op_x[], const __fixed __input[],
	long __n)) __THROW;
extern int CopyToY _OF((__Y __fixed __op_y[], const __fixed __input[],
	long __n)) __THROW;

extern int CopyFromX _OF((__fixed __output[], const __X __fixed __ip_x[],
	long __n)) __THROW;
extern int CopyFromY _OF((__fixed __output[], const __Y __fixed __ip_y[],
	long __n)) __THROW;

#endif
__END_DECLS