[a3a01e1] | 1 | /* |
---|
[a6db140] | 2 | Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org> |
---|
[a3a01e1] | 3 | |
---|
[a6db140] | 4 | This file is part of aubio. |
---|
[a3a01e1] | 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. |
---|
[a3a01e1] | 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/>. |
---|
[a3a01e1] | 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #ifndef _LVEC_H |
---|
| 22 | #define _LVEC_H |
---|
| 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /** \file |
---|
| 29 | |
---|
[f72364d] | 30 | Vector of real-valued data in double precision |
---|
[a3a01e1] | 31 | |
---|
[f72364d] | 32 | This file specifies the ::lvec_t buffer type, which is used in some places in |
---|
| 33 | aubio to store a vector of ::lsmp_t. |
---|
| 34 | |
---|
| 35 | Note: the lvec_t data type is required in some algorithms such as IIR filters |
---|
| 36 | (see temporal/filter.h). |
---|
| 37 | |
---|
| 38 | \example test-lvec.c |
---|
[a3a01e1] | 39 | |
---|
| 40 | */ |
---|
| 41 | |
---|
[78429de] | 42 | /** Buffer for real data in double precision */ |
---|
| 43 | typedef struct { |
---|
[f72364d] | 44 | uint_t length; /**< length of buffer */ |
---|
| 45 | lsmp_t *data; /**< data array of size [length] */ |
---|
[78429de] | 46 | } lvec_t; |
---|
| 47 | |
---|
[a3a01e1] | 48 | /** lvec_t buffer creation function |
---|
| 49 | |
---|
| 50 | \param length the length of the buffer to create |
---|
| 51 | |
---|
| 52 | */ |
---|
[c7860af] | 53 | lvec_t * new_lvec(uint_t length); |
---|
[a3a01e1] | 54 | /** lvec_t buffer deletion function |
---|
| 55 | |
---|
| 56 | \param s buffer to delete as returned by new_lvec() |
---|
| 57 | |
---|
| 58 | */ |
---|
| 59 | void del_lvec(lvec_t *s); |
---|
| 60 | /** read sample value in a buffer |
---|
| 61 | |
---|
| 62 | Note that this function is not used in the aubio library, since the same |
---|
[c7860af] | 63 | result can be obtained using vec->data[position]. Its purpose is to |
---|
[a3a01e1] | 64 | access these values from wrappers, as created by swig. |
---|
| 65 | |
---|
| 66 | \param s vector to read from |
---|
| 67 | \param position sample position to read from |
---|
| 68 | |
---|
| 69 | */ |
---|
[c7860af] | 70 | lsmp_t lvec_read_sample(lvec_t *s, uint_t position); |
---|
[a3a01e1] | 71 | /** write sample value in a buffer |
---|
| 72 | |
---|
| 73 | Note that this function is not used in the aubio library, since the same |
---|
[c7860af] | 74 | result can be obtained by assigning vec->data[position]. Its purpose |
---|
[a3a01e1] | 75 | is to access these values from wrappers, as created by swig. |
---|
| 76 | |
---|
| 77 | \param s vector to write to |
---|
[c7860af] | 78 | \param data value to write in s->data[position] |
---|
[a3a01e1] | 79 | \param position sample position to write to |
---|
| 80 | |
---|
| 81 | */ |
---|
[c7860af] | 82 | void lvec_write_sample(lvec_t *s, lsmp_t data, uint_t position); |
---|
[a3a01e1] | 83 | |
---|
| 84 | /** read data from a buffer |
---|
| 85 | |
---|
| 86 | Note that this function is not used in the aubio library, since the same |
---|
| 87 | result can be obtained with vec->data. Its purpose is to access these values |
---|
| 88 | from wrappers, as created by swig. |
---|
| 89 | |
---|
| 90 | \param s vector to read from |
---|
| 91 | |
---|
| 92 | */ |
---|
[c7860af] | 93 | lsmp_t * lvec_get_data(lvec_t *s); |
---|
[a3a01e1] | 94 | |
---|
[79a01c5] | 95 | /** print out lvec data |
---|
| 96 | |
---|
| 97 | \param s vector to print out |
---|
| 98 | |
---|
| 99 | */ |
---|
| 100 | void lvec_print(lvec_t *s); |
---|
| 101 | |
---|
[b849106] | 102 | /** set all elements to a given value |
---|
| 103 | |
---|
| 104 | \param s vector to modify |
---|
| 105 | \param val value to set elements to |
---|
| 106 | |
---|
| 107 | */ |
---|
| 108 | void lvec_set(lvec_t *s, smpl_t val); |
---|
| 109 | |
---|
| 110 | /** set all elements to zero |
---|
| 111 | |
---|
| 112 | \param s vector to modify |
---|
| 113 | |
---|
| 114 | */ |
---|
| 115 | void lvec_zeros(lvec_t *s); |
---|
| 116 | |
---|
| 117 | /** set all elements to ones |
---|
| 118 | |
---|
| 119 | \param s vector to modify |
---|
| 120 | |
---|
| 121 | */ |
---|
| 122 | void lvec_ones(lvec_t *s); |
---|
| 123 | |
---|
[a3a01e1] | 124 | #ifdef __cplusplus |
---|
| 125 | } |
---|
| 126 | #endif |
---|
| 127 | |
---|
| 128 | #endif /* _LVEC_H */ |
---|