If a score does not use any <staff> elements, fool musicxml2ly with
a dummy value of "None". Similarly, don't use dict[staff], but dict.get
to avoid crashes in that case.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Apply Attributes and Direction only to the staves/voices they apply to
When extracting the voices of a part, first detect all different voices so that
we can assign dynamics to all voices right from the beginning.
Also, assign the dynamics and attributes only to those voices they really apply
to (in particular, if they have a <staff> element, only assign them to the voices
that use that particular staff). For this, I also need to keep a dict for
staff=>[voiceids,...] around. To be able to assign attributes only to the
correct voices, I need to copy the attributes object and erase all clefs, times
and keys that do not apply to the staff (and keep only those objects that either
have no number attribute or have the correct number attribute). This copying
(shallow copying of the relevant parts of the Attributes object) gave me some
major headache, but it should work fine now.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: A grace note at the beginning shall not set staff for the voice
The sample files from Recordare contain a piece where the voice on the
upper staff of a PianoStaff starts with a grace displayed in the second
staff. So far, this put the whole voice on the second staff. Thus, grace
notes are now ignored when determining the voice for a staff.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Staves with multiple voices get \voiceOne and \voiceTwo
When a staff has more than one voice, we get tons of colliding stems, so
put \voiceOne in the first voice and \voiceTwo in the remaining. This
still breaks with more than two voices, but the majority of cases works
fine now.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Implement part-group (i.e. StaffGroup in ly) and part-name (instrumentName)
Implementing part-groups and their bracketing and span-bars turned out
harder than I imagined... I build one nested set of StaffGroup and Staff
objects from the part-list, including the instrument names and the bracket
types. However, to be able to distinguish single-staff staves and piano
staves and to assign the correct voices and lyrics to a part, I need
another loop after everything has been processed. In this additional
loop through the whole score structure I extract the voice and lyrics
ids assigned to each part and assign them the StaffGroup nested
objects.
Finally, printing everything out is quite simple.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Convert grace notes from MusicXML to Lilypond
Grace notes are normal <note> elements in XML, only with a <grace/>
child element. I append these notes to a special array of EventChord
and try to take care of the zero duration of grace notes (which
come before the real note and thus also create the EventChord with
duration zero!)
There is still one problem with things like beams or articulations on
grace notes (they are printed after the whole cord (not inside the
\grace!), but this is a general problem that musicxml2ly inserts
slurs, ties, beams, articulations, etc. as separate events not assigned
to any particular note/EventChord. The code should be changed to
assign these ornaments/settings directly to the note or the chord they
apply to. This would (1) get rid of e.g. triple [ with beamed chords,
(2) make it possible to combine multiple MusicXML articulations into
single lilypond articulations, (3) apply fingerings and ties to notes
inside chords rather than the whole chord, and (4) fix the grace notes.
The other problem is when a chord is used as a grace chord in MusicXML.
Due to the whole structure of musicxml2ly, this problem goes very deep
and I don't know of any way to fix this short of a big rewrite.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
In MusicXML, a rest can also have a pitch, given as
<display-step>A</display-step><display-octave>3</display-octave>
If given, convert these into ordinary lilypond pitches and print them
out as "a4 \rest" instead of "r4".
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Reset measure position on backup elements, print => sys.stderr.write
-) Replace all relevant (i.e. non-testing outputs; these are still in there
in the main() functions for testing) occurrences of print by
sys.stderr.write
-) If a <backup> element is encountered (e.g. when there are two voices in
the measure), correctly reset the measure position to the desired
position after the backup.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Fix regression when adding expressions like octave shifts
Octave shifts in lilypond (like in MusicXML) are not associated with a
particular note but their position in the measure. So far, I simply
inserted them like a note, but unfortunately that reset the current
starting position in the measure (needed to find the correct position
for chords). So I added a method dedicated to inserting such commands
without resetting the position (of course, pending multi-bar rests
still need to be inserted before the music command).
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
MusicXML: Cleanup of span start/end and direction, coding style
Follow Han-Wen's tips:
-) Split the type of spanners into direction (start/stop) and type
(crescendo/decrescendo, up/down octave-shifts, ...)
-) Get rid of some ifs and use dicts instead
-) Get rid of unnecessary empty cases in dicts
-) Treat hairpins like all other spanners
-) Invert logic of quoting of lyrics and header fields to always quote unless
the text consists entirely of letters.
-) Implement all durations from MusicXML
-) If an ouput filename is given, the include needs to use only the basename
of the file, not the whole path
-) Change logic of adding .xml to the input file: First try the supplied
filename, then with .xml appended and only then with xml (no dot) appended.
-) Use progress (..) for the error message when input file does not exist.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
John Mandereau [Thu, 13 Sep 2007 20:39:58 +0000 (22:39 +0200)]
Fix some French translation nitpicks and typos
- add Gilles Thibault to THANKS for his comments on Changing defaults
French translation,
- also add P.E. Brame to THANKS for his (older) suggestions on
Instrument-specific notation French translation,
- update French literature.itely.