]> git.donarmstrong.com Git - lilypond.git/blob - ly/music-functions-init.ly
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / ly / music-functions-init.ly
1 % -*-Scheme-*-
2
3 \version "2.12.0"
4
5
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 %% this file is alphabetically sorted.
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9
10 %% need SRFI-1 for filter; optargs for lambda*
11 #(use-modules (srfi srfi-1)
12               (ice-9 optargs))
13
14 %% TODO: using define-music-function in a .scm causes crash.
15
16 acciaccatura =
17 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic
18    (_i "Create an acciaccatura from the following music expression"))
19
20 %% keep these two together
21 "instrument-definitions" = #'()
22 addInstrumentDefinition =
23 #(define-music-function
24    (parser location name lst) (string? list?)
25    (_i "Create instrument @var{name} with properties @var{list}.")
26    (set! instrument-definitions (acons name lst instrument-definitions))
27    (make-music 'SequentialMusic 'void #t))
28
29 addQuote =
30 #(define-music-function (parser location name music) (string? ly:music?)
31    (_i "Define @var{music} as a quotable music expression named
32 @var{name}")
33    (add-quotable parser name music)
34    (make-music 'SequentialMusic 'void #t))
35
36 %% keep these two together
37 afterGraceFraction = #(cons 6 8)
38 afterGrace =
39 #(define-music-function
40   (parser location main grace)
41   (ly:music? ly:music?)
42   (_i "Create @var{grace} note(s) after a @var{main} music expression.")
43   (let*
44       ((main-length (ly:music-length main))
45        (fraction  (ly:parser-lookup parser 'afterGraceFraction)))
46
47     (make-simultaneous-music
48      (list
49       main
50       (make-sequential-music
51        (list
52
53         (make-music 'SkipMusic
54                     'duration (ly:make-duration
55                                0 0
56                                (* (ly:moment-main-numerator main-length)
57                                   (car fraction))
58                                (* (ly:moment-main-denominator main-length)
59                                   (cdr fraction)) ))
60         (make-music 'GraceMusic
61                     'element grace)))))))
62
63
64 %% music identifiers not allowed at top-level,
65 %% so this is a music-function instead.
66 allowPageTurn =
67 #(define-music-function (location parser) ()
68    (_i "Allow a page turn. May be used at toplevel (ie between scores or
69 markups), or inside a score.")
70    (make-music 'EventChord
71                'page-marker #t
72                'page-turn-permission 'allow
73                'elements (list (make-music 'PageTurnEvent
74                                            'break-permission 'allow))))
75
76 applyContext =
77 #(define-music-function (parser location proc) (procedure?)
78   (_i "Modify context properties with Scheme procedure @var{proc}.")
79   (make-music 'ApplyContext
80               'origin location
81               'procedure proc))
82
83 applyMusic =
84 #(define-music-function (parser location func music) (procedure? ly:music?)
85    (_i"Apply procedure @var{func} to @var{music}.")
86   (func music))
87
88 applyOutput =
89 #(define-music-function (parser location ctx proc) (symbol? procedure?)
90   (_i "Apply function @code{proc} to every layout object in context @code{ctx}")
91   (make-music 'ApplyOutputEvent
92               'origin location
93               'procedure proc
94               'context-type ctx))
95
96 appoggiatura =
97 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic
98   (_i "Create an appoggiatura from @var{music}"))
99
100 % for regression testing purposes.
101 assertBeamQuant =
102 #(define-music-function (parser location l r) (pair? pair?)
103   (_i "Testing function: check whether the beam quants @var{l} and @var{r} are correct")
104   (make-grob-property-override 'Beam 'positions
105    (ly:make-simple-closure
106     (ly:make-simple-closure
107      (append
108       (list chain-grob-member-functions `(,cons 0 0))
109       (check-quant-callbacks l r))))))
110
111 % for regression testing purposes.
112 assertBeamSlope =
113 #(define-music-function (parser location comp) (procedure?)
114   (_i "Testing function: check whether the slope of the beam is the same as @code{comp}")
115   (make-grob-property-override 'Beam 'positions
116    (ly:make-simple-closure
117     (ly:make-simple-closure
118      (append
119       (list chain-grob-member-functions `(,cons 0 0))
120       (check-slope-callbacks comp))))))
121
122 autochange =
123 #(define-music-function (parser location music) (ly:music?)
124   (_i "Make voices that switch between staves automatically")
125   (make-autochange-music parser music))
126
127
128
129 balloonGrobText =
130 #(define-music-function (parser location grob-name offset text)
131                         (symbol? number-pair? markup?)
132   (_i "Attach @var{text} to @var{grob-name} at offset @var{offset}
133 (use like @code{\\once})")
134     (make-music 'AnnotateOutputEvent
135                 'symbol grob-name
136                 'X-offset (car offset)
137                 'Y-offset (cdr offset)
138                 'text text))
139
140 balloonText =
141 #(define-music-function (parser location offset text) (number-pair? markup?)
142   (_i "Attach @var{text} at @var{offset} (use like @code{\\tweak})")
143     (make-music 'AnnotateOutputEvent
144                 'X-offset (car offset)
145                 'Y-offset (cdr offset)
146                 'text text))
147
148 bar =
149 #(define-music-function (parser location type) (string?)
150   (_i "Insert a bar line of type @var{type}")
151    (context-spec-music
152     (make-property-set 'whichBar type)
153     'Timing))
154
155 barNumberCheck =
156 #(define-music-function (parser location n) (integer?)
157   (_i "Print a warning if the current bar number is not @var{n}.")
158    (make-music 'ApplyContext
159                'origin location
160                'procedure
161                (lambda (c)
162                  (let*
163                      ((cbn (ly:context-property c 'currentBarNumber)))
164                    (if (and  (number? cbn) (not (= cbn n)))
165                        (ly:input-message location "Barcheck failed got ~a expect ~a"
166                                          cbn n))))))
167
168 bendAfter =
169 #(define-music-function (parser location delta) (real?)
170   (_i "Create a fall or doit of pitch interval @var{delta}.")
171   (make-music 'BendAfterEvent
172    'delta-step delta))
173
174 %% why a function?
175 breathe =
176 #(define-music-function (parser location) ()
177   (_i "Insert a breath mark.")
178             (make-music 'EventChord
179               'origin location
180               'elements (list (make-music 'BreathingEvent))))
181
182
183
184 clef =
185 #(define-music-function (parser location type) (string?)
186   (_i "Set the current clef to @var{type}.")
187    (make-clef-set type))
188
189 cueDuring =
190 #(define-music-function
191   (parser location what dir main-music) (string? ly:dir? ly:music?)
192   (_i "Insert contents of quote @var{what} corresponding to @var{main-music},
193 in a CueVoice oriented by @var{dir}.")
194   (make-music 'QuoteMusic
195               'element main-music
196               'quoted-context-type 'Voice
197               'quoted-context-id "cue"
198               'quoted-music-name what
199               'quoted-voice-direction dir
200               'origin location))
201
202
203
204 displayLilyMusic =
205 #(define-music-function (parser location music) (ly:music?)
206   (_i "Display  the LilyPond input representation of @var{music}
207 to the console.")
208    (newline)
209    (display-lily-music music parser)
210    music)
211
212 displayMusic =
213 #(define-music-function (parser location music) (ly:music?)
214   (_i "Display the internal representation of @var{music} to the console.")
215    (newline)
216    (display-scheme-music music)
217    music)
218
219
220
221 endSpanners =
222 #(define-music-function (parser location music) (ly:music?)
223   (_i "Terminate the next spanner prematurely after exactly one note without the need of a specific end spanner.")
224    (if (eq? (ly:music-property music 'name) 'EventChord)
225        (let*
226            ((elts (ly:music-property music 'elements))
227             (start-span-evs (filter (lambda (ev)
228                                 (and (music-has-type ev 'span-event)
229                                      (equal? (ly:music-property ev 'span-direction)
230                                              START)))
231                               elts))
232             (stop-span-evs
233              (map (lambda (m)
234                     (let* ((c (music-clone m)))
235                       (set! (ly:music-property c 'span-direction) STOP)
236                       c))
237                   start-span-evs))
238             (end-ev-chord (make-music 'EventChord
239                                       'elements stop-span-evs))
240             (total (make-music 'SequentialMusic
241                                'elements (list music
242                                                end-ev-chord))))
243          total)
244
245        (ly:input-message location (_ "argument endSpanners is not an EventChord: ~a" music))))
246
247
248
249 featherDurations=
250 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
251  (_i "Adjust durations of music in @var{argument} by rational @var{factor}. ")
252    (let*
253        ((orig-duration (ly:music-length argument))
254         (multiplier (ly:make-moment 1 1)))
255
256      (music-map
257       (lambda (mus)
258         (if (and (eq? (ly:music-property mus 'name) 'EventChord)
259                  (< 0 (ly:moment-main-denominator (ly:music-length mus))))
260             (begin
261               (ly:music-compress mus multiplier)
262               (set! multiplier (ly:moment-mul factor multiplier)))
263             )
264         mus)
265       argument)
266
267      (ly:music-compress
268       argument
269       (ly:moment-div orig-duration (ly:music-length argument)))
270
271      argument))
272
273
274
275 grace =
276 #(def-grace-function startGraceMusic stopGraceMusic
277    (_i "Insert @var{music} as grace notes."))
278
279
280
281 instrumentSwitch =
282 #(define-music-function
283    (parser location name) (string?)
284    (_i "Switch instrument to @var{name}, which must be predefined with
285 @code{\\addInstrumentDefinition}.")
286    (let*
287        ((handle  (assoc name instrument-definitions))
288         (instrument-def (if handle (cdr handle) '()))
289         )
290
291      (if (not handle)
292          (ly:input-message location "No such instrument: ~a" name))
293      (context-spec-music
294       (make-music 'SimultaneousMusic
295                   'elements
296                   (map (lambda (kv)
297                          (make-property-set
298                           (car kv)
299                           (cdr kv)))
300                        instrument-def))
301       'Staff)))
302
303
304
305 keepWithTag =
306 #(define-music-function
307   (parser location tag music) (symbol? ly:music?)
308   (_i "Include only elements of @var{music} that are tagged with @var{tag}.")
309   (music-filter
310    (lambda (m)
311     (let* ((tags (ly:music-property m 'tags))
312            (res (memq tag tags)))
313      (or
314       (eq? tags '())
315       res)))
316    music))
317
318 killCues =
319 #(define-music-function
320    (parser location music)
321    (ly:music?)
322    (_i "Remove cue notes from @var{music}.")
323    (music-map
324     (lambda (mus)
325       (if (string? (ly:music-property mus 'quoted-music-name))
326           (ly:music-property mus 'element)
327           mus)) music))
328
329
330
331 label =
332 #(define-music-function (parser location label) (symbol?)
333    (_i "Create @var{label} as a bookmarking label")
334    (make-music 'EventChord
335                'page-marker #t
336                'page-label label
337                'elements (list (make-music 'LabelEvent
338                                            'page-label label))))
339
340
341
342 makeClusters =
343 #(define-music-function
344                 (parser location arg) (ly:music?)
345    (_i "Display chords in @var{arg} as clusters")
346                 (music-map note-to-cluster arg))
347
348 musicMap =
349 #(define-music-function (parser location proc mus) (procedure? ly:music?)
350              (music-map proc mus))
351
352
353
354 %% noPageBreak and noPageTurn are music functions (not music indentifiers),
355 %% because music identifiers are not allowed at top-level.
356 noPageBreak =
357 #(define-music-function (location parser) ()
358    (_i "Forbid a page break. May be used at toplevel (ie between scores or
359 markups), or inside a score.")
360    (make-music 'EventChord
361                'page-marker #t
362                'page-break-permission 'forbid
363                'elements (list (make-music 'PageBreakEvent
364                                            'break-permission '()))))
365
366 noPageTurn =
367 #(define-music-function (location parser) ()
368    (_i "Forbid a page turn. May be used at toplevel (ie between scores or
369 markups), or inside a score.")
370    (make-music 'EventChord
371                'page-marker #t
372                'page-turn-permission 'forbid
373                'elements (list (make-music 'PageTurnEvent
374                                            'break-permission '()))))
375
376
377
378 octaveCheck =
379 #(define-music-function (parser location pitch-note) (ly:music?)
380    (_i "octave check")
381
382    (make-music 'RelativeOctaveCheck
383                'origin location
384                'pitch (pitch-of-note pitch-note)
385            ))
386
387 ottava = #(define-music-function (parser location octave) (number?)
388   (_i "set the octavation ")
389   (make-ottava-set octave))
390
391 overrideBeamSettings =
392 #(define-music-function
393     (parser location
394      context time-signature rule-type grouping-rule)
395     (symbol? pair? symbol? pair?)
396
397  (_i "Override beamSettings in @var{context}
398 for time signatures of @var{time-signature} and rules of type
399 @var{rule-type} to have a grouping rule alist
400 @var{grouping-rule}.
401 @var{rule-type} can be @code{end} or @code{subdivide},
402 with a potential future value of @code{begin}.
403 @var{grouping-rule} is an alist of @var{(beam-type . grouping)}
404 entries.  @var{grouping} is in units of @var{beam-type}.  If
405 @var{beam-type} is @code{*}, grouping is in units of the denominator
406 of @var{time-signature}.")
407
408  ;; TODO -- add warning if largest value of grouping is
409  ;;         greater than time-signature.
410
411 #{
412 #(override-beam-setting
413   $time-signature $rule-type $grouping-rule $context)
414 #})
415
416 overrideProperty =
417 #(define-music-function (parser location name property value)
418    (string? symbol? scheme?)
419
420    (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
421 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
422 or @code{\"GrobName\"}")
423
424    (let*
425        ((name-components (string-split name #\.))
426         (context-name 'Bottom)
427         (grob-name #f))
428
429      (if (> 2 (length name-components))
430          (set! grob-name (string->symbol (car name-components)))
431          (begin
432            (set! grob-name (string->symbol (list-ref name-components 1)))
433            (set! context-name (string->symbol (list-ref name-components 0)))))
434
435      (make-music 'ApplyOutputEvent
436                  'origin location
437                  'context-type context-name
438                  'procedure
439                  (lambda (grob orig-context context)
440                    (if (equal?
441                         (cdr (assoc 'name (ly:grob-property grob 'meta)))
442                         grob-name)
443                        (set! (ly:grob-property grob property) value))))))
444
445
446
447 %% pageBreak and pageTurn are music functions (iso music indentifiers),
448 %% because music identifiers are not allowed at top-level.
449 pageBreak =
450 #(define-music-function (location parser) ()
451    (_i "Force a page break. May be used at toplevel (ie between scores or
452 markups), or inside a score.")
453    (make-music 'EventChord
454                'page-marker #t
455                'line-break-permission 'force
456                'page-break-permission 'force
457                'elements (list (make-music 'LineBreakEvent
458                                            'break-permission 'force)
459                                (make-music 'PageBreakEvent
460                                            'break-permission 'force))))
461
462 pageTurn =
463 #(define-music-function (location parser) ()
464    (_i "Force a page turn between two scores or top-level markups.")
465    (make-music 'EventChord
466                'page-marker #t
467                'line-break-permission 'force
468                'page-break-permission 'force
469                'page-turn-permission 'force
470                'elements (list (make-music 'LineBreakEvent
471                                            'break-permission 'force)
472                                (make-music 'PageBreakEvent
473                                            'break-permission 'force)
474                                (make-music 'PageTurnEvent
475                                            'break-permission 'force))))
476
477 parallelMusic =
478 #(define-music-function (parser location voice-ids music) (list? ly:music?)
479   (_i "Define parallel music sequences, separated by '|' (bar check signs),
480 and assign them to the identifiers provided in @var{voice-ids}.
481
482 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
483
484 @var{music}: a music sequence, containing BarChecks as limiting expressions.
485
486 Example:
487
488 @verbatim
489   \\parallelMusic #'(A B C) {
490     c c | d d | e e |
491     d d | e e | f f |
492   }
493 <==>
494   A = { c c | d d | }
495   B = { d d | e e | }
496   C = { e e | f f | }
497 @end verbatim
498 ")
499   (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
500          (current-voices voices)
501          (current-sequence (list)))
502     ;;
503     ;; utilities
504     (define (push-music m)
505       "Push the music expression into the current sequence"
506       (set! current-sequence (cons m current-sequence)))
507     (define (change-voice)
508       "Stores the previously built sequence into the current voice and
509        change to the following voice."
510       (list-set! current-voices 0 (cons (make-music 'SequentialMusic
511                                          'elements (reverse! current-sequence))
512                                         (car current-voices)))
513       (set! current-sequence (list))
514       (set! current-voices (cdr current-voices)))
515     (define (bar-check? m)
516       "Checks whether m is a bar check."
517       (eq? (ly:music-property m 'name) 'BarCheck))
518     (define (music-origin music)
519       "Recursively search an origin location stored in music."
520       (cond ((null? music) #f)
521             ((not (null? (ly:music-property music 'origin)))
522              (ly:music-property music 'origin))
523             (else (or (music-origin (ly:music-property music 'element))
524                       (let ((origins (remove not (map music-origin
525                                                       (ly:music-property music 'elements)))))
526                         (and (not (null? origins)) (car origins)))))))
527     ;;
528     ;; first, split the music and fill in voices
529     (map-in-order (lambda (m)
530                     (push-music m)
531                     (if (bar-check? m) (change-voice)))
532                   (ly:music-property music 'elements))
533     (if (not (null? current-sequence)) (change-voice))
534     ;; un-circularize `voices' and reorder the voices
535     (set! voices (map-in-order (lambda (dummy seqs)
536                                  (reverse! seqs))
537                                voice-ids voices))
538     ;;
539     ;; set origin location of each sequence in each voice
540     ;; for better type error tracking
541     (for-each (lambda (voice)
542                 (for-each (lambda (seq)
543                             (set! (ly:music-property seq 'origin)
544                                   (or (music-origin seq) location)))
545                           voice))
546               voices)
547     ;;
548     ;; check sequence length
549     (apply for-each (lambda* (#:rest seqs)
550                       (let ((moment-reference (ly:music-length (car seqs))))
551                         (for-each (lambda (seq moment)
552                                     (if (not (equal? moment moment-reference))
553                                         (ly:music-message seq
554                                          "Bars in parallel music don't have the same length")))
555                           seqs (map-in-order ly:music-length seqs))))
556            voices)
557    ;;
558    ;; bind voice identifiers to the voices
559    (map (lambda (voice-id voice)
560           (ly:parser-define! parser voice-id
561                              (make-music 'SequentialMusic
562                                'origin location
563                                'elements voice)))
564         voice-ids voices))
565  ;; Return an empty sequence. this function is actually a "void" function.
566  (make-music 'SequentialMusic 'void #t))
567
568 parenthesize =
569 #(define-music-function (parser loc arg) (ly:music?)
570    (_i "Tag @var{arg} to be parenthesized.")
571
572    (if (memq 'event-chord (ly:music-property arg 'types))
573      ; arg is an EventChord -> set the parenthesize property on all child notes and rests
574      (map
575        (lambda (ev)
576          (if (or (memq 'note-event (ly:music-property ev 'types))
577                  (memq 'rest-event (ly:music-property ev 'types)))
578            (set! (ly:music-property ev 'parenthesize) #t)))
579        (ly:music-property arg 'elements))
580      ; No chord, simply set property for this expression:
581      (set! (ly:music-property arg 'parenthesize) #t))
582    arg)
583
584 partcombine =
585 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
586                 (make-part-combine-music parser
587                                          (list part1 part2)))
588
589 pitchedTrill =
590 #(define-music-function
591    (parser location main-note secondary-note)
592    (ly:music? ly:music?)
593    (let*
594        ((get-notes (lambda (ev-chord)
595                      (filter
596                       (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
597                       (ly:music-property ev-chord 'elements))))
598         (sec-note-events (get-notes secondary-note))
599         (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
600                               (ly:music-property main-note 'elements))))
601
602      (if (pair? sec-note-events)
603          (begin
604            (let*
605                ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
606                 (forced (ly:music-property (car sec-note-events ) 'force-accidental)))
607
608              (if (ly:pitch? trill-pitch)
609                  (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
610                            trill-events)
611                  (begin
612                    (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
613                    (display sec-note-events)))
614
615              (if (eq? forced #t)
616                  (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced))
617                            trill-events)))))
618      main-note))
619
620
621
622 quoteDuring =
623 #(define-music-function
624   (parser location what main-music)
625   (string? ly:music?)
626   (make-music 'QuoteMusic
627               'element main-music
628               'quoted-music-name what
629               'origin location))
630
631
632
633 removeWithTag =
634 #(define-music-function
635   (parser location tag music) (symbol? ly:music?)
636   (_i "Remove elements of @var{music} that are tagged with @var{tag}.")
637   (music-filter
638    (lambda (m)
639     (let* ((tags (ly:music-property m 'tags))
640            (res (memq tag tags)))
641      (not res)))
642  music))
643
644 resetRelativeOctave =
645 #(define-music-function
646     (parser location reference-note)
647     (ly:music?)
648     (_i "Set the octave inside a \\relative section.")
649
650    (let*
651     ((notes (ly:music-property reference-note 'elements))
652      (pitch (ly:music-property (car notes) 'pitch)))
653
654     (set! (ly:music-property reference-note 'elements) '())
655     (set! (ly:music-property reference-note
656        'to-relative-callback)
657        (lambda (music last-pitch)
658         pitch))
659
660     reference-note))
661
662 revertBeamSettings =
663 #(define-music-function
664     (parser location
665      context time-signature rule-type)
666     (symbol? pair? symbol?)
667
668  (_i "Revert beam settings in @var{context} for time signatures of
669 @var{time-signature} and groups of type
670 @var{group-type}.  @var{group-type} can be @code{end}
671 or @code{subdivide}.")
672 #{
673   #(revert-beam-setting $time-signature $rule-type $context)
674 #})
675
676 rightHandFinger =
677 #(define-music-function (parser location finger) (number-or-string?)
678    (_i "Apply @var{finger} as a fingering indication.")
679
680    (apply make-music
681           (append
682            (list
683             'StrokeFingerEvent
684             'origin location)
685            (if  (string? finger)
686                 (list 'text finger)
687                 (list 'digit finger)))))
688
689
690
691 scaleDurations =
692 #(define-music-function (parser location fraction music) (number-pair? ly:music?)
693    (_i "Multiply the duration of events in @var{music} by @var{fraction}.")
694    (ly:music-compress music
695                       (ly:make-moment (car fraction) (cdr fraction))))
696
697 setBeatGrouping =
698 #(define-music-function (parser location grouping) (pair?)
699    (_i "Set the beat grouping in the current time signature to
700 @var{grouping}.")
701    (define (default-group-setting c)
702     (let* ((context-time-signature
703             (ly:context-property c 'timeSignatureFraction))
704            (time-signature (if (null? context-time-signature)
705                                '(4 . 4)
706                                context-time-signature)))
707       (override-property-setting
708        c
709        'beamSettings
710        (list time-signature 'end)
711        (list  (cons '* grouping)))))
712
713    (context-spec-music
714      (make-apply-context default-group-setting)
715      'Score))
716
717 shiftDurations =
718 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
719    (_i "Scale @var{arg} up by a factor of @var{2^dur*(2-(1/2)^dots)}.")
720
721    (music-map
722     (lambda (x)
723       (shift-one-duration-log x dur dots)) arg))
724
725 spacingTweaks =
726 #(define-music-function (parser location parameters) (list?)
727    (_i "Set the system stretch, by reading the 'system-stretch property of
728 the `parameters' assoc list.")
729    #{
730       \overrideProperty #"Score.NonMusicalPaperColumn"
731         #'line-break-system-details
732         #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
733                 (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
734    #})
735
736 styledNoteHeads =
737 #(define-music-function
738    (parser location style heads music)
739    (symbol? list-or-symbol? ly:music?)
740    (_i "Set @var{heads} in @var{music} to @var{style}.")
741    (style-note-heads heads style music))
742
743
744
745 tag =
746 #(define-music-function (parser location tag arg)
747    (symbol? ly:music?)
748
749    (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
750
751    (set!
752     (ly:music-property arg 'tags)
753     (cons tag
754           (ly:music-property arg 'tags)))
755    arg)
756
757 transposedCueDuring =
758 #(define-music-function
759   (parser location what dir pitch-note main-music)
760   (string? ly:dir? ly:music? ly:music?)
761
762   (_i "Insert notes from the part @var{what} into a voice called @code{cue},
763 using the transposition defined by @var{pitch-note}.  This happens
764 simultaneously with @var{main-music}, which is usually a rest.  The
765 argument @var{dir} determines whether the cue notes should be notated
766 as a first or second voice.")
767
768   (make-music 'QuoteMusic
769               'element main-music
770               'quoted-context-type 'Voice
771               'quoted-context-id "cue"
772               'quoted-music-name what
773               'quoted-voice-direction dir
774               'quoted-transposition (pitch-of-note pitch-note)
775               'origin location))
776
777 transposition =
778 #(define-music-function (parser location pitch-note) (ly:music?)
779    (_i "Set instrument transposition")
780
781    (context-spec-music
782     (make-property-set 'instrumentTransposition
783                        (ly:pitch-negate (pitch-of-note pitch-note)))
784         'Staff))
785
786 tweak =
787 #(define-music-function (parser location sym val arg)
788    (symbol? scheme? ly:music?)
789    (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
790
791    (if (equal? (object-property sym 'backend-type?) #f)
792        (begin
793          (ly:warning (_ "cannot find property type-check for ~a") sym)
794          (ly:warning (_ "doing assignment anyway"))))
795    (set!
796     (ly:music-property arg 'tweaks)
797     (acons sym val
798            (ly:music-property arg 'tweaks)))
799    arg)
800
801
802
803 unfoldRepeats =
804 #(define-music-function (parser location music) (ly:music?)
805                   (unfold-repeats music))
806
807
808
809 withMusicProperty =
810 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
811    (_i "Set @var{sym} to @var{val} in @var{music}.")
812
813    (set! (ly:music-property music sym) val)
814    music)