Skip to content

Commit

Permalink
Fix #125121: Formula determining octave number affecting split staff …
Browse files Browse the repository at this point in the history
…point
  • Loading branch information
finleylau authored and lasconic committed Feb 9, 2018
1 parent 2e112ab commit 470095f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion awl/utils.cpp
Expand Up @@ -59,7 +59,7 @@ QString pitch2string(int v)
{
if (v < 0 || v > 127)
return QString("----");
int octave = (v / 12) - 2;
int octave = (v / 12) - 1;
QString o;
o.sprintf("%d", octave);
int i = v % 12;
Expand Down
2 changes: 1 addition & 1 deletion libmscore/utils.cpp
Expand Up @@ -508,7 +508,7 @@ QString pitch2string(int v)
{
if (v < 0 || v > 127)
return QString("----");
int octave = (v / 12) - 2;
int octave = (v / 12) - 1;
QString o;
o.sprintf("%d", octave);
int i = v % 12;
Expand Down

4 comments on commit 470095f

@mirabilos
Copy link
Contributor

Choose a reason for hiding this comment

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

This problem already occurred in commit 9649548

Maybe it’s time to factor this out into a macro? #define TO_OCTAVE(x) (((x) / 12) - 1)

@anatoly-os
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is time (in 2018) to avoid using macros for such calculations and start using unified namespace with such methods... Something like MSUtils?
Just my thoughts.

@mirabilos
Copy link
Contributor

Choose a reason for hiding this comment

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

@anatoly-os if you want to have function-call performance penalty on many (depending on the compiler and the implementation, even most) uses… sure… I’d prefer it to stay fast.

@anatoly-os
Copy link
Contributor

Choose a reason for hiding this comment

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

@mirabilos I prefer facts. Scott Meyers showed some in Item '2: Prefer consts, enums, and inlines to #defines' in Effective C++. Personally, I have one more disadvantage - I cannot debug through macros. Speaking about performance, did you ever check the penalty you mentioned in MuseScore? I'm sure that such optimizations are not actual on desktop/laptop systems. So, as MuseScore is not used on embedded devices, I prefer maintainability and ease of support and debugging.

Please sign in to comment.