[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New partcombineUp and partcombineDown functions (issue 4514042)
From: |
bordage . bertrand |
Subject: |
Re: New partcombineUp and partcombineDown functions (issue 4514042) |
Date: |
Thu, 01 Sep 2011 21:44:57 +0000 |
Reviewers: J_lowe, dan_faithful.be,
Message:
I updated the patch and added a regtest.
Dan, I don't have time for now to rewrite the whole part combiner. Do
you want to do it ? If so, I can help you (at my level).
Bertrand
Description:
New partcombineUp and partcombineDown functions
Fix issue 1321
Please review this at http://codereview.appspot.com/4514042/
Affected files:
A input/regression/part-combine-3voices.ly
M lily/part-combine-iterator.cc
M ly/music-functions-init.ly
M scm/part-combiner.scm
Index: input/regression/part-combine-3voices.ly
diff --git a/input/regression/part-combine-3voices.ly
b/input/regression/part-combine-3voices.ly
new file mode 100644
index
0000000000000000000000000000000000000000..8dcb00966b4eec2b882b4562d9da3e49d79c96ab
--- /dev/null
+++ b/input/regression/part-combine-3voices.ly
@@ -0,0 +1,18 @@
+\version "2.15.10"
+
+\header {
+ texidoc ="It is possible to use the part combiner for three
+ voices with \\partcombineUp and \\partcombineDown."
+}
+
+
+soprano = { d''2 f'' g'' }
+alto = { a' c''4 d'' e''2 }
+tenor = { f'2 a'4 b' c''2 }
+basso = { d'4 e' f' g' g'2 }
+
+\new Staff << \partcombineUp \soprano \alto \\ \basso >>
+
+\new Staff << \soprano \\ \partcombineDown \tenor \basso >>
+
+
Index: lily/part-combine-iterator.cc
diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc
index
4583d221f646ef9bcdc801dd46c4674366795fb3..9ab0495ae14ce909838c5498e5421d28590fd5bf
100644
--- a/lily/part-combine-iterator.cc
+++ b/lily/part-combine-iterator.cc
@@ -65,6 +65,11 @@ private:
Moment start_moment_;
SCM split_list_;
+ SCM direction_;
+ SCM directionOne_;
+ SCM directionTwo_;
+ SCM horizontalShiftOne_;
+ SCM horizontalShiftTwo_;
Stream_event *unisono_event_;
Stream_event *solo_one_event_;
@@ -133,6 +138,11 @@ Part_combine_iterator::Part_combine_iterator ()
first_iter_ = 0;
second_iter_ = 0;
split_list_ = SCM_EOL;
+ direction_ = SCM_BOOL_F;
+ directionOne_ = scm_from_int (1);
+ directionTwo_ = scm_from_int (-1);
+ horizontalShiftOne_ = scm_from_int (0);
+ horizontalShiftTwo_ = scm_from_int (1);
state_ = APART;
playing_state_ = APART;
last_playing_ = APART;
@@ -349,6 +359,17 @@ Part_combine_iterator::construct_children ()
{
start_moment_ = get_outlet ()->now_mom ();
split_list_ = get_music ()->get_property ("split-list");
+ direction_ = get_music ()->get_property ("direction");
+ if (is_direction (direction_))
+ {
+ directionOne_ = direction_;
+ directionTwo_ = direction_;
+ if (scm_is_true (scm_negative_p (direction_)))
+ {
+ horizontalShiftOne_ = scm_from_int (1);
+ horizontalShiftTwo_ = scm_from_int (0);
+ }
+ }
Context *c = get_outlet ();
@@ -369,6 +390,8 @@ Part_combine_iterator::construct_children ()
Context *two = handles_[CONTEXT_TWO].get_context ();
set_context (two);
second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr
(lst))));
+ Context *shared = handles_[CONTEXT_SHARED].get_context ();
+ set_context (shared);
/* Mimic all settings of voiceOne/voiceTwo for the two separate
voices...*/
/* FIXME: Is there any way to use the definition of \voiceOne/\voiceTwo
@@ -391,16 +414,20 @@ Part_combine_iterator::construct_children ()
{
SCM sym = ly_symbol2scm (*p);
execute_pushpop_property (one, sym,
- ly_symbol2scm ("direction"), scm_from_int
(1));
+ ly_symbol2scm ("direction"),
directionOne_);
execute_pushpop_property (two, sym,
- ly_symbol2scm ("direction"), scm_from_int
(-1));
+ ly_symbol2scm ("direction"),
directionTwo_);
+
+ if (scm_is_number (direction_))
+ execute_pushpop_property (shared, sym,
+ ly_symbol2scm ("direction"), direction_);
}
/* Handle horizontal shifts for crossing notes */
execute_pushpop_property (one, ly_symbol2scm ("NoteColumn"),
- ly_symbol2scm ("horizontal-shift"),
scm_from_int (0));
+ ly_symbol2scm ("horizontal-shift"),
horizontalShiftOne_);
execute_pushpop_property (two, ly_symbol2scm ("NoteColumn"),
- ly_symbol2scm ("horizontal-shift"),
scm_from_int (1));
+ ly_symbol2scm ("horizontal-shift"),
horizontalShiftTwo_);
/* Also handle MultiMeasureRest positions for voice 1/2 */
execute_pushpop_property (one, ly_symbol2scm ("MultiMeasureRest"),
ly_symbol2scm ("staff-position"), scm_from_int
(4));
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index
b3a009860753c54d7ab7549617ab4ba6f32d3ae5..1419daa808f7ebf5e65f33cb9116b940d1fdda67
100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -767,7 +767,21 @@ partcombine =
(_i "Take the music in @var{part1} and @var{part2} and typeset so
that they share a staff.")
(make-part-combine-music parser
- (list part1 part2)))
+ (list part1 part2) #f))
+
+partcombineUp =
+#(define-music-function (parser location part1 part2) (ly:music? ly:music?)
+ (_i "Take the music in @var{part1} and @var{part2} and typeset so
+that they share a staff with stems directed upward.")
+ (make-part-combine-music parser
+ (list part1 part2) UP))
+
+partcombineDown =
+#(define-music-function (parser location part1 part2) (ly:music? ly:music?)
+ (_i "Take the music in @var{part1} and @var{part2} and typeset so
+that they share a staff with stems directed downward.")
+ (make-part-combine-music parser
+ (list part1 part2) DOWN))
partcombineForce =
#(define-music-function (location parser type once) (symbol-or-boolean?
boolean?)
Index: scm/part-combiner.scm
diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm
index
c492701c9142087bb6c44ac65deabf1a41d0a224..61fbf95f50587f79700f96371a7e3bd087bb1fe5
100644
--- a/scm/part-combiner.scm
+++ b/scm/part-combiner.scm
@@ -243,7 +243,7 @@ LilyPond version 2.8 and earlier."
(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")))
@@ -252,6 +252,7 @@ LilyPond version 2.8 and earlier."
(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) '())
- Re: New partcombineUp and partcombineDown functions (issue 4514042),
bordage . bertrand <=