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 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
218 (_i "Rearrange durations in ARGUMENT so there is an
219 acceleration/deceleration. ")
222 ((orig-duration (ly:music-length argument))
223 (multiplier (ly:make-moment 1 1)))
227 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
228 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
230 (ly:music-compress mus multiplier)
231 (set! multiplier (ly:moment-mul factor multiplier)))
238 (ly:moment-div orig-duration (ly:music-length argument)))
243 #(def-grace-function startGraceMusic stopGraceMusic)
246 "instrument-definitions" = #'()
248 addInstrumentDefinition =
249 #(define-music-function
250 (parser location name lst) (string? list?)
252 (set! instrument-definitions (acons name lst instrument-definitions))
254 (make-music 'SequentialMusic 'void #t))
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 #(define-music-function (parser location) ()
283 (_i "If page breaks and tweak dump is not asked, and the file
284 <basename>-page-layout.ly exists, include it.")
285 (if (not (ly:get-option 'dump-tweaks))
286 (let ((tweak-filename (format #f "~a-page-layout.ly"
287 (ly:parser-output-name parser))))
288 (if (access? tweak-filename R_OK)
290 (ly:message "Including tweak file ~a" tweak-filename)
291 (set! page-layout-parser (ly:parser-clone parser))
292 (ly:parser-parse-string page-layout-parser
293 (format #f "\\include \"~a\""
295 (make-music 'SequentialMusic 'void #t))
300 #(define-music-function
301 (parser location tag music) (symbol? ly:music?)
304 (let* ((tags (ly:music-property m 'tags))
305 (res (memq tag tags)))
312 #(define-music-function
313 (parser location tag music) (symbol? ly:music?)
316 (let* ((tags (ly:music-property m 'tags))
317 (res (memq tag tags)))
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 #(define-music-function (parser location label) (symbol?)
333 (_i "Place a bookmarking label, either at top-level or inside music.")
334 (make-music 'EventChord
337 'elements (list (make-music 'LabelEvent
338 'page-label label))))
341 #(define-music-function
342 (parser location arg) (ly:music?)
343 (music-map note-to-cluster arg))
346 #(define-music-function (parser location proc mus) (procedure? ly:music?)
347 (music-map proc mus))
352 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
354 (make-music 'OldLyricCombineMusic
356 'elements (list music lyrics)))
360 #(define-music-function (parser location name property value)
361 (string? symbol? scheme?)
364 (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
365 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
366 or @code{\"GrobName\"}")
369 ((name-components (string-split name #\.))
370 (context-name 'Bottom)
373 (if (> 2 (length name-components))
374 (set! grob-name (string->symbol (car name-components)))
376 (set! grob-name (string->symbol (list-ref name-components 1)))
377 (set! context-name (string->symbol (list-ref name-components 0)))))
379 (make-music 'ApplyOutputEvent
381 'context-type context-name
383 (lambda (grob orig-context context)
385 (cdr (assoc 'name (ly:grob-property grob 'meta)))
387 (set! (ly:grob-property grob property) value))))))
389 %% These are music functions (iso music indentifiers), because music identifiers
390 %% are not allowed at top-level.
392 #(define-music-function (location parser) ()
393 (_i "Force a page break. May be used at toplevel (ie between scores or
394 markups), or inside a score.")
395 (make-music 'EventChord
397 'line-break-permission 'force
398 'page-break-permission 'force
399 'elements (list (make-music 'LineBreakEvent
400 'break-permission 'force)
401 (make-music 'PageBreakEvent
402 'break-permission 'force))))
405 #(define-music-function (location parser) ()
406 (_i "Forbid a page break. May be used at toplevel (ie between scores or
407 markups), or inside a score.")
408 (make-music 'EventChord
410 'page-break-permission 'forbid
411 'elements (list (make-music 'PageBreakEvent
412 'break-permission '()))))
415 #(define-music-function (location parser) ()
416 (_i "Force a page turn between two scores or top-level markups.")
417 (make-music 'EventChord
419 'line-break-permission 'force
420 'page-break-permission 'force
421 'page-turn-permission 'force
422 'elements (list (make-music 'LineBreakEvent
423 'break-permission 'force)
424 (make-music 'PageBreakEvent
425 'break-permission 'force)
426 (make-music 'PageTurnEvent
427 'break-permission 'force))))
430 #(define-music-function (location parser) ()
431 (_i "Forbid a page turn. May be used at toplevel (ie between scores or
432 markups), or inside a score.")
433 (make-music 'EventChord
435 'page-turn-permission 'forbid
436 'elements (list (make-music 'PageTurnEvent
437 'break-permission '()))))
440 #(define-music-function (location parser) ()
441 (_i "Allow a page turn. May be used at toplevel (ie between scores or
442 markups), or inside a score.")
443 (make-music 'EventChord
445 'page-turn-permission 'allow
446 'elements (list (make-music 'PageTurnEvent
447 'break-permission 'allow))))
451 %% define-music-function in a .scm causes crash.
454 #(define-music-function (parser location pitch-note) (ly:music?)
457 (make-music 'RelativeOctaveCheck
459 'pitch (pitch-of-note pitch-note)
462 ottava = #(define-music-function (parser location octave) (number?)
463 (_i "set the octavation ")
464 (make-ottava-set octave))
467 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
468 (make-part-combine-music parser
473 #(define-music-function
474 (parser location main-note secondary-note)
475 (ly:music? ly:music?)
477 ((get-notes (lambda (ev-chord)
479 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
480 (ly:music-property ev-chord 'elements))))
481 (sec-note-events (get-notes secondary-note))
482 (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
483 (ly:music-property main-note 'elements))))
485 (if (pair? sec-note-events)
488 ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
489 (forced (ly:music-property (car sec-note-events ) 'force-accidental)))
491 (if (ly:pitch? trill-pitch)
492 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
495 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
496 (display sec-note-events)))
499 (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced))
506 #(use-modules (ice-9 optargs))
509 #(define-music-function (parser location voice-ids music) (list? ly:music?)
510 (_i "Define parallel music sequences, separated by '|' (bar check signs),
511 and assign them to the identifiers provided in @var{voice-ids}.
513 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
515 @var{music}: a music sequence, containing BarChecks as limiting expressions.
520 \\parallelMusic #'(A B C) {
530 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
531 (current-voices voices)
532 (current-sequence (list)))
535 (define (push-music m)
536 "Push the music expression into the current sequence"
537 (set! current-sequence (cons m current-sequence)))
538 (define (change-voice)
539 "Stores the previously built sequence into the current voice and
540 change to the following voice."
541 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
542 'elements (reverse! current-sequence))
543 (car current-voices)))
544 (set! current-sequence (list))
545 (set! current-voices (cdr current-voices)))
546 (define (bar-check? m)
547 "Checks whether m is a bar check."
548 (eq? (ly:music-property m 'name) 'BarCheck))
549 (define (music-origin music)
550 "Recursively search an origin location stored in music."
551 (cond ((null? music) #f)
552 ((not (null? (ly:music-property music 'origin)))
553 (ly:music-property music 'origin))
554 (else (or (music-origin (ly:music-property music 'element))
555 (let ((origins (remove not (map music-origin
556 (ly:music-property music 'elements)))))
557 (and (not (null? origins)) (car origins)))))))
559 ;; first, split the music and fill in voices
560 (map-in-order (lambda (m)
562 (if (bar-check? m) (change-voice)))
563 (ly:music-property music 'elements))
564 (if (not (null? current-sequence)) (change-voice))
565 ;; un-circularize `voices' and reorder the voices
566 (set! voices (map-in-order (lambda (dummy seqs)
570 ;; set origin location of each sequence in each voice
571 ;; for better type error tracking
572 (for-each (lambda (voice)
573 (for-each (lambda (seq)
574 (set! (ly:music-property seq 'origin)
575 (or (music-origin seq) location)))
579 ;; check sequence length
580 (apply for-each (lambda* (#:rest seqs)
581 (let ((moment-reference (ly:music-length (car seqs))))
582 (for-each (lambda (seq moment)
583 (if (not (equal? moment moment-reference))
584 (ly:music-message seq
585 "Bars in parallel music don't have the same length")))
586 seqs (map-in-order ly:music-length seqs))))
589 ;; bind voice identifiers to the voices
590 (map (lambda (voice-id voice)
591 (ly:parser-define! parser voice-id
592 (make-music 'SequentialMusic
596 ;; Return an empty sequence. this function is actually a "void" function.
597 (make-music 'SequentialMusic 'void #t))
602 #(define-music-function (parser loc arg) (ly:music?)
603 (_i "Tag @var{arg} to be parenthesized.")
605 (if (memq 'event-chord (ly:music-property arg 'types))
606 ; arg is an EventChord -> set the parenthesize property on all child notes and rests
609 (if (or (memq 'note-event (ly:music-property ev 'types))
610 (memq 'rest-event (ly:music-property ev 'types)))
611 (set! (ly:music-property ev 'parenthesize) #t)))
612 (ly:music-property arg 'elements))
613 ; No chord, simply set property for this expression:
614 (set! (ly:music-property arg 'parenthesize) #t))
619 (define-music-function
620 (parser location what main-music)
622 (make-music 'QuoteMusic
624 'quoted-music-name what
629 resetRelativeOctave =
630 #(define-music-function
631 (parser location reference-note)
633 (_i "Set the octave inside a \\relative section.")
636 ((notes (ly:music-property reference-note 'elements))
637 (pitch (ly:music-property (car notes) 'pitch)))
639 (set! (ly:music-property reference-note 'elements) '())
640 (set! (ly:music-property reference-note
641 'to-relative-callback)
642 (lambda (music last-pitch)
649 #(define-music-function
650 (parser location fraction music) (number-pair? ly:music?)
651 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
656 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
661 (shift-one-duration-log x dur dots)) arg))
664 #(define-music-function (parser location parameters) (list?)
665 (_i "Set the system stretch, by reading the 'system-stretch property of
666 the `parameters' assoc list.")
668 \overrideProperty #"Score.NonMusicalPaperColumn"
669 #'line-break-system-details
670 #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
671 (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
676 #(define-music-function (parser location finger) (number-or-string?)
677 (_i "Define a StrokeFingerEvent")
686 (list 'digit finger)))))
689 #(define-music-function (parser location name) (string?)
690 (_i "Include the score tweak, if exists.")
691 (if (and page-layout-parser (not (ly:get-option 'dump-tweaks)))
692 (let ((tweak-music (ly:parser-lookup page-layout-parser
693 (string->symbol name))))
694 (if (ly:music? tweak-music)
696 (make-music 'SequentialMusic)))
697 (make-music 'SequentialMusic)))
700 tag = #(define-music-function (parser location tag arg)
703 (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
706 (ly:music-property arg 'tags)
708 (ly:music-property arg 'tags)))
713 transposedCueDuring =
714 #(define-music-function
715 (parser location what dir pitch-note main-music)
716 (string? ly:dir? ly:music? ly:music?)
718 (_i "Insert notes from the part @var{what} into a voice called @code{cue},
719 using the transposition defined by @var{pitch-note}. This happens
720 simultaneously with @var{main-music}, which is usually a rest. The
721 argument @var{dir} determines whether the cue notes should be notated
722 as a first or second voice.")
724 (make-music 'QuoteMusic
726 'quoted-context-type 'Voice
727 'quoted-context-id "cue"
728 'quoted-music-name what
729 'quoted-voice-direction dir
730 'quoted-transposition (pitch-of-note pitch-note)
736 #(define-music-function (parser location pitch-note) (ly:music?)
737 (_i "Set instrument transposition")
740 (make-property-set 'instrumentTransposition
741 (ly:pitch-negate (pitch-of-note pitch-note)))
744 tweak = #(define-music-function (parser location sym val arg)
745 (symbol? scheme? ly:music?)
747 (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
750 (ly:music-property arg 'tweaks)
752 (ly:music-property arg 'tweaks)))
758 #(define-music-function (parser location music) (ly:music?)
759 (unfold-repeats music))
764 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
765 (_i "Set @var{sym} to @var{val} in @var{music}.")
767 (set! (ly:music-property music sym) val)