Another patch for musicxml2ly: In situations like this:

    <trill-mark default-y='20'/>
    <wavy-line type='start' number='1'/>

this will be created:

    \trill \startTrillSpan

It should only be \startTrillSpan.

(My changes can also be found on Github: https://github.com/th-we/lilypond.)

Greets,
Thomas Weber
>From 282b5b501d89a70a4aa799214744bb69af61630c Mon Sep 17 00:00:00 2001
From: Thomas Weber <t...@notabit.eu>
Date: Sun, 13 Dec 2015 21:07:15 +0100
Subject: [PATCH] musicxml2ly: Avoid duplicate "tr" if both <trill-mark> and
 <wavy-line> are present

---
 scripts/musicxml2ly.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py
index 5cf5333..397dd78 100644
--- a/scripts/musicxml2ly.py
+++ b/scripts/musicxml2ly.py
@@ -1179,7 +1179,7 @@ articulations_dict = {
     #"toe": "?",
     "turn": "turn",
     "tremolo": musicxml_tremolo_to_lily_event,
-    "trill-mark": "trill",
+    "trill-mark": lambda notations: None if notations.get_named_children ('wavy-line') else "trill",
     #"triple-tongue": "?",
     #"unstress": "?"
     "up-bow": "upbow",
@@ -1187,12 +1187,16 @@ articulations_dict = {
 }
 articulation_spanners = [ "wavy-line" ]
 
-def musicxml_articulation_to_lily_event (mxl_event):
+def musicxml_articulation_to_lily_event (mxl_event, parent_node):
     # wavy-line elements are treated as trill spanners, not as articulation ornaments
     if mxl_event.get_name () in articulation_spanners:
         return musicxml_spanner_to_lily_event (mxl_event)
 
     tmp_tp = articulations_dict.get (mxl_event.get_name ())
+    
+    if hasattr (tmp_tp, '__call__'):
+        tmp_tp = tmp_tp(parent_node)
+    
     if not tmp_tp:
         return
 
@@ -2351,7 +2355,7 @@ def musicxml_voice_to_lily_voice (voice):
 
             # accidental-marks are direct children of <notation>!
             for a in notations.get_named_children ('accidental-mark'):
-                ev = musicxml_articulation_to_lily_event (a)
+                ev = musicxml_articulation_to_lily_event (a, notations)
                 if ev:
                     ev_chord.append (ev)
 
@@ -2376,7 +2380,7 @@ def musicxml_voice_to_lily_voice (voice):
 
             for a in ornaments:
                 for ch in a.get_all_children ():
-                    ev = musicxml_articulation_to_lily_event (ch)
+                    ev = musicxml_articulation_to_lily_event (ch, a)
                     if ev:
                         ev_chord.append (ev)
 
-- 
1.9.1

ÿþ<?xml version='1.0' encoding='UTF-16' standalone='no'?>

<!DOCTYPE score-partwise PUBLIC '-//Recordare//DTD MusicXML 3.0 Partwise//EN' 'http://www.musicxml.org/dtds/partwise.dtd'>

<score-partwise version='3.0'>

	<identification>

		<rights>Copyright © </rights>

		<encoding>

			<software>Sibelius 8.0</software>

			<software>Dolet 6.5 for Sibelius</software>

			<encoding-date>2015-12-13</encoding-date>

			<supports element='accidental' type='yes'/>

			<supports element='transpose' type='no'/>

			<supports attribute='new-page' element='print' type='yes' value='yes'/>

			<supports attribute='new-system' element='print' type='yes' value='yes'/>

		</encoding>

	</identification>

	<defaults>

		<scaling>

			<millimeters>7</millimeters>

			<tenths>40</tenths>

		</scaling>

		<page-layout>

			<page-height>1697</page-height>

			<page-width>1200</page-width>

			<page-margins type='odd'>

				<left-margin>72.5714</left-margin>

				<right-margin>72.5714</right-margin>

				<top-margin>72.5714</top-margin>

				<bottom-margin>72.5714</bottom-margin>

			</page-margins>

			<page-margins type='even'>

				<left-margin>72.5714</left-margin>

				<right-margin>72.5714</right-margin>

				<top-margin>72.5714</top-margin>

				<bottom-margin>72.5714</bottom-margin>

			</page-margins>

		</page-layout>

		<system-layout>

			<system-margins>

				<left-margin>22.1875</left-margin>

				<right-margin>0</right-margin>

			</system-margins>

			<system-distance>92.5</system-distance>

			<top-system-distance>72.8125</top-system-distance>

		</system-layout>

		<?DoletSibelius StaffJustificationPercentage=65?>

		<appearance>

			<line-width type='beam'>5</line-width>

			<line-width type='heavy barline'>5</line-width>

			<line-width type='leger'>1.5625</line-width>

			<line-width type='light barline'>1.5625</line-width>

			<line-width type='slur middle'>2.1875</line-width>

			<line-width type='slur tip'>0.625</line-width>

			<line-width type='staff'>0.9375</line-width>

			<line-width type='stem'>0.9375</line-width>

			<line-width type='tie middle'>2.1875</line-width>

			<line-width type='tie tip'>0.625</line-width>

			<note-size type='grace'>60</note-size>

			<note-size type='cue'>75</note-size>

		</appearance>

		<music-font font-family='Opus Std,music'/>

		<word-font font-family='Plantin MT Std'/>

	</defaults>

	<part-list>

		<score-part id='P1'>

			<part-name print-object='no'>[Unnamed (treble staff)]</part-name>

			<score-instrument id='P1-I1'>

				<instrument-name></instrument-name>

				<instrument-sound>keyboard.piano.grand</instrument-sound>

			</score-instrument>

			<midi-instrument id='P1-I1'>

				<volume>79</volume>

				<pan>0</pan>

			</midi-instrument>

		</score-part>

	</part-list>

<!--=========================================================-->

	<part id='P1'>

		<measure number='1'>

			<print>

				<system-layout>

					<system-margins>

						<left-margin>22.1875</left-margin>

						<right-margin>0</right-margin>

					</system-margins>

					<top-system-distance>217.8125</top-system-distance>

				</system-layout>

				<staff-layout>

					<?DoletSibelius ExtraSpacesAbove=3?>

				</staff-layout>

			</print>

			<attributes>

				<divisions>768</divisions>

				<key>

					<fifths>0</fifths>

					<mode>major</mode>

				</key>

				<time>

					<beats>4</beats>

					<beat-type>4</beat-type>

				</time>

				<clef>

					<sign>G</sign>

					<line>2</line>

				</clef>

			</attributes>

			<note>

				<pitch>

					<step>G</step>

					<octave>4</octave>

				</pitch>

				<duration>3072</duration>

				<voice>1</voice>

				<type>whole</type>

				<notations>

					<ornaments>

						<trill-mark default-y='20'/>

						<wavy-line type='start' number='1'/>

						<wavy-line type='stop' number='1'/>

					</ornaments>

				</notations>

			</note>

			<barline location='right'>

				<bar-style>light-heavy</bar-style>

			</barline>

		</measure>

	</part>

<!--=========================================================-->

</score-partwise>

\version "2.16.2"
% automatically converted by musicxml2ly from /home/tom/VirtualBox VMs/shared/trill-test.xml

\header {
    encodingsoftware = "Sibelius 8.0"
    copyright = "Copyright © "
    encodingdate = "2015-12-13"
    }

#(set-global-staff-size 19.9169291339)
\paper {
    paper-width = 21.0\cm
    paper-height = 29.7\cm
    top-margin = 1.27\cm
    bottom-margin = 1.27\cm
    left-margin = 1.27\cm
    right-margin = 1.27\cm
    between-system-space = 1.62\cm
    page-top-space = 1.27\cm
    }
\layout {
    \context { \Score
        autoBeaming = ##f
        }
    }
PartPOneVoiceOne =  \relative g' {
    \clef "treble" \key c \major \numericTimeSignature\time 4/4 g1
    \trill \startTrillSpan \stopTrillSpan \bar "|."
    }


% The score definition
\score {
    <<
        \new Staff <<
            \set Staff.instrumentName = "[Unnamed (treble staff)]"
            \context Staff << 
                \context Voice = "PartPOneVoiceOne" { \PartPOneVoiceOne }
                >>
            >>
        
        >>
    \layout {}
    % To create MIDI output, uncomment the following line:
    %  \midi {}
    }

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to