lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nashville notation as chord symbols


From: Thomas Morley
Subject: Re: Nashville notation as chord symbols
Date: Thu, 18 Jun 2015 23:18:35 +0200

2015-06-15 9:26 GMT+02:00 Amelie Zapf <address@hidden>:
> Hi Stan, Klaus,
>
> the following snippet does Nashville numbers correctly for the key of C
> (except for the rhythmical symbols). In order to adapt this to other
> keys we'd need to hand the routine two pitches, the chord root and the
> current key, and have it compute the difference between the two, which
> is the scale degree. Does anybody know how to do that?
>
> Amy
>
> \version "2.18.2"
> % Chords
> #(define (note-name->international-markup pitch lowercase?)
>    (let* (
>        (name (ly:pitch-notename pitch))
>        (alt (ly:pitch-alteration pitch))
>        (hspace (vector-ref #(0.15 0.15 0.05 0.05 0.15) (+ (* alt 2) 2)))
>        (raise (vector-ref #(0.6 0.6 0.65 0.8 0.7) (+ (* alt 2) 2)))
>      )
>      (make-line-markup
>        (list
>          (if (= alt 0)
>            ;; If it's natural and not b, do nothing
>            (make-line-markup (list empty-markup))
>            ;; Else add alteration
>            (make-line-markup
>              (list
>                (make-smaller-markup
>                  (make-raise-markup raise
>                     (make-musicglyph-markup (assoc-get alt
> standard-alteration-glyph-name-alist ""))))
>                (make-hspace-markup hspace)
>          )))
>          (make-simple-markup
>            (vector-ref #("1" "2" "3" "4" "5" "6" "7") name)
>          )
>  ))))
>
>
>
> nashvilleChords = {
>   \set chordRootNamer = #note-name->international-markup
>   \unset chordNoteNamer
> }
>
> \chords {
>   c1 d:m es f:maj7 fis:sus4 g:7 c
>   \nashvilleChords
>   c1 d:m es f:maj7 fis:sus4 g:7 c
> }
> %


Hi Amelie,

the cleanest way would be to redefine the chordNameFunction, currently
it's 'ignatzek-chord-names'
A lot of work though...

That said, I've tried the engraver-route.
Though, I've absolutely no clue about the nashville-system, thus have
a thorough look at the output:

\version "2.18.2"

#(define nashville-chord-engraver
   (let ((root (ly:make-pitch 0 0 0)))

     (define (note-name->international-markup pitch lowercase?)
       (let* ((diff (ly:pitch-diff pitch root))
              (name (ly:pitch-notename diff))
              (alt (ly:pitch-alteration diff))
              (hspace (vector-ref #(0.15 0.15 0.05 0.05 0.15) (+ (* alt 2) 2)))
              (raise (vector-ref #(0.6 0.6 0.65 0.8 0.7) (+ (* alt 2) 2))))

         (make-line-markup
           (list
             (if (= alt 0)
                 ;; If it's natural and not b, do nothing
                 (make-line-markup (list empty-markup))
                 ;; Else add alteration
                 (make-line-markup
                   (list
                     (make-smaller-markup
                       (make-raise-markup raise
                          (make-musicglyph-markup
                            (assoc-get
                              alt
                              standard-alteration-glyph-name-alist ""))))
                     (make-hspace-markup hspace))))
             (make-simple-markup
               (vector-ref #("1" "2" "3" "4" "5" "6" "7") name))))))

   (make-engraver
    (listeners
     ((key-change-event engraver event)
      (let*
       ((context (ly:translator-context engraver)))
       (set! root (ly:event-property event 'tonic))
       (set! (ly:context-property context 'chordRootNamer)
             note-name->international-markup)))))))

%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%

\paper { indent = 0 }

music =
\chordmode {
    %% drawback:
    %% key _needs_ to be set!!
    %% otherwise the chordRootNamer falls back to his default
    \key c \major
    c1 d:m es f:maj7 fis:sus4 g:7 c
    \break
    \key d \major
    d:m es f:maj7 fis:sus4 g:7 c d
  }

\score {
%  \transpose c d
  <<
    \new ChordNames \music
    \new Staff \music
  >>
  \layout {
      \context { \Score \omit BarNumber }
      \context { \ChordNames \consists #nashville-chord-engraver }
  }
}


HTH,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]