1 | /* |
---|
2 | Copyright (C) 2009-2013 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 _AUBIO__FMAT_H |
---|
22 | #define _AUBIO__FMAT_H |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** \file |
---|
29 | |
---|
30 | Matrix of real valued data |
---|
31 | |
---|
32 | This file specifies the fmat_t type, which is used in aubio to store arrays |
---|
33 | of floating point values. |
---|
34 | |
---|
35 | \example test-fmat.c |
---|
36 | |
---|
37 | */ |
---|
38 | |
---|
39 | /** Buffer for real data */ |
---|
40 | typedef struct { |
---|
41 | uint_t length; /**< length of matrix */ |
---|
42 | uint_t height; /**< height of matrix */ |
---|
43 | smpl_t **data; /**< data array of size [length] * [height] */ |
---|
44 | } fmat_t; |
---|
45 | |
---|
46 | /** fmat_t buffer creation function |
---|
47 | |
---|
48 | \param length the length of the matrix to create |
---|
49 | \param height the height of the matrix to create |
---|
50 | |
---|
51 | */ |
---|
52 | fmat_t * new_fmat(uint_t length, uint_t height); |
---|
53 | /** fmat_t buffer deletion function |
---|
54 | |
---|
55 | \param s buffer to delete as returned by new_fmat() |
---|
56 | |
---|
57 | */ |
---|
58 | void del_fmat(fmat_t *s); |
---|
59 | /** read sample value in a buffer |
---|
60 | |
---|
61 | Note that this function is not used in the aubio library, since the same |
---|
62 | result can be obtained using vec->data[channel][position]. Its purpose is to |
---|
63 | access these values from wrappers, as created by swig. |
---|
64 | |
---|
65 | \param s vector to read from |
---|
66 | \param channel channel to read from |
---|
67 | \param position sample position to read from |
---|
68 | |
---|
69 | */ |
---|
70 | smpl_t fmat_read_sample(fmat_t *s, uint_t channel, uint_t position); |
---|
71 | /** write sample value in a buffer |
---|
72 | |
---|
73 | Note that this function is not used in the aubio library, since the same |
---|
74 | result can be obtained by assigning vec->data[channel][position]. Its purpose |
---|
75 | is to access these values from wrappers, as created by swig. |
---|
76 | |
---|
77 | \param s vector to write to |
---|
78 | \param data value to write in s->data[channel][position] |
---|
79 | \param channel channel to write to |
---|
80 | \param position sample position to write to |
---|
81 | |
---|
82 | */ |
---|
83 | void fmat_write_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position); |
---|
84 | /** read channel vector from a buffer |
---|
85 | |
---|
86 | Note that this function is not used in the aubio library, since the same |
---|
87 | result can be obtained with vec->data[channel]. Its purpose is to access |
---|
88 | these values from wrappers, as created by swig. |
---|
89 | |
---|
90 | \param s vector to read from |
---|
91 | \param channel channel to read from |
---|
92 | \param output ::fvec_t to output to |
---|
93 | |
---|
94 | */ |
---|
95 | void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); |
---|
96 | /** write channel vector into a buffer |
---|
97 | |
---|
98 | Note that this function is not used in the aubio library, since the same |
---|
99 | result can be obtained by assigning vec->data[channel]. Its purpose is to |
---|
100 | access these values from wrappers, as created by swig. |
---|
101 | |
---|
102 | \param s vector to write to |
---|
103 | \param data vector of [length] values to write |
---|
104 | \param channel channel to write to |
---|
105 | |
---|
106 | */ |
---|
107 | void fmat_put_channel(fmat_t *s, smpl_t * data, uint_t channel); |
---|
108 | /** read data from a buffer |
---|
109 | |
---|
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. |
---|
113 | |
---|
114 | \param s vector to read from |
---|
115 | |
---|
116 | */ |
---|
117 | smpl_t ** fmat_get_data(fmat_t *s); |
---|
118 | |
---|
119 | /** print out fmat data |
---|
120 | |
---|
121 | \param s vector to print out |
---|
122 | |
---|
123 | */ |
---|
124 | void fmat_print(fmat_t *s); |
---|
125 | |
---|
126 | /** set all elements to a given value |
---|
127 | |
---|
128 | \param s vector to modify |
---|
129 | \param val value to set elements to |
---|
130 | |
---|
131 | */ |
---|
132 | void fmat_set(fmat_t *s, smpl_t val); |
---|
133 | |
---|
134 | /** set all elements to zero |
---|
135 | |
---|
136 | \param s vector to modify |
---|
137 | |
---|
138 | */ |
---|
139 | void fmat_zeros(fmat_t *s); |
---|
140 | |
---|
141 | /** set all elements to ones |
---|
142 | |
---|
143 | \param s vector to modify |
---|
144 | |
---|
145 | */ |
---|
146 | void fmat_ones(fmat_t *s); |
---|
147 | |
---|
148 | /** revert order of vector elements |
---|
149 | |
---|
150 | \param s vector to revert |
---|
151 | |
---|
152 | */ |
---|
153 | void fmat_rev(fmat_t *s); |
---|
154 | |
---|
155 | /** apply weight to vector |
---|
156 | |
---|
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. |
---|
159 | |
---|
160 | \param s vector to weight |
---|
161 | \param weight weighting coefficients |
---|
162 | |
---|
163 | */ |
---|
164 | void fmat_weight(fmat_t *s, fmat_t *weight); |
---|
165 | |
---|
166 | /** make a copy of a matrix |
---|
167 | |
---|
168 | \param s source vector |
---|
169 | \param t vector to copy to |
---|
170 | |
---|
171 | */ |
---|
172 | void fmat_copy(fmat_t *s, fmat_t *t); |
---|
173 | |
---|
174 | #ifdef __cplusplus |
---|
175 | } |
---|
176 | #endif |
---|
177 | |
---|
178 | #endif /* _AUBIO__FMAT_H */ |
---|