For a given audio signal I want it to be spitted in to 50ms chunks to perform Fourier Transform. The problem is when I use the usual split method in Numpy it adds some high frequency components due to sudden split.
So to solve this I heard we have to use a proper window.
The splitting using the numpy function is equalent to using a rectangular window which in signal processing, a not-so-clever method!
So I need help how I can use Blackman window to make my audio signal spliced in to chunks.
So here is what I have used for a similar application in audio signal processing. To be exact I was making a spectrogram finder for songs. For that I also wanted to find the Fourier Transform of small chunks.
spacing = 0.1 # seconds window_dura = 0.2 #seconds signal_N = len(data) #length of whole audio window_N = int(sample_rate * window_dura) spacing_N = int(spacing * sample_rate) #blackman nuttel window a0,a1,a2,a3 = 0.3635819,0.4891775,0.1365995,0.0106411 xWindow = np.arange(0,window_N,1) yWindow = a0 - a1 * np.cos(2 * np.pi * xWindow / window_N) + a2 * np.cos(4 * np.pi * xWindow / window_N) -a3 * np.cos(6 * np.pi * xWindow / window_N) n = int((signal_N - window_N) / spacing_N) # number of chunks targetable (window touches the starting point # ... total does not exceed signal length) window_Array = np.zeros(shape=(n,siganl_N)) # all windows horizontally stacked print("r3:shape",window_Array.shape) for i in range(n): window_Array[i,i*spacing_N:i*spacing_N+window_N] = yWindow
Also see how these windows are aligned (only first 10 windows are displayed)
#See how the window_Array's each "window with full duration" looks like max_plot_N = 10 fig,ax = plt.subplots(min(max_plot_N,n),1,figsize=(30,4*min(max_plot_N,n))) for i in range(n)[:max_plot_N]: ax[i].plot(window_Array[i]) plt.show()