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: Tue, 23 Jun 2015 23:08:47 +0200

2015-06-23 13:30 GMT+02:00 Amelie Zapf <address@hidden>:
> Hi David,
>
>> Pop music in the U.S.A. may be the monetary epicentre of the musical
>> universe, but most of LilyPond's developer base are rather removed from
>> there.
>
> I must disappoint you, I'm a Berlin jazz pianist that just happens to do
> some studio work. Since, apart from the classical scene, German-produced
> music has only domestic relevance, it's not necessarily where the really
> big bucks are.
>
>> Sentences like "I think it would be great if Lilypond could" rarely lead
>> anywhere in a volunteer-driven project since they imply that unnamed
>> others should be willing to invest more time and effort into bringing
>> such support into being than you yourself would, and that tends to be
>> not a realistic expectation.
>
> Well, I'm definitely willing to do my part. It's just that I'm not a
> Scheme expert and the last time I was more deeply involved in Lilypond
> coding was for the 1.8 version. (I wrote the original Ignatzek – who was
> one of my piano teachers, btw – chord naming routine.)
>
> As long as you don't mind me asking questions, especially on
> poorly-documented functions, I believe we can get along and get
> Nashville chord charts supported in a viable timeframe.
>
> Kind regards,
>
> Amy



Hi Amy,

I took a single point and tried some coding:

KeySignatures as key-indications.

Though, there are still a lot of questions to answer:
- is lowercase for minor (sometimes) needed or wanted
- or: is minor always shown with "-" or do other indications happen
- how to format: bold, italic, fontsize etc, etc
- how to behave at line-break
- do other scales like mixolydian appear, if yes, how are they indicated
- how to write des-major: Db (where b stands for the accidental-glyph), other?
etc, etc

About relative indication of KeySignatures.
Relative to which pitch? c or the previous tonic

You see, as I wrote before I've no clue about the nashville-chords ;)

Here the code so far.
Be aware it's more a scatch then fully elaborated.
It may be possible to shorten the code, depending on how the above
quetions are decided.

\version "2.18.2"

#(define (conditional-kern-before markup bool amount)
  "Add AMOUNT of space before MARKUP if BOOL is true."
  (if bool
      (make-line-markup
       (list (make-hspace-markup amount)
             markup))
      markup))

#(define-public (alteration->text-accidental-markup alteration)
  (make-smaller-markup
   (make-raise-markup
    (if (= alteration FLAT)
        0.3
        0.6)
    (make-musicglyph-markup
     (assoc-get alteration standard-alteration-glyph-name-alist "")))))

#(define (accidental->markup alteration)
  "Return accidental markup for ALTERATION."
  (if (= alteration 0)
      (make-line-markup (list empty-markup))
      (conditional-kern-before
       (alteration->text-accidental-markup alteration)
       #t 0.1)))

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

#(define-public (note-name->string pitch lowercase?)
  "Return pitch markup for @var{pitch}."
  (make-concat-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 (nashville-chord-engraver context)
   (let ((root (ly:make-pitch 0 0 0))
         (scale '()))

     (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
      (acknowledgers
       ((key-signature-interface engraver grob source-engraver)
         (let ((root-name (note-name->string root #f))
               (minor? (equal? scale minor)))
         (ly:grob-set-property! grob 'stencil
           (grob-interpret-markup grob
              (markup #:box #:concat (root-name (if minor? "-" ""))))))))
      (listeners
       ((key-change-event engraver event)
         (let* ((pitch-alist (ly:event-property event 'pitch-alist))
                (tonic-pitch (ly:event-property event 'tonic))
                (c0-pitch-list
                  (ly:transpose-key-alist pitch-alist
                       (ly:pitch-diff (ly:make-pitch 0 0 0) tonic-pitch))))
         (set! scale c0-pitch-list)
         (set! root tonic-pitch)
         (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 aes \minor
    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 "Key_engraver"
          \consists #nashville-chord-engraver
      }
  }
}


Cheers,
  Harm

Might make most sense to reply to this post in a new thread. ;)



reply via email to

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