Skip to content

Conversation

SilverGreen93
Copy link
Contributor

@SilverGreen93 SilverGreen93 commented Oct 8, 2025

Partially resolves: #30167 (Part 2)

The C piano keys in the Piano Keyboard panel are always shown in standard pitch notation.

Display the notes with respect to locale by using the strings from global/pitchName.

Piano keyboard with Romanian locale:

Image

Piano keyboard with German locale:

Image
  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@SilverGreen93
Copy link
Contributor Author

Updated this PR as well based on the comment from #30415

@Jojo-Schmitz
Copy link
Contributor

That's a very cheap fix, I like it ;-)

@Jojo-Schmitz
Copy link
Contributor

Downside: for other languages it might look like
image
Here the added space seems a bit disturbing?

@SilverGreen93
Copy link
Contributor Author

Here the added space seems a bit disturbing?

For SPN notation, I removed the space in #30530, so it looks better.

@SilverGreen93
Copy link
Contributor Author

Here the added space seems a bit disturbing?

I removed spaces from all my PRs. It is better this way. Logic is easier.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Oct 15, 2025

BTW, Mu4 seems lacking Mu3's notename tooltips for the piano keyboard:
image
(along with the advanced setting to switch this off)

int octaveNumber = (key / 12) - 1;

QString octaveLabel = "C" + QString::number(octaveNumber);
octaveLabel = muse::qtrc("global/pitchName", octaveLabel.toStdString().c_str());
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is unsafe, because the std::string is destructed immediately after c_str() has been called, meaning that the pointer passed to qtrc is dangling. This would be solved by making octaveLabel immediately a std::string instead of QString, because then the lifetime of the std::string and its data is until the end of the scope, which is enough here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or make it static ;-)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that would solve anything, would it? (and octaveNumber isn't static either)

Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Oct 17, 2025

Choose a reason for hiding this comment

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

Probably, but how is this here different from

preset.name = muse::trc("instruments/stringTunings", presetObj.value("name").toStdString().c_str());

Or is that simply having the same issue?

Copy link
Member

Choose a reason for hiding this comment

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

I think that has the same issue indeed (but in practice, it probably only leads to a crash very seldom, because even though the std::string's memory is deleted, it is not immediately removed or filled with garbage).

Copy link
Contributor Author

@SilverGreen93 SilverGreen93 Oct 17, 2025

Choose a reason for hiding this comment

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

MuseScore/src/notation/internal/instrumentsrepository.cpp

I saw that as well, but I think @cbjeukendrup is right, seems to be a dangling pointer issue. Will fix accordingly. Thanks!

The C piano keys in the Piano Keyboard panel are always shown in standard pitch notation.

Display the notes with respect to locale by using the strings from `EditPitchBase`.
@cbjeukendrup cbjeukendrup merged commit 993c798 into musescore:master Oct 17, 2025
12 checks passed
@SilverGreen93 SilverGreen93 deleted the pianokey_localisation branch October 17, 2025 21:10
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

Successfully merging this pull request may close these issues.

Display pitch notation in language locale (Helmholtz or SPN)

3 participants