Copyright update
[opera_libre.git] / definitions / functions.ly
blob671e1a06143059b425d67cb6afd79afdf9a1aec3
1 %------------------------------------------------------------------%
2 % Opéra Libre -- functions.ly %
3 % %
4 % (c) Valentin Villenave, 2008, 2009 % %
5 %------------------------------------------------------------------%
7 % Core structure functions (with great help from Nicolas Sceaux and
8 % Reinhold Kainhofer).
10 %%%%%%%%%%%%%%%%%%%%%%%%% Scores inclusion %%%%%%%%%%%%%%%%%%%%%%%%%
12 %% Prefix/postfix defs --------------------------------------------%
13 #(define text-id "Texte")
15 %% Variables handling ---------------------------------------------%
16 #(define (make-sym prefix-or-name name-or-postfix)
17 (if (symbol? prefix-or-name)
18 (string->symbol (string-append
19 (symbol->string prefix-or-name)
20 name-or-postfix))
21 (string->symbol (string-append
22 prefix-or-name
23 (symbol->string name-or-postfix)))))
25 #(define (make-this-music name)
26 (let ((music (ly:parser-lookup parser name)))
27 (if (ly:music? music)
28 music
29 (make-music 'Music 'void #t))))
31 #(define (make-this-text name)
32 (let ((mark (ly:parser-lookup parser name)))
33 (if (markup? mark)
34 mark
35 (begin
36 (ly:warning "no text found in markup")
37 point-stencil))))
40 %% LilyPond commands ----------------------------------------------%
41 includeAll =
42 #(define-music-function (parser location variable-names) (list?)
43 (map (lambda (variable-name)
44 (let* ((music (make-this-music variable-name))
45 (score (scorify-music music parser))
46 (layout (ly:output-def-clone $defaultlayout))
47 (header (make-module))
48 (title (make-this-text (make-sym text-id variable-name))))
49 (module-define! header 'piece title)
51 (ly:score-set-header! score header)
52 (ly:score-add-output-def! score layout)
53 (add-score parser score)))
55 variable-names)
56 (make-music 'Music 'void #t))