Skip to content

Fix #303623: Fix multiple issues with chord diagrams in MusicXML export #5958

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

Closed
wants to merge 1 commit into from

Conversation

thibault
Copy link
Contributor

Resolves: https://musescore.org/en/node/303623

There are multiple issues in the MusicXML annotations export that prevents chord diagrams to be exported in most cases:

  • chord diagrams are not exported unless there is a sibling harmony element.
  • only one chord diagram is exported for a chord.
  • chord diagrams that are not linked to a chord are not exported.
  • chord diagrams are not always exported to the correct voice.

This PR rewrites the harmony export algorithm to fix those issues.

This is my first contribution to MuseScore and moreover I'm not familiar with c++ at all, so there will probably be some stuff to fix.

  • I signed CLA
  • I made sure the code in the PR follows the coding rules
  • I made sure the code compiles on my machine
  • I made sure there are no unnecessary changes in the code
  • I made sure the title of the PR reflects the core meaning of the issue you are solving
  • I made sure the commit message(s) contain a description and answer the question "Why do those changes fix that particular issue?" or "Why are those changes really necessary as improvements?"
  • I made sure the commit message title starts with "fix #424242:" if there is a related issue
  • I created the test (mtest, vtest, script test) to verify the changes I made

@thibault thibault marked this pull request as ready for review April 16, 2020 19:12
@Jojo-Schmitz
Copy link
Contributor

There are quite a few MusicXML tests failing, see https://travis-ci.org/github/musescore/MuseScore/jobs/675894505#L4385 ff.


for (const Element* e : seg->annotations()) {
int wtrack = -1; // track to write annotation
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite my best efforts, I still don't understand what are those wtrack checks are used for. Since I'm not too sure, I did'nt add such a check in the following harmonies method. Fill free to tell me where I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this might be related to this issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wtrack is the track where something is to be written. Required when MuseScore forces things in a staff's first track (e.g. staff text), when no note start at that time. This seems to no longer apply to harmonies.

const Harmony* harmony = diagram->harmony();
if (harmony) {
exp->harmony(harmony, diagram, offset);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line break and less indent before else. Maybe make it an else if

const Element* defaultHarmony = harmonies.back();
exp->harmony(toHarmony(defaultHarmony), diagram, offset);
harmonies.pop_back();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line break and less indent before else

// That's why we need to explore the remaining segments to find
// `Harmony` and `FretDiagram` elements in Segments without Chords and output them now.
for (auto seg1 = seg->next(); seg1; seg1 = seg1->next()) {
if (!seg1->isChordRestType()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

braces not needed here

@@ -6444,4 +6471,3 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
}

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded change

@Jojo-Schmitz
Copy link
Contributor

@lvinken: mind reviewing this?

@thibault
Copy link
Contributor Author

Hi @Jojo-Schmitz, thank you for your review. I fixed the formatting issues you mentioned.

@Jojo-Schmitz
Copy link
Contributor

And now it'd be good if you could squash them all into one commit, and making sure the commit title (not just the PR title) is "Fix #303623: Fix multiple issues with chord diagrams in MusicXML export"

seg, fd);
}

for (const Element* e: harmonies) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

braces not needed here

@thibault thibault force-pushed the mxl_diagram_export branch 2 times, most recently from 0d86401 to 6ff0246 Compare April 17, 2020 07:59
@thibault
Copy link
Contributor Author

@Jojo-Schmitz Ok, I just force-pushed the squashed version of the branch.

@lvinken
Copy link
Contributor

lvinken commented Apr 18, 2020

Will have a look, but don't know when yet.

@lvinken
Copy link
Contributor

lvinken commented Apr 24, 2020

Started reviewing, may take a few days.

<root-step>F</root-step>
</root>
<kind>major</kind>
<offset>1</offset>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect (which is an existing bug), see https://musescore.org/en/node/304371.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Since this seems to be an existing bug that is not directly linked nor caused by this PR's modifications, how do you want to play this? Should this be corrected and added to the current PR or handled in a different one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the regression tests don't break, I can live with leaving this unsolved for some time. It does lead to invalid MusicXML, so I would want it fixed for 3.5.

@lvinken
Copy link
Contributor

lvinken commented Apr 25, 2020

Review done, thanks for implementing this, as it works a lot better than my previous implementation. No further comments.

@thibault
Copy link
Contributor Author

@lvinken Thank you for your review. @Jojo-Schmitz, is this good to merge?

if (harmony) {
exp->harmony(harmony, diagram, offset);
}
else if (! harmonies.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picky mode: that space after ! is not needed

@Jojo-Schmitz
Copy link
Contributor

Looks good to me too, with one minor exception.

@thibault thibault force-pushed the mxl_diagram_export branch from 6ff0246 to 2252102 Compare April 28, 2020 13:21
@thibault
Copy link
Contributor Author

@Jojo-Schmitz Hi. I just updated the PR with a fix for your last comment.

@thibault
Copy link
Contributor Author

thibault commented May 6, 2020

Hi @Jojo-Schmitz. I'm not sure about how the MuseScore project's handles PR merging. This PR has been hanging for a week, should I just be patient or are further actions required from me?

@Jojo-Schmitz
Copy link
Contributor

Patience. There a PRs that are several years old.
As far as I can tell it is ready to get merged. I'm not the one to decide though...

@thibault
Copy link
Contributor Author

thibault commented May 7, 2020

Hi @Jojo-Schmitz, I didn't want to rush you or anything, just make sure that I had done everything I could to get this fixed. I'll wait then :)

@Jojo-Schmitz
Copy link
Contributor

You can't rush me here, I can't merge PRs ;-)

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Nov 8, 2020

