Skip to content

Transposes minor keys to relative major#622

Open
MerijnBosma wants to merge 2 commits into
ChordPro:masterfrom
MerijnBosma:nashville-minor-key-fix-(#526)
Open

Transposes minor keys to relative major#622
MerijnBosma wants to merge 2 commits into
ChordPro:masterfrom
MerijnBosma:nashville-minor-key-fix-(#526)

Conversation

@MerijnBosma
Copy link
Copy Markdown
Contributor

When transcoding to Nashville or Roman notation,
correctly transposes minor keys to their relative major
for accurate representation.

Fixes #526

When transcoding to Nashville or Roman notation,
correctly transposes minor keys to their relative major
for accurate representation.

Fixes ChordPro#526
@sciurius
Copy link
Copy Markdown
Collaborator

When you take a look at the t/cho folder, there are small songs used for testing. Can you supply one or two small songs to test (prove) that the transposition is now what it should be?

@MerijnBosma
Copy link
Copy Markdown
Contributor Author

For test I've used cho002 and cho010 (since 10 was one where nashville and roman notation are used).
I've made counterparts (cho002a and cho010a) where I changed the keys to their relative minor (D -> Bm for cho002 and C -> Am for cho010) to test.

All output is what I expect it to be, see attached all input and output.

cho.zip

@sciurius
Copy link
Copy Markdown
Collaborator

I run the following command:

perl script/chordpro.pl -X cho010a.cho --xc roman --gen ChordPro -o -

The difference in output between your version and mine is line 4, where I have chords 1 and 4 and you have #2 and #6. Is that correct?

@MerijnBosma
Copy link
Copy Markdown
Contributor Author

I run the following command:

perl script/chordpro.pl -X cho010a.cho --xc roman --gen ChordPro -o -

The difference in output between your version and mine is line 4, where I have chords 1 and 4 and you have #2 and #6. Is that correct?

Yes, except that I think it's just he opposite. The current release shows #2 and #6 (wrong) and the version with my changes shows 1 and 4 (correct).

At least, that is what I see when I do that same test here, and what I'd expect.

@sciurius
Copy link
Copy Markdown
Collaborator

Let's split.

t/cho/cho026.cho

{new_song}
{title: Nashville C}
{key: Am}

[C]Hello, [G]World!

{new_song}
{title: Nashville D}
{key: D}

[D]Hello, [G]World!

Desired output from perl script/chordpro.pl -X t/cho/cho026.cho --xc nashville --gen ChordPro -o - ?

t/cho/cho027.cho

{new_song}
{title: Roman C}
{key: Am}

[C]Hello, [G]World!

{new_song}
{title: Roman D}
{key: D}

[D]Hello, [G]World!

Desired output from perl script/chordpro.pl -X t/cho/cho027.cho --xc roman --gen ChordPro -o - ?

@MerijnBosma
Copy link
Copy Markdown
Contributor Author

MerijnBosma commented Nov 19, 2025

cho026

desired output

{title: Nashville C}
{key: 6m}

[1]Hello, [5]World!

{new_song}
{title: Nashville D}
{key: 2}

[1]Hello, [4]World!

output of new code

{title: Nashville C}
{key: 6m}

[1]Hello, [5]World!

{new_song}
{title: Nashville D}
{key: 2}

[1]Hello, [4]World!

output of current release

{title: Nashville C}
{key: 6m}

[#2]Hello, [#6]World!

{new_song}
{title: Nashville D}
{key: 2}

[1]Hello, [4]World!

cho027

desired output

{title: Roman C}
{key: VI}

[I]Hello, [V]World!

{new_song}
{title: Roman D}
{key: II}

[I]Hello, [IV]World!

output of new code

{title: Roman C}
{key: VI}

[#II]Hello, [#VI]World!

{new_song}
{title: Roman D}
{key: II}

[I]Hello, [IV]World!

output of current release

{title: Roman C}
{key: VI}

[#II]Hello, [#VI]World!

{new_song}
{title: Roman D}
{key: II}

[I]Hello, [IV]World!

So it turns out that roman doesn't work as expected yet. I'm going to take another look at the code if I can find why this happens.

Ensures that the original key is used for Nashville notation
calculations when the key has already been transcoded, preventing
incorrect chord transformations.

Fixes ChordPro#526
@MerijnBosma
Copy link
Copy Markdown
Contributor Author

ok, I've updated the pr, now I also get the desired result for cho27 with the new code.

ChordPro pushed a commit that referenced this pull request Nov 20, 2025
@sciurius
Copy link
Copy Markdown
Collaborator

Looks okay.
Can you rebase the PR on the dev branch? That's where new development takes place.

@MerijnBosma
Copy link
Copy Markdown
Contributor Author

MerijnBosma commented Nov 20, 2025

Looks okay. Can you rebase the PR on the dev branch? That's where new development takes place.

I don't think I can do that on your repo?

Or do you mean that I should create a new PR on the dev branch?

@sciurius
Copy link
Copy Markdown
Collaborator

I have rebased the PR and applied it. Thanks!

@sciurius sciurius closed this Nov 21, 2025
@sciurius sciurius reopened this Nov 22, 2025
@sciurius
Copy link
Copy Markdown
Collaborator

I've added some test cases in t/71_cho.t.

Without this PR, tests cho026n and cho027r fail.
With this PR, test cho028 starts failing.

Can you take a look?

@sciurius sciurius added the regression PR causes regression errors label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

regression PR causes regression errors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sheets with minor key in nashville notation should be centered around relative major

2 participants