X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-music-display-methods.scm;h=845b514f4499767dcf4a9c2a0c540732a27e539f;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=6d9dc8250603c6d8bc8e480e9728c0f95c3bb017;hpb=44dd3acc534e7a534f846810b481c3f603eaa92e;p=lilypond.git diff --git a/scm/define-music-display-methods.scm b/scm/define-music-display-methods.scm index 6d9dc82506..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)) @@ -179,7 +177,7 @@ expression." ((marcato) "^") ((stopped) "+") ((tenuto) "-") - ((staccatissimo) "|") + ((staccatissimo) "!") ((accent) ">") ((staccato) ".") ((portato) "_") @@ -526,8 +524,17 @@ Otherwise, return #f." (map-in-order (lambda (event) (music->lily-string event parser)) (ly:music-property note 'articulations)))) - (else ;; unknown? - ""))) + (else + ;; pure duration + ;; FIXME: { c4 c4 4 4 } must not be output as { c4 c 4 4 } + ;; quite tricky to do. Do it when outputting sequences? + (format #f "~a~{~a~}" + (duration->lily-string (ly:music-property note 'duration) + #:force-duration #t + #:remember #t) + (map-in-order (lambda (event) + (music->lily-string event parser)) + (ly:music-property note 'articulations)))))) (define-display-method ClusterNoteEvent (note parser) (simple-note->lily-string note parser)) @@ -715,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 @@ -808,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))))) @@ -830,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) @@ -858,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) @@ -917,7 +908,7 @@ Otherwise, return #f." '()) (duration->lily-string ?unit #:force-duration #t) (if (pair? ?count) - (format #f "~a ~~ ~a" (car ?count) (cdr ?count)) + (format #f "~a - ~a" (car ?count) (cdr ?count)) ?count) (new-line->lily-string)))) @@ -955,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) @@ -993,7 +989,7 @@ Otherwise, return #f." context-type 'Timing element (music 'PartialSet - partial-duration ?duration)))) + duration ?duration)))) (and ?duration (format #f "\\partial ~a" @@ -1054,7 +1050,7 @@ Otherwise, return #f." quoted-voice-direction ?quoted-voice-direction quoted-music-name ?quoted-music-name quoted-context-id "cue" - quoted-context-type 'Voice + quoted-context-type 'CueVoice element ?music)) (format #f "\\cueDuring #~s #~a ~a" ?quoted-music-name