6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 %% this file is alphabetically sorted.
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 #(use-modules (srfi srfi-1))
13 %% FIXME: guile-1.7 required?
14 %#(use-modules (scm display-lily))invalid module name for use-syntax ((srfi srfi-39))
16 #(use-modules (scm display-lily))
17 #(display-lily-init parser)
21 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic)
24 #(define-music-function (parser location name music) (string? ly:music?)
25 "Add a piece of music to be quoted "
26 (add-quotable name music)
27 (make-music 'SequentialMusic 'void #t))
34 #(define-music-function
35 (parser location main grace)
39 ((main-length (ly:music-length main))
40 (fraction (ly:parser-lookup parser 'afterGraceFraction)))
42 (make-simultaneous-music
45 (make-sequential-music
48 (make-music 'SkipMusic
49 'duration (ly:make-duration
51 (* (ly:moment-main-numerator main-length)
53 (* (ly:moment-main-denominator main-length)
55 (make-music 'GraceMusic
59 #(define-music-function (parser location func music) (procedure? ly:music?)
64 #(define-music-function (parser location ctx proc) (symbol? procedure?)
65 (make-music 'ApplyOutputEvent
71 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic)
75 % for regression testing purposes.
77 #(define-music-function (parser location l r) (pair? pair?)
78 (make-grob-property-override 'Beam 'positions
79 (ly:make-simple-closure
80 (ly:make-simple-closure
82 (list chain-grob-member-functions `(,cons 0 0))
83 (check-quant-callbacks l r))))))
85 % for regression testing purposes.
87 #(define-music-function (parser location comp) (procedure?)
88 (make-grob-property-override 'Beam 'positions
89 (ly:make-simple-closure
90 (ly:make-simple-closure
92 (list chain-grob-member-functions `(,cons 0 0))
93 (check-slope-callbacks comp))))))
98 #(define-music-function (parser location music) (ly:music?)
99 (make-autochange-music music))
102 #(define-music-function (parser location proc) (procedure?)
103 (make-music 'ApplyContext
108 #(define-music-function (parser location type)
111 (make-property-set 'whichBar type)
116 #(define-music-function (parser location n) (integer?)
117 (make-music 'ApplyContext
122 ((cbn (ly:context-property c 'currentBarNumber)))
123 (if (and (number? cbn) (not (= cbn n)))
124 (ly:input-message location "Barcheck failed got ~a expect ~a"
130 #(define-music-function (parser location) ()
131 (make-music 'EventChord
133 'elements (list (make-music 'BreathingEvent))))
136 #(define-music-function (parser location delta) (integer?)
138 (make-music 'BendAfterEvent
142 #(define-music-function (parser location type)
145 "Set the current clef."
147 (make-clef-set type))
151 #(define-music-function
152 (parser location fraction music) (number-pair? ly:music?)
153 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
157 #(define-music-function
158 (parser location what dir main-music)
159 (string? ly:dir? ly:music?)
160 (make-music 'QuoteMusic
162 'quoted-context-type 'Voice
163 'quoted-context-id "cue"
164 'quoted-music-name what
165 'quoted-voice-direction dir
170 #(define-music-function (parser location music) (ly:music?)
171 (display-lily-music music)
175 #(define-music-function (parser location music) (ly:music?)
176 (display-scheme-music music)
180 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
182 "Rearrange durations in ARGUMENT so there is an
183 acceleration/deceleration. "
186 ((orig-duration (ly:music-length argument))
187 (multiplier (ly:make-moment 1 1)))
191 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
192 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
194 (ly:music-compress mus multiplier)
195 (set! multiplier (ly:moment-mul factor multiplier)))
202 (ly:moment-div orig-duration (ly:music-length argument)))
207 #(def-grace-function startGraceMusic stopGraceMusic)
210 "instrument-definitions" = #'()
212 addInstrumentDefinition =
213 #(define-music-function
214 (parser location name lst) (string? list?)
216 (set! instrument-definitions (acons name lst instrument-definitions))
218 (make-music 'SequentialMusic 'void #t))
222 #(define-music-function
223 (parser location name) (string?)
225 ((handle (assoc name instrument-definitions))
226 (instrument-def (if handle (cdr handle) '()))
230 (ly:input-message "No such instrument: ~a" name))
232 (make-music 'SimultaneousMusic
243 #(define-music-function
244 (parser location tag music) (symbol? ly:music?)
247 (let* ((tags (ly:music-property m 'tags))
248 (res (memq tag tags)))
257 #(define-music-function
258 (parser location music)
262 (if (string? (ly:music-property mus 'quoted-music-name))
263 (ly:music-property mus 'element)
268 #(define-music-function
269 (parser location arg) (ly:music?)
270 (music-map note-to-cluster arg))
273 #(define-music-function (parser location proc mus) (procedure? ly:music?)
274 (music-map proc mus))
279 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
281 (make-music 'OldLyricCombineMusic
283 'elements (list music lyrics)))
287 #(define-music-function (parser location name property value)
288 (string? symbol? scheme?)
291 "Set @var{property} to @var{value} in all grobs named @var{name}.
292 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
293 or @code{\"GrobName\"}"
296 ((name-components (string-split name #\.))
297 (context-name 'Bottom)
300 (if (> 2 (length name-components))
301 (set! grob-name (string->symbol (car name-components)))
303 (set! grob-name (string->symbol (list-ref name-components 1)))
304 (set! context-name (string->symbol (list-ref name-components 0)))))
306 (make-music 'ApplyOutputEvent
308 'context-type context-name
310 (lambda (grob orig-context context)
312 (cdr (assoc 'name (ly:grob-property grob 'meta)))
314 (set! (ly:grob-property grob property) value))))))
318 #(define-music-function
319 (parser location tag music) (symbol? ly:music?)
322 (let* ((tags (ly:music-property m 'tags))
323 (res (memq tag tags)))
329 %% define-music-function in a .scm causes crash.
332 #(define-music-function (parser location pitch-note) (ly:music?)
335 (make-music 'RelativeOctaveCheck
337 'pitch (pitch-of-note pitch-note)
340 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
341 (make-part-combine-music (list part1 part2)))
345 #(define-music-function
346 (parser location main-note secondary-note)
347 (ly:music? ly:music?)
349 ((get-notes (lambda (ev-chord)
351 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
352 (ly:music-property ev-chord 'elements))))
353 (sec-note-events (get-notes secondary-note))
354 (trill-events (filter (lambda (m) (memq 'trill-span-event (ly:music-property m 'types)))
355 (ly:music-property main-note 'elements)))
358 (if (pair? sec-note-events)
359 (ly:music-property (car sec-note-events) 'pitch)
362 (if (ly:pitch? trill-pitch)
363 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
366 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
367 (display sec-note-events)))
372 #(define-music-function (parser loc arg) (ly:music?)
373 "Tag @var{arg} to be parenthesized."
375 (set! (ly:music-property arg 'parenthesize) #t)
379 #(use-modules (ice-9 optargs))
382 #(define-music-function (parser location voice-ids music) (list? ly:music?)
383 "Define parallel music sequences, separated by '|' (bar check signs),
384 and assign them to the identifiers provided in @var{voice-ids}.
386 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
388 @var{music}: a music sequence, containing BarChecks as limiting expressions.
391 \\parallelMusic #'(A B C) {
400 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
401 (current-voices voices)
402 (current-sequence (list)))
405 (define (push-music m)
406 "Push the music expression into the current sequence"
407 (set! current-sequence (cons m current-sequence)))
408 (define (change-voice)
409 "Stores the previously built sequence into the current voice and
410 change to the following voice."
411 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
412 'elements (reverse! current-sequence))
413 (car current-voices)))
414 (set! current-sequence (list))
415 (set! current-voices (cdr current-voices)))
416 (define (bar-check? m)
417 "Checks whether m is a bar check."
418 (eq? (ly:music-property m 'name) 'BarCheck))
419 (define (music-origin music)
420 "Recursively search an origin location stored in music."
421 (cond ((null? music) #f)
422 ((not (null? (ly:music-property music 'origin)))
423 (ly:music-property music 'origin))
424 (else (or (music-origin (ly:music-property music 'element))
425 (let ((origins (remove not (map music-origin
426 (ly:music-property music 'elements)))))
427 (and (not (null? origins)) (car origins)))))))
429 ;; first, split the music and fill in voices
430 (map-in-order (lambda (m)
432 (if (bar-check? m) (change-voice)))
433 (ly:music-property music 'elements))
434 (if (not (null? current-sequence)) (change-voice))
435 ;; un-circularize `voices' and reorder the voices
436 (set! voices (map-in-order (lambda (dummy seqs)
440 ;; set origin location of each sequence in each voice
441 ;; for better type error tracking
442 (for-each (lambda (voice)
443 (for-each (lambda (seq)
444 (set! (ly:music-property seq 'origin)
445 (or (music-origin seq) location)))
449 ;; check sequence length
450 (apply for-each (lambda* (#:rest seqs)
451 (let ((moment-reference (ly:music-length (car seqs))))
452 (for-each (lambda (seq moment)
453 (if (not (equal? moment moment-reference))
454 (ly:music-message seq
455 "Bars in parallel music don't have the same length")))
456 seqs (map-in-order ly:music-length seqs))))
459 ;; bind voice identifiers to the voices
460 (map (lambda (voice-id voice)
461 (ly:parser-define! parser voice-id
462 (make-music 'SequentialMusic
466 ;; Return an empty sequence. this function is actually a "void" function.
467 (make-music 'SequentialMusic 'void #t))
472 (define-music-function
473 (parser location what main-music)
475 (make-music 'QuoteMusic
477 'quoted-music-name what
482 resetRelativeOctave =
483 #(define-music-function
484 (parser location reference-note)
486 "Set the octave inside a \\relative section."
489 ((notes (ly:music-property reference-note 'elements))
490 (pitch (ly:music-property (car notes) 'pitch)))
492 (set! (ly:music-property reference-note 'elements) '())
493 (set! (ly:music-property reference-note
494 'to-relative-callback)
495 (lambda (music last-pitch)
503 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
509 (shift-one-duration-log x dur dots)) arg))
512 #(define-music-function (parser location parameters) (list?)
513 "Set the system stretch, by reading the 'system-stretch property of
514 the `parameters' assoc list."
516 \overrideProperty #"Score.NonMusicalPaperColumn"
517 #'line-break-system-details
518 #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters))))
521 %% Parser used to read page-layout file, and then retreive score tweaks.
522 #(define page-layout-parser #f)
524 includePageLayoutFile =
525 #(define-music-function (parser location) ()
526 "If page breaks and tweak dump is not asked, and the file
527 <basename>-page-layout.ly exists, include it."
528 (if (not (ly:get-option 'dump-tweaks))
529 (let ((tweak-filename (format #f "~a-page-layout.ly"
530 (ly:parser-output-name parser))))
531 (if (access? tweak-filename R_OK)
533 (ly:message "Including tweak file ~a" tweak-filename)
534 (set! page-layout-parser (ly:clone-parser parser))
535 (ly:parser-parse-string page-layout-parser
536 (format #f "\\include \"~a\""
538 (make-music 'SequentialMusic 'void #t))
542 #(define-music-function (parser location finger) (number-or-string?)
543 "Define a StrokeFingerEvent"
552 (list 'digit finger)))))
555 #(define-music-function (parser location name) (string?)
556 "Include the score tweak, if exists."
557 (if (and page-layout-parser (not (ly:get-option 'dump-tweaks)))
558 (let ((tweak-music (ly:parser-lookup page-layout-parser
559 (string->symbol name))))
560 (if (ly:music? tweak-music)
562 (make-music 'SequentialMusic)))
563 (make-music 'SequentialMusic)))
565 transposedCueDuring =
566 #(define-music-function
567 (parser location what dir pitch-note main-music)
568 (string? ly:dir? ly:music? ly:music?)
570 "Insert notes from the part @var{what} into a voice called @code{cue},
571 using the transposition defined by @var{pitch-note}. This happens
572 simultaneously with @var{main-music}, which is usually a rest. The
573 argument @var{dir} determines whether the cue notes should be notated
574 as a first or second voice."
576 (make-music 'QuoteMusic
578 'quoted-context-type 'Voice
579 'quoted-context-id "cue"
580 'quoted-music-name what
581 'quoted-voice-direction dir
582 'quoted-transposition (pitch-of-note pitch-note)
588 #(define-music-function (parser location pitch-note) (ly:music?)
589 "Set instrument transposition"
592 (make-property-set 'instrumentTransposition
593 (ly:pitch-diff (ly:make-pitch 0 0 0) (pitch-of-note pitch-note)))
597 tweak = #(define-music-function (parser location sym val arg)
598 (symbol? scheme? ly:music?)
600 "Add @code{sym . val} to the @code{tweaks} property of @var{arg}."
604 (ly:music-property arg 'tweaks)
606 (ly:music-property arg 'tweaks)))
609 tag = #(define-music-function (parser location tag arg)
612 "Add @var{tag} to the @code{tags} property of @var{arg}."
615 (ly:music-property arg 'tags)
617 (ly:music-property arg 'tags)))
622 #(define-music-function (parser location music) (ly:music?)
623 (unfold-repeats music))
628 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
629 "Set @var{sym} to @var{val} in @var{music}."
631 (set! (ly:music-property music sym) val)