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. "
25 (let ((es (ly:music-property music 'elements))
26 (e (ly:music-property music 'element)))
27 (set! (ly:music-property music 'elements)
28 (map (lambda (y) (music-map function y)) es))
30 (set! (ly:music-property music 'element)
31 (music-map function e)))
34 (define-public (music-filter pred? music)
35 "Filter out music expressions that do not satisfy PRED."
37 (define (inner-music-filter pred? music)
39 (let* ((es (ly:music-property music 'elements))
40 (e (ly:music-property music 'element))
41 (as (ly:music-property music 'articulations))
42 (filtered-as (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) as)))
43 (filtered-e (if (ly:music? e)
44 (inner-music-filter pred? e)
46 (filtered-es (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) es))))
47 (set! (ly:music-property music 'element) filtered-e)
48 (set! (ly:music-property music 'elements) filtered-es)
49 (set! (ly:music-property music 'articulations) filtered-as)
50 ;; if filtering emptied the expression, we remove it completely.
51 (if (or (not (pred? music))
52 (and (eq? filtered-es '()) (not (ly:music? e))
53 (or (not (eq? es '()))
58 (set! music (inner-music-filter pred? music))
61 (make-music 'Music))) ;must return music.
64 (define-public (display-music music)
65 "Display music, not done with music-map for clarity of presentation."
68 (let ((es (ly:music-property music 'elements))
69 (e (ly:music-property music 'element)))
70 (display (ly:music-mutable-properties music))
72 (begin (display "\nElements: {\n")
73 (map display-music es)
83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
85 (define (shift-one-duration-log music shift dot)
86 " add SHIFT to ly:duration-log and optionally
87 a dot to any note encountered. This scales the music up by a factor
88 2^shift * (2 - (1/2)^dot)"
89 (let ((d (ly:music-property music 'duration)))
91 (let* ((cp (ly:duration-factor d))
92 (nd (ly:make-duration (+ shift (ly:duration-log d))
93 (+ dot (ly:duration-dot-count d))
96 (set! (ly:music-property music 'duration) nd)))
101 (define-public (shift-duration-log music shift dot)
102 (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))
129 (n (ly:music-name music)))
130 (if (equal? n "Repeated_music")
133 (if (equal? (ly:music-property music 'iterator-ctor)
134 Chord_tremolo_iterator::constructor)
136 ((seq-arg? (memq 'sequential-music
137 (ly:music-property e 'types)))
138 (count (ly:music-property music 'repeat-count))
139 (dot-shift (if (= 0 (remainder count 3))
144 (set! count (* 2 (quotient count 3))))
146 (shift-duration-log music (+ (if seq-arg? 1 0)
147 (ly:intlog2 count)) dot-shift)
150 (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1)))
153 (set! (ly:music-property music 'length)
154 Repeated_music::unfolded_music_length)
155 (set! (ly:music-property music 'start-moment-function)
156 Repeated_music::first_start)
157 (set! (ly:music-property music 'iterator-ctor)
158 Unfolded_repeat_iterator::constructor)))
161 (set! (ly:music-property music 'elements)
162 (map unfold-repeats es)))
164 (set! (ly:music-property music 'element)
169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
170 ;; property setting music objs.
172 (define-public (make-grob-property-set grob gprop val)
173 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
174 i.e. this is not an override"
175 (make-music 'OverrideProperty
181 (define-public (make-grob-property-override grob gprop val)
182 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
183 i.e. this is not an override"
184 (make-music 'OverrideProperty
189 (define-public (make-grob-property-revert grob gprop)
190 "Revert the grob property GPROP for GROB."
191 (make-music 'OverrideProperty
193 'grob-property gprop))
195 (define direction-polyphonic-grobs
196 '(Stem Tie Rest Slur Script TextScript Dots DotColumn Fingering
199 (define-public (make-voice-props-set n)
200 (make-sequential-music
202 (map (lambda (x) (make-grob-property-set x 'direction
204 direction-polyphonic-grobs)
206 (make-grob-property-set 'NoteColumn 'horizontal-shift (quotient n 2))
207 (make-grob-property-set 'MultiMeasureRest 'staff-position (if (odd? n) -4 4))
212 (define-public (make-voice-props-revert)
213 (make-sequential-music
215 (map (lambda (x) (make-grob-property-revert x 'direction))
216 direction-polyphonic-grobs)
217 (list (make-grob-property-revert 'NoteColumn 'horizontal-shift))
218 (list (make-grob-property-revert 'MultiMeasureRest 'staff-position)))))
221 (define*-public (context-spec-music m context #:optional id)
222 "Add \\context CONTEXT = ID to M. "
223 (let ((cm (make-music 'ContextSpeccedMusic
225 'context-type context)))
227 (set! (ly:music-property cm 'context-id) id))
231 (define-public (descend-to-context m context)
232 "Like context-spec-music, but only descending. "
233 (let ((cm (context-spec-music m context)))
234 (ly:music-set-property! cm 'descend-only #t)
237 (define-public (make-non-relative-music mus)
238 (make-music 'UnrelativableMusic
242 (define-public (make-apply-context func)
243 (make-music 'ApplyContext
246 (define-public (make-sequential-music elts)
247 (make-music 'SequentialMusic
250 (define-public (make-simultaneous-music elts)
251 (make-music 'SimultaneousMusic
254 (define-public (make-event-chord elts)
255 (make-music 'EventChord
258 (define-public (make-skip-music dur)
259 (make-music 'SkipMusic
262 (define-public (make-grace-music music)
263 (make-music 'GraceMusic
269 (define-public (make-multi-measure-rest duration location)
270 (make-music 'MultiMeasureRestMusicGroup
272 'elements (list (make-music 'BarCheck
274 (make-event-chord (list (make-music 'MultiMeasureRestEvent
276 'duration duration)))
277 (make-music 'BarCheck
280 (define-public (glue-mm-rest-texts music)
281 "Check if we have R1*4-\\markup { .. }, and if applicable convert to
282 a property set for MultiMeasureRestNumber."
283 (define (script-to-mmrest-text script-music)
284 "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets."
285 (let ((dir (ly:music-property script-music 'direction))
286 (p (make-music 'MultiMeasureTextEvent
287 'text (ly:music-property script-music 'text))))
289 (set! (ly:music-property p 'direction) dir))
291 (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
292 (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
293 (es (ly:music-property music 'elements))
294 (texts (map script-to-mmrest-text (filter text? es)))
295 (others (remove text? es)))
297 (set! (ly:music-property music 'elements)
298 (cons (make-event-chord texts) others)))))
302 (define-public (make-property-set sym val)
303 (make-music 'PropertySet
307 (define-public (make-ottava-set octavation)
308 (let ((m (make-music 'ApplyContext)))
309 (define (ottava-modify context)
310 "Either reset middleCPosition to the stored original, or remember
311 old middleCPosition, add OCTAVATION to middleCPosition, and set
312 OTTAVATION to `8va', or whatever appropriate."
313 (if (number? (ly:context-property context 'middleCPosition))
315 (let ((where (ly:context-property-where-defined context 'middleCPosition))
316 (oc0 (ly:context-property context 'originalCentralCPosition)))
317 (ly:context-set-property! context 'middleCPosition oc0)
318 (ly:context-unset-property where 'originalCentralCPosition)
319 (ly:context-unset-property where 'ottavation))
320 (let* ((where (ly:context-property-where-defined context 'middleCPosition))
321 (c0 (ly:context-property context 'middleCPosition))
322 (new-c0 (+ c0 (* -7 octavation)))
323 (string (cdr (assoc octavation '((2 . "15ma")
327 (-2 . "15ma bassa"))))))
328 (ly:context-set-property! context 'middleCPosition new-c0)
329 (ly:context-set-property! context 'originalCentralCPosition c0)
330 (ly:context-set-property! context 'ottavation string)))))
331 (set! (ly:music-property m 'procedure) ottava-modify)
332 (context-spec-music m 'Staff)))
334 (define-public (set-octavation ottavation)
335 (ly:export (make-ottava-set ottavation)))
337 (define-public (make-time-signature-set num den . rest)
338 "Set properties for time signature NUM/DEN. Rest can contain a list
340 (let* ((set1 (make-property-set 'timeSignatureFraction (cons num den)))
341 (beat (ly:make-moment 1 den))
342 (len (ly:make-moment num den))
343 (set2 (make-property-set 'beatLength beat))
344 (set3 (make-property-set 'measureLength len))
345 (set4 (make-property-set 'beatGrouping (if (pair? rest)
348 (basic (list set1 set2 set3 set4)))
350 (context-spec-music (make-sequential-music basic) 'Timing) 'Score)))
352 (define-public (make-mark-set label)
353 "Make the music for the \\mark command."
354 (let* ((set (if (integer? label)
355 (context-spec-music (make-property-set 'rehearsalMark label)
358 (ev (make-music 'MarkEvent))
359 (ch (make-event-chord (list ev))))
361 (make-sequential-music (list set ch))
363 (set! (ly:music-property ev 'label) label)
366 (define-public (set-time-signature num den . rest)
367 (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
369 (define-public (make-penalty-music pen page-pen)
370 (make-music 'BreakEvent
372 'page-penalty page-pen))
374 (define-public (make-articulation name)
375 (make-music 'ArticulationEvent
376 'articulation-type name))
378 (define-public (make-lyric-event string duration)
379 (make-music 'LyricEvent
383 (define-public (make-span-event type spandir)
385 'span-direction spandir))
387 (define-public (set-mus-properties! m alist)
388 "Set all of ALIST as properties of M."
391 (set! (ly:music-property m (caar alist)) (cdar alist))
392 (set-mus-properties! m (cdr alist)))))
394 (define-public (music-separator? m)
396 (let ((ts (ly:music-property m 'types)))
397 (memq 'separator ts)))
400 ;;; splitting chords into voices.
401 (define (voicify-list lst number)
402 "Make a list of Musics.
404 voicify-list :: [ [Music ] ] -> number -> [Music]
405 LST is a list music-lists.
407 NUMBER is 0-base, i.e. Voice=1 (upstems) has number 0.
411 (cons (context-spec-music
412 (make-sequential-music
413 (list (make-voice-props-set number)
414 (make-simultaneous-music (car lst))))
415 'Voice (number->string (1+ number)))
416 (voicify-list (cdr lst) (1+ number)))))
418 (define (voicify-chord ch)
419 "Split the parts of a chord into different Voices using separator"
420 (let ((es (ly:music-property ch 'elements)))
421 (set! (ly:music-property ch 'elements)
422 (voicify-list (split-list es music-separator?) 0))
425 (define-public (voicify-music m)
426 "Recursively split chords that are separated with \\ "
427 (if (not (ly:music? m))
429 (error "not music!")))
430 (let ((es (ly:music-property m 'elements))
431 (e (ly:music-property m 'element)))
433 (set! (ly:music-property m 'elements) (map voicify-music es)))
435 (set! (ly:music-property m 'element) (voicify-music e)))
436 (if (and (equal? (ly:music-name m) "Simultaneous_music")
437 (reduce (lambda (x y ) (or x y)) #f (map music-separator? es)))
438 (set! m (context-spec-music (voicify-chord m) 'Staff)))
441 (define-public (empty-music)
442 (ly:export (make-music 'Music)))
445 ; Make a function that checks score element for being of a specific type.
446 (define-public (make-type-checker symbol)
449 ;;(eq? #t (ly:grob-property elt symbol))
450 (not (eq? #f (memq symbol (ly:grob-property elt 'interfaces))))))
452 (define-public ((outputproperty-compatibility func sym val) grob g-context ao-context)
454 (set! (ly:grob-property grob sym) val)))
457 (define-public ((set-output-property grob-name symbol val) grob grob-c context)
460 \\applyoutput #(set-output-property 'Clef 'extra-offset '(0 . 1))
463 (let ((meta (ly:grob-property grob 'meta)))
464 (if (equal? (cdr (assoc 'name meta)) grob-name)
465 (set! (ly:grob-property grob symbol) val))))
469 (define-public (smart-bar-check n)
470 "Make a bar check that checks for a specific bar number.
472 (let ((m (make-music 'ApplyContext)))
474 (let* ((bn (ly:context-property tr 'currentBarNumber)))
478 (format "Bar check failed, we should have reached ~a, instead at ~a\n"
480 (set! (ly:music-property m 'procedure) checker)
483 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
484 ;; warn for bare chords at start.
486 (define (has-request-chord elts)
487 (reduce (lambda (x y) (or x y)) #f
489 (equal? (ly:music-name x) "Request_chord"))
492 (define (ly:music-message music msg)
493 (let ((ip (ly:music-property music 'origin)))
494 (if (ly:input-location? ip)
495 (ly:input-message ip msg)
498 (define (check-start-chords music)
499 "Check music expression for a Simultaneous_music containing notes\n(ie. Request_chords),
500 without context specification. Called from parser."
501 (let ((es (ly:music-property music 'elements))
502 (e (ly:music-property music 'element))
503 (name (ly:music-name music)))
504 (cond ((equal? name "Context_specced_music") #t)
505 ((equal? name "Simultaneous_music")
506 (if (has-request-chord es)
507 (ly:music-message music "Starting score with a chord.\nPlease insert an explicit \\context before chord")
508 (map check-start-chords es)))
509 ((equal? name "Sequential_music")
511 (check-start-chords (car es))))
512 (else (if (ly:music? e) (check-start-chords e)))))
517 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
519 ;; setting stuff for grace context.
522 (define (vector-extend v x)
523 "Make a new vector consisting of V, with X added to the end."
525 ((n (vector-length v))
526 (nv (make-vector (+ n 1) '())))
527 (vector-move-left! v 0 n nv 0)
531 (define (vector-map f v)
532 "Map F over V. This function returns nothing."
533 (do ((n (vector-length v))
536 (f (vector-ref v i))))
538 (define (vector-reverse-map f v)
539 "Map F over V, N to 0 order. This function returns nothing."
540 (do ((i (- (vector-length v) 1) (- i 1)))
542 (f (vector-ref v i))))
544 ;; TODO: make a remove-grace-property too.
545 (define-public (add-grace-property context-name grob sym val)
546 "Set SYM=VAL for GROB in CONTEXT-NAME. "
547 (define (set-prop context)
548 (let* ((where (ly:context-property-where-defined context 'graceSettings))
549 (current (ly:context-property where 'graceSettings))
550 (new-settings (append current
551 (list (list context-name grob sym val)))))
552 (ly:context-set-property! where 'graceSettings new-settings)))
553 (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
557 (defmacro-public def-grace-function (start stop)
558 `(def-music-function (parser location music) (ly:music?)
559 (make-music 'GraceMusic
561 'element (make-music 'SequentialMusic
562 'elements (list (ly:music-deep-copy ,start)
564 (ly:music-deep-copy ,stop))))))
566 (defmacro-public def-music-function (args signature . body)
567 "Helper macro for `ly:make-music-function'.
569 (def-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
572 `(ly:make-music-function (list ,@signature)
577 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
579 (define-public (cue-substitute quote-music)
580 "Must happen after quote-substitute."
582 (if (vector? (ly:music-property quote-music 'quoted-events))
584 ((dir (ly:music-property quote-music 'quoted-voice-direction))
585 (main-voice (if (eq? 1 dir) 1 0))
586 (cue-voice (if (eq? 1 dir) 0 1))
587 (main-music (ly:music-property quote-music 'element))
588 (return-value quote-music)
591 (if (or (eq? 1 dir) (eq? -1 dir))
593 ;; if we have stem dirs, change both quoted and main music
594 ;; to have opposite stems.
598 ;; cannot context-spec Quote-music, since context
599 ;; for the quotes is determined in the iterator.
600 (make-sequential-music
602 (context-spec-music (make-voice-props-set cue-voice) 'Voice "cue")
604 (context-spec-music (make-voice-props-revert) 'Voice "cue"))
607 (make-sequential-music
609 (make-voice-props-set main-voice)
611 (make-voice-props-revert)
613 (set! (ly:music-property quote-music 'element) main-music)
619 (define-public ((quote-substitute quote-tab) music)
621 ((quoted-name (ly:music-property music 'quoted-music-name))
622 (quoted-vector (if (string? quoted-name)
623 (hash-ref quote-tab quoted-name #f)
627 (if (string? quoted-name)
628 (if (vector? quoted-vector)
629 (set! (ly:music-property music 'quoted-events) quoted-vector)
630 (ly:warn "Cannot find quoted music `~S'" quoted-name)))
635 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
636 ;; switch it on here, so parsing and init isn't checked (too slow!)
638 ;; automatic music transformations.
640 (define (switch-on-debugging m)
641 (if (defined? 'set-debug-cell-accesses!)
642 (set-debug-cell-accesses! 15000))
645 (define (music-check-error music)
648 (if (and (ly:music? m)
649 (eq? (ly:music-property m 'error-found) #t))
652 (for-each signal (ly:music-property music 'elements))
653 (signal (ly:music-property music 'element))
656 (set! (ly:music-property music 'error-found) #t))
659 (define-public toplevel-music-functions
661 ;; check-start-chords ; ; no longer needed with chord syntax.
662 (lambda (music parser) (voicify-music music))
663 (lambda (x parser) (music-map glue-mm-rest-texts x))
664 (lambda (x parser) (music-map music-check-error x))
665 (lambda (music parser)
667 (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes)) music))
668 ;; switch-on-debugging
669 (lambda (x parser) (music-map cue-substitute x))
676 (define (apply-durations lyric-music durations)
677 (define (apply-duration music)
678 (if (and (not (equal? (ly:music-length music) ZERO-MOMENT))
679 (ly:duration? (ly:music-property music 'duration)))
681 (set! (ly:music-property music 'duration) (car durations))
682 (set! durations (cdr durations)))))
684 (music-map apply-duration lyric-music))
687 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
690 (define-public ((add-balloon-text object-name text off) grob orig-context cur-context)
691 "Usage: see input/regression/balloon.ly "
692 (let* ((meta (ly:grob-property grob 'meta))
693 (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant"))
694 (cb (ly:grob-property grob 'print-function)))
695 (if (equal? nm object-name)
697 (set! (ly:grob-property grob 'print-function) Balloon_interface::print)
698 (set! (ly:grob-property grob 'balloon-original-callback) cb)
699 (set! (ly:grob-property grob 'balloon-text) text)
700 (set! (ly:grob-property grob 'balloon-text-offset) off)
701 (set! (ly:grob-property grob 'balloon-text-props) '((font-family . roman)))))))
703 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
706 (define-public (set-accidentals-properties extra-natural
710 (make-sequential-music
711 (append (if (boolean? extra-natural)
712 (list (make-property-set 'extraNatural extra-natural))
714 (list (make-property-set 'autoAccidentals auto-accs)
715 (make-property-set 'autoCautionaries auto-cauts))))
718 (define-public (set-accidental-style style . rest)
719 "Set accidental style to STYLE. Optionally takes a context argument,
720 e.g. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which
721 use GrandStaff as a context. "
722 (let ((context (if (pair? rest)
724 (pcontext (if (pair? rest)
725 (car rest) 'GrandStaff)))
728 ;; accidentals as they were common in the 18th century.
729 ((equal? style 'default)
730 (set-accidentals-properties #t '(Staff (same-octave . 0))
732 ;; accidentals from one voice do NOT get cancelled in other voices
733 ((equal? style 'voice)
734 (set-accidentals-properties #t '(Voice (same-octave . 0))
736 ;; accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
737 ;; This includes all the default accidentals, but accidentals also needs cancelling
738 ;; in other octaves and in the next measure.
739 ((equal? style 'modern)
740 (set-accidentals-properties #f '(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
742 ;; the accidentals that Stone adds to the old standard as cautionaries
743 ((equal? style 'modern-cautionary)
744 (set-accidentals-properties #f '(Staff (same-octave . 0))
745 '(Staff (any-octave . 0) (same-octave . 1))
747 ;; Multivoice accidentals to be read both by musicians playing one voice
748 ;; and musicians playing all voices.
749 ;; Accidentals are typeset for each voice, but they ARE cancelled across voices.
750 ((equal? style 'modern-voice)
751 (set-accidentals-properties #f
752 '(Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
753 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
756 ;; same as modernVoiceAccidental eccept that all special accidentals are typeset
758 ((equal? style 'modern-voice-cautionary)
759 (set-accidentals-properties #f
760 '(Voice (same-octave . 0) )
761 '(Voice (any-octave . 0) (same-octave . 1)
762 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
764 ;; stone's suggestions for accidentals on grand staff.
765 ;; Accidentals are cancelled across the staves in the same grand staff as well
766 ((equal? style 'piano)
767 (set-accidentals-properties #f
768 '(Staff (same-octave . 0)
769 (any-octave . 0) (same-octave . 1)
770 GrandStaff (any-octave . 0) (same-octave . 1))
773 ((equal? style 'piano-cautionary)
774 (set-accidentals-properties #f
775 '(Staff (same-octave . 0))
776 '(Staff (any-octave . 0) (same-octave . 1)
777 GrandStaff (any-octave . 0) (same-octave . 1))
779 ;; do not set localKeySignature when a note alterated differently from
780 ;; localKeySignature is found.
781 ;; Causes accidentals to be printed at every note instead of
782 ;; remembered for the duration of a measure.
783 ;; accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
784 ((equal? style 'forget)
785 (set-accidentals-properties '()
786 '(Staff (same-octave . -1))
788 ;; Do not reset the key at the start of a measure. Accidentals will be
789 ;; printed only once and are in effect until overridden, possibly many
791 ((equal? style 'no-reset)
792 (set-accidentals-properties '()
793 '(Staff (same-octave . #t))
797 (ly:warn "Unknown accidental style: ~S" (symbol->string style))
798 (make-sequential-music '()))))))
800 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
802 (define-public (skip-of-length mus)
803 "Create a skip of exactly the same length as MUS."
808 'duration (ly:make-duration 0 0))))
810 (make-event-chord (list (ly:music-compress skip (ly:music-length mus))))
814 (define-public (mmrest-of-length mus)
815 "Create a mmrest of exactly the same length as MUS."
819 (make-multi-measure-rest
820 (ly:make-duration 0 0) '() )))
821 (ly:music-compress skip (ly:music-length mus))