[d1ec8cb] | 1 | /* |
---|
[a6db140] | 2 | Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org> |
---|
[d1ec8cb] | 3 | |
---|
[a6db140] | 4 | This file is part of aubio. |
---|
[d1ec8cb] | 5 | |
---|
[a6db140] | 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. |
---|
[d1ec8cb] | 10 | |
---|
[a6db140] | 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/>. |
---|
[d1ec8cb] | 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef _FVEC_H |
---|
| 22 | #define _FVEC_H |
---|
| 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /** \file |
---|
| 29 | |
---|
| 30 | Real buffers |
---|
| 31 | |
---|
| 32 | This file specifies the fvec_t buffer type, which is used throughout aubio to |
---|
| 33 | store real data. |
---|
| 34 | |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | /** Sample buffer type */ |
---|
| 38 | typedef struct _fvec_t fvec_t; |
---|
| 39 | /** Buffer for real values */ |
---|
| 40 | struct _fvec_t { |
---|
| 41 | uint_t length; /**< length of buffer */ |
---|
| 42 | uint_t channels; /**< number of channels */ |
---|
| 43 | smpl_t **data; /**< data array of size [length] * [channels] */ |
---|
| 44 | }; |
---|
| 45 | /** fvec_t buffer creation function |
---|
| 46 | |
---|
| 47 | \param length the length of the buffer to create |
---|
| 48 | \param channels the number of channels in the buffer |
---|
| 49 | |
---|
| 50 | */ |
---|
| 51 | fvec_t * new_fvec(uint_t length, uint_t channels); |
---|
| 52 | /** fvec_t buffer deletion function |
---|
| 53 | |
---|
| 54 | \param s buffer to delete as returned by new_fvec() |
---|
| 55 | |
---|
| 56 | */ |
---|
| 57 | void del_fvec(fvec_t *s); |
---|
| 58 | /** read sample value in a buffer |
---|
| 59 | |
---|
| 60 | Note that this function is not used in the aubio library, since the same |
---|
| 61 | result can be obtained using vec->data[channel][position]. Its purpose is to |
---|
| 62 | access these values from wrappers, as created by swig. |
---|
| 63 | |
---|
| 64 | \param s vector to read from |
---|
| 65 | \param channel channel to read from |
---|
| 66 | \param position sample position to read from |
---|
| 67 | |
---|
| 68 | */ |
---|
| 69 | smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position); |
---|
| 70 | /** write sample value in a buffer |
---|
| 71 | |
---|
| 72 | Note that this function is not used in the aubio library, since the same |
---|
| 73 | result can be obtained by assigning vec->data[channel][position]. Its purpose |
---|
| 74 | is to access these values from wrappers, as created by swig. |
---|
| 75 | |
---|
| 76 | \param s vector to write to |
---|
| 77 | \param data value to write in s->data[channel][position] |
---|
| 78 | \param channel channel to write to |
---|
| 79 | \param position sample position to write to |
---|
| 80 | |
---|
| 81 | */ |
---|
| 82 | void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position); |
---|
| 83 | /** read channel vector from a buffer |
---|
| 84 | |
---|
| 85 | Note that this function is not used in the aubio library, since the same |
---|
| 86 | result can be obtained with vec->data[channel]. Its purpose is to access |
---|
| 87 | these values from wrappers, as created by swig. |
---|
| 88 | |
---|
| 89 | \param s vector to read from |
---|
| 90 | \param channel channel to read from |
---|
| 91 | |
---|
| 92 | */ |
---|
| 93 | smpl_t * fvec_get_channel(fvec_t *s, uint_t channel); |
---|
| 94 | /** write channel vector into a buffer |
---|
| 95 | |
---|
| 96 | Note that this function is not used in the aubio library, since the same |
---|
| 97 | result can be obtained by assigning vec->data[channel]. Its purpose is to |
---|
| 98 | access these values from wrappers, as created by swig. |
---|
| 99 | |
---|
| 100 | \param s vector to write to |
---|
| 101 | \param data vector of [length] values to write |
---|
| 102 | \param channel channel to write to |
---|
| 103 | |
---|
| 104 | */ |
---|
| 105 | void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel); |
---|
| 106 | /** read data from a buffer |
---|
| 107 | |
---|
| 108 | Note that this function is not used in the aubio library, since the same |
---|
| 109 | result can be obtained with vec->data. Its purpose is to access these values |
---|
| 110 | from wrappers, as created by swig. |
---|
| 111 | |
---|
| 112 | \param s vector to read from |
---|
| 113 | |
---|
| 114 | */ |
---|
| 115 | smpl_t ** fvec_get_data(fvec_t *s); |
---|
| 116 | |
---|
[32f5a01] | 117 | /** print out fvec data |
---|
| 118 | |
---|
| 119 | \param s vector to print out |
---|
| 120 | |
---|
| 121 | */ |
---|
| 122 | void fvec_print(fvec_t *s); |
---|
| 123 | |
---|
[3b2d32c] | 124 | /** set all elements to a given value |
---|
| 125 | |
---|
| 126 | \param s vector to modify |
---|
| 127 | \param val value to set elements to |
---|
| 128 | |
---|
| 129 | */ |
---|
| 130 | void fvec_set(fvec_t *s, smpl_t val); |
---|
| 131 | |
---|
| 132 | /** set all elements to zero |
---|
| 133 | |
---|
| 134 | \param s vector to modify |
---|
| 135 | |
---|
| 136 | */ |
---|
| 137 | void fvec_zeros(fvec_t *s); |
---|
| 138 | |
---|
| 139 | /** set all elements to ones |
---|
| 140 | |
---|
| 141 | \param s vector to modify |
---|
| 142 | |
---|
| 143 | */ |
---|
| 144 | void fvec_ones(fvec_t *s); |
---|
| 145 | |
---|
| 146 | /** revert order of vector elements |
---|
| 147 | |
---|
| 148 | \param s vector to revert |
---|
| 149 | |
---|
| 150 | */ |
---|
| 151 | void fvec_rev(fvec_t *s); |
---|
| 152 | |
---|
| 153 | /** apply weight to vector |
---|
| 154 | |
---|
| 155 | If the weight vector is longer than s, only the first elements are used. If |
---|
| 156 | the weight vector is shorter than s, the last elements of s are not weighted. |
---|
| 157 | |
---|
| 158 | \param s vector to weight |
---|
| 159 | \param weight weighting coefficients |
---|
| 160 | |
---|
| 161 | */ |
---|
| 162 | void fvec_weight(fvec_t *s, fvec_t *weight); |
---|
| 163 | |
---|
| 164 | /** make a copy of a vector |
---|
| 165 | |
---|
| 166 | \param s source vector |
---|
| 167 | \param t vector to copy to |
---|
| 168 | |
---|
| 169 | */ |
---|
| 170 | void fvec_copy(fvec_t *s, fvec_t *t); |
---|
| 171 | |
---|
[d1ec8cb] | 172 | #ifdef __cplusplus |
---|
| 173 | } |
---|
| 174 | #endif |
---|
| 175 | |
---|
| 176 | #endif /* _FVEC_H */ |
---|