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

Harp pedalling diagrams and harp notation palette #12269

Closed
wants to merge 10 commits into from

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Jul 4, 2022

This pull request adds harp pedalling diagrams to MuseScore for GSoC 2022.
These diagrams will be editable through a UI which will be built in the coming weeks.

Debussy-MS-1

Known issues

  • Save in score
  • Inspector
  • Style properties
  • Style (diagram size, placement) is not final and will be amended.
  • Text diagrams are not finished. A start has been made.
  • Screenreader not yet working
  • Some issues with internal xml representation causing loss of data (eg. between palette and score) - input on this very welcome!
  • Harp diagram not using the Leland font when it is set in styledef.cpp and the style menu in the program

  • 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

setXmlText(diagram);
}

const String HarpPedalDiagram::getStringName(HarpString str)
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should be static and should be declared directly in this file. Also, HarpString should be renamed to HarpStringType (and the argument to "type" accordingly). After these manipulations the method itself should be renamed to harpStringTypeToString

@@ -788,6 +788,24 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
{ Sid::stringNumberFrameBgColor, "stringNumberFrameBgColor", PropertyValue::fromValue(draw::Color::transparent) },
{ Sid::stringNumberOffset, "stringNumberOffset", PointF(0.0, 0.0) },

{ Sid::harpPedalDiagramFontFace, "harpPedalDiagramFontFace", "Leland" },
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably should not be Leland, since <sym> symbols will automatically use the "Text" variant of the currently selected score font (e.g. Leland Text).

Copy link
Contributor

Choose a reason for hiding this comment

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

Also consider using these symbols for the accidentals (they will be a better size): https://www.w3.org/2019/03/smufl13/tables/standard-accidentals-for-chord-symbols.html

diagram.append(strName + String("<sym>accidentalNatural</sym>, "));
break;
case PedalPosition::SHARP:
diagram.append(strName + String("<sym>accidentalSharp</sym>, "));
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is not usual to include a comma. Also, from what I can find on the internet, it is common to put D, C, and B on a second line. This is from Dorico:
image
@oktophonie Can you confirm that this is desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The text diagrams in the design I'm following from @Tantacrul are only supposed to show the changes over previous settings, but yes the above is what I'd expect as a sort of initial state.
I'm still working on the text diagrams so can change this if need be!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, showing only changes is good, but even then Dorico puts D,C,B on a separate line. I'm wondering if we should do that too.
Schermafbeelding 2022-07-07 om 16 10 41

Copy link
Contributor

Choose a reason for hiding this comment

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

@oktophonie - thoughts about having two lines?

Copy link
Contributor

Choose a reason for hiding this comment

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

Two lines is standard, as arranged in the Dorico example, and there should be no commas.

(One line is possible (D C B E F G A) but I've very rarely seen this - it would usually be just to save space in particularly tight situations.)

@miiizen
Copy link
Contributor Author

miiizen commented Jul 12, 2022

Both types of pedal diagrams are now finished. The UI to edit them can be submitted as a separate PR or added to this one.
I'll squash and rebase later in case there's much to change.
Thanks!

@miiizen miiizen marked this pull request as ready for review July 12, 2022 17:43
@@ -1209,6 +1209,18 @@ void LayoutSystem::layoutSystemElements(const LayoutOptions& options, LayoutCont
}
}
}

//-------------------------------------------------------------
// Harp pedal diagrams
Copy link
Contributor

Choose a reason for hiding this comment

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

By putting this at the bottom of the function, harp pedal diagrams will be stacked 'outside' of everything else. For example, if they are above the staff, they will appear even above tempo markings and rehearsal marks. @oktophonie What would be the correct stacking order?

Copy link
Contributor

Choose a reason for hiding this comment

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

@miiizen, as suggested by @oktophonie, let's place them for now "outside" ottavas but "inside" anything else. That would mean moving this block of code to just above

//
// We need to known if we have FretDiagrams in the system to decide when to layout the Harmonies
//
bool hasFretDiagram = false;

@oktophonie
Copy link
Contributor

Like other indications of playing technique I'd expect them to stay close to the stave without too much getting in between. This is pretty easy if they are between the staves or below the bottom one. For placing them above, someone with access to a lot of solo harp material might better advise. I'd expect them to go outside of 8va markings but inside anything else(?)

