source: src/cvec.h @ ed73bc6

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since ed73bc6 was 78429de, checked in by Paul Brossier <piem@piem.org>, 15 years ago

src/*vec.h: strip down _*vec_t

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/*
2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
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.
10
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.
15
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/>.
18
19*/
20
21#ifndef _CVEC_H
22#define _CVEC_H_
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/** \file
29
30  Complex buffers
31
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.
35
36*/
37
38/** Buffer for complex data */
39typedef struct {
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] */
44} cvec_t;
45
46/** cvec_t buffer creation function
47
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
52  creation argument.
53
54  \param length the length of the buffer to create
55  \param channels the number of channels in the buffer
56
57*/
58cvec_t * new_cvec(uint_t length, uint_t channels);
59/** cvec_t buffer deletion function
60
61  \param s buffer to delete as returned by new_cvec()
62
63*/
64void del_cvec(cvec_t *s);
65/** write norm value in a complex buffer
66
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.
70
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
75
76*/
77void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
78/** write phase value in a complex buffer
79
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.
83
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
88
89*/
90void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
91/** read norm value from a complex buffer
92
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.
96
97  \param s vector to read from
98  \param channel channel to read from
99  \param position sample position to read from
100
101*/
102smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
103/** read phase value from a complex buffer
104
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.
108
109  \param s vector to read from
110  \param channel channel to read from
111  \param position sample position to read from
112
113*/
114smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
115/** write norm channel in a complex buffer
116
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.
120
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
124
125*/
126void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
127/** write phase channel in a complex buffer
128
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.
132
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
136
137*/
138void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
139/** read norm channel from a complex buffer
140
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.
144
145  \param s vector to read from
146  \param channel channel to read from
147
148*/
149smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
150/** write phase channel in a complex buffer
151
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.
155
156  \param s vector to read from
157  \param channel channel to read from
158
159*/
160smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
161/** read norm data from a complex buffer
162
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.
166
167  \param s vector to read from
168
169*/
170smpl_t ** cvec_get_norm(cvec_t *s);
171/** read phase data from a complex buffer
172
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.
176
177  \param s vector to read from
178
179*/
180smpl_t ** cvec_get_phas(cvec_t *s);
181
182/** print out cvec data
183
184  \param s vector to print out
185
186*/
187void cvec_print(cvec_t *s);
188
189/** set all elements to a given value
190
191  \param s vector to modify
192  \param val value to set elements to
193
194*/
195void cvec_set(cvec_t *s, smpl_t val);
196
197/** set all elements to zero
198
199  \param s vector to modify
200
201*/
202void cvec_zeros(cvec_t *s);
203
204/** set all elements to ones
205
206  \param s vector to modify
207
208*/
209void cvec_ones(cvec_t *s);
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif /* _CVEC_H */
216
Note: See TracBrowser for help on using the repository browser.