Hello Tom,

A good template will separate content and form. Ideally you’d be able to use a 
few templates that work so universally that you need only to define the music 
variables and include the template file. This would mean that changing the 
music and the form can be done simply. If for example you wanted to change the 
layout a bit you do not want to have to change this in every score you have. 
Instead you can change it in the included layout definition and you’re done.

We can even use functions to do this in a very clean manner. See the appended 
example.

Cheers,
Valentin

Am Dienstag, 22. Februar 2022, 03:09:03 CET schrieb Tom Campbell:
> I am about to transcribe a bunch of older Western folk music in lead sheet
> form for an open source tunebook. Am trying to create a robust template so
> I don't have to think too much about anything other than getting the notes,
> chords, and lyrics right. You can see it below, or rendered by the
> invaluable Lilybin at http://lilybin.com/u6p5m8/8.
> 
> Can you tell me what's bad about this as a template? The lead sheets will
> contain chord names and guitar fretboard diagrams. Added a crucial (for me)
> section overriding the predefined guitar fretboard diagram for a chord. I
> also took too long to figure out how to get pickup notes in a format that
> seemed natural.
> 
> Thanks!
> 
> % Lead sheet with:
> % - Guitar fretboard diagrams
> % - Override a predefined fretboard diagram
> % - Pickup note with text above it suppressed
> % - Chord and other text suppressed above the pickup note
> %%%% Please send critiques to tomcampb...@gmail.com
> \version "2.18.2"
> \include "predefined-guitar-fretboards.ly"
> 
> % Override predefined fretboard for e minor.
> % This just adds a G to the first (highest) string.
> % A little contrived but it's brief.
> \storePredefinedDiagram #default-fret-table \chordmode { e:m }
> #guitar-tuning
> #"o;2-2;2-3;o;o;3-4;"
> 
> \header {
> title = "Hit and Miss (Daphne)"
> composer = "Trad."
> }
> 
> theMelody = \relative c {
>   \clef treble
>   \key e \minor
>   \time 6/8
> 
> % Pickup note
>   \partial 8 e'8
> 
> % Verse melody (truncated for clarity)
> g4 a8 b4 e8
> d8. e16 fis8
> e4 b16 c
> 
> }
> 
> theLyrics = \lyricmode {
> When Daph -- ne from fair
>   Phoe -- bus did fly the --
> }
> 
> theChords = \chordmode {
> % Replace the N.C. that would appear over
> % the pickup note
> \set noChordSymbol = ""
> \partial 8 r8
>   e2.:min
>   b4.:min
>   e4.:min
>  }
> 
> \score {
>   <<
>   \new ChordNames { \theChords }
>   \new FretBoards { \theChords }
>   \new Voice = "one" { \autoBeamOn \theMelody }
>   \new Lyrics \lyricsto "one" \theLyrics
> 
>   \layout { }
>   \midi { }
> }

% Lead sheet with:
% - Guitar fretboard diagrams
% - Override a predefined fretboard diagram
% - Pickup note with text above it suppressed
% - Chord and other text suppressed above the pickup note
%%%% Please send critiques to tomcampb...@gmail.com
\version "2.22"

%%%% STARTING INCLUDABLE TEMPLATE
#(define (music-or-false? m) (or (ly:music? m) (not m)))
#(define (music-or-list-or-false? m) (or (music-or-false? m) (list? m)))

