Re: [frogs] After capo handler comes capo key

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


On 1 August 2011 23:19, Wols Lists <antlists@xxxxxxxxxxxxxxx> wrote:

> The main thing is I've commented everything I think is dodgy, so if you
> can cast an eye over it and point me in the right direction ... I was
> hoping to get some hints from the code that implemented \key and \major
> / \minor, but I couldn't find it. Not least because I need to know if
> I'm in minor mode to print the capo key correctly :-)

There's no flag which will tell you the mode of a key since all the
modes are just lists containing (scale-degree . alteration) pairs.
When a \key command is parsed, the list is tranposed; that tells the
engraver which alterations to typeset.

#(display minor)

-> ((0 . 0) (1 . 0) (2 . -1/2) (3 . 0) (4 . 0) (5 . -1/2) (6 . -1/2))

Here are a few comments on the music function:

> (let* (key-pitch (ly:make-pitch (ly:context-property context 'keySignature '())))

To read context properties inside a music function requires
\applyContext (in scheme form: (make-apply-context ...) or (make-music
'ApplyContext ...) ):

applyTest =
#(define-music-function (parser location) ()
   (define (look-at-key ctx)
     (newline)
     ;; not keySignature since that's the list of alterations
     (display (ly:context-property ctx 'tonic)))
   (context-spec-music
    (make-apply-context look-at-key)
    'Staff))

\relative c' {
  \key a \major
  \applyTest
  a1
}

Assuming the capo key appears above a stave, you'll have to set
capoPitch at Score level for ChordNames to see it.

> (capo-pitch (ly:make-pitch 0 capokey )) ;; set capo-pitch to the passed in notename ;; need to convert notename to "note alter"

You can pass pitches directly to the music function if you use the
predicate ly:pitch?

> (pitch-diff (cc:pitch::pitch-interval key-pitch capo-pitch))  ;; how do I call a c++ function

See the list of exported scheme functions here:

http://lilypond.org/doc/v2.15/Documentation/internals/scheme-functions

>    (if (capo-fret >= 0)
>      (make-line-markup (list "Capo " (abs (minus capo-fret 12)) (make-hspace-markup 1) (make-parenthesize-markup capokey)))  ;; do I need a make-markup function
>      (make-line-markup (list "Capo " (abs capo-fret) (make-hspace-markup 1) (make-parenthesize-markup capokey))))))

You can't return a markup from a music function (it must return music).

If the capo key markup is to be aligned somewhere over prefatory
material (such as the key signature), your best bet would be to create
a new break-aligned grob (similar to a rehearsal mark or bar number).

Cheers,
Neil

---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/