David Kastrup wrote Thursday, December 05, 2013 5:48 PM

> We need to figure out how we can provide "style sheets", similar to how
> LaTeX makes it possible to define "document classes" (layout definitions
> and tools) and "packages" (raw functionality packaged into coherent
> interfaces).

A simpler approach would be to embed templates into LP so that they
could just be invoked.  The template would provide the context structure
of a particular type of score, and also define the variables needed.  All
the (new) users would need to do would be to override the values of the
variables with their own music.

You can try this now by simply using \include.  Two \include's are needed:
one which goes at the top of the file to define and set up the default
values of the variables and one which goes at the bottom of the file to
define the context structure.  A real example using a template which
provides an SATB choir on two staves with lyrics between them and
a piano staff with accompaniment is attached.  I've left out the two
include files, but you can easily image what they contain.  You'll see this
is a really easy interface for a new user, as all the complication is
provided by the included file.

A nice feature is that any context left without input is not printed, so the
same template could be used for SA and piano, just piano, a variable
number of verses, etc.

If this mechanism were to be embedded in LP all that would be needed
as the user interface would be something like

\use SA-TB-B-template

before the user code providing the music, as attached.

Just a thought ...

Trevor
\version "2.17.96"

\include "SA-TB-P-init.ily"

#(set-global-staff-size 19)

\header {
  title = "'Twas Cool that Night in Bethlehem"
  composer = "James L. Alty"
  poet = "James L. Alty"
}

\paper {
  page-count = 2
}

Time = {
  \numericTimeSignature
  \time 4/4
  \tempo 4 = 100
  \repeat volta 4 {
    s1*17
  }
  \alternative {
    { s1 }
    { s1 }
  }
  s1*2
  \bar "|."
}

Key = { \key ef \major }

LadiesInstrumentName = 
  \markup \right-column \smallCaps { "Soprano" "Alto" }

MenInstrumentName = 
  \markup \right-column \smallCaps { "Tenor" "Bass" }
  
PianoInstrumentName = \markup \smallCaps "Piano"

SopranoMusic = \relative {
  \oneVoice R1 | r2 r4 \voiceOne bf'\mp\( | bf bf bf af | bf ef bf4.\) af8\( | g4 g g f |
  g2.\) g4\(\< | f g c, g' | f g bf4.\)\mf g8\(\> | f4 ef ef c | ef2.\) c'4\p\( |
  c4 bf c ef | c bf g f\) | g4.\( f8 g4 bf | c,2.\) ef4\mf\( | f\< g bf\) g\( |
  c4 bf ef4.\)\f c8\(\mf | af4\> g f ef\p | ef1\) | ef | \oneVoice R1 | R1 |
}

AltoMusic = \relative {
  s1 | s2. g'4 | g g af af | g g af4. ef8 | ef4 ef c c |
  d2. d4 | c c af d | c c d4. d8 | bf4 bf af af | bf2. g'4 |
  g4 g g g | g g d d | d4. d8 ef4 ef | af,2. c4 | c d f ef |
  g4 g af4. af8 | ef4 d c c | bf1 | bf1 | s1 | s1 |
}

TenorMusic = \relative {
  \oneVoice R1 | r2 r4 \voiceOne ef' | ef ef ef ef | ef ef ef4. c8 | bf4 bf af af |
  b2. bf4 | af af f bf | af af d4. bf8 | g4 g f f | g2. ef'4 |
  ef ef ef ef | d ef bf bf | bf4. bf8 g4 g | f2. af4 | af bf bf bf |
  e4 d c4. ef8 | c4 bf af af | g1 | g1 | \oneVoice R1 | R1 |
}

BassMusic = \relative {
  s1 | s2. bf4 | bf bf c c | bf bf c4. af8 | ef4 d c c |
  g'2. g4 | bf, d c d | bf c g4. d'8 | ef4 ef bf bf | ef2. c'4 |
  bf4 bf af af | g bf g f| ef4. ef8 c4 bf | c2. ef4 | bf bf d ef |
  c4 g' f4. f8 | f4 g f bf, | ef1 | ef | s | s |
}

VerseOne = \lyricsto "Soprano" \lyricmode {
  \set stanza = "1."
  'Twas cool that night in Beth -- le -- hem,
  the U -- ni -- verse was still,
  And time and space were full of grace,
  a -- wai -- ting our Lord's will.
  The an -- gels looked on an -- xious -- ly 
  and Ma -- ry gave a sigh.
  And then all heav'n was full of joy: 
  they heard a ba -- by cry.
}

VerseTwo = \lyricsto "Soprano" \lyricmode {
  \set stanza = "2."
  A ti -- ny boy in swad -- dling clothes 
  lay in a man -- ger bare.
  His love -- ly face was full of grace, 
  with -- out a world -- ly care.
  Then Ma -- ry took him in her arms, 
  her fine be -- lov -- ed son.
  She thanked the Lord for this great gift 
  and all that He had done.
}

VerseThree = \lyricsto "Soprano" \lyricmode {
  \set stanza = "3."
  An an -- gel from the Lord came down
  to shep -- herds on the hill.
  \hdq Great joy and peace I \tdq bring, he said,
  \hdq and to man -- kind, good -- \tdq will.
  They jour -- neyed down to Beth -- le -- hem
  to seek what they'd been told.
  They found the man -- ger and the boy
  as was fore -- told of old.
}

VerseFour = \lyricsto "Soprano" \lyricmode {
  \set stanza = "4."
  That ba -- by grew in -- to a man, 
  who saved us from our sin.
  Who died for us up -- on a cross,
  and begs us to come in.
  Why can't we all be like this man,
  and fill our lives with grace?
  To help the poor and weak and lame
  un -- til we see his _ face.
}

PianoRH = \relative {
  \repeat unfold 4 { <d' ef g bf>2 <c ef g af>2 } |
  % bar 5
  <bf c ef g>2 <af c ef g> |
  % bar 6
  <g b d g>2. g'4 | <af, c f> g' <ef, f af c> g' | <af, c f> g' <d f g bf>4. g8 |
  % bar 9
  <af, f'>4 ef' <af, ef'> <af c> | <g bf ef>1 |
  % bar 11
  <ef' g c>4 bf' q ef | q bf <bf, d g> f' | q4. f8 q4 bf | <f, af c>2. ef'4 |
  % bar 15
  <af, c f> g' <d f g bf> g |
  % bar 16
  <e g c> bf' <f af c ef?> c' | <c, ef? af> <bf d g> <af c f> ef' | <g, bf ef>1 | q |
  % bar 20
  <c ef af>4^"Slower" <bf d g> < af c f> c8 ef | <ef bf g>1 |
}

PianoLH = \relative {
  <ef, bf ef,>2 bf | q bf | q bf | q bf | <af' ef af,> ef |
  <g d g,>2. r4 | <bf bf,>2 <f' f,> | <bf, bf,> <g' g,> |
   <bf bf,>2 <f f,> | <ef bf ef,>2. r4 |
  <c' g c,>2 <bf f bf,> | <af ef af,> <g d g,> | <ef bf ef,>
   <g d g,>2 <f, c f,>2. r4 | <bf' bf,>2 <g g,> |
  <c c,>2 <f, f,> | q <bf bf,> | <ef, bf ef,>1 | q |
   <f f,>2 <bf bf,> | <ef, bf ef,>1 |
}

\include "SA-TB-P.ily"


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to