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 offset text) (number-pair? markup?)
104 (make-music 'AnnotateOutputEvent
105 'X-offset (car offset)
106 'Y-offset (cdr offset)
110 #(define-music-function (parser location grob-name offset text) (symbol? number-pair? markup?)
112 (make-music 'AnnotateOutputEvent
114 'X-offset (car offset)
115 'Y-offset (cdr offset)
119 #(define-music-function (parser location type)
122 (make-property-set 'whichBar type)
127 #(define-music-function (parser location n) (integer?)
128 (make-music 'ApplyContext
133 ((cbn (ly:context-property c 'currentBarNumber)))
134 (if (and (number? cbn) (not (= cbn n)))
135 (ly:input-message location "Barcheck failed got ~a expect ~a"
141 #(define-music-function (parser location) ()
142 (make-music 'EventChord
144 'elements (list (make-music 'BreathingEvent))))
147 #(define-music-function (parser location delta) (integer?)
149 (make-music 'BendAfterEvent
153 #(define-music-function (parser location type)
155 (_i "Set the current clef.")
157 (make-clef-set type))
161 #(define-music-function
162 (parser location fraction music) (number-pair? ly:music?)
163 (ly:music-compress music (ly:make-moment (car fraction) (cdr fraction))))
167 #(define-music-function
168 (parser location what dir main-music)
169 (string? ly:dir? ly:music?)
170 (make-music 'QuoteMusic
172 'quoted-context-type 'Voice
173 'quoted-context-id "cue"
174 'quoted-music-name what
175 'quoted-voice-direction dir
178 %% The following causes an error with guile 1.6.8 (guile 1.6.7 and 1.8.x are fine)
179 #(use-modules (scm display-lily))
182 #(define-music-function (parser location music) (ly:music?)
184 (display-lily-music music parser)
188 #(define-music-function (parser location music) (ly:music?)
190 (display-scheme-music music)
194 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
195 (_i "Rearrange durations in ARGUMENT so there is an
196 acceleration/deceleration. ")
199 ((orig-duration (ly:music-length argument))
200 (multiplier (ly:make-moment 1 1)))
204 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
205 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
207 (ly:music-compress mus multiplier)
208 (set! multiplier (ly:moment-mul factor multiplier)))
215 (ly:moment-div orig-duration (ly:music-length argument)))
220 #(def-grace-function startGraceMusic stopGraceMusic)
223 "instrument-definitions" = #'()
225 addInstrumentDefinition =
226 #(define-music-function
227 (parser location name lst) (string? list?)
229 (set! instrument-definitions (acons name lst instrument-definitions))
231 (make-music 'SequentialMusic 'void #t))
235 #(define-music-function
236 (parser location name) (string?)
238 ((handle (assoc name instrument-definitions))
239 (instrument-def (if handle (cdr handle) '()))
243 (ly:input-message "No such instrument: ~a" name))
245 (make-music 'SimultaneousMusic
256 #(define-music-function
257 (parser location tag music) (symbol? ly:music?)
260 (let* ((tags (ly:music-property m 'tags))
261 (res (memq tag tags)))
270 #(define-music-function
271 (parser location music)
275 (if (string? (ly:music-property mus 'quoted-music-name))
276 (ly:music-property mus 'element)
281 #(define-music-function
282 (parser location arg) (ly:music?)
283 (music-map note-to-cluster arg))
286 #(define-music-function (parser location proc mus) (procedure? ly:music?)
287 (music-map proc mus))
292 #(define-music-function (parser location music lyrics) (ly:music? ly:music?)
294 (make-music 'OldLyricCombineMusic
296 'elements (list music lyrics)))
300 #(define-music-function (parser location name property value)
301 (string? symbol? scheme?)
304 (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
305 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
306 or @code{\"GrobName\"}")
309 ((name-components (string-split name #\.))
310 (context-name 'Bottom)
313 (if (> 2 (length name-components))
314 (set! grob-name (string->symbol (car name-components)))
316 (set! grob-name (string->symbol (list-ref name-components 1)))
317 (set! context-name (string->symbol (list-ref name-components 0)))))
319 (make-music 'ApplyOutputEvent
321 'context-type context-name
323 (lambda (grob orig-context context)
325 (cdr (assoc 'name (ly:grob-property grob 'meta)))
327 (set! (ly:grob-property grob property) value))))))
331 #(define-music-function
332 (parser location tag music) (symbol? ly:music?)
335 (let* ((tags (ly:music-property m 'tags))
336 (res (memq tag tags)))
342 %% define-music-function in a .scm causes crash.
345 #(define-music-function (parser location pitch-note) (ly:music?)
348 (make-music 'RelativeOctaveCheck
350 'pitch (pitch-of-note pitch-note)
353 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
354 (make-part-combine-music parser
359 #(define-music-function
360 (parser location main-note secondary-note)
361 (ly:music? ly:music?)
363 ((get-notes (lambda (ev-chord)
365 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
366 (ly:music-property ev-chord 'elements))))
367 (sec-note-events (get-notes secondary-note))
368 (trill-events (filter (lambda (m) (memq 'trill-span-event (ly:music-property m 'types)))
369 (ly:music-property main-note 'elements)))
372 (if (pair? sec-note-events)
373 (ly:music-property (car sec-note-events) 'pitch)
376 (if (ly:pitch? trill-pitch)
377 (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
380 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
381 (display sec-note-events)))
386 #(define-music-function (parser loc arg) (ly:music?)
387 (_i "Tag @var{arg} to be parenthesized.")
389 (set! (ly:music-property arg 'parenthesize) #t)
393 #(use-modules (ice-9 optargs))
396 #(define-music-function (parser location voice-ids music) (list? ly:music?)
397 (_i "Define parallel music sequences, separated by '|' (bar check signs),
398 and assign them to the identifiers provided in @var{voice-ids}.
400 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
402 @var{music}: a music sequence, containing BarChecks as limiting expressions.
407 \\parallelMusic #'(A B C) {
417 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
418 (current-voices voices)
419 (current-sequence (list)))
422 (define (push-music m)
423 "Push the music expression into the current sequence"
424 (set! current-sequence (cons m current-sequence)))
425 (define (change-voice)
426 "Stores the previously built sequence into the current voice and
427 change to the following voice."
428 (list-set! current-voices 0 (cons (make-music 'SequentialMusic
429 'elements (reverse! current-sequence))
430 (car current-voices)))
431 (set! current-sequence (list))
432 (set! current-voices (cdr current-voices)))
433 (define (bar-check? m)
434 "Checks whether m is a bar check."
435 (eq? (ly:music-property m 'name) 'BarCheck))
436 (define (music-origin music)
437 "Recursively search an origin location stored in music."
438 (cond ((null? music) #f)
439 ((not (null? (ly:music-property music 'origin)))
440 (ly:music-property music 'origin))
441 (else (or (music-origin (ly:music-property music 'element))
442 (let ((origins (remove not (map music-origin
443 (ly:music-property music 'elements)))))
444 (and (not (null? origins)) (car origins)))))))
446 ;; first, split the music and fill in voices
447 (map-in-order (lambda (m)
449 (if (bar-check? m) (change-voice)))
450 (ly:music-property music 'elements))
451 (if (not (null? current-sequence)) (change-voice))
452 ;; un-circularize `voices' and reorder the voices
453 (set! voices (map-in-order (lambda (dummy seqs)
457 ;; set origin location of each sequence in each voice
458 ;; for better type error tracking
459 (for-each (lambda (voice)
460 (for-each (lambda (seq)
461 (set! (ly:music-property seq 'origin)
462 (or (music-origin seq) location)))
466 ;; check sequence length
467 (apply for-each (lambda* (#:rest seqs)
468 (let ((moment-reference (ly:music-length (car seqs))))
469 (for-each (lambda (seq moment)
470 (if (not (equal? moment moment-reference))
471 (ly:music-message seq
472 "Bars in parallel music don't have the same length")))
473 seqs (map-in-order ly:music-length seqs))))
476 ;; bind voice identifiers to the voices
477 (map (lambda (voice-id voice)
478 (ly:parser-define! parser voice-id
479 (make-music 'SequentialMusic
483 ;; Return an empty sequence. this function is actually a "void" function.
484 (make-music 'SequentialMusic 'void #t))
489 (define-music-function
490 (parser location what main-music)
492 (make-music 'QuoteMusic
494 'quoted-music-name what
499 resetRelativeOctave =
500 #(define-music-function
501 (parser location reference-note)
503 (_i "Set the octave inside a \\relative section.")
506 ((notes (ly:music-property reference-note 'elements))
507 (pitch (ly:music-property (car notes) 'pitch)))
509 (set! (ly:music-property reference-note 'elements) '())
510 (set! (ly:music-property reference-note
511 'to-relative-callback)
512 (lambda (music last-pitch)
520 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
525 (shift-one-duration-log x dur dots)) arg))
528 #(define-music-function (parser location parameters) (list?)
529 (_i "Set the system stretch, by reading the 'system-stretch property of
530 the `parameters' assoc list.")
532 \overrideProperty #"Score.NonMusicalPaperColumn"
533 #'line-break-system-details
534 #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters))))
537 %% Parser used to read page-layout file, and then retreive score tweaks.
538 #(define page-layout-parser #f)
540 includePageLayoutFile =
541 #(define-music-function (parser location) ()
542 (_i "If page breaks and tweak dump is not asked, and the file
543 <basename>-page-layout.ly exists, include it.")
544 (if (not (ly:get-option 'dump-tweaks))
545 (let ((tweak-filename (format #f "~a-page-layout.ly"
546 (ly:parser-output-name parser))))
547 (if (access? tweak-filename R_OK)
549 (ly:message "Including tweak file ~a" tweak-filename)
550 (set! page-layout-parser (ly:parser-clone parser))
551 (ly:parser-parse-string page-layout-parser
552 (format #f "\\include \"~a\""
554 (make-music 'SequentialMusic 'void #t))
558 #(define-music-function (parser location finger) (number-or-string?)
559 (_i "Define a StrokeFingerEvent")
568 (list 'digit finger)))))
571 #(define-music-function (parser location name) (string?)
572 (_i "Include the score tweak, if exists.")
573 (if (and page-layout-parser (not (ly:get-option 'dump-tweaks)))
574 (let ((tweak-music (ly:parser-lookup page-layout-parser
575 (string->symbol name))))
576 (if (ly:music? tweak-music)
578 (make-music 'SequentialMusic)))
579 (make-music 'SequentialMusic)))
581 transposedCueDuring =
582 #(define-music-function
583 (parser location what dir pitch-note main-music)
584 (string? ly:dir? ly:music? ly:music?)
586 (_i "Insert notes from the part @var{what} into a voice called @code{cue},
587 using the transposition defined by @var{pitch-note}. This happens
588 simultaneously with @var{main-music}, which is usually a rest. The
589 argument @var{dir} determines whether the cue notes should be notated
590 as a first or second voice.")
592 (make-music 'QuoteMusic
594 'quoted-context-type 'Voice
595 'quoted-context-id "cue"
596 'quoted-music-name what
597 'quoted-voice-direction dir
598 'quoted-transposition (pitch-of-note pitch-note)
604 #(define-music-function (parser location pitch-note) (ly:music?)
605 (_i "Set instrument transposition")
608 (make-property-set 'instrumentTransposition
609 (ly:pitch-negate (pitch-of-note pitch-note)))
612 tweak = #(define-music-function (parser location sym val arg)
613 (symbol? scheme? ly:music?)
615 (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
618 (ly:music-property arg 'tweaks)
620 (ly:music-property arg 'tweaks)))
623 tag = #(define-music-function (parser location tag arg)
626 (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
629 (ly:music-property arg 'tags)
631 (ly:music-property arg 'tags)))
636 #(define-music-function (parser location music) (ly:music?)
637 (unfold-repeats music))
642 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
643 (_i "Set @var{sym} to @var{val} in @var{music}.")
645 (set! (ly:music-property music sym) val)