Changeset a54502c
 Timestamp:
 Sep 29, 2009, 8:08:10 PM (12 years ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
 Children:
 899dfd3
 Parents:
 6481c0c
 Location:
 src/temporal
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/temporal/filter.c
r6481c0c ra54502c 1 1 /* 2 Copyright (C) 2003 Paul Brossier2 Copyright (C) 20032009 Paul Brossier <piem@aubio.org> 3 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 4 This file is part of aubio. 8 5 9 This program is distributed in the hope that it will be useful,10 but WITHOUT ANY WARRANTY; without even the implied warranty of11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 GNU General Public License for more details.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. 13 10 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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/>. 17 18 18 19 */ … … 28 29 #include "temporal/filter.h" 29 30 30 struct _aubio_filter_t { 31 struct _aubio_filter_t 32 { 31 33 uint_t order; 32 34 uint_t samplerate; 33 lvec_t * 34 lvec_t * 35 lvec_t * 36 lvec_t * 35 lvec_t *a; 36 lvec_t *b; 37 lvec_t *y; 38 lvec_t *x; 37 39 }; 38 40 39 void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) { 40 fvec_copy(in, out); 41 void 42 aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out) 43 { 44 fvec_copy (in, out); 41 45 aubio_filter_do (f, out); 42 46 } 43 47 44 void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { 45 uint_t i,j,l, order = f>order; 48 void 49 aubio_filter_do (aubio_filter_t * f, fvec_t * in) 50 { 51 uint_t i, j, l, order = f>order; 46 52 lsmp_t *x; 47 53 lsmp_t *y; … … 54 60 for (j = 0; j < in>length; j++) { 55 61 /* new input */ 56 x[0] = KILL_DENORMAL (in>data[i][j]);62 x[0] = KILL_DENORMAL (in>data[i][j]); 57 63 y[0] = b[0] * x[0]; 58 for (l =1;l<order; l++) {64 for (l = 1; l < order; l++) { 59 65 y[0] += b[l] * x[l]; 60 66 y[0] = a[l] * y[l]; … … 63 69 in>data[i][j] = y[0]; 64 70 /* store for next sample */ 65 for (l =order1; l>0; l){66 x[l] = x[l 1];67 y[l] = y[l 1];71 for (l = order  1; l > 0; l) { 72 x[l] = x[l  1]; 73 y[l] = y[l  1]; 68 74 } 69 75 } … … 108 114 } 109 115 110 lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f ) { 116 lvec_t * 117 aubio_filter_get_feedback (aubio_filter_t * f) 118 { 111 119 return f>a; 112 120 } 113 121 114 lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f ) { 122 lvec_t * 123 aubio_filter_get_feedforward (aubio_filter_t * f) 124 { 115 125 return f>b; 116 126 } 117 127 118 uint_t aubio_filter_get_order ( aubio_filter_t *f ) { 128 uint_t 129 aubio_filter_get_order (aubio_filter_t * f) 130 { 119 131 return f>order; 120 132 } 121 133 122 uint_t aubio_filter_get_samplerate ( aubio_filter_t *f ) { 134 uint_t 135 aubio_filter_get_samplerate (aubio_filter_t * f) 136 { 123 137 return f>samplerate; 124 138 } 125 139 126 aubio_filter_t * new_aubio_filter(uint_t samplerate, 127 uint_t order, uint_t channels) { 128 aubio_filter_t * f = AUBIO_NEW(aubio_filter_t); 129 f>x = new_lvec(order, channels); 130 f>y = new_lvec(order, channels); 131 f>a = new_lvec(order, 1); 132 f>b = new_lvec(order, 1); 133 f>samplerate = samplerate; 140 aubio_filter_t * 141 new_aubio_filter (uint_t samplerate, uint_t order, uint_t channels) 142 { 143 aubio_filter_t *f = AUBIO_NEW (aubio_filter_t); 144 f>x = new_lvec (order, channels); 145 f>y = new_lvec (order, channels); 146 f>a = new_lvec (order, 1); 147 f>b = new_lvec (order, 1); 148 f>samplerate = samplerate; 134 149 f>order = order; 135 150 /* set default to identity */ … … 138 153 } 139 154 140 void del_aubio_filter(aubio_filter_t * f) { 141 del_lvec(f>a); 142 del_lvec(f>b); 143 del_lvec(f>x); 144 del_lvec(f>y); 145 AUBIO_FREE(f); 155 void 156 del_aubio_filter (aubio_filter_t * f) 157 { 158 del_lvec (f>a); 159 del_lvec (f>b); 160 del_lvec (f>x); 161 del_lvec (f>y); 162 AUBIO_FREE (f); 146 163 return; 147 164 } 
src/temporal/filter.h
r6481c0c ra54502c 1 1 /* 2 Copyright (C) 2003 Paul Brossier 2 Copyright (C) 20032009 Paul Brossier <piem@aubio.org> 3 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 4 This file is part of aubio. 8 5 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details.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. 13 10 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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/>. 17 18 18 19 */ … … 73 74 74 75 */ 75 void aubio_filter_do (aubio_filter_t * f, fvec_t * in);76 void aubio_filter_do (aubio_filter_t * f, fvec_t * in); 76 77 77 78 /** filter input vector (outofplace) … … 82 83 83 84 */ 84 void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out);85 void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out); 85 86 86 87 /** filter input vector forward and backward … … 91 92 92 93 */ 93 void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp);94 void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp); 94 95 95 96 /** returns a pointer to feedback coefficients \f$ a_i \f$ … … 100 101 101 102 */ 102 lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f);103 lvec_t *aubio_filter_get_feedback (aubio_filter_t * f); 103 104 104 105 /** returns a pointer to feedforward coefficients \f$ b_i \f$ … … 109 110 110 111 */ 111 lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f);112 lvec_t *aubio_filter_get_feedforward (aubio_filter_t * f); 112 113 113 114 /** get order of the filter … … 118 119 119 120 */ 120 uint_t aubio_filter_get_order ( aubio_filter_t *f);121 uint_t aubio_filter_get_order (aubio_filter_t * f); 121 122 122 123 /** get sampling rate of the filter … … 127 128 128 129 */ 129 uint_t aubio_filter_get_samplerate ( aubio_filter_t *f);130 uint_t aubio_filter_get_samplerate (aubio_filter_t * f); 130 131 131 132 /** create new filter object … … 141 142 142 143 */ 143 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels); 144 aubio_filter_t *new_aubio_filter (uint_t samplerate, uint_t order, 145 uint_t channels); 144 146 145 147 /** delete a filter object … … 148 150 149 151 */ 150 void del_aubio_filter (aubio_filter_t * f);152 void del_aubio_filter (aubio_filter_t * f); 151 153 152 154 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.