[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 _CVEC_H |
---|
| 22 | #define _CVEC_H_ |
---|
| 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /** \file |
---|
| 29 | |
---|
[c698d1b] | 30 | Complex buffers |
---|
[d1ec8cb] | 31 | |
---|
| 32 | This file specifies the cvec_t buffer type, which is used throughout aubio to |
---|
| 33 | store complex data. Complex values are stored in terms of phase and |
---|
| 34 | norm, within size/2+1 long vectors. |
---|
| 35 | |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | /** Buffer for complex data */ |
---|
[78429de] | 39 | typedef struct { |
---|
[d1ec8cb] | 40 | uint_t length; /**< length of buffer = (requested length)/2 + 1 */ |
---|
[66fb3ea] | 41 | smpl_t *norm; /**< norm array of size [length] */ |
---|
| 42 | smpl_t *phas; /**< phase array of size [length] */ |
---|
[78429de] | 43 | } cvec_t; |
---|
[d1ec8cb] | 44 | |
---|
| 45 | /** cvec_t buffer creation function |
---|
| 46 | |
---|
| 47 | This function creates a cvec_t structure holding two arrays of size |
---|
[66fb3ea] | 48 | [length/2+1], corresponding to the norm and phase values of the |
---|
[d1ec8cb] | 49 | spectral frame. The length stored in the structure is the actual size of both |
---|
| 50 | arrays, not the length of the complex and symetrical vector, specified as |
---|
| 51 | creation argument. |
---|
| 52 | |
---|
| 53 | \param length the length of the buffer to create |
---|
| 54 | |
---|
| 55 | */ |
---|
[66fb3ea] | 56 | cvec_t * new_cvec(uint_t length); |
---|
[d1ec8cb] | 57 | /** cvec_t buffer deletion function |
---|
| 58 | |
---|
| 59 | \param s buffer to delete as returned by new_cvec() |
---|
| 60 | |
---|
| 61 | */ |
---|
| 62 | void del_cvec(cvec_t *s); |
---|
| 63 | /** write norm value in a complex buffer |
---|
| 64 | |
---|
| 65 | Note that this function is not used in the aubio library, since the same |
---|
[66fb3ea] | 66 | result can be obtained by assigning vec->norm[position]. Its purpose |
---|
[d1ec8cb] | 67 | is to access these values from wrappers, as created by swig. |
---|
| 68 | |
---|
| 69 | \param s vector to write to |
---|
[66fb3ea] | 70 | \param data norm value to write in s->norm[position] |
---|
[d1ec8cb] | 71 | \param position sample position to write to |
---|
| 72 | |
---|
| 73 | */ |
---|
[66fb3ea] | 74 | void cvec_write_norm(cvec_t *s, smpl_t data, uint_t position); |
---|
[d1ec8cb] | 75 | /** write phase value in a complex buffer |
---|
| 76 | |
---|
| 77 | Note that this function is not used in the aubio library, since the same |
---|
[66fb3ea] | 78 | result can be obtained by assigning vec->phas[position]. Its purpose |
---|
[d1ec8cb] | 79 | is to access these values from wrappers, as created by swig. |
---|
| 80 | |
---|
| 81 | \param s vector to write to |
---|
[66fb3ea] | 82 | \param data phase value to write in s->phas[position] |
---|
[d1ec8cb] | 83 | \param position sample position to write to |
---|
| 84 | |
---|
| 85 | */ |
---|
[66fb3ea] | 86 | void cvec_write_phas(cvec_t *s, smpl_t data, uint_t position); |
---|
[d1ec8cb] | 87 | /** read norm value from a complex buffer |
---|
| 88 | |
---|
| 89 | Note that this function is not used in the aubio library, since the same |
---|
[66fb3ea] | 90 | result can be obtained with vec->norm[position]. Its purpose is to |
---|
[d1ec8cb] | 91 | access these values from wrappers, as created by swig. |
---|
| 92 | |
---|
| 93 | \param s vector to read from |
---|
| 94 | \param position sample position to read from |
---|
| 95 | |
---|
| 96 | */ |
---|
[66fb3ea] | 97 | smpl_t cvec_read_norm(cvec_t *s, uint_t position); |
---|
[d1ec8cb] | 98 | /** read phase value from a complex buffer |
---|
| 99 | |
---|
| 100 | Note that this function is not used in the aubio library, since the same |
---|
[66fb3ea] | 101 | result can be obtained with vec->phas[position]. Its purpose is to |
---|
[d1ec8cb] | 102 | access these values from wrappers, as created by swig. |
---|
| 103 | |
---|
| 104 | \param s vector to read from |
---|
| 105 | \param position sample position to read from |
---|
| 106 | |
---|
| 107 | */ |
---|
[66fb3ea] | 108 | smpl_t cvec_read_phas(cvec_t *s, uint_t position); |
---|
[d1ec8cb] | 109 | /** read norm data from a complex buffer |
---|
| 110 | |
---|
| 111 | Note that this function is not used in the aubio library, since the same |
---|
| 112 | result can be obtained with vec->norm. Its purpose is to access these values |
---|
| 113 | from wrappers, as created by swig. |
---|
| 114 | |
---|
| 115 | \param s vector to read from |
---|
| 116 | |
---|
| 117 | */ |
---|
[66fb3ea] | 118 | smpl_t * cvec_get_norm(cvec_t *s); |
---|
[d1ec8cb] | 119 | /** read phase data from a complex buffer |
---|
| 120 | |
---|
| 121 | Note that this function is not used in the aubio library, since the same |
---|
| 122 | result can be obtained with vec->phas. Its purpose is to access these values |
---|
| 123 | from wrappers, as created by swig. |
---|
| 124 | |
---|
| 125 | \param s vector to read from |
---|
| 126 | |
---|
| 127 | */ |
---|
[66fb3ea] | 128 | smpl_t * cvec_get_phas(cvec_t *s); |
---|
[d1ec8cb] | 129 | |
---|
[55b7cb4] | 130 | /** print out cvec data |
---|
| 131 | |
---|
| 132 | \param s vector to print out |
---|
| 133 | |
---|
| 134 | */ |
---|
| 135 | void cvec_print(cvec_t *s); |
---|
| 136 | |
---|
[012466b] | 137 | /** set all elements to a given value |
---|
| 138 | |
---|
| 139 | \param s vector to modify |
---|
| 140 | \param val value to set elements to |
---|
| 141 | |
---|
| 142 | */ |
---|
| 143 | void cvec_set(cvec_t *s, smpl_t val); |
---|
| 144 | |
---|
| 145 | /** set all elements to zero |
---|
| 146 | |
---|
| 147 | \param s vector to modify |
---|
| 148 | |
---|
| 149 | */ |
---|
| 150 | void cvec_zeros(cvec_t *s); |
---|
| 151 | |
---|
| 152 | /** set all elements to ones |
---|
| 153 | |
---|
| 154 | \param s vector to modify |
---|
| 155 | |
---|
| 156 | */ |
---|
| 157 | void cvec_ones(cvec_t *s); |
---|
| 158 | |
---|
[d1ec8cb] | 159 | #ifdef __cplusplus |
---|
| 160 | } |
---|
| 161 | #endif |
---|
| 162 | |
---|
| 163 | #endif /* _CVEC_H */ |
---|
| 164 | |
---|