]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4348: Part combiner: move direction handling out of iterator
authorDan Eble <nine.fierce.ballads@gmail.com>
Sat, 18 Apr 2015 03:01:55 +0000 (23:01 -0400)
committerDan Eble <nine.fierce.ballads@gmail.com>
Fri, 24 Apr 2015 11:07:48 +0000 (07:07 -0400)
input/regression/display-lily-tests.ly
lily/part-combine-iterator.cc
ly/music-functions-init.ly
scm/define-music-display-methods.scm

index cbbebd6539fa0f9bd6acb0767c7a93e38f8aec97..6ff266c4efa8381846b7742712bef56bed289f1a 100644 (file)
@@ -237,7 +237,11 @@ stderr of this run."
 
 %% \partcombine
 \test ##[ \partcombine { c4 e4 }
-{ d4 f4 } #]                                           % PartCombineMusic UnrelativableMusic
+{ d4 f4 } #]
+\test ##[ \partcombineUp { c2 e2 }
+{ d2 f2 } #]
+\test ##[ \partcombineDown { c1 e1 }
+{ d1 f1 } #]
 
 %% Cue notes
 \test ##[ \cueDuring #"foo" #1 { c4 d4 } #]
index d1a8f019f3a9abce3964a290209629f1c9999f9a..4d1baec7568b3d24939dac9c7bdac59b5467ad00 100644 (file)
@@ -65,11 +65,6 @@ 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_;
@@ -146,11 +141,6 @@ 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;
   chosen_part_ = 1;
   playing_state_ = PLAYING_OTHER;
@@ -369,17 +359,6 @@ 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 ();
 
@@ -402,44 +381,6 @@ Part_combine_iterator::construct_children ()
   second_iter_ = Music_iterator::unsmob (get_iterator (Music::unsmob (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
-            directly??? */
-  char const *syms[]
-  =
-  {
-    "Stem",
-    "DynamicLineSpanner",
-    "Tie",
-    "Dots",
-    "MultiMeasureRest",
-    "Rest",
-    "Slur",
-    "TextScript",
-    "Script",
-    0
-  };
-
-  for (char const **p = syms; *p; p++)
-    {
-      SCM sym = ly_symbol2scm (*p);
-      execute_pushpop_property (one, sym,
-                                ly_symbol2scm ("direction"), directionOne_);
-
-      execute_pushpop_property (two, sym,
-                                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"), horizontalShiftOne_);
-  execute_pushpop_property (two, ly_symbol2scm ("NoteColumn"),
-                            ly_symbol2scm ("horizontal-shift"), horizontalShiftTwo_);
-
 }
 
 IMPLEMENT_LISTENER (Part_combine_iterator, set_busy);
index 9b1d36623baf9f115aa09fe774b51e3c29e02b97..cbba26a65256a366e3c2793cebb641e91d18266b 100644 (file)
@@ -1131,24 +1131,36 @@ a music expression containing simultaneous voices, where @var{part1}
 and @var{part2} are combined into one voice where appropriate.
 Optional @var{chord-range} sets the distance in steps between notes
 that may be combined into a chord or unison.")
-   (make-part-combine-music parser
-                            (list part1 part2) #f chord-range))
+   #{ \context Staff <<
+        \context Voice = "one" \with { \voiceOne } {}
+        \context Voice = "two" \with { \voiceTwo } {}
+        \context Voice = "shared" {}
+        #(make-part-combine-music parser (list part1 part2) #f chord-range)
+      >> #} )
 
 partcombineUp =
 #(define-music-function (parser location chord-range part1 part2)
    ((number-pair? '(0 . 8)) 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 chord-range))
+   #{ \context Staff <<
+        \context Voice = "one" \with { \voiceOne } {}
+        \context Voice = "two" \with { \voiceThree } {}
+        \context Voice = "shared" \with { \voiceOne } {}
+        #(make-part-combine-music parser (list part1 part2) UP chord-range)
+      >> #} )
 
 partcombineDown =
 #(define-music-function (parser location chord-range part1 part2)
    ((number-pair? '(0 . 8)) 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 chord-range))
+   #{ \context Staff <<
+        \context Voice = "one" \with { \voiceFour } {}
+        \context Voice = "two" \with { \voiceTwo } {}
+        \context Voice = "shared" \with { \voiceTwo } {}
+        #(make-part-combine-music parser (list part1 part2) DOWN chord-range)
+      >> #} )
 
 partcombineForce =
 #(define-music-function (location parser type once) (boolean-or-symbol? boolean?)
index ca532c5029a3bd669f901468263f8066559e4966..cca78ffec267ed80fd610dbacb5f5fe382202e9b 100644 (file)
@@ -1012,6 +1012,7 @@ Otherwise, return #f."
 
 (define-extra-display-method PartCombineMusic (expr parser)
   (with-music-match (expr (music 'PartCombineMusic
+                                 direction ?dir
                                  elements ((music 'UnrelativableMusic
                                                   element (music 'ContextSpeccedMusic
                                                                  context-id "one"
@@ -1022,11 +1023,35 @@ Otherwise, return #f."
                                                                  context-id "two"
                                                                  context-type 'Voice
                                                                  element ?sequence2)))))
-                    (format #f "\\partcombine ~a~a~a"
+                    (format #f "\\partcombine~a ~a~a~a"
+                            (cond ((equal? ?dir UP) "Up")
+                                  ((equal? ?dir DOWN) "Down")
+                                  (else ""))
                             (music->lily-string ?sequence1 parser)
                             (new-line->lily-string)
                             (music->lily-string ?sequence2 parser))))
 
+(define-extra-display-method ContextSpeccedMusic (expr parser)
+  "If `expr' is a \\partcombine expression, return \"\\partcombine ...\".
+Otherwise, return #f."
+  (with-music-match
+   (expr (music 'ContextSpeccedMusic
+                context-type 'Staff
+                element (music 'SimultaneousMusic
+                               elements ((music 'ContextSpeccedMusic
+                                                context-id "one"
+                                                context-type 'Voice)
+                                         (music 'ContextSpeccedMusic
+                                                context-id "two"
+                                                context-type 'Voice)
+                                         (music 'ContextSpeccedMusic
+                                                context-id "shared"
+                                                context-type 'Voice)
+                                         ?pc-music))))
+   (with-music-match
+    (?pc-music (music 'PartCombineMusic))
+    (format #f "~a" (music->lily-string ?pc-music parser)))))
+
 (define-display-method UnrelativableMusic (expr parser)
   (music->lily-string (ly:music-property expr 'element) parser))