2 Copyright (C) 2003-2007 Paul Brossier <piem@piem.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 This file specifies the cvec_t buffer type, which is used throughout aubio to
32 store complex data. Complex values are stored in terms of phase and
33 norm, within size/2+1 long vectors.
37 /** Spectrum buffer type */
38 typedef struct _cvec_t cvec_t;
39 /** Buffer for complex data */
41 uint_t length; /**< length of buffer = (requested length)/2 + 1 */
42 uint_t channels; /**< number of channels */
43 smpl_t **norm; /**< norm array of size [length] * [channels] */
44 smpl_t **phas; /**< phase array of size [length] * [channels] */
47 /** cvec_t buffer creation function
49 This function creates a cvec_t structure holding two arrays of size
50 [length/2+1] * channels, corresponding to the norm and phase values of the
51 spectral frame. The length stored in the structure is the actual size of both
52 arrays, not the length of the complex and symetrical vector, specified as
55 \param length the length of the buffer to create
56 \param channels the number of channels in the buffer
59 cvec_t * new_cvec(uint_t length, uint_t channels);
60 /** cvec_t buffer deletion function
62 \param s buffer to delete as returned by new_cvec()
65 void del_cvec(cvec_t *s);
66 /** write norm value in a complex buffer
68 Note that this function is not used in the aubio library, since the same
69 result can be obtained by assigning vec->norm[channel][position]. Its purpose
70 is to access these values from wrappers, as created by swig.
72 \param s vector to write to
73 \param data norm value to write in s->norm[channel][position]
74 \param channel channel to write to
75 \param position sample position to write to
78 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
79 /** write phase value in a complex buffer
81 Note that this function is not used in the aubio library, since the same
82 result can be obtained by assigning vec->phas[channel][position]. Its purpose
83 is to access these values from wrappers, as created by swig.
85 \param s vector to write to
86 \param data phase value to write in s->phas[channel][position]
87 \param channel channel to write to
88 \param position sample position to write to
91 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
92 /** read norm value from a complex buffer
94 Note that this function is not used in the aubio library, since the same
95 result can be obtained with vec->norm[channel][position]. Its purpose is to
96 access these values from wrappers, as created by swig.
98 \param s vector to read from
99 \param channel channel to read from
100 \param position sample position to read from
103 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
104 /** read phase value from a complex buffer
106 Note that this function is not used in the aubio library, since the same
107 result can be obtained with vec->phas[channel][position]. Its purpose is to
108 access these values from wrappers, as created by swig.
110 \param s vector to read from
111 \param channel channel to read from
112 \param position sample position to read from
115 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
116 /** write norm channel in a complex buffer
118 Note that this function is not used in the aubio library, since the same
119 result can be obtained by assigning vec->norm[channel]. Its purpose is to
120 access these values from wrappers, as created by swig.
122 \param s vector to write to
123 \param data norm vector of [length] samples to write in s->norm[channel]
124 \param channel channel to write to
127 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
128 /** write phase channel in a complex buffer
130 Note that this function is not used in the aubio library, since the same
131 result can be obtained by assigning vec->phas[channel]. Its purpose is to
132 access these values from wrappers, as created by swig.
134 \param s vector to write to
135 \param data phase vector of [length] samples to write in s->phas[channel]
136 \param channel channel to write to
139 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
140 /** read norm channel from a complex buffer
142 Note that this function is not used in the aubio library, since the same
143 result can be obtained with vec->norm[channel]. Its purpose is to access
144 these values from wrappers, as created by swig.
146 \param s vector to read from
147 \param channel channel to read from
150 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
151 /** write phase channel in a complex buffer
153 Note that this function is not used in the aubio library, since the same
154 result can be obtained with vec->phas[channel]. Its purpose is to access
155 these values from wrappers, as created by swig.
157 \param s vector to read from
158 \param channel channel to read from
161 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
162 /** read norm data from a complex buffer
164 Note that this function is not used in the aubio library, since the same
165 result can be obtained with vec->norm. Its purpose is to access these values
166 from wrappers, as created by swig.
168 \param s vector to read from
171 smpl_t ** cvec_get_norm(cvec_t *s);
172 /** read phase data from a complex buffer
174 Note that this function is not used in the aubio library, since the same
175 result can be obtained with vec->phas. Its purpose is to access these values
176 from wrappers, as created by swig.
178 \param s vector to read from
181 smpl_t ** cvec_get_phas(cvec_t *s);
183 /** print out cvec data
185 \param s vector to print out
188 void cvec_print(cvec_t *s);