Hello Andreas,

Am 10.09.2015 um 19:38 schrieb Andreas Stenberg:
Hi!

I'm editing an 18-th century piece with several voices and "movements" where the source; an early print, has a printing error for the first movement of the piece. In all the Voices for that movement the key is given as G-major when it obviously should be D- major as in the rest of the movements.

In the Baroque period it was still fairly common to allude to church modes in key signature, e.g. – d ‘minor’ without a flat or { \key d \dorian } (also with other minor keys)
– e ‘minor’ without a sharp or { \key e \phrygian }.
From this point of view, I think (without knowing the exact context of course) it’s possible that it was not by mistake that the editor wrote { \key g \mixolydian }.

But this doesn’t impede the editorial decision to use two sharps in your print. (It might lead to confusion with ambiguous notes, though.)

Is there any way to get a bracket on the c- sharp in the key signature for D - major?

With LilyPond, all things are possible! It just depends on the amount of programming involved… In this case, the actual programming has already been done by David Nalesnik (kudos!) for the thread starting here <http://lists.gnu.org/archive/html/lilypond-user/2015-08/msg00373.html>: providing an alternative print routine for KeySignature (and KeyCancellation, which you’re likely not going to need), which allows individual handling of the accidentals.
I modified this such that it doesn’t do coloring, but parenthesizing.

Yours, Simon
\version "2.19.23"
% courtesy of David Nalesnik
% http://lists.gnu.org/archive/html/lilypond-user/2015-08/msg00414.html
%
% adapted for parenthesizing by Simon Albrecht

#(define key-signature-parenthesize `(
   ((0 . ,SHARP) . #t) ; C
  ))


#(define key-signature::special-print
   (lambda (grob)
     (let* ((inter (/ (ly:staff-symbol-staff-space grob) 2.0))
            (mol empty-stencil)
            (c0s (ly:grob-property grob 'c0-position))
            (is-cancellation? (grob::has-interface grob 'key-cancellation-interface))
            (pos empty-interval)
            (overlapping-pos empty-interval)
            (padding-pairs (ly:grob-property grob 'padding-pairs))
            (fm (ly:grob-default-font grob))
            (alist (ly:grob-property grob 'glyph-name-alist))) (display (ly:grob-property grob 'alteration-alist)) (newline)
       (let loop ((s (ly:grob-property grob 'alteration-alist))
                  (stil mol)
                  (last-glyph-name #f))
         (if (pair? s)
             (let* ((alt (if is-cancellation? 0 (cdar s)))
                    (glyph-name (ly:assoc-get alt alist)))
               (if (not (string? glyph-name))
                   (begin
                    (ly:warning "No glyph found for alteration: ~a" alt)
                    (loop (cdr s) stil last-glyph-name))
                   (let ((acc (ly:font-get-glyph fm glyph-name)))
                     (if (equal? acc empty-stencil)
                         (begin 
                          (ly:warning "alteration not found")
                          (loop (cdr s) stil last-glyph-name))
                         (let ((column empty-stencil)
                               (pos empty-interval))
                           (let inner ((pos-list
                                        (key-signature-interface::alteration-positions
                                         (car s) c0s grob)))
                             (if (pair? pos-list)
                                 (let* ((p (car pos-list))
                                        (pitch (car s))
                                        (paren? (assoc-get pitch key-signature-parenthesize))
                                        (acc
                                         (if paren?
                                             (parenthesize-stencil acc 0.065 0.4 0.4 0.1)
                                             acc)))
                                   (set! pos (add-point pos p))
                                   (set! column
                                         (ly:stencil-add column
                                           (ly:stencil-translate-axis acc (* p inter) Y)))
                                   (inner (cdr pos-list))))
                             (let* ((padding (ly:grob-property grob 'padding 0.0))
                                    (handle (assoc (cons glyph-name last-glyph-name) padding-pairs))
                                    (padding
                                     (cond
                                      ((pair? handle) (cdr handle))
                                      ((and
                                        (string=? glyph-name "accidentals.natural")
                                        (not (interval-empty?
                                              (interval-intersection overlapping-pos pos))))
                                       (+ padding 0.3))
                                      (else padding))))
                         
                               (set! pos (interval-widen pos 4))
                               (set! overlapping-pos (coord-translate pos 2))
                               (loop (cdr s)
                                 (ly:stencil-combine-at-edge
                                  stil
                                  X
                                  LEFT
                                  column
                                  padding)
                                 glyph-name))))))))
             (ly:stencil-aligned-to stil X LEFT))))))


music = \relative {
  \key d \major
  \time 2/4
  d'16 cis d cis d4
}

%% DEFAULT:

{
  \music
}

%% WITH OVERRIDES:

{
  \override Staff.KeySignature.stencil =
  #key-signature::special-print

  \override Staff.KeyCancellation.stencil =
  #key-signature::special-print

  \music
}

{
  \override Staff.KeySignature.stencil =
  #key-signature::special-print

  \override Staff.KeyCancellation.stencil =
  #key-signature::special-print

  \clef bass
  \music
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to