Beautiful numbersHow do we actually make formatting decisions? In other words, which of the three configurations should we choose for the following slur?
There are a few books on the art of music engraving available. Unfortunately, they contain rules of simple thumbs and some examples. Such rules can be instructive, but they are a far cry from an algorithm that we could readily implement in a computer. Following the instructions from literature leads to algorithms with lots of handcoded exceptions. Doing all this case analysis is a lot of work, and often not all cases are covered completely.
Formatting rules defined by example. Image from Ted Ross' The Art of Music Engraving
We have developed a much easier and robust method of determining the best formatting solution: score based formatting. The principle is the same as a beauty contest: for each possible configuration, we compute an ugliness score. Then we choose the least ugly configuration.
For example, in the above configuration, the slur nicely connects the starting and ending note of the figure, a desirable trait. However, it also grazes one note head closely, while staying away from the others. Therefore, for this configuration, we deduct a `variance' score of 15.39.
In this configuration, the slur keeps a uniform distance from the heads, but we have to deduct some points because the slur doesn't start and end on the note heads. For the left edge, we deduct 1.71, and for the right edge (which is further from the head) we deduct 9.37 points. Furthermore, the slur goes up, while the melody goes down. This incurs a penalty of 2.00 points
Finally, in this configuration, only the ending the slur is far away from the ending note head, at a score of 10.04 ugliness points.
Adding up all scores, we notice that the third option is the least ugly, or most beautiful version. Hence we select that one.
This technique is a general technique, and it is used in a lot of situations, for example
- determining beam slopes
- formatting tied chords
- formatting dotted chords
- line breaking
- page breaking
This technique evaluates a lot of possibilities, which takes some time to compute. However, that is a worthwhile expense, because the end result is much better, and because it makes our lives easy.
Next: Man is the measure of things: is a
flexible architecture enough?