Plotting Calculating And Cleaning
Calculating Fast Fourier Transform
Remember FFT has 2 components (frequency and magnitude of frequency)
np.fft.rfftfreq(window_length, d=inverse_sampling_rate) -> Returns ndarray of sampling frequencies
np.fft.rfft(discrete_signal_input) -> Returns COMPLEX ndarray
Since it returns a complex array, it has an imaginary part, but we only want the magnitude (so only the real). So we take the absolute value
Dividing by window_length to normalize the FFT output (not required but good to do)
Even though we should be ensuring that all signals are the same length, in case they aren't, this scales magnitude of the FFT
Calculating the Filterbank Energy Coefficients and Mel Frequency Cepstrum Coefficients
Filterbank:
logfbank(audio signal that is n*1 array, sampling_rate, nfft)
nfft
: the FFT size (number of bins used for dividing the window into equal strips, or bins)
Cepstrum: Similar to above but uses
mfcc()
(Remember, this is just the filterbank energy coefficients with the discrete cosine transform)Calculated by
Get the sample frequency by getting the rate from
wavfile.read()
Here, we just used the conventional window size of 0.025 seconds
So the
nfft=44100*0.025
Analyzing Plotted Graphs
Time Series
Noise Threshold Detection
Remember in
Background and Downsampling
, we can see where there is low magnitude portions (quieter sound) and we should filter this outBarely any signal for algorithm to process
General Idea: Compute a threshold, if sample does not meet this threshold, it is filtered out
Fourier Transform
Frequencies are so distributed, you can't tell much :sad:
Filterbank Coefficients and Mel Cepstrum Coefficients
Can now distinguish between instruments pretty well visually
Calculating Threshold Envelope of the Signal to Clean Dead Space
Want to detect the red lines (this is called the Rolling Mean)
Do this easier with
Pandas Series
instead ofnumpy array
Returns List of booleans for Numpy array Masking (Lines up with numpy array length, if the index is matched up with False, it is removed from the array)
To find threshold value (in this case it's 0.0005), you have to test out which one works best
Last updated