leadsheetScore =
#(define-void-function (title composer voice chords lyrics)
   (markup? (markup? "Trad.") music-or-false? music-or-false? music-or-list-or-false?)
   (let* ((CN (if chords #{ \new ChordNames $chords #} (empty-music)))
          (FB (if chords
                  (if voice
                      #{ \new FretBoards $chords #}
                      #{ \new FretBoards \with { \consists Bar_engraver \override BarLine.bar-extent = #'(-6 . 3) } $chords #})
              (empty-music)))
          (VC (if voice #{ \new Staff \new Voice="auto" $voice #} (empty-music)))
          (LY (if lyrics
                  (if voice
                      (if (ly:music? lyrics)
                          (list #{ \new Lyrics \lyricsto "auto" $lyrics #})
                          (map (lambda (x)
                                 (if (ly:music? x)
                                     #{ \new Lyrics \lyricsto "auto" $x #}
                                     (if (pair? x)
                                         ; If x is a pair of the form (key . music) we create a stanza indication
                                         #{ \new Lyrics \lyricsto "auto" { \set stanza =
                                                                           $(if (markup? (car x))
                                                                                         (car x)
                                                                                         (format "~a" (car x)))
                                                                           $(cdr x) } #})))
                                     lyrics))
                      (if (ly:music? lyrics)
                          (list #{ \new Lyrics $lyrics #})
                          (map (lambda (x)
                                 (if (ly:music? x)
                                     #{ \new Lyrics $x #}
                                     (if (pair? x)
                                         ; If x is a pair of the form (key . music) we create a stanza indication
                                         #{ \new Lyrics { \set stanza =
                                                          $(if (markup? (car x))
                                                                        (car x)
                                                                        (format "~a" (car x)))
                                                          $(cdr x) } #})))
                                     lyrics)))
                  (empty-music)))
          (mus (make-music 'SimultaneousMusic
                           'elements
                           `(,CN ,FB ,VC . ,LY)))
          (score
           #{
             \score {
               \header {
                 title = #title
                 composer = #composer
               }
               $mus
              \layout { }
              \midi { }
            }
          #}))
     (add-score score)))

\paper {
  print-all-headers = ##t
}


%%%% STARTING CONTENT

\include "predefined-guitar-fretboards.ly"

% Override predefined fretboard for e minor.
% This just adds a G to the first (highest) string.
% A little contrived but it's brief.
\storePredefinedDiagram #default-fret-table \chordmode { e:m }
#guitar-tuning
#"o;2-2;2-3;o;o;3-4;"

theMelody = \relative c {
  \clef treble
  \key e \minor
  \time 6/8

% Pickup note
  \partial 8 e'8

% Verse melody (truncated for clarity)
g4 a8 b4 e8
d8. e16 fis8 
e4 b16 c

}

theLyrics = \lyricmode {
When Daph -- ne from fair 
  Phoe -- bus did fly the __
}

theChords = \chordmode {
% Replace the N.C. that would appear over
% the pickup note
\time 6/8
\set noChordSymbol = ""
\partial 8 r8 
  e2.:min
  b4.:min
  e4.:min
 }

%%% SAME AS BEFORE
\leadsheetScore "Hit and Miss (Daphne)" \theMelody \theChords \theLyrics

%%% NO CHORDS
\leadsheetScore "Hit and Miss (Daphne)" "theComposer" \theMelody ##f \theLyrics

sI = \theLyrics

sII = \lyricmode {
This is a se -- cond stan -- _ _ za,
}

%%% MULTIPLE LINES OF LYRICS
\leadsheetScore "Hit and Miss (Daphne)" "theComposer" \theMelody ##f #`(,sI ,sII)

%% DUE TO NEW VALUES BEING APPENDED WE NEED TO REVERSE THE ORDER
alyrics.2 = \sII
alyrics.1 = \sI

%%% MULTIPLE LINES OF LYRICS WITH STANZA INDICATIONS NOT GIVEN IN THE LYRICS THEMSELVES (BUT BY AN ALIST)
\leadsheetScore "Hit and Miss (Daphne)" "theComposer" \theMelody ##f \alyrics

rhythmicLyrics = \lyricmode {
When8 Daph4 -- ne8 from4 fair8 
  Phoe8. -- bus16 did8 fly4 the8
}

%%% NO VOICE
\leadsheetScore "Hit and Miss (Daphne)" "theComposer" ##f \theChords \rhythmicLyrics

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to