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