i have wav file visualize in frequency domain. next, write simple script takes in wav file , outputs whether energy @ frequency "f" exceeds threshold "z" (whether tone has strong presence in wav file). there bunch of code snippets online show how plot fft spectrum in python, don't understand lot of steps.
- i know wavfile.read(myfile) returns sampling rate (fs) , data array (data), when run fft on (y = numpy.fft.fft(data)), units y in?
to array of frequencies x-axis, posters n = len(data):
x = numpy.linspace(0.0, 1.0/(2.0*t), n/2)
and others this:
x = numpy.fft.fftfreq(n) * fs)[range(n/2)]
is there difference between these 2 methods , there online explanation these operations conceptually?
- some of online tutorials ffts mention windowing, not lot of posters use windowing in code snippets. see numpy has numpy.hamming(n), should use input method , how "apply" output window fft arrays?
- for threshold computation, correct find frequency in x that's closest desired tone/frequency , check if corresponding element (same index) in y has amplitude greater threshold?
fft data in units of normalized frequency first point 0 hz , one past last point
fshz. can create frequency axislinspace(0.0, (1.0 - 1.0/n)*fs, n). can usefftfreqcomponents negative.these same if
neven. can userfftfreqthink. note "positive half" of frequencies, want audio (which real-valued). note can userfftproduce positive half of spectrum, , frequenciesrfftfreq(n,1.0/fs).windowing decrease sidelobe levels, @ cost of widening mainlobe of frequencies there.
nlength of signal , multiply signal window. however, if looking in long signal might want "chop" pieces, window them, , add absolute values of spectra."is correct" hard answer. simple approach said, find bin closest frequency , check amplitude.
Comments
Post a Comment