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/>.
30 Vector of complex-valued data
32 This file specifies the ::cvec_t buffer type, which is used throughout aubio
33 to store complex data. Complex values are stored in terms of ::cvec_t.phas
34 and norm, within size/2+1 long vectors of ::smpl_t.
40 /** Buffer for complex data
44 uint_t buffer_size = 1024;
46 // create a complex vector of 512 values
47 cvec_t * input = new_cvec (buffer_size);
49 // set some values of the vector
51 input->phas[23] = M_PI;
54 // compute the mean of the vector
55 mean = cvec_mean(input);
64 uint_t length; /**< length of buffer = (requested length)/2 + 1 */
65 smpl_t *norm; /**< norm array of size ::cvec_t.length */
66 smpl_t *phas; /**< phase array of size ::cvec_t.length */
69 /** cvec_t buffer creation function
71 This function creates a cvec_t structure holding two arrays of size
72 [length/2+1], corresponding to the norm and phase values of the
73 spectral frame. The length stored in the structure is the actual size of both
74 arrays, not the length of the complex and symmetrical vector, specified as
77 \param length the length of the buffer to create
80 cvec_t * new_cvec(uint_t length);
81 /** cvec_t buffer deletion function
83 \param s buffer to delete as returned by new_cvec()
86 void del_cvec(cvec_t *s);
87 /** write norm value in a complex buffer
89 Note that this function is not used in the aubio library, since the same
90 result can be obtained by assigning vec->norm[position]. Its purpose
91 is to access these values from wrappers, as created by swig.
93 \param s vector to write to
94 \param data norm value to write in s->norm[position]
95 \param position sample position to write to
98 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position);
99 /** write phase value in a complex buffer
101 Note that this function is not used in the aubio library, since the same
102 result can be obtained by assigning vec->phas[position]. Its purpose
103 is to access these values from wrappers, as created by swig.
105 \param s vector to write to
106 \param data phase value to write in s->phas[position]
107 \param position sample position to write to
110 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position);
111 /** read norm value from a complex buffer
113 Note that this function is not used in the aubio library, since the same
114 result can be obtained with vec->norm[position]. Its purpose is to
115 access these values from wrappers, as created by swig.
117 \param s vector to read from
118 \param position sample position to read from
121 smpl_t cvec_read_norm(cvec_t *s, uint_t position);
122 /** read phase value from a complex buffer
124 Note that this function is not used in the aubio library, since the same
125 result can be obtained with vec->phas[position]. Its purpose is to
126 access these values from wrappers, as created by swig.
128 \param s vector to read from
129 \param position sample position to read from
132 smpl_t cvec_read_phas(cvec_t *s, uint_t position);
133 /** read norm data from a complex buffer
135 Note that this function is not used in the aubio library, since the same
136 result can be obtained with vec->norm. Its purpose is to access these values
137 from wrappers, as created by swig.
139 \param s vector to read from
142 smpl_t * cvec_get_norm(cvec_t *s);
143 /** read phase data from a complex buffer
145 Note that this function is not used in the aubio library, since the same
146 result can be obtained with vec->phas. Its purpose is to access these values
147 from wrappers, as created by swig.
149 \param s vector to read from
152 smpl_t * cvec_get_phas(cvec_t *s);
154 /** print out cvec data
156 \param s vector to print out
159 void cvec_print(cvec_t *s);
161 /** set all elements to a given value
163 \param s vector to modify
164 \param val value to set elements to
167 void cvec_set(cvec_t *s, smpl_t val);
169 /** set all elements to zero
171 \param s vector to modify
174 void cvec_zeros(cvec_t *s);
176 /** set all elements to ones
178 \param s vector to modify
181 void cvec_ones(cvec_t *s);