[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nashville notation as chord symbols
From: |
Paul Morris |
Subject: |
Re: Nashville notation as chord symbols |
Date: |
Mon, 15 Jun 2015 10:05:22 -0400 |
Hi Amy,
> On Jun 15, 2015, at 9:34 AM, Amelie Zapf <address@hidden> wrote:
>
> the remaining problem of the Scheme function is: how to access the
> current root of the key signature in the function definition. For even
> if we explicitly state the root again in the definition, it would be
> immensely problematic if the piece contained a key change. Since
> Lilypond does have an internal representation of the current key
> signature (it needs to, to place accidentals correctly), there must be a
> way to access it from within a function.
>
> Does anybody know how?
Unfortunately it’s not simple… The tonic note of the current key is a context
property that’s used by the Key_engraver:
http://lilypond.org/doc/v2.18/Documentation/internals/key_005fengraver
It’s possible to create a custom engraver (with scheme) that can access this
property and do something with it. (There’s not all that much documentation on
this, but maybe look in the LSR for examples? “make-engraver” is the function.)
I’m not sure how a custom engraver would work with chordRootNamer and
chordNoteNamer, just because I’m unfamiliar with the chord name mechanisms.
In the meantime, the code below will let you pass the current root/tonic note
as an argument to \nashvilleChords. You would just have to redo
\nashvilleChords with any key change.
HTH,
-Paul
\version "2.18.2"
% Chords
#(define (note-name->international-markup root)
"takes @code{root} pitch and returns a procedure
(a lambda function) which has @code{root} in scope (a closure)"
(lambda (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)
)
)))))
nashvilleChords =
#(define-music-function (parser location root) (ly:pitch?)
#{
\set chordRootNamer = #(note-name->international-markup root)
\unset chordNoteNamer
#})
\score {
\chords {
d1 e:m f g:maj7 gis:sus4 a:7 d
\nashvilleChords d
d1 e:m f g:maj7 gis:sus4 a:7 d
\nashvilleChords f
f1 g:m a b:maj7 bis:sus4 c:7 f
}
\midi {
\tempo 4 = 180
}
\layout {
}
}
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/15
- Re: Nashville notation as chord symbols, Klaus Blum, 2015/06/15
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/15
- Re: Nashville notation as chord symbols, David Kastrup, 2015/06/15
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/15
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/15
- Re: Nashville notation as chord symbols,
Paul Morris <=
- Re: Nashville notation as chord symbols, David Kastrup, 2015/06/15
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/17
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/17
- Re: Nashville notation as chord symbols, David Nalesnik, 2015/06/17
- Re: Nashville notation as chord symbols, David Nalesnik, 2015/06/17
- Re: Nashville notation as chord symbols, Amelie Zapf, 2015/06/17
- Re: Nashville notation as chord symbols, Paul Morris, 2015/06/18
- Re: Nashville notation as chord symbols, David Kastrup, 2015/06/18
- Re: Nashville notation as chord symbols, Paul Morris, 2015/06/19
- Re: Nashville notation as chord symbols, David Kastrup, 2015/06/15