Here's how PMX deals with accidentals in chords. The shifting is done
simply using \loffset. That's the easy part. The hard part is figuring out
how where each one should go. PMX uses a set of rules that I think I
learned from some list traffic. Start with the topmost accidental.
Imagine sliding it in from the left until it just contacts either a
notehead, the stem, or another accidental, then back off to the left a
little bit. Do the same thing with the next accidental down from the top,
and so on. For every one after the first, if it has been displaced to the
left by another accid, then another check must be made before proceeding: If
it could be slid horizontally over the intervening accid(s) into a space
that is big enough to hold it, then do it, and push it again as far to the
right as possible.
Implementing this in PMX was very challenging. There's probably a better
way than what I finally ended up with, but I think the method always works.
I make a list of ALL the possible sequences in which the N accidentals could
be taken...there will be N! sequences. I take each sequence in turn and
compute a figure of merit that basically represents the average amount of
shifting required (smaller is better). The figure for each sequence is
obtained by sliding each member of the sequence in from the left IN TURN as
described above (NOT starting at the top), but also without any jumping over
into blank spaces. Then to handle the "top-down" rule, I just rule out any
sequence where any member was shifted to the left due to interference with a
LOWER accidental. After cycling through all possible sequences, the one with
the smallest figure-of-merit is selected.
Programming the elemental process of sliding in from the left and checking
for interference was fairly complicated. Accidentals are not rectangles, so
I had to define the left- and right-hand profile of each type of accidental.
At any given stage in a sequence, there will be some collection of
noteheads, stem segments, and accidentals already there, which define the
left-hand boundary against which the next accidental's right-hand profile
must be checked. Once the position is determined, the new accidental's
left-hand profile must be added to the existing left-hand boundary to
prepare for checking the next accidental in the sequence.
Joerg also mentioned problems of accidentals crashing into clefs. That's a
separate issue but one that PMX has to face in many other different
situations, so it did not pose so much of a new challenge. PMX just adds
extra horizontal space as required, using \off{...} . Again, the tricky
part is calculating how much extra space is needed. I did just notice a bug
in this when there are lots of chords with lots of accidentals in one line,
and I'll deal with that as soon as I can.
--Don Simons
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Joerg Anders
> Sent: Friday, January 04, 2002 7:02 AM
> To: [EMAIL PROTECTED]
> Subject: [TeX-music] accidentals
>
>
> Hi all!
>
> I have some problems with accidentals in chords. The
> accidentals overlap each other and overlap with
> other symbols (like clef).
>
> example:
>
> \input musixtex
> \hsize=37mm
> \startpiece
> \NOtes\sh e\sh g\sh i\zq{gi}\qu e\hpause\en
> \NOtes\sh e\sh g\sh i\zq{gi}\qu e\en
> \Endpiece
> \end
>
>
> Ok! I could play with \sk, \roffset, \loff, \hloff (or so...)
> But I'm convinced there is a better solution.
>
> Does anybody now how to place proper accidentals in chords.
> (A pointer to some documentation or example sufficies.)
>
> --
> J.Anders, Chemnitz, GERMANY ([EMAIL PROTECTED])
>
> _______________________________________________
> TeX-music mailing list
> [EMAIL PROTECTED]
> http://sunsite.dk/mailman/listinfo/tex-music
_______________________________________________
TeX-music mailing list
[EMAIL PROTECTED]
http://sunsite.dk/mailman/listinfo/tex-music