FFT: Linear to Logarithmic (TM4C, CMSIS & NeoPixels/ws2812)

I'm trying to perform an FFT using the CMSIS libraries.

My FFT_Output[] provides 1024 bins of data as expected. The issue is that it's linearly spaced and I want to change it to a logarithmic scale into 64 bins (each of these bins correspond to an LED) as it corresponds with how we hear so looks better. I'm sampling at 44kHz and taking 2048 samples (FFT_Output provides 1024) and using a TM4C1294XL.

I'd like to keep the 'negative' frequencies that the FFT produces for the symmetrical effect that it'll have on the LEDs.

I'm really struggling with how to do this, I've never done logarithms in C. I have no problem scaling it linearly. How could I change this function (which scales lin) to do it logarithmically or is there a better way?

FFT_Output[] - my 1024 result bin[] - my 64 bit bin that corresponds to my LEDs bin_scaled[] - my 64 scaled to 255 (the number needed for my LEDs)

int j;
for(j=0; j<N_LED; j++)
{
IntMasterDisable();
int i;
for(i=0;i<N_SAMPLES/2;i++)
{
bin[i/16] += FFT_Output[i];
}

arm_max_f32(bin, N_LED, &Bin_maxValue, &Bin_Index);
bin_scaled[j] = (bin[j]/Bin_maxValue)*255; //this is the array that will be used
IntMasterEnable();
}

• Can you clarify your question? It sounds like you're asking "How do I calculate the logarithm of a number in C?", which is off-topic here and has multiple related answers in stackoverflow.com/search?q=logarithm+[c] – MBaz Apr 23 '16 at 15:31
• CMSIS is an abstraction layer ARM specified for some of their processors; it doesn't define FFTs. Maybe you're talking about some specific compiler/toolchain vendors standard libraries that go under the same name? At any rate, this is a specific programming and not a DSP question and is off-topic here, sorry. – Marcus Müller Apr 23 '16 at 16:07
• @MarcusMüller: I guess he is talking about CMSIS-DSP. – jojek Apr 23 '16 at 16:34
• Yes, I'm talking about CMSIS-DSP:) No, I'm asking how to scale an entire array logarithmically not the single number. I'm trying to reduce 1024 bins linear to 64 bins logarithmic. Does that clear it up? – William Yates Apr 23 '16 at 17:22