Jump to content

Fingering spanner: Difference between revisions

From LilyPond wiki
m New category
Tags: Mobile edit Mobile web edit
m Revise
 
Line 1: Line 1:
Draw a line or a dashed line between two fingerings.
Draw a straight or dashed line between two fingerings.


Syntax is <code>-\guide (dashed)#t #'(X-start-guide-line-coordinate . Y-start-guide-line-coordinate)-finger-number</code>.
Syntax is
 
-\guide <var>dashed?</var> <var>offset</var> -<var>f</var>
 
If Boolean argument <var>dashed?</var> is set to <code>#t</code>, draw a dashed line. The target fingering number is given by <var>f</var>, the offset from <var>f</var> to the start fingering is <var>offset</var>, which is coordinate pair (the X-value of this pair is thus always negative).
 
This function should be only used after the complete music has been typeset.  Any change in the formatting will make the X-offsets invalid.


<lilypond version="2.24">
<lilypond version="2.24">
%% http://lsr.di.unimi.it/LSR/Item?id=999
% LSR Credits: PPS in May 2015
%% <= http://lilypond.1069038.n5.nabble.com/lilypond-fingeringOrientations-spanner-tc169349.html
%% <= http://lilypond.1069038.n5.nabble.com/Violin-fingering-td176424.html
%% <= http://lilypond.1069038.n5.nabble.com/glissando-in-fingering-notation-td159875.html
 
% Credits: PPS on May 2015


guide =
guide =
Line 28: Line 29:
               \line {
               \line {
                 \translate #'(0 . 0.5)
                 \translate #'(0 . 0.5)
                 \override #'(thicknes . 1.3)
                 \override #'(thickness . 1.3)
                 \with-dimensions #'(0 . 0) #'(0 . 0)
                 \with-dimensions #'(0 . 0) #'(0 . 0)
                 #(if dashed?
                 #(if dashed?
Line 47: Line 48:


%%%% Test:
%%%% Test:
sopran = {
voiceI = {
   \set fingeringOrientations = #'(up)
   \set fingeringOrientations = #'(up)
   <cis'-3>16 <e'-0> <a-2> b  
   <cis'-3>16 <e'-0> <a-2> b  
  <c'-\guide ##f #'(-4 . 1)-2-1>8  
    <c'-\guide ##f #'(-4 . 1) -2
  cis' d' dis' e' f' |  
      -1>8  
    cis' d' dis' e' f' |  
   fis' g'
   fis' g'
  <gis'-\guide ##t #'(-39.5 . -2.5)-2-\guide ##t #'(-39.5 . -2.5)-1>  
    <gis'-\guide ##t #'(-39.5 . -2.5) -2
  <a'-3-\guide ##f #'(-3.5 . -0.2)-1> bes' b'
        -\guide ##t #'(-39.5 . -2.5) -1>  
  <c''-\guide ##t #'(-13 . -0.8)-3-\guide ##t #'(-13 . -0.8)-1>  
    <a'-3
  <cis''-2-4>
      -\guide ##f #'(-3.5 . -0.2) -1> bes' b'
    <c''-\guide ##t #'(-13 . -0.8) -3
        -\guide ##t #'(-13 . -0.8) -1>  
    <cis''-2-4> |
}
}


bass = {
voiceII = {
   c4\rest a16 a, ais a, b a, bis a, cis' a, d' a, |  
   r4 a16 a, ais a, b a, bis a, cis' a, d' a, |  
   dis' a, e' a, eis' a, fis' a, g' a, gis' a, a' a, g' a,
   dis' a, e' a, eis' a, fis' a, g' a, gis' a, a' a, g' a, |
}
}


Line 67: Line 73:
   \clef "G_8"  
   \clef "G_8"  
   \key d \major
   \key d \major
   << \sopran \\ \bass >>  
   << \voiceI \\ \voiceII >>  
}
}
</lilypond>
</lilypond>

Latest revision as of 06:41, 11 March 2026

Draw a straight or dashed line between two fingerings.

Syntax is

-\guide dashed? offset -f

If Boolean argument dashed? is set to #t, draw a dashed line. The target fingering number is given by f, the offset from f to the start fingering is offset, which is coordinate pair (the X-value of this pair is thus always negative).

This function should be only used after the complete music has been typeset. Any change in the formatting will make the X-offsets invalid.

\version "2.24"

% LSR Credits: PPS in May 2015

guide =
#(define-music-function (dashed? coord fingering) 
  (boolean? pair? ly:music?)
  "Make a line or dashed spanner, starting from the end 
   fingering and ending at the start fingering.
   One should define the ending point with x and y coordinates."
  (let ((fingering-ev (make-music 'FingeringEvent))
        (finger (ly:music-property fingering 'digit)))
    #{
      \tweak stencil
        #(lambda (grob)
          (grob-interpret-markup grob
            #{ 
              \markup 
                \concat {
            	  \line {
            	    \translate #'(0 . 0.5)
            	    \override #'(thickness . 1.3)
            	    \with-dimensions #'(0 . 0) #'(0 . 0)
            	    #(if dashed?
            	         #{
            	           \markup
            	             \override #'(on . 0.8)
            	             \override #'(off . 0.4)
            	             \draw-dashed-line $coord 
            	         #}
            	         #{ \markup \draw-line $coord #})
            	  }
            	  \hspace #0.4
            	  #(number->string finger)
            	}
            #}))
        $fingering-ev
    #}))

%%%% Test:
voiceI = {
  \set fingeringOrientations = #'(up)

  <cis'-3>16 <e'-0> <a-2> b 
    <c'-\guide ##f #'(-4 . 1) -2
       -1>8 
    cis' d' dis' e' f' | 
  fis' g'
    <gis'-\guide ##t #'(-39.5 . -2.5) -2
         -\guide ##t #'(-39.5 . -2.5) -1> 
    <a'-3
       -\guide ##f #'(-3.5 . -0.2) -1> bes' b'
    <c''-\guide ##t #'(-13 . -0.8) -3
        -\guide ##t #'(-13 . -0.8) -1> 
    <cis''-2-4> |
}

voiceII = {
  r4 a16 a, ais a, b a, bis a, cis' a, d' a, | 
  dis' a, e' a, eis' a, fis' a, g' a, gis' a, a' a, g' a, |
}

{
  \clef "G_8" 
  \key d \major
  << \voiceI \\ \voiceII >> 
}