Changeset 10a5413 for src/mathutils.c


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

src/mathutils.c: add aubio_is_power_of_two and aubio_next_power_of_two

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.