Vorlage:AccScheme

Aus Lilypond Wiki
Wechseln zu: Navigation, Suche

Allgemeines

Scheme-Code, der speziell für AkkordeonSheets benötigt wird.

Hidden Code

Bassregister

In Lilypond sind einige Bassregister enthalten, die für mich unzureichend waren. Hier eine Lösung, die neue Bassregister definiert.

Code

#(defmacro* define-register-set (set-symbol doc #:optional definition)
   "Defines markup command named with @var{set-symbol} for creating
accordion register markups as well as a music function of the same
name.

@var{doc} is the optional documentation string followed by the actual
@var{definition}.  See existing definitions in @file{scm/accreg.scm}
for examples."
   `(begin
     (define-markup-command (,set-symbol layout props name) (string?)
       #:properties (translate-scaled-markup)
       #:category accordion-registers
       ;; It would be nice to generate the documentation string
       ;; automatically containing all possible registrations but this
       ;; is a hen-and-egg problem.  When the macro is being executed,
       ;; the register definition has not yet been evaluated.  It
       ;; would be feasible to not ever evaluate it and consider it
       ;; final.  But that seems like a somewhat unfriendly interface.
       ,(if definition doc "Undocumented.")
       (let* ((instrument ,(or definition doc))
              (register
               (ly:assoc-get name (ly:assoc-get 'register instrument)))
              (reedbanks (ly:assoc-get 'reedbank instrument)))
         (interpret-markup
          layout props
          (make-general-align-markup
           Y DOWN
           (fold (lambda (d m)
                   (markup #:combine m
                     #:translate-scaled d
                     #:musicglyph "accordion.dot"))
             (markup #:musicglyph
               (ly:assoc-get 'glyph instrument))
             (or (ly:assoc-get 'dots register)
                 (append-map (lambda (x)
                               (ly:assoc-get 'dots
                                 (ly:assoc-get x reedbanks)))
                   (ly:assoc-get 'reedbanks register))))))))

     (define-public ,set-symbol
       (define-music-function (register)
         (string?)
         ,(format #f "Equivalent to @code{<>^\\markup \\~a@var{REGISTER}}."
            set-symbol)
         (make-event-chord
          (list
           (make-music
            'TextScriptEvent
            'direction
            1
            'text
            (,(string->symbol (format #f "make-~a-markup" set-symbol)) register))))))))

%% Anwendungsbeispiel
\markup { \myBass #"MiddleBass" \hspace #2 "Soft Tenor" }

Output

Akkordeon Register

Underline ChordNames

In Lilypond gibt es standardmäßig keinen Befehl, um Akkordbezeichnungen in ChordNames-Kontexten zu unterstreichen.

Hier eine Lösung mit Scheme.

Code

#(define (pitch-alteration-semitones pitch)
   (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))

#(define ((chord-name->german-markup-text-alteration B-instead-of-Bb) pitch lowercase?)

   (define (pitch-alteration-semitones pitch)
     (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))

   (define (conditional-string-downcase str condition)
     (if condition
         (string-downcase str)
         str))

   (let* ((name (ly:pitch-notename pitch))
          (alt-semitones  (pitch-alteration-semitones pitch))
          (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -1)))
                   (cons 7 (+ (if B-instead-of-Bb 1 1) alt-semitones))
                   (cons name alt-semitones))))
     (make-line-markup
      (list
       (make-simple-markup
        (conditional-string-downcase
         (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
         lowercase?))
       (let ((alteration (/ (cdr n-a) 2)))
         (cond
          ((and (equal? lowercase? #f) (= alteration FLAT) (= (car n-a) 7)) (make-simple-markup ""))
          ((and (= alteration FLAT) (or (= (car n-a) 5) (= (car n-a) 2) )) (make-simple-markup "s"))
          ((= alteration FLAT) (make-simple-markup "es"))
          ((and (= alteration DOUBLE-FLAT) (or (= (car n-a) 5)(= (car n-a) 2) )) (make-simple-markup "ses"))
          ((= alteration DOUBLE-FLAT) (make-simple-markup "eses"))
          ((= alteration SHARP) (make-simple-markup "is"))
          ((= alteration DOUBLE-SHARP) (make-simple-markup "isis"))
          (else empty-markup)))))))

#(define germanChords (chord-name->german-markup-text-alteration #t))

#(define (note-name->underlined-markup pitch lowercase?)
   "Return pitch markup for @var{pitch}."
   (make-underline-markup
    (make-line-markup
     (list
      (make-simple-markup
       (conditional-string-downcase
        (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))
        lowercase?))
      (accidental->markup (ly:pitch-alteration pitch))))))

#(define (note-name->german-underlined-markup pitch lowercase?)
   (make-underline-markup
    (make-line-markup
     (list
      ((chord-name->german-markup-text-alteration #t) pitch lowercase?)))))

#(define (note-name->my-german-markup pitch lowercase?)
   (let* ((name (ly:pitch-notename pitch))
          (alt-semitones (pitch-alteration-semitones pitch))
          (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -2)))
                   (cons 7 (+ 1 alt-semitones))
                   (cons name alt-semitones))))
     (make-line-markup
      (list
       (string-append
        (list-ref '("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
        (if (or (equal? (car n-a) 2) (equal? (car n-a) 5))
            (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (cdr n-a)))
            (list-ref '("eses" "es" "" "is" "isis") (+ 2 (cdr n-a)))))))))

%% englische Akkordbezeichnungen unterstreichen
counterbass= \once \set ChordNames.chordRootNamer = #note-name->underlined-markup

%% deutsche Akkordnamen unterstrichen
gRoot= \once \set ChordNames.chordRootNamer = #note-name->german-underlined-markup
%% deutsche Akkordgrundnamen nach dem Schrägstrich unterstrichen
gNote= \once \set ChordNames.chordNoteNamer = #note-name->german-underlined-markup

%% alle nachfolgenden Chordnames unterstreichen
Rt = \set ChordNames.chordRootNamer = #note-name->german-underlined-markup
%% Unterstreichung rückgängig machen
revRt = \set ChordNames.chordRootNamer = #note-name->my-german-markup
rRt = \set ChordNames.chordRootNamer = #germanChords
oRt = \once \set ChordNames.chordRootNamer = #note-name->my-german-markup
Nt = \set ChordNames.chordNoteNamer = #note-name->german-underlined-markup
revNt = \set ChordNames.chordNoteNamer = #note-name->my-german-markup

%% Anwendungsbeispiele
\chordmode {
  \Rt c dis e \revRt c cis c/e \Nt c/e d/fis
  \revNt d/fis
}

Output

LilyWiki Underlining Chordnames

Usage

{{AccScheme}}

Kategorien

Wer verlinkt auf diese Seite?