From 027f1aab2ec8fbbc8a20cf421510f8b9a259d6d2 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 14 Aug 2000 20:55:10 +0200 Subject: [PATCH] patch::: 1.3.78.jcn1 1.3.78.jcn1 =========== * Fixed a2-devnull-engraver, a2-engraver. * Renamed part combiner music names to "one", "two". * Cleaned up property setting of part combiner, renamed to "solo"/"unison" --- CHANGES | 10 ++ VERSION | 2 +- input/test/part-combine.ly | 14 +-- lily/a2-devnull-engraver.cc | 22 ++-- lily/a2-engraver.cc | 89 ++++++++++------ lily/chord.cc | 15 +-- lily/include/musical-pitch.hh | 2 + lily/include/part-combine-music-iterator.hh | 2 +- lily/musical-pitch.cc | 15 +++ lily/part-combine-music-iterator.cc | 110 ++++++++++++-------- lily/part-combine-music.cc | 8 +- 11 files changed, 171 insertions(+), 118 deletions(-) diff --git a/CHANGES b/CHANGES index d46d267c6c..983fbc6e78 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +1.3.78.jcn1 +=========== + +* Fixed a2-devnull-engraver, a2-engraver. + +* Renamed part combiner music names to "one", "two". + +* Cleaned up property setting of part combiner, renamed to "solo"/"unison" + + 1.3.77.jcn5 =========== diff --git a/VERSION b/VERSION index ba678f5afe..c1932a9645 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=78 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # 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 074498488e..1213e9d1a9 100644 --- a/input/test/part-combine.ly +++ b/input/test/part-combine.ly @@ -1,19 +1,19 @@ \score{ - \context Staff = first < - \context Voice=first { \skip 1; } - \context Voice=second { \skip 1; } + \context Staff = one < + \context Voice=one { \skip 1; } + \context Voice=two { \skip 1; } - \context Voice=first \partcombine Voice - \context Thread=first \notes\relative c'' + \context Voice=one \partcombine Voice + \context Thread=one \notes\relative c'' { c4 d e f b,4 d c d r2 e4 f c4 d e f } - \context Thread=second \notes\relative c'' + \context Thread=two \notes\relative c'' { - a b c d + g b d f r2 c4 d a c c d a4. b8 c4 d diff --git a/lily/a2-devnull-engraver.cc b/lily/a2-devnull-engraver.cc index 680dedb5a3..e0f9545333 100644 --- a/lily/a2-devnull-engraver.cc +++ b/lily/a2-devnull-engraver.cc @@ -17,25 +17,15 @@ public: VIRTUAL_COPY_CONS (Translator); protected: - virtual bool do_try_music (Music*); + virtual void acknowledge_element (Score_element_info); }; ADD_THIS_TRANSLATOR (A2_devnull_engraver); -bool -A2_devnull_engraver::do_try_music (Music *m) +void +A2_devnull_engraver::acknowledge_element (Score_element_info i) { - if (Note_req * n = dynamic_cast (m)) - { - SCM a2 = get_property ("a2"); - // should be able to read id_str_, no? - SCM second = get_property ("second"); - - if (a2 == SCM_BOOL_T && second == SCM_BOOL_T) - { - return true; - } - } - return false; + if (daddy_trans_l_->id_str_ == "two" + && to_boolean (get_property ("unison"))) + i.elem_l_->suicide (); } - diff --git a/lily/a2-engraver.cc b/lily/a2-engraver.cc index 65a239e030..2aedb05b20 100644 --- a/lily/a2-engraver.cc +++ b/lily/a2-engraver.cc @@ -23,12 +23,12 @@ public: 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_; + enum State { NORMAL, UNISON, SOLO } state_; }; ADD_THIS_TRANSLATOR (A2_engraver); @@ -36,18 +36,25 @@ ADD_THIS_TRANSLATOR (A2_engraver); A2_engraver::A2_engraver () { text_p_ = 0; + state_ = NORMAL; } void A2_engraver::do_process_music () +{ +} + + +void +A2_engraver::acknowledge_element (Score_element_info i) { if (!text_p_) { - SCM a2 = get_property ("a2"); + SCM unison = get_property ("unison"); SCM solo = get_property ("solo"); - SCM solo2 = get_property ("solo2"); - if (solo == SCM_BOOL_T || a2 == SCM_BOOL_T || solo2 == SCM_BOOL_T) + if ((solo == SCM_BOOL_T && state_ != SOLO) + || (unison == SCM_BOOL_T && state_ != UNISON)) { text_p_ = new Item (get_property ("basicTextScriptProperties")); Side_position::set_axis (text_p_, Y_AXIS); @@ -60,28 +67,33 @@ A2_engraver::do_process_music () 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; + state_ = SOLO; + if (daddy_trans_l_->id_str_ == "one") + text = ly_str02scm ("Solo"); + else + { + text = ly_str02scm ("Solo II"); + dir = DOWN; + } } - else if (a2 == SCM_BOOL_T) + else if (unison == SCM_BOOL_T) { text = ly_str02scm ("\\`a 2"); + state_ = UNISON; } - + Side_position::set_direction (text_p_, dir); text_p_->set_elt_property ("text", text); } } +#if 0 } void A2_engraver::acknowledge_element (Score_element_info i) { +#endif if (text_p_) { if (Note_head::has_interface (i.elem_l_)) @@ -95,26 +107,39 @@ A2_engraver::acknowledge_element (Score_element_info i) 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 (Stem::has_interface (i.elem_l_)) + { + SCM unirhythm = get_property ("unirhythm"); + SCM unison = get_property ("unison"); + SCM solo = get_property ("solo"); + SCM interval = get_property ("interval"); + + /* + This still needs some work. + */ + if ((unirhythm != SCM_BOOL_T && solo != SCM_BOOL_T)) +#if 0 + /* + Apart from the uglyness of this, we can't do this yet + because to get up/down stems for small intervals, we + need Part_combine_music_iterator to uncombine the + voices (while still setting unison). + */ + || (unirhythm == SCM_BOOL_T + && gh_number_p (interval) && gh_scm2int (interval) < 3)) +#endif + { + if (daddy_trans_l_->id_str_ == "one") { - 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); - } + Directional_element_interface (i.elem_l_).set (UP); + } + else if (daddy_trans_l_->id_str_ == "two") + { + Directional_element_interface (i.elem_l_).set (DOWN); } } } @@ -129,9 +154,5 @@ A2_engraver::do_pre_move_processing () 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/chord.cc b/lily/chord.cc index 6c85816726..ef1c58a66f 100644 --- a/lily/chord.cc +++ b/lily/chord.cc @@ -13,6 +13,7 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" +#include "lookup.hh" int compare (Chord* left, Chord* right) @@ -20,17 +21,9 @@ compare (Chord* left, Chord* right) assert (left); assert (right); - if (left->inversion_b_ == right->inversion_b_ - && left->bass_b_ == right->bass_b_ - && left->pitch_arr_.size () == right->pitch_arr_.size ()) - { - for (int i = 0; i < left->pitch_arr_.size (); i++) - if (left->pitch_arr_[i] != right->pitch_arr_[i]) - return 1; - return 0; - } - - return 1; + return !(left->inversion_b_ == right->inversion_b_ + && left->bass_b_ == right->bass_b_ + && !compare (&left->pitch_arr_, &right->pitch_arr_)); } /* diff --git a/lily/include/musical-pitch.hh b/lily/include/musical-pitch.hh index 7f2c386b4d..079de76c8f 100644 --- a/lily/include/musical-pitch.hh +++ b/lily/include/musical-pitch.hh @@ -53,5 +53,7 @@ struct Musical_pitch : public Input #include "compare.hh" INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare); +int compare (Array*, Array*); + #endif /* MUSICAL_PITCH_HH */ diff --git a/lily/include/part-combine-music-iterator.hh b/lily/include/part-combine-music-iterator.hh index 60cbebc8fc..dcf86214e8 100644 --- a/lily/include/part-combine-music-iterator.hh +++ b/lily/include/part-combine-music-iterator.hh @@ -33,7 +33,7 @@ private: Music_iterator * first_iter_p_; Music_iterator * second_iter_p_; - bool combined_b_; + bool unirhythm_b_; }; #endif /* PART_COMBINE_MUSIC_ITERATOR_HH */ diff --git a/lily/musical-pitch.cc b/lily/musical-pitch.cc index 0ebd91dfe4..5e82e01c7b 100644 --- a/lily/musical-pitch.cc +++ b/lily/musical-pitch.cc @@ -10,6 +10,21 @@ #include "debug.hh" #include "main.hh" +int +compare (Array* left, Array* right) +{ + assert (left); + assert (right); + + if (left->size () == right->size ()) + { + for (int i = 0; i < left->size (); i++) + if ((*left)[i] != (*right)[i]) + return 1; + } + return 0; +} + SCM Musical_pitch::to_scm ()const { diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 86f035486b..6933b2bd1c 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -14,7 +14,7 @@ Part_combine_music_iterator::Part_combine_music_iterator () { - combined_b_ = false; + unirhythm_b_ = false; first_iter_p_ = 0; second_iter_p_ = 0; @@ -117,32 +117,40 @@ 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 (); - bool changed_b = false; Part_combine_music const * p = dynamic_cast (music_l_); - String to_id = combined_b_ ? "first" : "second"; + String to_id = unirhythm_b_ ? "one" : "two"; /* different rhythm for combined voices: separate same rhythm for separated voices: combine + + Arg. Voices should be separated for small intervals, eg < 3. + This should be \property settable, and, we need the outcome + of the spanish_inquisition's... + + Can't we first do a process_and_next go into a fake/tmp tree, + use + junk the result, and then do the real process_and_next...? + */ - if ((first_next != second_next && combined_b_) - || (first_next == second_next && !combined_b_)) + if ((first_next != second_next && unirhythm_b_) + || (first_next == second_next && !unirhythm_b_)) { - combined_b_ = !combined_b_; - to_id = combined_b_ ? "first" : "second"; + unirhythm_b_ = !unirhythm_b_; + to_id = unirhythm_b_ ? "one" : "two"; change_to (second_iter_p_, p->what_str_, to_id); - changed_b = true; } Translator_group * fd = first_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_, - "first"); + "one"); Translator_group * sd = second_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_, to_id); - fd->set_property ("first", SCM_BOOL_T); - sd->set_property ("second", SCM_BOOL_T); + fd->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F); + sd->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F); + first_iter_p_->report_to_l ()->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F); + second_iter_p_->report_to_l ()->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F); if (first_next <= m) first_iter_p_->process_and_next (m); @@ -155,23 +163,17 @@ Part_combine_music_iterator::do_process_and_next (Moment m) /* TODO: - * "a2" string is fine, but "Soli" strings are one request late, - second a2 requests are junked one requst late... + * "a2" string is fine, but "Soli" strings are one request late?? The problem seems to be: we need to do_try_music for the spanish_inquisition to work; but the properties that we set need to be set *before* we do_try_music? * setting of stem directions by a2-engraver don't work - - * move much as possible code (changed?) to engravers: just notify - them of status: unison/solo. Engravers should be able to find - out whether something changed and if so, what to do. - - * who should reset the properties, it's a mess now? - - Later (because currently,we only handle thread swiching, really): + * separate for small ( <3 ?) intervals too + + Later (because currently, we only handle thread switching, really): Maybe different modes exist? @@ -198,39 +200,59 @@ 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); - - // URG, moveme: just set properties - 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])) + if ((first_next == second_next) + && !compare (&first_spanish_inquisition->pitch_arr_, + &second_spanish_inquisition->pitch_arr_)) { - if (changed_b) - { - fd->set_property ("a2", SCM_BOOL_T); - sd->set_property ("a2", SCM_BOOL_T); - } - second_iter_p_->report_to_l ()->set_property ("a2", SCM_BOOL_T); + fd->set_property ("unison", SCM_BOOL_T); + sd->set_property ("unison", SCM_BOOL_T); + first_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_T); + second_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_T); } else - second_iter_p_->report_to_l ()->set_property ("a2", SCM_BOOL_F); - - if (changed_b - && first_spanish_inquisition->pitch_arr_.size () + { + fd->set_property ("unison", SCM_BOOL_F); + sd->set_property ("unison", SCM_BOOL_F); + first_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_F); + second_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_F); + } + + if (first_spanish_inquisition->pitch_arr_.size () && + second_spanish_inquisition->pitch_arr_.size ()) + { + first_spanish_inquisition->pitch_arr_.sort (Musical_pitch::compare); + second_spanish_inquisition->pitch_arr_.sort (Musical_pitch::compare); + SCM interval = gh_int2scm (first_spanish_inquisition->pitch_arr_.top ().semitone_pitch () + - second_spanish_inquisition->pitch_arr_[0].semitone_pitch ()); + fd->set_property ("interval", interval); + sd->set_property ("interval", interval); + first_iter_p_->report_to_l ()->set_property ("interval", interval); + second_iter_p_->report_to_l ()->set_property ("interval", interval); + } + + if (first_spanish_inquisition->pitch_arr_.size () && !second_spanish_inquisition->pitch_arr_.size ()) { fd->set_property ("solo", SCM_BOOL_T); + first_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_T); } + else + { + fd->set_property ("solo", SCM_BOOL_F); + first_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_F); + } + - if (changed_b - && !first_spanish_inquisition->pitch_arr_.size () + if (!first_spanish_inquisition->pitch_arr_.size () && second_spanish_inquisition->pitch_arr_.size ()) { - sd->set_property ("solo2", SCM_BOOL_T); + sd->set_property ("solo", SCM_BOOL_T); + second_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_T); + } + else + { + sd->set_property ("solo", SCM_BOOL_F); + second_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_F); } first_spanish_inquisition->pitch_arr_.clear (); diff --git a/lily/part-combine-music.cc b/lily/part-combine-music.cc index 41127ac741..27064244b7 100644 --- a/lily/part-combine-music.cc +++ b/lily/part-combine-music.cc @@ -13,8 +13,8 @@ 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 ()); + set_mus_property ("one", f->self_scm ()); + set_mus_property ("two", s->self_scm ()); } @@ -55,11 +55,11 @@ Part_combine_music::compress (Moment m) Music* Part_combine_music::first_l () const { - return unsmob_music (get_mus_property ("first")); + return unsmob_music (get_mus_property ("one")); } Music* Part_combine_music::second_l () const { - return unsmob_music (get_mus_property ("second")); + return unsmob_music (get_mus_property ("two")); } -- 2.39.5