6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 %% this file is alphabetically sorted.
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 #(use-modules (srfi srfi-1))
15 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic)
18 #(define-music-function (parser location name music) (string? ly:music?)
19 (_i "Add a piece of music to be quoted ")
20 (add-quotable parser name music)
21 (make-music 'SequentialMusic 'void #t))
27 #(define-music-function
28 (parser location main grace)
32 ((main-length (ly:music-length main))
33 (fraction (ly:parser-lookup parser 'afterGraceFraction)))
35 (make-simultaneous-music
38 (make-sequential-music
41 (make-music 'SkipMusic
42 'duration (ly:make-duration
44 (* (ly:moment-main-numerator main-length)
46 (* (ly:moment-main-denominator main-length)
48 (make-music 'GraceMusic
52 #(define-music-function (parser location func music) (procedure? ly:music?)
57 #(define-music-function (parser location ctx proc) (symbol? procedure?)
58 (make-music 'ApplyOutputEvent
64 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic)
68 % for regression testing purposes.
70 #(define-music-function (parser location l r) (pair? pair?)
71 (make-grob-property-override 'Beam 'positions
72 (ly:make-simple-closure
73 (ly:make-simple-closure
75 (list chain-grob-member-functions `(,cons 0 0))
76 (check-quant-callbacks l r))))))
78 % for regression testing purposes.
80 #(define-music-function (parser location comp) (procedure?)
81 (make-grob-property-override 'Beam 'positions
82 (ly:make-simple-closure
83 (ly:make-simple-closure
85 (list chain-grob-member-functions `(,cons 0 0))
86 (check-slope-callbacks comp))))))
91 #(define-music-function (parser location music) (ly:music?)
92 (make-autochange-music parser music))
95 #(define-music-function (parser location proc) (procedure?)
96 (make-music 'ApplyContext
102 #(define-music-function (parser location grob-name offset text) (symbol? number-pair? markup?)
104 (make-music 'AnnotateOutputEvent
106 'X-offset (car offset)
107 'Y-offset (cdr offset)
111 #(define-music-function (parser location offset text) (number-pair? markup?)
113 (make-music 'AnnotateOutputEvent
114 'X-offset (car offset)
115 'Y-offset (cdr offset)
120 #(define-music-function (parser location type)
123 (make-property-set 'whichBar type)
128 #(define-music-function (parser location n) (integer?)
129 (_i "Print a warning if the current bar number is not @var{n}.")
130 (make-music 'ApplyContext
135 ((cbn (ly:context-property c 'currentBarNumber)))
136 (if (and (number? cbn) (not (= cbn n)))
137 (ly:input-message location "Barcheck failed got ~a expect ~a"
142 #(define-music-function (parser location delta) (real?)
143 (_i "Create a fall or doit of pitch interval @var{delta}.")
144 (make-music 'BendAfterEvent
149 #(define-music-function (parser location) ()
150 (_i "Insert a breath mark.")
151 (make-music 'EventChord
153 'elements (list (make-music 'BreathingEvent))))
157 #(define-music-function (parser location type) (string?)
158 (_i "Set the current clef to @var{type}.")
159 (make-clef-set type))
163 #(define-music-function
164 (parser location what dir main-music) (string? ly:dir? ly:music?)
165 (_i "Insert contents of quote @var{what} corresponding to @var{main-music},
166 in a CueVoice oriented by @var{dir}.")
167 (make-music 'QuoteMusic
169 'quoted-context-type 'Voice
170 'quoted-context-id "cue"
171 'quoted-music-name what
172 'quoted-voice-direction dir
176 #(define-music-function (parser location music) (ly:music?)
177 (_i "Display @var{music} to the console in LilyPond input notation.")
179 (display-lily-music music parser)
183 #(define-music-function (parser location music) (ly:music?)
184 (_i "Display the internal representation of @var{music} to the console.")
186 (display-scheme-music music)
191 #(define-music-function (parser location music) (ly:music?)
192 (_i "Terminate the next spanner prematurely after exactly one note without the need of a specific end spanner.")
193 (if (eq? (ly:music-property music 'name) 'EventChord)
195 ((elts (ly:music-property music 'elements))
196 (start-span-evs (filter (lambda (ev)
197 (and (music-has-type ev 'span-event)
198 (equal? (ly:music-property ev 'span-direction)
203 (let* ((c (music-clone m)))
204 (set! (ly:music-property c 'span-direction) STOP)
207 (end-ev-chord (make-music 'EventChord
208 'elements stop-span-evs))
209 (total (make-music 'SequentialMusic
210 'elements (list music
214 (ly:input-message location (_ "argument endSpanners is not an EventChord: ~a" music))))
217 (_i "Adjust durations of @var{music} in @var{argument}. Argument is a fraction
218 (numerator denominator) which controlls acceleration/deceleration. ")
219 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
221 ((orig-duration (ly:music-length argument))
222 (multiplier (ly:make-moment 1 1)))
226 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
227 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
229 (ly:music-compress mus multiplier)
230 (set! multiplier (ly:moment-mul factor multiplier)))
237 (ly:moment-div orig-duration (ly:music-length argument)))
242 (_i "Insert @var{music} as grace notes.")
243 #(def-grace-function startGraceMusic stopGraceMusic)
245 "instrument-definitions" = #'()
247 addInstrumentDefinition =
248 #(define-music-function
249 (parser location name lst) (string? list?)
251 (set! instrument-definitions (acons name lst instrument-definitions))
253 (make-music 'SequentialMusic 'void #t))
257 (_i "Switch instrument to @var{name}, which must be predefined with @var{\addInstrumentDefinition}.")
258 #(define-music-function
259 (parser location name) (string?)
261 ((handle (assoc name instrument-definitions))
262 (instrument-def (if handle (cdr handle) '()))
266 (ly:input-message "No such instrument: ~a" name))
268 (make-music 'SimultaneousMusic
278 %% Parser used to read page-layout file, and then retreive score tweaks.
279 #(define page-layout-parser #f)
281 includePageLayoutFile =
282 (_i "Include the file @var{<basename>-page-layout.ly}.")
283 #(define-music-function (parser location) ()
284 (if (not (ly:get-option 'dump-tweaks))
285 (let ((tweak-filename (format #f "~a-page-layout.ly"
286 (ly:parser-output-name parser))))
287 (if (access? tweak-filename R_OK)
289 (ly:message "Including tweak file ~a" tweak-filename)
290 (set! page-layout-parser (ly:parser-clone parser))
291 (ly:parser-parse-string page-layout-parser
292 (format #f "\\include \"~a\""
294 (make-music 'SequentialMusic 'void #t))
297 (_i "Include only elements of @var{music} that are tagged with @var{tag}.")
298 #(define-music-function
299 (parser location tag music) (symbol? ly:music?)
302 (let* ((tags (ly:music-property m 'tags))
303 (res (memq tag tags)))
310 (_i "Remove elements of @var{music} that are tagged with @var{tag}.")
311 #(define-music-function
312 (parser location tag music) (symbol? ly:music?)
315 (let* ((tags (ly:music-property m 'tags))
316 (res (memq tag tags)))
321 (_i "Remove cue notes from @var{music}.")
322 #(define-music-function
323 (parser location music)
327 (if (string? (ly:music-property mus 'quoted-music-name))
328 (ly:music-property mus 'element)
332 (_i "Create @var{label} as a bookmarking label")
333 #(define-music-function (parser location label) (symbol?)
334 (make-music 'EventChord
337 'elements (list (make-music 'LabelEvent
338 'page-label label))))
341 (_i "Display chords in @var{arg} as clusters")
342 #(define-music-function
343 (parser location arg) (ly:music?)
344 (music-map note-to-cluster arg))
347 #(define-music-function (parser location proc mus) (procedure? ly:music?)
348 (music-map proc mus))
353 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
355 (make-music 'OldLyricCombineMusic
357 'elements (list music lyrics)))
361 #(define-music-function (parser location name property value)
362 (string? symbol? scheme?)
365 (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
366 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
367 or @code{\"GrobName\"}")
370 ((name-components (string-split name #\.))
371 (context-name 'Bottom)
374 (if (> 2 (length name-components))
375 (set! grob-name (string->symbol (car name-components)))
377 (set! grob-name (string->symbol (list-ref name-components 1)))
378 (set! context-name (string->symbol (list-ref name-components 0)))))
380 (make-music 'ApplyOutputEvent
382 'context-type context-name
384 (lambda (grob orig-context context)
386 (cdr (assoc 'name (ly:grob-property grob 'meta)))
388 (set! (ly:grob-property grob property) value))))))
390 %% These are music functions (iso music indentifiers), because music identifiers
391 %% are not allowed at top-level.
393 #(define-music-function (location parser) ()
394 (_i "Force a page break. May be used at toplevel (ie between scores or
395 markups), or inside a score.")
396 (make-music 'EventChord
398 'line-break-permission 'force
399 'page-break-permission 'force
400 'elements (list (make-music 'LineBreakEvent
401 'break-permission 'force)
402 (make-music 'PageBreakEvent
403 'break-permission 'force))))
406 #(define-music-function (location parser) ()
407 (_i "Forbid a page break. May be used at toplevel (ie between scores or
408 markups), or inside a score.")
409 (make-music 'EventChord
411 'page-break-permission 'forbid
412 'elements (list (make-music 'PageBreakEvent
413 'break-permission '()))))
416 #(define-music-function (location parser) ()
417 (_i "Force a page turn between two scores or top-level markups.")
418 (make-music 'EventChord
420 'line-break-permission 'force
421 'page-break-permission 'force
422 'page-turn-permission 'force
423 'elements (list (make-music 'LineBreakEvent
424 'break-permission 'force)
425 (make-music 'PageBreakEvent
426 'break-permission 'force)
427 (make-music 'PageTurnEvent
428 'break-permission 'force))))
431 #(define-music-function (location parser) ()
432 (_i "Forbid a page turn. May be used at toplevel (ie between scores or
433 markups), or inside a score.")
434 (make-music 'EventChord
436 'page-turn-permission 'forbid
437 'elements (list (make-music 'PageTurnEvent
438 'break-permission '()))))
441 #(define-music-function (location parser) ()
442 (_i "Allow a page turn. May be used at toplevel (ie between scores or
443 markups), or inside a score.")
444 (make-music 'EventChord
446 'page-turn-permission 'allow
447 'elements (list (make-music 'PageTurnEvent
448 'break-permission 'allow))))
452 %% define-music-function in a .scm causes crash.
455 #(define-music-function (parser location pitch-note) (ly:music?)
458 (make-music 'RelativeOctaveCheck
460 'pitch (pitch-of-note pitch-note)
463 ottava = #(define-music-function (parser location octave) (number?)
464 (_i "set the octavation ")
465 (make-ottava-set octave))
468 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
469 (make-part-combine-music parser
474 #(define-music-function
475 (parser location main-note secondary-note)
476 (ly:music? ly:music?)
478 ((get-notes (lambda (ev-chord)
480 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
481 (ly:music-property ev-chord 'elements))))
482 (sec-note-events (get-notes secondary-note))
483 (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
484 (ly:music-property main-note 'elements))))
486 (if (pair? sec-note-events)
489 ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
490 (forced (ly:music-property (car sec-note-events ) 'force-accidental)))
492 (if (ly:pitch? trill-pitch)
493 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
496 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
497 (display sec-note-events)))
500 (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced))
507 #(use-modules (ice-9 optargs))
510 #(define-music-function (parser location voice-ids music) (list? ly:music?)
511 (_i "Define parallel music sequences, separated by '|' (bar check signs),
512 and assign them to the identifiers provided in @var{voice-ids}.
514 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
516 @var{music}: a music sequence, containing BarChecks as limiting expressions.
521 \\parallelMusic #'(A B C) {
531 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
532 (current-voices voices)
533 (current-sequence (list)))
536 (define (push-music m)
537 "Push the music expression into the current sequence"
538 (set! current-sequence (cons m current-sequence)))
539 (define (change-voice)
540 "Stores the previously built sequence into the current voice and
541 change to the following voice."
542 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
543 'elements (reverse! current-sequence))
544 (car current-voices)))
545 (set! current-sequence (list))
546 (set! current-voices (cdr current-voices)))
547 (define (bar-check? m)
548 "Checks whether m is a bar check."
549 (eq? (ly:music-property m 'name) 'BarCheck))
550 (define (music-origin music)
551 "Recursively search an origin location stored in music."
552 (cond ((null? music) #f)
553 ((not (null? (ly:music-property music 'origin)))
554 (ly:music-property music 'origin))
555 (else (or (music-origin (ly:music-property music 'element))
556 (let ((origins (remove not (map music-origin
557 (ly:music-property music 'elements)))))
558 (and (not (null? origins)) (car origins)))))))
560 ;; first, split the music and fill in voices
561 (map-in-order (lambda (m)
563 (if (bar-check? m) (change-voice)))
564 (ly:music-property music 'elements))
565 (if (not (null? current-sequence)) (change-voice))
566 ;; un-circularize `voices' and reorder the voices
567 (set! voices (map-in-order (lambda (dummy seqs)
571 ;; set origin location of each sequence in each voice
572 ;; for better type error tracking
573 (for-each (lambda (voice)
574 (for-each (lambda (seq)
575 (set! (ly:music-property seq 'origin)
576 (or (music-origin seq) location)))
580 ;; check sequence length
581 (apply for-each (lambda* (#:rest seqs)
582 (let ((moment-reference (ly:music-length (car seqs))))
583 (for-each (lambda (seq moment)
584 (if (not (equal? moment moment-reference))
585 (ly:music-message seq
586 "Bars in parallel music don't have the same length")))
587 seqs (map-in-order ly:music-length seqs))))
590 ;; bind voice identifiers to the voices
591 (map (lambda (voice-id voice)
592 (ly:parser-define! parser voice-id
593 (make-music 'SequentialMusic
597 ;; Return an empty sequence. this function is actually a "void" function.
598 (make-music 'SequentialMusic 'void #t))
603 #(define-music-function (parser loc arg) (ly:music?)
604 (_i "Tag @var{arg} to be parenthesized.")
606 (if (memq 'event-chord (ly:music-property arg 'types))
607 ; arg is an EventChord -> set the parenthesize property on all child notes and rests
610 (if (or (memq 'note-event (ly:music-property ev 'types))
611 (memq 'rest-event (ly:music-property ev 'types)))
612 (set! (ly:music-property ev 'parenthesize) #t)))
613 (ly:music-property arg 'elements))
614 ; No chord, simply set property for this expression:
615 (set! (ly:music-property arg 'parenthesize) #t))
620 (define-music-function
621 (parser location what main-music)
623 (make-music 'QuoteMusic
625 'quoted-music-name what
630 resetRelativeOctave =
631 #(define-music-function
632 (parser location reference-note)
634 (_i "Set the octave inside a \\relative section.")
637 ((notes (ly:music-property reference-note 'elements))
638 (pitch (ly:music-property (car notes) 'pitch)))
640 (set! (ly:music-property reference-note 'elements) '())
641 (set! (ly:music-property reference-note
642 'to-relative-callback)
643 (lambda (music last-pitch)
650 #(define-music-function
651 (parser location fraction music) (number-pair? ly:music?)
652 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
657 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
662 (shift-one-duration-log x dur dots)) arg))
665 #(define-music-function (parser location parameters) (list?)
666 (_i "Set the system stretch, by reading the 'system-stretch property of
667 the `parameters' assoc list.")
669 \overrideProperty #"Score.NonMusicalPaperColumn"
670 #'line-break-system-details
671 #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
672 (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
677 #(define-music-function (parser location finger) (number-or-string?)
678 (_i "Define a StrokeFingerEvent")
687 (list 'digit finger)))))
690 #(define-music-function (parser location name) (string?)
691 (_i "Include the score tweak, if exists.")
692 (if (and page-layout-parser (not (ly:get-option 'dump-tweaks)))
693 (let ((tweak-music (ly:parser-lookup page-layout-parser
694 (string->symbol name))))
695 (if (ly:music? tweak-music)
697 (make-music 'SequentialMusic)))
698 (make-music 'SequentialMusic)))
701 tag = #(define-music-function (parser location tag arg)
704 (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
707 (ly:music-property arg 'tags)
709 (ly:music-property arg 'tags)))
714 transposedCueDuring =
715 #(define-music-function
716 (parser location what dir pitch-note main-music)
717 (string? ly:dir? ly:music? ly:music?)
719 (_i "Insert notes from the part @var{what} into a voice called @code{cue},
720 using the transposition defined by @var{pitch-note}. This happens
721 simultaneously with @var{main-music}, which is usually a rest. The
722 argument @var{dir} determines whether the cue notes should be notated
723 as a first or second voice.")
725 (make-music 'QuoteMusic
727 'quoted-context-type 'Voice
728 'quoted-context-id "cue"
729 'quoted-music-name what
730 'quoted-voice-direction dir
731 'quoted-transposition (pitch-of-note pitch-note)
737 #(define-music-function (parser location pitch-note) (ly:music?)
738 (_i "Set instrument transposition")
741 (make-property-set 'instrumentTransposition
742 (ly:pitch-negate (pitch-of-note pitch-note)))
745 tweak = #(define-music-function (parser location sym val arg)
746 (symbol? scheme? ly:music?)
748 (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
751 (ly:music-property arg 'tweaks)
753 (ly:music-property arg 'tweaks)))
759 #(define-music-function (parser location music) (ly:music?)
760 (unfold-repeats music))
765 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
766 (_i "Set @var{sym} to @var{val} in @var{music}.")
768 (set! (ly:music-property music sym) val)