Skip to content

Commit 2d691a7

Browse files
authored
Add support for crescendo and decrescendo in alphaTex (#338)
* Added crescendo/decrescendo parsing to alphaTex * Added docs for crescendo
1 parent 00364b6 commit 2d691a7

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Documentation/input/alphatex/beat-effects.cshtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TexSample: true
66
<p>
77
There are various effects that can be applied to a beat. All beat
88
effects are specified in braces after the beat.
9-
<code>Beat{Effects}</code>
9+
<code>Beat{Effects}</code> Multiple effects are simple separated by spaces like <code>3.3 {f v}</code>
1010
</p>
1111

1212
<h2 id="simple-effects">Simple Effects</h2>
@@ -48,6 +48,9 @@ TexSample: true
4848
|
4949
// tremolo picking (`tp duration` where duration can be 8,16 or 32)
5050
3.3{tp 8} 3.3{tp 16} 3.3{tp 32}
51+
|
52+
// Crescendo / Decrescendo
53+
3.3{cre} 3.3{cre} 3.3{dec} 3.3{dec}
5154
</div>
5255
<script type="text/x-alphatab">
5356
$('#alphaTabBeatEffects').alphaTab();

Source/AlphaTab.Test/Importer/AlphaTexImporterTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,5 +967,15 @@ public void TestDynamics()
967967
}
968968

969969

970+
[TestMethod]
971+
public void TestCrescendo()
972+
{
973+
var tex = @"1.1.4{dec} 1.1{dec} 1.1{cre} 1.1{cre}";
974+
var score = ParseTex(tex);
975+
Assert.AreEqual(CrescendoType.Decrescendo, score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[0].Crescendo);
976+
Assert.AreEqual(CrescendoType.Decrescendo, score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[1].Crescendo);
977+
Assert.AreEqual(CrescendoType.Crescendo, score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[2].Crescendo);
978+
Assert.AreEqual(CrescendoType.Crescendo, score.Tracks[0].Staves[0].Bars[0].Voices[0].Beats[3].Crescendo);
979+
}
970980
}
971981
}

Source/AlphaTab/Importer/AlphaTexImporter.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,20 @@ private bool ApplyBeatEffect(Beat beat)
15351535
return true;
15361536
}
15371537

1538+
if (syData == "cre")
1539+
{
1540+
beat.Crescendo = CrescendoType.Crescendo;
1541+
NewSy();
1542+
return true;
1543+
}
1544+
1545+
if (syData == "dec")
1546+
{
1547+
beat.Crescendo = CrescendoType.Decrescendo;
1548+
NewSy();
1549+
return true;
1550+
}
1551+
15381552
if (syData == "tp")
15391553
{
15401554
NewSy();

0 commit comments

Comments
 (0)