LSR: Update.
[lilypond/mpolesky.git] / ly / music-functions-init.ly
blobd3d14e7f379b379b93e3bc5b0d26b21d656ccd85
1 %%%% This file is part of LilyPond, the GNU music typesetter.
2 %%%%
3 %%%% Copyright (C) 2003--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 %%%% Jan Nieuwenhuizen <janneke@gnu.org>
5 %%%%
6 %%%% LilyPond is free software: you can redistribute it and/or modify
7 %%%% it under the terms of the GNU General Public License as published by
8 %%%% the Free Software Foundation, either version 3 of the License, or
9 %%%% (at your option) any later version.
10 %%%%
11 %%%% LilyPond is distributed in the hope that it will be useful,
12 %%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
13 %%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 %%%% GNU General Public License for more details.
15 %%%%
16 %%%% You should have received a copy of the GNU General Public License
17 %%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 % -*-Scheme-*-
21 \version "2.12.0"
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 %% this file is alphabetically sorted.
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 %% need SRFI-1 for filter; optargs for lambda*
29 #(use-modules (srfi srfi-1)
30 (ice-9 optargs))
32 %% TODO: using define-music-function in a .scm causes crash.
34 acciaccatura =
35 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic
36 (_i "Create an acciaccatura from the following music expression"))
38 %% keep these two together
39 "instrument-definitions" = #'()
40 addInstrumentDefinition =
41 #(define-music-function
42 (parser location name lst) (string? list?)
43 (_i "Create instrument @var{name} with properties @var{list}.")
44 (set! instrument-definitions (acons name lst instrument-definitions))
45 (make-music 'SequentialMusic 'void #t))
47 addQuote =
48 #(define-music-function (parser location name music) (string? ly:music?)
49 (_i "Define @var{music} as a quotable music expression named
50 @var{name}")
51 (add-quotable parser name music)
52 (make-music 'SequentialMusic 'void #t))
54 %% keep these two together
55 afterGraceFraction = #(cons 6 8)
56 afterGrace =
57 #(define-music-function
58 (parser location main grace)
59 (ly:music? ly:music?)
60 (_i "Create @var{grace} note(s) after a @var{main} music expression.")
61 (let*
62 ((main-length (ly:music-length main))
63 (fraction (ly:parser-lookup parser 'afterGraceFraction)))
65 (make-simultaneous-music
66 (list
67 main
68 (make-sequential-music
69 (list
71 (make-music 'SkipMusic
72 'duration (ly:make-duration
73 0 0
74 (* (ly:moment-main-numerator main-length)
75 (car fraction))
76 (* (ly:moment-main-denominator main-length)
77 (cdr fraction)) ))
78 (make-music 'GraceMusic
79 'element grace)))))))
82 %% music identifiers not allowed at top-level,
83 %% so this is a music-function instead.
84 allowPageTurn =
85 #(define-music-function (location parser) ()
86 (_i "Allow a page turn. May be used at toplevel (ie between scores or
87 markups), or inside a score.")
88 (make-music 'EventChord
89 'page-marker #t
90 'page-turn-permission 'allow
91 'elements (list (make-music 'PageTurnEvent
92 'break-permission 'allow))))
94 applyContext =
95 #(define-music-function (parser location proc) (procedure?)
96 (_i "Modify context properties with Scheme procedure @var{proc}.")
97 (make-music 'ApplyContext
98 'origin location
99 'procedure proc))
101 applyMusic =
102 #(define-music-function (parser location func music) (procedure? ly:music?)
103 (_i"Apply procedure @var{func} to @var{music}.")
104 (func music))
106 applyOutput =
107 #(define-music-function (parser location ctx proc) (symbol? procedure?)
108 (_i "Apply function @code{proc} to every layout object in context @code{ctx}")
109 (make-music 'ApplyOutputEvent
110 'origin location
111 'procedure proc
112 'context-type ctx))
114 appoggiatura =
115 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic
116 (_i "Create an appoggiatura from @var{music}"))
118 % for regression testing purposes.
119 assertBeamQuant =
120 #(define-music-function (parser location l r) (pair? pair?)
121 (_i "Testing function: check whether the beam quants @var{l} and @var{r} are correct")
122 (make-grob-property-override 'Beam 'positions
123 (ly:make-simple-closure
124 (ly:make-simple-closure
125 (append
126 (list chain-grob-member-functions `(,cons 0 0))
127 (check-quant-callbacks l r))))))
129 % for regression testing purposes.
130 assertBeamSlope =
131 #(define-music-function (parser location comp) (procedure?)
132 (_i "Testing function: check whether the slope of the beam is the same as @code{comp}")
133 (make-grob-property-override 'Beam 'positions
134 (ly:make-simple-closure
135 (ly:make-simple-closure
136 (append
137 (list chain-grob-member-functions `(,cons 0 0))
138 (check-slope-callbacks comp))))))
140 autochange =
141 #(define-music-function (parser location music) (ly:music?)
142 (_i "Make voices that switch between staves automatically")
143 (make-autochange-music parser music))
147 balloonGrobText =
148 #(define-music-function (parser location grob-name offset text)
149 (symbol? number-pair? markup?)
150 (_i "Attach @var{text} to @var{grob-name} at offset @var{offset}
151 use like @code{\\once})")
152 (make-music 'AnnotateOutputEvent
153 'symbol grob-name
154 'X-offset (car offset)
155 'Y-offset (cdr offset)
156 'text text))
158 balloonText =
159 #(define-music-function (parser location offset text) (number-pair? markup?)
160 (_i "Attach @var{text} at @var{offset} (use like @code{\\tweak})")
161 (make-music 'AnnotateOutputEvent
162 'X-offset (car offset)
163 'Y-offset (cdr offset)
164 'text text))
166 bar =
167 #(define-music-function (parser location type) (string?)
168 (_i "Insert a bar line of type @var{type}")
169 (context-spec-music
170 (make-property-set 'whichBar type)
171 'Timing))
173 barNumberCheck =
174 #(define-music-function (parser location n) (integer?)
175 (_i "Print a warning if the current bar number is not @var{n}.")
176 (make-music 'ApplyContext
177 'origin location
178 'procedure
179 (lambda (c)
180 (let*
181 ((cbn (ly:context-property c 'currentBarNumber)))
182 (if (and (number? cbn) (not (= cbn n)))
183 (ly:input-message location "Barcheck failed got ~a expect ~a"
184 cbn n))))))
186 bendAfter =
187 #(define-music-function (parser location delta) (real?)
188 (_i "Create a fall or doit of pitch interval @var{delta}.")
189 (make-music 'BendAfterEvent
190 'delta-step delta))
192 bookOutputName =
193 #(define-music-function (parser location newfilename) (string?)
194 (_i "Direct output for the current book block to @var{newfilename}.")
195 (set! book-filename newfilename)
196 (make-music 'SequentialMusic 'void #t))
198 bookOutputSuffix =
199 #(define-music-function (parser location newsuffix) (string?)
200 (_i "Set the output filename suffix for the current book block to
201 @var{newsuffix}.")
202 (set! book-output-suffix newsuffix)
203 (make-music 'SequentialMusic 'void #t))
205 %% why a function?
206 breathe =
207 #(define-music-function (parser location) ()
208 (_i "Insert a breath mark.")
209 (make-music 'EventChord
210 'origin location
211 'elements (list (make-music 'BreathingEvent))))
215 clef =
216 #(define-music-function (parser location type) (string?)
217 (_i "Set the current clef to @var{type}.")
218 (make-clef-set type))
220 cueDuring =
221 #(define-music-function
222 (parser location what dir main-music) (string? ly:dir? ly:music?)
223 (_i "Insert contents of quote @var{what} corresponding to @var{main-music},
224 in a CueVoice oriented by @var{dir}.")
225 (make-music 'QuoteMusic
226 'element main-music
227 'quoted-context-type 'Voice
228 'quoted-context-id "cue"
229 'quoted-music-name what
230 'quoted-voice-direction dir
231 'origin location))
235 displayLilyMusic =
236 #(define-music-function (parser location music) (ly:music?)
237 (_i "Display the LilyPond input representation of @var{music}
238 to the console.")
239 (newline)
240 (display-lily-music music parser)
241 music)
243 displayMusic =
244 #(define-music-function (parser location music) (ly:music?)
245 (_i "Display the internal representation of @var{music} to the console.")
246 (newline)
247 (display-scheme-music music)
248 music)
252 endSpanners =
253 #(define-music-function (parser location music) (ly:music?)
254 (_i "Terminate the next spanner prematurely after exactly one note without the need of a specific end spanner.")
255 (if (eq? (ly:music-property music 'name) 'EventChord)
256 (let*
257 ((elts (ly:music-property music 'elements))
258 (start-span-evs (filter (lambda (ev)
259 (and (music-has-type ev 'span-event)
260 (equal? (ly:music-property ev 'span-direction)
261 START)))
262 elts))
263 (stop-span-evs
264 (map (lambda (m)
265 (let* ((c (music-clone m)))
266 (set! (ly:music-property c 'span-direction) STOP)
268 start-span-evs))
269 (end-ev-chord (make-music 'EventChord
270 'elements stop-span-evs))
271 (total (make-music 'SequentialMusic
272 'elements (list music
273 end-ev-chord))))
274 total)
276 (ly:input-message location (_ "argument endSpanners is not an EventChord: ~a" music))))
280 featherDurations=
281 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
282 (_i "Adjust durations of music in @var{argument} by rational @var{factor}. ")
283 (let*
284 ((orig-duration (ly:music-length argument))
285 (multiplier (ly:make-moment 1 1)))
287 (music-map
288 (lambda (mus)
289 (if (and (eq? (ly:music-property mus 'name) 'EventChord)
290 (< 0 (ly:moment-main-denominator (ly:music-length mus))))
291 (begin
292 (ly:music-compress mus multiplier)
293 (set! multiplier (ly:moment-mul factor multiplier)))
295 mus)
296 argument)
298 (ly:music-compress
299 argument
300 (ly:moment-div orig-duration (ly:music-length argument)))
302 argument))
306 grace =
307 #(def-grace-function startGraceMusic stopGraceMusic
308 (_i "Insert @var{music} as grace notes."))
312 instrumentSwitch =
313 #(define-music-function
314 (parser location name) (string?)
315 (_i "Switch instrument to @var{name}, which must be predefined with
316 @code{\\addInstrumentDefinition}.")
317 (let*
318 ((handle (assoc name instrument-definitions))
319 (instrument-def (if handle (cdr handle) '()))
322 (if (not handle)
323 (ly:input-message location "No such instrument: ~a" name))
324 (context-spec-music
325 (make-music 'SimultaneousMusic
326 'elements
327 (map (lambda (kv)
328 (make-property-set
329 (car kv)
330 (cdr kv)))
331 instrument-def))
332 'Staff)))
336 keepWithTag =
337 #(define-music-function
338 (parser location tag music) (symbol? ly:music?)
339 (_i "Include only elements of @var{music} that are tagged with @var{tag}.")
340 (music-filter
341 (lambda (m)
342 (let* ((tags (ly:music-property m 'tags))
343 (res (memq tag tags)))
345 (eq? tags '())
346 res)))
347 music))
349 killCues =
350 #(define-music-function
351 (parser location music)
352 (ly:music?)
353 (_i "Remove cue notes from @var{music}.")
354 (music-map
355 (lambda (mus)
356 (if (and (string? (ly:music-property mus 'quoted-music-name))
357 (string=? (ly:music-property mus 'quoted-context-id "") "cue"))
358 (ly:music-property mus 'element)
359 mus)) music))
363 label =
364 #(define-music-function (parser location label) (symbol?)
365 (_i "Create @var{label} as a bookmarking label")
366 (make-music 'EventChord
367 'page-marker #t
368 'page-label label
369 'elements (list (make-music 'LabelEvent
370 'page-label label))))
374 makeClusters =
375 #(define-music-function
376 (parser location arg) (ly:music?)
377 (_i "Display chords in @var{arg} as clusters")
378 (music-map note-to-cluster arg))
380 musicMap =
381 #(define-music-function (parser location proc mus) (procedure? ly:music?)
382 (music-map proc mus))
386 %% noPageBreak and noPageTurn are music functions (not music indentifiers),
387 %% because music identifiers are not allowed at top-level.
388 noPageBreak =
389 #(define-music-function (location parser) ()
390 (_i "Forbid a page break. May be used at toplevel (ie between scores or
391 markups), or inside a score.")
392 (make-music 'EventChord
393 'page-marker #t
394 'page-break-permission 'forbid
395 'elements (list (make-music 'PageBreakEvent
396 'break-permission '()))))
398 noPageTurn =
399 #(define-music-function (location parser) ()
400 (_i "Forbid a page turn. May be used at toplevel (ie between scores or
401 markups), or inside a score.")
402 (make-music 'EventChord
403 'page-marker #t
404 'page-turn-permission 'forbid
405 'elements (list (make-music 'PageTurnEvent
406 'break-permission '()))))
410 octaveCheck =
411 #(define-music-function (parser location pitch-note) (ly:music?)
412 (_i "octave check")
414 (make-music 'RelativeOctaveCheck
415 'origin location
416 'pitch (pitch-of-note pitch-note)
419 ottava = #(define-music-function (parser location octave) (number?)
420 (_i "set the octavation ")
421 (make-ottava-set octave))
423 overrideBeamSettings =
424 #(define-music-function
425 (parser location
426 context time-signature rule-type grouping-rule)
427 (symbol? pair? symbol? pair?)
429 (_i "Override beamSettings in @var{context}
430 for time signatures of @var{time-signature} and rules of type
431 @var{rule-type} to have a grouping rule alist
432 @var{grouping-rule}.
433 @var{rule-type} can be @code{end} or @code{subdivide},
434 with a potential future value of @code{begin}.
435 @var{grouping-rule} is an alist of @var{(beam-type . grouping)}
436 entries. @var{grouping} is in units of @var{beam-type}. If
437 @var{beam-type} is @code{*}, grouping is in units of the denominator
438 of @var{time-signature}.")
440 ;; TODO -- add warning if largest value of grouping is
441 ;; greater than time-signature.
444 #(override-beam-setting
445 $time-signature $rule-type $grouping-rule $context)
448 overrideProperty =
449 #(define-music-function (parser location name property value)
450 (string? symbol? scheme?)
452 (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
453 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
454 or @code{\"GrobName\"}")
456 (let*
457 ((name-components (string-split name #\.))
458 (context-name 'Bottom)
459 (grob-name #f))
461 (if (> 2 (length name-components))
462 (set! grob-name (string->symbol (car name-components)))
463 (begin
464 (set! grob-name (string->symbol (list-ref name-components 1)))
465 (set! context-name (string->symbol (list-ref name-components 0)))))
467 (make-music 'ApplyOutputEvent
468 'origin location
469 'context-type context-name
470 'procedure
471 (lambda (grob orig-context context)
472 (if (equal?
473 (cdr (assoc 'name (ly:grob-property grob 'meta)))
474 grob-name)
475 (set! (ly:grob-property grob property) value))))))
479 %% pageBreak and pageTurn are music functions (iso music indentifiers),
480 %% because music identifiers are not allowed at top-level.
481 pageBreak =
482 #(define-music-function (location parser) ()
483 (_i "Force a page break. May be used at toplevel (i.e. between scores or
484 markups), or inside a score.")
485 (make-music 'EventChord
486 'page-marker #t
487 'line-break-permission 'force
488 'page-break-permission 'force
489 'elements (list (make-music 'LineBreakEvent
490 'break-permission 'force)
491 (make-music 'PageBreakEvent
492 'break-permission 'force))))
494 pageTurn =
495 #(define-music-function (location parser) ()
496 (_i "Force a page turn between two scores or top-level markups.")
497 (make-music 'EventChord
498 'page-marker #t
499 'line-break-permission 'force
500 'page-break-permission 'force
501 'page-turn-permission 'force
502 'elements (list (make-music 'LineBreakEvent
503 'break-permission 'force)
504 (make-music 'PageBreakEvent
505 'break-permission 'force)
506 (make-music 'PageTurnEvent
507 'break-permission 'force))))
509 parallelMusic =
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.
518 Example:
520 @verbatim
521 \\parallelMusic #'(A B C) {
522 c c | d d | e e |
523 d d | e e | f f |
525 <==>
526 A = { c c | d d | }
527 B = { d d | e e | }
528 C = { e e | f f | }
529 @end verbatim
531 (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
532 (current-voices voices)
533 (current-sequence (list)))
535 ;; utilities
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)
562 (push-music 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)
568 (reverse! seqs))
569 voice-ids voices))
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)))
577 voice))
578 voices)
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))))
588 voices)
590 ;; bind voice identifiers to the voices
591 (map (lambda (voice-id voice)
592 (ly:parser-define! parser voice-id
593 (make-music 'SequentialMusic
594 'origin location
595 'elements voice)))
596 voice-ids voices))
597 ;; Return an empty sequence. this function is actually a "void" function.
598 (make-music 'SequentialMusic 'void #t))
600 parenthesize =
601 #(define-music-function (parser loc arg) (ly:music?)
602 (_i "Tag @var{arg} to be parenthesized.")
604 (if (memq 'event-chord (ly:music-property arg 'types))
605 ; arg is an EventChord -> set the parenthesize property on all child notes and rests
606 (map
607 (lambda (ev)
608 (if (or (memq 'note-event (ly:music-property ev 'types))
609 (memq 'rest-event (ly:music-property ev 'types)))
610 (set! (ly:music-property ev 'parenthesize) #t)))
611 (ly:music-property arg 'elements))
612 ; No chord, simply set property for this expression:
613 (set! (ly:music-property arg 'parenthesize) #t))
614 arg)
616 partcombine =
617 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
618 (_i "Take the music in @var{part1} and @var{part2} and typeset so that they share a staff.")
619 (make-part-combine-music parser
620 (list part1 part2)))
622 pitchedTrill =
623 #(define-music-function
624 (parser location main-note secondary-note)
625 (ly:music? ly:music?)
626 (_i "Print a trill with @var{main-note} as the main note of the trill and
627 print @var{secondary-note} as a stemless note head in parentheses.")
628 (let* ((get-notes (lambda (ev-chord)
629 (filter
630 (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
631 (ly:music-property ev-chord 'elements))))
632 (sec-note-events (get-notes secondary-note))
633 (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
634 (ly:music-property main-note 'elements))))
636 (if (pair? sec-note-events)
637 (begin
638 (let* ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
639 (forced (ly:music-property (car sec-note-events) 'force-accidental)))
641 (if (ly:pitch? trill-pitch)
642 (for-each (lambda (m)
643 (ly:music-set-property! m 'pitch trill-pitch)) trill-events)
644 (begin
645 (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
646 (display sec-note-events)))
648 (if (eq? forced #t)
649 (for-each (lambda (m)
650 (ly:music-set-property! m 'force-accidental forced))
651 trill-events)))))
652 main-note))
654 quoteDuring =
655 #(define-music-function
656 (parser location what main-music)
657 (string? ly:music?)
658 (_i "Indicate a section of music to be quoted. @var{what} indicates the name
659 of the quoted voice, as specified in an @code{\\addQuote} command.
660 @var{main-music} is used to indicate the length of music to be quoted;
661 usually contains spacers or multi-measure rests.")
662 (make-music 'QuoteMusic
663 'element main-music
664 'quoted-music-name what
665 'origin location))
667 removeWithTag =
668 #(define-music-function
669 (parser location tag music) (symbol? ly:music?)
670 (_i "Remove elements of @var{music} that are tagged with @var{tag}.")
671 (music-filter
672 (lambda (m)
673 (let* ((tags (ly:music-property m 'tags))
674 (res (memq tag tags)))
675 (not res)))
676 music))
678 resetRelativeOctave =
679 #(define-music-function
680 (parser location reference-note)
681 (ly:music?)
682 (_i "Set the octave inside a \\relative section.")
684 (let*
685 ((notes (ly:music-property reference-note 'elements))
686 (pitch (ly:music-property (car notes) 'pitch)))
688 (set! (ly:music-property reference-note 'elements) '())
689 (set! (ly:music-property reference-note
690 'to-relative-callback)
691 (lambda (music last-pitch)
692 pitch))
694 reference-note))
696 revertBeamSettings =
697 #(define-music-function
698 (parser location
699 context time-signature rule-type)
700 (symbol? pair? symbol?)
702 (_i "Revert beam settings in @var{context} for time signatures of
703 @var{time-signature} and groups of type
704 @var{group-type}. @var{group-type} can be @code{end}
705 or @code{subdivide}.")
707 #(revert-beam-setting $time-signature $rule-type $context)
710 rightHandFinger =
711 #(define-music-function (parser location finger) (number-or-string?)
712 (_i "Apply @var{finger} as a fingering indication.")
714 (apply make-music
715 (append
716 (list
717 'StrokeFingerEvent
718 'origin location)
719 (if (string? finger)
720 (list 'text finger)
721 (list 'digit finger)))))
725 scaleDurations =
726 #(define-music-function (parser location fraction music) (number-pair? ly:music?)
727 (_i "Multiply the duration of events in @var{music} by @var{fraction}.")
728 (ly:music-compress music
729 (ly:make-moment (car fraction) (cdr fraction))))
731 setBeatGrouping =
732 #(define-music-function (parser location grouping) (pair?)
733 (_i "Set the beat grouping in the current time signature to
734 @var{grouping}.")
735 (define (default-group-setting c)
736 (let* ((context-time-signature
737 (ly:context-property c 'timeSignatureFraction))
738 (time-signature (if (null? context-time-signature)
739 '(4 . 4)
740 context-time-signature)))
741 (override-property-setting
743 'beamSettings
744 (list time-signature 'end)
745 (list (cons '* grouping)))))
747 (context-spec-music
748 (make-apply-context default-group-setting)
749 'Score))
751 shiftDurations =
752 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
753 (_i "Scale @var{arg} up by a factor of @var{2^dur*(2-(1/2)^dots)}.")
755 (music-map
756 (lambda (x)
757 (shift-one-duration-log x dur dots)) arg))
759 spacingTweaks =
760 #(define-music-function (parser location parameters) (list?)
761 (_i "Set the system stretch, by reading the 'system-stretch property of
762 the `parameters' assoc list.")
764 \overrideProperty #"Score.NonMusicalPaperColumn"
765 #'line-break-system-details
766 #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
767 (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
770 styledNoteHeads =
771 #(define-music-function
772 (parser location style heads music)
773 (symbol? list-or-symbol? ly:music?)
774 (_i "Set @var{heads} in @var{music} to @var{style}.")
775 (style-note-heads heads style music))
779 tag =
780 #(define-music-function (parser location tag arg)
781 (symbol? ly:music?)
783 (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
785 (set!
786 (ly:music-property arg 'tags)
787 (cons tag
788 (ly:music-property arg 'tags)))
789 arg)
791 transposedCueDuring =
792 #(define-music-function
793 (parser location what dir pitch-note main-music)
794 (string? ly:dir? ly:music? ly:music?)
796 (_i "Insert notes from the part @var{what} into a voice called @code{cue},
797 using the transposition defined by @var{pitch-note}. This happens
798 simultaneously with @var{main-music}, which is usually a rest. The
799 argument @var{dir} determines whether the cue notes should be notated
800 as a first or second voice.")
802 (make-music 'QuoteMusic
803 'element main-music
804 'quoted-context-type 'Voice
805 'quoted-context-id "cue"
806 'quoted-music-name what
807 'quoted-voice-direction dir
808 'quoted-transposition (pitch-of-note pitch-note)
809 'origin location))
811 transposition =
812 #(define-music-function (parser location pitch-note) (ly:music?)
813 (_i "Set instrument transposition")
815 (context-spec-music
816 (make-property-set 'instrumentTransposition
817 (ly:pitch-negate (pitch-of-note pitch-note)))
818 'Staff))
820 tweak =
821 #(define-music-function (parser location sym val arg)
822 (symbol? scheme? ly:music?)
823 (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
825 (if (equal? (object-property sym 'backend-type?) #f)
826 (begin
827 (ly:warning (_ "cannot find property type-check for ~a") sym)
828 (ly:warning (_ "doing assignment anyway"))))
829 (set!
830 (ly:music-property arg 'tweaks)
831 (acons sym val
832 (ly:music-property arg 'tweaks)))
833 arg)
837 unfoldRepeats =
838 #(define-music-function (parser location music) (ly:music?)
839 (_i "Force any @code{\\repeat volta}, @code{\\repeat tremolo} or
840 @code{\\repeat percent} commands in @var{music} to be interpreted
841 as @code{\\repeat unfold}.")
842 (unfold-repeats music))
846 withMusicProperty =
847 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
848 (_i "Set @var{sym} to @var{val} in @var{music}.")
850 (set! (ly:music-property music sym) val)
851 music)