- Timestamp:
- Dec 1, 2007, 10:59:25 PM (17 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:
- 6913434
- Parents:
- 2b6144dd
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchdetection.c
r2b6144dd ra7667ce 22 22 #include "spectral/phasevoc.h" 23 23 #include "mathutils.h" 24 #include "temporal/ filter.h"24 #include "temporal/cdesign.h" 25 25 #include "pitch/pitchmcomb.h" 26 26 #include "pitch/pitchyin.h" … … 103 103 p->fftgrain = new_cvec(bufsize, channels); 104 104 p->mcomb = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate); 105 p->filter = new_aubio_cdsgn_filter(samplerate );105 p->filter = new_aubio_cdsgn_filter(samplerate, channels); 106 106 p->callback = aubio_pitchdetection_mcomb; 107 107 break; -
src/temporal/adesign.c
r2b6144dd ra7667ce 26 26 #include "temporal/adesign.h" 27 27 28 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate ) {29 aubio_filter_t * f = new_aubio_filter(samplerate, 7 );30 lsmp_t * a = f->a ;31 lsmp_t * b = f->b ;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 32 /* uint_t l; */ 33 33 /* for now, 44100, adsgn */ … … 52 52 } 53 53 */ 54 f->a = a;55 f->b = b;54 f->a->data[0] = a; 55 f->b->data[0] = b; 56 56 return f; 57 57 } -
src/temporal/adesign.h
r2b6144dd ra7667ce 23 23 24 24 */ 25 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate );25 aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate, uint_t channels); 26 26 27 27 #define aubio_adsgn_filter_do aubio_filter_do -
src/temporal/cdesign.c
r2b6144dd ra7667ce 26 26 #include "temporal/adesign.h" 27 27 28 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate ) {29 aubio_filter_t * f = new_aubio_filter(samplerate, 5 );30 lsmp_t * a = f->a ;31 lsmp_t * b = f->b ;28 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels) { 29 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 32 /* uint_t l; */ 33 33 /* for now, 44100, cdsgn */ … … 48 48 } 49 49 */ 50 f->a = a;51 f->b = b;50 f->a->data[0] = a; 51 f->b->data[0] = b; 52 52 return f; 53 53 } -
src/temporal/cdesign.h
r2b6144dd ra7667ce 25 25 26 26 */ 27 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate );27 aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate, uint_t channels); 28 28 29 29 #define aubio_cdsgn_filter_do aubio_filter_do -
src/temporal/filter.c
r2b6144dd ra7667ce 24 24 #include "aubio_priv.h" 25 25 #include "fvec.h" 26 #include "lvec.h" 26 27 #include "mathutils.h" 27 28 #include "temporal/filter.h" 28 29 #include "temporal/filter_priv.h" 29 30 30 /* bug: mono only */31 31 void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { 32 uint_t i,j,l, order = f->order; 33 lsmp_t *x = f->x; 34 lsmp_t *y = f->y; 35 lsmp_t *a = f->a; 36 lsmp_t *b = f->b; 37 i=0;//for (i=0;i<in->channels;i++) { 38 for (j = 0; j < in->length; j++) { 39 /* new input */ 40 //AUBIO_DBG("befor %f\t", in->data[i][j]); 41 x[0] = in->data[i][j]; 42 y[0] = b[0] * x[0]; 43 for (l=1;l<order; l++) { 44 y[0] += b[l] * x[l]; 45 y[0] -= a[l] * y[l]; 46 } /* + 1e-37; for denormal ? */ 47 /* new output */ 48 in->data[i][j] = y[0]; 49 //AUBIO_DBG("after %f\n", in->data[i][j]); 50 /* store states for next sample */ 51 for (l=order-1; l>0; l--){ 52 x[l] = x[l-1]; 53 y[l] = y[l-1]; 54 } 55 } 56 /* store states for next buffer */ 57 f->x = x; 58 f->y = y; 59 //} 32 aubio_filter_do_outplace(f, in, in); 60 33 } 61 34 62 35 void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) { 63 36 uint_t i,j,l, order = f->order; 64 lsmp_t *x = f->x;65 lsmp_t *y = f->y;66 lsmp_t *a = f->a ;67 lsmp_t *b = f->b ;37 lsmp_t *x; 38 lsmp_t *y; 39 lsmp_t *a = f->a->data[0]; 40 lsmp_t *b = f->b->data[0]; 68 41 69 i=0; // works in mono only !!! 70 //for (i=0;i<in->channels;i++) { 71 for (j = 0; j < in->length; j++) { 72 /* new input */ 73 x[0] = in->data[i][j]; 74 y[0] = b[0] * x[0]; 75 for (l=1;l<order; l++) { 76 y[0] += b[l] * x[l]; 77 y[0] -= a[l] * y[l]; 42 for (i = 0; i < in->channels; i++) { 43 x = f->x->data[i]; 44 y = f->y->data[i]; 45 for (j = 0; j < in->length; j++) { 46 /* new input */ 47 if (ISDENORMAL(in->data[i][j])) { 48 x[0] = y[0] = 0.; 49 } else { 50 x[0] = in->data[i][j]; 51 y[0] = b[0] * x[0]; 52 for (l=1;l<order; l++) { 53 y[0] += b[l] * x[l]; 54 y[0] -= a[l] * y[l]; 55 } 56 } 57 /* new output */ 58 out->data[i][j] = y[0]; 59 /* store for next sample */ 60 for (l=order-1; l>0; l--){ 61 x[l] = x[l-1]; 62 y[l] = y[l-1]; 63 } 78 64 } 79 // + 1e-37; 80 /* new output */ 81 out->data[i][j] = y[0]; 82 /* store for next sample */ 83 for (l=order-1; l>0; l--){ 84 x[l] = x[l-1]; 85 y[l] = y[l-1]; 86 } 65 /* store for next run */ 66 f->x->data[i] = x; 67 f->y->data[i] = y; 87 68 } 88 /* store for next run */89 f->x = x;90 f->y = y;91 //}92 69 } 93 70 … … 126 103 } 127 104 128 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order ) {105 aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order, uint_t channels) { 129 106 aubio_filter_t * f = AUBIO_NEW(aubio_filter_t); 130 lsmp_t * x = f->x;131 lsmp_t * y = f->y;132 lsmp_t * a = f->a;133 lsmp_t * b = f->b;134 uint_t l;107 f->x = new_lvec(order, channels); 108 f->y = new_lvec(order, channels); 109 f->a = new_lvec(order, 1); 110 f->b = new_lvec(order, 1); 111 f->a->data[0][1] = 1.; 135 112 f->order = order; 136 a = AUBIO_ARRAY(lsmp_t,f->order);137 b = AUBIO_ARRAY(lsmp_t,f->order);138 x = AUBIO_ARRAY(lsmp_t,f->order);139 y = AUBIO_ARRAY(lsmp_t,f->order);140 /* initial states to zeros */141 for (l=0; l<f->order; l++){142 x[l] = 0.;143 y[l] = 0.;144 }145 f->x = x;146 f->y = y;147 f->a = a;148 f->b = b;149 113 return f; 150 114 } -
src/temporal/filter.h
r2b6144dd ra7667ce 69 69 \param samplerate signal sampling rate 70 70 \param order order of the filter (number of coefficients) 71 \param channels number of channels to allocate 71 72 72 73 */ 73 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order );74 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels); 74 75 /** delete a filter object 75 76 -
src/temporal/filter_priv.h
r2b6144dd ra7667ce 18 18 */ 19 19 20 #include "lvec.h" 20 21 struct _aubio_filter_t { 21 22 uint_t order; 22 l smp_t * a;23 l smp_t * b;24 l smp_t * y;25 l smp_t * x;23 lvec_t * a; 24 lvec_t * b; 25 lvec_t * y; 26 lvec_t * x; 26 27 }; 27 28
Note: See TracChangeset
for help on using the changeset viewer.