Skip to content

Commit

Permalink
fix #41761: beam angle too sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Mar 7, 2015
1 parent 4fe7cb1 commit 7e9824d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
42 changes: 34 additions & 8 deletions libmscore/beam.cpp
Expand Up @@ -716,11 +716,11 @@ static void initBeamMetrics()

B(0, -5,-4, 16, 2);
B(0, -5,-3, 16, 2);
B(0, -5,-2, 16, 2);
B(0, -5,-1, 16, 2);
B(0, -5, 0, 16, 4);
B(0, -5, 1, 16, 5);
B(0, -5, 2, 16, 5);
B(0, -5,-2, 17, 2);
B(0, -5,-1, 17, 2);
B(0, -5, 0, 18, 4);
B(0, -5, 1, 18, 5);
B(0, -5, 2, 21, 5);

B(0, 2, 3, 12, 1);
B(0, 2, 4, 12, 4);
Expand Down Expand Up @@ -753,8 +753,8 @@ static void initBeamMetrics()

B(1, 15, 11, -21, -1);
B(1, 15, 10, -21, -1);
B(1, 15, 9, -21, -1);
B(1, 15, 8, -21, -1);
B(1, 15, 9, -21, -4);
B(1, 15, 8, -21, -5);

B(1, 1, 8, -11, 6);
B(1, 1, 7, -11, 6);
Expand All @@ -766,7 +766,7 @@ static void initBeamMetrics()
B(1, 8, 12, -12, 5);
B(1, 8, 13, -12, 4);
B(1, 8, 14, -12, 5);
B(1, 8, 15, -12, 1);
B(1, 8, 15, -12, 5);

B(0, 1, 0, 11, -1);
B(0, 1, -1, 11, -2);
Expand Down Expand Up @@ -1164,6 +1164,28 @@ void Beam::computeStemLen(const QList<ChordRest*>& cl, qreal& py1, int beamLevel
if (hasNoSlope())
bm.s = 0.0;

// special case for two beamed notes: flatten to max of 1sp
static int maxShortSlant = 4;
if (bm.l && elements().size() == 2) {
//qDebug("computeStemLen: l = %d, s = %d", (int)bm.l, (int)bm.s);
if (bm.s > maxShortSlant) {
// slant downward
// lengthen first stem if down
if (bm.l > 0)
bm.l += bm.s - maxShortSlant;
// flatten beam
bm.s = maxShortSlant;
}
else if (bm.s < -maxShortSlant) {
// slant upward
// lengthen first stem if up
if (bm.l < 0)
bm.l -= -maxShortSlant - bm.s;
// flatten beam
bm.s = -maxShortSlant;
}
}

if (bm.l) {
if (bm.l > 0)
bm.l -= graceStemLengthCorrection;
Expand Down Expand Up @@ -1264,6 +1286,10 @@ void Beam::computeStemLen(const QList<ChordRest*>& cl, qreal& py1, int beamLevel
uint interval = qAbs((l2 - l1) / 2);
minS = minSlant(interval);
maxS = maxSlant(interval);
if (elements().size() == 2) {
minS = qMin(minS, 2);
maxS = qMin(maxS, 4);
}
}
int ll1;
if (_up) {
Expand Down
Binary file added vtest/beams-16-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/beams-16.mscz
Binary file not shown.
2 changes: 1 addition & 1 deletion vtest/gen
Expand Up @@ -47,7 +47,7 @@ else
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 grace-4 tuplets-1 breath-1\
harmony-1 harmony-2 harmony-3 harmony-4 harmony-5 harmony-6 harmony-7 harmony-8 harmony-9 harmony-10 harmony-11\
beams-1 beams-2 beams-3 beams-4 beams-5 beams-6 beams-7 beams-8 beams-9 beams-10\
beams-11 beams-12 beams-13 beams-14 beams-15\
beams-11 beams-12 beams-13 beams-14 beams-15 beams-16\
user-offset-1 user-offset-2 chord-space-1 chord-space-2 tablature-1 image-1\
lyrics-1 lyrics-2 lyrics-3 lyrics-4 voice-1 voice-2 slash-1 slash-2 system-1 system-2 system-3"
fi
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Expand Up @@ -22,7 +22,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,grace-4,tuplets-1,breath-1, ^
harmony-1,harmony-2,harmony-3,harmony-4,harmony-5,harmony-6,harmony-7,harmony-8,harmony-9,harmony-10,harmony-11, ^
beams-1,beams-2,beams-3,beams-4,beams-5,beams-6,beams-7,beams-8,beams-9,beams-10, ^
beams-11,beams-12,beams-13,beams-14,beams-15, ^
beams-11,beams-12,beams-13,beams-14,beams-15,beams-16, ^
user-offset-1,user-offset-2,chord-space-1,chord-space-2,tablature-1,image-1, ^
lyrics-1,lyrics-2,lyrics-3,lyrics-4,voice-1,voice-2,slash-1,slash-2,system-1,system-2,system-3

Expand Down

0 comments on commit 7e9824d

Please sign in to comment.