Changes in / [8eecb9f:c5de692]
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/gen_code.py
r8eecb9f rc5de692 463 463 """.format(**self.__dict__) 464 464 for set_param in self.prototypes['set']: 465 params = get_params_types_names(set_param)[1:] 466 param = self.shortname.split('_set_')[-1] 467 paramdecls = "".join([""" 468 {0} {1};""".format(p['type'], p['name']) for p in params]) 465 params = get_params_types_names(set_param)[1] 466 paramtype = params['type'] 469 467 method_name = get_name(set_param) 470 468 param = method_name.split('aubio_'+self.shortname+'_set_')[-1] 471 refs = ", ".join(["&%s" % p['name'] for p in params]) 472 paramlist = ", ".join(["%s" % p['name'] for p in params]) 473 if len(params): 474 paramlist = "," + paramlist 475 pyparamtypes = ''.join([pyargparse_chars[p['type']] for p in params]) 469 pyparamtype = pyargparse_chars[paramtype] 476 470 out += """ 477 471 static PyObject * … … 479 473 {{ 480 474 uint_t err = 0; 481 {paramdecls} 482 """.format(param = param, paramdecls = paramdecls, **self.__dict__) 483 484 if len(refs) and len(pyparamtypes): 485 out += """ 486 487 if (!PyArg_ParseTuple (args, "{pyparamtypes}", {refs})) {{ 475 {paramtype} {param}; 476 477 if (!PyArg_ParseTuple (args, "{pyparamtype}", &{param})) {{ 488 478 return NULL; 489 479 }} 490 """.format(pyparamtypes = pyparamtypes, refs = refs) 491 492 out += """ 493 err = aubio_{shortname}_set_{param} (self->o {paramlist}); 480 err = aubio_{shortname}_set_{param} (self->o, {param}); 494 481 495 482 if (err > 0) {{ … … 506 493 Py_RETURN_NONE; 507 494 }} 508 """.format(param = param, refs = refs, paramdecls = paramdecls, 509 pyparamtypes = pyparamtypes, paramlist = paramlist, **self.__dict__) 495 """.format(param = param, paramtype = paramtype, pyparamtype = pyparamtype, **self.__dict__) 510 496 return out 511 497 -
src/mathutils.c
r8eecb9f rc5de692 388 388 } 389 389 390 void391 fvec_mul (fvec_t *o, smpl_t val)392 {393 uint_t j;394 for (j = 0; j < o->length; j++) {395 o->data[j] *= val;396 }397 }398 399 390 void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp, 400 391 uint_t post, uint_t pre) { -
src/mathutils.h
r8eecb9f rc5de692 193 193 */ 194 194 void fvec_add (fvec_t * v, smpl_t c); 195 196 /** multiply each elements of a vector by a scalar197 198 \param v vector to add constant to199 \param s constant to scale v with200 201 */202 void fvec_mul (fvec_t * v, smpl_t s);203 195 204 196 /** remove the minimum value of the vector to each elements -
src/spectral/filterbank_mel.h
r8eecb9f rc5de692 56 56 57 57 \param fb filterbank object 58 \param samplerate audio sampling rate , in Hz58 \param samplerate audio sampling rate 59 59 60 60 The filter coefficients are built to match exactly Malcolm Slaney's Auditory -
src/spectral/mfcc.c
r8eecb9f rc5de692 52 52 fvec_t *output; 53 53 #endif 54 smpl_t scale;55 54 }; 56 55 … … 76 75 /* filterbank allocation */ 77 76 mfcc->fb = new_aubio_filterbank (n_filters, mfcc->win_s); 78 if (n_filters == 40) 79 aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate); 80 else 81 aubio_filterbank_set_mel_coeffs(mfcc->fb, samplerate, 82 0, samplerate/2.); 77 aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate); 83 78 84 79 /* allocating buffers */ … … 102 97 mfcc->output = new_fvec (n_filters); 103 98 #endif 104 105 mfcc->scale = 1.;106 99 107 100 return mfcc; … … 135 128 fvec_t tmp; 136 129 #endif 137 138 130 /* compute filterbank */ 139 131 aubio_filterbank_do (mf->fb, in, mf->in_dct); … … 142 134 fvec_log10 (mf->in_dct); 143 135 144 if (mf->scale != 1) fvec_mul (mf->in_dct, mf->scale); 136 /* raise power */ 137 //fvec_pow (mf->in_dct, 3.); 145 138 146 139 /* compute mfccs */ … … 158 151 return; 159 152 } 160 161 uint_t aubio_mfcc_set_power (aubio_mfcc_t *mf, smpl_t power)162 {163 return aubio_filterbank_set_power(mf->fb, power);164 }165 166 uint_t aubio_mfcc_get_power (aubio_mfcc_t *mf)167 {168 return aubio_filterbank_get_power(mf->fb);169 }170 171 uint_t aubio_mfcc_set_scale (aubio_mfcc_t *mf, smpl_t scale)172 {173 mf->scale = scale;174 return AUBIO_OK;175 }176 177 uint_t aubio_mfcc_get_scale (aubio_mfcc_t *mf)178 {179 return mf->scale;180 }181 182 uint_t aubio_mfcc_set_mel_coeffs (aubio_mfcc_t *mf, smpl_t freq_min,183 smpl_t freq_max)184 {185 return aubio_filterbank_set_mel_coeffs(mf->fb, mf->samplerate,186 freq_min, freq_max);187 }188 189 uint_t aubio_mfcc_set_mel_coeffs_htk (aubio_mfcc_t *mf, smpl_t freq_min,190 smpl_t freq_max)191 {192 return aubio_filterbank_set_mel_coeffs_htk(mf->fb, mf->samplerate,193 freq_min, freq_max);194 }195 196 uint_t aubio_mfcc_set_mel_coeffs_slaney (aubio_mfcc_t *mf)197 {198 return aubio_filterbank_set_mel_coeffs_slaney (mf->fb, mf->samplerate);199 } -
src/spectral/mfcc.h
r8eecb9f rc5de692 74 74 void aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out); 75 75 76 /** set power parameter77 78 \param mf mfcc object, as returned by new_aubio_mfcc()79 \param power Raise norm of the input spectrum norm to this power before80 computing filterbank. Defaults to `1`.81 82 See aubio_filterbank_set_power().83 84 */85 uint_t aubio_mfcc_set_power (aubio_mfcc_t *mf, smpl_t power);86 87 /** get power parameter88 89 \param mf mfcc object, as returned by new_aubio_mfcc()90 \return current power parameter. Defaults to `1`.91 92 See aubio_filterbank_get_power().93 94 */95 uint_t aubio_mfcc_get_power (aubio_mfcc_t *mf);96 97 /** set scaling parameter98 99 \param mf mfcc object, as returned by new_aubio_mfcc()100 \param scale Scaling value to apply.101 102 Scales the output of the filterbank after taking its logarithm and before103 computing the DCT. Defaults to `1`.104 105 */106 uint_t aubio_mfcc_set_scale (aubio_mfcc_t *mf, smpl_t scale);107 108 /** get scaling parameter109 110 \param mf mfcc object, as returned by new_aubio_mfcc()111 \return current scaling parameter. Defaults to `1`.112 113 */114 uint_t aubio_mfcc_get_scale (aubio_mfcc_t *mf);115 116 /** Mel filterbank initialization117 118 \param mf mfcc object119 \param fmin start frequency, in Hz120 \param fmax end frequency, in Hz121 122 The filterbank will be initialized with bands linearly spaced in the mel123 scale, from `fmin` to `fmax`.124 125 See also126 --------127 128 aubio_filterbank_set_mel_coeffs()129 130 */131 uint_t aubio_mfcc_set_mel_coeffs (aubio_mfcc_t *mf,132 smpl_t fmin, smpl_t fmax);133 134 /** Mel filterbank initialization135 136 \param mf mfcc object137 \param fmin start frequency, in Hz138 \param fmax end frequency, in Hz139 140 The bank of filters will be initalized to to cover linearly spaced bands in141 the Htk mel scale, from `fmin` to `fmax`.142 143 See also144 --------145 146 aubio_filterbank_set_mel_coeffs_htk()147 148 */149 uint_t aubio_mfcc_set_mel_coeffs_htk (aubio_mfcc_t *mf,150 smpl_t fmin, smpl_t fmax);151 152 /** Mel filterbank initialization (Auditory Toolbox's parameters)153 154 \param mf mfcc object155 \param samplerate audio sampling rate, in Hz156 157 The filter coefficients are built to match exactly Malcolm Slaney's Auditory158 Toolbox implementation. The number of filters should be 40.159 160 This is the default filterbank when `mf` was created with `n_filters = 40`.161 162 See also163 --------164 165 aubio_filterbank_set_mel_coeffs_slaney()166 167 */168 uint_t aubio_mfcc_set_mel_coeffs_slaney (aubio_mfcc_t *mf);169 170 76 #ifdef __cplusplus 171 77 }
Note: See TracChangeset
for help on using the changeset viewer.