lilypond-user
[Top][All Lists]
Advanced

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

Re: Changing notes based on fingerings


From: Nicolas Sceaux
Subject: Re: Changing notes based on fingerings
Date: Thu, 17 Jul 2008 16:53:51 +0200

Le 17 juil. 08 à 16:16, Eric Knapp a écrit :

I am using this approach with good results. I know the music
expression I want to create. I just need to be able to catch music
expressions so that I can get the fingering number that the user
entered. Then I can create the correct note based on the fingering.

With code like this:

 \override  Fingering #'stencil = #custom-fingerings  %<-- a function

But this comes too late.
I would do the following: write a music function which, when encountering
a ChordEvent containing a NoteEvent and a FingeringEvent, makes to
appropriate changes.

\stickify { a''4-2 }
==>
< \tweak #'style #'triangle a'' >4

This can be done the following way (note that this won't work properly
with chords -- that would require some easy modifications):

#(define (stickify-music music)
   (if (eqv? (ly:music-property music 'name) 'EventChord)
       (let ((note #f)
             (fingering #f)
             (other-elements (list)))
         (for-each (lambda (elt)
(cond ((eqv? (ly:music-property elt 'name) 'NoteEvent)
                            (set! note elt))
((eqv? (ly:music-property elt 'name) 'FingeringEvent)
                            (set! fingering elt))
                           (else
                            (set! other-elements
                                  (cons elt other-elements)))))
                   (ly:music-property music 'elements))
         (if (and note fingering)
             (begin
               ;; change the note head
               (set! (ly:music-property note 'tweaks)
                     (cons (cons 'style
(case (ly:music-property fingering 'digit)
                                   ((1) 'triangle)
                                   ((2) 'xcircle)
                                   ((3) 'cross)
                                   (else 'default)))
                           (ly:music-property note 'tweaks)))
               ;; remove the fingering
               (set! (ly:music-property music 'elements)
                     (cons note other-elements))))))
   music)

stickify =
#(define-music-function (parser location music) (ly:music?)
   (music-map stickify-music music))

\stickify { c'-1 d'-2 e'-3 f' }

nicolas





reply via email to

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