Changeset a4364b8 for src/temporal/adesign.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/adesign.c
rd9c45df ra4364b8 1 1 /* 2 Copyright (C) 2003-2007 Paul Brossier3 2 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. 3 Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org> 8 4 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. 5 This file is part of aubio. 13 6 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. 7 aubio is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 aubio is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with aubio. If not, see <http://www.gnu.org/licenses/>. 17 19 18 20 */ 19 20 21 21 22 #include "aubio_priv.h" 22 23 #include "types.h" 23 24 #include "fvec.h" 25 #include "lvec.h" 24 26 #include "temporal/filter.h" 25 #include "temporal/filter_priv.h"26 27 #include "temporal/adesign.h" 27 28 28 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels) { 29 aubio_filter_t * f = new_aubio_filter(samplerate, 7, 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, adsgn */ 34 a[0] = 1.00000000000000000000000000000000000000000000000000000; 35 a[1] = -4.01957618111583236952810693765059113502502441406250000; 36 a[2] = 6.18940644292069386267485242569819092750549316406250000; 37 a[3] = -4.45319890354411640487342083360999822616577148437500000; 38 a[4] = 1.42084294962187751565352300531230866909027099609375000; 39 a[5] = -0.14182547383030480458998567883099894970655441284179688; 40 a[6] = 0.00435117723349511334451911181986361043527722358703613; 41 b[0] = 0.25574112520425740235907596797915175557136535644531250; 42 b[1] = -0.51148225040851391653973223583307117223739624023437500; 43 b[2] = -0.25574112520426162120656954357400536537170410156250000; 44 b[3] = 1.02296450081703405032840237254276871681213378906250000; 45 b[4] = -0.25574112520426051098354491841746494174003601074218750; 46 b[5] = -0.51148225040851369449512731080176308751106262207031250; 47 b[6] = 0.25574112520425729133677350546349771320819854736328125; 48 /* DBG: filter coeffs at creation time */ 49 /* 50 for (l=0; l<f->order; l++){ 51 AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); 29 void aubio_filter_set_adsgn (aubio_filter_t * f) { 30 31 uint_t samplerate = aubio_filter_get_samplerate (f); 32 lvec_t *bs = aubio_filter_get_feedforward (f); 33 lvec_t *as = aubio_filter_get_feedback (f); 34 lsmp_t *b = bs->data[0], *a = as->data[0]; 35 uint_t order = aubio_filter_get_order (f); 36 37 if ( order != 7 ) { 38 AUBIO_ERROR ( "order of A-weighting filter must be 7, not %d\n", order ); 39 return; 52 40 } 53 */ 54 f->a->data[0] = a; 55 f->b->data[0] = b; 41 42 /* select coefficients according to sampling frequency */ 43 switch ( samplerate ) { 44 45 case 8000: 46 b[0] = 6.306209468238731519207362907764036208391189575195312500e-01; 47 b[1] = -1.261241893647746525886077506584115326404571533203125000e+00; 48 b[2] = -6.306209468238730408984338282607495784759521484375000000e-01; 49 b[3] = 2.522483787295493051772155013168230652809143066406250000e+00; 50 b[4] = -6.306209468238730408984338282607495784759521484375000000e-01; 51 b[5] = -1.261241893647746525886077506584115326404571533203125000e+00; 52 b[6] = 6.306209468238731519207362907764036208391189575195312500e-01; 53 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 54 a[1] = -2.128467193009123015201566886389628052711486816406250000e+00; 55 a[2] = 2.948668980101234460278192273108288645744323730468750000e-01; 56 a[3] = 1.824183830735050637628091863007284700870513916015625000e+00; 57 a[4] = -8.056628943119792385374466903158463537693023681640625000e-01; 58 a[5] = -3.947497982842933517133587884018197655677795410156250000e-01; 59 a[6] = 2.098548546080332977137317129745497368276119232177734375e-01; 60 break; 61 62 case 16000: 63 b[0] = 5.314898298235570806014038680586963891983032226562500000e-01; 64 b[1] = -1.062979659647114161202807736117392778396606445312500000e+00; 65 b[2] = -5.314898298235570806014038680586963891983032226562500000e-01; 66 b[3] = 2.125959319294228322405615472234785556793212890625000000e+00; 67 b[4] = -5.314898298235570806014038680586963891983032226562500000e-01; 68 b[5] = -1.062979659647114161202807736117392778396606445312500000e+00; 69 b[6] = 5.314898298235570806014038680586963891983032226562500000e-01; 70 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 71 a[1] = -2.867832572992162987191022693878039717674255371093750000e+00; 72 a[2] = 2.221144410202312347024644623161293566226959228515625000e+00; 73 a[3] = 4.552683347886614662058946123579517006874084472656250000e-01; 74 a[4] = -9.833868636162828025248927588108927011489868164062500000e-01; 75 a[5] = 5.592994142413361402521587706360151059925556182861328125e-02; 76 a[6] = 1.188781038285612462468421313133148942142724990844726562e-01; 77 break; 78 79 case 22050: 80 b[0] = 4.492998504299193784916610638902056962251663208007812500e-01; 81 b[1] = -8.985997008598388680056245902960654348134994506835937500e-01; 82 b[2] = -4.492998504299192674693586013745516538619995117187500000e-01; 83 b[3] = 1.797199401719677958055854105623438954353332519531250000e+00; 84 b[4] = -4.492998504299192674693586013745516538619995117187500000e-01; 85 b[5] = -8.985997008598388680056245902960654348134994506835937500e-01; 86 b[6] = 4.492998504299193784916610638902056962251663208007812500e-01; 87 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 88 a[1] = -3.229078805225074955131958631682209670543670654296875000e+00; 89 a[2] = 3.354494881236033787530459449044428765773773193359375000e+00; 90 a[3] = -7.317843680657351024265722116979304701089859008789062500e-01; 91 a[4] = -6.271627581807257545420952737913466989994049072265625000e-01; 92 a[5] = 1.772142005020879151899748649157118052244186401367187500e-01; 93 a[6] = 5.631716697383508385410522123493137769401073455810546875e-02; 94 break; 95 96 case 44100: 97 b[0] = 2.55741125204257513381378430494805797934532165527343750e-01; 98 b[1] = -5.114822504085150267627568609896115958690643310546875000e-01; 99 b[2] = -2.557411252042575133813784304948057979345321655273437500e-01; 100 b[3] = 1.022964500817030053525513721979223191738128662109375000e+00; 101 b[4] = -2.557411252042575133813784304948057979345321655273437500e-01; 102 b[5] = -5.114822504085150267627568609896115958690643310546875000e-01; 103 b[6] = 2.557411252042575133813784304948057979345321655273437500e-01; 104 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 105 a[1] = -4.019576181115832369528106937650591135025024414062500000e+00; 106 a[2] = 6.189406442920693862674852425698190927505493164062500000e+00; 107 a[3] = -4.453198903544116404873420833609998226165771484375000000e+00; 108 a[4] = 1.420842949621876627475103305187076330184936523437500000e+00; 109 a[5] = -1.418254738303044160119270600262098014354705810546875000e-01; 110 a[6] = 4.351177233495117681327801761881346465088427066802978516e-03; 111 112 case 96000: 113 b[0] = 9.951898975972744976203898659150581806898117065429687500e-02; 114 b[1] = -1.990379795194548995240779731830116361379623413085937500e-01; 115 b[2] = -9.951898975972744976203898659150581806898117065429687500e-02; 116 b[3] = 3.980759590389097990481559463660232722759246826171875000e-01; 117 b[4] = -9.951898975972744976203898659150581806898117065429687500e-02; 118 b[5] = -1.990379795194548995240779731830116361379623413085937500e-01; 119 b[6] = 9.951898975972744976203898659150581806898117065429687500e-02; 120 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 121 a[1] = -4.802203044225376693532325589330866932868957519531250000e+00; 122 a[2] = 9.401807218627226347962277941405773162841796875000000000e+00; 123 a[3] = -9.566143943569164420637207513209432363510131835937500000e+00; 124 a[4] = 5.309775930392619081032989925006404519081115722656250000e+00; 125 a[5] = -1.517333360452622237346531619550660252571105957031250000e+00; 126 a[6] = 1.740971994228911745583587844521389342844486236572265625e-01; 127 break; 128 129 case 192000: 130 b[0] = 3.433213424548713782469278044118254911154508590698242188e-02; 131 b[1] = -6.866426849097426177159775306790834292769432067871093750e-02; 132 b[2] = -3.433213424548714476358668434841092675924301147460937500e-02; 133 b[3] = 1.373285369819485235431955061358166858553886413574218750e-01; 134 b[4] = -3.433213424548714476358668434841092675924301147460937500e-02; 135 b[5] = -6.866426849097426177159775306790834292769432067871093750e-02; 136 b[6] = 3.433213424548713782469278044118254911154508590698242188e-02; 137 a[0] = 1.000000000000000000000000000000000000000000000000000000e+00; 138 a[1] = -5.305923689674640009172890131594613194465637207031250000e+00; 139 a[2] = 1.165952437466175695135461864992976188659667968750000000e+01; 140 a[3] = -1.357560092700591525272102444432675838470458984375000000e+01; 141 a[4] = 8.828906932824192921316353022120893001556396484375000000e+00; 142 a[5] = -3.039490120988216581565666274400427937507629394531250000e+00; 143 a[6] = 4.325834301870381537469256727490574121475219726562500000e-01; 144 break; 145 146 default: 147 AUBIO_ERROR ( "sampling rate of A-weighting filter is %d, should be one of\ 148 8000, 16000, 22050, 44100, 96000, 192000.\n", samplerate ); 149 break; 150 151 } 152 153 } 154 155 aubio_filter_t * new_aubio_filter_adsgn (uint_t samplerate, uint_t channels) { 156 aubio_filter_t * f = new_aubio_filter (samplerate, 7, channels); 157 aubio_filter_set_adsgn (f); 56 158 return f; 57 159 }
Note: See TracChangeset
for help on using the changeset viewer.