Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Cycle separation in a wave file with Python

I got an audio wave file which is a short piece of a song. My data is an array of sampled wave (e.g. [-8193 -8445 -8697 -7941 -6680 -4915 ... 9201 8193 6932]), which looks like:

wave

There are a lot of repeated patterns here and each pattern has a certain frequency. I want to extract the changing frequency so that I can get the changing pitch of the song.

However, there are multiple cycles and the pattern keeps changing. I wonder how to separate each cycle from this continuous wave.

EDIT A lot of comments mentions using FFT and finding the max one as the fundamental frequency.

I did try that and here is the result of numpy.fft(signal): enter image description here I have few doubts about that:

  1. Should I find the maximum one based on the original value of Fourier or the absolute one.
  2. If the wave file becomes longer, the frequency of the audio might change in a single wave file. We can only find one frequency of this wave file, which is unreasonable.

Comments