Key detection Dance Music inaccuracies - matlab I have been working on a project with a vide variety of functions for DJ'ing. I am nearing the end, however, the accuracy rate on the key detection part of it is not pleasant when fed tracks of Dance music. With classical music, the algorithm returns a very better accuracy rate.

First of all I must explain how I never studied Signal Processing at University and I had to learn the concepts on my own, so excuse my lack of extended knowledge in the subject (hence why I am asking here).

I spent most of my time researching and at the end I came up with an algorithm that is a mixture of techniques suggested in literature.

Summary of Implementation: The audio is split into 5.5 second sections and translated to mono, downsampled to 11025hz and translated into the frequency domain using STFT technique. The STFT result in hz is translated into real music notes by a Chromagram. The chromagram is a 12 dimensional chroma vector in which each bin represents a real pitch class i.e. the first bin represents A, the second represents A#, third represents B etc. Each chroma vector is then correlated against 24 key templates. A coefficient is obtained for every key and a weighting system rewards the highest correlating keys when the difference between the other correlating keys is significant, and penalises when the difference is minute.

I perform the STFT and Chromagram steps with the help of a package by Dan Ellis, that I found online.

Now in the original code the parameters are: w (4086) is the basic STFT DFT length (window is half, hop is 1/4)

In the paper written by the same person there is this section: http://imgur.com/0EVyjFc, where he explains how the STFT is performed.

First question: I am not understanding why he divides the window by half before passing it to the STFT function?

Now, I am using an FFT length of 8192 samples unlike the 4086 of Ellis, after performing parameter testing which gave me best results at that length.

Before the hanning window is calculated these are the values of the parameters..

sr =

11025


N =

8192


W =

4096


 H =

2048


The second question: what could be the reason for such inconsistent and inaccurate results with dance music? Is it perhaps some characteristic of dance music that makes it difficult for the chromagram to match the notes in hz from the STFT to real music notes? Perhaps because of the Kicks, or something to do with the lower frequency ranges? What do you suggest can be done to the audio prior to performing STFT? may be some kind of filter? Can you suggest trying any different parameter in the STFT? or in general any other suggestion / extra step to make the final detection better? Suggestions that would alter the main steps of the key detection completely would be a bit out of reach, however, as I dont have much time left to submit the project.

Thanks in advance!
A 12-dimensional chromagram may not estimate pitch very well, given synthesized semi-tonal sounds that include lots of energy at multiple odd harmonics, as those harmonics will often end up in the wrong pitch class slots.  If there's lots of tonal bass, low-pass filtering just above the primary range of the bass instrument/synth's fundamental might help getting rid of some of the harmonics and overtones.

If the drums are not tuned to the key (probably not), then they will interfere with any key centered pitch class information.  Perhaps time-domain filtering out of all percussive events, and only analyzing the tones between the drum beat attacks might help in this case.  Even a simple low-envelope amplitude gate function might be suitable (assuming the sound isn't so compressed that there is no lower amplitude in any extent portion of the envelope!).

And, as per the previous answer, are you sure the sounds of your "dance music" actually contains a musical key? (as opposed to producing some cognitive or auditory illusion of tonality).