7 #(use-modules (srfi srfi-1))
10 tweak = #(define-music-function (parser location sym val arg)
11 (symbol? scheme? ly:music?)
13 "Add @code{sym . val} to the @code{tweaks} property of @var{arg}."
17 (ly:music-property arg 'tweaks)
19 (ly:music-property arg 'tweaks)))
22 tag = #(define-music-function (parser location tag arg)
25 "Add @var{tag} to the @code{tags} property of @var{arg}."
28 (ly:music-property arg 'tags)
30 (ly:music-property arg 'tags)))
34 #(define-music-function (parser location type)
37 "Set the current clef."
42 #(define-music-function (parser location type)
45 (make-property-set 'whichBar type)
49 #(define-music-function (parser location func music) (procedure? ly:music?)
53 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
55 (make-music 'OldLyricCombineMusic
57 'elements (list music lyrics)))
60 #(def-grace-function startGraceMusic stopGraceMusic)
63 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic)
65 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic)
68 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
69 (make-part-combine-music (list part1 part2)))
72 #(define-music-function (parser location music) (ly:music?)
73 (make-autochange-music music))
76 #(define-music-function (parser location proc) (procedure?)
77 (make-music 'ApplyContext
82 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
85 (shift-one-duration-log x dur dots)) arg))
88 #(define-music-function (parser location proc mus) (procedure? ly:music?)
92 #(define-music-function (parser location music) (ly:music?)
93 (display-scheme-music music)
96 %% FIXME: guile-1.7 required?
97 %#(use-modules (scm display-lily))invalid module name for use-syntax ((srfi srfi-39))
99 #(use-modules (scm display-lily))
100 #(display-lily-init parser)
102 #(define-music-function (parser location music) (ly:music?)
103 (display-lily-music music)
107 #(define-music-function (parser location proc) (procedure?)
108 (make-music 'ApplyOutputEvent
113 #(define-music-function (parser location name property value)
114 (string? symbol? scheme?)
117 "Set @var{property} to @var{value} in all grobs named @var{name}.
118 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
119 or @code{\"GrobName\"}"
122 ((name-components (string-split name #\.))
123 (context-name 'Bottom)
126 (if (> 2 (length name-components))
127 (set! grob-name (string->symbol (car name-components)))
129 (set! grob-name (string->symbol (list-ref name-components 1)))
130 (set! context-name (string->symbol (list-ref name-components 0)))))
133 (make-music 'ApplyOutputEvent
136 (lambda (grob orig-context context)
138 (cdr (assoc 'name (ly:grob-property grob 'meta)))
140 (set! (ly:grob-property grob property) value)
146 #(define-music-function (parser location) ()
147 (make-music 'EventChord
149 'elements (list (make-music 'BreathingSignEvent))))
153 #(define-music-function (parser location music) (ly:music?)
154 (unfold-repeats music))
157 #(define-music-function
158 (parser location fraction music) (number-pair? ly:music?)
159 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
162 #(define-music-function
163 (parser location arg) (ly:music?)
164 (music-map note-to-cluster arg))
168 #(define-music-function
169 (parser location tag music) (symbol? ly:music?)
172 (let* ((tags (ly:music-property m 'tags))
173 (res (memq tag tags)))
178 #(define-music-function
179 (parser location tag music) (symbol? ly:music?)
182 (let* ((tags (ly:music-property m 'tags))
183 (res (memq tag tags)))
192 %% define-music-function in a .scm causes crash.
195 #(define-music-function
196 (parser location what dir main-music)
197 (string? ly:dir? ly:music?)
198 (make-music 'QuoteMusic
200 'quoted-context-type 'Voice
201 'quoted-context-id "cue"
202 'quoted-music-name what
203 'quoted-voice-direction dir
208 (define-music-function
209 (parser location what main-music)
211 (make-music 'QuoteMusic
213 'quoted-music-name what
219 #(define-music-function
220 (parser location main-note secondary-note)
221 (ly:music? ly:music?)
223 ((get-notes (lambda (ev-chord)
225 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
226 (ly:music-property ev-chord 'elements))))
227 (sec-note-events (get-notes secondary-note))
228 (trill-events (filter (lambda (m) (memq 'trill-span-event (ly:music-property m 'types)))
229 (ly:music-property main-note 'elements)))
232 (if (pair? sec-note-events)
233 (ly:music-property (car sec-note-events) 'pitch)
236 (if (ly:pitch? trill-pitch)
237 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
240 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
241 (display sec-note-events)))
246 #(define-music-function
247 (parser location music)
251 (if (string? (ly:music-property mus 'quoted-music-name))
252 (ly:music-property mus 'element)
260 #(define-music-function
261 (parser location main grace)
262 (ly:music? ly:music?)
265 ((main-length (ly:music-length main))
266 (fraction (ly:parser-lookup parser 'afterGraceFraction)))
268 (make-simultaneous-music
271 (make-sequential-music
274 (make-music 'SkipMusic
275 'duration (ly:make-duration
277 (* (ly:moment-main-numerator main-length)
279 (* (ly:moment-main-denominator main-length)
281 (make-music 'GraceMusic
282 'element grace)))))))
286 #(define-music-function (parser location n) (integer?)
287 (make-music 'ApplyContext
292 ((cbn (ly:context-property c 'currentBarNumber)))
294 (ly:input-message location "Barcheck failed got ~a expect ~a"
299 % for regression testing purposes.
301 #(define-music-function (parser location l r) (pair? pair?)
302 (make-grob-property-override 'Beam 'positions
303 (ly:make-simple-closure
304 (ly:make-simple-closure
306 (list chain-grob-member-functions `(,cons 0 0))
307 (check-quant-callbacks l r))))))
309 % for regression testing purposes.
311 #(define-music-function (parser location comp) (procedure?)
312 (make-grob-property-override 'Beam 'positions
313 (ly:make-simple-closure
314 (ly:make-simple-closure
316 (list chain-grob-member-functions `(,cons 0 0))
317 (check-slope-callbacks comp))))))
321 #(define-music-function (parser location voice-ids music) (list? ly:music?)
322 "Define parallel music sequences, separated by '|' (bar check signs),
323 and assign them to the identifiers provided in @var{voice-ids}.
325 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
327 @var{music}: a music sequence, containing BarChecks as limiting expressions.
330 \\parallelMusic #'(A B C) {
339 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
340 (current-voices voices)
341 (current-sequence (list)))
344 (define (push-music m)
345 "Push the music expression into the current sequence"
346 (set! current-sequence (cons m current-sequence)))
347 (define (change-voice)
348 "Stores the previously built sequence into the current voice and
349 change to the following voice."
350 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
351 'elements (reverse! current-sequence))
352 (car current-voices)))
353 (set! current-sequence (list))
354 (set! current-voices (cdr current-voices)))
355 (define (bar-check? m)
356 "Checks whether m is a bar check."
357 (eq? (ly:music-property m 'name) 'BarCheck))
358 (define (music-origin music)
359 "Recursively search an origin location stored in music."
360 (cond ((null? music) #f)
361 ((not (null? (ly:music-property music 'origin)))
362 (ly:music-property music 'origin))
363 (else (or (music-origin (ly:music-property music 'element))
364 (let ((origins (remove not (map music-origin
365 (ly:music-property music 'elements)))))
366 (and (not (null? origins)) (car origins)))))))
368 ;; first, split the music and fill in voices
369 (map-in-order (lambda (m)
371 (if (bar-check? m) (change-voice)))
372 (ly:music-property music 'elements))
373 (if (not (null? current-sequence)) (change-voice))
374 ;; un-circularize `voices' and reorder the voices
375 (set! voices (map-in-order (lambda (dummy seqs)
379 ;; set origin location of each sequence in each voice
380 ;; for better type error tracking
381 (for-each (lambda (voice)
382 (for-each (lambda (seq)
383 (set! (ly:music-property seq 'origin)
384 (or (music-origin seq) location)))
388 ;; check sequence length
389 (apply for-each (lambda (. seqs)
390 (let ((moment-reference (ly:music-length (car seqs))))
391 (for-each (lambda (seq moment)
392 (if (not (equal? moment moment-reference))
393 (ly:music-message seq
394 "Bars in parallel music don't have the same length")))
395 seqs (map-in-order ly:music-length seqs))))
398 ;; bind voice identifiers to the voices
399 (map (lambda (voice-id voice)
400 (ly:parser-define! parser voice-id
401 (make-music 'SequentialMusic
405 ;; Return an empty sequence. this function is actually a "void" function.
406 (make-music 'SequentialMusic 'void #t))
411 %% this is a stub. Write your own to suit the spacing tweak output.
413 #(define-music-function (parser location parameters) (list?)
414 (make-music 'SequentialMusic 'void #t))
417 #(define-music-function (parser location pitch-note) (ly:music?)
420 (make-music 'RelativeOctaveCheck
422 'pitch (pitch-of-note pitch-note)
426 #(define-music-function (parser location name music) (string? ly:music?)
427 "Add a piece of music to be quoted "
428 (add-quotable name music)
429 (make-music 'SequentialMusic 'void #t))
433 #(define-music-function (parser loc arg) (ly:music?)
434 "Tag @var{arg} to be parenthesized."
436 (set! (ly:music-property arg 'parenthesize) #t)