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