[c7860af] | 1 | /* |
---|
[0683ee2] | 2 | Copyright (C) 2009-2015 Paul Brossier <piem@aubio.org> |
---|
[c7860af] | 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 | |
---|
[b235c0e] | 21 | #ifndef _AUBIO__FMAT_H |
---|
| 22 | #define _AUBIO__FMAT_H |
---|
[c7860af] | 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /** \file |
---|
| 29 | |
---|
[f72364d] | 30 | Matrix of real valued data |
---|
[c7860af] | 31 | |
---|
[f72364d] | 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 |
---|
[c7860af] | 36 | |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | /** Buffer for real data */ |
---|
| 40 | typedef struct { |
---|
[f72364d] | 41 | uint_t length; /**< length of matrix */ |
---|
| 42 | uint_t height; /**< height of matrix */ |
---|
| 43 | smpl_t **data; /**< data array of size [length] * [height] */ |
---|
[c7860af] | 44 | } fmat_t; |
---|
| 45 | |
---|
| 46 | /** fmat_t buffer creation function |
---|
| 47 | |
---|
[4435ea6e] | 48 | \param length the length of the matrix to create |
---|
| 49 | \param height the height of the matrix to create |
---|
[c7860af] | 50 | |
---|
| 51 | */ |
---|
[4ed0ed1] | 52 | fmat_t * new_fmat(uint_t height, uint_t length); |
---|
[1ece4f8] | 53 | |
---|
[c7860af] | 54 | /** fmat_t buffer deletion function |
---|
| 55 | |
---|
| 56 | \param s buffer to delete as returned by new_fmat() |
---|
| 57 | |
---|
| 58 | */ |
---|
| 59 | void del_fmat(fmat_t *s); |
---|
| 60 | |
---|
[1ece4f8] | 61 | /** read sample value in a buffer |
---|
[c7860af] | 62 | |
---|
| 63 | \param s vector to read from |
---|
| 64 | \param channel channel to read from |
---|
[0683ee2] | 65 | \param position sample position to read from |
---|
[c7860af] | 66 | |
---|
| 67 | */ |
---|
[1ece4f8] | 68 | smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position); |
---|
[c7860af] | 69 | |
---|
[1ece4f8] | 70 | /** write sample value in a buffer |
---|
[c7860af] | 71 | |
---|
[0683ee2] | 72 | \param s vector to write to |
---|
[c7860af] | 73 | \param data value to write in s->data[channel][position] |
---|
[0683ee2] | 74 | \param channel channel to write to |
---|
| 75 | \param position sample position to write to |
---|
[c7860af] | 76 | |
---|
| 77 | */ |
---|
[1ece4f8] | 78 | void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position); |
---|
[c7860af] | 79 | |
---|
[1ece4f8] | 80 | /** read channel vector from a buffer |
---|
[c7860af] | 81 | |
---|
| 82 | \param s vector to read from |
---|
| 83 | \param channel channel to read from |
---|
[ce1d788] | 84 | \param output ::fvec_t to output to |
---|
[c7860af] | 85 | |
---|
| 86 | */ |
---|
[3cd9fdd] | 87 | void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); |
---|
[c7860af] | 88 | |
---|
[1ece4f8] | 89 | /** get vector buffer from an fmat data |
---|
[c7860af] | 90 | |
---|
[1ece4f8] | 91 | \param s vector to read from |
---|
| 92 | \param channel channel to read from |
---|
[c7860af] | 93 | |
---|
| 94 | */ |
---|
[1ece4f8] | 95 | smpl_t * fmat_get_channel_data (fmat_t *s, uint_t channel); |
---|
[c7860af] | 96 | |
---|
[1ece4f8] | 97 | /** read data from a buffer |
---|
[c7860af] | 98 | |
---|
| 99 | \param s vector to read from |
---|
| 100 | |
---|
| 101 | */ |
---|
| 102 | smpl_t ** fmat_get_data(fmat_t *s); |
---|
| 103 | |
---|
[0683ee2] | 104 | /** print out fmat data |
---|
[c7860af] | 105 | |
---|
[0683ee2] | 106 | \param s vector to print out |
---|
[c7860af] | 107 | |
---|
| 108 | */ |
---|
| 109 | void fmat_print(fmat_t *s); |
---|
| 110 | |
---|
| 111 | /** set all elements to a given value |
---|
| 112 | |
---|
| 113 | \param s vector to modify |
---|
| 114 | \param val value to set elements to |
---|
| 115 | |
---|
| 116 | */ |
---|
| 117 | void fmat_set(fmat_t *s, smpl_t val); |
---|
| 118 | |
---|
[0683ee2] | 119 | /** set all elements to zero |
---|
[c7860af] | 120 | |
---|
| 121 | \param s vector to modify |
---|
| 122 | |
---|
| 123 | */ |
---|
| 124 | void fmat_zeros(fmat_t *s); |
---|
| 125 | |
---|
[0683ee2] | 126 | /** set all elements to ones |
---|
[c7860af] | 127 | |
---|
| 128 | \param s vector to modify |
---|
| 129 | |
---|
| 130 | */ |
---|
| 131 | void fmat_ones(fmat_t *s); |
---|
| 132 | |
---|
| 133 | /** revert order of vector elements |
---|
| 134 | |
---|
| 135 | \param s vector to revert |
---|
| 136 | |
---|
| 137 | */ |
---|
| 138 | void fmat_rev(fmat_t *s); |
---|
| 139 | |
---|
| 140 | /** apply weight to vector |
---|
| 141 | |
---|
| 142 | If the weight vector is longer than s, only the first elements are used. If |
---|
| 143 | the weight vector is shorter than s, the last elements of s are not weighted. |
---|
| 144 | |
---|
| 145 | \param s vector to weight |
---|
| 146 | \param weight weighting coefficients |
---|
| 147 | |
---|
| 148 | */ |
---|
| 149 | void fmat_weight(fmat_t *s, fmat_t *weight); |
---|
| 150 | |
---|
[0683ee2] | 151 | /** make a copy of a matrix |
---|
[c7860af] | 152 | |
---|
| 153 | \param s source vector |
---|
| 154 | \param t vector to copy to |
---|
| 155 | |
---|
| 156 | */ |
---|
| 157 | void fmat_copy(fmat_t *s, fmat_t *t); |
---|
| 158 | |
---|
| 159 | #ifdef __cplusplus |
---|
| 160 | } |
---|
| 161 | #endif |
---|
| 162 | |
---|
[b235c0e] | 163 | #endif /* _AUBIO__FMAT_H */ |
---|