Changeset 10a5413


Ignore:
Timestamp:
Oct 7, 2009, 6:26:59 PM (15 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:
1b88289
Parents:
daa4ca9
Message:

src/mathutils.c: add aubio_is_power_of_two and aubio_next_power_of_two

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    rdaa4ca9 r10a5413  
    115115
    116116dnl Check for header files
    117 AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h errno.h stdarg.h unistd.h signal.h],,)
     117AC_CHECK_HEADERS([string.h stdlib.h stdio.h math.h limits.h errno.h stdarg.h unistd.h signal.h],,)
    118118AC_CHECK_HEADERS(fftw3.h,,AC_MSG_ERROR([Ouch! missing fftw3.h header]))
    119119AC_ARG_ENABLE(complex,
  • src/aubio_priv.h

    rdaa4ca9 r10a5413  
    6161#if HAVE_STRING_H
    6262#include <string.h>
     63#endif
     64
     65#if HAVE_LIMITS_H
     66#include <limits.h> // for CHAR_BIT, in C99 standard
    6367#endif
    6468
  • src/mathutils.c

    rdaa4ca9 r10a5413  
    410410}
    411411
     412uint_t
     413aubio_is_power_of_two(uint_t a) {
     414  if ((a & a-1) == 0) {
     415    return 1;
     416  } else {
     417    return 0;
     418  }
     419}
     420
     421uint_t
     422aubio_next_power_of_two(uint_t a) {
     423  uint_t i;
     424  a--;
     425  for (i = 0; i < sizeof(uint_t) * CHAR_BIT; i++ ) {
     426    a = a | a >> 1;
     427  }
     428  return a+1;
     429}
     430
    412431smpl_t
    413432aubio_db_spl (fvec_t * o)
  • src/mathutils.h

    rdaa4ca9 r10a5413  
    317317smpl_t aubio_miditofreq (smpl_t midi);
    318318
     319/** return 1 if a is a power of 2, 0 otherwise */
     320uint_t aubio_is_power_of_two(uint_t a);
     321
     322/** return the next power of power of 2 greater than a */
     323uint_t aubio_next_power_of_two(uint_t a);
     324
    319325/** compute sound pressure level (SPL) in dB
    320326
  • wscript

    rdaa4ca9 r10a5413  
    5454  conf.check(header_name='math.h')
    5555  conf.check(header_name='string.h')
     56  conf.check(header_name='limits.h')
    5657
    5758  # optionally use complex.h
Note: See TracChangeset for help on using the changeset viewer.