]> git.donarmstrong.com Git - lilypond.git/blob - ly/music-functions-init.ly
2dded22e3d77acd2b2dbcab500d6a01a5f893be9
[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 @var{\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
363 overrideProperty =
364 #(define-music-function (parser location name property value)
365    (string? symbol? scheme?)
366
367    (_i "Set @var{property} to @var{value} in all grobs named @var{name}.
368 The @var{name} argument is a string of the form @code{\"Context.GrobName\"}
369 or @code{\"GrobName\"}")
370
371    (let*
372        ((name-components (string-split name #\.))
373         (context-name 'Bottom)
374         (grob-name #f))
375
376      (if (> 2 (length name-components))
377          (set! grob-name (string->symbol (car name-components)))
378          (begin
379            (set! grob-name (string->symbol (list-ref name-components 1)))
380            (set! context-name (string->symbol (list-ref name-components 0)))))
381
382      (make-music 'ApplyOutputEvent
383                  'origin location
384                  'context-type context-name
385                  'procedure
386                  (lambda (grob orig-context context)
387                    (if (equal?
388                         (cdr (assoc 'name (ly:grob-property grob 'meta)))
389                         grob-name)
390                        (set! (ly:grob-property grob property) value))))))
391
392 %% These are music functions (iso music indentifiers), because music identifiers
393 %% are not allowed at top-level.
394 pageBreak =
395 #(define-music-function (location parser) ()
396    (_i "Force a page break. May be used at toplevel (ie between scores or
397 markups), or inside a score.")
398    (make-music 'EventChord
399                'page-marker #t
400                'line-break-permission 'force
401                'page-break-permission 'force
402                'elements (list (make-music 'LineBreakEvent
403                                            'break-permission 'force)
404                                (make-music 'PageBreakEvent
405                                            'break-permission 'force))))
406
407 noPageBreak =
408 #(define-music-function (location parser) ()
409    (_i "Forbid a page break. May be used at toplevel (ie between scores or
410 markups), or inside a score.")
411    (make-music 'EventChord
412                'page-marker #t
413                'page-break-permission 'forbid
414                'elements (list (make-music 'PageBreakEvent
415                                            'break-permission '()))))
416
417 pageTurn =
418 #(define-music-function (location parser) ()
419    (_i "Force a page turn between two scores or top-level markups.")
420    (make-music 'EventChord
421                'page-marker #t
422                'line-break-permission 'force
423                'page-break-permission 'force
424                'page-turn-permission 'force
425                'elements (list (make-music 'LineBreakEvent
426                                            'break-permission 'force)
427                                (make-music 'PageBreakEvent
428                                            'break-permission 'force)
429                                (make-music 'PageTurnEvent
430                                            'break-permission 'force))))
431
432 noPageTurn =
433 #(define-music-function (location parser) ()
434    (_i "Forbid a page turn. May be used at toplevel (ie between scores or
435 markups), or inside a score.")
436    (make-music 'EventChord
437                'page-marker #t
438                'page-turn-permission 'forbid
439                'elements (list (make-music 'PageTurnEvent
440                                            'break-permission '()))))
441
442 allowPageTurn =
443 #(define-music-function (location parser) ()
444    (_i "Allow a page turn. May be used at toplevel (ie between scores or
445 markups), or inside a score.")
446    (make-music 'EventChord
447                'page-marker #t
448                'page-turn-permission 'allow
449                'elements (list (make-music 'PageTurnEvent
450                                            'break-permission 'allow))))
451
452 %% Todo:
453 %% doing
454 %% define-music-function in a .scm causes crash.
455
456 octaveCheck =
457 #(define-music-function (parser location pitch-note) (ly:music?)
458    (_i "octave check")
459
460    (make-music 'RelativeOctaveCheck
461                'origin location
462                'pitch (pitch-of-note pitch-note)
463            ))
464
465 ottava = #(define-music-function (parser location octave) (number?)
466   (_i "set the octavation ")
467   (make-ottava-set octave))
468
469 partcombine =
470 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
471                 (make-part-combine-music parser
472                                          (list part1 part2)))
473
474
475 pitchedTrill =
476 #(define-music-function
477    (parser location main-note secondary-note)
478    (ly:music? ly:music?)
479    (let*
480        ((get-notes (lambda (ev-chord)
481                      (filter
482                       (lambda (m) (eq? 'NoteEvent (ly:music-property m 'name)))
483                       (ly:music-property ev-chord 'elements))))
484         (sec-note-events (get-notes secondary-note))
485         (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event))
486                               (ly:music-property main-note 'elements))))
487
488      (if (pair? sec-note-events)
489          (begin
490            (let*
491                ((trill-pitch (ly:music-property (car sec-note-events) 'pitch))
492                 (forced (ly:music-property (car sec-note-events ) 'force-accidental)))
493
494              (if (ly:pitch? trill-pitch)
495                  (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch))
496                            trill-events)
497                  (begin
498                    (ly:warning (_ "Second argument of \\pitchedTrill should be single note: "))
499                    (display sec-note-events)))
500
501              (if (eq? forced #t)
502                  (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced))
503                            trill-events)))))
504      main-note))
505
506
507
508 %% for lambda*
509 #(use-modules (ice-9 optargs))
510
511 parallelMusic =
512 #(define-music-function (parser location voice-ids music) (list? ly:music?)
513   (_i "Define parallel music sequences, separated by '|' (bar check signs),
514 and assign them to the identifiers provided in @var{voice-ids}.
515
516 @var{voice-ids}: a list of music identifiers (symbols containing only letters)
517
518 @var{music}: a music sequence, containing BarChecks as limiting expressions.
519
520 Example:
521
522 @verbatim
523   \\parallelMusic #'(A B C) {
524     c c | d d | e e |
525     d d | e e | f f |
526   }
527 <==>
528   A = { c c | d d | }
529   B = { d d | e e | }
530   C = { e e | f f | }
531 @end verbatim
532 ")
533   (let* ((voices (apply circular-list (make-list (length voice-ids) (list))))
534          (current-voices voices)
535          (current-sequence (list)))
536     ;;
537     ;; utilities
538     (define (push-music m)
539       "Push the music expression into the current sequence"
540       (set! current-sequence (cons m current-sequence)))
541     (define (change-voice)
542       "Stores the previously built sequence into the current voice and
543        change to the following voice."
544       (list-set! current-voices 0 (cons (make-music 'SequentialMusic
545                                          'elements (reverse! current-sequence))
546                                         (car current-voices)))
547       (set! current-sequence (list))
548       (set! current-voices (cdr current-voices)))
549     (define (bar-check? m)
550       "Checks whether m is a bar check."
551       (eq? (ly:music-property m 'name) 'BarCheck))
552     (define (music-origin music)
553       "Recursively search an origin location stored in music."
554       (cond ((null? music) #f)
555             ((not (null? (ly:music-property music 'origin)))
556              (ly:music-property music 'origin))
557             (else (or (music-origin (ly:music-property music 'element))
558                       (let ((origins (remove not (map music-origin
559                                                       (ly:music-property music 'elements)))))
560                         (and (not (null? origins)) (car origins)))))))
561     ;;
562     ;; first, split the music and fill in voices
563     (map-in-order (lambda (m)
564                     (push-music m)
565                     (if (bar-check? m) (change-voice)))
566                   (ly:music-property music 'elements))
567     (if (not (null? current-sequence)) (change-voice))
568     ;; un-circularize `voices' and reorder the voices
569     (set! voices (map-in-order (lambda (dummy seqs)
570                                  (reverse! seqs))
571                                voice-ids voices))
572     ;;
573     ;; set origin location of each sequence in each voice
574     ;; for better type error tracking
575     (for-each (lambda (voice)
576                 (for-each (lambda (seq)
577                             (set! (ly:music-property seq 'origin)
578                                   (or (music-origin seq) location)))
579                           voice))
580               voices)
581     ;;
582     ;; check sequence length
583     (apply for-each (lambda* (#:rest seqs)
584                       (let ((moment-reference (ly:music-length (car seqs))))
585                         (for-each (lambda (seq moment)
586                                     (if (not (equal? moment moment-reference))
587                                         (ly:music-message seq
588                                          "Bars in parallel music don't have the same length")))
589                           seqs (map-in-order ly:music-length seqs))))
590            voices)
591    ;;
592    ;; bind voice identifiers to the voices
593    (map (lambda (voice-id voice)
594           (ly:parser-define! parser voice-id
595                              (make-music 'SequentialMusic
596                                'origin location
597                                'elements voice)))
598         voice-ids voices))
599  ;; Return an empty sequence. this function is actually a "void" function.
600  (make-music 'SequentialMusic 'void #t))
601
602
603
604 parenthesize =
605 #(define-music-function (parser loc arg) (ly:music?)
606    (_i "Tag @var{arg} to be parenthesized.")
607
608    (if (memq 'event-chord (ly:music-property arg 'types))
609      ; arg is an EventChord -> set the parenthesize property on all child notes and rests
610      (map
611        (lambda (ev)
612          (if (or (memq 'note-event (ly:music-property ev 'types))
613                  (memq 'rest-event (ly:music-property ev 'types)))
614            (set! (ly:music-property ev 'parenthesize) #t)))
615        (ly:music-property arg 'elements))
616      ; No chord, simply set property for this expression:
617      (set! (ly:music-property arg 'parenthesize) #t))
618    arg)
619
620
621 quoteDuring = #
622 (define-music-function
623   (parser location what main-music)
624   (string? ly:music?)
625   (make-music 'QuoteMusic
626               'element main-music
627               'quoted-music-name what
628               'origin location))
629
630
631
632 resetRelativeOctave  =
633 #(define-music-function
634     (parser location reference-note)
635     (ly:music?)
636     (_i "Set the octave inside a \\relative section.")
637
638    (let*
639     ((notes (ly:music-property reference-note 'elements))
640      (pitch (ly:music-property (car notes) 'pitch)))
641
642     (set! (ly:music-property reference-note 'elements) '())
643     (set! (ly:music-property reference-note
644        'to-relative-callback)
645        (lambda (music last-pitch)
646         pitch))
647
648     reference-note))
649
650
651 scaleDurations =
652 #(define-music-function (parser location fraction music) (number-pair? ly:music?)
653    (_i "Multiply the duration of events in @var{music} by @var{fraction}.")
654    (ly:music-compress music
655                       (ly:make-moment (car fraction) (cdr fraction))))
656
657
658
659 shiftDurations =
660 #(define-music-function (parser location dur dots arg) (integer? integer? ly:music?)
661    (_i "Scale @var{arg} up by a factor of @var{2^dur*(2-(1/2)^dots)}.")
662
663    (music-map
664     (lambda (x)
665       (shift-one-duration-log x dur dots)) arg))
666
667 spacingTweaks =
668 #(define-music-function (parser location parameters) (list?)
669    (_i "Set the system stretch, by reading the 'system-stretch property of
670 the `parameters' assoc list.")
671    #{
672       \overrideProperty #"Score.NonMusicalPaperColumn"
673         #'line-break-system-details
674         #$(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
675                 (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
676    #})
677
678
679 rightHandFinger =
680 #(define-music-function (parser location finger) (number-or-string?)
681    (_i "Apply @var{finger} as a fingering indication.")
682
683    (apply make-music
684           (append
685            (list
686             'StrokeFingerEvent
687             'origin location)
688            (if  (string? finger)
689                 (list 'text finger)
690                 (list 'digit finger)))))
691
692 scoreTweak =
693 #(define-music-function (parser location name) (string?)
694    (_i "Include the score tweak, if exists.")
695    (if (and page-layout-parser (not (ly:get-option 'dump-tweaks)))
696        (let ((tweak-music (ly:parser-lookup page-layout-parser
697                                             (string->symbol name))))
698          (if (ly:music? tweak-music)
699              tweak-music
700              (make-music 'SequentialMusic)))
701        (make-music 'SequentialMusic)))
702
703
704 tag =
705 #(define-music-function (parser location tag arg)
706    (symbol? ly:music?)
707
708    (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
709
710    (set!
711     (ly:music-property arg 'tags)
712     (cons tag
713           (ly:music-property arg 'tags)))
714    arg)
715
716
717
718 transposedCueDuring =
719 #(define-music-function
720   (parser location what dir pitch-note main-music)
721   (string? ly:dir? ly:music? ly:music?)
722
723   (_i "Insert notes from the part @var{what} into a voice called @code{cue},
724 using the transposition defined by @var{pitch-note}.  This happens
725 simultaneously with @var{main-music}, which is usually a rest.  The
726 argument @var{dir} determines whether the cue notes should be notated
727 as a first or second voice.")
728
729   (make-music 'QuoteMusic
730               'element main-music
731               'quoted-context-type 'Voice
732               'quoted-context-id "cue"
733               'quoted-music-name what
734               'quoted-voice-direction dir
735               'quoted-transposition (pitch-of-note pitch-note)
736               'origin location))
737
738
739
740 transposition =
741 #(define-music-function (parser location pitch-note) (ly:music?)
742    (_i "Set instrument transposition")
743
744    (context-spec-music
745     (make-property-set 'instrumentTransposition
746                        (ly:pitch-negate (pitch-of-note pitch-note)))
747         'Staff))
748
749 tweak =
750 #(define-music-function (parser location sym val arg)
751    (symbol? scheme? ly:music?)
752    (_i "Add @code{sym . val} to the @code{tweaks} property of @var{arg}.")
753
754    (if (equal? (object-property sym 'backend-type?) #f)
755        (begin
756          (ly:warning (_ "cannot find property type-check for ~a") sym)
757          (ly:warning (_ "doing assignment anyway"))))
758    (set!
759     (ly:music-property arg 'tweaks)
760     (acons sym val
761            (ly:music-property arg 'tweaks)))
762    arg)
763
764
765
766 unfoldRepeats =
767 #(define-music-function (parser location music) (ly:music?)
768                   (unfold-repeats music))
769
770
771
772 withMusicProperty =
773 #(define-music-function (parser location sym val music) (symbol? scheme? ly:music?)
774    (_i "Set @var{sym} to @var{val} in @var{music}.")
775
776    (set! (ly:music-property music sym) val)
777    music)