]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/satb.ly
Issue 5167/1: Reorganize markup commands to use object properties
[lilypond.git] / ly / satb.ly
index a15dd1d72d2e00586a51025189f917520c18032d..36e9dc367af947fd8b92be3cbd42ac750adb9b7d 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.18.0"
+%\version "2.19.19"
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%                                                %%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%                                                %%
   context structure for a score arrangement consisting
   of the following staves:
 
   context structure for a score arrangement consisting
   of the following staves:
 
-  Descant Staff
-  Soprano and Alto (optionally on two Staves or one Staff)
+  Solo Staff (outside Choir grouping)
+  Descant Staff (within Choir grouping)
+  Women Staff (single voice on one staff)
+  Soprano and Alto (optionally on two Staves or one Staff each)
   Multiple verses (up to 9)
   Multiple verses (up to 9)
-  Tenor and Bass (optionally on two Staves or one Staff)
+  Tenor and Bass (optionally on two Staves or one Staff each)
+  Men Staff (single voice on one staff)
   Piano Staff
 
   It is intended primarily to hide the complexity of the context
   Piano Staff
 
   It is intended primarily to hide the complexity of the context
   \header { ... }
   Key = { ... }
   Time = { ... }
   \header { ... }
   Key = { ... }
   Time = { ... }
+  SoloMusic = \relative { ... }
   DescantMusic = \relative { ... }
   DescantLyrics = \lyricmode { ... }
   DescantMusic = \relative { ... }
   DescantLyrics = \lyricmode { ... }
+  WomenMusic = \relative { ... }
+  WomenLyrics = \lyricmode { ... }
   SopranoMusic = \relative { ... }
   SopranoLyrics = \lyricmode { ... }
   AltoMusic = \relative { ... }
   SopranoMusic = \relative { ... }
   SopranoLyrics = \lyricmode { ... }
   AltoMusic = \relative { ... }
@@ -45,6 +51,8 @@
   TenorLyrics = \lyricmode { ... }
   BassMusic = \relative { ... }
   BassLyrics = \lyricmode { ... }
   TenorLyrics = \lyricmode { ... }
   BassMusic = \relative { ... }
   BassLyrics = \lyricmode { ... }
+  MenMusic = \relative { ... }
+  MenLyrics = \lyricmode { ... }
   PianoRHMusic = \relative { ... }
   PianoDynamics = { ... }
   PianoLHMusic = \relative { ... }
   PianoRHMusic = \relative { ... }
   PianoDynamics = { ... }
   PianoLHMusic = \relative { ... }
   All of the definitions are optional. Staves with no music will be
   omitted from the output.
 
   All of the definitions are optional. Staves with no music will be
   omitted from the output.
 
-  Other variables, such as the instrumentName, can also be changed by
-  defining variables like AltoInstrumentName.  The key is defined in
-  the variable Key, and the structure of time and repeats in the
-  variable Time, using spacer rests.  A \layout block may be defined in
-  the variable Layout.  There is no default \header block and no default
-  \paper block.
+  Other variables, such as the instrumentName, shortInstrumentName
+  and MidiInstrument can also be changed by defining variables like
+  AltoInstrumentName, BassMidiInstrument, etc.  The prefixes for staves
+  containing two divided voices are WomenDivided and MenDivided, hence
+  the corresponding variables would be WomenDividedInstrumentName, etc.
+  The key is defined in the variable Key, and the structure of time
+  and repeats in the variable Time, using spacer rests.
+
+  A \layout block may be defined in the variable Layout.  There is
+  no default \header block and no default \paper block.
 
   Music may be tagged with #'print or #'play to be included only in
   the printed score or in the MIDI file respectively.
 
 %}
 
 
   Music may be tagged with #'print or #'play to be included only in
   the printed score or in the MIDI file respectively.
 
 %}
 
