From 2b1e4fd89d57bfecd23afbdeb55293792398f826 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 31 May 2015 10:53:57 +0200 Subject: [PATCH] Issue 4426: Remove bar checks at the end of \parallelMusic passages This allows ending \parallelMusic at non-bar boundaries. --- input/regression/parallelmusic-partial.ly | 34 +++++++++++++++++++++++ ly/music-functions-init.ly | 23 ++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 input/regression/parallelmusic-partial.ly diff --git a/input/regression/parallelmusic-partial.ly b/input/regression/parallelmusic-partial.ly new file mode 100644 index 0000000000..1ae05af13b --- /dev/null +++ b/input/regression/parallelmusic-partial.ly @@ -0,0 +1,34 @@ +\version "2.19.22" + +\header { + texidoc = " +@code{\\parallelMusic} does not complain about incomplete bars at its +end. +" +} + +\parallelMusic vI.vII +\fixed c' +{ + f2 | + a2 | + d2 r2 | + d2 r8 cis cis cis | + d4 r4 \bar "|." | + d4 r4 \bar "|." | +} + +global = +{ + \key d\minor + \time 4/4 + \partial 2 +} + +\score { + \new StaffGroup + << + \new Staff { \global \vI } + \new Staff { \global \vII } + >> +} diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 0dfb92a1c0..6e9e627eec 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -1030,6 +1030,9 @@ Example: B = { d d | e e | } C = { e e | f f | } @end verbatim + +The last bar checks in a sequence are not copied to the result in +order to facilitate ending the last entry at non-bar boundaries. ") (define voice-count (length voice-ids)) (define (bar-check? m) @@ -1050,7 +1053,7 @@ Example: "Store the previously built sequence into the current voice and change to the following voice." (set-car! current-voices - (cons (reverse! current-sequence) + (cons current-sequence (car current-voices))) (set! current-sequence '()) (set! current-voices (cdr current-voices))) @@ -1067,9 +1070,21 @@ change to the following voice." (if (bar-check? m) (change-voice)))))) lst) (if (pair? current-sequence) (change-voice)) - ;; un-circularize `voices' and reorder the voices - (set! voices (map reverse! - (list-head voices voice-count))) + ;; Un-circularize voices + (set! voices (list-head voices voice-count)) + + ;; Remove trailing bar checks to facilitate ending a + ;; sequence on a non-bar, reverse partial sequences and sequences + (set! voices (map! + (lambda (l) + (map! reverse! + (reverse! + (if (and (pair? l) (pair? (car l)) + (bar-check? (caar l))) + (cons (cdar l) (cdr l)) + l)))) + voices)) + ;; check sequence length (apply for-each (lambda seqs (define (seq-len seq) -- 2.39.5