2018-02-21 04:26 AM
Hello.,
I need to write test code for Audio codec which is interfaced through SAI interface . For this I am generating 1KHz sine wave using DAC and given to codec input and capturing the same through SAI interface . Now how to conclude that signal frequency is 1Khz by using SAI captured samples.
I was suggested to do FFT on those samples ,
>> Is it possible to do FFT on captured sample from SAI interface.
>> To do this Is there any inbuilt algorithm available in CMSIS library. If so which one to use and how to use can anyone suggest me .
#sai #stm32f72018-02-23 03:45 AM
Hello Clive.,.,
Thank you for the reply.
I have gone through the example you have referred , In that i found following 3 function calls
arm_cfft_f32(&CFFT_LENGTH,(float32_t*) sine_sample,1,0);
arm_cmplx_mag_f32((float32_t*) sine_sample,pDst,512); arm_max_f32(pDst,512,&MaxValue,&testIndex);But if I use these function in my application it giving number of errors, I have included all required header files.
Also in these example which one is the frequency parameter , Can just brief me how use those functions , or if you can provide some aPP note it will be more helpful.
Thank you.,
2018-02-23 03:56 AM
What is the error, probably most likely a linker error and you haven’t added the library to your project.
you don’t get frequency directly out of a FFT, you get the bin index which contains the biggest magnitude, depending on the sample rate and fft size you will find that each bin spans a number of frequencies.
also beware that bin 0 contains DC, so it’s probably best to zero that before doing the max magnitude call.
2018-02-23 03:58 AM
The example should show you how to use the functions.
Just plug in your input data, and call it periodically (if required).
But if I use these function in my application it giving number of errors, I have included all required header files.
You need to add these FFT sources to your project as well.
'giving a number of errors' is not quite an accurate description, better show the actual error messages.
2018-02-23 03:58 AM
Edwin kaus wrote:
it giving number of errors,
Don't you think that it would be necessary to know what, exactly, those errors are in order to be able to say anything about how to fix them ... ?
As others have said, might it not be simpler to just do the analysis on a PC?
eg, Audacity can directly give you the spectrum of an audio signal - no programming required ...
2018-02-23 04:18 AM
Hello.,
Most probably I have missed some libraries to be add, that I will try to solve .
But I need some detailed explanation to get frequency after FFT, Is it any arithmetic operation required on Magnitude and index values, Can you provide those formulas required.
2018-02-23 04:26 AM
So, again, why DIY - and why on the target?
2018-02-23 04:34 AM
Sample rate/fft length = bin width
max index * bin width = frequency in the bin of the largest magnitude signal.
for example, a 44khz sample rate with an fft of 512 will give you 86hz per bin.
so if bin 2 contains the biggest magnitude then the frequency is 172 hz.
2018-02-23 04:39 AM
Seems that including code that involves operations unfamiliar to you is introducing more trouble, instead of testing/verifying the codec.
PC based applications (like the suggested Audacity), would do all that for you.
2018-02-23 04:50 AM
Hello.,
I understand your concern , Yes its so simple to do it on PC and I have done those thing already. But in our application I need to test all on board available resource by its own and then its goes for application mode. So this is very important requirement to test audio codec.
2018-02-23 05:14 AM
Hello.,
Here in my application audio signal is captured at 16Khz sampling frequency, suppose if I do FFT for 512 words(16bits). How to apply above formula to get frequency.