@shoogle shoogle mentioned this pull request Aug 23, 2022
12 tasks
@@ -522,6 +524,9 @@ EngravingItem* ChordRest::drop(EditData& data)
if (fromPalette) {
r->setXmlText(score()->createRehearsalMarkText(r));
}
} else if (e->isHarpPedalDiagram()) {
HarpPedalDiagram* h = toHarpPedalDiagram(e);
h->updateDiagramText();
Copy link
Contributor

Choose a reason for hiding this comment

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

You could consider overriding the added() method in HarpPedalDiagram and then moving the call to updateDiagramText(); to the added() method.


class HarpPedalDiagram final : public TextBase
{
std::vector<PedalPosition> _pedalState;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the number of entries is/should always be 7, how about using std::array<PedalPosition, 7>?

static std::vector<std::pair<String, String> > symbolReplacements {
{ u"\ued60", u"b " },
{ u"\ued61", u" nat " },
{ u"\ued62", u"# " }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these things will need to be translatable. You could drop this method in this PR and do it in #12597 instead. Let's ask @shoogle to advise about what the description should be exactly.

case HarpStringType::A:
return String("A");
case HarpStringType::B:
return String("B");
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to take into account German note names. @oktophonie what do you think?

If yes, I'm not completely sure how to do that. We could do this through the 'normal' translation system that is also used for the UI, but that means that scores will look different if you open them in a MuseScore with a different language, which seems a bit dangerous to me. ISTR that we have some code somewhere to compute German note names, but I don't remember where and how it should be used.

using namespace mu::engraving;

// Position of separator character in diagram
static const int SEPARATOR_IDX = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be constexpr instead of just const

using namespace mu::engraving;

namespace mu::engraving {
enum class PedalPosition {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could write enum class PedalPosition : char {, to specify that this enum only needs the space of a char (1 byte). Same for HarpStringType. Tiny memory usage optimization.

for (int idx = 0; idx < _pedalState.size(); idx++) {
if (idx == SEPARATOR_IDX) {
// insert separator
diagram.append(String("\ue683"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there are reason to not use
<sym>harpPedalDivider</sym>
<sym>harpPedalRaised</sym>
<sym>harpPedalCentered</sym>
<sym>harpPedalLowered</sym>
respectively instead of the unicode values? That way, Leland should be used automatically as the font for the symbols. See also https://github.com/musescore/MuseScore/pull/12269/files#r915853649

(We might need to make sure here too that we're using Leland and not Leland Text; see

if (t->isDynamic() || t->textStyleType() == TextStyleType::OTTAVA) {
.)

@@ -99,6 +99,7 @@ const char* PaletteCell::translationContext() const
case ElementType::BREATH:
case ElementType::FERMATA:
case ElementType::SYMBOL:
case ElementType::HARP_DIAGRAM:
Copy link
Contributor

Choose a reason for hiding this comment

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

For ElementType::HARP_DIAGRAM, this method should return "palette" (it should correspond with:

sp->appendElement(pedalDiagram, QT_TRANSLATE_NOOP("palette", "Harp pedal diagram"));
                                                   ^~~~~~~

and

sp->appendElement(pedalTextDiagram, QT_TRANSLATE_NOOP("palette", "Harp pedal text"));
                                                       ^~~~~~~

@@ -163,6 +164,7 @@ static const ElementName elementNames[] = {
{ ElementType::STAFFTYPE_CHANGE, "StaffTypeChange", QT_TRANSLATE_NOOP("elementName", "Staff type change") },
{ ElementType::HARMONY, "Harmony", QT_TRANSLATE_NOOP("elementName", "Chord symbol") },
{ ElementType::FRET_DIAGRAM, "FretDiagram", QT_TRANSLATE_NOOP("elementName", "Fretboard diagram") },
{ ElementType::HARP_DIAGRAM, "HarpPedalDiagram", QT_TRANSLATE_NOOP("elementName", "Harp Pedal Diagram") },
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing: for ui texts, we use "Sentence case" instead of "Title Case". So this one would be "Harp pedal diagram".


auto pedalTextDiagram = Factory::makeHarpPedalDiagram(gpaletteScore->dummy()->segment());
pedalTextDiagram->setIsDiagram(false);
pedalTextDiagram->updateDiagramText();
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also consider to call updateDiagramText() in layout(), so that you don't need to remember to call it and so that it will always be up-to-date when other diagrams earlier in the score are modified.

(If you decide to do so, then my comment in src/engraving/libmscore/chordrest.cpp doesn't apply anymore)

@cbjeukendrup
Copy link
Contributor

A rebase is needed. It would have my preference to merge this PR first, so that we can review the new changes in #12597 in isolation.

case HarpStringType::G:
return String("G");
}
return String("");
Copy link
Contributor

@cbjeukendrup cbjeukendrup Aug 24, 2022

Choose a reason for hiding this comment

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

Better just String() instead of String("") (in all places where an empty String is created).

Also, those String literals should be prefixed with u. So: String(u"A") or simply u"A".

Otherwise, you are converting from const char* to QString and then from QString to String. That's undesired because we want that the engraving module doesn't depend on Qt.

@cbjeukendrup
Copy link
Contributor

Some quick tips for rebasing, in case it's useful:

  • About the #includes and forward declarations, I have recently done a PR to sort those alphabetically. This gives somewhat strange conflicts; to solve them, just choose the change from the master branch (or maybe Git will call it "Updated upstream") and then re-insert the #include that you inserted, please in the correct alphabetical order.
  • static const ElementName elementNames[] has been moved to typesconv.cpp
  • ElementType has been moved to types/types.h as opposed to libmscore/types.h
  • QT_TRANSLATE_NOOP has been replaced with TranslatableString (in many cases);
  • In PaletteCreator.cpp, some other new palettes have been added; you can simply preserve both changes

So in this case, the best strategy is often to choose the changes from the master branch and then reapply your additions. Of course, during rebasing, you can still see your changes (as they were before the rebase) here on GitHub, which you can use as a reference.

Finally: you could save the SHA of your last commit, 340ad21, so that if it goes completely wrong you can do git checkout 340ad21e138dc486a9294bd6e3e1fd838decdbd7 to go back to the state before rebase.

@miiizen miiizen closed this Aug 25, 2022
@Jojo-Schmitz
Copy link
Contributor

Huh?

@miiizen
Copy link
Contributor Author

miiizen commented Aug 25, 2022

Sorry for the confusion, please see #12597!

@Jojo-Schmitz
Copy link
Contributor

But how does that match with #12269 (comment) ?

@cbjeukendrup
Copy link
Contributor

@Jojo-Schmitz We changed the plans a bit; it is not very convenient for @miiizen to continuously maintain two PRs. We decided to move on with #12597.

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.

None yet

6 participants