--- lilypond-2.5.10/lily/part-combine-iterator.cc 2004-11-18 18:02:22.000000000 -0500 +++ lilypond-2.5.10bret/lily/part-combine-iterator.cc 2005-02-01 14:26:30.555201403 -0500 @@ -74,6 +74,8 @@ void solo2 (); void apart (bool silent); void unisono (bool silent); + + void set_activevoice_property(char *, char *); }; @@ -148,6 +150,26 @@ } void +Part_combine_iterator::set_activevoice_property(char *v1, char *v2) +{ + Context *t = get_outlet (); + while (t) { + String cs = t->context_name (); + if (!String::compare(cs,"Staff")) { + t->set_property("activeVoicePartOne", ly_symbol2scm(v1)); + t->set_property("activeVoicePartTwo", ly_symbol2scm(v2)); + //cs = t->id_string(); + //get_music()->origin()->warning(_f("Setting %s/%s on staff %s\n", + //v1, v2, cs.to_str0() ) ); + return; + } + t = t->get_parent_context (); + } +} + + + +void Part_combine_iterator::chords_together () { if (state_ == TOGETHER) @@ -158,6 +180,7 @@ state_ = TOGETHER; substitute_both (shared_.get_outlet (), shared_.get_outlet ()); + set_activevoice_property("shared", "shared"); } } @@ -198,6 +221,7 @@ first_iter_-> try_music_in_children (event); } playing_state_ = SOLO1; + set_activevoice_property("solo", "null"); } } @@ -244,9 +268,24 @@ in the 1st voice, so in that case, we use the second voice as a basis for events. */ - Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet() : shared_.get_outlet(); - Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet() : null_.get_outlet(); - substitute_both (c1, c2); + // BDW: If unison, keep separate stems + if (newstate == UNISONO) { + substitute_both (one_.get_outlet(), two_.get_outlet()); + set_activevoice_property("one", "two"); + } else { + // BDW: if rests, only need one voice + if (last_playing_ == SOLO2) { + substitute_both(null_.get_outlet(), shared_.get_outlet()); + set_activevoice_property("null", "shared"); + } else { + substitute_both(shared_.get_outlet(), null_.get_outlet()); + set_activevoice_property("shared", "null"); + } + // Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet() : shared_.get_outlet(); + // Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet() : null_.get_outlet(); + // substitute_both (c1, c2); + } + kill_mmrest ((last_playing_ == SOLO2) ? one_.get_outlet () : two_.get_outlet ()); kill_mmrest (shared_.get_outlet ()); @@ -285,6 +324,7 @@ second_iter_-> try_music_in_children (event); playing_state_ = SOLO2; + set_activevoice_property("null", "solo"); } } } @@ -301,6 +341,7 @@ { state_ = APART; substitute_both (one_.get_outlet (), two_.get_outlet ()); + set_activevoice_property("one", "two"); } } --- lilypond-2.5.10/lily/new-lyric-combine-music-iterator.cc 2005-01-14 08:57:04.000000000 -0500 +++ lilypond-2.5.10bret/lily/new-lyric-combine-music-iterator.cc 2005-02-01 14:44:02.835681939 -0500 @@ -36,6 +36,8 @@ Context *lyrics_context_; Context *music_context_; SCM lyricsto_voice_name_; + SCM last_associatedVoice_; + bool voice_from_staff_; Music_iterator * lyric_iter_; }; @@ -54,6 +56,8 @@ lyric_iter_ = 0; music_context_ = 0; lyrics_context_ = 0; + last_associatedVoice_ = SCM_EOL; + voice_from_staff_ = false; /* Ugh. out of place here. @@ -166,8 +170,18 @@ if (scm_is_string (running)) voice_name = running; - if (scm_is_string (voice_name) - && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) + /* We have to look up the voice context if one of the following + three conditions holds: + (1) The music_context_ is not yet set + (2) The voice_name indicates a staff context, in which case + we have to look up the currently active voice from a staff + property + (3) The associatedVoice property has changed + */ + + if (scm_is_string (voice_name) && + (!music_context_ || voice_from_staff_ || + ly_scm2string (voice_name) != ly_scm2string (last_associatedVoice_) )) { /* (spaghettini). @@ -181,12 +195,59 @@ while (t && t->get_parent_context ()) t = t->get_parent_context (); + last_associatedVoice_ = voice_name; + String name = ly_scm2string (voice_name); Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); + if (voice) + voice_from_staff_ = false; + + if (!voice) + { + int staffVoicePart = 0; + + if (name.right_string(2) == ".1") { + staffVoicePart = 1; + } + else if (name.right_string(2) == ".2") { + staffVoicePart = 2; + } + + if (staffVoicePart > 0) + { + String staffName = name.left_string(name.length() - 2); + + Context *staff = find_context_below (t, ly_symbol2scm ("Staff"), + staffName); + if (staff) + { + voice_from_staff_ = true; + if (staffVoicePart == 1) { + voice_name = staff->get_property("activeVoicePartOne"); + } else { + voice_name = staff->get_property("activeVoicePartTwo"); + } + if (voice_name) { + if (voice_name == ly_symbol2scm("one")) + name = "one"; + else if (voice_name == ly_symbol2scm("two")) + name = "two"; + else if (voice_name == ly_symbol2scm("shared")) + name = "shared"; + else if (voice_name == ly_symbol2scm("solo")) + name = "solo"; + voice = find_context_below (t, ly_symbol2scm ("Voice"), + name); + } + } + } + + } if (voice) music_context_ = voice; + } if (lyrics_context_ && music_context_) @@ -217,6 +278,8 @@ lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); lyric_iter_ = 0; music_context_ = 0; + last_associatedVoice_ = SCM_EOL; + voice_from_staff_ = false; } if (music_context_ --- lilypond-2.5.10/ChangeLog 2005-01-30 18:28:43.000000000 -0500 +++ lilypond-2.5.10bret/ChangeLog 2005-02-01 15:43:09.908834543 -0500 @@ -1,3 +1,12 @@ +2005-02-01 Bret Whissel + + * lily/part-combine-iterator.cc: create activeVoicePartOne and + activeVoicePartTwo staff properties. + + * lily/new-lyric-combine-music-iterator.cc: search for staff name + and activeVoicePartXXX properties if search for named voice + context fails. + 2005-01-31 Han-Wen Nienhuys * mf/GNUmakefile (INSTALLATION_OUT_FILES4): install cff.ps files.