-#(defmacro defaulting (name . default)
-  (if (defined? name) name (if (pair? default) (car default) '#{#})))
-
-#(define (sym . strings) (string->symbol (apply string-append strings)))
-
-#(defmacro short-name (part)
-  "Use PartShortInstrumentName, or the first letter of
-PartInstrumentName or its default."
-  (if (defined? (sym part "Music"))
-    (let ((sname (sym part "ShortInstrumentName")))
-      (if (defined? sname)
-        sname
-        `(substring (defaulting ,(sym part "InstrumentName") ,part)
-                   0 1)))
-    ""))
-
-#(defmacro lyrics-if-defined (name voice . optionals)
-  (let ((above (if (pair? optionals) (car optionals) #f)))
-    (if (defined? name)
-      `(make-music 'ContextSpeccedMusic
-        'create-new #t
-        'context-type 'Lyrics
-        'property-operations ',(if above `((assign alignAboveContext ,above)) '())
-        'element (make-music 'LyricCombineMusic
-                  'associated-context ,voice
-                  'element ,name))
-      #{#})))
-
-#(defmacro one-voice-staff (name clef)
-  `#{ <<
-     \new Staff = #(identity ,name) \with {
-       instrumentName = \markup \smallCaps
-         #(defaulting ,(sym name "InstrumentName") ,name)
-       shortInstrumentName = \markup \smallCaps #(short-name ,name)
-       midiInstrument = "clarinet"
-     } {
-       #(defaulting Key)
-       \clef #(identity ,clef)
-       \new Voice = #(identity ,name) <<
-        #(defaulting Time)
-        \dynamicUp
-        #(defaulting ,(sym name "Music"))
-       >>
-     }
-     #(lyrics-if-defined ,(sym name "Lyrics") ,name)
-     #(lyrics-if-defined ,(sym name "LyricsOne") ,name)
-     #(lyrics-if-defined ,(sym name "LyricsTwo") ,name)
-     #(lyrics-if-defined ,(sym name "LyricsThree") ,name)
-   >> #})
-
-#(defmacro two-voice-staff (name clef v1name v2name)
-  `#{ <<
-    \new Staff = #(identity ,name) \with {
-      instrumentName = \markup \right-column \smallCaps {
-        #(defaulting ,(sym v1name "InstrumentName") ,v1name)
-        #(defaulting ,(sym v2name "InstrumentName") ,v2name)
-      }
-      shortInstrumentName = \markup \right-column \smallCaps {
-       #(short-name ,v1name)
-       #(short-name ,v2name)
-      }
-      midiInstrument = "clarinet"
-    } <<
-      #(defaulting Key)
-      \clef #(identity ,clef)
-      \new Voice = #(identity ,v1name) <<
-       #(defaulting Time)
-       \voiceOne
-       \dynamicUp
-       #(defaulting ,(sym v1name "Music"))
-      >>
-      \new Voice = #(identity ,v2name) <<
-       #(defaulting Time)
-       \voiceTwo
-       #(defaulting ,(sym v2name "Music"))
-      >>
-    >>
-    #(lyrics-if-defined ,(sym v1name "Lyrics") ,v1name ,name)
-    #(lyrics-if-defined ,(sym v1name "LyricsOne") ,v1name ,name)
-    #(lyrics-if-defined ,(sym v1name "LyricsTwo") ,v1name ,name)
-    #(lyrics-if-defined ,(sym v1name "LyricsThree") ,v1name ,name)
-    #(lyrics-if-defined ,(sym v2name "Lyrics") ,v2name)
-    #(lyrics-if-defined ,(sym v2name "LyricsOne") ,v2name)
-    #(lyrics-if-defined ,(sym v2name "LyricsTwo") ,v2name)
-    #(lyrics-if-defined ,(sym v2name "LyricsThree") ,v2name)
-  >> #})
-
-SATB = <<
-  \new ChoirStaff
-  \with {
-    \override VerticalAxisGroup.remove-empty = ##t
-    \override VerticalAxisGroup.remove-first = ##t
-  }
-  <<
-    #(one-voice-staff "Descant" "treble")
-
-    #(if (defaulting TwoVoicesPerStaff #f)
-      (two-voice-staff "Women" "treble" "Soprano" "Alto")
-      (make-simultaneous-music (list (one-voice-staff "Soprano" "treble")
-                                    (one-voice-staff "Alto" "treble"))))
-
-    #(lyrics-if-defined VerseOne "Soprano")
-    #(lyrics-if-defined VerseTwo "Soprano")
-    #(lyrics-if-defined VerseThree "Soprano")
-    #(lyrics-if-defined VerseFour "Soprano")
-    #(lyrics-if-defined VerseFive "Soprano")
-    #(lyrics-if-defined VerseSix "Soprano")
-    #(lyrics-if-defined VerseSeven "Soprano")
-    #(lyrics-if-defined VerseEight "Soprano")
-    #(lyrics-if-defined VerseNine "Soprano")
-
-    #(if (defaulting TwoVoicesPerStaff #f)
-      (two-voice-staff "Men" "bass" "Tenor" "Bass")
-      (make-simultaneous-music (list (one-voice-staff "Tenor" "treble_8")
-                                    (one-voice-staff "Bass" "bass"))))
-  >>  % End ChoirStaff
-
-  \new PianoStaff
-  \with {
-    instrumentName = \markup \smallCaps
-                       #(defaulting PianoInstrumentName "Piano" )
-    shortInstrumentName = \markup \smallCaps #(short-name "Piano" )
+\include "vocal-tkit.ly"
+\include "piano-tkit.ly"
+
+#(define satb-voice-prefixes
+   ;; These define the permitted prefixes to various names.
+   ;; They are combined with a fixed set of postfixes to form
+   ;; names such as AltoMusic, BassInstrumentName, etc.
+   ;; These names may be redefined.
+   '("Alto"
+     "Bass"
+     "Descant"
+     "Men"
+     "MenDivided"
+     "Piano"
+     "PianoLH"
+     "PianoRH"
+     "Solo"
+     "Soprano"
+     "Tenor"
+     "Women"
+     "WomenDivided"))
+
+#(define satb-lyrics-postfixes
+   ;; These define the permitted postfixes to the names of lyrics.
+   ;; They are combined with the prefixes to form names like
+   ;; AltoLyrics, etc.
+   ;; These names may be redefined or extended.
+  '("Lyrics"
+    "LyricsOne"
+    "LyricsTwo"
+    "LyricsThree"
+    "LyricsFour"))
+
+#(define satb-lyrics-variable-names
+   ;; These define the names which may be used to specify stanzas
+   ;; which go between the two two-voice staves when TwoVoicesPerStaff
+   ;; is set to #t.  They may be redefined or extended.
+  '("VerseOne"
+    "VerseTwo"
+    "VerseThree"
+    "VerseFour"
+    "VerseFive"
+    "VerseSix"
+    "VerseSeven"
+    "VerseEight"
+    "VerseNine"))
+
+%% make the above definitions available
+#(set-music-definitions!
+  satb-voice-prefixes
+  satb-lyrics-postfixes
+  satb-lyrics-variable-names)
+
+%% override the usual default value
+#(if (not SoloShortInstrumentName)
+       (set! SoloShortInstrumentName ""))
+
+SATB =
+<<
+  \make-one-voice-vocal-staff "Solo" "treble"
+  \new ChoirStaff <<
+    \make-one-voice-vocal-staff "Descant" "treble"
+    \make-one-voice-vocal-staff "Women" "treble"
+    #(if TwoVoicesPerStaff
+      #{
+        \make-two-vocal-staves-with-stanzas
+          "WomenDivided" "treble" "MenDivided" "bass"
+          "Soprano" "Alto" "Tenor" "Bass"
+          #satb-lyrics-variable-names
+      #}
+      #{
+        <<
+          \make-one-voice-vocal-staff "Soprano" "treble"
+          \make-one-voice-vocal-staff "Alto" "treble"
+          \make-one-voice-vocal-staff "Tenor" "treble_8"
+          \make-one-voice-vocal-staff "Bass" "bass"
+        >>
+      #} )
+    \make-one-voice-vocal-staff "Men" "bass"
+  >>
+>>
+
+Piano = \make-pianostaff
+
+\tagGroup #'(print play)
+
+\layout {
+  \context {
+    \Staff
     \override VerticalAxisGroup.remove-empty = ##t
     \override VerticalAxisGroup.remove-first = ##t
   }
     \override VerticalAxisGroup.remove-empty = ##t
     \override VerticalAxisGroup.remove-first = ##t
   }
-  <<
-    \new Staff {
-      \clef "treble"
-      #(defaulting Key)
-      \new Voice <<
-       #(defaulting Time)
-       #(defaulting PianoRHMusic)
-      >>
-    }
-    \new Dynamics {
-      #(defaulting PianoDynamics)
-    }
-    \new Staff {
-      \clef "bass"
-      #(defaulting Key)
-      \new Voice <<
-       #(defaulting Time)
-       #(defaulting PianoLHMusic)
-      >>
-    }
-  >>
->>
+}
 
 \score {
 
 \score {
-  \keepWithTag #'print \SATB
-  \layout { #(defaulting Layout) }
+  \keepWithTag #'print
+  #(if have-music
+       #{ << \SATB \Piano >> #}
+       #{ { } #} )
+  \layout { $(if Layout Layout) }
 }
 
 }
 
+
 \score {
 \score {
-  \keepWithTag #'play \SATB
-  \midi { }
+  \keepWithTag #'play
+  #(if have-music
+       #{ << \SATB \Piano >> #}
+       #{ { } #} )
+  \midi {
+    \context {
+      \Score
+      midiChannelMapping = #'instrument
+    }
+  }
 }
 }
-