Changeset edd3dac


Ignore:
Timestamp:
Nov 9, 2018, 5:32:31 PM (6 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
Children:
e33d960
Parents:
98c712e
Message:

[filterbank] remove warning when list starts with 0, add some sanity checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/filterbank_mel.c

    r98c712e redd3dac  
    5555  }
    5656
    57   if (freqs->data[freqs->length - 1] > samplerate / 2) {
    58     AUBIO_WRN ("Nyquist frequency is %fHz, but highest frequency band ends at \
    59 %fHz\n", samplerate / 2, freqs->data[freqs->length - 1]);
     57  for (fn = 0; fn < freqs->length; fn++) {
     58    if (freqs->data[fn] < 0) {
     59      AUBIO_ERR("filterbank_mel: freqs must contain only positive values.\n");
     60      return AUBIO_FAIL;
     61    } else if (freqs->data[fn] > samplerate / 2) {
     62      AUBIO_WRN("filterbank_mel: freqs should contain only "
     63          "values > samplerate / 2.\n");
     64    } else if (fn > 0 && freqs->data[fn] < freqs->data[fn-1]) {
     65      AUBIO_ERR("filterbank_mel: freqs should be a list of frequencies "
     66          "sorted from low to high, but freq[%d] < freq[%d-1]\n", fn, fn);
     67      return AUBIO_FAIL;
     68    }
    6069  }
    6170
     
    92101  /* zeroing of all filters */
    93102  fmat_zeros (filters);
    94 
    95   if (fft_freqs->data[1] >= lower_freqs->data[0]) {
    96     /* - 1 to make sure we don't miss the smallest power of two */
    97     uint_t min_win_s =
    98         (uint_t) FLOOR (samplerate / lower_freqs->data[0]) - 1;
    99     AUBIO_WRN ("Lowest frequency bin (%.2fHz) is higher than lowest frequency \
    100 band (%.2f-%.2fHz). Consider increasing the window size from %d to %d.\n",
    101         fft_freqs->data[1], lower_freqs->data[0],
    102         upper_freqs->data[0], (win_s - 1) * 2,
    103         aubio_next_power_of_two (min_win_s));
    104   }
    105103
    106104  /* building each filter table */
     
    161159  del_fvec (fft_freqs);
    162160
    163   return 0;
     161  return AUBIO_OK;
    164162}
    165163
Note: See TracChangeset for help on using the changeset viewer.