+
+(define-public (make-property-set sym val)
+ (let*
+ (
+ (m (make-music-by-name 'PropertySet))
+ )
+ (ly:set-mus-property! m 'symbol sym)
+ (ly:set-mus-property! m 'value val)
+ m
+ ))
+
+
+
+(define-public (make-ottava-set octavation)
+ (let*
+ ((m (make-music-by-name 'ApplyContext)))
+
+
+ (define (ottava-modify context)
+ "Either reset centralCPosition to the stored original,
+or remember old centralCPosition, add OCTAVATION to centralCPosition,
+and set OTTAVATION to `8va', or whatever appropriate."
+ (if (number? (ly:get-context-property context 'centralCPosition))
+
+ (if (= octavation 0)
+ (let*
+ ((where (ly:context-property-where-defined context 'centralCPosition))
+ (oc0 (ly:get-context-property context 'originalCentralCPosition)))
+
+ (ly:set-context-property! context 'centralCPosition oc0)
+ (ly:unset-context-property where 'originalCentralCPosition)
+ (ly:unset-context-property where 'ottavation))
+
+ (let*
+ ((where (ly:context-property-where-defined context 'centralCPosition))
+ (c0 (ly:get-context-property context 'centralCPosition))
+ (new-c0 (+ c0 (* -7 octavation)))
+ (string (cdr
+ (assoc octavation '((2 . "15ma")
+ (1 . "8va")
+ (0 . #f)
+ (-1 . "8va bassa")
+ (-2 . "15ma bassa"))))))
+
+ (ly:set-context-property! context 'centralCPosition new-c0)
+ (ly:set-context-property! context 'originalCentralCPosition c0)
+ (ly:set-context-property! context 'ottavation string)
+
+ ))))
+
+ (ly:set-mus-property! m 'procedure ottava-modify)
+ (context-spec-music m 'Staff)
+ ))
+
+(define-public (set-octavation ottavation)
+ (ly:export (make-ottava-set ottavation)))
+
+(define-public (make-time-signature-set num den . rest)
+ " Set properties for time signature NUM/DEN.
+Rest can contain a list of beat groupings
+
+"
+
+ (let*
+ (
+ (set1 (make-property-set 'timeSignatureFraction (cons num den) ))
+ (beat (ly:make-moment 1 den))
+ (len (ly:make-moment num den))
+ (set2 (make-property-set 'beatLength beat))
+ (set3 (make-property-set 'measureLength len))
+ (set4 (make-property-set 'beatGrouping (if (pair? rest)
+ (car rest)
+ '())))
+ (basic (list set1 set2 set3 set4)))
+
+ (context-spec-music
+ (make-sequential-music basic) 'Timing)))
+
+(define-public (set-time-signature num den . rest)
+ (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
+
+(define-public (make-penalty-music pen)
+ (let
+ ((m (make-music-by-name 'BreakEvent)))
+ (ly:set-mus-property! m 'penalty pen)
+ m))
+
+(define-public (make-articulation name)
+ (let* (
+ (m (make-music-by-name 'ArticulationEvent))
+ )
+ (ly:set-mus-property! m 'articulation-type name)
+ m
+ ))
+
+(define-public (make-lyric-event string duration)
+ (let* ((m (make-music-by-name 'LyricEvent)))
+
+ (ly:set-mus-property! m 'duration duration)
+ (ly:set-mus-property! m 'text string)
+ m))
+
+(define-public (make-span-event type spandir)
+ (let* (
+ (m (make-music-by-name type))
+ )
+ (ly:set-mus-property! m 'span-direction spandir)
+ m
+ ))
+
+(define-public (set-mus-properties! m alist)
+ "Set all of ALIST as properties of M."
+ (if (pair? alist)
+ (begin
+ (ly:set-mus-property! m (caar alist) (cdar alist))
+ (set-mus-properties! m (cdr alist)))
+ ))
+
+
+
+(define-public (music-separator? m)
+ "Is M a separator?"
+ (let* ((ts (ly:get-mus-property m 'types )))
+ (memq 'separator ts)
+ ))