"Harmony analysis tool" plugin does not take into account transposing instruments

• May 14, 2022 - 17:07

When the selection to analyse is taken from multiple instruments not all transposing the same way, the analyse is not performed on the concert pitch leading to incorrect analysis.

Example in this excerpt of My Favorite Things:
When selecting notes from the flute and the piano (both non transposing instruments), the analyse is correct. It finds the chord E.
HarmonyAnalyserOk.png

When selecting notes from the saxophone (Bb instrument) and the piano (non transposing instrument), the analyse is incorrect. It does not find anything.
HarmonyAnalyserError.png

Attachment Size
mcveHarmonyAnalyser.mscz 7.21 KB

Comments

Thanks for info! Since I'm focused on piano music, I never noticed this problem.
I'm quite low on free time these days so I can not promise anything but I'll try to see can I do something about it.
Anyway, I'm glad to hear that someone is using the tool :)

Hi again.
Actually, it was trivial to solve this issue.
I updated the plugin code so you can download it now and try.

I'll explain the solution here for someone interested in writing plugins. When working with note element, you can get its pitch class by using three different properties: tpc1 which always gives concert pitch, tpc2 which always gives transposing pitch and tpc which gives either concert or transposing pitch (as per current "Concert Pitch" setting). Thus, the solution was to simply use tpc1 property instead of tpc property.

    var selection = curScore.selection;
    var elements = selection.elements;
    for (var i = 0; i < elements.length; i++) {
        var element = elements[i]
        if (element.type == Element.NOTE) {
            selectedTpc[element.tpc1 + 1] = true;
            if (element.pitch < minPitch) { 
                minPitch = element.pitch;
                minPitchTpc = element.tpc1; 
            }
        }
    }

Do you still have an unanswered question? Please log in first to post your question.