1 %------------------------------------------------------------------%
2 % Opéra Libre -- titling.ly %
4 % (c) Valentin Villenave, 2008 %
6 %------------------------------------------------------------------%
8 %%% The following functions were provided by
9 %%% Nicolas Sceaux <nicolas.sceaux@free.fr>
13 %%% use-rehearsal-numbers
14 %%% If #t, add rehearsal numbers to piece titles.
18 %%% (add-toplevel-markup parser text)
19 %%% add a markup at current point.
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
26 %%% (rehearsal-number)
27 %%% return a new x.y rehearsal number.
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.
37 %%% Markup command to be used for act titles
40 %%% Markup command to be used for scene titles
43 %%% Markup command to be used for piece titles
45 %%% \scene-desription <markup>
46 %%% Markup command to be used for entering a scene description.
48 %%% Table of contexts \paper variables
49 %%% ==================================
52 %%% a string used as the table of contents title
55 %%% markup used for pieces
58 %%% markup used for scene titles
61 %%% markup used for act titles
67 %%% \pieceToc <title-markup>
68 %%% add a piece title in the table of contents.
70 %%% \pieceTocTitle <title-string>
71 %%% add the piece title in the table of contents and at current
72 %%% point of the book (upper cased).
74 %%% \pieceTitle <title-string>
75 %%% add the upper cased piece title at the current point of the book.
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.
83 %%% \opusTitle <title-string>
85 %%% \ouverture <title-string>
86 %%% \act <title-string>
87 %%% \scene <title-string>
88 %%% \sceneDescription <description-markup>
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
)
116 (let
* ((elment
(car table
))
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
)))))))
124 `
(delay-stencil-evaluation
125 ,(delay
(ly
:stencil-expr
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
))))
138 (set
! page-header-table
(cons
(cons page-number text-disp
)
140 (set
! page-header-table
141 (assoc-set
! page-header-table
143 (list
(car text-disp
) (caddr prev-value
)))))))
144 (reverse
(if odd odd-label-header-table even-label-header-table
)))
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
))))))))))
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
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
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))
191 evenHeaderMarkup
= \markup \even-header
192 oddHeaderMarkup
= \markup \odd-header
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)
214 (set
! increase-rehearsal-major-number
216 (set
! major-number
(1+ major-number
))
217 (set
! minor-number
0)))
218 (set
! rehearsal-number
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
)
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
)
234 tocTitleMarkup
= \markup \column {
236 \fontsize #6 \fill-line
{ \paper-prop
#'tocTitle
"TABLE OF CONTENTS" }
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 {
256 \fontsize #2 \fill-line
{ \fromproperty #'toc
:text
}
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
)
273 (if
(eqv?
#t
(ly
:get-option
'use-rehearsal-numbers
))
275 (add-toplevel-markup parser
276 (markup
#:rehearsal-number rehearsal
279 (add-no-page-break parser
)))
280 (make-music
'Music
'void
#t
)))
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
)
289 (add-toplevel-markup parser
290 (if
(eqv?
#t
(ly
:get-option
'use-rehearsal-numbers
))
291 (markup
#:rehearsal-number rehearsal
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
)))
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
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
)))
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
318 (markup
#:small-title title
)))
319 (add-no-page-break parser
)
320 (make-music
'Music
'void
#t
)))
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
)
329 (add-toplevel-markup parser
330 (if
(eqv?
#t
(ly
:get-option
'use-rehearsal-numbers
))
331 (markup
#:rehearsal-number rehearsal
334 (markup
#:title title
)))
335 (add-no-page-break parser
)
336 (make-music
'Music
'void
#t
)))
339 #(define-music-function
(parser location
) ()
340 (let
((rehearsal
(rehearsal-number
)))
341 (if
(eqv?
#t
(ly
:get-option
'use-rehearsal-numbers
))
343 (add-toplevel-markup parser
(markup
#:rehearsal-number rehearsal
))
344 (add-no-page-break parser
)))
345 (make-music
'Music
'void
#t
)))
348 #(use-modules
(srfi srfi-
39))
349 #(define-public
*opus-title
* (make-parameter
""))
350 #(define-public
*act-title
* (make-parameter
""))
353 #(define-music-function
(parser location title
) (string?
)
354 (*opus-title
* (if
(*part
*)
355 (string-append title
", " (*part-name
*))
357 (make-music
'Music
'void
#t
))
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
)
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
))
373 (add-toplevel-markup parser
(markup
#:rehearsal-number rehearsal
))
374 (add-no-page-break parser
))))
375 (make-music
'Music
'void
#t
))
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
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
))
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
))
402 #(define-music-function
(parser location title
) (string?
)
403 (add-toc-item parser
'tocSceneMarkup title
)
404 (add-odd-page-header-text
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
))
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
))
427 line-width
= #(- paper-width
(* 40 mm
))
428 %horizontal-shift = 5
431 ragged-last-bottom
= ##t
433 between-system-space
= 1\cm
434 between-system-padding
= #5
437 scoreTitleMarkup
= #f
439 oddFooterMarkup
= \markup \column {
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
)
447 \fromproperty #'header
:longcopyright
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
)
455 \fill-line
{ \fromproperty #'header
:tagline
}
458 evenFooterMarkup
= \markup \column {
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
)
465 \fill-line
{ \fromproperty #'header
:notes
}
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
)
473 \fill-line
{ \fromproperty #'header
:tagline
}
477 tocTitle
= "TABLE DES MATIÈRES"
484 bookTitleMarkup
= \markup \when-property
#'header
:title
\column {
486 \fill-line
{ \fontsize #11 \italic \fromproperty #'header
:composer
}
488 \fill-line
{ \fontsize #11 \italic \fromproperty #'header
:poet
}
490 \fill-line
{ \fontsize #13 \fromproperty #'header
:title
}
492 \fill-line
{ \postscript #"-20 0 moveto 40 0 rlineto stroke" }
494 \fill-line
{ \fontsize #6 \fromproperty #'header
:date
}
496 \on-the-fly
#(lambda
(layout props arg
)
498 (interpret-markup layout props
499 (markup
#:fill-line
(#:column
(#:vspace
6
500 #:fill-line
(#:fontsize
6 (*part-name
*))))))
503 \when-property
#'header
:arrangement
\column {
505 \fill-line
{ \fontsize #3 \fromproperty #'header
:arrangement
}
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"
525 \name StaffGroupNoBar
526 \description "Like StaffGroup, but without spanbar"
527 \remove "Span_bar_engraver"
528 \accepts "StaffGroupNoBracket"
529 \accepts "InnerStaffGroup"
530 \accepts "InnerChoirStaff"
534 \name StaffGroupNoBracket
535 \description "Like StaffGroup, but without brackets"
536 \remove "System_start_delimiter_engraver"
540 \consists "Instrument_name_engraver"
545 \override VerticalAxisGroup
#'minimum-Y-extent
= #'(-
4 . 4)
547 figuredBassAlterationDirection
= #RIGHT
548 \override BassFigureAlignment
#'stacking-dir
= #UP
549 \override BassFigureAlignmentPositioning
#'direction
= #DOWN
551 RemoveEmptyStaffContext
= \context {
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)
562 \description "Staff with small notes"
564 \override StaffSymbol
#'staff-space
= #(magstep -
2)
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
.}
579 \override #'(box-padding
. 1.0) \override #'(baseline-skip
. 2.7)
580 \box \center-column
{
583 \with-url
#"http://valentin.villenave.info" \teeny "<v.villenave@gmail.com>"
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 .
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
596 \italic Free to download, with the \italic freedom
597 to distribute, modify and perform.
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 }