mir_eval icon indicating copy to clipboard operation
mir_eval copied to clipboard

Are there any methods for transposing chord notations from one key to another?

Open VijayIyer opened this issue 3 years ago • 1 comments

I am working with data whose chord notations / symbols are in the format mir_eval works with (e.g C:min, C:7, etc). In order to model the transitions between chords, it's more convenient to transpose all the chords to C Major or A minor. This is a step that I have seen mentioned in many papers regarding chord detection / harmonic analysis.

Q: Does mir_eval have any methods to do the same, on the chord notations / symbols in the format it accepts? I know a few python libraries like chords-parser, mingus which work with notation like this (Cm, C7, Cmaj7), however, I would need to translate between the 2 types of notations ( I am able to do it for easier chords). The difference can get a lot more complicated for chords with inversions, augmented chords, suspended chords, etc.

VijayIyer avatar Jul 22 '22 20:07 VijayIyer

mir_eval doesn't do this directly, but I have implemented this kind of thing over in my data augmentation library muda, specifically here:

https://github.com/bmcfee/muda/blob/9e4ef5fabce1f35e53829940aff51aa6b0a30893/muda/deformers/pitch.py#L18-L50

This operates on chord annotations that would validate against an extended version of Harte's grammar, which is essentially what mir_eval uses for chord parsing. This would cover all the inversion, added/suppressed notes, and extended quality information automatically. It's mainly used to transpose a chord annotation by a fixed number of semitones, which occurs during training of chord models to achieve key invariance.

The one thing it won't do for you is spelling the root note of the chords - it goes through midi numbers for convenience, and converts back assuming C:maj. The implementation above pre-dates our implementation of note spelling in librosa, but it would be easy to add if you need it. OTOH, if you're only ever transposing into C:maj or A:min, it shouldn't be necessary.

bmcfee avatar Jul 22 '22 21:07 bmcfee