lilypond-user
[Top][All Lists]
Advanced

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

Re: Guitar Fret Diagram - scale degree below string


From: Klaus Blum
Subject: Re: Guitar Fret Diagram - scale degree below string
Date: Sun, 16 Aug 2015 07:34:55 -0700 (MST)

Hi tone, 

welcome to the forum!  :-)

The most elegant solution would be to take "fret-diagrams.scm" and use it to
build a modified fretboard command that accepts markup for fingerings. But
as I'm not an expert, this is out of reach for me.

Anyway, I've played around with explicit positioning of markups. The code
may be a horrible mess, but at least it is a function that's (more or less)
easy to use. 
I hope this helps.

Cheers, 
Klaus

%
--------------------------------------------------------------------------------------------------------------------
% Chord Chart.
% Want to add scale degree below strings.
% Example:  below the Db7#5#9 diagram there should be:
%           "3 b7 #9 #5" (without the quotes).
\version "2.19.15"
\pointAndClickOff
%
% the following two functions are borrowed from:
% http://lsr.di.unimi.it/LSR/Item?id=628
#(define-public (stack-stencil-overlay stencils)
   "Recursive function to add stencils together"
   (if (and (pair? stencils)
            (ly:stencil? (car stencils)))
       (if (and (pair? (cdr stencils))
                (ly:stencil? (cadr stencils)))
           (let ((tail (stack-stencil-overlay (cdr stencils)))
                 (head (car stencils)))
             (ly:stencil-add head tail))
           (car stencils))
       point-stencil))

#(define-markup-command (overlay layout props args)
   (markup-list?)
   "Overlay arguments one on top of the next"
   (let ((stencils (interpret-markup-list layout props args)))
     (stack-stencil-overlay
      (remove ly:stencil-empty? stencils))))

#(define-markup-command (custom-fret layout props control six five four
three two one)
   (string? markup? markup? markup? markup? markup? markup?)
   (interpret-markup layout props
     #{
       \markup {
         \override #'(size . 1.5)
         \left-column {
           \fret-diagram-terse $control
           \fontsize #-8
           \sans
           \overlay {
             % find the following values by trial-and-error:
             \translate #'(-0.1 . 0) \center-align \transparent "."
             \translate #'(0.2 . 0) \center-align $six
             \translate #'(1.7 . 0) \center-align $five
             \translate #'(3.2 . 0) \center-align $four
             \translate #'(4.7 . 0) \center-align $three
             \translate #'(6.2 . 0) \center-align $two
             \translate #'(7.7 . 0) \center-align $one
           }
         }
       }
     #}))

#(define-markup-command (with-flat layout props text)
   (markup?)
   (interpret-markup layout props
     #{
       \markup \concat {\raise #0.2 \flat $text }
     #}))

#(define-markup-command (with-sharp layout props text)
   (markup?)
   (interpret-markup layout props
     #{
       \markup \concat {\raise #0.4 \sharp $text }
     #}))

\score {
  <<
    \chords {
      %{ B13sus4 %}     b:13sus4
      %{ Db7#5#9 %}     des:7.5+.9+
    }
    %
    \new Lyrics \lyricmode{
      %{ B13sus4 %}     \markup { \override #'(size . 1.5) \fret-diagram-terse
#"7;x;7;9;9;x;"}
      %{ Db7#5#9 %}     \markup { \custom-fret #"x;8;9;9;10;x;"  "" "3"
\with-flat "7" \with-sharp "9" \with-sharp "5" "" }
    }
    %
    \chordmode {
      \clef "treble_8"
      \override Staff.TimeSignature #'stencil = ##f
      %{ B13sus4 %}     <b, a e' aes'>
      %{ Db7#5#9 %}     <f b e' a'>
    }
    %
  >>
  \layout {
    \context {
      \Lyrics
      \override LyricSpace #'minimum-distance = #1.5
      \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
      \override LyricText #'self-alignment-X = #CENTER
    }
    %
    \context {
      \ChordNames
      \override ChordName #'font-size = #1
      \override ChordName #'self-alignment-X = #CENTER
      \override ChordName #'X-offset =
#ly:self-alignment-interface::aligned-on-x-parent
    }
  }
}
%
--------------------------------------------------------------------------------------------------------------------



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Guitar-Fret-Diagram-scale-degree-below-string-tp179664p179693.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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