Ignore:
Timestamp:
Feb 9, 2016, 3:24:53 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
1175883
Parents:
a33d406
Message:

src/temporal/filter.c: check parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/temporal/c_weighting.c

    ra33d406 r9590e81  
    3030{
    3131  uint_t order; lsmp_t *a, *b; lvec_t *as, *bs;
     32
     33  if ((sint_t)samplerate <= 0) {
     34    AUBIO_ERROR("aubio_filter: failed setting C-weighting with samplerate %d\n", samplerate);
     35    return AUBIO_FAIL;
     36  }
     37  if (f == NULL) {
     38    AUBIO_ERROR("aubio_filter: failed setting C-weighting with filter NULL\n");
     39    return AUBIO_FAIL;
     40  }
     41
     42  order = aubio_filter_get_order (f);
     43  if ( order != 5 ) {
     44    AUBIO_ERROR ("aubio_filter: order of C-weighting filter must be 5, not %d\n", order);
     45    return 1;
     46  }
     47
    3248  aubio_filter_set_samplerate (f, samplerate);
    3349  bs = aubio_filter_get_feedforward (f);
    3450  as = aubio_filter_get_feedback (f);
    3551  b = bs->data, a = as->data;
    36   order = aubio_filter_get_order (f);
    37 
    38   if ( order != 5 ) {
    39     AUBIO_ERROR ("order of C-weighting filter must be 5, not %d\n", order);
    40     return 1;
    41   }
    4252
    4353  /* select coefficients according to sampling frequency */
     
    200210aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) {
    201211  aubio_filter_t * f = new_aubio_filter(5);
    202   aubio_filter_set_c_weighting (f, samplerate);
     212  if (aubio_filter_set_c_weighting(f,samplerate) != AUBIO_OK) {
     213    del_aubio_filter(f);
     214    return NULL;
     215  }
    203216  return f;
    204217}
    205 
Note: See TracChangeset for help on using the changeset viewer.