X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-music-display-methods.scm;h=845b514f4499767dcf4a9c2a0c540732a27e539f;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=32a747aba8504db978364bac70075ece2abe0179;hpb=bf562afb0241f46a8e899d73adeb39b5dfdcbda8;p=lilypond.git diff --git a/scm/define-music-display-methods.scm b/scm/define-music-display-methods.scm index 32a747aba8..845b514f44 100644 --- a/scm/define-music-display-methods.scm +++ b/scm/define-music-display-methods.scm @@ -1,7 +1,7 @@ ;;; define-music-display-methods.scm -- data for displaying music ;;; expressions using LilyPond notation. ;;; -;;; Copyright (C) 2005--2012 Nicolas Sceaux +;;; Copyright (C) 2005--2015 Nicolas Sceaux ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -167,10 +167,8 @@ expression." (define-display-method TremoloEvent (event parser) - (let ((tremolo-type (ly:music-property event 'tremolo-type))) - (format #f ":~a" (if (= 0 tremolo-type) - "" - tremolo-type)))) + (let ((tremolo-type (ly:music-property event 'tremolo-type 8))) + (format #f ":~a" tremolo-type))) (define-display-method ArticulationEvent (event parser) #t (let* ((articulation (ly:music-property event 'articulation-type)) @@ -724,29 +722,7 @@ Otherwise, return #f." (repeat->lily-string expr "percent" parser)) (define-display-method TremoloRepeatedMusic (expr parser) - (let* ((main (ly:music-property expr 'element)) - (children (if (music-is-of-type? main 'sequential-music) - ;; \repeat tremolo n { ... } - (length (extract-named-music main '(EventChord - NoteEvent))) - ;; \repeat tremolo n c4 - 1)) - (times (ly:music-property expr 'repeat-count)) - - ;; # of dots is equal to the 1 in bitwise representation (minus 1)! - (dots (1- (logcount (* times children)))) - ;; The remaining missing multiplicator to scale the notes by - ;; times * children - (mult (/ (* times children (ash 1 dots)) (1- (ash 2 dots)))) - (shift (- (ly:intlog2 (floor mult))))) - (set! main (ly:music-deep-copy main)) - ;; Adjust the time of the notes - (ly:music-compress main (ly:make-moment children 1)) - ;; Adjust the displayed note durations - (shift-duration-log main (- shift) (- dots)) - (format #f "\\repeat tremolo ~a ~a" - times - (music->lily-string main parser)))) + (repeat->lily-string expr "tremolo" parser)) ;;; ;;; Contexts @@ -817,13 +793,19 @@ Otherwise, return #f." (music->lily-string element parser)) #f))) -(define (property-value->lily-string arg parser) +(define-public (value->lily-string arg parser) (cond ((ly:music? arg) (music->lily-string arg parser)) ((string? arg) (format #f "#~s" arg)) ((markup? arg) (markup->lily-string arg)) + ((ly:duration? arg) + (format #f "##{ ~a #}" (duration->lily-string arg #:force-duration #t))) + ((ly:pitch? arg) + (format #f "~a~a" + (note-name->lily-string arg parser) + (octave->lily-string arg))) (else (format #f "#~a" (scheme-expr->lily-string arg))))) @@ -839,7 +821,7 @@ Otherwise, return #f." "" (format #f "~a . " (*current-context*))) property - (property-value->lily-string value parser) + (value->lily-string value parser) (new-line->lily-string)))) (define-display-method PropertyUnset (expr parser) @@ -867,7 +849,7 @@ Otherwise, return #f." (if (eqv? (*current-context*) 'Bottom) (cons symbol properties) (cons* (*current-context*) symbol properties)) - (property-value->lily-string value parser) + (value->lily-string value parser) (new-line->lily-string)))) (define-display-method RevertProperty (expr parser) @@ -964,21 +946,26 @@ Otherwise, return @code{#f}." (music 'PropertySet value ?clef-transposition symbol 'clefTransposition) + (music 'PropertySet + value ?clef-transposition-style + symbol 'clefTranspositionStyle) (music 'ApplyContext procedure ly:set-middle-C!))))) (let ((clef-name (assoc-get (list ?clef-glyph ?clef-position 0) clef-name-alist))) - (if clef-name - (format #f "\\clef \"~a~{~a~a~}\"~a" - clef-name - (cond ((= 0 ?clef-transposition) - (list "" "")) - ((> ?clef-transposition 0) - (list "^" (1+ ?clef-transposition))) - (else - (list "_" (- 1 ?clef-transposition)))) - (new-line->lily-string)) - #f)))) + (and clef-name + (format #f "\\clef \"~a~?\"~a" + clef-name + (case ?clef-transposition-style + ((parenthesized) "~a(~a)") + ((bracketed) "~a[~a]") + (else "~a~a")) + (cond ((zero? ?clef-transposition) + (list "" "")) + ((positive? ?clef-transposition) + (list "^" (1+ ?clef-transposition))) + (else (list "_" (- 1 ?clef-transposition)))) + (new-line->lily-string)))))) ;;; \bar (define-extra-display-method ContextSpeccedMusic (expr parser)