-#!@PYTHON@
+#!@TARGET_PYTHON@
import optparse
import sys
import os
import string
from gettext import gettext as _
-import musicxml
-
-
-
-datadir = '@local_lilypond_datadir@'
-if not os.path.isdir (datadir):
- datadir = '@lilypond_datadir@'
-if os.environ.has_key ('LILYPONDPREFIX'):
- datadir = os.environ['LILYPONDPREFIX']
- while datadir[-1] == os.sep:
- datadir = datadir[:-1]
-if os.path.exists (os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/')):
- datadir = os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/')
-elif os.path.exists (os.path.join (datadir, 'share/lilypond/current/')):
- datadir = os.path.join (datadir, 'share/lilypond/current/')
-sys.path.insert (0, os.path.join (datadir, 'python'))
+for d in ['@lilypond_datadir@',
+ '@lilypond_libdir@']:
+ sys.path.insert (0, os.path.join (d, 'python'))
# dynamic relocation, for GUB binaries.
-bindir = os.path.split (sys.argv[0])[0]
-
-for prefix_component in ['share', 'lib']:
- datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component)
+bindir = os.path.abspath (os.path.split (sys.argv[0])[0])
+for p in ['share', 'lib']:
+ datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p)
sys.path.insert (0, datadir)
+
+
import lilylib as ly
import musicxml
'Acoustic Snare Drum': 'acousticsnare',
'Side Stick': 'sidestick',
'Open Triangle': 'opentriangle',
+ 'Mute Triangle': 'mutetriangle',
'Tambourine': 'tambourine',
}
self.add_music (evc, diff)
def last_event_chord (self, starting_at):
+
+ value = None
if (self.elements
and isinstance (self.elements[-1], musicexp.EventChord)
and self.begin_moment == starting_at):
- return self.elements[-1]
+ value = self.elements[-1]
else:
self.jumpto (starting_at)
- return None
+ value = None
+
+ return value
+
def correct_negative_skip (self, goto):
self.end_moment = goto
self.begin_moment = goto
modes_found = {}
voice_builder = LilyPondVoiceBuilder()
+
for n in voice._elements:
if n.get_name () == 'forward':
continue
- try:
- voice_builder.jumpto (n._when)
- except NegativeSkip, neg:
- voice_builder.correct_negative_skip (n._when)
- n.message ("Negative skip? from %s to %s, diff %s" % (neg.here, neg.dest, neg.dest - neg.here))
+ if not n.get_maybe_exist_named_child ('chord'):
+ try:
+ voice_builder.jumpto (n._when)
+ except NegativeSkip, neg:
+ voice_builder.correct_negative_skip (n._when)
+ n.message ("Negative skip? from %s to %s, diff %s" % (neg.here, neg.dest, neg.dest - neg.here))
if isinstance (n, musicxml.Attributes):
if n.is_first () and n._measure_position == Rational (0):
ev_chord = voice_builder.last_event_chord (n._when)
if not ev_chord:
ev_chord = musicexp.EventChord()
+ voice_builder.add_music (ev_chord, n._duration)
-
ev_chord.append (main_event)
- voice_builder.add_music (ev_chord, n._duration)
notations = n.get_maybe_exist_typed_child (musicxml.Notations)
tuplet_event = None
tuplet_events.append ((ev_chord, tuplet_event, frac))
## force trailing mm rests to be written out.
- voice_builder.add_music (musicexp.EventChord ())
+ voice_builder.add_music (musicexp.EventChord (), Rational (0))
ly_voice = group_tuplets (voice_builder.elements, tuplet_events)