You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2003/08/19 03:11:06 UTC
cvs commit: cocoon-2.1/src/blocks/midi/samples/stylesheets transpose.xsl invert.xsl
joerg 2003/08/18 18:11:06
Modified: src/blocks/midi/samples/stylesheets transpose.xsl invert.xsl
Log:
some optimizations either on readability or performance (hopefully a good compromise, I hate global variables ;-) )
Revision Changes Path
1.2 +8 -8 cocoon-2.1/src/blocks/midi/samples/stylesheets/transpose.xsl
Index: transpose.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/midi/samples/stylesheets/transpose.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- transpose.xsl 16 Aug 2003 14:37:07 -0000 1.1
+++ transpose.xsl 19 Aug 2003 01:11:06 -0000 1.2
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="transposition" select="0"/>
<xsl:template match="NOTE_ON">
- <xsl:variable name="fixedTransposition">
+ <xsl:variable name="offset">
<xsl:choose>
<xsl:when test="not(number($transposition) = number($transposition))">
<xsl:message>The parameter $transposition must be a number!</xsl:message>
@@ -16,15 +15,16 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
- <xsl:variable name="offset" select="$fixedTransposition"/>
- <NOTE_ON PITCH="{@PITCH + $offset}" REGISTER="{@REGISTER}" VELOCITY="{@VELOCITY}">
- <xsl:apply-templates/>
+ <NOTE_ON PITCH="{@PITCH + $offset}">
+ <xsl:copy-of select="@REGISTER | @VELOCITY"/>
+ <xsl:apply-templates/>
</NOTE_ON>
</xsl:template>
- <xsl:template match="node()|@*">
+ <xsl:template match="node()">
<xsl:copy>
- <xsl:apply-templates select="node()|@*"/>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
1.2 +10 -8 cocoon-2.1/src/blocks/midi/samples/stylesheets/invert.xsl
Index: invert.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/midi/samples/stylesheets/invert.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- invert.xsl 16 Aug 2003 14:37:07 -0000 1.1
+++ invert.xsl 19 Aug 2003 01:11:06 -0000 1.2
@@ -1,18 +1,20 @@
<?xml version="1.0"?>
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:variable name="notes" select="//NOTE_ON"/>
+ <xsl:variable name="medianPitch" select="floor(sum($notes/@PITCH) div count($notes))"/>
<xsl:template match="NOTE_ON">
- <xsl:variable name="notes" select="//NOTE_ON"/>
- <xsl:variable name="medianPitch" select="floor(sum($notes/@PITCH) div count($notes))"/>
- <NOTE_ON PITCH="{$medianPitch - (@PITCH - $medianPitch)}" REGISTER="{@REGISTER}" VELOCITY="{@VELOCITY}">
- <xsl:apply-templates />
+ <NOTE_ON PITCH="{$medianPitch * 2 - @PITCH}">
+ <xsl:copy-of select="@REGISTER | @VELOCITY"/>
+ <xsl:apply-templates select="node()"/>
</NOTE_ON>
</xsl:template>
- <xsl:template match="node()|@*">
+ <xsl:template match="node()">
<xsl:copy>
- <xsl:apply-templates select="node()|@*"/>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>