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 539ce24
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 173 deletions.
56 changes: 41 additions & 15 deletions libmscore/beam.cpp
Expand Up @@ -675,8 +675,8 @@ static void initBeamMetrics()
B(0, 3, 4, 13, 1);
B(0, 3, 5, 13, 2);
B(0, 3, 6, 14, 4);
B(0, 3, 7, 13, 4);
B(0, 3, 8, 13, 6);
B(0, 3, 7, 14, 4);
B(0, 3, 8, 14, 6);

B(0, 3, 2, 11, -1);
B(0, 3, 1, 11, -2);
Expand Down Expand Up @@ -716,17 +716,17 @@ 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);
B(0, 2, 5, 13, 4); // F
B(0, 2, 6, 15, 5);
B(0, 2, 7, 13, 6);
B(0, 2, 7, 15, 6);
B(0, 2, 8, 16, 8);
B(0, 2, 9, 16, 8);

Expand All @@ -741,7 +741,7 @@ static void initBeamMetrics()
// =================================== E
B(1, 8, 8, -12, 0);
B(0, 1, 1, 13, 0);
B(1, 1, 1, -9, 0);
B(1, 1, 1, -12, 0);

B(1, 8, 7, -12, -1);
B(1, 8, 6, -12, -4);
Expand All @@ -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 @@ -796,7 +796,7 @@ static void initBeamMetrics()
// =================================== F
B(1, 7, 7,-13, 0); //F
B(0, 0, 0, 12, 0);
B(0, 7, 7, 10, 0);
B(0, 7, 7, 12, 0);

B(1, 7, 6, -13, -1);
B(1, 7, 5, -13, -2);
Expand Down Expand Up @@ -908,8 +908,8 @@ static void initBeamMetrics()
B(1, 5, 4, -13, -1);
B(1, 5, 3, -13, -2);
B(1, 5, 2, -14, -4);
B(1, 5, 1, -14, -4);
B(1, 5, 0, -13, -6);
B(1, 5, 1, -15, -4);
B(1, 5, 0, -15, -6);

B(1, 12, 11, -15, -1);
B(1, 12, 10, -15, -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
40 changes: 20 additions & 20 deletions mtest/libmscore/beam/Beam-A.mscx
Expand Up @@ -260,8 +260,8 @@
</Chord>
<Beam id="7">
<StemDirection>up</StemDirection>
<l1>-4</l1>
<l2>-8</l2>
<l1>-5</l1>
<l2>-9</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand All @@ -288,8 +288,8 @@
</LayoutBreak>
<Beam id="8">
<StemDirection>up</StemDirection>
<l1>-3</l1>
<l2>-9</l2>
<l1>-7</l1>
<l2>-11</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand Down Expand Up @@ -420,7 +420,7 @@
</Note>
</Chord>
<Beam id="14">
<l1>9</l1>
<l1>8</l1>
<l2>4</l2>
</Beam>
<Chord>
Expand All @@ -444,7 +444,7 @@
<Measure number="6">
<Beam id="15">
<StemDirection>up</StemDirection>
<l1>8</l1>
<l1>7</l1>
<l2>3</l2>
</Beam>
<Chord>
Expand Down Expand Up @@ -487,7 +487,7 @@
</Chord>
<Beam id="17">
<StemDirection>up</StemDirection>
<l1>4</l1>
<l1>3</l1>
<l2>-1</l2>
</Beam>
<Chord>
Expand Down Expand Up @@ -567,7 +567,7 @@
<Beam id="20">
<StemDirection>up</StemDirection>
<l1>-1</l1>
<l2>4</l2>
<l2>3</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
Expand All @@ -588,7 +588,7 @@
<Beam id="21">
<StemDirection>up</StemDirection>
<l1>-1</l1>
<l2>4</l2>
<l2>3</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand Down Expand Up @@ -616,7 +616,7 @@
<Beam id="22">
<StemDirection>up</StemDirection>
<l1>-1</l1>
<l2>4</l2>
<l2>3</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
Expand All @@ -636,7 +636,7 @@
</Chord>
<Beam id="23">
<l1>-1</l1>
<l2>4</l2>
<l2>3</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand All @@ -657,7 +657,7 @@
</Chord>
<Beam id="24">
<l1>-1</l1>
<l2>4</l2>
<l2>3</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
Expand Down Expand Up @@ -723,7 +723,7 @@
</Note>
</Chord>
<Beam id="27">
<l1>8</l1>
<l1>9</l1>
<l2>13</l2>
</Beam>
<Chord>
Expand All @@ -743,7 +743,7 @@
</Note>
</Chord>
<Beam id="28">
<l1>11</l1>
<l1>12</l1>
<l2>16</l2>
</Beam>
<Chord>
Expand All @@ -770,7 +770,7 @@
<pause>3</pause>
</LayoutBreak>
<Beam id="29">
<l1>12</l1>
<l1>13</l1>
<l2>17</l2>
</Beam>
<Chord>
Expand Down Expand Up @@ -811,7 +811,7 @@
</Note>
</Chord>
<Beam id="31">
<l1>16</l1>
<l1>17</l1>
<l2>21</l2>
</Beam>
<Chord>
Expand Down Expand Up @@ -1064,7 +1064,7 @@
</Chord>
<Beam id="42">
<l1>21</l1>
<l2>16</l2>
<l2>17</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand Down Expand Up @@ -1092,7 +1092,7 @@
<Beam id="43">
<StemDirection>down</StemDirection>
<l1>21</l1>
<l2>16</l2>
<l2>17</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
Expand All @@ -1113,7 +1113,7 @@
<Beam id="44">
<StemDirection>down</StemDirection>
<l1>21</l1>
<l2>16</l2>
<l2>17</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
Expand All @@ -1135,7 +1135,7 @@
<Beam id="45">
<StemDirection>down</StemDirection>
<l1>21</l1>
<l2>16</l2>
<l2>17</l2>
</Beam>
<Chord>
<durationType>eighth</durationType>
Expand Down

0 comments on commit 539ce24

Please sign in to comment.