Changeset a54502c for src/temporal/filter.c
- Timestamp:
- Sep 29, 2009, 8:08:10 PM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 899dfd3
- Parents:
- 6481c0c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/filter.c
r6481c0c ra54502c 1 1 /* 2 Copyright (C) 2003 Paul Brossier2 Copyright (C) 2003-2009 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 =order-1; 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 }
Note: See TracChangeset
for help on using the changeset viewer.