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))
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)
135 (let* ((seq-arg? (memq 'sequential-music
136 (ly:music-property e 'types)))
137 (count (ly:music-property music 'repeat-count))
138 (dot-shift (if (= 0 (remainder count 3))
142 (set! count (* 2 (quotient count 3))))
144 (shift-duration-log music (+ (if seq-arg? 1 0)
145 (ly:intlog2 count)) dot-shift)
148 (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1)))))
150 (set! (ly:music-property music 'length)
151 Repeated_music::unfolded_music_length)
152 (set! (ly:music-property music 'start-moment-function)
153 Repeated_music::first_start)
154 (set! (ly:music-property music 'iterator-ctor)
155 Unfolded_repeat_iterator::constructor)))
158 (set! (ly:music-property music 'elements)
159 (map unfold-repeats es)))
161 (set! (ly:music-property music 'element)
165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166 ;; property setting music objs.
168 (define-public (make-grob-property-set grob gprop val)
169 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
170 i.e. this is not an override"
171 (make-music 'OverrideProperty
177 (define-public (make-grob-property-override grob gprop val)
178 "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
179 i.e. this is not an override"
180 (make-music 'OverrideProperty
185 (define-public (make-grob-property-revert grob gprop)
186 "Revert the grob property GPROP for GROB."
187 (make-music 'OverrideProperty
189 'grob-property gprop))
191 (define direction-polyphonic-grobs
192 '(Stem Tie Rest Slur Script TextScript Dots DotColumn Fingering))
194 (define-public (make-voice-props-set n)
195 (make-sequential-music
197 (map (lambda (x) (make-grob-property-set x 'direction
199 direction-polyphonic-grobs)
201 (make-grob-property-set 'NoteColumn 'horizontal-shift (quotient n 2))
202 (make-grob-property-set 'MultiMeasureRest 'staff-position (if (odd? n) -4 4))))))
204 (define-public (make-voice-props-revert)
205 (make-sequential-music
207 (map (lambda (x) (make-grob-property-revert x 'direction))
208 direction-polyphonic-grobs)
209 (list (make-grob-property-revert 'NoteColumn 'horizontal-shift))
210 (list (make-grob-property-revert 'MultiMeasureRest 'staff-position)))))
213 (define*-public (context-spec-music m context #:optional id)
214 "Add \\context CONTEXT = ID to M. "
215 (let ((cm (make-music 'ContextSpeccedMusic
217 'context-type context)))
219 (set! (ly:music-property cm 'context-id) id))
222 (define-public (descend-to-context m context)
223 "Like context-spec-music, but only descending. "
224 (let ((cm (context-spec-music m context)))
225 (ly:music-set-property! cm 'descend-only #t)
228 (define-public (make-non-relative-music mus)
229 (make-music 'UnrelativableMusic
232 (define-public (make-apply-context func)
233 (make-music 'ApplyContext
236 (define-public (make-sequential-music elts)
237 (make-music 'SequentialMusic
240 (define-public (make-simultaneous-music elts)
241 (make-music 'SimultaneousMusic
244 (define-public (make-event-chord elts)
245 (make-music 'EventChord
248 (define-public (make-skip-music dur)
249 (make-music 'SkipMusic
252 (define-public (make-grace-music music)
253 (make-music 'GraceMusic
259 (define-public (make-multi-measure-rest duration location)
260 (make-music 'MultiMeasureRestMusicGroup
262 'elements (list (make-music 'BarCheck
264 (make-event-chord (list (make-music 'MultiMeasureRestEvent
266 'duration duration)))
267 (make-music 'BarCheck
270 (define-public (glue-mm-rest-texts music)
271 "Check if we have R1*4-\\markup { .. }, and if applicable convert to
272 a property set for MultiMeasureRestNumber."
273 (define (script-to-mmrest-text script-music)
274 "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets."
275 (let ((dir (ly:music-property script-music 'direction))
276 (p (make-music 'MultiMeasureTextEvent
277 'text (ly:music-property script-music 'text))))
279 (set! (ly:music-property p 'direction) dir))
281 (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
282 (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
283 (es (ly:music-property music 'elements))
284 (texts (map script-to-mmrest-text (filter text? es)))
285 (others (remove text? es)))
287 (set! (ly:music-property music 'elements)
288 (cons (make-event-chord texts) others)))))
292 (define-public (make-property-set sym val)
293 (make-music 'PropertySet
297 (define-public (make-ottava-set octavation)
298 (let ((m (make-music 'ApplyContext)))
299 (define (ottava-modify context)
300 "Either reset middleCPosition to the stored original, or remember
301 old middleCPosition, add OCTAVATION to middleCPosition, and set
302 OTTAVATION to `8va', or whatever appropriate."
303 (if (number? (ly:context-property context 'middleCPosition))
305 (let ((where (ly:context-property-where-defined context 'middleCPosition))
306 (oc0 (ly:context-property context 'originalCentralCPosition)))
307 (ly:context-set-property! context 'middleCPosition oc0)
308 (ly:context-unset-property where 'originalCentralCPosition)
309 (ly:context-unset-property where 'ottavation))
310 (let* ((where (ly:context-property-where-defined context 'middleCPosition))
311 (c0 (ly:context-property context 'middleCPosition))
312 (new-c0 (+ c0 (* -7 octavation)))
313 (string (cdr (assoc octavation '((2 . "15ma")
317 (-2 . "15ma bassa"))))))
318 (ly:context-set-property! context 'middleCPosition new-c0)
319 (ly:context-set-property! context 'originalCentralCPosition c0)
320 (ly:context-set-property! context 'ottavation string)))))
321 (set! (ly:music-property m 'procedure) ottava-modify)
322 (context-spec-music m 'Staff)))
324 (define-public (set-octavation ottavation)
325 (ly:export (make-ottava-set ottavation)))
327 (define-public (make-time-signature-set num den . rest)
328 "Set properties for time signature NUM/DEN. Rest can contain a list
330 (let* ((set1 (make-property-set 'timeSignatureFraction (cons num den)))
331 (beat (ly:make-moment 1 den))
332 (len (ly:make-moment num den))
333 (set2 (make-property-set 'beatLength beat))
334 (set3 (make-property-set 'measureLength len))
335 (set4 (make-property-set 'beatGrouping (if (pair? rest)
338 (basic (list set1 set2 set3 set4)))
340 (context-spec-music (make-sequential-music basic) 'Timing) 'Score)))
342 (define-public (make-mark-set label)
343 "Make the music for the \\mark command."
344 (let* ((set (if (integer? label)
345 (context-spec-music (make-property-set 'rehearsalMark label)
348 (ev (make-music 'MarkEvent))
349 (ch (make-event-chord (list ev))))
351 (make-sequential-music (list set ch))
353 (set! (ly:music-property ev 'label) label)
356 (define-public (set-time-signature num den . rest)
357 (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
359 (define-public (make-penalty-music pen page-pen)
360 (make-music 'BreakEvent
362 'page-penalty page-pen))
364 (define-public (make-articulation name)
365 (make-music 'ArticulationEvent
366 'articulation-type name))
368 (define-public (make-lyric-event string duration)
369 (make-music 'LyricEvent
373 (define-public (make-span-event type spandir)
375 'span-direction spandir))
377 (define-public (set-mus-properties! m alist)
378 "Set all of ALIST as properties of M."
381 (set! (ly:music-property m (caar alist)) (cdar alist))
382 (set-mus-properties! m (cdr alist)))))
384 (define-public (music-separator? m)
386 (let ((ts (ly:music-property m 'types)))
387 (memq 'separator ts)))
390 ;;; splitting chords into voices.
391 (define (voicify-list lst number)
392 "Make a list of Musics.
394 voicify-list :: [ [Music ] ] -> number -> [Music]
395 LST is a list music-lists.
397 NUMBER is 0-base, i.e. Voice=1 (upstems) has number 0.
401 (cons (context-spec-music
402 (make-sequential-music
403 (list (make-voice-props-set number)
404 (make-simultaneous-music (car lst))))
405 'Voice (number->string (1+ number)))
406 (voicify-list (cdr lst) (1+ number)))))
408 (define (voicify-chord ch)
409 "Split the parts of a chord into different Voices using separator"
410 (let ((es (ly:music-property ch 'elements)))
411 (set! (ly:music-property ch 'elements)
412 (voicify-list (split-list es music-separator?) 0))
415 (define-public (voicify-music m)
416 "Recursively split chords that are separated with \\ "
417 (if (not (ly:music? m))
419 (error "not music!")))
420 (let ((es (ly:music-property m 'elements))
421 (e (ly:music-property m 'element)))
423 (set! (ly:music-property m 'elements) (map voicify-music es)))
425 (set! (ly:music-property m 'element) (voicify-music e)))
426 (if (and (equal? (ly:music-name m) "Simultaneous_music")
427 (reduce (lambda (x y ) (or x y)) #f (map music-separator? es)))
428 (set! m (context-spec-music (voicify-chord m) 'Staff)))
431 (define-public (empty-music)
432 (ly:export (make-music 'Music)))
435 ; Make a function that checks score element for being of a specific type.
436 (define-public (make-type-checker symbol)
439 ;;(eq? #t (ly:grob-property elt symbol))
440 (not (eq? #f (memq symbol (ly:grob-property elt 'interfaces))))))
442 (define-public ((outputproperty-compatibility func sym val) grob g-context ao-context)
444 (set! (ly:grob-property grob sym) val)))
447 (define-public ((set-output-property grob-name symbol val) grob grob-c context)
450 \\applyoutput #(set-output-property 'Clef 'extra-offset '(0 . 1))
453 (let ((meta (ly:grob-property grob 'meta)))
454 (if (equal? (cdr (assoc 'name meta)) grob-name)
455 (set! (ly:grob-property grob symbol) val))))
459 (define-public (smart-bar-check n)
460 "Make a bar check that checks for a specific bar number.
462 (let ((m (make-music 'ApplyContext)))
464 (let* ((bn (ly:context-property tr 'currentBarNumber)))
468 (format "Bar check failed, we should have reached ~a, instead at ~a\n"
470 (set! (ly:music-property m 'procedure) checker)
473 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
474 ;; warn for bare chords at start.
476 (define (has-request-chord elts)
477 (reduce (lambda (x y) (or x y)) #f
479 (equal? (ly:music-name x) "Request_chord"))
482 (define (ly:music-message music msg)
483 (let ((ip (ly:music-property music 'origin)))
484 (if (ly:input-location? ip)
485 (ly:input-message ip msg)
488 (define (check-start-chords music)
489 "Check music expression for a Simultaneous_music containing notes\n(ie. Request_chords),
490 without context specification. Called from parser."
491 (let ((es (ly:music-property music 'elements))
492 (e (ly:music-property music 'element))
493 (name (ly:music-name music)))
494 (cond ((equal? name "Context_specced_music") #t)
495 ((equal? name "Simultaneous_music")
496 (if (has-request-chord es)
497 (ly:music-message music "Starting score with a chord.\nPlease insert an explicit \\context before chord")
498 (map check-start-chords es)))
499 ((equal? name "Sequential_music")
501 (check-start-chords (car es))))
502 (else (if (ly:music? e) (check-start-chords e)))))
507 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509 ;; setting stuff for grace context.
512 (define (vector-extend v x)
513 "Make a new vector consisting of V, with X added to the end."
514 (let* ((n (vector-length v))
515 (nv (make-vector (+ n 1) '())))
516 (vector-move-left! v 0 n nv 0)
520 (define (vector-map f v)
521 "Map F over V. This function returns nothing."
522 (do ((n (vector-length v))
525 (f (vector-ref v i))))
527 (define (vector-reverse-map f v)
528 "Map F over V, N to 0 order. This function returns nothing."
529 (do ((i (- (vector-length v) 1) (- i 1)))
531 (f (vector-ref v i))))
533 ;; TODO: make a remove-grace-property too.
534 (define-public (add-grace-property context-name grob sym val)
535 "Set SYM=VAL for GROB in CONTEXT-NAME. "
536 (define (set-prop context)
537 (let* ((where (ly:context-property-where-defined context 'graceSettings))
538 (current (ly:context-property where 'graceSettings))
539 (new-settings (append current
540 (list (list context-name grob sym val)))))
541 (ly:context-set-property! where 'graceSettings new-settings)))
542 (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
546 (defmacro-public def-grace-function (start stop)
547 `(def-music-function (parser location music) (ly:music?)
548 (make-music 'GraceMusic
550 'element (make-music 'SequentialMusic
551 'elements (list (ly:music-deep-copy ,start)
553 (ly:music-deep-copy ,stop))))))
555 (defmacro-public def-music-function (args signature . body)
556 "Helper macro for `ly:make-music-function'.
558 (def-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
561 `(ly:make-music-function (list ,@signature)
566 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
568 (define-public (cue-substitute quote-music)
569 "Must happen after quote-substitute."
571 (if (vector? (ly:music-property quote-music 'quoted-events))
572 (let* ((dir (ly:music-property quote-music 'quoted-voice-direction))
573 (main-voice (if (eq? 1 dir) 1 0))
574 (cue-voice (if (eq? 1 dir) 0 1))
575 (main-music (ly:music-property quote-music 'element))
576 (return-value quote-music))
578 (if (or (eq? 1 dir) (eq? -1 dir))
580 ;; if we have stem dirs, change both quoted and main music
581 ;; to have opposite stems.
585 ;; cannot context-spec Quote-music, since context
586 ;; for the quotes is determined in the iterator.
587 (make-sequential-music
589 (context-spec-music (make-voice-props-set cue-voice) 'Voice "cue")
591 (context-spec-music (make-voice-props-revert) 'Voice "cue"))))
593 (make-sequential-music
595 (make-voice-props-set main-voice)
597 (make-voice-props-revert))))
598 (set! (ly:music-property quote-music 'element) main-music)))
603 (define-public ((quote-substitute quote-tab) music)
604 (let* ((quoted-name (ly:music-property music 'quoted-music-name))
605 (quoted-vector (if (string? quoted-name)
606 (hash-ref quote-tab quoted-name #f)
609 (if (string? quoted-name)
610 (if (vector? quoted-vector)
611 (set! (ly:music-property music 'quoted-events) quoted-vector)
612 (ly:warn "Cannot find quoted music `~S'" quoted-name)))
617 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
618 ;; switch it on here, so parsing and init isn't checked (too slow!)
620 ;; automatic music transformations.
622 (define (switch-on-debugging m)
623 (if (defined? 'set-debug-cell-accesses!)
624 (set-debug-cell-accesses! 15000))
627 (define (music-check-error music)
630 (if (and (ly:music? m)
631 (eq? (ly:music-property m 'error-found) #t))
634 (for-each signal (ly:music-property music 'elements))
635 (signal (ly:music-property music 'element))
638 (set! (ly:music-property music 'error-found) #t))
641 (define (precompute-music-length music)
642 (set! (ly:music-property music 'length)
643 (ly:music-length music))
646 (define-public toplevel-music-functions
648 ;; check-start-chords ; ; no longer needed with chord syntax.
649 (lambda (music parser) (voicify-music music))
650 (lambda (x parser) (music-map glue-mm-rest-texts x))
651 (lambda (x parser) (music-map music-check-error x))
652 (lambda (x parser) (music-map precompute-music-length x))
653 (lambda (music parser)
655 (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes)) music))
656 ;; switch-on-debugging
657 (lambda (x parser) (music-map cue-substitute x))))
662 (define (apply-durations lyric-music durations)
663 (define (apply-duration music)
664 (if (and (not (equal? (ly:music-length music) ZERO-MOMENT))
665 (ly:duration? (ly:music-property music 'duration)))
667 (set! (ly:music-property music 'duration) (car durations))
668 (set! durations (cdr durations)))))
670 (music-map apply-duration lyric-music))
673 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
676 (define-public ((add-balloon-text object-name text off) grob orig-context cur-context)
677 "Usage: see input/regression/balloon.ly "
678 (let* ((meta (ly:grob-property grob 'meta))
679 (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant"))
680 (cb (ly:grob-property grob 'print-function)))
681 (if (equal? nm object-name)
683 (set! (ly:grob-property grob 'print-function) Balloon_interface::print)
684 (set! (ly:grob-property grob 'balloon-original-callback) cb)
685 (set! (ly:grob-property grob 'balloon-text) text)
686 (set! (ly:grob-property grob 'balloon-text-offset) off)
687 (set! (ly:grob-property grob 'balloon-text-props) '((font-family . roman)))))))
689 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
692 (define-public (set-accidentals-properties extra-natural
696 (make-sequential-music
697 (append (if (boolean? extra-natural)
698 (list (make-property-set 'extraNatural extra-natural))
700 (list (make-property-set 'autoAccidentals auto-accs)
701 (make-property-set 'autoCautionaries auto-cauts))))
704 (define-public (set-accidental-style style . rest)
705 "Set accidental style to STYLE. Optionally takes a context argument,
706 e.g. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which
707 use GrandStaff as a context. "
708 (let ((context (if (pair? rest)
710 (pcontext (if (pair? rest)
711 (car rest) 'GrandStaff)))
714 ;; accidentals as they were common in the 18th century.
715 ((equal? style 'default)
716 (set-accidentals-properties #t '(Staff (same-octave . 0))
718 ;; accidentals from one voice do NOT get cancelled in other voices
719 ((equal? style 'voice)
720 (set-accidentals-properties #t '(Voice (same-octave . 0))
722 ;; accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
723 ;; This includes all the default accidentals, but accidentals also needs cancelling
724 ;; in other octaves and in the next measure.
725 ((equal? style 'modern)
726 (set-accidentals-properties #f '(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
728 ;; the accidentals that Stone adds to the old standard as cautionaries
729 ((equal? style 'modern-cautionary)
730 (set-accidentals-properties #f '(Staff (same-octave . 0))
731 '(Staff (any-octave . 0) (same-octave . 1))
733 ;; Multivoice accidentals to be read both by musicians playing one voice
734 ;; and musicians playing all voices.
735 ;; Accidentals are typeset for each voice, but they ARE cancelled across voices.
736 ((equal? style 'modern-voice)
737 (set-accidentals-properties #f
738 '(Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
739 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
742 ;; same as modernVoiceAccidental eccept that all special accidentals are typeset
744 ((equal? style 'modern-voice-cautionary)
745 (set-accidentals-properties #f
746 '(Voice (same-octave . 0))
747 '(Voice (any-octave . 0) (same-octave . 1)
748 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
750 ;; stone's suggestions for accidentals on grand staff.
751 ;; Accidentals are cancelled across the staves in the same grand staff as well
752 ((equal? style 'piano)
753 (set-accidentals-properties #f
754 '(Staff (same-octave . 0)
755 (any-octave . 0) (same-octave . 1)
756 GrandStaff (any-octave . 0) (same-octave . 1))
759 ((equal? style 'piano-cautionary)
760 (set-accidentals-properties #f
761 '(Staff (same-octave . 0))
762 '(Staff (any-octave . 0) (same-octave . 1)
763 GrandStaff (any-octave . 0) (same-octave . 1))
765 ;; do not set localKeySignature when a note alterated differently from
766 ;; localKeySignature is found.
767 ;; Causes accidentals to be printed at every note instead of
768 ;; remembered for the duration of a measure.
769 ;; accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
770 ((equal? style 'forget)
771 (set-accidentals-properties '()
772 '(Staff (same-octave . -1))
774 ;; Do not reset the key at the start of a measure. Accidentals will be
775 ;; printed only once and are in effect until overridden, possibly many
777 ((equal? style 'no-reset)
778 (set-accidentals-properties '()
779 '(Staff (same-octave . #t))
783 (ly:warn "Unknown accidental style: ~S" (symbol->string style))
784 (make-sequential-music '()))))))
786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
788 (define-public (skip-of-length mus)
789 "Create a skip of exactly the same length as MUS."
793 'duration (ly:make-duration 0 0))))
795 (make-event-chord (list (ly:music-compress skip (ly:music-length mus))))))
797 (define-public (mmrest-of-length mus)
798 "Create a mmrest of exactly the same length as MUS."
801 (make-multi-measure-rest
802 (ly:make-duration 0 0) '())))
803 (ly:music-compress skip (ly:music-length mus))