;;; define-music-display-methods.scm -- data for displaying music
;;; expressions using LilyPond notation.
;;;
-;;; Copyright (C) 2005--2012 Nicolas Sceaux <nicolas.sceaux@free.fr>
+;;; Copyright (C) 2005--2014 Nicolas Sceaux <nicolas.sceaux@free.fr>
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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))
(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
(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)))))
""
(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)
(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)
(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)