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 real-valued data
32 This file specifies the ::fvec_t buffer type, which is used throughout aubio
33 to store vector of real-valued ::smpl_t.
39 /** Buffer for real data
41 Vector of real-valued data
43 ::fvec_t is is the structure used to store vector of real-valued data, ::smpl_t .
47 uint_t buffer_size = 1024;
49 // create a vector of 512 values
50 fvec_t * input = new_fvec (buffer_size);
52 // set some values of the vector
56 // compute the mean of the vector
57 mean = fvec_mean(a_vector);
64 See `examples/` and `tests/src` directories for more examples.
68 uint_t length; /**< length of buffer */
69 smpl_t *data; /**< data vector of length ::fvec_t.length */
72 /** fvec_t buffer creation function
74 \param length the length of the buffer to create
77 fvec_t * new_fvec(uint_t length);
78 /** fvec_t buffer deletion function
80 \param s buffer to delete as returned by new_fvec()
83 void del_fvec(fvec_t *s);
84 /** read sample value in a buffer
86 Note that this function is not used in the aubio library, since the same
87 result can be obtained using vec->data[position]. Its purpose is to
88 access these values from wrappers, as created by swig.
90 \param s vector to read from
91 \param position sample position to read from
94 smpl_t fvec_read_sample(fvec_t *s, uint_t position);
95 /** write sample value in a buffer
97 Note that this function is not used in the aubio library, since the same
98 result can be obtained by assigning vec->data[position]. Its purpose
99 is to access these values from wrappers, as created by swig.
101 \param s vector to write to
102 \param data value to write in s->data[position]
103 \param position sample position to write to
106 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position);
108 /** read data from a buffer
110 Note that this function is not used in the aubio library, since the same
111 result can be obtained with vec->data. Its purpose is to access these values
112 from wrappers, as created by swig.
114 \param s vector to read from
117 smpl_t * fvec_get_data(fvec_t *s);
119 /** print out fvec data
121 \param s vector to print out
124 void fvec_print(fvec_t *s);
126 /** set all elements to a given value
128 \param s vector to modify
129 \param val value to set elements to
132 void fvec_set(fvec_t *s, smpl_t val);
134 /** set all elements to zero
136 \param s vector to modify
139 void fvec_zeros(fvec_t *s);
141 /** set all elements to ones
143 \param s vector to modify
146 void fvec_ones(fvec_t *s);
148 /** revert order of vector elements
150 \param s vector to revert
153 void fvec_rev(fvec_t *s);
155 /** apply weight to vector
157 If the weight vector is longer than s, only the first elements are used. If
158 the weight vector is shorter than s, the last elements of s are not weighted.
160 \param s vector to weight
161 \param weight weighting coefficients
164 void fvec_weight(fvec_t *s, fvec_t *weight);
166 /** make a copy of a vector
168 \param s source vector
169 \param t vector to copy to
172 void fvec_copy(fvec_t *s, fvec_t *t);