"Does @code{mus} belong to the music class @code{type}?"
(memq type (ly:music-property mus 'types)))
+(define-safe-public (music-type-predicate types)
+ "Returns a predicate function that can be used for checking
+music to have one of the types listed in @var{types}."
+ (if (cheap-list? types)
+ (lambda (m)
+ (any (lambda (t) (music-is-of-type? m t)) types))
+ (lambda (m) (music-is-of-type? m types))))
+
;; TODO move this
(define-public ly:grob-property
(make-procedure-with-setter ly:grob-property
(<= min (length res))))
res
(begin
- (if parser
- (ly:parser-error
- (format #f (_ "bad grob property path ~a")
- path)
- location))
+ (ly:parser-error
+ (format #f (_ "bad grob property path ~a")
+ path)
+ location)
#f)))))
+(define-safe-public (check-context-path path #:optional location)
+ "Check a context property path specification @var{path}, a symbol
+list (or a single symbol), for validity and possibly complete it.
+Returns the completed specification, or @code{#f} when rising an
+error (using optionally @code{location})."
+ (let* ((path (if (symbol? path) (list path) path)))
+ ;; A Guile 1.x bug specific to optargs precludes moving the
+ ;; defines out of the let
+ (define (property? s)
+ (object-property s 'translation-type?))
+ (define (unspecial? s)
+ (not (property? s)))
+ (define (check c p) (c p))
+ (or (case (length path)
+ ((1) (and (property? (car path)) (cons 'Bottom path)))
+ ((2) (and (unspecial? (car path)) (property? (cadr path)) path))
+ (else #f))
+ (begin
+ (ly:parser-error
+ (format #f (_ "bad context property ~a")
+ path)
+ location)
+ #f))))
+
(define-public (make-grob-property-set grob gprop val)
"Make a @code{Music} expression that sets @var{gprop} to @var{val} in
@var{grob}. Does a pop first, i.e., this is not an override."
(Voice Slur direction ,DOWN))
general-grace-settings))
+;; Getting a unique context id name
+
+(define-session unique-counter -1)
+(define-safe-public (get-next-unique-voice-name)
+ (set! unique-counter (1+ unique-counter))
+ (format #f "uniqueContext~s" unique-counter))
+
+
(define-safe-public (make-voice-props-set n)
(make-sequential-music
(append
;; articulations on individual events since they can't actually get
;; into a repeat chord given its input syntax.
- (define (keep-element? m)
- (any (lambda (t) (music-is-of-type? m t))
- event-types))
- (define origin (ly:music-property repeat-chord 'origin #f))
- (define (set-origin! l)
- (if origin
- (for-each (lambda (m) (set! (ly:music-property m 'origin) origin)) l))
- l)
+ (define keep-element? (music-type-predicate event-types))
(for-each
(lambda (field)
;; now treat the elements
(set! (ly:music-property repeat-chord 'elements)
(let ((elts
- (set-origin! (ly:music-deep-copy
- (filter keep-element?
- (ly:music-property original-chord
- 'elements))))))
+ (ly:music-deep-copy (filter keep-element?
+ (ly:music-property original-chord
+ 'elements))
+ repeat-chord)))
(for-each
(lambda (m)
(let ((arts (ly:music-property m 'articulations)))
(if (pair? arts)
(set! (ly:music-property m 'articulations)
- (set-origin! (filter! keep-element? arts))))
+ (ly:set-origin! (filter! keep-element? arts)
+ repeat-chord)))
(if (ly:duration? (ly:music-property m 'duration))
(set! (ly:music-property m 'duration) duration))
(if (ly:music-property m 'cautionary #f)
(if (pair? arts)
(set! (ly:music-property repeat-chord 'articulations)
(append!
- (set-origin! (ly:music-deep-copy arts))
+ (ly:music-deep-copy arts repeat-chord)
(ly:music-property repeat-chord 'articulations)))))
repeat-chord)
mus))
-(define-public (music-has-type music type)
- (memq type (ly:music-property music 'types)))
-
(define-public (music-clone music . music-properties)
"Clone @var{music} and set properties according to
@var{music-properties}, a list of alternating property symbols and
(context-spec-music (make-property-set 'skipTypesetting (not bool))
'Score))))
-(define (skip-as-needed music parser)
+(define (skip-as-needed music)
"Replace MUSIC by
<< { \\set skipTypesetting = ##f
LENGTHOF(\\showFirstLength)
(define-session-public toplevel-music-functions
(list
- (lambda (music parser) (expand-repeat-chords!
- (cons 'rhythmic-event
- (ly:parser-lookup '$chord-repeat-events))
- music))
- (lambda (music parser) (expand-repeat-notes! music))
- (lambda (music parser) (voicify-music music))
- (lambda (x parser) (music-map music-check-error x))
- (lambda (x parser) (music-map precompute-music-length x))
- (lambda (music parser)
-
+ (lambda (music) (expand-repeat-chords!
+ (cons 'rhythmic-event
+ (ly:parser-lookup '$chord-repeat-events))
+ music))
+ expand-repeat-notes!
+ voicify-music
+ (lambda (x) (music-map music-check-error x))
+ (lambda (x) (music-map precompute-music-length x))
+ (lambda (music)
(music-map (quote-substitute (ly:parser-lookup 'musicQuotes)) music))
;; switch-on-debugging
- (lambda (x parser) (music-map cue-substitute x))
+ (lambda (x) (music-map cue-substitute x))
- (lambda (x parser)
- (skip-as-needed x parser)
- )))
+ skip-as-needed))
;;;;;;;;;;
;;; general purpose music functions
(define-public (pitch-of-note event-chord)
(let ((evs (filter (lambda (x)
- (music-has-type x 'note-event))
+ (music-is-of-type? x 'note-event))
(ly:music-property event-chord 'elements))))
(and (pair? evs)
"Return a flat list of all music with @var{type} (either a single
type symbol or a list of alternatives) inside of @var{music}, not
recursing into matches themselves."
- (extract-music
- music
- (if (cheap-list? type)
- (lambda (m)
- (any (lambda (t) (music-is-of-type? m t)) type))
- (lambda (m) (music-is-of-type? m type)))))
+ (extract-music music (music-type-predicate type)))
-(define*-public (event-chord-wrap! music #:optional)
+(define*-public (event-chord-wrap! music)
"Wrap isolated rhythmic events and non-postevent events in
-@var{music} inside of an @code{EventChord}. If the optional
-@var{parser} argument is given, chord repeats @samp{q} are expanded
-using the default settings. Otherwise, you need to cater for them
-yourself."
+@var{music} inside of an @code{EventChord}. Chord repeats @samp{q}
+are expanded using the default settings of the parser."
(map-some-music
(lambda (m)
(cond ((music-is-of-type? m 'event-chord)
(set! (ly:music-property m 'articulations) '()))
(make-event-chord (cons m arts))))
(else #f)))
- (if parser
- (expand-repeat-chords!
- (cons 'rhythmic-event
- (ly:parser-lookup '$chord-repeat-events))
- music)
- music)))
+ (expand-repeat-chords!
+ (cons 'rhythmic-event
+ (ly:parser-lookup '$chord-repeat-events))
+ music)))
(define-public (event-chord-notes event-chord)
"Return a list of all notes from @var{event-chord}."