Changeset 037319a for src/mathutils.c


Ignore:
Timestamp:
Mar 6, 2013, 9:28:36 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
c965b33
Parents:
e1bfde5
Message:

src/mathutils.c: freqtomidi and miditofreq to not produce infs and nans

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    re1bfde5 r037319a  
    399399aubio_freqtomidi (smpl_t freq)
    400400{
     401  if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
    401402  /* log(freq/A-2)/log(2) */
    402403  smpl_t midi = freq / 6.875;
     
    410411aubio_miditofreq (smpl_t midi)
    411412{
     413  if (midi > 140.) return 0.; // avoid infs
    412414  smpl_t freq = (midi + 3.) / 12.;
    413415  freq = EXP (freq * 0.69314718055995);
Note: See TracChangeset for help on using the changeset viewer.