ActeUnSceneUn, take 2
[opera_libre.git] / definitions / titling.ly
bloba20db430dd6adb09cc72624132b13e604f60c7a8
1 %------------------------------------------------------------------%
2 % Opéra Libre -- titling.ly %
3 % %
4 % (c) Valentin Villenave, 2008 %
5 % %
6 %------------------------------------------------------------------%
8 %%% The following functions were provided by
9 %%% Nicolas Sceaux <nicolas.sceaux@free.fr>
10 %%%
11 %%% Options
12 %%% =======
13 %%% use-rehearsal-numbers
14 %%% If #t, add rehearsal numbers to piece titles.
15 %%%
16 %%% Scheme functions
17 %%% ================
18 %%% (add-toplevel-markup parser text)
19 %%% add a markup at current point.
20 %%%
21 %%% (add-toc-item parser markup-symbol text)
22 %%% add an item in the table of content, using markup style
23 %%% `markup-symbol' and `text', referencing the page occuring
24 %%% at current point.
25 %%%
26 %%% (rehearsal-number)
27 %%% return a new x.y rehearsal number.
28 %%%
29 %%% (increase-rehearsal-major-number)
30 %%% increase the major part of rehearsal numbers (ie the x in x.y)
31 %%% and reset the minor part.
32 %%%
33 %%% Markup commands
34 %%% ===============
35 %%%
36 %%% \act <title>
37 %%% Markup command to be used for act titles
38 %%%
39 %%% \scene <title>
40 %%% Markup command to be used for scene titles
41 %%%
42 %%% \title <title>
43 %%% Markup command to be used for piece titles
44 %%%
45 %%% \scene-desription <markup>
46 %%% Markup command to be used for entering a scene description.
47 %%%
48 %%% Table of contexts \paper variables
49 %%% ==================================
50 %%%
51 %%% tocTitle
52 %%% a string used as the table of contents title
53 %%%
54 %%% tocPieceMarkup
55 %%% markup used for pieces
56 %%%
57 %%% tocSceneMarkup
58 %%% markup used for scene titles
59 %%%
60 %%% tocActMarkup
61 %%% markup used for act titles
62 %%%
63 %%% Music functions
64 %%% ===============
65 %%% Piece titling:
66 %%%
67 %%% \pieceToc <title-markup>
68 %%% add a piece title in the table of contents.
69 %%%
70 %%% \pieceTocTitle <title-string>
71 %%% add the piece title in the table of contents and at current
72 %%% point of the book (upper cased).
73 %%%
74 %%% \pieceTitle <title-string>
75 %%% add the upper cased piece title at the current point of the book.
76 %%%
77 %%% \pieceTocAndTitle <toc-markup> <title-markup>
78 %%% add a piece title in the table of content, and a different
79 %%% title at the current point of the book.
80 %%%
81 %%% Sectionning:
82 %%%
83 %%% \opusTitle <title-string>
84 %%%
85 %%% \ouverture <title-string>
86 %%% \act <title-string>
87 %%% \scene <title-string>
88 %%% \sceneDescription <description-markup>
89 %%%
90 %%% \actEnd
91 %%% Print an act end text.
95 %%%%%%%%%%%%%%%%%%%%%%%%%% Fancy Headers %%%%%%%%%%%%%%%%%%%%%%%%%%%
97 %% Scheme functions -----------------------------------------------%
99 %%% Set odd and even page header, respectively, to `text'.
100 %%% If `display-first' is false, then `text' will not be displayed
101 %%% on the first page it has been added, only on the following ones.
102 %%% `parser' is the lilypond parser object.
104 #(define-public add-odd-page-header-text #f)
105 #(define-public add-even-page-header-text #f)
106 #(define header-markup-aux #f)
107 #(let ((odd-label-header-table (list))
108 (odd-page-header-table (list))
109 (even-label-header-table (list))
110 (even-page-header-table (list)))
111 (set! header-markup-aux
112 (lambda (layout props odd)
113 (define (page-text page-number table)
114 (if (null? table)
116 (let* ((elment (car table))
117 (p (car elment))
118 (text (cadr elment))
119 (display-1st (caddr elment)))
120 (cond ((and (= page-number p) (not display-1st)) #f)
121 ((>= page-number p) text)
122 (else (page-text page-number (cdr table)))))))
123 (ly:make-stencil
124 `(delay-stencil-evaluation
125 ,(delay (ly:stencil-expr
126 (begin
127 (if (or (and odd (null? odd-page-header-table))
128 (and (not odd) (null? even-page-header-table)))
129 (let ((page-header-table (list)))
130 (for-each (lambda (label-header)
131 (let* ((label (car label-header))
132 (text-disp (cdr label-header))
133 (table (ly:output-def-lookup layout 'label-page-table))
134 (label-page (and (list? table) (assoc label table)))
135 (page-number (and label-page (cdr label-page)))
136 (prev-value (and page-number (assoc page-number page-header-table))))
137 (if (not prev-value)
138 (set! page-header-table (cons (cons page-number text-disp)
139 page-header-table))
140 (set! page-header-table
141 (assoc-set! page-header-table
142 page-number
143 (list (car text-disp) (caddr prev-value)))))))
144 (reverse (if odd odd-label-header-table even-label-header-table)))
145 (if odd
146 (set! odd-page-header-table page-header-table)
147 (set! even-page-header-table page-header-table))))
148 (interpret-markup layout props
149 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
150 (text (page-text page-number (if odd odd-page-header-table even-page-header-table)))
151 (text-markup (markup #:italic (or text "")))
152 (page-number-markup (number->string page-number)))
153 (cond ((or (= 1 page-number) (not text)) (markup #:null))
154 (odd (markup #:fill-line (#:null text-markup page-number-markup)))
155 (else (markup #:fill-line (page-number-markup text-markup #:null))))))))))
156 (cons 0 0)
157 (ly:stencil-extent (interpret-markup layout props "XXX") Y))))
158 (set! add-odd-page-header-text
159 (lambda (parser text display-1st)
160 (let ((label (gensym "header")))
161 (set! odd-label-header-table
162 (cons (list label text display-1st)
163 odd-label-header-table))
164 (collect-music-for-book parser
165 (make-music 'Music
166 'page-marker #t
167 'page-label label)))))
168 (set! add-even-page-header-text
169 (lambda (parser text display-1st)
170 (let ((label (gensym "header")))
171 (set! even-label-header-table
172 (cons (list label text display-1st)
173 even-label-header-table))
174 (collect-music-for-book parser
175 (make-music 'Music
176 'page-marker #t
177 'page-label label))))))
179 %% Markup commands ------------------------------------------------%
181 %%% Interpret the odd or even page headers, based on header text
182 %%% added using `add-odd-page-header-text' or `add-even-page-header-text'.
184 #(define-markup-command (odd-header layout props) ()
185 (header-markup-aux layout props #t))
187 #(define-markup-command (even-header layout props) ()
188 (header-markup-aux layout props #f))
190 \paper {
191 evenHeaderMarkup = \markup \even-header
192 oddHeaderMarkup = \markup \odd-header
196 %%% Toplevel markups
199 #(define-public (add-toplevel-markup parser text)
200 (collect-scores-for-book parser (list text)))
202 #(define-public (add-toc-item parser markup-symbol text)
203 (collect-music-for-book parser
204 (add-toc-item! markup-symbol text)))
207 %%% Rehearsal numbers
210 #(define-public rehearsal-number #f)
211 #(define-public increase-rehearsal-major-number #f)
212 #(let ((major-number 0)
213 (minor-number 0))
214 (set! increase-rehearsal-major-number
215 (lambda ()
216 (set! major-number (1+ major-number))
217 (set! minor-number 0)))
218 (set! rehearsal-number
219 (lambda ()
220 (set! minor-number (1+ minor-number))
221 (format #f "~a-~a" major-number minor-number))))
224 %%% Table of contents
226 #(define-markup-command (paper-prop layout props name default)
227 (symbol? markup?)
228 "Get the value of a \\paper property, or defaults to some value"
229 (let ((val (ly:output-def-lookup layout name)))
230 (interpret-markup layout props (if (markup? val)
232 default))))
233 \paper {
234 tocTitleMarkup = \markup \column {
235 \vspace #2
236 \fontsize #6 \fill-line { \paper-prop #'tocTitle "TABLE OF CONTENTS" }
237 \vspace #2
239 tocPieceMarkup = \markup \fill-line {
240 \line-width-ratio #0.7 \fill-line {
241 \line { \fromproperty #'toc:text }
242 \fromproperty #'toc:page
245 tocBoldPieceMarkup = \markup \fill-line {
246 \line-width-ratio #0.7 \fill-line {
247 \line { \bold \fromproperty #'toc:text }
248 \bold \fromproperty #'toc:page
251 tocSceneMarkup = \markup \italic \column {
252 \fill-line { \fromproperty #'toc:text }
254 tocActMarkup = \markup \large \italic \column {
255 \vspace #1
256 \fontsize #2 \fill-line { \fromproperty #'toc:text }
257 \vspace #1
262 %%% Music functions
265 %%% Pieces
266 pieceToc =
267 #(define-music-function (parser location title) (markup?)
268 (let ((rehearsal (rehearsal-number)))
269 (add-toc-item parser 'tocPieceMarkup
270 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
271 (markup #:rehearsal-number-toc rehearsal title)
272 title))
273 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
274 (begin
275 (add-toplevel-markup parser
276 (markup #:rehearsal-number rehearsal
277 #:hspace 1
278 #:huge title))
279 (add-no-page-break parser)))
280 (make-music 'Music 'void #t)))
282 pieceTocTitle =
283 #(define-music-function (parser location title) (string?)
284 (let ((rehearsal (rehearsal-number)))
285 (add-toc-item parser 'tocPieceMarkup
286 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
287 (markup #:rehearsal-number-toc rehearsal title)
288 title))
289 (add-toplevel-markup parser
290 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
291 (markup #:rehearsal-number rehearsal
292 #:hspace 1
293 #:huge (string-upper-case title))
294 (markup #:title (string-upper-case title))))
295 (add-no-page-break parser)
296 (make-music 'Music 'void #t)))
298 pieceTitle =
299 #(define-music-function (parser location title) (string?)
300 (let ((rehearsal (rehearsal-number)))
301 (add-toplevel-markup parser
302 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
303 (markup #:rehearsal-number rehearsal
304 #:hspace 1
305 #:huge (string-upper-case title))
306 (markup #:title (string-upper-case title))))
307 (add-no-page-break parser)
308 (make-music 'Music 'void #t)))
310 pieceSTitle =
311 #(define-music-function (parser location title) (markup?)
312 (let ((rehearsal (rehearsal-number)))
313 (add-toplevel-markup parser
314 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
315 (markup #:rehearsal-number rehearsal
316 #:hspace 1
317 #:huge title)
318 (markup #:small-title title)))
319 (add-no-page-break parser)
320 (make-music 'Music 'void #t)))
322 pieceTocAndTitle =
323 #(define-music-function (parser location title toc-title) (markup? markup?)
324 (let ((rehearsal (rehearsal-number)))
325 (add-toc-item parser 'tocPieceMarkup
326 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
327 (markup #:rehearsal-number-toc rehearsal toc-title)
328 toc-title))
329 (add-toplevel-markup parser
330 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
331 (markup #:rehearsal-number rehearsal
332 #:hspace 1
333 #:huge title)
334 (markup #:title title)))
335 (add-no-page-break parser)
336 (make-music 'Music 'void #t)))
338 pieceNoTitle =
339 #(define-music-function (parser location) ()
340 (let ((rehearsal (rehearsal-number)))
341 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
342 (begin
343 (add-toplevel-markup parser (markup #:rehearsal-number rehearsal))
344 (add-no-page-break parser)))
345 (make-music 'Music 'void #t)))
347 %%% Sections
348 #(use-modules (srfi srfi-39))
349 #(define-public *opus-title* (make-parameter ""))
350 #(define-public *act-title* (make-parameter ""))
352 opusTitle =
353 #(define-music-function (parser location title) (string?)
354 (*opus-title* (if (*part*)
355 (string-append title ", " (*part-name*))
356 title))
357 (make-music 'Music 'void #t))
359 ouverture =
360 #(define-music-function (parser location title) (string?)
361 (let ((rehearsal (rehearsal-number)))
362 (add-page-break parser)
363 (add-toc-item parser 'tocPieceMarkup
364 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
365 (markup #:rehearsal-number-toc rehearsal title)
366 title))
367 (add-even-page-header-text parser (string-upper-case (*opus-title*)) #f)
368 (add-odd-page-header-text parser (string-upper-case title) #f)
369 (add-toplevel-markup parser (markup #:act (string-upper-case title)))
370 (add-no-page-break parser)
371 (if (eqv? #t (ly:get-option 'use-rehearsal-numbers))
372 (begin
373 (add-toplevel-markup parser (markup #:rehearsal-number rehearsal))
374 (add-no-page-break parser))))
375 (make-music 'Music 'void #t))
377 act =
378 #(define-music-function (parser location act-title) (string?)
379 (increase-rehearsal-major-number)
380 (add-page-break parser)
381 (add-toc-item parser 'tocActMarkup act-title)
382 (add-even-page-header-text parser (string-upper-case (*opus-title*)) #f)
383 (*act-title* act-title)
384 (add-odd-page-header-text
385 parser
386 (format #f "~a." (string-upper-case (*act-title*)))
388 (add-toplevel-markup parser
389 (markup #:act (string-upper-case act-title)))
390 (add-no-page-break parser)
391 (make-music 'Music 'void #t))
393 actEnd =
394 #(define-music-function (parser location text) (markup?)
395 (add-no-page-break parser)
396 (add-toplevel-markup parser (markup #:fontsize 4 #:fill-line (text)))
397 (add-no-page-break parser)
398 (add-toplevel-markup parser (markup #:null))
399 (make-music 'Music 'void #t))
401 scene =
402 #(define-music-function (parser location title) (string?)
403 (add-toc-item parser 'tocSceneMarkup title)
404 (add-odd-page-header-text
405 parser
406 (format #f "~a, ~a."
407 (string-upper-case (*act-title*))
408 (string-upper-case title))
410 (add-toplevel-markup parser
411 (markup #:scene (string-upper-case title)))
412 (add-no-page-break parser)
413 (make-music 'Music 'void #t))
415 sceneDescription =
416 #(define-music-function (parser location description) (markup?)
417 (add-toplevel-markup parser
418 (markup #:scene-description description))
419 (add-no-page-break parser)
420 (make-music 'Music 'void #t))
425 \paper {
427 line-width = #(- paper-width (* 40 mm))
428 %horizontal-shift = 5
429 bottom-margin = #20
430 ragged-bottom = ##t
431 ragged-last-bottom = ##t
432 left-margin = #20
433 between-system-space = 1\cm
434 between-system-padding = #5
437 scoreTitleMarkup = #f
439 oddFooterMarkup = \markup \column {
440 \fill-line {
441 %% put copyright only on pagenr. 1
442 \on-the-fly #(lambda (layout props arg)
443 (if (and (= 1 (chain-assoc-get 'page:page-number props -1))
444 (not (chain-assoc-get 'page:last? props #f)))
445 (interpret-markup layout props arg)
446 empty-stencil))
447 \fromproperty #'header:longcopyright
449 \fill-line {
450 %% put tagline on last page
451 \on-the-fly #(lambda (layout props arg)
452 (if (chain-assoc-get 'page:last? props #f)
453 (interpret-markup layout props arg)
454 empty-stencil))
455 \fill-line { \fromproperty #'header:tagline }
458 evenFooterMarkup = \markup \column {
459 \fill-line {
460 %% put notice on second page
461 \on-the-fly #(lambda (layout props arg)
462 (if (= 2 (chain-assoc-get 'page:page-number props -1))
463 (interpret-markup layout props arg)
464 empty-stencil))
465 \fill-line { \fromproperty #'header:notes }
467 \fill-line {
468 %% put tagline on last page
469 \on-the-fly #(lambda (layout props arg)
470 (if (chain-assoc-get 'page:last? props #f)
471 (interpret-markup layout props arg)
472 empty-stencil))
473 \fill-line { \fromproperty #'header:tagline }
477 tocTitle = "TABLE DES MATIÈRES"
481 %%% Title page
483 \paper {
484 bookTitleMarkup = \markup \when-property #'header:title \column {
485 \vspace #9
486 \fill-line { \fontsize #11 \italic \fromproperty #'header:composer }
487 \vspace #1
488 \fill-line { \fontsize #11 \italic \fromproperty #'header:poet }
489 \vspace #9
490 \fill-line { \fontsize #13 \fromproperty #'header:title }
491 \vspace #9
492 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
493 \vspace #9
494 \fill-line { \fontsize #6 \fromproperty #'header:date }
495 \vspace #1
496 \on-the-fly #(lambda (layout props arg)
497 (if (*part*)
498 (interpret-markup layout props
499 (markup #:fill-line (#:column (#:vspace 6
500 #:fill-line (#:fontsize 6 (*part-name*))))))
501 empty-stencil))
502 \fill-line {
503 \when-property #'header:arrangement \column {
504 \vspace #6
505 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
512 \layout {
515 \context {
516 \Score
517 \override BarNumber #'padding = #2
518 \override InstrumentName #'space-alist = #'((left-edge extra-space . 2.0))
519 \override VerticalAlignment #'max-stretch = #ly:align-interface::calc-max-stretch
520 \accepts "StaffGroupNoBar"
521 skipBars = ##t
523 \context {
524 \StaffGroup
525 \name StaffGroupNoBar
526 \description "Like StaffGroup, but without spanbar"
527 \remove "Span_bar_engraver"
528 \accepts "StaffGroupNoBracket"
529 \accepts "InnerStaffGroup"
530 \accepts "InnerChoirStaff"
532 \context {
533 \StaffGroup
534 \name StaffGroupNoBracket
535 \description "Like StaffGroup, but without brackets"
536 \remove "System_start_delimiter_engraver"
538 \context {
539 \ChoirStaff
540 \consists "Instrument_name_engraver"
542 \context {
543 \Staff
544 \name Staff
545 \override VerticalAxisGroup #'minimum-Y-extent = #'(-4 . 4)
546 %% Figured bass
547 figuredBassAlterationDirection = #RIGHT
548 \override BassFigureAlignment #'stacking-dir = #UP
549 \override BassFigureAlignmentPositioning #'direction = #DOWN
551 RemoveEmptyStaffContext = \context {
552 \Staff
553 \remove "Axis_group_engraver"
554 \consists "Hara_kiri_engraver"
555 \override Beam #'auto-knee-gap = #'()
556 \override VerticalAxisGroup #'remove-empty = ##t
557 \override VerticalAxisGroup #'minimum-Y-extent = #'(-4 . 4)
559 \context {
560 \Staff
561 \name SmallStaff
562 \description "Staff with small notes"
563 fontSize = #-2
564 \override StaffSymbol #'staff-space = #(magstep -2)
568 \header {
569 maintainer = "Valentin Villenave"
570 maintainerEmail = "v.villenave@gmail.com"
571 maintainerWeb = "http://valentin.villenave.info"
572 copyright = \markup \copyright
573 longcopyright = \markup \center-column {
574 \line { \copyright \hspace #-1 . }
575 \line { GNU General Public License v.3 or later.}
578 tagline = \markup {
579 \override #'(box-padding . 1.0) \override #'(baseline-skip . 2.7)
580 \box \center-column {
581 \small \line {
582 \copyright
583 \with-url #"http://valentin.villenave.info" \teeny "<v.villenave@gmail.com>"
584 \hspace #-1 .
585 Gravure réalisée avec \with-url #"http://www.LilyPond.org"
586 \line { \teeny www. \hspace #-1.0 LilyPond \hspace #-1.0 \teeny .org }
587 #(ly:export (string-append "version " (lilypond-version))) \hspace #-1 .
589 %{ \small \line {
590 Sheet music from \with-url #"http://www.MutopiaProject.org"
591 \concat { \teeny www. MutopiaProject \teeny .org }
592 and \with-url #"http://nicolas.sceaux.free.fr"
593 nicolas.sceaux.free.fr
594 } %}
595 \small \line {
596 \italic Free to download, with the \italic freedom
597 to distribute, modify and perform.
599 \teeny \line {
600 Licensed under the Creative Commons Attributio 3.0 License,
601 for details see: \hspace #-0.5
602 \with-url #"http://creativecommons.org/licenses/by/3.0"
603 http://creativecommons.org/licenses/by/3.0 }