-
-
-(define-public (make-music-by-name x)
- (if (not (symbol? x))
- (error (format "Not a symbol: ~a" x)))
- (let*
- (
- (props (hashq-ref music-name-to-property-table x '()))
- (name (if (pair? props)
- (cdr (assoc 'internal-class-name props))
- (error "Can not find music object" x)))
- )
-
- (if (eq? props '())
- (ly:warn (format "Could not find music type `~a'" x)))
- (ly:make-bare-music name props)
- ))
-
-
+(define-safe-public (make-music name . music-properties)
+ "Create a music object of given name, and set its properties
+according to `music-properties', a list of alterning property symbols
+and values. E.g:
+ (make-music 'OverrideProperty
+ 'symbol 'Stem
+ 'grob-property 'thickness
+ 'grob-value (* 2 1.5))"
+ (if (not (symbol? name))
+ (ly:error (_ "symbol expected: ~S") name))
+ (let ((props (hashq-ref music-name-to-property-table name '())))
+ (if (not (pair? props))
+ (ly:error (_ "can't find music object: ~S") name))
+ (let ((m (ly:make-music props)))
+ (define (set-props mus-props)
+ (if (and (not (null? mus-props))
+ (not (null? (cdr mus-props))))
+ (begin
+ (set! (ly:music-property m (car mus-props)) (cadr mus-props))
+ (set-props (cddr mus-props)))))
+ (set-props music-properties)
+ m)))