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