Oh, seems the name 'testHarmony6' is taken meanwhile (since 870db63), so these would need to get renamed to 'testHarmony7'.
So on top of rebasing there are 2 renames and a one-line change in mtest/musicxml/io/tst_mxml_io.cpp.

@vpereverzev
Copy link
Member

vpereverzev commented Nov 16, 2020

looking forward for rebase (on 3.x probably), then I'll merge it

@vpereverzev
Copy link
Member

Still looking for rebase

@vpereverzev vpereverzev added the archived PRs that have gone stale but could potentially be revived in the future label Nov 30, 2020
@vpereverzev
Copy link
Member

Archived due to inactivity (we can re-open it later once the author will return)

@kwertyops kwertyops mentioned this pull request Dec 27, 2020
12 tasks
@kwertyops
Copy link

@Jojo-Schmitz and @vpereverzev --

To keep this moving along, I've forked this fork, done the rebase onto 3.x, and submitted a new pull request.

See here: #7167

@Jojo-Schmitz
Copy link
Contributor

This seems still to be needed for master

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of musescore#5958
Fore some reason that PR's test files (testHarmony6.mscx, testHamony6_ref.xml) were already in master (as testHarmony7.mscx, testHamony76_ref.xml) but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of musescore#5958
Fore some reason that PR's test files (testHarmony6.mscx, testHamony6_ref.xml) were already in master (as testHarmony7.mscx, testHamony76_ref.xml) but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of musescore#5958
Fore some reason that PR's test files (testHarmony6.mscx, testHamony6_ref.xml) were already in master (as testHarmony7.mscx, testHamony76_ref.xml) but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of musescore#5958
Fore some reason that PR's test files (testHarmony6.mscx, testHamony6_ref.xml) were already in master (as testHarmony7.mscx, testHamony76_ref.xml) but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony76_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Mar 18, 2023
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jun 20, 2023
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Feb 1, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 28, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 28, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 28, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request May 5, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jun 23, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jun 23, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Jojo-Schmitz pushed a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jun 23, 2024
…icXML export

Port/rebase of @thibault's musescore#5958

For some reason that PR's test files (testHarmony6.mscx, testHarmony6_ref.xml) were already in master (as testHarmony7.mscx, testHarmony7_ref.xml), but not used in the unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived PRs that have gone stale but could potentially be revived in the future
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants