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