lilypond-user
[Top][All Lists]
Advanced

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

Re: Glissando between single notes in chord


From: pabuhr
Subject: Re: Glissando between single notes in chord
Date: Wed, 17 Oct 2012 20:48:28 -0700

I've been working on the last version of David Nalesnik's guide-finger code.
The reason is a horizontal and vertical placement problem when the guide line
is long and/or at a steep angle. I have managed to fix the vertical problem,
but the horizontal problem has me flummoxed. The example below shows the
horizontal problem by placing a guide finger above/below a normal finger
number.

A stencil is created for the guide-line and finger number, which needs to be
centered above/below its associated note head for fingeringOrientations up and
down. However, something is wrong with the centering calculation. The width of
the stencil seems to be too short so the calculation fails to center it. So
there is something about the width of the stencil I do not understand.

I have heavily comment the code to make it possible to understand.

=======================================================================

\version "2.17.4"
\language english
#(set-global-staff-size 30)

% left-hand finger guide before note
#(define (guide-finger slope len fingering)
  ;; Purpose
  ;;   add ornamentation line before fingering symbol to indicate figner 
movement along a
  ;;   string without making a sound (i.e., not a glissando)
  ;; Parameters
  ;;   slope : angle of rotation around right centre
  ;;   len : length of line prefacing fingering
  ;;   fingering : fingering designation for note
  (let ((music (make-music 'FingeringEvent)))
   (set! (ly:music-property music 'tweaks)
        (acons 'stencil
         (lambda (grob)
          (let* (
                ;; assign to finger the "digit" property from parameter 
"fingering"
                (finger (ly:music-property fingering 'digit))
                ;; DOES NEXT LINE GENERATE A STENCIL FROM THE STRING FOR A 
FINGER NUMBER???
                ;; IS THERE A WAY TO GENERATE A FINGER STENCIL THAT IS A FINGER 
NUMBER RATHER THAN A MARKUP?
                (finger-stil (grob-interpret-markup grob (number->string 
finger)))
                ;; assign to finger-stil-X the width of finger-stil
                (finger-stil-X (ly:stencil-extent finger-stil X))
                ;; assign to finger-stil-Y the height slightly below the middle 
of finger number
                (finger-stil-Y (* 0.4 (interval-length (ly:stencil-extent 
finger-stil Y))))

                ;; assign to guide-line a horizontal line-stencil with thickness
                ;;   and length "len" up "finger-stil-Y" vertically on 
fingering number
                (guide-line (make-line-stencil 0.13 0 finger-stil-Y len 
finger-stil-Y))
                ;; rotate guide-line "slope" degrees around right centre
                (guide-line (ly:stencil-rotate guide-line slope 1 0))
                ;; center line vertically on fingering number
                (guide-line-X (ly:stencil-extent guide-line X))

                ;; assign to stil the concatenation of stencil line and finger 
number along X-axis on right
                ;;   add padding 0.2 to move guide slightly left from finger 
number
                (stil (ly:stencil-combine-at-edge guide-line X 1 finger-stil 
0.2))
                ;; assign to stil-ext-X the width of stil
                (stil-ext-X (ly:stencil-extent stil X))
          ) ;; end declarations
           ;; fingering oriented on left/right side ?
           (if (= 0 (ly:grob-property grob 'side-axis))
                ;; return finger guide as is
                stil
                ;; otherwise, create and return new finger guide with X-extents 
positioned with the number
                ;; centered over the note
                (ly:make-stencil
                 ;; copy expr from stil
                 (ly:stencil-expr stil)
                 
;;#########################################################################
                 ;; widen the stencil by doubling its width minus one 
finger-number width,
                 ;;   which should have a center point under the remaining 
finger number
                 
;;#########################################################################
                 (cons 0 (- (* 2 (interval-length stil-ext-X)) (interval-length 
finger-stil-X)))
                 (ly:stencil-extent finger-stil Y)
           ) ;; end make-stencil
          ) ;; end if
         ) ;; end let
        ) ;; end lambda
         (ly:music-property music 'tweaks)
   ) ;; end acons
  ) ;; end set
   music
 ) ;; end let
)

% guide-neutral
%   <c-\gn-1>4  c4^\gn^2  c4-\gn-3  c4_\gn_4
gn = #(define-music-function (parser location fingering) (ly:music?)
           (guide-finger 0 0.7 fingering)) % line-slope line-length
% guide-down
%   <c-\gd-1>4  c4^\gd^2  c4-\gd-3  c4_\gd_4
gd = #(define-music-function (parser location fingering) (ly:music?)
           (guide-finger 20 0.7 fingering))
% guide-up
%   <c-\gu-1>4  c4^\gu^2  c4-\gu-3  c4_\gu_4
gu = #(define-music-function (parser location fingering) (ly:music?)
           (guide-finger -20 0.7 fingering))

% guide slope length
%   <c-\gslen #-15 #1 -1>4  c4^\gslen #45 #1 ^2  c4-\gslen #-15 #1 -3  
c4_\gslen 1 #2 _4
gslen = #(define-music-function (parser location slope len fingering) (number? 
number? ly:music?)
                  (guide-finger slope len fingering))

fl = \set fingeringOrientations = #'(left)

\relative c'' {
  <f^4>2 <f^\gu-4> <f^\gd-4> <f^3 d^\gslen #-60 #1 -4>
  <f^4> <f^\gslen #-20 #2 -4> <f^\gslen #35 #2 -4> <d^3 f^\gslen #60 #2 -4>
  <f^\gslen #0 #2 -4> <d^3 f^\gslen #0 #2 -4>
}

% Local Variables: %
% tab-width: 4 %
% compile-command: "lilypond --ps test7.ly" %
% End: %



reply via email to

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