From beb1e82ba392164a419f0926f2ef509c0fefbd89 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:26:59 +0000 Subject: [PATCH] lilypond-1.2.11 --- TODO | 4 ++ VERSION | 2 +- input/bugs/ps.ly | 19 ++++++ input/test/auto-change.ly | 14 ++++ lily/auto-change-iterator.cc | 95 +++++++++++++++++++++++++++ lily/auto-change-music.cc | 17 +++++ lily/include/auto-change-iterator.hh | 27 ++++++++ lily/include/auto-change-music.hh | 24 +++++++ lily/include/pitch-squash-engraver.hh | 2 - lily/music-iterator.cc | 10 ++- lily/my-lily-lexer.cc | 1 + lily/note-heads-engraver.cc | 6 ++ lily/parser.yy | 9 ++- 13 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 input/bugs/ps.ly create mode 100644 input/test/auto-change.ly create mode 100644 lily/auto-change-iterator.cc create mode 100644 lily/auto-change-music.cc create mode 100644 lily/include/auto-change-iterator.hh create mode 100644 lily/include/auto-change-music.hh diff --git a/TODO b/TODO index 694d39e90e..9d0fd5f962 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ -*-outline-layout:(2 (-1 -1 0 :) 0);outline-stylish-prefixes:nil -*- + * GNU LilyPond TODO Features you cannot find in the documentation as working, should be mentioned here. This is an assorted collection of stuff that will be @@ -10,6 +11,9 @@ Grep -i for TODO, FIXME and ugh/ugr/urg. .* TODO . * use Rhythmic_head::position_i () for all Staff_referenced +. * setting indent to 0 with \shape fails +. * junk -M ? +. * mudela-book doco . * Depracate Wordwrap . * rerun profile . * Break_req handling is silly (break_forbid () + \break fucks up.) diff --git a/VERSION b/VERSION index 41c1aa8efa..ae415ac44e 100644 --- a/VERSION +++ b/VERSION @@ -1,7 +1,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=2 -PATCH_LEVEL=10 +PATCH_LEVEL=11 MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a diff --git a/input/bugs/ps.ly b/input/bugs/ps.ly new file mode 100644 index 0000000000..db59c5ce54 --- /dev/null +++ b/input/bugs/ps.ly @@ -0,0 +1,19 @@ + +\score { + { + \context Staff = i { + \notes { a' b' c' d' } + } + +% \break + + \context PianoStaff < + \context Staff = i { + \notes { a' b' c' d' } + } + \context Staff = ii { + \notes { \clef "bass"; a b c d } + } + > + } +} diff --git a/input/test/auto-change.ly b/input/test/auto-change.ly new file mode 100644 index 0000000000..3a27cbe163 --- /dev/null +++ b/input/test/auto-change.ly @@ -0,0 +1,14 @@ + +\score { + \notes \context PianoStaff < + \context Staff = "up" { + \autochange Staff \relative c' { g4 a b c d e f g } + } + \context Staff = "down" { + \clef bass; + s1*2 + } + + > + +} diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc new file mode 100644 index 0000000000..5d3537b461 --- /dev/null +++ b/lily/auto-change-iterator.cc @@ -0,0 +1,95 @@ +/* + auto-change-iterator.cc -- implement Auto_change_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#include "auto-change-music.hh" +#include "auto-change-iterator.hh" +#include "translator-group.hh" +#include "musical-request.hh" + + + +void +Auto_change_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 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 (_ ("I'm one myself")); + } + else + ; // error (_ ("none of these in my family")); + +} + +void +Auto_change_iterator::do_process_and_next (Moment m) +{ + Music_wrapper_iterator::do_process_and_next (m); + Pitch_interrogate_req spanish_inquisition; + + Music_iterator *it = try_music (&spanish_inquisition); + + if (it && spanish_inquisition.pitch_arr_.size ()) + { + Musical_pitch p = spanish_inquisition.pitch_arr_[0]; + Direction s = Direction (sign(p.semitone_pitch ())); + if (s && s != where_dir_) + { + where_dir_ = s; + String to_id = (s > 0) ? "up" : "down"; + Auto_change_music const * auto_mus = dynamic_cast (music_l_); + + change_to (it, auto_mus->what_str_, to_id); + } + } +} + +Auto_change_iterator::Auto_change_iterator( ) +{ + where_dir_ = CENTER; +} diff --git a/lily/auto-change-music.cc b/lily/auto-change-music.cc new file mode 100644 index 0000000000..7902d55ced --- /dev/null +++ b/lily/auto-change-music.cc @@ -0,0 +1,17 @@ + +/* + auto-switch-music.cc -- implement + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#include "auto-change-music.hh" + +Auto_change_music::Auto_change_music (String what, Music * m) + : Music_wrapper (m) +{ + what_str_ = what; +} diff --git a/lily/include/auto-change-iterator.hh b/lily/include/auto-change-iterator.hh new file mode 100644 index 0000000000..4171a9cf84 --- /dev/null +++ b/lily/include/auto-change-iterator.hh @@ -0,0 +1,27 @@ +/* + auto-change-iterator.hh -- declare Auto_change_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef AUTO_CHANGE_ITERATOR_HH +#define AUTO_CHANGE_ITERATOR_HH + +#include "music-wrapper-iterator.hh" +#include "direction.hh" + +class Auto_change_iterator : public Music_wrapper_iterator +{ + Direction where_dir_; + + void change_to (Music_iterator* , String, String); +protected: + virtual void do_process_and_next (Moment); +public: + Auto_change_iterator (); +}; + +#endif /* AUTO_CHANGE_ITERATOR_HH */ diff --git a/lily/include/auto-change-music.hh b/lily/include/auto-change-music.hh new file mode 100644 index 0000000000..ec698bec82 --- /dev/null +++ b/lily/include/auto-change-music.hh @@ -0,0 +1,24 @@ +/* + auto-change-music.hh -- declare Auto_change_music + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef AUTO_CHANGE_MUSIC_HH +#define AUTO_CHANGE_MUSIC_HH + +#include "music-wrapper.hh" + +class Auto_change_music : public Music_wrapper +{ +public: + Auto_change_music (String what, Music *); + String what_str_; +}; + + +#endif /* AUTO_CHANGE_MUSIC_HH */ + diff --git a/lily/include/pitch-squash-engraver.hh b/lily/include/pitch-squash-engraver.hh index ad042e84f3..bc1b7be97b 100644 --- a/lily/include/pitch-squash-engraver.hh +++ b/lily/include/pitch-squash-engraver.hh @@ -14,10 +14,8 @@ class Pitch_squash_engraver : public Engraver { public: - VIRTUAL_COPY_CONS (Translator); virtual void acknowledge_element (Score_element_info); - }; #endif /* PITCH_SQUASH_GRAV_HH */ diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index e677118a19..f9625b848b 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -28,6 +28,8 @@ #include "grace-music.hh" #include "lyric-combine-music.hh" #include "lyric-combine-music-iterator.hh" +#include "auto-change-music.hh" +#include "auto-change-iterator.hh" void Music_iterator::do_print() const @@ -115,7 +117,9 @@ Music_iterator* Music_iterator::static_get_iterator_p (Music const *m) { Music_iterator * p =0; - + + /* It would be nice to do this decentrally, but the order of this is + significant. */ if (dynamic_cast (m)) p = new Request_chord_iterator; else if (dynamic_cast (m)) @@ -131,7 +135,9 @@ Music_iterator::static_get_iterator_p (Music const *m) else if (dynamic_cast (m)) p = new Time_scaled_music_iterator; else if (dynamic_cast (m)) - p = new Grace_iterator; + p = new Grace_iterator; + else if (dynamic_cast (m)) + p = new Auto_change_iterator; else if (dynamic_cast (m)) p = new Music_wrapper_iterator; else if (Repeated_music const * n = dynamic_cast (m)) diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 6edf314018..deb6ff2789 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -21,6 +21,7 @@ #include "input.hh" static Keyword_ent the_key_tab[]={ + {"autochange", AUTOCHANGE}, {"spanrequest", SPANREQUEST}, {"simultaneous", SIMULTANEOUS}, {"sequential", SEQUENTIAL}, diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 5243ff56cd..7ac5c8ade6 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -33,6 +33,12 @@ Note_heads_engraver::do_try_music (Music *m) { return notes_end_pq_.size (); } + else if (Pitch_interrogate_req *p = dynamic_cast (m)) + { + for (int i= note_req_l_arr_.size (); i--;) + p->pitch_arr_.push (note_req_l_arr_[i]->pitch_); // GUH UGH UGHUGH. + return true; + } return false; } diff --git a/lily/parser.yy b/lily/parser.yy index c848282874..feb3ae516e 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -43,6 +43,7 @@ #include "repeated-music.hh" #include "mudela-version.hh" #include "grace-music.hh" +#include "auto-change-music.hh" // mmm Mudela_version oldest_version ("1.1.52"); @@ -124,7 +125,7 @@ yylex (YYSTYPE *s, void * v_l) %pure_parser /* tokens which are not keywords */ - +%token AUTOCHANGE %token TEXTSCRIPT %token ACCEPTS %token ALTERNATIVE @@ -785,6 +786,12 @@ Composite_music: $$ = csm; } + | AUTOCHANGE STRING Music { + Auto_change_music * chm = new Auto_change_music (*$2, $3); + delete $2; + $$ = chm; + chm->set_spot ($3->spot ()); + } | GRACE Music { $$ = new Grace_music ($2); } -- 2.39.5