MusicXML: Fix problem with lyrics on notes with grace notes
When a note had grace notes (and it was tied or part of a slur), sometimes
the lyrics for that note were completely ignored and all subsequent
lyrics were one note off. Now I simply ignore all slurs/ties of grace notes
and everything works just fine.
Also, clean up the staff change code. Now a staff change is not only applied
before a note, but also before other stuff (like clef change).
When we encounter a note with a different staff value than the
previous note in that voice, simply add the \change Staff=.. event
into the notes. However, this does not work inside chords, so we
ignore all staff changes inside chords. I'll have to find a different
way to print some notes of a chord on one staff and the other notes
on the other staff...
MusicXML: Fix problems with chord detection and pickup measures
Pickup measures messed up chord detection and voice start positions
for multi-voice parts, because I erroneously reset the position after
a pickup measure to 1, while in fact it should have been the length
of the pickup measure!
Also, fix some typos and only ignore skips in pickup measures intended
for padding to a full measure. Explicitly adde skips need to be honored.
-) Sometimes the contents of the first volta was duplicated (once
before and the second time inside the first volta). The cause
was theat I forgot an if clause to mark the repeat's body finished
when the first volta ending is encountered
-) I messed up the order of the repeat/ending markers in the output.
MusicXML: Fix small problems with assignment <harmony> <=> voice
Oops, I didn't want to treat <direction > elements like <harmony>.
The direction elements should still be asssigned to all voices (or
all voices of the staff).
Also, at the end of the loop, assign all remaining <harmony> elements
to the voice of the previous note and don't simply discard it.
Instead of assigning <harmony> elements to every voice or only the very
first voice (in the frist case, we'll have duplicated frets, in the
second one the fretboards will often be inserted at the completely
wrong position), simply insert the fretboard into the next note that
we encounter in the MusicXML file.
I suppose we could also do something similar for text markup (i.e.
<direction><words>...</word></direction>), but there we need to
distinguish direction elements with words-only subelements and with
dynamics subelements.
MusicXML: Convert fretboards from MusicXML to Lilypond
In MusicXML, fretboards are inside <harmony> elements, assigned
to a particular staff, while in lilypond the \fret-diagram is a
text markup assigned to a particular note. So we run into the same
problems as we do with dynamics (i.e. we need to find a proper
note to assign the element to, which is not very robust). For
single-voice harmony, this works quite well so far.
I forgot to reset the is_tied flag, so after a tie, no lyrics would be
printed out any more (the second note of a tie is in a melisma and does
not use any lyrics syllables in lilypond - Of course only if it is
really a tied note...).
MusicXML: Also finish repeats that do not have an explicit ending bar
Some musicXML examples just display the first page of a multi-page score.
Sometimes a repeat occurs on these pages with no ending bar (which would
follow on a subsequent page). Simply finish the \repeat sequence at the
very end of the page.
MusicXML: Fix lyrics on chords, ignore lyrics for notes inside melismata
The lyrics detection code so far ignored chords (ie. it added a \skip for
every additional note in the chord). Now I simply ignore all subsequent
notes and the corresponding syllables for the lyrics.
By default, lilypond does not add lyrics to notes in melismata (i.e.
tied notes and notes inside slurs), so while walking through all notes,
we need to check whether we are inside a slur, a tie or a grace note
and simply ignore the lyrics on these notes.
There are some scores, which still put lyrics on notes inside slurs, so
in the future, I'll also add a way to set/unset ignoreMelismata, but
that's left for the future.
MusicXML: Convert colors in text markup using \with-color #(rgb-color ...)
Now that we have the rgb-color scheme function in git, make use of it in
text markup conversion. In MusicXML, the color is given as #AARRGGBB
or #RRGGBB, we simply ignore the alpha channel, extract the r, g and b
values and scale them to the 0.0 - 1.0 range
MusicXML: Convert some more text markup attributes
Convert italics, better font sizes. Unfortunately, I don't know
how to convert RGB colors to x-colors used by lilypond, so colors
are not converted. Similarly, font families are not converted, mainly
because I don'tknow the correct lilypond expression for this.
Underline, overline and strike-through don't seem to be supported
by lilypond at all :-(
MusicXML: Convert words, assigned to staves => assign to notes in Lilypond
In MusicXML, words are represented in direction elements, in Lilypond, they
are assigned to notes....
Also try to convert as many font attributes as possible (several are still
missing, currently only text-size and text-wight are supported)
MusicXML: Implement Barline styles and repeats in musicxml2ly
-) The <barline> element is now converted to a \bar"...." lilypond
expression. Not all bar styles from MusicXML are supported by lilypond,
though.
-) Convert repeats and alternative endings from MusicXML to lilypond.
While lilypond has a nice hierarchy (i.e. nested music) for repeating
structures, MusicXML only has markers "here starts/ends a repeat or
altern.ending", so I need to somehow build up that repeat hierarchy
from the flat data. I've imlemented this via a loop that looks for
a repeat structure, replaces that one repeat by a proper instance
of musicexp.RepeatedMusic. Since I directly modify the list of
event chords, after replacing one repeat, I have to start the
whole loop from the start (because the iterators are off after
the list is modified).
-) Add some more unit test files for barlines and repeating structures
(some even do not make sense from a musical point of view)
-) Fix typo in the coverage/regression tests make file
Mats Bengtsson [Mon, 15 Oct 2007 13:59:26 +0000 (15:59 +0200)]
Use the collapse-height mechanism also for SystemStartBar.
Makes it possible to get a bar line at the left end of the
stave also for single stave scores.
MusicXML: Fix wrong chord detection with mid-measure attributes
Mid-measure attributes (like clef changes) need to be inserted as
commands, not as music, because that will reset the current measure
position and mess up chord detection for the following notes.
MusicXML: Support for upbeats and partial/implicit measures
-) In the Duration class, don't write out e.g. *3/1 for the factor.
In this case, *3 is much better
-) Add support for implicit measures, i.e. measures in MusicXML that do
not count. These are typically used for upbeats and for places where
a repeat or clef/key change occurs inside a measure. In this case,
the measure is split into to <measure> elements, the second one with
the implicit attribute set to "yes". Now we don't start a measure
in lilypond for those implicit measures.
-) Implicit measures at the very beginning are now converted as \partial X
-) Don't print out | %0 at the very beginning (i.e. for the measure with
number 0)
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
Joe Neeman [Fri, 5 Oct 2007 23:55:33 +0000 (09:55 +1000)]
Fix 411, 412 and 445.
Exclude VerticalAxisGroup 'minimum-Y-extent from the skyline, but include it in
align-interface calculations. Reinstate minimum-Y-extent in Staff.
Allow header/footer snippets in test cases, expand lilypond-book to insert versionnumber
-) Add --introduction=.. and --footer=.. options to lys-to-tely.py so that we
can insert custom text form a texi file at the beginning and end of a
regression test page. So far, one had to add a .ly file with a proper name
(so that it gets sorted to the begin/end), which resulted in an ugly empty
image and a link to a dummy .ly file at the top. The header for the
lys-to-tely script must not be called *.texi, because make WWW tries to
run makeinfo on all *.texi files.
-) Change the buildsystem to use these additional parameters. The make variables
HEADER_FILE and FOOTER_FILE are used for this.
-) Change the regression tests to make use of the texi file rather than the
AAA-intro-regression.ly file
-) Since that header contained the lilypond version number, I also expanded
lilypond-book to replace @lilypondversion (or the \lilypondversion and
<lilypondversion> counterparts for latex and html) by the version. The
build must then use the lilypond-book script from scripts/out/ rather
than scripts/lilypond-book.py (which does not have the @VERSION_NUMBER@
replaced by the version by the build system).
-) Add the bass drum instrument
-) Ignore notes with the attribute print-object="no". These are
typically notes that indicate midi output for tremolos and should
not be printed.
-) Use the Musix_xml_node.message method to print out the warning about
missing note types. This also prints out where the problem occurs.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
Instead of keeping an array of grace elements for each chord,
rather use a full SequentialMusic object that holds EventChords
(so we can insert beams, real grace chords, etc.). For this we also
need a method in the SequentialMusic class to get the last chord.
Depending on the slash attribute of the <grace> element, we now
use acciaccatura rather than grace for slashed grace notes.
Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
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>