Hi,

I am a numpy newbie.

I have two wav files, one that numpy takes a long time to process the FFT. They was created within audacity using white noise and silence for gaps.

  1. my_1_minute_noise_with_gaps.wav
  2. my_1_minute_noise_with_gaps_truncated.wav

The files are very similar in the following way;

  • 1. is white noise with silence gaps on every 15 second interval.
  • 2. is 1. but slightly shorter, i.e. I trimmed some ms off the end but it still has the last gap at 60s.

The code I am using processes the file like this;

    framerate, data = scipy.io.wavfile.read(filepath)
    right = data[:, 0]
    # Align it to be efficient.
    if len(right) % 2 != 0:
        right = right[range(len(right) - 1)]
    noframes = len(right)
    fftout = np.fft.fft(right) / noframes    # <<< I am timing this cmd

Using timeit...

  • my_1_minute_noise_with_gaps_truncated took 30.75620985s to process.
  • my_1_minute_noise_with_gaps took 22307.13917s to process.

Could someone tell me why this behaviour is happening please?

Sorry I can't attach the files as this email gets bounced but you could easily create the files yourself.
E.g my last gap width is 59.9995 - 1:00.0005, I repeat this every 15 seconds.
My truncated file is 1:00.0015s long, non-truncated is 1:00.0833s long


Thanks.