Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
?
EE Times-Asia > Embedded
?
?
Embedded??

Creating a Mandolin-to-MIDI bridge

Posted: 25 Aug 2015 ?? ?Print Version ?Bookmark and Share

Keywords:MIDI? Fast Fourier Transforms? FFTs?

All that remains is to find the frequency with the maximum energy content between the bins. I ran a couple of simulations in Python in which I fed in a real guitar pluck and performed the short FFTs. This worked pretty well, even after adding noise, so at this point I was feeling reasonably happy.

However, it turned out that I had overlooked one little thing. Despite the fact that my method was working pretty well, there was a fundamental issue with the sampling time. In the case of detecting low frequency notes, I need to wait 128 samples at 250Hz (remember we have to discard the first 64 points as we don't need negative frequencies), which comes to little over half a second. The thing is that it's possibly to play more than two notes a second (some players can achieve eight notes a second fairly easily when playing tremolos).

Figure 3: Example Input data for note A4 (440Hz).

Figure 4: Short FFT outputs for note A4 (440Hz).

The problem lies not with choosing the FFT sampling frequency or the FFT size, but with the condition that we need at least 2.5Hz of frequency resolution. The FFT resolution clamps the time taken to sample to at least 0.4 seconds sine.

So this just tossed my original plan out of the door; but don't despair because there's still hope...

Autocorrelation to the rescue!
Autocorrelation is another commonly used method to determine the frequency content of a signal. The theory behind this is simplewith autocorrelation you just multiply the signal (a series of points) with the same signal phase-shifted. You keep varying the phase shift and what you end up with is a series of points that tell you how strongly the signal matches itself when shifted over time. The first sample (0 shift) is always strongest, which can be ignored for our particular project. The beauty of this relationship is that, if the signal is periodic, the signal will most strongly match (or correlate) at a shift value which represents the fundamental frequency of the signal.

There are interesting trade-offs when performing autocorrelation, however. One is the fact that the frequency bins from an autocorrelation are exponential in nature. To illustrate this, assume we have an N-point FFT with a sampling frequency of Fs; in this case, the bins would be as follows:

By comparison, if we were to employ autocorrelation, our bins would be as follows:


?First Page?Previous Page 1???2???3?Next Page?Last Page



Article Comments - Creating a Mandolin-to-MIDI bridge
Comments:??
*? You can enter [0] more charecters.
*Verify code:
?
?
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

?
?
Back to Top