Fore-word :Kindly Observe this question has multiple updates take the latest update as question !
here below is my 256pt FFT on an 2Khz sinusoid signal,on a fixed point DSP tms320c5515
please ignore this this has occured due to programatic bug
is this above figure expected in the first place ?(with out windowing)
after looking several resources i have came to a conclusion that using a hanning window is the best way to go before an STFT,but my question is how to window an input signal which is a signed data 16bit,
i know generally we go for finding the hamming window vector in matlab for a 256bin and try to multiply that window
but when i did multiply my signal with a vector which i got from the matlab a 256pt hamming window which is having values from 0.08 -0.99 ,still i have my spectral leakages persistent in the FFT results
float window[256]={
0.0801396321, 0.0805584436, 0.0812561802, 0.0822324185, 0.0834865656,
0.0850178601, 0.0868253726, 0.0889080056, 0.0912644947, 0.0938934094,
0.0967931537, 0.099961967, 0.103397926, 0.107098944, 0.111062774,
0.115287011, 0.119769089, 0.124506288, 0.129495732, 0.134734391,
0.140219085, 0.145946484, 0.151913112, 0.158115346, 0.16454942,
0.171211429, 0.178097329, 0.185202937, 0.192523942, 0.200055898,
0.207794233, 0.215734248, 0.223871124, 0.232199921, 0.240715582,
0.249412937, 0.258286707, 0.267331503, 0.276541836, 0.285912112,
0.295436645, 0.305109651, 0.314925258, 0.324877507, 0.334960356,
0.345167684, 0.355493294, 0.365930917, 0.376474217, 0.387116792,
0.397852183, 0.40867387, 0.419575286, 0.43054981, 0.441590782,
0.452691497, 0.463845217, 0.47504517, 0.486284557, 0.497556555,
0.508854319, 0.520170992, 0.531499704, 0.542833575, 0.554165727,
0.565489278, 0.576797356, 0.588083093, 0.59933964, 0.610560161,
0.621737846, 0.632865908, 0.643937592, 0.654946175, 0.665884975,
0.676747351, 0.687526708, 0.698216503, 0.708810244, 0.719301502,
0.729683906, 0.739951154, 0.750097012, 0.760115322, 0.77, 0.779745046,
0.789344544, 0.798792666, 0.808083676, 0.817211933, 0.826171896,
0.834958125, 0.843565286, 0.851988154, 0.860221615, 0.868260671,
0.876100441, 0.883736166, 0.89116321, 0.898377064, 0.905373349,
0.912147817, 0.918696356, 0.92501499, 0.931099882, 0.93694734,
0.942553812, 0.947915896, 0.953030335, 0.957894025, 0.962504013,
0.966857501, 0.970951846, 0.974784561, 0.97835332, 0.981655957,
0.984690466, 0.987455005, 0.989947896, 0.992167626, 0.994112846,
0.995782376, 0.997175203, 0.99829048, 0.999127531, 0.999685848,
0.999965091, 0.999965091, 0.999685848, 0.999127531, 0.99829048,
0.997175203, 0.995782376, 0.994112846, 0.992167626, 0.989947896,
0.987455005, 0.984690466, 0.981655957, 0.97835332, 0.974784561,
0.970951846, 0.966857501, 0.962504013, 0.957894025, 0.953030335,
0.947915896, 0.942553812, 0.93694734, 0.931099882, 0.92501499,
0.918696356, 0.912147817, 0.905373349, 0.898377064, 0.89116321,
0.883736166, 0.876100441, 0.868260671, 0.860221615, 0.851988154,
0.843565286, 0.834958125, 0.826171896, 0.817211933, 0.808083676,
0.798792666, 0.789344544, 0.779745046, 0.77, 0.760115322, 0.750097012,
0.739951154, 0.729683906, 0.719301502, 0.708810244, 0.698216503,
0.687526708, 0.676747351, 0.665884975, 0.654946175, 0.643937592,
0.632865908, 0.621737846, 0.610560161, 0.59933964, 0.588083093,
0.576797356, 0.565489278, 0.554165727, 0.542833575, 0.531499704,
0.520170992, 0.508854319, 0.497556555, 0.486284557, 0.47504517,
0.463845217, 0.452691497, 0.441590782, 0.43054981, 0.419575286,
0.40867387, 0.397852183, 0.387116792, 0.376474217, 0.365930917,
0.355493294, 0.345167684, 0.334960356, 0.324877507, 0.314925258,
0.305109651, 0.295436645, 0.285912112, 0.276541836, 0.267331503,
0.258286707, 0.249412937, 0.240715582, 0.232199921, 0.223871124,
0.215734248, 0.207794233, 0.200055898, 0.192523942, 0.185202937,
0.178097329, 0.171211429, 0.16454942, 0.158115346, 0.151913112,
0.145946484, 0.140219085, 0.134734391, 0.129495732, 0.124506288,
0.119769089, 0.115287011, 0.111062774, 0.107098944, 0.103397926,
0.099961967, 0.0967931537, 0.0938934094, 0.0912644947, 0.0889080056,
0.0868253726, 0.0850178601, 0.0834865656, 0.0822324185, 0.0812561802,
0.0805584436, 0.0801396321, 0.08}
is my way of windowing correct or wrong ?
UPDATE 1 : Results with out windowing
of updated screen shots of input tone and windowed and FFT:
with suggestions of more explanations requirement i have tried to give a standard 440Hz tone with sampling freq 8000, which is 16bitPCM format, the tone is windowed and then fft was done
with out windowing
ater applying my window looking like
after windowing with the above window it has turned the sinusoidal to sqaure(expected ? !) which further given rise to more worse FFT why so ?
UPDATE 2 :Update 1 has bug with the program where i was trying to do FFT with a wrong window array
Here below is the input the effect of windowing and the FFT result,there no problem with the window i have mentioned in the question,i have generated it from matlab and used it as array,
now is the response and every thing OK ! ? i feel its correct,a peak at 14th bin (~430Hz) and 256-14(~7560Hz) now i have to go for the magnitude plotting urgently to get the power of each bin
UPDATE 3 :Magnitude Plot Updated
Now the convnetional problem why two peaks,how to remove the other negative frequency peak can i nullify greater than (fs/2)? people do this by shifting how can i shift the (256-14)7560Hz componed to it left un existing side -14Hz ,How ?
are there any other things i do need to do further improvisation to this FFT ? to further make it better
and also i am seeing a secondary peak next to my desired peak sometimes(not shown in the pic )why so ?
UPDATE 4 : Update is Regarding the new window usage,effects after overlapped frames are used,also zeropadding
With the suggestion from other forums,when people said a zero padding decreases the multiple peaks in the magnitude plot and also a overlapped frames will help
so i have changed my strategy to do a 512pt FFT Frame size 20ms ie., 160 samples(8000 sampling rate) 50 % overlap which makes it to 320 samples rest i have done zero padding
and i also have updated the window to symmetric 4-term Blackman-harris Window which is said to give peaks of dominant frequency and suppress the rest
below figure show the updated results,and magnitude plot resulting in a valley also,which is not desired
But on the other side i have Opensource KissFFT algo which is doing same thing which gives a superb response to the same input
output of KissFFT(Open Source Implementation)-which is also trying to take a 160ms frame and do the FFT of 512pt with 50% frame overlap
why so ? whats wrong with my approach what am i missing ? Is this any bug with my hardware FFT algorithm when compared to Cooley-Tukey Algo ? My hardware uses a Radix-2 approach
i really need some inputs to make my fft more strengthened
Very thanks for the answers up to now !