</barline>
</measure>
- <!-- General tests: multiple notations, directions, pedal spanners, etc. -->
+ <!-- Dynamics, attached to notes by putting them inside <notations> tags -->
<measure number="22">
+ <note>
+ <pitch>
+ <step>C</step><octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <notations>
+ <dynamics><f/></dynamics>
+ </notations>
+ <lyric number="1"><text>f</text></lyric>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step><octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <notations>
+ <dynamics><ppp/></dynamics>
+ </notations>
+ <lyric number="1"><text>ppp</text></lyric>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step><octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <notations>
+ <dynamics><sfp/></dynamics>
+ </notations>
+ <lyric number="1"><text>sfp</text></lyric>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step><octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <notations>
+ <dynamics><other-dynamics>sfffz</other-dynamics></dynamics>
+ </notations>
+ <lyric number="1"><text>Oth.dyn.</text></lyric>
+ </note>
+ </measure>
+
+ <!-- General tests: multiple notations, directions, pedal spanners, etc. -->
+ <measure number="23">
<direction placement="below">
<direction-type>
<pedal line="no" relative-x="-9" type="start"/>
class DynamicsEvent (Event):
def __init__ (self):
self.type = None
- self.available_commands = [ "ppppp", "pppp", "ppp", "pp", "p",
- "mp", "mf",
- "f", "ff", "fff", "ffff",
- "fp", "sf", "sff", "sp", "spp", "sfz", "rfz" ];
def wait_for_note (self):
return True;
def ly_expression (self):
- if self.type == None:
- return;
- elif self.type in self.available_commands:
+ if self.type:
return '\%s' % self.type
else:
- return '-\markup{ \dynamic %s }' % self.type
-
+ return;
+
def print_ly (self, printer):
- if self.type == None:
- return
- elif self.type in self.available_commands:
+ if self.type:
printer.dump ("\\%s" % self.type)
- else:
- printer.dump ("-\\markup{ \\dynamic %s }" % self.type)
class TextEvent (Event):
)
)
)
-)
-"""
+)"""
}
def round_to_two_digits (val):
return ev
+
def musicxml_dynamics_to_lily_event (dynentry):
- dynamics_available = ( "p", "pp", "ppp", "pppp", "ppppp", "pppppp",
- "f", "ff", "fff", "ffff", "fffff", "ffffff",
- "mp", "mf", "sf", "sfp", "sfpp", "fp",
- "rf", "rfz", "sfz", "sffz", "fz" )
- if not dynentry.get_name() in dynamics_available:
+ dynamics_available = (
+ "ppppp", "pppp", "ppp", "pp", "p", "mp", "mf",
+ "f", "ff", "fff", "ffff", "fp", "sf", "sff", "sp", "spp", "sfz", "rfz" )
+ dynamicsname = dynentry.get_name ()
+ if dynamicsname == "other-dynamics":
+ dynamicsname = dynentry.get_text ()
+ if not dynamicsname:
return
+
+ if not dynamicsname in dynamics_available:
+ # Get rid of - in tag names (illegal in ly tags!)
+ dynamicstext = dynamicsname
+ dynamicsname = string.replace (dynamicsname, "-", "")
+ additional_definitions[dynamicsname] = dynamicsname + \
+ "=#(make-dynamic-script \"" + dynamicstext + "\")"
+ needed_additional_definitions.append (dynamicsname)
event = musicexp.DynamicsEvent ()
- event.type = dynentry.get_name ()
+ event.type = dynamicsname
return event
# Convert single-color two-byte strings to numbers 0.0 - 1.0
printer.newline ()
for a in set(needed_additional_definitions):
printer.print_verbatim (additional_definitions.get (a, ''))
+ printer.newline ()
printer.newline ()
# Read in the tree from the given I/O object (either file or string) and