Bug: scale detection filters on only one of the drum instruments (id = 2).
Fix: Instrument Id 31 should also be included.

Suggestion:
Enhance algorithm to pick the most likely scale in case of a match among scales. The relative major scale seems always prefered over the minor scale. On multiple candidate scales, I would pick the one that is more likely to have the key of the 2. Key detection could be performed by selecting the note with the most occurences.