@end ignore
@item
-[no changes yet]
+Accidentals in the key signature may be printed in octaves other
+than their traditional positions, or in multiple octaves.
+@lilypond[quote,relative=0]
+\override Staff.KeySignature #'flat-positions = #'((-5 . 5))
+\override Staff.KeyCancellation #'flat-positions = #'((-5 . 5))
+\clef bass \key es\major es g bes d
+\clef treble \bar "||" \key es\major es g bes d
+\override Staff.KeySignature #'sharp-positions = #'(2)
+\bar "||" \key d\major b fis b2
+@end lilypond
@end itemize
fis
@end lilypond
+Additional modes can be defined, by listing the alterations
+for each scale step when the mode starts on C.
+
+@lilypond[verbatim,quote]
+freygish = #`((0 . ,NATURAL) (1 . ,FLAT) (2 . ,NATURAL)
+ (3 . ,NATURAL) (4 . ,NATURAL) (5 . ,FLAT) (6 . ,FLAT))
+
+\relative c' {
+ \key c\freygish c4 des e f
+ \bar "||" \key d\freygish d es fis g
+}
+@end lilypond
+
+Accidentals in the key signature may be printed in octaves other
+than their traditional positions, or in multiple octaves, by
+using the @code{flat-positions} and @code{sharp-positions}
+properties of @code{KeySignature}. Entries in these properties
+specify the range of staff-positions where accidentals will be
+printed. If a single position is specified in an entry, the
+accidentals are placed within the octave ending at that staff
+position.
+
+@lilypond[verbatim, quote,relative=0]
+\override Staff.KeySignature #'flat-positions = #'((-5 . 5))
+\override Staff.KeyCancellation #'flat-positions = #'((-5 . 5))
+\clef bass \key es\major es g bes d
+\clef treble \bar "||" \key es\major es g bes d
+
+\override Staff.KeySignature #'sharp-positions = #'(2)
+\bar "||" \key b\major b fis b2
+@end lilypond
@snippets
@rinternals{Key_performer},
@rinternals{KeyCancellation},
@rinternals{KeySignature},
-@rinternals{key-cancellation-interface},
@rinternals{key-signature-interface}.
\version "2.16.0"
\header { texidoc = "Each clef has its own accidental placing
-rules. "}
+rules, which can be adjusted using @code{sharp-positions}
+and @code{flat-positions}." }
#(set-global-staff-size 16)
\key cis \major cis \key ces \major ces
\clef bass
\key cis \major cis \key ces \major ces
+ \break R1
+ \tempo "B-sharp on top"
+ \override Staff.KeySignature #'sharp-positions = #'(6 0 1 2 3 4 5)
+ \override Staff.KeyCancellation #'sharp-positions = #'(6 0 1 2 3 4 5)
+ \key cis \major R
+ \tempo "Flats throughout the staff"
+ \override Staff.KeySignature #'flat-positions = #'((-5 . 5))
+ \override Staff.KeyCancellation #'flat-positions = #'((-5 . 5))
+ \key ces \major R
+ \clef tenor
+ \key cis \major cis \break \key ces \major ces
+ \clef treble
+ \key cis \major cis \key ces \major ces
}
-
-
the cancellation signature.
*/
- int last_pos = -1000;
+ Slice pos, overlapping_pos;
SCM last_glyph_name = SCM_BOOL_F;
SCM padding_pairs = me->get_property ("padding-pairs");
me->warning (_ ("alteration not found"));
else
{
- SCM what = scm_caar (s);
-
- SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-position");
-
- int pos = scm_to_int (scm_call_3 (proc, what, scm_cdar (s), c0s));
- acc.translate_axis (pos * inter, Y_AXIS);
-
+ SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-positions");
+
+ pos.set_empty ();
+ Stencil column;
+ for (SCM pos_list = scm_call_3 (proc, scm_car (s), c0s, smob);
+ scm_is_pair (pos_list); pos_list = scm_cdr (pos_list))
+ {
+ int p = scm_to_int (scm_car (pos_list));
+ pos.add_point (p);
+ column.add_stencil (acc.translated (Offset (0, p * inter)));
+ }
/*
The natural sign (unlike flat & sharp)
has vertical edges on both sides. A little padding is
if (scm_is_pair (handle))
padding = robust_scm2double (scm_cdr (handle), 0.0);
else if (glyph_name == "accidentals.natural"
- && last_pos < pos + 2
- && last_pos > pos - 6)
+ && !intersection (overlapping_pos, pos).is_empty ())
padding += 0.3;
- mol.add_at_edge (X_AXIS, LEFT, acc, padding);
+ mol.add_at_edge (X_AXIS, LEFT, column, padding);
- last_pos = pos;
+ pos.widen (4);
+ overlapping_pos = pos + 2;
last_glyph_name = glyph_name_scm;
}
}
"alteration-alist "
"c0-position "
"glyph-name-alist "
+ "flat-positions "
+ "sharp-positions "
"padding "
"padding-pairs "
);
;; f
;;
(flag-count ,number? "The number of tremolo beams.")
+ (flat-positions ,list? "Flats in key signatures are placed
+within the specified ranges of staff-positions. The general form
+is a list of pairs, with one pair for each type of clef, in order
+of the staff-position at which each clef places C:
+@code{(alto treble tenor soprano baritone mezzosoprano bass)}.
+If the list contains a single element it applies for all clefs.
+A single number in place of a pair sets accidentals within the octave
+ending at that staff-position.")
(font-encoding ,symbol? "The font encoding is the broadest
category for selecting a font. Currently, only lilypond's system
fonts (Emmentaler) are using this property. Available
values may also be specified.")
(self-alignment-Y ,number? "Like @code{self-alignment-X} but for
the Y@tie{}axis.")
+ (sharp-positions ,list? "Sharps in key signatures are placed
+within the specified ranges of staff-positions. The general form
+is a list of pairs, with one pair for each type of clef, in order
+of the staff-position at which each clef places C:
+@code{(alto treble tenor soprano baritone mezzosoprano bass)}.
+If the list contains a single element it applies for all clefs.
+A single number in place of a pair sets accidentals within the octave
+ending at that staff-position.")
(shorten-pair ,number-pair? "The lengths to shorten a
text-spanner on both sides, for example a pedal bracket. Positive
values shorten the text-spanner, while negative values lengthen it.")
(break-visibility . ,begin-of-line-invisible)
(glyph-name-alist . ,cancellation-glyph-name-alist)
(non-musical . #t)
+ (flat-positions . (2 3 4 2 1 2 1))
+ (sharp-positions . (4 5 4 2 3 2 3))
(space-alist . (
(time-signature . (extra-space . 1.25))
(staff-bar . (extra-space . 0.6))
(break-visibility . ,begin-of-line-visible)
(glyph-name-alist . ,standard-alteration-glyph-name-alist)
(non-musical . #t)
+ (flat-positions . (2 3 4 2 1 2 1))
+ (sharp-positions . (4 5 4 2 3 2 3))
(space-alist . (
(time-signature . (extra-space . 1.15))
(staff-bar . (extra-space . 1.1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; key signature
-(define-public (key-signature-interface::alteration-position step alter
- c0-position)
- ;; TODO: memoize - this is mostly constant.
-
- ;; fes, ges, as and bes typeset in lower octave
- (define FLAT_TOP_PITCH 2)
-
- ;; ais and bis typeset in lower octave
- (define SHARP_TOP_PITCH 4)
-
- (if (pair? step)
- (+ (cdr step) (* (car step) 7) c0-position)
- (let* ((from-bottom-pos (modulo (+ 4 49 c0-position) 7))
- (p step)
- (c0 (- from-bottom-pos 4)))
-
- (if
- (or (and (< alter 0)
- (or (> p FLAT_TOP_PITCH) (> (+ p c0) 4)) (> (+ p c0) 1))
- (and (> alter 0)
- (or (> p SHARP_TOP_PITCH) (> (+ p c0) 5)) (> (+ p c0) 2)))
-
- ;; Typeset below c_position
- (set! p (- p 7)))
-
- ;; Provide for the four cases in which there's a glitch
- ;; it's a hack, but probably not worth
- ;; the effort of finding a nicer solution.
- ;; --dl.
- (cond
- ((and (= c0 2) (= p 3) (> alter 0))
- (set! p (- p 7)))
- ((and (= c0 -3) (= p -1) (> alter 0))
- (set! p (+ p 7)))
- ((and (= c0 -4) (= p -1) (< alter 0))
- (set! p (+ p 7)))
- ((and (= c0 -2) (= p -3) (< alter 0))
- (set! p (+ p 7))))
-
- (+ c0 p))))
-
+(define-public (key-signature-interface::alteration-positions
+ entry c0-position grob)
+ (let ((step (car entry))
+ (alter (cdr entry)))
+ (if (pair? step)
+ (list (+ (cdr step) (* (car step) 7) c0-position))
+ (let* ((c-position (modulo c0-position 7))
+ (positions
+ (if (< alter 0)
+ ;; See (flat|sharp)-positions in define-grob-properties.scm
+ (ly:grob-property grob 'flat-positions '(3))
+ (ly:grob-property grob 'sharp-positions '(3))))
+ (p (list-ref positions
+ (if (< c-position (length positions))
+ c-position 0)))
+ (max-position (if (pair? p) (cdr p) p))
+ (min-position (if (pair? p) (car p) (- max-position 6)))
+ (first-position (+ (modulo (- (+ c-position step)
+ min-position)
+ 7)
+ min-position)))
+ (define (prepend x l) (if (> x max-position)
+ l
+ (prepend (+ x 7) (cons x l))))
+ (prepend first-position '())))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; annotations