From a89412a560827a2f6b78a16301a21100e57ee378 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 13 Aug 2000 23:23:46 +0200 Subject: [PATCH] patch::: 1.3.77.jcn4 1.3.77.jcn4 =========== * Part-combine iterator identifies Soli and A2 parts in threads by looking at rhythm and pitches. It switches Voice context automagically, and communicates current state using a2/solo/solo2 properties. * Simple A2_engraver (`a due) prints `a2/Solo/Solo II. Soli seem to arrive one request late. --- Generated by janneke@gnu.org, From = lilypond-1.3.77.jcn3, To = lilypond-1.3.77.jcn4 usage cd lilypond-source-dir; patch -E -p1 < lilypond-1.3.77.jcn4.diff Patches do not contain automatically generated files or (urg) empty directories, i.e., you should rerun autoconf, configure --- CHANGES | 18 +++- VERSION | 2 +- input/test/part-combine.ly | 8 +- lily/a2-engraver.cc | 137 ++++++++++++++++++++++++++++ lily/part-combine-music-iterator.cc | 99 ++++++++++---------- ly/engraver.ly | 3 +- 6 files changed, 211 insertions(+), 56 deletions(-) create mode 100644 lily/a2-engraver.cc diff --git a/CHANGES b/CHANGES index 76c1d7e6d9..ebc757006e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,20 @@ ---- ../lilypond-1.3.77.jcn2/CHANGES Sun Aug 13 15:50:59 2000 +--- ../lilypond-1.3.77.jcn3/CHANGES Sun Aug 13 20:05:00 2000 +++ b/CHANGES Sun Aug 13 23:23:46 2000 +@@ -1,3 +1,14 @@ +1.3.77.jcn4 +=========== + +* Part-combine iterator identifies Soli and A2 parts in threads by + looking at rhythm and pitches. It switches Voice context automagically, + and communicates current state using a2/solo/solo2 properties. + +* Simple A2_engraver (`a due) prints `a2/Solo/Solo II. Soli seem to + arrive one request late. + + + 1.3.77.jcn3 + =========== + --- ../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 diff --git a/VERSION b/VERSION index 02d85c324e..833ea3ac2a 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=77 -MY_PATCH_LEVEL=jcn3 +MY_PATCH_LEVEL=jcn4 # 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 index d228cd703d..074498488e 100644 --- a/input/test/part-combine.ly +++ b/input/test/part-combine.ly @@ -4,14 +4,18 @@ \context Voice=second { \skip 1; } \context Voice=first \partcombine Voice - \context Thread \notes\relative c'' + \context Thread=first \notes\relative c'' { c4 d e f + b,4 d c d + r2 e4 f c4 d e f } - \context Thread \notes\relative c'' + \context Thread=second \notes\relative c'' { a b c d + r2 c4 d + a c c d a4. b8 c4 d } > diff --git a/lily/a2-engraver.cc b/lily/a2-engraver.cc new file mode 100644 index 0000000000..65a239e030 --- /dev/null +++ b/lily/a2-engraver.cc @@ -0,0 +1,137 @@ +/* + a2-engraver.cc -- implement A2_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000 Jan Nieuwenhuizen +*/ + +#include "engraver.hh" +#include "item.hh" +#include "note-head.hh" +#include "stem.hh" +#include "translator-group.hh" +#include "side-position-interface.hh" +#include "directional-element-interface.hh" + +class A2_engraver : public Engraver +{ +public: + A2_engraver (); + VIRTUAL_COPY_CONS (Translator); + +protected: + virtual void do_process_music (); + virtual void acknowledge_element (Score_element_info); + //virtual void process_acknowledged (); + + virtual void do_pre_move_processing (); + +private: + Item* text_p_; +}; + +ADD_THIS_TRANSLATOR (A2_engraver); + +A2_engraver::A2_engraver () +{ + text_p_ = 0; +} + +void +A2_engraver::do_process_music () +{ + if (!text_p_) + { + SCM a2 = get_property ("a2"); + SCM solo = get_property ("solo"); + SCM solo2 = get_property ("solo2"); + + if (solo == SCM_BOOL_T || a2 == SCM_BOOL_T || solo2 == SCM_BOOL_T) + { + text_p_ = new Item (get_property ("basicTextScriptProperties")); + Side_position::set_axis (text_p_, Y_AXIS); + announce_element (text_p_, 0); + + /* + Urg, read prop + */ + SCM text; + Direction dir = UP; + if (solo == SCM_BOOL_T) + { + text = ly_str02scm ("Solo"); + } + else if (solo2 == SCM_BOOL_T) + { + text = ly_str02scm ("Solo II"); + dir = DOWN; + } + else if (a2 == SCM_BOOL_T) + { + text = ly_str02scm ("\\`a 2"); + } + + Side_position::set_direction (text_p_, dir); + text_p_->set_elt_property ("text", text); + + } + } +} + +void +A2_engraver::acknowledge_element (Score_element_info i) +{ + if (text_p_) + { + if (Note_head::has_interface (i.elem_l_)) + { + Score_element*t = text_p_; + Side_position::add_support (t, i.elem_l_); + if (Side_position::get_axis (t) == X_AXIS + && !t->parent_l (Y_AXIS)) + t->set_parent (i.elem_l_, Y_AXIS); + } + if (Stem::has_interface (i.elem_l_)) + { + Side_position::add_support (text_p_, i.elem_l_); + + SCM a2 = get_property ("a2"); + SCM solo = get_property ("solo"); + SCM solo2 = get_property ("solo2"); + + SCM first = get_property ("first"); + SCM second = get_property ("second"); + + if (solo != SCM_BOOL_T + && solo2 != SCM_BOOL_T + && a2 != SCM_BOOL_T) + { + if (first == SCM_BOOL_T) + { + Directional_element_interface (i.elem_l_).set (UP); + } + else if (second == SCM_BOOL_T) + { + Directional_element_interface (i.elem_l_).set (DOWN); + } + } + } + } +} + +void +A2_engraver::do_pre_move_processing () +{ + if (text_p_) + { + Side_position::add_staff_support (text_p_); + typeset_element (text_p_); + text_p_ = 0; + } + // burp: reset properties + daddy_trans_l_->set_property ("a2", SCM_BOOL_F); + daddy_trans_l_->set_property ("solo", SCM_BOOL_F); + daddy_trans_l_->set_property ("solo2", SCM_BOOL_F); +} + diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 33bea70d14..0f6b907551 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -117,11 +117,10 @@ 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 + bool changed_b = false; + Part_combine_music const * p = dynamic_cast (music_l_); + String to_id = combined_b_ ? "first" : "second"; /* different rhythm for combined voices: separate same rhythm for separated voices: combine @@ -130,47 +129,29 @@ Part_combine_music_iterator::do_process_and_next (Moment m) || (first_next == second_next && !combined_b_)) { combined_b_ = !combined_b_; - String to_id = combined_b_ ? "first" : "second"; - - Part_combine_music const * p = dynamic_cast (music_l_); - + to_id = combined_b_ ? "first" : "second"; 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)); - } + changed_b = true; } - first_iter_p_->process_and_next (m); - second_iter_p_->process_and_next (m); + 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); - Music_iterator::do_process_and_next (m); + fd->set_property ("first", SCM_BOOL_T); + if (!combined_b_) + sd->set_property ("second", SCM_BOOL_T); + if (first_next <= m) + first_iter_p_->process_and_next (m); -#if 0 + if (second_next <= m) + second_iter_p_->process_and_next (m); + + Music_iterator::do_process_and_next (m); /* TODO: @@ -207,23 +188,39 @@ Part_combine_music_iterator::do_process_and_next (Moment m) 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 ()) + /* + Hmm. In the case of a2, the second identical set of requests must + be junked: that's the whole point of detecting a2. Howto/whereto + junk these requests? + */ + if (changed_b + && (first_next == second_next) + && first_spanish_inquisition->pitch_arr_.size () + && (first_spanish_inquisition->pitch_arr_.size () + == second_spanish_inquisition->pitch_arr_.size ()) + && (first_spanish_inquisition->pitch_arr_[0] == + second_spanish_inquisition->pitch_arr_[0])) + { + fd->set_property ("a2", SCM_BOOL_T); + sd->set_property ("a2", SCM_BOOL_T); + } + + if (changed_b + && first_spanish_inquisition->pitch_arr_.size () + && !second_spanish_inquisition->pitch_arr_.size ()) + { + fd->set_property ("solo", SCM_BOOL_T); + } + + if (changed_b + && !first_spanish_inquisition->pitch_arr_.size () + && second_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 (music_l_); - - change_to (it, auto_mus->what_str_, to_id); - } + sd->set_property ("solo2", SCM_BOOL_T); } first_spanish_inquisition->pitch_arr_.clear (); second_spanish_inquisition->pitch_arr_.clear (); -#endif } Music_iterator* diff --git a/ly/engraver.ly b/ly/engraver.ly index 35e94628b2..fbbf35f2e6 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -145,6 +145,7 @@ VoiceContext = \translator { \consists "Melisma_engraver"; textScriptPadding = #3.0 \consists "Text_engraver"; + \consists "A2_engraver"; startSustain = #"Ped." @@ -204,7 +205,7 @@ GraceContext=\translator { ThreadContext = \translator{ \type Engraver_group_engraver; - \consists "Note_heads_engraver" ; + \consists "Note_heads_engraver"; \consists "Output_property_engraver"; Generic_property_list = #generic-thread-properties \consists "Property_engraver"; -- 2.39.2