7 #(use-modules (srfi srfi-1))
8 %% FIXME: guile-1.7 required?
9 %#(use-modules (scm display-lily))invalid module name for use-syntax ((srfi srfi-39))
11 #(use-modules (scm display-lily))
12 #(display-lily-init parser)
16 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic)
19 #(define-music-function (parser location name music) (string? ly:music?)
20 "Add a piece of music to be quoted "
21 (add-quotable name music)
22 (make-music 'SequentialMusic 'void #t))
29 #(define-music-function
30 (parser location main grace)
34 ((main-length (ly:music-length main))
35 (fraction (ly:parser-lookup parser 'afterGraceFraction)))
37 (make-simultaneous-music
40 (make-sequential-music
43 (make-music 'SkipMusic
44 'duration (ly:make-duration
46 (* (ly:moment-main-numerator main-length)
48 (* (ly:moment-main-denominator main-length)
50 (make-music 'GraceMusic
54 #(define-music-function (parser location func music) (procedure? ly:music?)
59 #(define-music-function (parser location ctx proc) (symbol? procedure?)
60 (make-music 'ApplyOutputEvent
66 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic)
70 % for regression testing purposes.
72 #(define-music-function (parser location l r) (pair? pair?)
73 (make-grob-property-override 'Beam 'positions
74 (ly:make-simple-closure
75 (ly:make-simple-closure
77 (list chain-grob-member-functions `(,cons 0 0))
78 (check-quant-callbacks l r))))))
80 % for regression testing purposes.
82 #(define-music-function (parser location comp) (procedure?)
83 (make-grob-property-override 'Beam 'positions
84 (ly:make-simple-closure
85 (ly:make-simple-closure
87 (list chain-grob-member-functions `(,cons 0 0))
88 (check-slope-callbacks comp))))))
93 #(define-music-function (parser location music) (ly:music?)
94 (make-autochange-music music))
97 #(define-music-function (parser location proc) (procedure?)
98 (make-music 'ApplyContext
103 #(define-music-function (parser location type)
106 (make-property-set 'whichBar type)
111 #(define-music-function (parser location n) (integer?)
112 (make-music 'ApplyContext
117 ((cbn (ly:context-property c 'currentBarNumber)))
119 (ly:input-message location "Barcheck failed got ~a expect ~a"
125 #(define-music-function (parser location) ()
126 (make-music 'EventChord
128 'elements (list (make-music 'BreathingSignEvent))))
131 #(define-music-function (parser location delta) (integer?)
133 (make-music 'BendAfterEvent
137 #(define-music-function (parser location type)
140 "Set the current clef."
142 (make-clef-set type))
146 #(define-music-function
147 (parser location fraction music) (number-pair? ly:music?)
148 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
152 #(define-music-function
153 (parser location what dir main-music)
154 (string? ly:dir? ly:music?)
155 (make-music 'QuoteMusic
157 'quoted-context-type 'Voice
158 'quoted-context-id "cue"
159 'quoted-music-name what
160 'quoted-voice-direction dir
165 #(define-music-function (parser location music) (ly:music?)
166 (display-lily-music music)
170 #(define-music-function (parser location music) (ly:music?)
171 (display-scheme-music music)
175 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
177 "Rearrange durations in ARGUMENT so there is an
178 acceleration/deceleration. "
181 ((orig-duration (ly:music-length argument))
182 (multiplier (ly:make-moment 1 1)))
186 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
187 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
189 (ly:music-compress mus multiplier)
190 (set! multiplier (ly:moment-mul factor multiplier)))
197 (ly:moment-div orig-duration (ly:music-length argument)))
202 #(def-grace-function startGraceMusic stopGraceMusic)
205 #(define-music-function
206 (parser location tag music) (symbol? ly:music?)
209 (let* ((tags (ly:music-property m 'tags))
210 (res (memq tag tags)))
219 #(define-music-function
220 (parser location music)
224 (if (string? (ly:music-property mus 'quoted-music-name))
225 (ly:music-property mus 'element)
230 #(define-music-function
231 (parser location arg) (ly:music?)
232 (music-map note-to-cluster arg))
235 #(define-music-function (parser location proc mus) (procedure? ly:music?)
236 (music-map proc mus))
241 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
243 (make-music 'OldLyricCombineMusic
245 'elements (list music lyrics)))
249 #(define-music-function (parser location name property value)
250 (string? symbol? scheme?)
253 "Set @var{property} to @var{value} in all grobs named @var{name}.
254 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
255 or @code{\"GrobName\"}"
258 ((name-components (string-split name #\.))
259 (context-name 'Bottom)
262 (if (> 2 (length name-components))
263 (set! grob-name (string->symbol (car name-components)))
265 (set! grob-name (string->symbol (list-ref name-components 1)))
266 (set! context-name (string->symbol (list-ref name-components 0)))))
268 (make-music 'ApplyOutputEvent
270 'context-type context-name
272 (lambda (grob orig-context context)
274 (cdr (assoc 'name (ly:grob-property grob 'meta)))
276 (set! (ly:grob-property grob property) value))))))
280 #(define-music-function
281 (parser location tag music) (symbol? ly:music?)
284 (let* ((tags (ly:music-property m 'tags))
285 (res (memq tag tags)))
291 %% define-music-function in a .scm causes crash.
295 #(define-music-function (parser location pitch-note) (ly:music?)
298 (make-music 'RelativeOctaveCheck
300 'pitch (pitch-of-note pitch-note)
303 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
304 (make-part-combine-music (list part1 part2)))
308 #(define-music-function
309 (parser location main-note secondary-note)
310 (ly:music? ly:music?)
312 ((get-notes (lambda (ev-chord)
314 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
315 (ly:music-property ev-chord 'elements))))
316 (sec-note-events (get-notes secondary-note))
317 (trill-events (filter (lambda (m) (memq 'trill-span-event (ly:music-property m 'types)))
318 (ly:music-property main-note 'elements)))
321 (if (pair? sec-note-events)
322 (ly:music-property (car sec-note-events) 'pitch)
325 (if (ly:pitch? trill-pitch)
326 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
329 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
330 (display sec-note-events)))
340 #(define-music-function (parser loc arg) (ly:music?)
341 "Tag @var{arg} to be parenthesized."
343 (set! (ly:music-property arg 'parenthesize) #t)
347 #(define-music-function (parser location voice-ids music) (list? ly:music?)
348 "Define parallel music sequences, separated by '|' (bar check signs),
349 and assign them to the identifiers provided in @var{voice-ids}.
351 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
353 @var{music}: a music sequence, containing BarChecks as limiting expressions.
356 \\parallelMusic #'(A B C) {
365 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
366 (current-voices voices)
367 (current-sequence (list)))
370 (define (push-music m)
371 "Push the music expression into the current sequence"
372 (set! current-sequence (cons m current-sequence)))
373 (define (change-voice)
374 "Stores the previously built sequence into the current voice and
375 change to the following voice."
376 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
377 'elements (reverse! current-sequence))
378 (car current-voices)))
379 (set! current-sequence (list))
380 (set! current-voices (cdr current-voices)))
381 (define (bar-check? m)
382 "Checks whether m is a bar check."
383 (eq? (ly:music-property m 'name) 'BarCheck))
384 (define (music-origin music)
385 "Recursively search an origin location stored in music."
386 (cond ((null? music) #f)
387 ((not (null? (ly:music-property music 'origin)))
388 (ly:music-property music 'origin))
389 (else (or (music-origin (ly:music-property music 'element))
390 (let ((origins (remove not (map music-origin
391 (ly:music-property music 'elements)))))
392 (and (not (null? origins)) (car origins)))))))
394 ;; first, split the music and fill in voices
395 (map-in-order (lambda (m)
397 (if (bar-check? m) (change-voice)))
398 (ly:music-property music 'elements))
399 (if (not (null? current-sequence)) (change-voice))
400 ;; un-circularize `voices' and reorder the voices
401 (set! voices (map-in-order (lambda (dummy seqs)
405 ;; set origin location of each sequence in each voice
406 ;; for better type error tracking
407 (for-each (lambda (voice)
408 (for-each (lambda (seq)
409 (set! (ly:music-property seq 'origin)
410 (or (music-origin seq) location)))
414 ;; check sequence length
415 (apply for-each (lambda (. seqs)
416 (let ((moment-reference (ly:music-length (car seqs))))
417 (for-each (lambda (seq moment)
418 (if (not (equal? moment moment-reference))
419 (ly:music-message seq
420 "Bars in parallel music don't have the same length")))
421 seqs (map-in-order ly:music-length seqs))))
424 ;; bind voice identifiers to the voices
425 (map (lambda (voice-id voice)
426 (ly:parser-define! parser voice-id
427 (make-music 'SequentialMusic
431 ;; Return an empty sequence. this function is actually a "void" function.
432 (make-music 'SequentialMusic 'void #t))
437 (define-music-function
438 (parser location what main-music)
440 (make-music 'QuoteMusic
442 'quoted-music-name what
447 resetRelativeOctave =
448 #(define-music-function
449 (parser location reference-note)
451 "Set the octave inside a \\relative section."
454 ((notes (ly:music-property reference-note 'elements))
455 (pitch (ly:music-property (car notes) 'pitch)))
457 (set! (ly:music-property reference-note 'elements) '())
458 (set! (ly:music-property reference-note
459 'to-relative-callback)
460 (lambda (music last-pitch)
468 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
474 (shift-one-duration-log x dur dots)) arg))
477 %% this is a stub. Write your own to suit the spacing tweak output.
479 #(define-music-function (parser location parameters) (list?)
480 (make-music 'SequentialMusic 'void #t))
483 transposedCueDuring = #
484 (define-music-function
485 (parser location what dir pitch-note main-music)
486 (string? ly:dir? ly:music? ly:music?)
488 "Insert notes from the part @var{what} into a voice called @code{cue},
489 using the transposition defined by @var{pitch-note}. This happens
490 simultaneously with @var{main-music}, which is usually a rest. The
491 argument @var{dir} determines whether the cue notes should be notated
492 as a first or second voice."
494 (make-music 'QuoteMusic
496 'quoted-context-type 'Voice
497 'quoted-context-id "cue"
498 'quoted-music-name what
499 'quoted-voice-direction dir
500 'quoted-transposition (pitch-of-note pitch-note)
507 tweak = #(define-music-function (parser location sym val arg)
508 (symbol? scheme? ly:music?)
510 "Add @code{sym . val} to the @code{tweaks} property of @var{arg}."
514 (ly:music-property arg 'tweaks)
516 (ly:music-property arg 'tweaks)))
519 tag = #(define-music-function (parser location tag arg)
522 "Add @var{tag} to the @code{tags} property of @var{arg}."
525 (ly:music-property arg 'tags)
527 (ly:music-property arg 'tags)))
532 #(define-music-function (parser location music) (ly:music?)
533 (unfold-repeats music))