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