aubio
0.4.1
|
00001 /* 00002 Copyright (C) 2009-2013 Paul Brossier <piem@aubio.org> 00003 00004 This file is part of aubio. 00005 00006 aubio is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 aubio is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with aubio. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef _AUBIO__FMAT_H 00022 #define _AUBIO__FMAT_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /** \file 00029 00030 Matrix of real valued data 00031 00032 This file specifies the fmat_t type, which is used in aubio to store arrays 00033 of floating point values. 00034 00035 \example test-fmat.c 00036 00037 */ 00038 00039 /** Buffer for real data */ 00040 typedef struct { 00041 uint_t length; /**< length of matrix */ 00042 uint_t height; /**< height of matrix */ 00043 smpl_t **data; /**< data array of size [length] * [height] */ 00044 } fmat_t; 00045 00046 /** fmat_t buffer creation function 00047 00048 \param length the length of the matrix to create 00049 \param height the height of the matrix to create 00050 00051 */ 00052 fmat_t * new_fmat(uint_t height, uint_t length); 00053 00054 /** fmat_t buffer deletion function 00055 00056 \param s buffer to delete as returned by new_fmat() 00057 00058 */ 00059 void del_fmat(fmat_t *s); 00060 00061 /** read sample value in a buffer 00062 00063 \param s vector to read from 00064 \param channel channel to read from 00065 \param position sample position to read from 00066 00067 */ 00068 smpl_t fmat_get_sample(fmat_t *s, uint_t channel, uint_t position); 00069 00070 /** write sample value in a buffer 00071 00072 \param s vector to write to 00073 \param data value to write in s->data[channel][position] 00074 \param channel channel to write to 00075 \param position sample position to write to 00076 00077 */ 00078 void fmat_set_sample(fmat_t *s, smpl_t data, uint_t channel, uint_t position); 00079 00080 /** read channel vector from a buffer 00081 00082 \param s vector to read from 00083 \param channel channel to read from 00084 \param output ::fvec_t to output to 00085 00086 */ 00087 void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); 00088 00089 /** get vector buffer from an fmat data 00090 00091 \param s vector to read from 00092 \param channel channel to read from 00093 00094 */ 00095 smpl_t * fmat_get_channel_data (fmat_t *s, uint_t channel); 00096 00097 /** read data from a buffer 00098 00099 \param s vector to read from 00100 00101 */ 00102 smpl_t ** fmat_get_data(fmat_t *s); 00103 00104 /** print out fmat data 00105 00106 \param s vector to print out 00107 00108 */ 00109 void fmat_print(fmat_t *s); 00110 00111 /** set all elements to a given value 00112 00113 \param s vector to modify 00114 \param val value to set elements to 00115 00116 */ 00117 void fmat_set(fmat_t *s, smpl_t val); 00118 00119 /** set all elements to zero 00120 00121 \param s vector to modify 00122 00123 */ 00124 void fmat_zeros(fmat_t *s); 00125 00126 /** set all elements to ones 00127 00128 \param s vector to modify 00129 00130 */ 00131 void fmat_ones(fmat_t *s); 00132 00133 /** revert order of vector elements 00134 00135 \param s vector to revert 00136 00137 */ 00138 void fmat_rev(fmat_t *s); 00139 00140 /** apply weight to vector 00141 00142 If the weight vector is longer than s, only the first elements are used. If 00143 the weight vector is shorter than s, the last elements of s are not weighted. 00144 00145 \param s vector to weight 00146 \param weight weighting coefficients 00147 00148 */ 00149 void fmat_weight(fmat_t *s, fmat_t *weight); 00150 00151 /** make a copy of a matrix 00152 00153 \param s source vector 00154 \param t vector to copy to 00155 00156 */ 00157 void fmat_copy(fmat_t *s, fmat_t *t); 00158 00159 #ifdef __cplusplus 00160 } 00161 #endif 00162 00163 #endif /* _AUBIO__FMAT_H */