2 Copyright (C) 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 fmat_t type, which is used in aubio to store real
37 /** Buffer for real data */
39 uint_t length; /**< length of buffer */
40 uint_t height; /**< number of channels */
41 smpl_t **data; /**< data array of size [length] * [channels] */
44 /** fmat_t buffer creation function
46 \param length the length of the buffer to create
47 \param channels the number of channels in the buffer
50 fmat_t * new_fmat(uint_t length, uint_t channels);
51 /** fmat_t buffer deletion function
53 \param s buffer to delete as returned by new_fmat()
56 void del_fmat(fmat_t *s);
57 /** read sample value in a buffer
59 Note that this function is not used in the aubio library, since the same
60 result can be obtained using vec->data[channel][position]. Its purpose is to
61 access these values from wrappers, as created by swig.
63 \param s vector to read from
64 \param channel channel to read from
65 \param position sample position to read from
68 smpl_t fmat_read_sample(fmat_t *s, uint_t channel, uint_t position);
69 /** write sample value in a buffer
71 Note that this function is not used in the aubio library, since the same
72 result can be obtained by assigning vec->data[channel][position]. Its purpose
73 is to access these values from wrappers, as created by swig.
75 \param s vector to write to
76 \param data value to write in s->data[channel][position]
77 \param channel channel to write to
78 \param position sample position to write to
81 void fmat_write_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position);
82 /** read channel vector from a buffer
84 Note that this function is not used in the aubio library, since the same
85 result can be obtained with vec->data[channel]. Its purpose is to access
86 these values from wrappers, as created by swig.
88 \param s vector to read from
89 \param channel channel to read from
92 smpl_t * fmat_get_channel(fmat_t *s, uint_t channel);
93 /** write channel vector into a buffer
95 Note that this function is not used in the aubio library, since the same
96 result can be obtained by assigning vec->data[channel]. Its purpose is to
97 access these values from wrappers, as created by swig.
99 \param s vector to write to
100 \param data vector of [length] values to write
101 \param channel channel to write to
104 void fmat_put_channel(fmat_t *s, smpl_t * data, uint_t channel);
105 /** read data from a buffer
107 Note that this function is not used in the aubio library, since the same
108 result can be obtained with vec->data. Its purpose is to access these values
109 from wrappers, as created by swig.
111 \param s vector to read from
114 smpl_t ** fmat_get_data(fmat_t *s);
116 /** print out fmat data
118 \param s vector to print out
121 void fmat_print(fmat_t *s);
123 /** set all elements to a given value
125 \param s vector to modify
126 \param val value to set elements to
129 void fmat_set(fmat_t *s, smpl_t val);
131 /** set all elements to zero
133 \param s vector to modify
136 void fmat_zeros(fmat_t *s);
138 /** set all elements to ones
140 \param s vector to modify
143 void fmat_ones(fmat_t *s);
145 /** revert order of vector elements
147 \param s vector to revert
150 void fmat_rev(fmat_t *s);
152 /** apply weight to vector
154 If the weight vector is longer than s, only the first elements are used. If
155 the weight vector is shorter than s, the last elements of s are not weighted.
157 \param s vector to weight
158 \param weight weighting coefficients
161 void fmat_weight(fmat_t *s, fmat_t *weight);
163 /** make a copy of a matrix
165 \param s source vector
166 \param t vector to copy to
169 void fmat_copy(fmat_t *s, fmat_t *t);