release commit
[lilypond.git] / ly / music-functions-init.ly
blob1d34fca85a2b0216a29c3428b59e379349a07a20
1 \version "2.3.2"
3 #(defmacro-public def-music-function (args signature . body)
4 "Helper macro for `ly:make-music-function'.
5 Syntax:
6 (def-music-function (location arg1 arg2 ...) (arg1-type? arg2-type? ...)
7 ...function body...)
9 `(ly:make-music-function (list ,@signature)
10 (lambda (,@args)
11 ,@body)))
13 applymusic = #(def-music-function (location func music) (procedure? ly:music?)
14 (func music))
16 addlyrics = #(def-music-function (location music lyrics) (ly:music? ly:music?)
17 (make-music 'LyricCombineMusic 'elements (list music lyrics)))
19 #(use-modules (srfi srfi-1))
20 #(define-public (symbol-or-symbols? obj)
21 "Return #t iif obj is a symbol or a symbol list."
22 (or (symbol? obj)
23 (and (list? obj)
24 (null? (remove symbol? obj)))))
27 %% \mytag #'foo { ... } ==> OK
28 %% c-\mytag #'foo ^4 ==> KO
29 mytag = #(def-music-function (location tagname music) (symbol-or-symbols? ly:music?)
30 (set! (ly:music-property music 'tags)
31 ((if (list? tagname) append cons) tagname (ly:music-property music 'tags)))
32 music)
35 #(defmacro def-grace-function (start stop)
36 `(def-music-function (location music) (ly:music?)
37 (make-music 'GraceMusic
38 'element (make-music 'SequentialMusic
39 'elements (list (ly:music-deep-copy ,start)
40 music
41 (ly:music-deep-copy ,stop))))))
42 grace = #(def-grace-function startGraceMusic stopGraceMusic)
43 acciaccatura = #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic)
44 appoggiatura = #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic)
46 partcombine = #(def-music-function (location part1 part2) (ly:music? ly:music?)
47 (make-part-combine-music (list part1 part2)))
49 autochange = #(def-music-function (location music) (ly:music?)
50 (make-autochange-music music))
52 applycontext = #(def-music-function (location proc) (procedure?)
53 (make-music 'ApplyContext 'procedure proc))
55 applyoutput = #(def-music-function (location proc) (procedure?)
56 (make-music 'ApplyOutputEvent 'procedure proc))
58 breathe = #(def-music-function (location) ()
59 (make-music 'EventChord 'elements (list (make-music 'BreathingSignEvent))))
63 TODO:
65 remove these from the parser, and softcode here:
67 * \tag
69 with small syntax changes, we could also do
71 * \bar
72 * ?