[solved] Code optimization

int level[16];

Try changing to:

int8_t level[16];

and:

    while (i < FFT_N/2) {
      if [fft_log_out[i]] >= 0) {
        level[i] = ((uint8_t)fft_log_out[i]) / 16; // - eq[i];
      } else {
        level[i] = 0;
      }

This is based on...

  • checking for >= 0 should be approximately the same speed regardless of data type.
  • division of uint8 by 16 should end up being a 4-bit shift. Much faster than the 32bit division that map() will do.