source: src/cvec.h @ 64c3658

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

src/cvec.{c,h}: add cvec_set, cvec_zeros and cvec_ones

  • Property mode set to 100644
File size: 6.6 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/** Spectrum buffer type */
39typedef struct _cvec_t cvec_t;
40/** Buffer for complex data */
41struct _cvec_t {
42  uint_t length;   /**< length of buffer = (requested length)/2 + 1 */
43  uint_t channels; /**< number of channels */
44  smpl_t **norm;   /**< norm array of size [length] * [channels] */
45  smpl_t **phas;   /**< phase array of size [length] * [channels] */
46};
47
48/** cvec_t buffer creation function
49
50  This function creates a cvec_t structure holding two arrays of size
51  [length/2+1] * channels, corresponding to the norm and phase values of the
52  spectral frame. The length stored in the structure is the actual size of both
53  arrays, not the length of the complex and symetrical vector, specified as
54  creation argument.
55
56  \param length the length of the buffer to create
57  \param channels the number of channels in the buffer
58
59*/
60cvec_t * new_cvec(uint_t length, uint_t channels);
61/** cvec_t buffer deletion function
62
63  \param s buffer to delete as returned by new_cvec()
64
65*/
66void del_cvec(cvec_t *s);
67/** write norm value in a complex buffer
68
69  Note that this function is not used in the aubio library, since the same
70  result can be obtained by assigning vec->norm[channel][position]. Its purpose
71  is to access these values from wrappers, as created by swig.
72
73  \param s vector to write to
74  \param data norm value to write in s->norm[channel][position]
75  \param channel channel to write to
76  \param position sample position to write to
77
78*/
79void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
80/** write phase value in a complex buffer
81
82  Note that this function is not used in the aubio library, since the same
83  result can be obtained by assigning vec->phas[channel][position]. Its purpose
84  is to access these values from wrappers, as created by swig.
85
86  \param s vector to write to
87  \param data phase value to write in s->phas[channel][position]
88  \param channel channel to write to
89  \param position sample position to write to
90
91*/
92void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position);
93/** read norm value from a complex buffer
94
95  Note that this function is not used in the aubio library, since the same
96  result can be obtained with vec->norm[channel][position]. Its purpose is to
97  access these values from wrappers, as created by swig.
98
99  \param s vector to read from
100  \param channel channel to read from
101  \param position sample position to read from
102
103*/
104smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position);
105/** read phase value from a complex buffer
106
107  Note that this function is not used in the aubio library, since the same
108  result can be obtained with vec->phas[channel][position]. Its purpose is to
109  access these values from wrappers, as created by swig.
110
111  \param s vector to read from
112  \param channel channel to read from
113  \param position sample position to read from
114
115*/
116smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position);
117/** write norm channel in a complex buffer
118
119  Note that this function is not used in the aubio library, since the same
120  result can be obtained by assigning vec->norm[channel]. Its purpose is to
121  access these values from wrappers, as created by swig.
122
123  \param s vector to write to
124  \param data norm vector of [length] samples to write in s->norm[channel]
125  \param channel channel to write to
126
127*/
128void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel);
129/** write phase channel in a complex buffer
130
131  Note that this function is not used in the aubio library, since the same
132  result can be obtained by assigning vec->phas[channel]. Its purpose is to
133  access these values from wrappers, as created by swig.
134
135  \param s vector to write to
136  \param data phase vector of [length] samples to write in s->phas[channel]
137  \param channel channel to write to
138
139*/
140void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel);
141/** read norm channel from a complex buffer
142
143  Note that this function is not used in the aubio library, since the same
144  result can be obtained with vec->norm[channel]. Its purpose is to access
145  these values from wrappers, as created by swig.
146
147  \param s vector to read from
148  \param channel channel to read from
149
150*/
151smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel);
152/** write phase channel in a complex buffer
153
154  Note that this function is not used in the aubio library, since the same
155  result can be obtained with vec->phas[channel]. Its purpose is to access
156  these values from wrappers, as created by swig.
157
158  \param s vector to read from
159  \param channel channel to read from
160
161*/
162smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel);
163/** read norm data from a complex buffer
164
165  Note that this function is not used in the aubio library, since the same
166  result can be obtained with vec->norm. Its purpose is to access these values
167  from wrappers, as created by swig.
168
169  \param s vector to read from
170
171*/
172smpl_t ** cvec_get_norm(cvec_t *s);
173/** read phase data from a complex buffer
174
175  Note that this function is not used in the aubio library, since the same
176  result can be obtained with vec->phas. Its purpose is to access these values
177  from wrappers, as created by swig.
178
179  \param s vector to read from
180
181*/
182smpl_t ** cvec_get_phas(cvec_t *s);
183
184/** print out cvec data
185
186  \param s vector to print out
187
188*/
189void cvec_print(cvec_t *s);
190
191/** set all elements to a given value
192
193  \param s vector to modify
194  \param val value to set elements to
195
196*/
197void cvec_set(cvec_t *s, smpl_t val);
198
199/** set all elements to zero
200
201  \param s vector to modify
202
203*/
204void cvec_zeros(cvec_t *s);
205
206/** set all elements to ones
207
208  \param s vector to modify
209
210*/
211void cvec_ones(cvec_t *s);
212
213#ifdef __cplusplus
214}
215#endif
216
217#endif /* _CVEC_H */
218
Note: See TracBrowser for help on using the repository browser.