Python FFT & Magnitude Spectrum of two similar signals have different frequencies
Question: My goal is to compare the FFT of similar signals. For some reason, when I take
the magnitude spectrum of two signals of the same length, the frequencies are
different... I can't do a simple side by side comparison of two signals
because of this. Anyone have any tips on how to get the same FFT on the
signals?

So for instance Signal1 provides the following:

![Signal 1](http://i.stack.imgur.com/zDpu5.png) ![Signal
2](http://i.stack.imgur.com/B2AOi.png)

Update: Here's the two signals plotted from 0-400Hz ![Plotted
signals](http://i.stack.imgur.com/n9kdz.png)

Here's my code: The logic behind the code is to import the signal, find where
the sound starts, chop the signal to be 1 second in length, perform FFT on
signal for comparison.

    
    
    import numpy as np
    from scipy.io.wavfile import read
    from pylab import plot
    from pylab import plot, psd, magnitude_spectrum
    import matplotlib.pyplot as plt
    
    #Hello Signal!!!
    (fs, x) = read('C:\Desktop\Spectral Work\EB_AB_1_2.wav') 
    
    #Remove silence out of beginning of signal with threshold of 1000 
    
    def indices(a, func):
        #This allows to use the lambda function for equivalent of find() in matlab
        return [i for (i, val) in enumerate(a) if func(val)]
    
    #Make the signal smaller so it uses less resources
    x_tiny = x[0:100000]
    #threshold is 1000, 0 is calling the first index greater than 1000
    thresh = indices(x_tiny, lambda y: y > 1000)[1]
    # backs signal up 20 bins, so to not ignore the initial pluck sound...
    thresh_start = thresh-20
    #starts at threshstart ends at end of signal (-1 is just a referencing thing)
    analysis_signal = x[thresh_start-1:] 
    
    #Split signal so it is 1 second long
    one_sec = 1*fs
    onesec = x[thresh_start-1:one_sec]
    
    #***unsure is just a placeholder because it spits out a weird error if I don't use
    #a third variable
    (xsig, ysig, unsure) = magnitude_spectrum(onesec, Fs=fs)
    

xsig is the amplitude and ysig is the Frequencies.

Here's links to the .wav files if you're interested in trying it out yourself:
[.wav1](https://drive.google.com/file/d/0BxHc4PVaRU7obTZ5TDlhTXdMNW8/view?usp=sharing
"wav1")
[.wav2](https://drive.google.com/file/d/0BxHc4PVaRU7oWE5YZGttU3lhcEU/view?usp=sharing
"wav2") Note: originally i uploaded the wrong .wav1 file... the correct one is
now up.


Answer: I'm guessing your signals aren't actually the same length. If you're
thresholding them independently, your `thresh_start` value won't be the same,
so:

    
    
    onesec = x[thresh_start-1:one_sec]
    

will give you different-length arrays for the two files. You can either
calculate the `threshold` value separately and then provide that number to
this module as a constant, or make your `onesec` array be the same length from
the start of _each_ threshold value:

    
    
    onesec = x[thresh_start-1:one_sec+thresh_start-1]
    

(Remember that slice notations is `[start:stop]`, not `[start:length]`)

