;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2004--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
;;;;
;;;; LilyPond is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
(define-method (note-events (vs <Voice-state>))
(define (f? x)
- (equal? (ly:event-property x 'class) 'note-event))
+ (ly:in-event-class? x 'note-event))
(filter f? (events vs)))
(define-method (previous-voice-state (vs <Voice-state>))
"Analyse EVS at INDEX, given state ACTIVE."
(define (analyse-tie-start active ev)
- (if (equal? (ly:event-property ev 'class) 'tie-event)
+ (if (ly:in-event-class? ev 'tie-event)
(acons 'tie (split-index (vector-ref voice-state-vec index))
active)
active))
(define (analyse-tie-end active ev)
- (if (equal? (ly:event-property ev 'class) 'note-event)
+ (if (ly:in-event-class? ev 'note-event)
(assoc-remove! active 'tie)
active))
(define (analyse-absdyn-end active ev)
- (if (or (equal? (ly:event-property ev 'class) 'absolute-dynamic-event)
- (and (equal? (ly:event-property ev 'class) 'crescendo-event)
+ (if (or (ly:in-event-class? ev 'absolute-dynamic-event)
+ (and (ly:in-event-class? ev 'span-dynamic-event)
(equal? STOP (ly:event-property ev 'span-direction))))
(assoc-remove! (assoc-remove! active 'cresc) 'decr)
active))
(define (active<? a b)
(cond ((symbol<? (car a) (car b)) #t)
- ((symbol<? (car b) (car b)) #f)
+ ((symbol<? (car b) (car a)) #f)
(else (< (cdr a) (cdr b)))))
(define (analyse-span-event active ev)
- (let* ((name (ly:event-property ev 'class))
+ (let* ((name (car (ly:event-property ev 'class)))
(key (cond ((equal? name 'slur-event) 'slur)
((equal? name 'phrasing-slur-event) 'tie)
((equal? name 'beam-event) 'beam)
(ly:interpret-music-expression (make-non-relative-music music) global)
context-list))
-(define-public (make-part-combine-music parser music-list)
+(define-public (make-part-combine-music parser music-list direction)
(let* ((m (make-music 'PartCombineMusic))
(m1 (make-non-relative-music (context-spec-music (first music-list) 'Voice "one")))
(m2 (make-non-relative-music (context-spec-music (second music-list) 'Voice "two")))
(evs1 (recording-group-emulate m1 listener)))
(set! (ly:music-property m 'elements) (list m1 m2))
+ (set! (ly:music-property m 'direction) direction)
(set! (ly:music-property m 'split-list)
(if (and (assoc "one" evs1) (assoc "two" evs2))
(determine-split-list (reverse! (assoc-get "one" evs1) '())
(define-public (add-quotable parser name mus)
(let* ((tab (eval 'musicQuotes (current-module)))
- (context-list (recording-group-emulate (context-spec-music mus 'Voice)
- (ly:parser-lookup parser 'partCombineListener))))
- (if (pair? context-list)
- (hash-set! tab name
- ;; cdr : skip name string
- (list->vector (reverse! (cdar context-list)
- '()))))))
+ (voicename (get-next-unique-voice-name))
+ ;; recording-group-emulate returns an assoc list (reversed!), so
+ ;; hand it a proper unique context name and extract that key:
+ (ctx-spec (context-spec-music mus 'Voice voicename))
+ (listener (ly:parser-lookup parser 'partCombineListener))
+ (context-list (reverse (recording-group-emulate ctx-spec listener)))
+ (raw-voice (assoc voicename context-list))
+ (quote-contents (if (pair? raw-voice) (cdr raw-voice) '())))
+
+ ;; If the context-specced quoted music does not contain anything, try to
+ ;; use the first child, i.e. the next in context-list after voicename
+ ;; That's the case e.g. for \addQuote "x" \relative c \new Voice {...}
+ (if (null? quote-contents)
+ (let find-non-empty ((current-tail (member raw-voice context-list)))
+ ;; if voice has contents, use them, otherwise check next ctx
+ (cond ((null? current-tail) #f)
+ ((and (pair? (car current-tail))
+ (pair? (cdar current-tail)))
+ (set! quote-contents (cdar current-tail)))
+ (else (find-non-empty (cdr current-tail))))))
+
+ (if (not (null? quote-contents))
+ (hash-set! tab name (list->vector (reverse! quote-contents '())))
+ (ly:music-warning mus (ly:format (_ "quoted music `~a' is empty") name)))))