fft
Python frequency detection
The aubio libraries have been wrapped with SWIG and can thus be used by Python. Among their many features include several methods for pitch detection/estimation including the YIN algorithm and some harmonic comb algorithms. However, if you want something simpler, I wrote some code for pitch estimation some time ago and you can take it … Read more
FFT in a single C-file [closed]
Your best bet is KissFFT – as its name implies it’s simple, but it’s still quite respectably fast, and a lot more lightweight than FFTW. It’s also free, wheras FFTW requires a hefty licence fee if you want to include it in a commercial product.
How to plot a 2D FFT in Matlab?
Assuming that I is your input image and F is its Fourier Transform (i.e. F = fft2(I)) You can use this code: F = fftshift(F); % Center FFT F = abs(F); % Get the magnitude F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined F = mat2gray(F); % Use … Read more
Python Scipy FFT wav files
Python provides several api to do this fairly quickly. I download the sheep-bleats wav file from this link. You can save it on the desktop and cd there within terminal. These lines in the python prompt should be enough: (omit >>>) import matplotlib.pyplot as plt from scipy.fftpack import fft from scipy.io import wavfile # get … Read more
Understanding Matlab FFT example
1) Why does the x-axis (frequency) end at 500? How do I know that there aren’t more frequencies or are they just ignored? It ends at 500Hz because that is the Nyquist frequency of the signal when sampled at 1000Hz. Look at this line in the Mathworks example: f = Fs/2*linspace(0,1,NFFT/2+1); The frequency axis of … Read more
Invertible STFT and ISTFT in Python
Here is my Python code, simplified for this answer: import scipy, pylab def stft(x, fs, framesz, hop): framesamp = int(framesz*fs) hopsamp = int(hop*fs) w = scipy.hanning(framesamp) X = scipy.array([scipy.fft(w*x[i:i+framesamp]) for i in range(0, len(x)-framesamp, hopsamp)]) return X def istft(X, fs, T, hop): x = scipy.zeros(T*fs) framesamp = X.shape[1] hopsamp = int(hop*fs) for n,i in enumerate(range(0, … Read more
how to extract frequency associated with fft values in python
np.fft.fftfreq tells you the frequencies associated with the coefficients: import numpy as np x = np.array([1,2,1,0,1,2,1,0]) w = np.fft.fft(x) freqs = np.fft.fftfreq(len(x)) for coef,freq in zip(w,freqs): if coef: print(‘{c:>6} * exp(2 pi i t * {f})’.format(c=coef,f=freq)) # (8+0j) * exp(2 pi i t * 0.0) # -4j * exp(2 pi i t * 0.25) # … Read more
Reliable and fast FFT in Java [closed]
FFTW is the ‘fastest fourier transform in the west’, and has some Java wrappers: http://www.fftw.org/download.html Hope that helps!
only integers, slices (`:`), ellipsis (`…`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
I believe your problem is this: in your while loop, n is divided by 2, but never cast as an integer again, so it becomes a float at some point. It is then added onto y, which is then a float too, and that gives you the warning.