[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 | |
---|
[78429de] | 37 | /** Buffer for real data */ |
---|
| 38 | typedef struct { |
---|
[d1ec8cb] | 39 | uint_t length; /**< length of buffer */ |
---|
[c7860af] | 40 | smpl_t *data; /**< data array of size [length] */ |
---|
[78429de] | 41 | } fvec_t; |
---|
| 42 | |
---|
[d1ec8cb] | 43 | /** fvec_t buffer creation function |
---|
| 44 | |
---|
| 45 | \param length the length of the buffer to create |
---|
| 46 | |
---|
| 47 | */ |
---|
[c7860af] | 48 | fvec_t * new_fvec(uint_t length); |
---|
[d1ec8cb] | 49 | /** fvec_t buffer deletion function |
---|
| 50 | |
---|
| 51 | \param s buffer to delete as returned by new_fvec() |
---|
| 52 | |
---|
| 53 | */ |
---|
| 54 | void del_fvec(fvec_t *s); |
---|
| 55 | /** read sample value in a buffer |
---|
| 56 | |
---|
| 57 | Note that this function is not used in the aubio library, since the same |
---|
[c7860af] | 58 | result can be obtained using vec->data[position]. Its purpose is to |
---|
[d1ec8cb] | 59 | access these values from wrappers, as created by swig. |
---|
| 60 | |
---|
| 61 | \param s vector to read from |
---|
| 62 | \param position sample position to read from |
---|
| 63 | |
---|
| 64 | */ |
---|
[c7860af] | 65 | smpl_t fvec_read_sample(fvec_t *s, uint_t position); |
---|
[d1ec8cb] | 66 | /** write sample value in a buffer |
---|
| 67 | |
---|
| 68 | Note that this function is not used in the aubio library, since the same |
---|
[c7860af] | 69 | result can be obtained by assigning vec->data[position]. Its purpose |
---|
[d1ec8cb] | 70 | is to access these values from wrappers, as created by swig. |
---|
| 71 | |
---|
| 72 | \param s vector to write to |
---|
[c7860af] | 73 | \param data value to write in s->data[position] |
---|
[d1ec8cb] | 74 | \param position sample position to write to |
---|
| 75 | |
---|
| 76 | */ |
---|
[c7860af] | 77 | void fvec_write_sample(fvec_t *s, smpl_t data, uint_t position); |
---|
[d1ec8cb] | 78 | |
---|
| 79 | /** read data from a buffer |
---|
| 80 | |
---|
| 81 | Note that this function is not used in the aubio library, since the same |
---|
| 82 | result can be obtained with vec->data. Its purpose is to access these values |
---|
| 83 | from wrappers, as created by swig. |
---|
| 84 | |
---|
| 85 | \param s vector to read from |
---|
| 86 | |
---|
| 87 | */ |
---|
[c7860af] | 88 | smpl_t * fvec_get_data(fvec_t *s); |
---|
[d1ec8cb] | 89 | |
---|
[32f5a01] | 90 | /** print out fvec data |
---|
| 91 | |
---|
| 92 | \param s vector to print out |
---|
| 93 | |
---|
| 94 | */ |
---|
| 95 | void fvec_print(fvec_t *s); |
---|
| 96 | |
---|
[3b2d32c] | 97 | /** set all elements to a given value |
---|
| 98 | |
---|
| 99 | \param s vector to modify |
---|
| 100 | \param val value to set elements to |
---|
| 101 | |
---|
| 102 | */ |
---|
| 103 | void fvec_set(fvec_t *s, smpl_t val); |
---|
| 104 | |
---|
| 105 | /** set all elements to zero |
---|
| 106 | |
---|
| 107 | \param s vector to modify |
---|
| 108 | |
---|
| 109 | */ |
---|
| 110 | void fvec_zeros(fvec_t *s); |
---|
| 111 | |
---|
| 112 | /** set all elements to ones |
---|
| 113 | |
---|
| 114 | \param s vector to modify |
---|
| 115 | |
---|
| 116 | */ |
---|
| 117 | void fvec_ones(fvec_t *s); |
---|
| 118 | |
---|
| 119 | /** revert order of vector elements |
---|
| 120 | |
---|
| 121 | \param s vector to revert |
---|
| 122 | |
---|
| 123 | */ |
---|
| 124 | void fvec_rev(fvec_t *s); |
---|
| 125 | |
---|
| 126 | /** apply weight to vector |
---|
| 127 | |
---|
| 128 | If the weight vector is longer than s, only the first elements are used. If |
---|
| 129 | the weight vector is shorter than s, the last elements of s are not weighted. |
---|
| 130 | |
---|
| 131 | \param s vector to weight |
---|
| 132 | \param weight weighting coefficients |
---|
| 133 | |
---|
| 134 | */ |
---|
| 135 | void fvec_weight(fvec_t *s, fvec_t *weight); |
---|
| 136 | |
---|
| 137 | /** make a copy of a vector |
---|
| 138 | |
---|
| 139 | \param s source vector |
---|
| 140 | \param t vector to copy to |
---|
| 141 | |
---|
| 142 | */ |
---|
| 143 | void fvec_copy(fvec_t *s, fvec_t *t); |
---|
| 144 | |
---|
[d1ec8cb] | 145 | #ifdef __cplusplus |
---|
| 146 | } |
---|
| 147 | #endif |
---|
| 148 | |
---|
| 149 | #endif /* _FVEC_H */ |
---|