]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.77.jcn3
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 13 Aug 2000 18:05:00 +0000 (20:05 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 13 Aug 2000 18:05:00 +0000 (20:05 +0200)
1.3.77.jcn3
===========

* First try at combining parts: part-combine*

---
Generated by janneke@gnu.org,
From = lilypond-1.3.77.jcn2, To = lilypond-1.3.77.jcn3

usage

    cd lilypond-source-dir; patch -E -p1 < lilypond-1.3.77.jcn3.diff

Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure

CHANGES
VERSION
input/test/part-combine.ly [new file with mode: 0644]
lily/include/part-combine-music-iterator.hh [new file with mode: 0644]
lily/include/part-combine-music.hh [new file with mode: 0644]
lily/music-iterator.cc
lily/my-lily-lexer.cc
lily/parser.yy
lily/part-combine-music-iterator.cc [new file with mode: 0644]
lily/part-combine-music.cc [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index bc42e868b4a385f3c7ad88e0df5bac8ccc9da296..76c1d7e6d9fd04aa21a796e472d1d8968f3f656a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,15 @@
---- ../lilypond-1.3.77.jcn1/CHANGES    Wed Aug  9 23:30:23 2000
+--- ../lilypond-1.3.77.jcn2/CHANGES    Sun Aug 13 15:50:59 2000
+++ b/CHANGES   Sun Aug 13 20:05:00 2000
+@@ -1,3 +1,9 @@
+1.3.77.jcn3
+===========
+
+* First try at combining parts: part-combine*
+
+
+ * fixed problem with HaraKiri
+ * fixed problem with dynamicDirection--- ../lilypond-1.3.77.jcn1/CHANGES      Wed Aug  9 23:30:23 2000
 ++ b/CHANGES   Sun Aug 13 15:50:59 2000
 @@ -1,3 +1,10 @@
 * fixed problem with HaraKiri
diff --git a/VERSION b/VERSION
index 30db784b6318b619f9c76374dfadb82ea7de8bbd..02d85c324e72e54121cfd73c6935ffbe604168bb 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=77
-MY_PATCH_LEVEL=jcn2
+MY_PATCH_LEVEL=jcn3
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/test/part-combine.ly b/input/test/part-combine.ly
new file mode 100644 (file)
index 0000000..d228cd7
--- /dev/null
@@ -0,0 +1,18 @@
+\score{
+       \context Staff = first <
+               \context Voice=first { \skip 1; }
+               \context Voice=second { \skip 1; }
+
+               \context Voice=first \partcombine Voice
+                       \context Thread \notes\relative c''
+                               {
+                                       c4 d e f
+                                       c4 d e f
+                               }
+                       \context Thread \notes\relative c''
+                               {
+                                       a b c d
+                                       a4. b8 c4 d
+                               }
+               >
+}
diff --git a/lily/include/part-combine-music-iterator.hh b/lily/include/part-combine-music-iterator.hh
new file mode 100644 (file)
index 0000000..60cbebc
--- /dev/null
@@ -0,0 +1,40 @@
+/*   
+  part-combine-music-iterator.hh -- declare Part_combine_music_iterator
+  
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#ifndef PART_COMBINE_MUSIC_ITERATOR_HH
+#define PART_COMBINE_MUSIC_ITERATOR_HH
+
+#include "music-iterator.hh"
+
+class Part_combine_music_iterator : public Music_iterator
+{
+public:
+  Part_combine_music_iterator ();
+
+protected:
+  virtual void construct_children ();
+  virtual Moment next_moment () const;
+  virtual void do_process_and_next (Moment);
+  virtual Music_iterator *try_music_in_children (Music *) const;
+
+  virtual bool ok () const;
+  virtual void do_print () const;
+  virtual ~Part_combine_music_iterator ();
+
+private:
+  void change_to (Music_iterator*, String, String);
+
+  Music_iterator * first_iter_p_;
+  Music_iterator * second_iter_p_;
+
+  bool combined_b_;
+};
+
+#endif /* PART_COMBINE_MUSIC_ITERATOR_HH */
+
diff --git a/lily/include/part-combine-music.hh b/lily/include/part-combine-music.hh
new file mode 100644 (file)
index 0000000..102de3a
--- /dev/null
@@ -0,0 +1,35 @@
+/*   
+  part-combine-music.hh -- declare Part_combine_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#ifndef PART_COMBINE_MUSIC_HH
+#define PART_COMBINE_MUSIC_HH
+
+#include "music.hh"
+
+
+class Part_combine_music : public Music
+{
+public:
+  VIRTUAL_COPY_CONS (Music);
+  Part_combine_music (String, Music*, Music*);
+
+  Music * first_l () const;
+  Music * second_l () const;
+  
+  virtual void transpose (Musical_pitch);
+  virtual void do_print () const;
+  virtual Moment length_mom () const;
+  virtual Musical_pitch to_relative_octave (Musical_pitch);
+  virtual void compress (Moment);
+
+  String what_str_;
+};
+
+#endif /* PART_COMBINE_MUSIC_HH */
+
index d3a92834e74dc7ef23d39849747f97f67978765b..9e88aeb12b1a7c6e0bc7f94a08233fc1f1752733 100644 (file)
@@ -34,6 +34,8 @@
 #include "lyric-combine-music-iterator.hh"
 #include "auto-change-music.hh"
 #include "auto-change-iterator.hh"
+#include "part-combine-music.hh"
+#include "part-combine-music-iterator.hh"
 #include "request.hh"
 #include "request-iterator.hh"
 #include "output-property.hh"
@@ -146,6 +148,8 @@ Music_iterator::static_get_iterator_p (Music  *m)
     p = new Grace_iterator;
   else if (dynamic_cast<Auto_change_music *> (m))
     p = new Auto_change_iterator;
+  else if (dynamic_cast<Part_combine_music *> (m))
+    p = new Part_combine_music_iterator;
   else if (dynamic_cast<Music_wrapper   *> (m))
     p = new Music_wrapper_iterator;
   else if (Repeated_music  * n = dynamic_cast<Repeated_music  *> (m))
index 9020ae16590f1e81ce5b710369df54faa8fa71ec..4bd5a30495bba5541a84a8a88864bba29a61b117 100644 (file)
@@ -66,6 +66,7 @@ static Keyword_ent the_key_tab[]={
   {"remove", REMOVE},
   {"repeat", REPEAT},
   {"addlyrics", ADDLYRICS},
+  {"partcombine", PARTCOMBINE},
   {"score", SCORE},
   {"script", SCRIPT},
   {"skip", SKIP},
index 5c4632ac7227f192e5c9415944f9072a60792b34..215dd6939480a49b58213f9ffc20f84a196108c4 100644 (file)
@@ -41,6 +41,7 @@
 #include "mudela-version.hh"
 #include "grace-music.hh"
 #include "auto-change-music.hh"
+#include "part-combine-music.hh"
 #include "output-property.hh"
 
 bool
@@ -168,6 +169,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token REMOVE
 %token REPEAT
 %token ADDLYRICS
+%token PARTCOMBINE
 %token SCM_T
 %token SCORE
 %token SCRIPT
@@ -237,7 +239,7 @@ yylex (YYSTYPE *s,  void * v_l)
 
 %type <scm>  embedded_scm scalar
 %type <music>  Music Sequential_music Simultaneous_music Music_sequence
-%type <music>  relative_music re_rhythmed_music
+%type <music>  relative_music re_rhythmed_music part_combined_music
 %type <music>  property_def translator_change
 %type <scm> Music_list
 %type <outputdef>  music_output_def_body
@@ -757,6 +759,7 @@ Composite_music:
        }
        | relative_music        { $$ = $1; }
        | re_rhythmed_music     { $$ = $1; } 
+       | part_combined_music   { $$ = $1; } 
        ;
 
 relative_music:
@@ -773,6 +776,13 @@ re_rhythmed_music:
        }
        ;
 
+part_combined_music:
+       PARTCOMBINE STRING Music Music {
+               Part_combine_music * p = new Part_combine_music (ly_scm2string ($2), $3, $4);
+               $$ = p;
+       }
+       ;
+
 translator_change:
        TRANSLATOR STRING '=' STRING  {
                Change_translator * t = new Change_translator;
diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc
new file mode 100644 (file)
index 0000000..33bea70
--- /dev/null
@@ -0,0 +1,238 @@
+/*   
+  part-combine-music-iterator.cc -- implement  Part_combine_music_iterator
+
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+ */
+
+#include "part-combine-music.hh"
+#include "part-combine-music-iterator.hh"
+#include "translator-group.hh"
+#include "musical-request.hh"
+#include "warn.hh"
+
+Part_combine_music_iterator::Part_combine_music_iterator ()
+{
+  combined_b_ = false;
+
+  first_iter_p_ = 0;
+  second_iter_p_ = 0;
+}
+
+Part_combine_music_iterator::~Part_combine_music_iterator ()
+{
+  delete second_iter_p_;
+  delete first_iter_p_;
+}
+
+Moment
+Part_combine_music_iterator::next_moment () const
+{
+  Moment first_next = first_iter_p_->next_moment ();
+  Moment second_next = second_iter_p_->next_moment ();
+  return first_next <? second_next;
+}
+
+bool
+Part_combine_music_iterator::ok () const
+{
+  //hmm
+  return first_iter_p_->ok ();
+}
+
+void
+Part_combine_music_iterator::do_print () const
+{
+  first_iter_p_->print ();
+  second_iter_p_->print ();
+}
+
+void
+Part_combine_music_iterator::construct_children ()
+{
+  Part_combine_music const * m = dynamic_cast<Part_combine_music const*> (music_l_);
+  
+  first_iter_p_ = get_iterator_p (m->first_l ());
+  second_iter_p_ = get_iterator_p (m->second_l ());
+}
+
+void
+Part_combine_music_iterator::change_to (Music_iterator *it, String to_type,
+                                       String to_id)
+{
+  Translator_group * current = it->report_to_l ();
+  Translator_group * last = 0;
+
+  /*
+    Cut & Paste from from Auto_change_iterator from Change_iterator (ugh).
+
+    TODO: abstract this function 
+   */
+  
+  /* find the type  of translator that we're changing.
+     
+     If \translator Staff = bass, then look for Staff = *
+   */
+  while  (current && current->type_str_ != to_type)
+    {
+      last = current;
+      current = current->daddy_trans_l_;
+    }
+
+  if (current && current->id_str_ == to_id)
+    {
+      String msg;
+      msg += _ ("Can't switch translators, I'm there already");
+    }
+  
+  if (current) 
+    if (last)
+      {
+       Translator_group * dest = 
+         it->report_to_l ()->find_create_translator_l (to_type, to_id);
+       current->remove_translator_p (last);
+       dest->add_translator (last);
+      }
+    else
+      {
+       /*
+         We could change the current translator's id, but that would make 
+         errors hard to catch
+         
+          last->translator_id_str_  = change_l ()->change_to_id_str_;
+       */
+       error (_f ("I'm one myself: `%s'", to_type.ch_C ()));
+      }
+  else
+    error (_f ("none of these in my family: `%s'", to_id.ch_C ()));
+}
+
+Pitch_interrogate_req* first_spanish_inquisition; // nobody expects it
+Pitch_interrogate_req* second_spanish_inquisition; // won't strike twice
+
+void
+Part_combine_music_iterator::do_process_and_next (Moment m)
+{
+  Moment first_next = first_iter_p_->next_moment ();
+  Moment second_next = second_iter_p_->next_moment ();
+
+#if 0
+  if (first_next > m || second_next > m)
+    return;
+#endif
+
+  /*
+    different rhythm for combined voices: separate 
+    same rhythm for separated voices: combine
+  */
+  if ((first_next != second_next && combined_b_)
+      || (first_next == second_next && !combined_b_))
+    {
+      combined_b_ = !combined_b_;
+      String to_id =  combined_b_ ? "first" : "second";
+
+      Part_combine_music const * p = dynamic_cast<Part_combine_music const* > (music_l_);
+
+      change_to (second_iter_p_, p->what_str_, to_id);
+
+      /*
+       A quick ugly hack to see if it works..
+       */
+#if 0
+      Translator_group * fd = 
+       first_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_,
+                                                                "first");
+      Translator_group * sd = 
+       second_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_,
+                                                                 to_id);
+#else
+      Translator_group * fd = first_iter_p_->report_to_l ();
+      Translator_group * sd = second_iter_p_->report_to_l ();
+#endif
+      
+      if (combined_b_)
+       {
+         fd->set_property ("verticalDirection", gh_int2scm (0));
+         fd->set_property ("noteHeadStyle", ly_symbol2scm ("default"));
+       }
+      else
+       {
+         fd->set_property ("verticalDirection", gh_int2scm (1));
+         fd->set_property ("noteHeadStyle", ly_symbol2scm ("diamond"));
+         sd->set_property ("verticalDirection", gh_int2scm (-1));
+       }
+    }
+
+  first_iter_p_->process_and_next (m);
+  second_iter_p_->process_and_next (m);
+
+  Music_iterator::do_process_and_next (m);
+
+
+#if 0 
+
+  /*
+    TODO:
+
+    * when combining two threads: check pitches, request stem directions
+
+    * a2-engraver to put texts a2/Solo/SoloII as appropriate.
+
+    * maybe the a2-engraver should set the stem directions, iso us?
+    
+
+    Maybe different modes exist?
+
+    * Wind instruments (Flute I/II)
+    * Hymnals:  
+
+
+      Rules for Hymnals/SATB (John Henckel <henckel@iname.com>):
+
+      1. if S and A differ by less than a third, the stems should be up/down.
+      2. else if S and A have different values, the stems should be up/down.
+      3. else if A sings "la" or higher, both S and A stems should be down.
+      4. else both stems should be up
+
+    * This may get really tricky: combining voices/staffs: string instruments
+
+   */
+  
+  if (!first_spanish_inquisition)
+    first_spanish_inquisition = new Pitch_interrogate_req;
+  Music_iterator* fit = first_iter_p_->try_music (first_spanish_inquisition);
+
+  if (!second_spanish_inquisition)
+    second_spanish_inquisition = new Pitch_interrogate_req;
+  Music_iterator* sit = second_iter_p_->try_music (second_spanish_inquisition);
+
+  if (fit && first_spanish_inquisition->pitch_arr_.size ())
+    {
+      Musical_pitch p = spanish_inquisition->pitch_arr_[0];
+      Direction s = Direction (sign(p.steps ()));
+      if (s != where_dir_)
+       {
+         where_dir_ = s;
+         String to_id =  (s >= 0) ?  "up" : "down";
+         Part_combine_music const * auto_mus = dynamic_cast<Part_combine_music const* > (music_l_);
+
+         change_to (it, auto_mus->what_str_, to_id);     
+       }
+    }
+
+  first_spanish_inquisition->pitch_arr_.clear ();
+  second_spanish_inquisition->pitch_arr_.clear ();
+#endif
+}
+
+Music_iterator*
+Part_combine_music_iterator::try_music_in_children (Music *m) const
+{
+  Music_iterator * i =  first_iter_p_->try_music (m);
+  if (i)
+    return i;
+  else
+    return second_iter_p_->try_music (m);
+}
+
diff --git a/lily/part-combine-music.cc b/lily/part-combine-music.cc
new file mode 100644 (file)
index 0000000..41127ac
--- /dev/null
@@ -0,0 +1,65 @@
+/*   
+  part-combine-music.cc --  implement Part_combine_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#include "part-combine-music.hh"
+#include "musical-pitch.hh"
+
+Part_combine_music::Part_combine_music (String what, Music * f, Music * s)
+{
+  what_str_ = what;
+  set_mus_property ("first", f->self_scm ());
+  set_mus_property ("second", s->self_scm ());  
+}
+
+
+void
+Part_combine_music::transpose (Musical_pitch p)
+{
+  first_l ()->transpose (p);
+  second_l () ->transpose (p);
+}
+
+void
+Part_combine_music::do_print () const  
+{
+  first_l ()->print();
+  second_l () ->print ();
+}
+
+Moment
+Part_combine_music::length_mom () const
+{
+  return first_l ()->length_mom ();
+}
+
+Musical_pitch
+Part_combine_music::to_relative_octave (Musical_pitch p)
+{
+  p = first_l ()->to_relative_octave (p);
+  return second_l ()->to_relative_octave (p);
+}
+
+void
+Part_combine_music::compress (Moment m)
+{
+  first_l ()->compress (m);
+  second_l ()->compress (m);
+}
+
+Music*
+Part_combine_music::first_l () const
+{
+  return unsmob_music (get_mus_property ("first"));
+}
+
+Music*
+Part_combine_music::second_l () const
+{
+  return unsmob_music (get_mus_property ("second"));
+}