Skip to content

Commit

Permalink
improve att.stems
Browse files Browse the repository at this point in the history
  • Loading branch information
rettinghaus committed Apr 7, 2020
1 parent 72b4373 commit 503db30
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
38 changes: 18 additions & 20 deletions mei2ly.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,7 @@
<xsl:call-template name="setOffset" />
</xsl:if>
<xsl:apply-templates mode="setStemDir" select="." />
<xsl:if test="@stem.len">
<xsl:value-of select="concat('\tweak Stem.length #', local:VU2LY(@stem.len) * 2, ' ')" />
</xsl:if>
<xsl:call-template name="setStemVisibility" />
<xsl:apply-templates select="@stem.len|@stem.visible" />
<!-- att.noteheads -->
<xsl:if test="@head.color">
<xsl:text>\tweak color #</xsl:text>
Expand Down Expand Up @@ -1054,10 +1051,7 @@
<xsl:text>\tweak Flag.stroke-style #"grace" </xsl:text>
</xsl:if>
<xsl:apply-templates mode="setStemDir" select="." />
<xsl:if test="@stem.len">
<xsl:value-of select="concat('\tweak Stem.length #', local:VU2LY(@stem.len) * 2, ' ')" />
</xsl:if>
<xsl:call-template name="setStemVisibility" />
<xsl:apply-templates select="@stem.len|@stem.visible" />
<xsl:apply-templates select="mei:note" />
<xsl:text>&gt;</xsl:text>
<xsl:call-template name="setDuration" />
Expand Down Expand Up @@ -3100,7 +3094,7 @@
</xsl:template>
<xsl:template mode="setStemDir" match="*[@stem.pos and not(@stem.dir)]">
<!-- data.STEMPOSITION -->
<xsl:value-of select="concat('\tweak Stem.direction #', translate(@stem.pos, 'cefghilntr', 'CEFGHILNTR'), ' ')" />
<xsl:value-of select="concat('\tweak Stem.direction #', upper-case(@stem.pos), ' ')" />
</xsl:template>
<xsl:template mode="setStemDir" match="*" />
<!-- set duration -->
Expand Down Expand Up @@ -3325,6 +3319,21 @@
<xsl:with-param name="direction" select="." />
</xsl:call-template>
</xsl:template>
<!-- att.stems -->
<xsl:template match="@stem.len">
<xsl:value-of select="concat('\tweak Stem.length #', local:VU2LY(.) * 2, ' ')" />
</xsl:template>
<xsl:template match="@stem.visible">
<xsl:choose>
<!-- Stem.stencil won't be sufficant -->
<xsl:when test=". = true()">
<xsl:value-of select="'\tweak Stem.transparent ##f '" />
</xsl:when>
<xsl:when test=". = false()">
<xsl:value-of select="'\tweak Stem.transparent ##t '" />
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- exclude untweaked attributes -->
<xsl:template match="@*" mode="tweak" />
<!-- set grace notes -->
Expand Down Expand Up @@ -4160,17 +4169,6 @@
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="setStemVisibility">
<!-- att.visibility -->
<xsl:choose>
<xsl:when test="@stem.visible = true()">
<xsl:value-of select="'\tweak Stem.transparent ##f '" />
</xsl:when>
<xsl:when test="@stem.visible = false()">
<xsl:value-of select="'\tweak Stem.transparent ##t '" />
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- modify note head -->
<xsl:template name="modifyNotehead">
<!-- data.NOTEHEADMODIFIER.list -->
Expand Down
2 changes: 1 addition & 1 deletion tests/merging-rests.mei
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<staff n="1">
<layer n="1">
<rest dur="4" xml:id="rest01a" />
<rest dur="4" xml:id="rest01b" sameas="#rest02b" />
<rest sameas="#rest02b" xml:id="rest01b" />
<rest dur="4" xml:id="rest01c" />
</layer>
<layer n="2">
Expand Down
5 changes: 3 additions & 2 deletions tests/stems.mei
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meiHead>
<fileDesc>
<titleStmt>
<title/>
<title>Different stem lengths</title>
</titleStmt>
<pubStmt>
<respStmt>
Expand All @@ -29,11 +29,12 @@
<measure n="1" right="dbl">
<staff n="1">
<layer n="1">
<note dur="4" oct="4" pname="c" accid.ges="n" stem.len="0"/>
<note dur="4" oct="4" pname="c" accid.ges="n" stem.visible="false"/>
<note dur="4" oct="4" pname="d" accid.ges="n" stem.len="2" stem.dir="down"/>
<note dur="4" oct="4" pname="e" accid.ges="n" stem.len="3" stem.dir="down"/>
<note dur="4" oct="4" pname="f" accid.ges="n" stem.len="4" stem.dir="down"/>
<note dur="4" oct="4" pname="g" accid.ges="n" stem.len="5" stem.dir="down"/>
<note dur="4" oct="4" pname="a" accid.ges="n" stem.visible="true" stem.dir="down"/>
</layer>
</staff>
</measure>
Expand Down
Binary file modified tests/stems.preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 20 additions & 17 deletions tests/stems.preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 503db30

Please sign in to comment.