def fourier_transform(signal, period, tt):
""" See http://en.wikipedia.org/wiki/Fourier_transform
How come Numpy and Scipy don't implement this ??? """
f = lambda func : (signal*func(2*pi*tt/period)).sum()
return f(cos)+ 1j*f(sin)
is using the FFT.What you want is the power spectral density in the discrete case, called the power spectrum. It can be calculated by multiplying the discrete Fourier transform (FFT) with its conjugate, and shifting. NumPy can do it. Here is an example: http://stackoverflow.com/questions/15382076/plotting-power-s...
If someone knows a way to use the FFT to get non-integer periods (apart from oversampling the signal) I'll gladly change the code.
It's controlled by a parameter NFFT -- the PSD will compute (NFFT/2+1) values evenly spaced between 0 and the Nyquist frequency.
So say the frame rate is 15Hz and you compute with NFFT=2048, then PSD[970] contains the amplitude at 7.09Hz.
This was a really cool project by the way!
If was a fun place to see in the 70's after watching my father rebuild our player piano.
Relevant: Zenph makes "re-performances" of old piano recordings. They take a recording, do music transcription magic to get the exact timings and velocities of each note event, and then feed that into a player piano. So it's as if you are listening to the ghost of Rachmaninov sitting at the piano, as shown here: https://www.youtube.com/watch?v=eevzbV6Hkkk&t=28 (music starts at 0:28)
(I just visited http://zenph.com for the first time in about a year, and it appears that they've pivoted into a music education company.)
http://isophonics.net/nnls-chroma
Here's chordify: http://ismir2012.ismir.net/event/papers/295_ISMIR_2012.pdf
That conference has great references but unfortunately hasn't been repeated since 2012 http://www.ismir.net/proceedings/index.php
However, this case would be one of the best cases for it, it's a single instrument, and you could make a careful recording out of it