Changeset a4364b8 for src/temporal/cdesign.c
- Timestamp:
- Sep 29, 2009, 7:43:12 AM (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:
- c159aeb
- Parents:
- d9c45df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/temporal/cdesign.c
rd9c45df ra4364b8 1 1 /* 2 Copyright (C) 2003-2007 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 */ 19 20 20 21 21 #include "aubio_priv.h" 22 22 #include "types.h" 23 23 #include "fvec.h" 24 #include "lvec.h" 24 25 #include "temporal/filter.h" 25 #include "temporal/filter_priv.h" 26 #include "temporal/adesign.h" 26 #include "temporal/cdesign.h" 27 27 28 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels) { 28 void aubio_filter_set_cdsgn (aubio_filter_t * f) { 29 30 uint_t samplerate = aubio_filter_get_samplerate (f); 31 lvec_t * bs = aubio_filter_get_feedforward (f); 32 lvec_t * as = aubio_filter_get_feedback (f); 33 lsmp_t *b = bs->data[0], *a = as->data[0]; 34 uint_t order = aubio_filter_get_order (f); 35 36 if ( order != 5 ) { 37 AUBIO_ERROR ( "order of C-weighting filter must be 5, not %d\n", order ); 38 return; 39 } 40 41 /* select coefficients according to sampling frequency */ 42 switch ( samplerate ) { 43 44 case 8000: 45 b[0] = 6.782173932405135552414776611840352416038513183593750000e-01; 46 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 47 b[2] = -1.356434786481027110482955322368070483207702636718750000e+00; 48 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 49 b[4] = 6.782173932405135552414776611840352416038513183593750000e-01; 50 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 51 a[1] = -6.589092811505605773447769024642184376716613769531250000e-01; 52 a[2] = -1.179445664897062595599663836765103042125701904296875000e+00; 53 a[3] = 4.243329729632123736848825501510873436927795410156250000e-01; 54 a[4] = 4.147270002091348328754349950031610205769538879394531250e-01; 55 break; 56 57 case 16000: 58 b[0] = 4.971057193673903418229542694461997598409652709960937500e-01; 59 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 60 b[2] = -9.942114387347806836459085388923995196819305419921875000e-01; 61 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 62 b[4] = 4.971057193673903418229542694461997598409652709960937500e-01; 63 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 64 a[1] = -1.162322939286873690889478893950581550598144531250000000e+00; 65 a[2] = -4.771961355734982701548574368644040077924728393554687500e-01; 66 a[3] = 4.736145114694704227886745684372726827859878540039062500e-01; 67 a[4] = 1.660337524309875301131711466950946487486362457275390625e-01; 68 break; 69 70 case 22050: 71 b[0] = 4.033381299002754549754001800465630367398262023925781250e-01; 72 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 73 b[2] = -8.066762598005509099508003600931260734796524047851562500e-01; 74 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 75 b[4] = 4.033381299002754549754001800465630367398262023925781250e-01; 76 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 77 a[1] = -1.449545371157945350404361306573264300823211669921875000e+00; 78 a[2] = -1.030104190885922088583015465701464563608169555664062500e-02; 79 a[3] = 3.881857047554073680828423675848171114921569824218750000e-01; 80 a[4] = 7.171589940116777917022972133054281584918498992919921875e-02; 81 break; 82 83 case 44100: 84 b[0] = 2.170085619492190254220531642204150557518005371093750000e-01; 85 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 86 b[2] = -4.340171238984380508441063284408301115036010742187500000e-01; 87 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 88 b[4] = 2.170085619492190254220531642204150557518005371093750000e-01; 89 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 90 a[1] = -2.134674963687040794013682898366823792457580566406250000e+00; 91 a[2] = 1.279333533236062692139967111870646476745605468750000000e+00; 92 a[3] = -1.495598460893957093453821016737492755055427551269531250e-01; 93 a[4] = 4.908700174624683852664386307651511742733418941497802734e-03; 94 break; 95 96 case 96000: 97 b[0] = 8.182864044979756834585771230194950476288795471191406250e-02; 98 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 99 b[2] = -1.636572808995951366917154246038990095257759094238281250e-01; 100 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 101 b[4] = 8.182864044979756834585771230194950476288795471191406250e-02; 102 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 103 a[1] = -2.856378516857566829401093855267390608787536621093750000e+00; 104 a[2] = 2.897640237559524045707348705036565661430358886718750000e+00; 105 a[3] = -1.225265958339703198376469117647502571344375610351562500e+00; 106 a[4] = 1.840048283551226071530493300087982788681983947753906250e-01; 107 break; 108 109 case 192000: 110 b[0] = 2.784755468532278815940728122768632601946592330932617188e-02; 111 b[1] = 0.000000000000000000000000000000000000000000000000000000e+00; 112 b[2] = -5.569510937064557631881456245537265203893184661865234375e-02; 113 b[3] = 0.000000000000000000000000000000000000000000000000000000e+00; 114 b[4] = 2.784755468532278815940728122768632601946592330932617188e-02; 115 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 116 a[1] = -3.333298856144166322224009491037577390670776367187500000e+00; 117 a[2] = 4.111467536240339448738723149290308356285095214843750000e+00; 118 a[3] = -2.222889041651291641699117462849244475364685058593750000e+00; 119 a[4] = 4.447204118126878991112960193277103826403617858886718750e-01; 120 break; 121 122 default: 123 AUBIO_ERROR ( "sampling rate of C-weighting filter is %d, should be one of\ 124 8000, 16000, 22050, 44100, 96000, 192000.\n", samplerate ); 125 break; 126 127 } 128 129 } 130 131 aubio_filter_t * new_aubio_filter_cdsgn (uint_t samplerate, uint_t channels) { 29 132 aubio_filter_t * f = new_aubio_filter(samplerate, 5, channels); 30 lsmp_t * a = f->a->data[0]; 31 lsmp_t * b = f->b->data[0]; 32 /* uint_t l; */ 33 /* for now, 44100, cdsgn */ 34 a[0] = 1.000000000000000000000000000000000000000000000000000000000000; 35 a[1] = -2.134674963687040794013682898366823792457580566406250000000000; 36 a[2] = 1.279333533236063358273781886964570730924606323242187500000000; 37 a[3] = -0.149559846089396208945743182994192466139793395996093750000000; 38 a[4] = 0.004908700174624848651394604104325480875559151172637939453125; 39 b[0] = 0.217008561949218803377448239189106971025466918945312500000000; 40 b[1] = -0.000000000000000222044604925031308084726333618164062500000000; 41 b[2] = -0.434017123898438272888711253472138196229934692382812500000000; 42 b[3] = 0.000000000000000402455846426619245903566479682922363281250000; 43 b[4] = 0.217008561949218969910901932962588034570217132568359375000000; 44 /* DBG: filter coeffs at creation time */ 45 /* 46 for (l=0; l<f->order; l++){ 47 AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); 48 } 49 */ 50 f->a->data[0] = a; 51 f->b->data[0] = b; 133 aubio_filter_set_cdsgn (f); 52 134 return f; 53 135 }
Note: See TracChangeset
for help on using the changeset viewer.