Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
VijayIyer opened this issue Jul 22, 2022 · 1 comment

Comments

@VijayIyer
Copy link

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.

@bmcfee
Copy link
Collaborator

bmcfee commented Jul 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants