;;; define-music-display-methods.scm -- data for displaying music
;;; expressions using LilyPond notation.
;;;
-;;; (c) 2005--2006 Nicolas Sceaux <nicolas.sceaux@free.fr>
+;;; (c) 2005--2008 Nicolas Sceaux <nicolas.sceaux@free.fr>
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
'HarmonicEvent
'BeamForbidEvent
'AbsoluteDynamicEvent
+ 'TupletSpanEvent
'TrillSpanEvent
'GlissandoEvent
'ArpeggioEvent
(define-span-event-display-method CrescendoEvent (event parser) #f "\\<" "\\!")
(define-span-event-display-method DecrescendoEvent (event parser) #f "\\>" "\\!")
(define-span-event-display-method PhrasingSlurEvent (event parser) #f "\\(" "\\)")
-(define-span-event-display-method SustainEvent (event parser) #f "\\sustainDown" "\\sustainUp")
-(define-span-event-display-method SostenutoEvent (event parser) #f "\\sostenutoDown" "\\sostenutoUp")
+(define-span-event-display-method SustainEvent (event parser) #f "\\sustainOn" "\\sustainOff")
+(define-span-event-display-method SostenutoEvent (event parser) #f "\\sostenutoOn" "\\sostenutoOff")
(define-span-event-display-method TextSpanEvent (event parser) #f "\\startTextSpan" "\\stopTextSpan")
(define-span-event-display-method TrillSpanEvent (event parser) #f "\\startTrillSpan" "\\stopTrillSpan")
(define-span-event-display-method StaffSpanEvent (event parser) #f "\\startStaff" "\\stopStaff")
(define-display-method RelativeOctaveCheck (octave parser)
(let ((pitch (ly:music-property octave 'pitch)))
- (format #f "\\octave ~a~a"
+ (format #f "\\octaveCheck ~a~a"
(note-name->lily-string pitch parser)
(octave->lily-string pitch))))
(fig (ly:music-property figure 'figure))
(bracket-start (ly:music-property figure 'bracket-start))
(bracket-stop (ly:music-property figure 'bracket-stop)))
+
(format #f "~a~a~a~a"
(if (null? bracket-start) "" "[")
(cond ((null? fig) "_")
(else fig))
(if (null? alteration)
""
- (case alteration
- ((-4) "--")
- ((-2) "-")
- ((0) "!")
- ((2) "+")
- ((4) "++")
+ (cond
+ ((= alteration DOUBLE-FLAT) "--")
+ ((= alteration FLAT) "-")
+ ((= alteration NATURAL) "!")
+ ((= alteration SHARP) "+")
+ ((= alteration DOUBLE-SHARP) "++")
(else "")))
(if (null? bracket-stop) "" "]"))))
(define-display-method UnfoldedRepeatedMusic (expr parser)
(repeat->lily-string expr "unfold" parser))
-(define-display-method FoldedRepeatedMusic (expr parser)
- (repeat->lily-string expr "fold" parser))
-
(define-display-method PercentRepeatedMusic (expr parser)
(repeat->lily-string expr "percent" parser))
;;; Layout properties
(define-display-method OverrideProperty (expr parser)
- (let ((symbol (ly:music-property expr 'symbol))
- (properties (ly:music-property expr 'grob-property-path))
- (value (ly:music-property expr 'grob-value))
- (once (ly:music-property expr 'once)))
+ (let* ((symbol (ly:music-property expr 'symbol))
+ (property-path (ly:music-property expr 'grob-property-path))
+ (properties (if (pair? property-path)
+ property-path
+ (list (ly:music-property expr 'grob-property))))
+ (value (ly:music-property expr 'grob-value))
+ (once (ly:music-property expr 'once)))
+
(format #f "~a\\override ~a~a #'~a = ~a~a"
(if (or (null? once)
(not once))
"\\melismaEnd"))
;;; \tempo
+;;; Check for all three different syntaxes of tempo:
+;;; \tempo string duration=note, \tempo duration=note and \tempo string
(define-extra-display-method ContextSpeccedMusic (expr parser)
"If expr is a tempo, return \"\\tempo x = nnn\", otherwise return #f."
- (with-music-match (expr (music 'ContextSpeccedMusic
+ (or (with-music-match (expr (music 'ContextSpeccedMusic
+ element (music 'SequentialMusic
+ elements ((music 'PropertySet
+ value ?unit-text
+ symbol 'tempoText)
+ (music 'PropertySet
+ symbol 'tempoWholesPerMinute)
+ (music 'PropertySet
+ value ?unit-duration
+ symbol 'tempoUnitDuration)
+ (music 'PropertySet
+ value ?unit-count
+ symbol 'tempoUnitCount)))))
+ (format #f "\\tempo ~a ~a = ~a"
+ (scheme-expr->lily-string ?unit-text)
+ (duration->lily-string ?unit-duration #:force-duration #t)
+ ?unit-count))
+ (with-music-match (expr (music 'ContextSpeccedMusic
+ element (music 'SequentialMusic
+ elements ((music 'PropertyUnset
+ symbol 'tempoText)
+ (music 'PropertySet
+ symbol 'tempoWholesPerMinute)
+ (music 'PropertySet
+ value ?unit-duration
+ symbol 'tempoUnitDuration)
+ (music 'PropertySet
+ value ?unit-count
+ symbol 'tempoUnitCount)))))
+ (format #f "\\tempo ~a = ~a"
+ (duration->lily-string ?unit-duration #:force-duration #t)
+ ?unit-count))
+ (with-music-match (expr (music 'ContextSpeccedMusic
element (music 'SequentialMusic
elements ((music 'PropertySet
- symbol 'tempoWholesPerMinute)
- (music 'PropertySet
- value ?unit-duration
- symbol 'tempoUnitDuration)
- (music 'PropertySet
- value ?unit-count
- symbol 'tempoUnitCount)))))
- (format #f "\\tempo ~a = ~a"
- (duration->lily-string ?unit-duration #:force-duration #t)
- ?unit-count)))
+ value ?tempo-text
+ symbol 'tempoText)))))
+ (format #f "\\tempo ~a" (scheme-expr->lily-string ?tempo-text)))))
;;; \clef
-(define clef-name-alist (map (lambda (name+vals)
- (cons (cdr name+vals)
- (car name+vals)))
- supported-clefs))
+(define clef-name-alist #f)
+(define-public (memoize-clef-names clefs)
+ "Initialize `clef-name-alist', if not already set."
+ (if (not clef-name-alist)
+ (set! clef-name-alist
+ (map (lambda (name+vals)
+ (cons (cdr name+vals)
+ (car name+vals)))
+ clefs))))
(define-extra-display-method ContextSpeccedMusic (expr parser)
"If `expr' is a clef change, return \"\\clef ...\"
value ?clef-glyph
symbol 'clefGlyph)
(music 'PropertySet
- symbol 'middleCPosition)
+ symbol 'middleCClefPosition)
(music 'PropertySet
value ?clef-position
symbol 'clefPosition)
(music 'PropertySet
value ?clef-octavation
- symbol 'clefOctavation)))))
+ symbol 'clefOctavation)
+ (music 'ApplyContext
+ procedure ly:set-middle-C!)))))
(let ((clef-prop+name (assoc (list ?clef-glyph ?clef-position 0)
clef-name-alist)))
(if clef-prop+name