2 Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
4 This file is part of aubio.
6 aubio is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 aubio is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with aubio. If not, see <http://www.gnu.org/licenses/>.
32 This file specifies the cvec_t buffer type, which is used throughout aubio to
33 store complex data. Complex values are stored in terms of phase and
34 norm, within size/2+1 long vectors.
38 /** Buffer for complex data */
40 uint_t length; /**< length of buffer = (requested length)/2 + 1 */
41 uint_t channels; /**< number of channels */
42 smpl_t **norm; /**< norm array of size [length] * [channels] */
43 smpl_t **phas; /**< phase array of size [length] * [channels] */
46 /** cvec_t buffer creation function
48 This function creates a cvec_t structure holding two arrays of size
49 [length/2+1] * channels, corresponding to the norm and phase values of the
50 spectral frame. The length stored in the structure is the actual size of both
51 arrays, not the length of the complex and symetrical vector, specified as
54 \param length the length of the buffer to create
55 \param channels the number of channels in the buffer
58 cvec_t * new_cvec(uint_t length, uint_t channels);
59 /** cvec_t buffer deletion function
61 \param s buffer to delete as returned by new_cvec()
64 void del_cvec(cvec_t *s);
65 /** write norm value in a complex buffer
67 Note that this function is not used in the aubio library, since the same
68 result can be obtained by assigning vec->norm[channel][position]. Its purpose
69 is to access these values from wrappers, as created by swig.
71 \param s vector to write to
72 \param data norm value to write in s->norm[channel][position]
73 \param channel channel to write to
74 \param position sample position to write to
77 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
78 /** write phase value in a complex buffer
80 Note that this function is not used in the aubio library, since the same
81 result can be obtained by assigning vec->phas[channel][position]. Its purpose
82 is to access these values from wrappers, as created by swig.
84 \param s vector to write to
85 \param data phase value to write in s->phas[channel][position]
86 \param channel channel to write to
87 \param position sample position to write to
90 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
91 /** read norm value from a complex buffer
93 Note that this function is not used in the aubio library, since the same
94 result can be obtained with vec->norm[channel][position]. Its purpose is to
95 access these values from wrappers, as created by swig.
97 \param s vector to read from
98 \param channel channel to read from
99 \param position sample position to read from
102 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
103 /** read phase value from a complex buffer
105 Note that this function is not used in the aubio library, since the same
106 result can be obtained with vec->phas[channel][position]. Its purpose is to
107 access these values from wrappers, as created by swig.
109 \param s vector to read from
110 \param channel channel to read from
111 \param position sample position to read from
114 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
115 /** write norm channel in a complex buffer
117 Note that this function is not used in the aubio library, since the same
118 result can be obtained by assigning vec->norm[channel]. Its purpose is to
119 access these values from wrappers, as created by swig.
121 \param s vector to write to
122 \param data norm vector of [length] samples to write in s->norm[channel]
123 \param channel channel to write to
126 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
127 /** write phase channel in a complex buffer
129 Note that this function is not used in the aubio library, since the same
130 result can be obtained by assigning vec->phas[channel]. Its purpose is to
131 access these values from wrappers, as created by swig.
133 \param s vector to write to
134 \param data phase vector of [length] samples to write in s->phas[channel]
135 \param channel channel to write to
138 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
139 /** read norm channel from a complex buffer
141 Note that this function is not used in the aubio library, since the same
142 result can be obtained with vec->norm[channel]. Its purpose is to access
143 these values from wrappers, as created by swig.
145 \param s vector to read from
146 \param channel channel to read from
149 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
150 /** write phase channel in a complex buffer
152 Note that this function is not used in the aubio library, since the same
153 result can be obtained with vec->phas[channel]. Its purpose is to access
154 these values from wrappers, as created by swig.
156 \param s vector to read from
157 \param channel channel to read from
160 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
161 /** read norm data from a complex buffer
163 Note that this function is not used in the aubio library, since the same
164 result can be obtained with vec->norm. Its purpose is to access these values
165 from wrappers, as created by swig.
167 \param s vector to read from
170 smpl_t ** cvec_get_norm(cvec_t *s);
171 /** read phase data from a complex buffer
173 Note that this function is not used in the aubio library, since the same
174 result can be obtained with vec->phas. Its purpose is to access these values
175 from wrappers, as created by swig.
177 \param s vector to read from
180 smpl_t ** cvec_get_phas(cvec_t *s);
182 /** print out cvec data
184 \param s vector to print out
187 void cvec_print(cvec_t *s);
189 /** set all elements to a given value
191 \param s vector to modify
192 \param val value to set elements to
195 void cvec_set(cvec_t *s, smpl_t val);
197 /** set all elements to zero
199 \param s vector to modify
202 void cvec_zeros(cvec_t *s);
204 /** set all elements to ones
206 \param s vector to modify
209 void cvec_ones(cvec_t *s);