andrew@0
|
1 /*
|
andrew@0
|
2 Copyright (C) 2003 Paul Brossier
|
andrew@0
|
3
|
andrew@0
|
4 This program is free software; you can redistribute it and/or modify
|
andrew@0
|
5 it under the terms of the GNU General Public License as published by
|
andrew@0
|
6 the Free Software Foundation; either version 2 of the License, or
|
andrew@0
|
7 (at your option) any later version.
|
andrew@0
|
8
|
andrew@0
|
9 This program is distributed in the hope that it will be useful,
|
andrew@0
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
andrew@0
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
andrew@0
|
12 GNU General Public License for more details.
|
andrew@0
|
13
|
andrew@0
|
14 You should have received a copy of the GNU General Public License
|
andrew@0
|
15 along with this program; if not, write to the Free Software
|
andrew@0
|
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
andrew@0
|
17
|
andrew@0
|
18 */
|
andrew@0
|
19
|
andrew@0
|
20 #ifndef _SAMPLE_H
|
andrew@0
|
21 #define _SAMPLE_H
|
andrew@0
|
22
|
andrew@0
|
23 #ifdef __cplusplus
|
andrew@0
|
24 extern "C" {
|
andrew@0
|
25 #endif
|
andrew@0
|
26
|
andrew@0
|
27 /** \file
|
andrew@0
|
28
|
andrew@0
|
29 Real and complex buffers
|
andrew@0
|
30
|
andrew@0
|
31 This file specifies fvec_t and cvec_t buffers types, which are used
|
andrew@0
|
32 throughout aubio to store real and complex data. Complex values are stored in
|
andrew@0
|
33 terms of phase and norm.
|
andrew@0
|
34
|
andrew@0
|
35 */
|
andrew@0
|
36
|
andrew@0
|
37 /** Sample buffer type */
|
andrew@0
|
38 typedef struct _fvec_t fvec_t;
|
andrew@0
|
39 /** Spectrum buffer type */
|
andrew@0
|
40 typedef struct _cvec_t cvec_t;
|
andrew@0
|
41 /** Buffer for real values */
|
andrew@0
|
42 struct _fvec_t {
|
andrew@0
|
43 ba_uint_t length; /**< length of buffer */
|
andrew@0
|
44 ba_uint_t channels; /**< number of channels */
|
andrew@0
|
45 smpl_t **data; /**< data array of size [length] * [channels] */
|
andrew@0
|
46 };
|
andrew@0
|
47 /** Buffer for complex data */
|
andrew@0
|
48 struct _cvec_t {
|
andrew@0
|
49 ba_uint_t length; /**< length of buffer = (requested length)/2 + 1 */
|
andrew@0
|
50 ba_uint_t channels; /**< number of channels */
|
andrew@0
|
51 smpl_t **norm; /**< norm array of size [length] * [channels] */
|
andrew@0
|
52 smpl_t **phas; /**< phase array of size [length] * [channels] */
|
andrew@0
|
53 };
|
andrew@0
|
54 /** fvec_t buffer creation function
|
andrew@0
|
55
|
andrew@0
|
56 \param length the length of the buffer to create
|
andrew@0
|
57 \param channels the number of channels in the buffer
|
andrew@0
|
58
|
andrew@0
|
59 */
|
andrew@0
|
60 fvec_t * new_fvec(ba_uint_t length, ba_uint_t channels);
|
andrew@0
|
61 /** fvec_t buffer deletion function
|
andrew@0
|
62
|
andrew@0
|
63 \param s buffer to delete as returned by new_fvec()
|
andrew@0
|
64
|
andrew@0
|
65 */
|
andrew@0
|
66 void del_fvec(fvec_t *s);
|
andrew@0
|
67 /** read sample value in a buffer
|
andrew@0
|
68
|
andrew@0
|
69 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
70 result can be obtained using vec->data[channel][position]. Its purpose is to
|
andrew@0
|
71 access these values from wrappers, as created by swig.
|
andrew@0
|
72
|
andrew@0
|
73 \param s vector to read from
|
andrew@0
|
74 \param channel channel to read from
|
andrew@0
|
75 \param position sample position to read from
|
andrew@0
|
76
|
andrew@0
|
77 */
|
andrew@0
|
78 smpl_t fvec_read_sample(fvec_t *s, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
79 /** write sample value in a buffer
|
andrew@0
|
80
|
andrew@0
|
81 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
82 result can be obtained by assigning vec->data[channel][position]. Its purpose
|
andrew@0
|
83 is to access these values from wrappers, as created by swig.
|
andrew@0
|
84
|
andrew@0
|
85 \param s vector to write to
|
andrew@0
|
86 \param data value to write in s->data[channel][position]
|
andrew@0
|
87 \param channel channel to write to
|
andrew@0
|
88 \param position sample position to write to
|
andrew@0
|
89
|
andrew@0
|
90 */
|
andrew@0
|
91 void fvec_write_sample(fvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
92 /** read channel vector from a buffer
|
andrew@0
|
93
|
andrew@0
|
94 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
95 result can be obtained with vec->data[channel]. Its purpose is to access
|
andrew@0
|
96 these values from wrappers, as created by swig.
|
andrew@0
|
97
|
andrew@0
|
98 \param s vector to read from
|
andrew@0
|
99 \param channel channel to read from
|
andrew@0
|
100
|
andrew@0
|
101 */
|
andrew@0
|
102 smpl_t * fvec_get_channel(fvec_t *s, ba_uint_t channel);
|
andrew@0
|
103 /** write channel vector into a buffer
|
andrew@0
|
104
|
andrew@0
|
105 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
106 result can be obtained by assigning vec->data[channel]. Its purpose is to
|
andrew@0
|
107 access these values from wrappers, as created by swig.
|
andrew@0
|
108
|
andrew@0
|
109 \param s vector to write to
|
andrew@0
|
110 \param data vector of [length] values to write
|
andrew@0
|
111 \param channel channel to write to
|
andrew@0
|
112
|
andrew@0
|
113 */
|
andrew@0
|
114 void fvec_put_channel(fvec_t *s, smpl_t * data, ba_uint_t channel);
|
andrew@0
|
115 /** read data from a buffer
|
andrew@0
|
116
|
andrew@0
|
117 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
118 result can be obtained with vec->data. Its purpose is to access these values
|
andrew@0
|
119 from wrappers, as created by swig.
|
andrew@0
|
120
|
andrew@0
|
121 \param s vector to read from
|
andrew@0
|
122
|
andrew@0
|
123 */
|
andrew@0
|
124 smpl_t ** fvec_get_data(fvec_t *s);
|
andrew@0
|
125
|
andrew@0
|
126 /** cvec_t buffer creation function
|
andrew@0
|
127
|
andrew@0
|
128 This function creates a cvec_t structure holding two arrays of size
|
andrew@0
|
129 [length/2+1] * channels, corresponding to the norm and phase values of the
|
andrew@0
|
130 spectral frame. The length stored in the structure is the actual size of both
|
andrew@0
|
131 arrays, not the length of the complex and symetrical vector, specified as
|
andrew@0
|
132 creation argument.
|
andrew@0
|
133
|
andrew@0
|
134 \param length the length of the buffer to create
|
andrew@0
|
135 \param channels the number of channels in the buffer
|
andrew@0
|
136
|
andrew@0
|
137 */
|
andrew@0
|
138 cvec_t * new_cvec(ba_uint_t length, ba_uint_t channels);
|
andrew@0
|
139 /** cvec_t buffer deletion function
|
andrew@0
|
140
|
andrew@0
|
141 \param s buffer to delete as returned by new_cvec()
|
andrew@0
|
142
|
andrew@0
|
143 */
|
andrew@0
|
144 void del_cvec(cvec_t *s);
|
andrew@0
|
145 /** write norm value in a complex buffer
|
andrew@0
|
146
|
andrew@0
|
147 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
148 result can be obtained by assigning vec->norm[channel][position]. Its purpose
|
andrew@0
|
149 is to access these values from wrappers, as created by swig.
|
andrew@0
|
150
|
andrew@0
|
151 \param s vector to write to
|
andrew@0
|
152 \param data norm value to write in s->norm[channel][position]
|
andrew@0
|
153 \param channel channel to write to
|
andrew@0
|
154 \param position sample position to write to
|
andrew@0
|
155
|
andrew@0
|
156 */
|
andrew@0
|
157 void cvec_write_norm(cvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
158 /** write phase value in a complex buffer
|
andrew@0
|
159
|
andrew@0
|
160 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
161 result can be obtained by assigning vec->phas[channel][position]. Its purpose
|
andrew@0
|
162 is to access these values from wrappers, as created by swig.
|
andrew@0
|
163
|
andrew@0
|
164 \param s vector to write to
|
andrew@0
|
165 \param data phase value to write in s->phas[channel][position]
|
andrew@0
|
166 \param channel channel to write to
|
andrew@0
|
167 \param position sample position to write to
|
andrew@0
|
168
|
andrew@0
|
169 */
|
andrew@0
|
170 void cvec_write_phas(cvec_t *s, smpl_t data, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
171 /** read norm value from a complex buffer
|
andrew@0
|
172
|
andrew@0
|
173 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
174 result can be obtained with vec->norm[channel][position]. Its purpose is to
|
andrew@0
|
175 access these values from wrappers, as created by swig.
|
andrew@0
|
176
|
andrew@0
|
177 \param s vector to read from
|
andrew@0
|
178 \param channel channel to read from
|
andrew@0
|
179 \param position sample position to read from
|
andrew@0
|
180
|
andrew@0
|
181 */
|
andrew@0
|
182 smpl_t cvec_read_norm(cvec_t *s, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
183 /** read phase value from a complex buffer
|
andrew@0
|
184
|
andrew@0
|
185 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
186 result can be obtained with vec->phas[channel][position]. Its purpose is to
|
andrew@0
|
187 access these values from wrappers, as created by swig.
|
andrew@0
|
188
|
andrew@0
|
189 \param s vector to read from
|
andrew@0
|
190 \param channel channel to read from
|
andrew@0
|
191 \param position sample position to read from
|
andrew@0
|
192
|
andrew@0
|
193 */
|
andrew@0
|
194 smpl_t cvec_read_phas(cvec_t *s, ba_uint_t channel, ba_uint_t position);
|
andrew@0
|
195 /** write norm channel in a complex buffer
|
andrew@0
|
196
|
andrew@0
|
197 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
198 result can be obtained by assigning vec->norm[channel]. Its purpose is to
|
andrew@0
|
199 access these values from wrappers, as created by swig.
|
andrew@0
|
200
|
andrew@0
|
201 \param s vector to write to
|
andrew@0
|
202 \param data norm vector of [length] samples to write in s->norm[channel]
|
andrew@0
|
203 \param channel channel to write to
|
andrew@0
|
204
|
andrew@0
|
205 */
|
andrew@0
|
206 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, ba_uint_t channel);
|
andrew@0
|
207 /** write phase channel in a complex buffer
|
andrew@0
|
208
|
andrew@0
|
209 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
210 result can be obtained by assigning vec->phas[channel]. Its purpose is to
|
andrew@0
|
211 access these values from wrappers, as created by swig.
|
andrew@0
|
212
|
andrew@0
|
213 \param s vector to write to
|
andrew@0
|
214 \param data phase vector of [length] samples to write in s->phas[channel]
|
andrew@0
|
215 \param channel channel to write to
|
andrew@0
|
216
|
andrew@0
|
217 */
|
andrew@0
|
218 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, ba_uint_t channel);
|
andrew@0
|
219 /** read norm channel from a complex buffer
|
andrew@0
|
220
|
andrew@0
|
221 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
222 result can be obtained with vec->norm[channel]. Its purpose is to access
|
andrew@0
|
223 these values from wrappers, as created by swig.
|
andrew@0
|
224
|
andrew@0
|
225 \param s vector to read from
|
andrew@0
|
226 \param channel channel to read from
|
andrew@0
|
227
|
andrew@0
|
228 */
|
andrew@0
|
229 smpl_t * cvec_get_norm_channel(cvec_t *s, ba_uint_t channel);
|
andrew@0
|
230 /** write phase channel in a complex buffer
|
andrew@0
|
231
|
andrew@0
|
232 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
233 result can be obtained with vec->phas[channel]. Its purpose is to access
|
andrew@0
|
234 these values from wrappers, as created by swig.
|
andrew@0
|
235
|
andrew@0
|
236 \param s vector to read from
|
andrew@0
|
237 \param channel channel to read from
|
andrew@0
|
238
|
andrew@0
|
239 */
|
andrew@0
|
240 smpl_t * cvec_get_phas_channel(cvec_t *s, ba_uint_t channel);
|
andrew@0
|
241 /** read norm data from a complex buffer
|
andrew@0
|
242
|
andrew@0
|
243 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
244 result can be obtained with vec->norm. Its purpose is to access these values
|
andrew@0
|
245 from wrappers, as created by swig.
|
andrew@0
|
246
|
andrew@0
|
247 \param s vector to read from
|
andrew@0
|
248
|
andrew@0
|
249 */
|
andrew@0
|
250 smpl_t ** cvec_get_norm(cvec_t *s);
|
andrew@0
|
251 /** read phase data from a complex buffer
|
andrew@0
|
252
|
andrew@0
|
253 Note that this function is not used in the aubio library, since the same
|
andrew@0
|
254 result can be obtained with vec->phas. Its purpose is to access these values
|
andrew@0
|
255 from wrappers, as created by swig.
|
andrew@0
|
256
|
andrew@0
|
257 \param s vector to read from
|
andrew@0
|
258
|
andrew@0
|
259 */
|
andrew@0
|
260 smpl_t ** cvec_get_phas(cvec_t *s);
|
andrew@0
|
261
|
andrew@0
|
262 #ifdef __cplusplus
|
andrew@0
|
263 }
|
andrew@0
|
264 #endif
|
andrew@0
|
265
|
andrew@0
|
266 #endif /* _SAMPLE_H */
|