3
$\begingroup$

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: https://i.sstatic.net/nZrxF.jpg, 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!

$\endgroup$

2 Answers 2

2
$\begingroup$

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).

$\endgroup$
3
  • $\begingroup$ As with regards to tracks actually containing musical keys and not "illusions", I analysed the tracks on Rekordbox and got a reading from there. Then got a reading from Beatport too. If they match, then I use them for my tests.. assuming that if they match they are "good". Thank you for your answer! What I did not quite understand was 'time domain filtering out all percussive events and only analysing the tones between the drum beat attacks". What do you mean exactly, and how could it be implemented ? $\endgroup$ Commented May 6, 2015 at 0:08
  • $\begingroup$ ok now that I am seeing the edit I am getting some more information. Should I look into "low envelope amplitude gate functions" ? $\endgroup$ Commented May 6, 2015 at 0:09
  • $\begingroup$ I made that term up for a function that simply ignores STFT windows that have an above average (or some other threshold) total energy/amplitude. $\endgroup$
    – hotpaw2
    Commented May 6, 2015 at 0:11
1
$\begingroup$

There are two things I know of which will cause a problem:

  • Some dance music just isn't in any key. It's just sounds lumped together until it sounds great.
  • The kick drum is the loudest thing but isn't always in a particular key. Often it just decays in frequency. There's been a trend recently for kick drums to be tuned to the track, but it's not always done.

Try applying a high pass filter above 100Hz and see if that improves things. I expect someone with more FFT skills than I will fill in more of the answer!

$\endgroup$
9
  • $\begingroup$ mathworks.com/help/signal/examples/… something like this? $\endgroup$ Commented May 5, 2015 at 18:50
  • $\begingroup$ Well, to test it quickly, put the source material into something like Audacity and just make a new file with the content below 100Hz removed and see how it processes it. But those examples look like the right kind of thing: uk.mathworks.com/help/signal/examples/… $\endgroup$
    – JayC
    Commented May 5, 2015 at 18:53
  • $\begingroup$ I performed a test on 10 tracks high pass filtered using a 100hz cut off. 1. actual key Gm intitial detected key [Am] with low pass filter F 2. actual key C initial key E with low pass filter E 3. actual key G initial key F with low pass filter C 4. actual key F#m initial key F# with low pass filter C# 5. actual key Bm initial key F with low pass filter F#m $\endgroup$ Commented May 5, 2015 at 20:17
  • $\begingroup$ 6. actual key D initial key C#m with low pass filter C#m 7. actual key F initial key Am with low pass filter F 8. actual key b initial key Fm with low pass filter D# 9. actual key Ebm initial key B with low pass filter Fm 10. actual key Am initial key A#m with low pass filter A#m $\endgroup$ Commented May 5, 2015 at 20:17
  • 1
    $\begingroup$ as you can see only in 1 occasion did the key detect properly once a low pass filter was put on the audio. Possibly, the detections were closer but this interesting solution didnt seem to effectively solve the problem $\endgroup$ Commented May 5, 2015 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.