AnsweredAssumed Answered

FFT of 2 sine waves added together

Question asked by Arpitha_U on Feb 7, 2017
Latest reply on Feb 14, 2017 by Jithul_Janardhanan

I am trying to find the fft of 2 sine waves added. The platform used is visualdsp++ and target processor is ADSP BF537. code-

 

section("L1_data_a")
float inp1[1024];

 

section("L1_data_b")
complex_fract32 out[1024;

 

section("L1_data_a")
complex_fract32 tw[1024];

 

section("L1_data_b")
fract32 mag[1024];
void main(void)
{

 

unsigned int i;
int wst = 1;
int block_exponent;
int scale_method = 1;
int mode=1;
float fs=100.0, f2=10.0, f1=20.0;
float constant= (2*3.142)/fs;
twidfftrad2_fr32(tw, 1024);
asm("nop;");
//--------------------Create frequency samples---------------------//

 


for(i=0;i<1024;i++)
{
inp1[i]=(10*sin(constant*f1*i))+(10*sin(constant*f2*i));
}

 

asm("nop;");

 

//------------------fft radix_2 library function --------------------//
rfft_fr32((fract32)inp1, out, tw, wst, 1024, &block_exponent, scale_method);
asm("nop;");

 

memset(mag,0,1024);
//------------------------Mangnitude calculation--------------------//
fft_magnitude_fr32(out,mag,1024,block_exponent,mode);
asm("nop;");
}
When mag is plotted(Line plot), peak is obtained at 200. Shouldn't there be two peaks at two different frequencies?

 

How to take audio as input to find fft of the same?

Outcomes