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 (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)))
389 ;;; splitting chords into voices.
390 (define (voicify-list lst number)
391 "Make a list of Musics.
393 voicify-list :: [ [Music ] ] -> number -> [Music]
394 LST is a list music-lists.
396 NUMBER is 0-base, i.e. Voice=1 (upstems) has number 0.
400 (cons (context-spec-music
401 (make-sequential-music
402 (list (make-voice-props-set number)
403 (make-simultaneous-music (car lst))))
404 'Voice (number->string (1+ number)))
405 (voicify-list (cdr lst) (1+ number)))))
407 (define (voicify-chord ch)
408 "Split the parts of a chord into different Voices using separator"
409 (let ((es (ly:music-property ch 'elements)))
410 (set! (ly:music-property ch 'elements)
411 (voicify-list (split-list es music-separator?) 0))
414 (define-public (voicify-music m)
415 "Recursively split chords that are separated with \\ "
416 (if (not (ly:music? m))
418 (error "not music!")))
419 (let ((es (ly:music-property m 'elements))
420 (e (ly:music-property m 'element)))
422 (set! (ly:music-property m 'elements) (map voicify-music es)))
424 (set! (ly:music-property m 'element) (voicify-music e)))
425 (if (and (equal? (ly:music-name m) "Simultaneous_music")
426 (reduce (lambda (x y ) (or x y)) #f (map music-separator? es)))
427 (set! m (context-spec-music (voicify-chord m) 'Staff)))
430 (define-public (empty-music)
431 (ly:export (make-music 'Music)))
434 ; Make a function that checks score element for being of a specific type.
435 (define-public (make-type-checker symbol)
438 ;;(eq? #t (ly:grob-property elt symbol))
439 (not (eq? #f (memq symbol (ly:grob-property elt 'interfaces))))))
441 (define-public ((outputproperty-compatibility func sym val) grob g-context ao-context)
443 (set! (ly:grob-property grob sym) val)))
446 (define-public ((set-output-property grob-name symbol val) grob grob-c context)
449 \\applyoutput #(set-output-property 'Clef 'extra-offset '(0 . 1))
452 (let ((meta (ly:grob-property grob 'meta)))
453 (if (equal? (cdr (assoc 'name meta)) grob-name)
454 (set! (ly:grob-property grob symbol) val))))
458 (define-public (smart-bar-check n)
459 "Make a bar check that checks for a specific bar number.
461 (let ((m (make-music 'ApplyContext)))
463 (let* ((bn (ly:context-property tr 'currentBarNumber)))
467 (format "Bar check failed, we should have reached ~a, instead at ~a\n"
469 (set! (ly:music-property m 'procedure) checker)
472 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
473 ;; warn for bare chords at start.
475 (define (has-request-chord elts)
476 (reduce (lambda (x y) (or x y)) #f
478 (equal? (ly:music-name x) "Request_chord"))
481 (define (ly:music-message music msg)
482 (let ((ip (ly:music-property music 'origin)))
483 (if (ly:input-location? ip)
484 (ly:input-message ip msg)
487 (define (check-start-chords music)
488 "Check music expression for a Simultaneous_music containing notes\n(ie. Request_chords),
489 without context specification. Called from parser."
490 (let ((es (ly:music-property music 'elements))
491 (e (ly:music-property music 'element))
492 (name (ly:music-name music)))
493 (cond ((equal? name "Context_specced_music") #t)
494 ((equal? name "Simultaneous_music")
495 (if (has-request-chord es)
496 (ly:music-message music "Starting score with a chord.\nPlease insert an explicit \\context before chord")
497 (map check-start-chords es)))
498 ((equal? name "Sequential_music")
500 (check-start-chords (car es))))
501 (else (if (ly:music? e) (check-start-chords e)))))
506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
508 ;; setting stuff for grace context.
511 (define (vector-extend v x)
512 "Make a new vector consisting of V, with X added to the end."
513 (let* ((n (vector-length v))
514 (nv (make-vector (+ n 1) '())))
515 (vector-move-left! v 0 n nv 0)
519 (define (vector-map f v)
520 "Map F over V. This function returns nothing."
521 (do ((n (vector-length v))
524 (f (vector-ref v i))))
526 (define (vector-reverse-map f v)
527 "Map F over V, N to 0 order. This function returns nothing."
528 (do ((i (- (vector-length v) 1) (- i 1)))
530 (f (vector-ref v i))))
532 ;; TODO: make a remove-grace-property too.
533 (define-public (add-grace-property context-name grob sym val)
534 "Set SYM=VAL for GROB in CONTEXT-NAME. "
535 (define (set-prop context)
536 (let* ((where (ly:context-property-where-defined context 'graceSettings))
537 (current (ly:context-property where 'graceSettings))
538 (new-settings (append current
539 (list (list context-name grob sym val)))))
540 (ly:context-set-property! where 'graceSettings new-settings)))
541 (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
545 (defmacro-public def-grace-function (start stop)
546 `(def-music-function (parser location music) (ly:music?)
547 (make-music 'GraceMusic
549 'element (make-music 'SequentialMusic
550 'elements (list (ly:music-deep-copy ,start)
552 (ly:music-deep-copy ,stop))))))
554 (defmacro-public def-music-function (args signature . body)
555 "Helper macro for `ly:make-music-function'.
557 (def-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
560 `(ly:make-music-function (list ,@signature)
565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
567 (define-public (cue-substitute quote-music)
568 "Must happen after quote-substitute."
570 (if (vector? (ly:music-property quote-music 'quoted-events))
571 (let* ((dir (ly:music-property quote-music 'quoted-voice-direction))
572 (main-voice (if (eq? 1 dir) 1 0))
573 (cue-voice (if (eq? 1 dir) 0 1))
574 (main-music (ly:music-property quote-music 'element))
575 (return-value quote-music))
577 (if (or (eq? 1 dir) (eq? -1 dir))
579 ;; if we have stem dirs, change both quoted and main music
580 ;; to have opposite stems.
584 ;; cannot context-spec Quote-music, since context
585 ;; for the quotes is determined in the iterator.
586 (make-sequential-music
588 (context-spec-music (make-voice-props-set cue-voice) 'Voice "cue")
590 (context-spec-music (make-voice-props-revert) 'Voice "cue"))))
592 (make-sequential-music
594 (make-voice-props-set main-voice)
596 (make-voice-props-revert))))
597 (set! (ly:music-property quote-music 'element) main-music)))
602 (define-public ((quote-substitute quote-tab) music)
603 (let* ((quoted-name (ly:music-property music 'quoted-music-name))
604 (quoted-vector (if (string? quoted-name)
605 (hash-ref quote-tab quoted-name #f)
608 (if (string? quoted-name)
609 (if (vector? quoted-vector)
610 (set! (ly:music-property music 'quoted-events) quoted-vector)
611 (ly:warn "Cannot find quoted music `~S'" quoted-name)))
616 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
617 ;; switch it on here, so parsing and init isn't checked (too slow!)
619 ;; automatic music transformations.
621 (define (switch-on-debugging m)
622 (if (defined? 'set-debug-cell-accesses!)
623 (set-debug-cell-accesses! 15000))
626 (define (music-check-error music)
629 (if (and (ly:music? m)
630 (eq? (ly:music-property m 'error-found) #t))
633 (for-each signal (ly:music-property music 'elements))
634 (signal (ly:music-property music 'element))
637 (set! (ly:music-property music 'error-found) #t))
640 (define (precompute-music-length music)
641 (set! (ly:music-property music 'length)
642 (ly:music-length music))
645 (define-public toplevel-music-functions
647 ;; check-start-chords ; ; no longer needed with chord syntax.
648 (lambda (music parser) (voicify-music music))
649 (lambda (x parser) (music-map glue-mm-rest-texts x))
650 (lambda (x parser) (music-map music-check-error x))
651 (lambda (x parser) (music-map precompute-music-length x))
652 (lambda (music parser)
654 (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes)) music))
655 ;; switch-on-debugging
656 (lambda (x parser) (music-map cue-substitute x))))
661 (define (apply-durations lyric-music durations)
662 (define (apply-duration music)
663 (if (and (not (equal? (ly:music-length music) ZERO-MOMENT))
664 (ly:duration? (ly:music-property music 'duration)))
666 (set! (ly:music-property music 'duration) (car durations))
667 (set! durations (cdr durations)))))
669 (music-map apply-duration lyric-music))
672 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
675 (define-public ((add-balloon-text object-name text off) grob orig-context cur-context)
676 "Usage: see input/regression/balloon.ly "
677 (let* ((meta (ly:grob-property grob 'meta))
678 (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant"))
679 (cb (ly:grob-property grob 'print-function)))
680 (if (equal? nm object-name)
682 (set! (ly:grob-property grob 'print-function) Balloon_interface::print)
683 (set! (ly:grob-property grob 'balloon-original-callback) cb)
684 (set! (ly:grob-property grob 'balloon-text) text)
685 (set! (ly:grob-property grob 'balloon-text-offset) off)
686 (set! (ly:grob-property grob 'balloon-text-props) '((font-family . roman)))))))
688 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
691 (define-public (set-accidentals-properties extra-natural
695 (make-sequential-music
696 (append (if (boolean? extra-natural)
697 (list (make-property-set 'extraNatural extra-natural))
699 (list (make-property-set 'autoAccidentals auto-accs)
700 (make-property-set 'autoCautionaries auto-cauts))))
703 (define-public (set-accidental-style style . rest)
704 "Set accidental style to STYLE. Optionally takes a context argument,
705 e.g. 'Staff or 'Voice. The context defaults to Voice, except for piano styles, which
706 use GrandStaff as a context. "
707 (let ((context (if (pair? rest)
709 (pcontext (if (pair? rest)
710 (car rest) 'GrandStaff)))
713 ;; accidentals as they were common in the 18th century.
714 ((equal? style 'default)
715 (set-accidentals-properties #t '(Staff (same-octave . 0))
717 ;; accidentals from one voice do NOT get cancelled in other voices
718 ((equal? style 'voice)
719 (set-accidentals-properties #t '(Voice (same-octave . 0))
721 ;; accidentals as suggested by Kurt Stone, Music Notation in the 20th century.
722 ;; This includes all the default accidentals, but accidentals also needs cancelling
723 ;; in other octaves and in the next measure.
724 ((equal? style 'modern)
725 (set-accidentals-properties #f '(Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
727 ;; the accidentals that Stone adds to the old standard as cautionaries
728 ((equal? style 'modern-cautionary)
729 (set-accidentals-properties #f '(Staff (same-octave . 0))
730 '(Staff (any-octave . 0) (same-octave . 1))
732 ;; Multivoice accidentals to be read both by musicians playing one voice
733 ;; and musicians playing all voices.
734 ;; Accidentals are typeset for each voice, but they ARE cancelled across voices.
735 ((equal? style 'modern-voice)
736 (set-accidentals-properties #f
737 '(Voice (same-octave . 0) (any-octave . 0) (same-octave . 1)
738 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
741 ;; same as modernVoiceAccidental eccept that all special accidentals are typeset
743 ((equal? style 'modern-voice-cautionary)
744 (set-accidentals-properties #f
745 '(Voice (same-octave . 0))
746 '(Voice (any-octave . 0) (same-octave . 1)
747 Staff (same-octave . 0) (any-octave . 0) (same-octave . 1))
749 ;; stone's suggestions for accidentals on grand staff.
750 ;; Accidentals are cancelled across the staves in the same grand staff as well
751 ((equal? style 'piano)
752 (set-accidentals-properties #f
753 '(Staff (same-octave . 0)
754 (any-octave . 0) (same-octave . 1)
755 GrandStaff (any-octave . 0) (same-octave . 1))
758 ((equal? style 'piano-cautionary)
759 (set-accidentals-properties #f
760 '(Staff (same-octave . 0))
761 '(Staff (any-octave . 0) (same-octave . 1)
762 GrandStaff (any-octave . 0) (same-octave . 1))
764 ;; do not set localKeySignature when a note alterated differently from
765 ;; localKeySignature is found.
766 ;; Causes accidentals to be printed at every note instead of
767 ;; remembered for the duration of a measure.
768 ;; accidentals not being remembered, causing accidentals always to be typeset relative to the time signature
769 ((equal? style 'forget)
770 (set-accidentals-properties '()
771 '(Staff (same-octave . -1))
773 ;; Do not reset the key at the start of a measure. Accidentals will be
774 ;; printed only once and are in effect until overridden, possibly many
776 ((equal? style 'no-reset)
777 (set-accidentals-properties '()
778 '(Staff (same-octave . #t))
782 (ly:warn "Unknown accidental style: ~S" (symbol->string style))
783 (make-sequential-music '()))))))
785 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
787 (define-public (skip-of-length mus)
788 "Create a skip of exactly the same length as MUS."
792 'duration (ly:make-duration 0 0))))
794 (make-event-chord (list (ly:music-compress skip (ly:music-length mus))))))
796 (define-public (mmrest-of-length mus)
797 "Create a mmrest of exactly the same length as MUS."
800 (make-multi-measure-rest
801 (ly:make-duration 0 0) '())))
802 (ly:music-compress skip (ly:music-length mus))