1 ;;;; music-functions.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 ;; (use-modules (ice-9 optargs))
10 ;;; ly:music-property with setter
11 ;;; (ly:music-property my-music 'elements)
12 ;;; ==> the 'elements property
13 ;;; (set! (ly:music-property my-music 'elements) value)
14 ;;; ==> set the 'elements property and return it
15 (define-public ly:music-property
16 (make-procedure-with-setter ly:music-property
17 ly:music-set-property!))
19 (define-public ly:grob-property
20 (make-procedure-with-setter ly:grob-property
21 ly:grob-set-property!))
23 (define-public (music-map function music)
24 "Apply @var{function} to @var{music} and all of the music it contains.
26 First it recurses over the children, then the function is applied to MUSIC.
28 (let ((es (ly:music-property music 'elements))
29 (e (ly:music-property music 'element)))
30 (set! (ly:music-property music 'elements)
31 (map (lambda (y) (music-map function y)) es))
33 (set! (ly:music-property music 'element)
34 (music-map function e)))
37 (define-public (music-filter pred? music)
38 "Filter out music expressions that do not satisfy PRED."
40 (define (inner-music-filter pred? music)
42 (let* ((es (ly:music-property music 'elements))
43 (e (ly:music-property music 'element))
44 (as (ly:music-property music 'articulations))
45 (filtered-as (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) as)))
46 (filtered-e (if (ly:music? e)
47 (inner-music-filter pred? e)
49 (filtered-es (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) es))))
50 (set! (ly:music-property music 'element) filtered-e)
51 (set! (ly:music-property music 'elements) filtered-es)
52 (set! (ly:music-property music 'articulations) filtered-as)
53 ;; if filtering emptied the expression, we remove it completely.
54 (if (or (not (pred? music))
55 (and (eq? filtered-es '()) (not (ly:music? e))
56 (or (not (eq? es '()))
61 (set! music (inner-music-filter pred? music))
64 (make-music 'Music))) ;must return music.
66 (define-public (display-music music)
67 "Display music, not done with music-map for clarity of presentation."
70 (let ((es (ly:music-property music 'elements))
71 (e (ly:music-property music 'element)))
72 (display (ly:music-mutable-properties music))
74 (begin (display "\nElements: {\n")
75 (map display-music es)
84 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
86 (define (shift-one-duration-log music shift dot)
87 " add SHIFT to ly:duration-log and optionally
88 a dot to any note encountered. This scales the music up by a factor
89 2^shift * (2 - (1/2)^dot)"
90 (let ((d (ly:music-property music 'duration)))
92 (let* ((cp (ly:duration-factor d))
93 (nd (ly:make-duration (+ shift (ly:duration-log d))
94 (+ dot (ly:duration-dot-count d))
97 (set! (ly:music-property music 'duration) nd)))
102 (define-public (shift-duration-log music shift dot)
103 (music-map (lambda (x) (shift-one-duration-log x shift dot))
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 (define-public (note-to-cluster music)
110 "Replace NoteEvents by ClusterNoteEvents."
111 (if (eq? (ly:music-property music 'name) 'NoteEvent)
112 (make-music 'ClusterNoteEvent
113 'pitch (ly:music-property music 'pitch)
114 'duration (ly:music-property music 'duration))
117 (define-public (notes-to-clusters music)
118 (music-map note-to-cluster music))
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 (define-public (unfold-repeats music)
125 This function replaces all repeats with unfold repeats. "
127 (let ((es (ly:music-property music 'elements))
128 (e (ly:music-property music 'element))
130 (if (memq 'repeated-music (ly:music-property music 'types))
132 (if (equal? (ly:music-property music 'iterator-ctor)
133 Chord_tremolo_iterator::constructor)
134 (let* ((seq-arg? (memq 'sequential-music
135 (ly:music-property e 'types)))
136 (count (ly:music-property music 'repeat-count))
137 (dot-shift (if (= 0 (remainder count 3))
141 (set! count (* 2 (quotient count 3))))
143 (shift-duration-log music (+ (if seq-arg? 1 0)
144 (ly:intlog2 count)) dot-shift)
147 (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1)))))
149 (set! (ly:music-property music 'length-callback)
150 Repeated_music::unfolded_music_length)
151 (set! (ly:music-property music 'start-callback)
152 Repeated_music::first_start)
153 (set! (ly:music-property music 'iterator-ctor)
154 Unfolded_repeat_iterator::constructor)))
157 (set! (ly:music-property music 'elements)
158 (map unfold-repeats es)))
160 (set! (ly:music-property music 'element)
164 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165 ;; property setting music objs.
167 (define-public (make-grob-property-set grob gprop val)
168 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
169 i.e. this is not an override"
170 (make-music 'OverrideProperty
176 (define-public (make-grob-property-override grob gprop val)
177 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
178 i.e. this is not an override"
179 (make-music 'OverrideProperty
184 (define-public (make-grob-property-revert grob gprop)
185 "Revert the grob property GPROP for GROB."
186 (make-music 'OverrideProperty
188 'grob-property gprop))
190 (define direction-polyphonic-grobs
191 '(Stem Tie Rest Slur Script TextScript Dots DotColumn Fingering))
193 (define-public (make-voice-props-set n)
194 (make-sequential-music
196 (map (lambda (x) (make-grob-property-set x 'direction
198 direction-polyphonic-grobs)
200 (make-grob-property-set 'NoteColumn 'horizontal-shift (quotient n 2))
201 (make-grob-property-set 'MultiMeasureRest 'staff-position (if (odd? n) -4 4))))))
203 (define-public (make-voice-props-revert)
204 (make-sequential-music
206 (map (lambda (x) (make-grob-property-revert x 'direction))
207 direction-polyphonic-grobs)
208 (list (make-grob-property-revert 'NoteColumn 'horizontal-shift))
209 (list (make-grob-property-revert 'MultiMeasureRest 'staff-position)))))
212 (define*-public (context-spec-music m context #:optional id)
213 "Add \\context CONTEXT = ID to M. "
214 (let ((cm (make-music 'ContextSpeccedMusic
216 'context-type context)))
218 (set! (ly:music-property cm 'context-id) id))
221 (define-public (descend-to-context m context)
222 "Like context-spec-music, but only descending. "
223 (let ((cm (context-spec-music m context)))
224 (ly:music-set-property! cm 'descend-only #t)
227 (define-public (make-non-relative-music mus)
228 (make-music 'UnrelativableMusic
231 (define-public (make-apply-context func)
232 (make-music 'ApplyContext
235 (define-public (make-sequential-music elts)
236 (make-music 'SequentialMusic
239 (define-public (make-simultaneous-music elts)
240 (make-music 'SimultaneousMusic
243 (define-public (make-event-chord elts)
244 (make-music 'EventChord
247 (define-public (make-skip-music dur)
248 (make-music 'SkipMusic
251 (define-public (make-grace-music music)
252 (make-music 'GraceMusic
258 (define-public (make-multi-measure-rest duration location)
259 (make-music 'MultiMeasureRestMusicGroup
261 'elements (list (make-music 'BarCheck
263 (make-event-chord (list (make-music 'MultiMeasureRestEvent
265 'duration duration)))
266 (make-music 'BarCheck
269 (define-public (glue-mm-rest-texts music)
270 "Check if we have R1*4-\\markup { .. }, and if applicable convert to
271 a property set for MultiMeasureRestNumber."
272 (define (script-to-mmrest-text script-music)
273 "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets."
274 (let ((dir (ly:music-property script-music 'direction))
275 (p (make-music 'MultiMeasureTextEvent
276 'text (ly:music-property script-music 'text))))
278 (set! (ly:music-property p 'direction) dir))
280 (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
281 (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
282 (es (ly:music-property music 'elements))
283 (texts (map script-to-mmrest-text (filter text? es)))
284 (others (remove text? es)))
286 (set! (ly:music-property music 'elements)
287 (cons (make-event-chord texts) others)))))
291 (define-public (make-property-set sym val)
292 (make-music 'PropertySet
296 (define-public (make-ottava-set octavation)
297 (let ((m (make-music 'ApplyContext)))
298 (define (ottava-modify context)
299 "Either reset middleCPosition to the stored original, or remember
300 old middleCPosition, add OCTAVATION to middleCPosition, and set
301 OTTAVATION to `8va', or whatever appropriate."
302 (if (number? (ly:context-property context 'middleCPosition))
304 (let ((where (ly:context-property-where-defined context 'middleCPosition))
305 (oc0 (ly:context-property context 'originalCentralCPosition)))
306 (ly:context-set-property! context 'middleCPosition oc0)
307 (ly:context-unset-property where 'originalCentralCPosition)
308 (ly:context-unset-property where 'ottavation))
309 (let* ((where (ly:context-property-where-defined context 'middleCPosition))
310 (c0 (ly:context-property context 'middleCPosition))
311 (new-c0 (+ c0 (* -7 octavation)))
312 (string (cdr (assoc octavation '((2 . "15ma")
316 (-2 . "15ma bassa"))))))
317 (ly:context-set-property! context 'middleCPosition new-c0)
318 (ly:context-set-property! context 'originalCentralCPosition c0)
319 (ly:context-set-property! context 'ottavation string)))))
320 (set! (ly:music-property m 'procedure) ottava-modify)
321 (context-spec-music m 'Staff)))
323 (define-public (set-octavation ottavation)
324 (ly:export (make-ottava-set ottavation)))
326 (define-public (make-time-signature-set num den . rest)
327 "Set properties for time signature NUM/DEN. Rest can contain a list
329 (let* ((set1 (make-property-set 'timeSignatureFraction (cons num den)))
330 (beat (ly:make-moment 1 den))
331 (len (ly:make-moment num den))
332 (set2 (make-property-set 'beatLength beat))
333 (set3 (make-property-set 'measureLength len))
334 (set4 (make-property-set 'beatGrouping (if (pair? rest)
337 (basic (list set1 set2 set3 set4)))
339 (context-spec-music (make-sequential-music basic) 'Timing) 'Score)))
341 (define-public (make-mark-set label)
342 "Make the music for the \\mark command."
343 (let* ((set (if (integer? label)
344 (context-spec-music (make-property-set 'rehearsalMark label)
347 (ev (make-music 'MarkEvent))
348 (ch (make-event-chord (list ev))))
350 (make-sequential-music (list set ch))
352 (set! (ly:music-property ev 'label) label)
355 (define-public (set-time-signature num den . rest)
356 (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
358 (define-public (make-penalty-music pen page-pen)
359 (make-music 'BreakEvent
361 'page-penalty page-pen))
363 (define-public (make-articulation name)
364 (make-music 'ArticulationEvent
365 'articulation-type name))
367 (define-public (make-lyric-event string duration)
368 (make-music 'LyricEvent
372 (define-public (make-span-event type spandir)
374 'span-direction spandir))
376 (define-public (set-mus-properties! m alist)
377 "Set all of ALIST as properties of M."
380 (set! (ly:music-property m (caar alist)) (cdar alist))
381 (set-mus-properties! m (cdr alist)))))
383 (define-public (music-separator? m)
385 (let ((ts (ly:music-property m 'types)))
386 (memq 'separator ts)))
388 ;;; splitting chords into voices.
389 (define (voicify-list lst number)
390 "Make a list of Musics.
392 voicify-list :: [ [Music ] ] -> number -> [Music]
393 LST is a list music-lists.
395 NUMBER is 0-base, i.e. Voice=1 (upstems) has number 0.
399 (cons (context-spec-music
400 (make-sequential-music
401 (list (make-voice-props-set number)
402 (make-simultaneous-music (car lst))))
403 'Voice (number->string (1+ number)))
404 (voicify-list (cdr lst) (1+ number)))))
406 (define (voicify-chord ch)
407 "Split the parts of a chord into different Voices using separator"
408 (let ((es (ly:music-property ch 'elements)))
409 (set! (ly:music-property ch 'elements)
410 (voicify-list (split-list es music-separator?) 0))
413 (define-public (voicify-music m)
414 "Recursively split chords that are separated with \\ "
415 (if (not (ly:music? m))
417 (error "not music!")))
418 (let ((es (ly:music-property m 'elements))
419 (e (ly:music-property m 'element)))
421 (display (ly:music-property m 'name))
424 (set! (ly:music-property m 'elements) (map voicify-music es)))
426 (set! (ly:music-property m 'element) (voicify-music e)))
427 (if (and (equal? (ly:music-property m 'name) 'SimultaneousMusic)
428 (reduce (lambda (x y ) (or x y)) #f (map music-separator? es)))
429 (set! m (context-spec-music (voicify-chord m) 'Staff)))
432 (define-public (empty-music)
433 (ly:export (make-music 'Music)))
436 ; Make a function that checks score element for being of a specific type.
437 (define-public (make-type-checker symbol)
440 ;;(eq? #t (ly:grob-property elt symbol))
441 (not (eq? #f (memq symbol (ly:grob-property elt 'interfaces))))))
443 (define-public ((outputproperty-compatibility func sym val) grob g-context ao-context)
445 (set! (ly:grob-property grob sym) val)))
448 (define-public ((set-output-property grob-name symbol val) grob grob-c context)
451 \\applyoutput #(set-output-property 'Clef 'extra-offset '(0 . 1))
454 (let ((meta (ly:grob-property grob 'meta)))
455 (if (equal? (cdr (assoc 'name meta)) grob-name)
456 (set! (ly:grob-property grob symbol) val))))
460 (define-public (smart-bar-check n)
461 "Make a bar check that checks for a specific bar number.
463 (let ((m (make-music 'ApplyContext)))
465 (let* ((bn (ly:context-property tr 'currentBarNumber)))
469 (format "Bar check failed, we should have reached ~a, instead at ~a\n"
471 (set! (ly:music-property m 'procedure) checker)
474 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
475 ;; warn for bare chords at start.
477 (define (has-request-chord elts)
478 (reduce (lambda (x y) (or x y)) #f
480 (equal? (ly:music-property x 'name) 'RequestChord))
483 (define (ly:music-message music msg)
484 (let ((ip (ly:music-property music 'origin)))
485 (if (ly:input-location? ip)
486 (ly:input-message ip msg)
489 (define (check-start-chords music)
490 "Check music expression for a Simultaneous_music containing notes\n(ie. Request_chords),
491 without context specification. Called from parser."
492 (let ((es (ly:music-property music 'elements))
493 (e (ly:music-property music 'element))
494 (name (ly:music-property music 'name)))
495 (cond ((equal? name "Context_specced_music") #t)
496 ((equal? name "Simultaneous_music")
497 (if (has-request-chord es)
498 (ly:music-message music "Starting score with a chord.\nPlease insert an explicit \\context before chord")
499 (map check-start-chords es)))
500 ((equal? name "SequentialMusic")
502 (check-start-chords (car es))))
503 (else (if (ly:music? e) (check-start-chords e)))))
508 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
510 ;; setting stuff for grace context.
513 (define (vector-extend v x)
514 "Make a new vector consisting of V, with X added to the end."
515 (let* ((n (vector-length v))
516 (nv (make-vector (+ n 1) '())))
517 (vector-move-left! v 0 n nv 0)
521 (define (vector-map f v)
522 "Map F over V. This function returns nothing."
523 (do ((n (vector-length v))
526 (f (vector-ref v i))))
528 (define (vector-reverse-map f v)
529 "Map F over V, N to 0 order. This function returns nothing."
530 (do ((i (- (vector-length v) 1) (- i 1)))
532 (f (vector-ref v i))))
534 ;; TODO: make a remove-grace-property too.
535 (define-public (add-grace-property context-name grob sym val)
536 "Set SYM=VAL for GROB in CONTEXT-NAME. "
537 (define (set-prop context)
538 (let* ((where (ly:context-property-where-defined context 'graceSettings))
539 (current (ly:context-property where 'graceSettings))
540 (new-settings (append current
541 (list (list context-name grob sym val)))))
542 (ly:context-set-property! where 'graceSettings new-settings)))
543 (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
547 (defmacro-public def-grace-function (start stop)
548 `(def-music-function (parser location music) (ly:music?)
549 (make-music 'GraceMusic
551 'element (make-music 'SequentialMusic
552 'elements (list (ly:music-deep-copy ,start)
554 (ly:music-deep-copy ,stop))))))
556 (defmacro-public def-music-function (args signature . body)
557 "Helper macro for `ly:make-music-function'.
559 (def-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
562 `(ly:make-music-function (list ,@signature)
567 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
569 (define-public (cue-substitute quote-music)
570 "Must happen after quote-substitute."
572 (if (vector? (ly:music-property quote-music 'quoted-events))
573 (let* ((dir (ly:music-property quote-music 'quoted-voice-direction))
574 (main-voice (if (eq? 1 dir) 1 0))
575 (cue-voice (if (eq? 1 dir) 0 1))
576 (main-music (ly:music-property quote-music 'element))
577 (return-value quote-music))
579 (if (or (eq? 1 dir) (eq? -1 dir))
581 ;; if we have stem dirs, change both quoted and main music
582 ;; to have opposite stems.
586 ;; cannot context-spec Quote-music, since context
587 ;; for the quotes is determined in the iterator.
588 (make-sequential-music
590 (context-spec-music (make-voice-props-set cue-voice) 'Voice "cue")
592 (context-spec-music (make-voice-props-revert) 'Voice "cue"))))
594 (make-sequential-music
596 (make-voice-props-set main-voice)
598 (make-voice-props-revert))))
599 (set! (ly:music-property quote-music 'element) main-music)))
604 (define-public ((quote-substitute quote-tab) music)
605 (let* ((quoted-name (ly:music-property music 'quoted-music-name))
606 (quoted-vector (if (string? quoted-name)
607 (hash-ref quote-tab quoted-name #f)
610 (if (string? quoted-name)
611 (if (vector? quoted-vector)
612 (set! (ly:music-property music 'quoted-events) quoted-vector)
613 (ly:warn "Cannot find quoted music `~S'" quoted-name)))
618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
619 ;; switch it on here, so parsing and init isn't checked (too slow!)
621 ;; automatic music transformations.
623 (define (switch-on-debugging m)
624 (if (defined? 'set-debug-cell-accesses!)
625 (set-debug-cell-accesses! 15000))
628 (define (music-check-error music)
631 (if (and (ly:music? m)
632 (eq? (ly:music-property m 'error-found) #t))
635 (for-each signal (ly:music-property music 'elements))
636 (signal (ly:music-property music 'element))
639 (set! (ly:music-property music 'error-found) #t))
642 (define (precompute-music-length music)
643 (set! (ly:music-property music 'length)
644 (ly:music-length music))
647 (define-public toplevel-music-functions
649 ;; check-start-chords ; ; no longer needed with chord syntax.
650 (lambda (music parser) (voicify-music music))
651 (lambda (x parser) (music-map glue-mm-rest-texts x))
652 (lambda (x parser) (music-map music-check-error x))
653 (lambda (x parser) (music-map precompute-music-length x))
654 (lambda (music parser)
656 (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes)) music))
657 ;; switch-on-debugging
658 (lambda (x parser) (music-map cue-substitute x))))
663 (define (apply-durations lyric-music durations)
664 (define (apply-duration music)
665 (if (and (not (equal? (ly:music-length music) ZERO-MOMENT))
666 (ly:duration? (ly:music-property music 'duration)))
668 (set! (ly:music-property music 'duration) (car durations))
669 (set! durations (cdr durations)))))
671 (music-map apply-duration lyric-music))
674 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
677 (define-public ((add-balloon-text object-name text off) grob orig-context cur-context)
678 "Usage: see input/regression/balloon.ly "
679 (let* ((meta (ly:grob-property grob 'meta))
680 (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant"))
681 (cb (ly:grob-property grob 'print-function)))
682 (if (equal? nm object-name)
684 (set! (ly:grob-property grob 'print-function) Balloon_interface::print)
685 (set! (ly:grob-property grob 'balloon-original-callback) cb)
686 (set! (ly:grob-property grob 'balloon-text) text)
687 (set! (ly:grob-property grob 'balloon-text-offset) off)
688 (set! (ly:grob-property grob 'balloon-text-props) '((font-family . roman)))))))
690 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
693 (define-public (set-accidentals-properties extra-natural
697 (make-sequential-music
698 (append (if (boolean? extra-natural)
699 (list (make-property-set 'extraNatural extra-natural))
701 (list (make-property-set 'autoAccidentals auto-accs)
702 (make-property-set 'autoCautionaries auto-cauts))))
705 (define-public (set-accidental-style style . rest)
706 "Set accidental style to STYLE. Optionally takes a context argument,
707 e.g. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which
708 use GrandStaff as a context. "
709 (let ((context (if (pair? rest)
711 (pcontext (if (pair? rest)
712 (car rest) 'GrandStaff)))
715 ;; accidentals as they were common in the 18th century.
716 ((equal? style 'default)
717 (set-accidentals-properties #t '(Staff (same-octave . 0))
719 ;; accidentals from one voice do NOT get cancelled in other voices
720 ((equal? style 'voice)
721 (set-accidentals-properties #t '(Voice (same-octave . 0))
723 ;; accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
724 ;; This includes all the default accidentals, but accidentals also needs cancelling
725 ;; in other octaves and in the next measure.
726 ((equal? style 'modern)
727 (set-accidentals-properties #f '(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
729 ;; the accidentals that Stone adds to the old standard as cautionaries
730 ((equal? style 'modern-cautionary)
731 (set-accidentals-properties #f '(Staff (same-octave . 0))
732 '(Staff (any-octave . 0) (same-octave . 1))
734 ;; Multivoice accidentals to be read both by musicians playing one voice
735 ;; and musicians playing all voices.
736 ;; Accidentals are typeset for each voice, but they ARE cancelled across voices.
737 ((equal? style 'modern-voice)
738 (set-accidentals-properties #f
739 '(Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
740 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
743 ;; same as modernVoiceAccidental eccept that all special accidentals are typeset
745 ((equal? style 'modern-voice-cautionary)
746 (set-accidentals-properties #f
747 '(Voice (same-octave . 0))
748 '(Voice (any-octave . 0) (same-octave . 1)
749 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
751 ;; stone's suggestions for accidentals on grand staff.
752 ;; Accidentals are cancelled across the staves in the same grand staff as well
753 ((equal? style 'piano)
754 (set-accidentals-properties #f
755 '(Staff (same-octave . 0)
756 (any-octave . 0) (same-octave . 1)
757 GrandStaff (any-octave . 0) (same-octave . 1))
760 ((equal? style 'piano-cautionary)
761 (set-accidentals-properties #f
762 '(Staff (same-octave . 0))
763 '(Staff (any-octave . 0) (same-octave . 1)
764 GrandStaff (any-octave . 0) (same-octave . 1))
766 ;; do not set localKeySignature when a note alterated differently from
767 ;; localKeySignature is found.
768 ;; Causes accidentals to be printed at every note instead of
769 ;; remembered for the duration of a measure.
770 ;; accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
771 ((equal? style 'forget)
772 (set-accidentals-properties '()
773 '(Staff (same-octave . -1))
775 ;; Do not reset the key at the start of a measure. Accidentals will be
776 ;; printed only once and are in effect until overridden, possibly many
778 ((equal? style 'no-reset)
779 (set-accidentals-properties '()
780 '(Staff (same-octave . #t))
784 (ly:warn "Unknown accidental style: ~S" (symbol->string style))
785 (make-sequential-music '()))))))
787 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
789 (define-public (skip-of-length mus)
790 "Create a skip of exactly the same length as MUS."
794 'duration (ly:make-duration 0 0))))
796 (make-event-chord (list (ly:music-compress skip (ly:music-length mus))))))
798 (define-public (mmrest-of-length mus)
799 "Create a mmrest of exactly the same length as MUS."
802 (make-multi-measure-rest
803 (ly:make-duration 0 0) '())))
804 (ly:music-compress skip (ly:music-length mus))