From: Jan Nieuwenhuizen Date: Mon, 13 Mar 2000 16:23:08 +0000 (+0100) Subject: patch::: 1.3.32.jcn1 X-Git-Tag: release/1.3.33~4 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=87b001c5f102fbf121dd2d5c0361cf4499021a89;p=lilypond.git patch::: 1.3.32.jcn1 1.3.32.jcn1 =========== * Removed duplicate lily/output-property-engraver.hh. * Removed optional use of vanilla spanner in Dynamic_engraver. * Fixed (measured) tremolo for Stem and Beam. Merged declarations stem-engraver.hh and chord-tremolo-engraver.hh into their .cc implementation file. Also fixed looks of Chord tremolo, input and implementation is still ugly. * Added *.yy and *.ll to TAGS, to that tags-find-replace doesn't omit parser and lexer. --- diff --git a/CHANGES b/CHANGES index 69278c3e1a..b2578a395b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,18 @@ +1.3.32.jcn1 +=========== + +* Removed duplicate lily/output-property-engraver.hh. + +* Removed optional use of vanilla spanner in Dynamic_engraver. + +* Fixed (measured) tremolo for Stem and Beam. Merged declarations + stem-engraver.hh and chord-tremolo-engraver.hh into their .cc + implementation file. Also fixed looks of Chord tremolo, input and + implementation is still ugly. + +* Added *.yy and *.ll to TAGS, to that tags-find-replace doesn't omit + parser and lexer. + 1.3.31.jcn5 =========== diff --git a/Documentation/programmer/regression-test.tely b/Documentation/programmer/regression-test.tely index 149ea061bb..082a1205ad 100644 --- a/Documentation/programmer/regression-test.tely +++ b/Documentation/programmer/regression-test.tely @@ -65,12 +65,12 @@ natural sign. @section Stems -Stem tremolos (official naming?) or rolls are tremolo signs that look -like beam segments crossing stems. If the stem is in a beam, the -tremolo must be parallel to the beam. If the stem is invisible -(eg. on a whole note), the tremolo must be centered on the note. +Stem tremolos or rolls are tremolo signs that look like beam segments +crossing stems. If the stem is in a beam, the tremolo must be parallel +to the beam. If the stem is invisible (eg. on a whole note), the +tremolo must be centered on the note. -@c @mu delafile{stem-tremolo.ly} +@mudelafile{stem-tremolo.ly} Chord tremolos look like beams, but are a kind of repeat symbol. To avoid confusion, chord tremolo beams do not reach the stems, but @@ -78,7 +78,7 @@ leave a gap. Chord tremolo beams on half notes are not ambiguous, as half notes cannot appear in a regular beam, and should reach the stems. -@c miudelafile{chord-tremolo.sly} +@mudelafile{chord-tremolo.sly} Beams, stems and noteheads often have communication troubles, since the two systems for y dimensions (1 unit = staffspace, 1 unit = 1 diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 1d222f5953..3862e3ad4d 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -1282,13 +1282,13 @@ The slur syntax with parentheses is a shorthand for this. @cindex tremolo marks -@node tremolo, , , Reference Manual +@node stem tremolo, , , Reference Manual Tremolo marks can be printed on a single note by adding `@code{:}[@var{length}]' after the note. The length must be at least 8. A @var{length} value of 8 gives one line across the note stem. If the length is omitted, then the last value is -used, or the value of the @code{abbrev}@indexcode{abbrev} property if there was +used, or the value of the @code{tremoloFlags}@indexcode{tremoloFlags} property if there was no last value. @mudela[verbatim,fragment,center] diff --git a/VERSION b/VERSION index ce1d30b72f..422bfe697d 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=32 -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/stem-tremolo.ly b/input/test/stem-tremolo.ly index bc962393de..022a9ae644 100644 --- a/input/test/stem-tremolo.ly +++ b/input/test/stem-tremolo.ly @@ -1,23 +1,23 @@ \version "1.3.5"; \score{ - \notes \transpose c'''{ + \context Voice\notes \relative c''{ + %%? + \property Voice.textVerticalDirection = #1 + %% burp, is this in staff or half spaces, or what? + \property Voice.textScriptPadding = #15 + a1:4^":4" a:8^":8" c:16^":16" a:32^":32" a^"x" a:^":" + a4:4 c:8 a:16 c:32 a a: a2: + \break \stemup -% \stemdown - % default abbreviations - c4 c4: c4:32 c4: c4 c2. - a,1 - a,1:32 - c,4:8 c': c,4:16 c': - [ c,8:16 c, c, c, ] - [ a a a a ] - [ c, f, b, e ] - [ c,16:32 c, c, c, ] [ a16:32 a a a ] -% % there's still some hairy beam bugfixing todo - [ c'8:16 g d a, ] - [ c,8:32 f, b, e ] - [ c'16:32 g d a, ] - - + a4:32 a'4:64 + \stemdown + c,4:32 c,4:64 + \stemboth + c'8:16 c c c + a': a a: a + c,16:32 c: c c a16:32 a: a a + c8:16 g: d: a: + c8:32 f: b: e: } } diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 15606f34b8..392d035808 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -39,7 +39,7 @@ Beam_engraver::do_try_music (Music *m) if (d == STOP && !beam_p_) { - m->warning (_ ("no beam to end")); + m->warning (_ ("can't find start of beam")); return false; } reqs_drul_[d ] = c; @@ -55,7 +55,7 @@ Beam_engraver::do_process_requests () if (reqs_drul_[STOP]) { if (!beam_p_) - reqs_drul_[STOP]->warning (_("no beam to end")); + reqs_drul_[STOP]->warning (_("can't find start of beam")); prev_start_req_ =0; finished_beam_p_ = beam_p_; finished_beam_info_p_ = beam_info_p_; @@ -84,7 +84,7 @@ Beam_engraver::do_process_requests () { if (beam_p_) { - reqs_drul_[START]->warning (_ ("Already have a beam")); + reqs_drul_[START]->warning (_ ("already have a beam")); return; } @@ -139,7 +139,7 @@ Beam_engraver::do_removal_processing () typeset_beam (); if (beam_p_) { - prev_start_req_->warning (_ ("unfinished beam")); + prev_start_req_->warning (_ ("unterminated beam")); finished_beam_p_ = beam_p_; finished_beam_info_p_ = beam_info_p_; typeset_beam (); @@ -167,7 +167,7 @@ Beam_engraver::acknowledge_element (Score_element_info info) Rhythmic_req *rhythmic_req = dynamic_cast (info.req_l_); if (!rhythmic_req) { - String s = _ ("Stem must have Rhythmic structure"); + String s = _ ("stem must have Rhythmic structure"); if (info.req_l_) info.req_l_->warning (s); else @@ -178,8 +178,8 @@ Beam_engraver::acknowledge_element (Score_element_info info) if (rhythmic_req->duration_.durlog_i_<= 2) { - rhythmic_req->warning (_ ("Stem doesn't fit in beam")); - prev_start_req_->warning (_ ("Beam was started here")); + rhythmic_req->warning (_ ("stem doesn't fit in beam")); + prev_start_req_->warning (_ ("beam was started here")); /* don't return, since diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 4b6ab0e69b..154d273426 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -8,22 +8,65 @@ */ #include "timing-translator.hh" -#include "chord-tremolo-engraver.hh" #include "stem.hh" #include "beam.hh" #include "musical-request.hh" #include "misc.hh" #include "warn.hh" #include "score-engraver.hh" +#include "engraver.hh" +#include "drul-array.hh" +#include "timing-engraver.hh" +#include "beaming.hh" + +/** + Generate a beam tremolo. Eat stems. + + UGH. Derive me from Beam_engraver. + + */ +class Chord_tremolo_engraver : public Engraver +{ +public: + VIRTUAL_COPY_CONS(Translator); + + + Chord_tremolo_engraver(); + +protected: + virtual void do_removal_processing(); + virtual void do_process_requests(); + virtual bool do_try_music (Music*); + virtual void acknowledge_element (Score_element_info); + virtual void do_pre_move_processing(); + virtual void do_post_move_processing(); + +private: + void typeset_beam (); + Drul_array reqs_drul_; + Chord_tremolo_req* prev_start_req_; + Beam* beam_p_; + Beam* finished_beam_p_; + + /// location within measure where beam started. + Moment beam_start_location_; + + /// moment (global time) where beam started. + Moment beam_start_mom_; + Beaming_info_list * beam_info_p_; + Beaming_info_list * finished_beam_info_p_; +}; ADD_THIS_TRANSLATOR (Chord_tremolo_engraver); Chord_tremolo_engraver::Chord_tremolo_engraver () { reqs_drul_[LEFT] = reqs_drul_[RIGHT] = 0; - abeam_p_ = 0; - finished_abeam_p_ = 0; + beam_p_ = 0; + finished_beam_p_ = 0; prev_start_req_ = 0; + finished_beam_info_p_=0; + beam_info_p_ =0; } bool @@ -35,9 +78,9 @@ Chord_tremolo_engraver::do_try_music (Music* m) if (reqs_drul_[d] && !reqs_drul_[d]->equal_b (b)) return false; - if ((d == STOP) && !abeam_p_) + if ((d == STOP) && !beam_p_) { - m->warning (_ ("no tremolo beam to end")); + m->warning (_ ("can't find start of chord tremolo")); return false; } @@ -53,14 +96,19 @@ Chord_tremolo_engraver::do_process_requests () { if (reqs_drul_[STOP]) { - if (!abeam_p_) - reqs_drul_[STOP]->warning (_ ("no tremolo beam to end")); + if (!beam_p_) + reqs_drul_[STOP]->warning (_ ("can't find start of chord tremolo")); + prev_start_req_ = 0; - finished_abeam_p_ = abeam_p_; - abeam_p_ = 0; + + finished_beam_p_ = beam_p_; + beam_p_ = 0; + + finished_beam_info_p_ = beam_info_p_; + beam_info_p_ = 0; } - if (abeam_p_) + if (beam_p_) { Score_engraver * e = 0; Translator * t = daddy_grav_l (); @@ -77,18 +125,23 @@ Chord_tremolo_engraver::do_process_requests () if (reqs_drul_[START]) { - if (abeam_p_) + if (beam_p_) { - reqs_drul_[START]->warning (_ ("Already have a tremolo beam")); + reqs_drul_[START]->warning (_ ("already have a chord tremolo")); return; } prev_start_req_ = reqs_drul_[START]; - abeam_p_ = new Beam; - abeam_p_->set_elt_property ("chord-tremolo", SCM_BOOL_T); + beam_p_ = new Beam; + beam_p_->set_elt_property ("chord-tremolo", SCM_BOOL_T); + Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver"); + Timing_engraver *timer = dynamic_cast (t); + beam_start_location_ = (t) ? timer->measure_position () : Moment (0); + beam_start_mom_ = now_mom(); + beam_info_p_ = new Beaming_info_list; - announce_element (Score_element_info (abeam_p_, reqs_drul_[LEFT])); + announce_element (Score_element_info (beam_p_, reqs_drul_[LEFT])); } } @@ -98,6 +151,7 @@ Chord_tremolo_engraver::do_post_move_processing () reqs_drul_ [START] = 0; } + void Chord_tremolo_engraver::do_pre_move_processing () { @@ -107,10 +161,14 @@ Chord_tremolo_engraver::do_pre_move_processing () void Chord_tremolo_engraver::typeset_beam () { - if (finished_abeam_p_) + if (finished_beam_p_) { - typeset_element (finished_abeam_p_); - finished_abeam_p_ = 0; + finished_beam_info_p_->beamify (); + finished_beam_p_->set_beaming (finished_beam_info_p_); + typeset_element (finished_beam_p_); + finished_beam_p_ = 0; + delete finished_beam_info_p_; + finished_beam_info_p_ =0; reqs_drul_[STOP] = 0; } @@ -120,20 +178,21 @@ void Chord_tremolo_engraver::do_removal_processing () { typeset_beam (); - if (abeam_p_) + if (beam_p_) { - prev_start_req_->warning (_ ("unfinished tremolo beam")); - finished_abeam_p_ = abeam_p_; + prev_start_req_->warning (_ ("unterminated chord tremolo")); + finished_beam_p_ = beam_p_; + finished_beam_info_p_ = beam_info_p_; typeset_beam (); } } void -Chord_tremolo_engraver::acknowledge_element (Score_element_info i) +Chord_tremolo_engraver::acknowledge_element (Score_element_info info) { - if (abeam_p_) + if (beam_p_) { - if (Stem* s = dynamic_cast (i.elem_l_)) + if (Stem* s = dynamic_cast (info.elem_l_)) { int type_i = prev_start_req_->type_i_; s->set_elt_property ("duration-log", gh_int2scm (intlog2 (type_i) - 2)); @@ -141,22 +200,38 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info i) s->set_beaming (s->flag_i (), LEFT); s->set_beaming ( s->flag_i (), RIGHT); - -#if 0 + /* + URG: this sets the direction of the Stem s. + It's amazing Mike: + + Stem:: type_i () ->first_head ()->get_direction () -> + directional_element (me).set (d); + + */ + SCM d = s->get_elt_property ("direction"); if (s->type_i () != 1) { int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2); - s->set_elt_property ("beam-gap", gh_int2scm(gap_i)); + beam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i)); } -#else - if (s->type_i () != 1) + s->set_elt_property ("direction", d); + + if (Rhythmic_req* r = dynamic_cast (info.req_l_)) { - int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2); - abeam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i)); + beam_p_->add_stem (s); + Moment stem_location = now_mom () - + beam_start_mom_ + beam_start_location_; + beam_info_p_->add_stem (stem_location, + (r->duration_.durlog_i_ - 2) >? 1); + } + else + { + String s = _ ("stem must have Rhythmic structure"); + if (info.req_l_) + info.req_l_->warning (s); + else + ::warning (s); } -#endif - - abeam_p_->add_stem (s); } } } diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index d36142c8e2..38362df351 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -24,13 +24,6 @@ #include "staff-symbol-referencer.hh" #include "translator-group.hh" -/* - Wat mij betreft wel DYN_LINE - */ -#define DYN_LINE - - -#ifdef DYN_LINE class Dynamic_line_spanner : public Spanner { public: @@ -106,12 +99,6 @@ Dynamic_line_spanner::do_post_processing () } -#endif -/* - TODO: - Baseline alignment / character metrics of dynamic symbols. - */ - /** print text & hairpin dynamics. */ @@ -125,11 +112,7 @@ class Dynamic_engraver : public Engraver Span_req * span_start_req_l_; Drul_array span_req_l_drul_; -#ifdef DYN_LINE Dynamic_line_spanner* line_spanner_; -#else - Spanner* line_spanner_; -#endif Moment last_request_mom_; void typeset_all (); @@ -209,13 +192,8 @@ Dynamic_engraver::do_process_requests () { if ((span_req_l_drul_[START] || text_req_l_) && !line_spanner_) { -#ifdef DYN_LINE line_spanner_ = new Dynamic_line_spanner; -#else - line_spanner_ = new Spanner; - line_spanner_->set_elt_property ("transparent", SCM_BOOL_T); side_position (line_spanner_).set_axis (Y_AXIS); -#endif announce_element (Score_element_info (line_spanner_, text_req_l_ ? text_req_l_ : span_req_l_drul_[START])); @@ -225,34 +203,6 @@ Dynamic_engraver::do_process_requests () if (span_req_l_drul_[START] || text_req_l_) last_request_mom_ = now_mom (); -#ifndef DYN_LINE - if (line_spanner_) - { - /* - Generic property will handle this for a Dynamic_line_spanner - */ - Direction dir = DOWN; - SCM s = get_property ("dynamicDirection"); - if (!isdir_b (s)) - { - s = get_property ("verticalDirection"); - } - - if (isdir_b (s) && to_dir (s)) - dir = to_dir (s); - - line_spanner_->set_elt_property ("direction", gh_int2scm ((int)dir)); - - s = get_property ("dynamicPadding"); - Real padding; - if (gh_number_p (s)) - padding = gh_scm2double (s); - else - padding = 2; - line_spanner_->set_elt_property ("padding", gh_double2scm (padding)); - } -#endif - if (text_req_l_) { String loud = text_req_l_->text_str_; @@ -280,6 +230,7 @@ Dynamic_engraver::do_process_requests () { assert (!finished_cresc_p_); cresc_p_->set_bounds(RIGHT, get_staff_info ().musical_pcol_l ()); + cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ()); finished_cresc_p_ = cresc_p_; cresc_p_ = 0; span_start_req_l_ = 0; @@ -323,6 +274,7 @@ Dynamic_engraver::do_process_requests () cresc_p_->set_bounds(LEFT, get_staff_info ().musical_pcol_l ()); cresc_p_->set_bounds(RIGHT, get_staff_info ().musical_pcol_l ()); + cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ()); // arrragh, brr, urg: we know how wide text is, no? if (text_p_) @@ -336,6 +288,7 @@ Dynamic_engraver::do_process_requests () assert (line_spanner_); cresc_p_->set_parent (line_spanner_, Y_AXIS); + cresc_p_->add_dependency (line_spanner_); announce_element (Score_element_info (cresc_p_, span_req_l_drul_[START])); } } @@ -359,12 +312,6 @@ Dynamic_engraver::do_removal_processing () typeset_all (); if (line_spanner_) { -#ifndef DYN_LINE - Direction dir = directional_element (line_spanner_).get (); - Real staff_space = Staff_symbol_referencer_interface (line_spanner_).staff_space (); - SCM s = line_spanner_->get_elt_property ("padding"); - line_spanner_->translate_axis (gh_scm2double (s) * staff_space * (int)dir, Y_AXIS); -#endif typeset_element (line_spanner_); line_spanner_ = 0; } @@ -376,7 +323,7 @@ Dynamic_engraver::typeset_all () { if (finished_cresc_p_) { - finished_cresc_p_->set_bounds (RIGHT, get_staff_info ().musical_pcol_l ()); + //finished_cresc_p_->set_bounds (RIGHT, get_staff_info ().musical_pcol_l ()); typeset_element (finished_cresc_p_); finished_cresc_p_ =0; } @@ -395,12 +342,6 @@ Dynamic_engraver::typeset_all () */ if (line_spanner_ && last_request_mom_ < now_mom ()) { -#ifndef DYN_LINE - Direction dir = directional_element (line_spanner_).get (); - Real staff_space = Staff_symbol_referencer_interface (line_spanner_).staff_space (); - SCM s = line_spanner_->get_elt_property ("padding"); - line_spanner_->translate_axis (gh_scm2double (s) * staff_space * (int)dir, Y_AXIS); -#endif typeset_element (line_spanner_); line_spanner_ = 0; } @@ -414,15 +355,7 @@ Dynamic_engraver::acknowledge_element (Score_element_info i) if (Note_column* n = dynamic_cast (i.elem_l_)) { side_position (line_spanner_).add_support (n); -#ifdef DYN_LINE line_spanner_->add_column (n); -#else - if (!line_spanner_->spanned_drul_[LEFT]) - line_spanner_->set_bounds (LEFT, n); - line_spanner_->set_bounds (RIGHT, n); - - line_spanner_->add_dependency (n); -#endif } } } diff --git a/lily/include/chord-tremolo-engraver.hh b/lily/include/chord-tremolo-engraver.hh index 0330680c8a..e69de29bb2 100644 --- a/lily/include/chord-tremolo-engraver.hh +++ b/lily/include/chord-tremolo-engraver.hh @@ -1,47 +0,0 @@ -/* - chord-tremolo-engraver.hh -- declare Chord_tremolo_engraver - - source file of the GNU LilyPond music typesetter - - (c) 1997--2000 Han-Wen Nienhuys - Jan Nieuwenhuizen -*/ - - -#ifndef Chord_tremolo_ENGRAVER_HH -#define Chord_tremolo_ENGRAVER_HH - -#include "engraver.hh" -#include "drul-array.hh" - -/** - Generate an abbreviation beam. Eat stems. - - UGH. Derive me from Beam_engraver. - - */ -class Chord_tremolo_engraver : public Engraver -{ -public: - VIRTUAL_COPY_CONS(Translator); - - - Chord_tremolo_engraver(); - -protected: - virtual void do_removal_processing(); - virtual void do_process_requests(); - virtual bool do_try_music (Music*); - virtual void acknowledge_element (Score_element_info); - virtual void do_pre_move_processing(); - virtual void do_post_move_processing(); - -private: - void typeset_beam (); - Drul_array reqs_drul_; - Chord_tremolo_req* prev_start_req_; - Beam* abeam_p_; - Beam* finished_abeam_p_; -}; - -#endif // Chord_tremolo_ENGRAVER_HH diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 3a6f324771..d5f93d6a06 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -64,7 +64,6 @@ struct Change_translator; struct Chord; struct Chord_name; struct Chord_name_engraver; -struct Chord_tremolo; struct Chord_tremolo_engraver; struct Chord_tremolo_req; struct Clef_change_req; diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index dbabc86edd..9fbbd284cd 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -177,7 +177,7 @@ public: VIRTUAL_COPY_CONS(Music); }; /** - Start / stop an abbreviation beam. */ + Start / stop a tremolo beam. */ class Chord_tremolo_req : public Span_req { public: diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 4231886b7e..907aa962b4 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -39,7 +39,7 @@ public: Duration default_duration_; Musical_pitch default_pitch_; Scope *default_header_p_; - int abbrev_beam_type_i_; + int chord_tremolo_type_i_; bool first_b_; int fatal_error_i_; Sources * source_l_; @@ -71,7 +71,7 @@ private: Simultaneous_music* get_rest_element (String, Duration *); Simultaneous_music* get_word_element (String, Duration*); String notename_str (Melodic_req* melodic); - void set_abbrev_beam (int type_i); + void set_chord_tremolo (int type_i); void set_last_duration (Duration const *); void set_last_pitch (Musical_pitch const *); friend int yyparse (void*); diff --git a/lily/include/stem-engraver.hh b/lily/include/stem-engraver.hh index 678a5800bd..e69de29bb2 100644 --- a/lily/include/stem-engraver.hh +++ b/lily/include/stem-engraver.hh @@ -1,37 +0,0 @@ -/* - stem-engraver.hh -- declare Stem_engraver - - source file of the GNU LilyPond music typesetter - - (c) 1997--2000 Han-Wen Nienhuys -*/ - - -#ifndef STEM_GRAV_HH -#define STEM_GRAV_HH - -#include "engraver.hh" - -/** - Make stems upon receiving noteheads. - */ -class Stem_engraver : public Engraver -{ - int default_abbrev_i_; - Stem *stem_p_; - Stem_tremolo *abbrev_p_; - Rhythmic_req *rhythmic_req_l_; - Tremolo_req* abbrev_req_l_; -protected: - virtual void do_creation_processing (); - virtual void acknowledge_element (Score_element_info); - virtual void do_pre_move_processing (); - virtual bool do_try_music (Music*); - -public: - VIRTUAL_COPY_CONS(Translator); - Stem_engraver(); - -}; - -#endif // STEM_GRAV_HH diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 854f846c1b..b081bcf6eb 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -28,7 +28,7 @@ My_lily_parser::My_lily_parser (Sources * source_l) first_b_ = true; source_l_ = source_l; lexer_p_ = 0; - abbrev_beam_type_i_ = 0; + chord_tremolo_type_i_ = 0; default_duration_.durlog_i_ = 2; error_level_i_ = 0; @@ -102,9 +102,9 @@ My_lily_parser::set_last_duration (Duration const *d) } void -My_lily_parser::set_abbrev_beam (int type_i) +My_lily_parser::set_chord_tremolo (int type_i) { - abbrev_beam_type_i_ = type_i; + chord_tremolo_type_i_ = type_i; } diff --git a/lily/output-property-engraver.hh b/lily/output-property-engraver.hh index ef30fdf091..e69de29bb2 100644 --- a/lily/output-property-engraver.hh +++ b/lily/output-property-engraver.hh @@ -1,61 +0,0 @@ -/* - output-property-engraver.cc -- implement Output_property_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2000 Han-Wen Nienhuys - - */ - -#include "output-property.hh" -#include "engraver.hh" - -class Output_property_engraver : public Engraver -{ -public: - Output_property_engraver(); - VIRTUAL_COPY_CONS(Translator); -protected: - - Link_array props_; - - virtual void do_acknowledge_element (Score_element_info); - virtual bool do_try_music (Music*); -}; - - -Output_property_engraver::do_try_music (Music* m) -{ - if (Output_property * o = dynamic_cast (m)) - { - props_.push (m); - return true; - } - return false; -} - -void -Output_property_engraver::do_acknowledge_element (Score_element_info i) -{ - for (int i=props_.size (); i--; ) - { - Output_property * o = props_[i]; - SCM pred = gh_car (o->pred_sym_val_list_); - /* - should typecheck pred. - */ - SCM result=gh_apply (pred, - gh_listify (i.elem_l_->self_scm_, SCM_UNDEFINED)); - if (to_boolean (result)) - { - i.elem_l_->set_elt_property (gh_cadr (o->pred_sym_val_list_), - gh_caddr (o->pred_sym_val_list_)); - } - } -} - -void -Output_property_engraver::do_pre_move_processing () -{ - props_.clear (); -} diff --git a/lily/parser.yy b/lily/parser.yy index c16f39fd6d..db172c5e26 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -225,7 +225,7 @@ yylex (YYSTYPE *s, void * v_l) %type sub_quotes sup_quotes %type simple_element request_chord command_element Simple_music Composite_music %type Alternative_music Repeated_music -%type abbrev_type +%type tremolo_type %type int unsigned %type script_dir %type optional_modality @@ -252,7 +252,7 @@ yylex (YYSTYPE *s, void * v_l) %type Music_list %type paper_block paper_def_body %type real real_with_dimension -%type abbrev_command_req +%type shorthand_command_req %type post_request %type command_req verbose_command_req %type extender_req @@ -926,11 +926,11 @@ command_element: ; command_req: - abbrev_command_req + shorthand_command_req | verbose_command_req semicolon { $$ = $1; } ; -abbrev_command_req: +shorthand_command_req: extender_req { $$ = $1; } @@ -952,18 +952,19 @@ abbrev_command_req: | '[' ':' unsigned { if (!is_duration_b ($3)) THIS->parser_error (_f ("not a duration: %d", $3)); - else if ($3 < 8) - THIS->parser_error (_ ("Can't abbreviate")); else - THIS->set_abbrev_beam ($3); + THIS->set_chord_tremolo ($3); Chord_tremolo_req* a = new Chord_tremolo_req; a->span_dir_ = START; - a->type_i_ = THIS->abbrev_beam_type_i_; + // urg + a->type_i_ = THIS->chord_tremolo_type_i_; $$=a; } | ']' { - if (!THIS->abbrev_beam_type_i_) + /* URG + */ + if (!THIS->chord_tremolo_type_i_) { Span_req*b= new Span_req; b->span_dir_ = STOP; @@ -974,8 +975,8 @@ abbrev_command_req: { Chord_tremolo_req* a = new Chord_tremolo_req; a->span_dir_ = STOP; - a->type_i_ = THIS->abbrev_beam_type_i_; - THIS->set_abbrev_beam (0); + a->type_i_ = THIS->chord_tremolo_type_i_; + THIS->set_chord_tremolo (0); $$ = a; } } @@ -1114,7 +1115,7 @@ verbose_request: sp_p->set_spot (THIS->here_input ()); $$ = sp_p; } - | abbrev_type { + | tremolo_type { Tremolo_req* a = new Tremolo_req; a->set_spot (THIS->here_input ()); a->type_i_ = $1; @@ -1384,15 +1385,13 @@ steno_duration: ; -abbrev_type: +tremolo_type: ':' { $$ =0; } | ':' unsigned { if (!is_duration_b ($2)) THIS->parser_error (_f ("not a duration: %d", $2)); - else if ($2 < 8) - THIS->parser_error (_ ("Can't abbreviate")); $$ = $2; } ; @@ -1408,10 +1407,14 @@ simple_element: n->pitch_ = *$1; n->duration_ = *$4; - if (THIS->abbrev_beam_type_i_) + /* + URG + */ + if (THIS->chord_tremolo_type_i_) { if (n->duration_.plet_b ()) - THIS->parser_error (_ ("Can't abbreviate tuplet")); + // urg, burp. what nonsense / silly implementation + THIS->parser_error (_ ("can't put stem tremolo on tuplet")); else n->duration_.set_plet (1, 2); } diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index a1f467e1f6..2af08ac71b 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -7,7 +7,6 @@ */ #include "staff-symbol-referencer.hh" -#include "stem-engraver.hh" #include "note-head.hh" #include "stem.hh" #include "musical-request.hh" @@ -15,23 +14,53 @@ #include "stem-tremolo.hh" #include "staff-info.hh" #include "translator-group.hh" +#include "engraver.hh" -Stem_engraver::Stem_engraver() +/** + Make stems upon receiving noteheads. + */ +class Stem_engraver : public Engraver { - abbrev_req_l_ = 0; + +public: + VIRTUAL_COPY_CONS (Translator); + Stem_engraver(); + +protected: + virtual void do_creation_processing (); + virtual void acknowledge_element (Score_element_info); + virtual void do_pre_move_processing (); + virtual bool do_try_music (Music*); + +private: + int default_tremolo_type_i_; + Stem *stem_p_; + Stem_tremolo *tremolo_p_; + Rhythmic_req *rhythmic_req_l_; + Tremolo_req* tremolo_req_l_; +}; + +ADD_THIS_TRANSLATOR (Stem_engraver); + +Stem_engraver::Stem_engraver () +{ + tremolo_req_l_ = 0; stem_p_ = 0; - abbrev_p_ = 0; - default_abbrev_i_ = 16; + tremolo_p_ = 0; + default_tremolo_type_i_ = 16; rhythmic_req_l_ =0; } void Stem_engraver::do_creation_processing () { - SCM prop = get_property ("abbrev"); + /* + huh, why only at creation time? + */ + SCM prop = get_property ("tremoloFlags"); if (gh_number_p(prop)) { - default_abbrev_i_ = gh_scm2int (prop); + default_tremolo_type_i_ = gh_scm2int (prop); } } @@ -53,28 +82,40 @@ Stem_engraver::acknowledge_element(Score_element_info i) stem_p_->set_elt_property ("duration-log", gh_int2scm (duration_log)); - if (abbrev_req_l_) + if (tremolo_req_l_) { /* - suggests typing of: - c8:16 c: c: c: - hmm, which isn't so bad? - */ - int t = abbrev_req_l_->type_i_; - if (!t) - t = default_abbrev_i_; + Stem tremolo is never applied to a note by default, + is must me requested. But there is a default for the + tremolo value: + + c4:8 c c: + + the first and last (quarter) note bothe get one tremolo flag. + */ + int requested_type = tremolo_req_l_->type_i_; + if (!requested_type) + requested_type = default_tremolo_type_i_; else - default_abbrev_i_ = t; + default_tremolo_type_i_ = requested_type; - if (t) + if (requested_type) { - abbrev_p_ = new Stem_tremolo; - announce_element (Score_element_info (abbrev_p_, abbrev_req_l_)); - abbrev_p_->set_elt_property ("tremolo-flags", gh_int2scm (intlog2 (t) - (duration_log>? 2))); + tremolo_p_ = new Stem_tremolo; + announce_element (Score_element_info (tremolo_p_, tremolo_req_l_)); + /* + The number of tremolo flags is the number of flags of + the tremolo-type minus the number of flags of the note + itself. + */ + int tremolo_flags = intlog2 (requested_type) - 2 + - (duration_log > 2 ? duration_log - 2 : 0); + if (tremolo_flags < 0) + tremolo_flags = 0; + tremolo_p_->set_elt_property ("tremolo-flags", + gh_int2scm (tremolo_flags)); } } - - // must give the request, to preserve the rhythmic info. announce_element (Score_element_info (stem_p_, r)); } @@ -90,11 +131,11 @@ Stem_engraver::acknowledge_element(Score_element_info i) void Stem_engraver::do_pre_move_processing() { - if (abbrev_p_) + if (tremolo_p_) { - abbrev_p_->set_stem (stem_p_); - typeset_element (abbrev_p_); - abbrev_p_ = 0; + tremolo_p_->set_stem (stem_p_); + typeset_element (tremolo_p_); + tremolo_p_ = 0; } if (stem_p_) @@ -112,18 +153,25 @@ Stem_engraver::do_pre_move_processing() daddy_trans_l_->set_property ("stemRightBeamCount", SCM_UNDEFINED); } + // UGH. Should mark non-forced instead. + + /* + aargh: I don't get it. direction is being set (and then set + to forced), if we have a Chord_tremolo. + */ SCM dir = stem_p_->get_elt_property ("direction"); if (gh_number_p (dir) && to_dir(dir)) { stem_p_->set_elt_property ("dir-forced", SCM_BOOL_T); } - typeset_element(stem_p_); stem_p_ = 0; } - abbrev_req_l_ = 0; + + + tremolo_req_l_ = 0; } bool @@ -131,12 +179,9 @@ Stem_engraver::do_try_music (Music* r) { if (Tremolo_req* a = dynamic_cast (r)) { - abbrev_req_l_ = a; + tremolo_req_l_ = a; return true; } return false; } - -ADD_THIS_TRANSLATOR(Stem_engraver); - diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index d6b2fcfa4c..d945dc2463 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -1,5 +1,5 @@ /* - abbrev.cc -- implement Stem_tremolo + stem-tremolo.cc -- implement Stem_tremolo source file of the GNU LilyPond music typesetter @@ -18,6 +18,11 @@ #include "staff-symbol-referencer.hh" #include "directional-element-interface.hh" +/* + TODO: + lengthen stem if necessary + */ + Stem_tremolo::Stem_tremolo () { set_elt_property ("stem", SCM_EOL); @@ -45,86 +50,79 @@ Stem_tremolo::dim_callback (Dimension_cache const *c) Molecule Stem_tremolo::do_brew_molecule () const { - Stem * st = stem_l (); - int mult =0; - if (Beam * b = st->beam_l ()) - { - mult = b->get_multiplicity (); - } + Stem * stem = stem_l (); + Beam * beam = stem->beam_l (); - Real interbeam_f = paper_l ()->interbeam_f (mult); - Real w = gh_scm2double (get_elt_property ("beam-width")); - Real space = Staff_symbol_referencer_interface (st).staff_space (); - Real half_staff_space = space / 2; - Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); - - int beams_i = 0; - Real dydx = 0.25; - - if (st && st->beam_l ()) + Real dydx; + if (beam) { Real dy = 0; - SCM s = st->beam_l ()->get_elt_property ("height"); + SCM s = beam->get_elt_property ("height"); if (gh_number_p (s)) dy = gh_scm2double (s); - Real dx = st->beam_l ()->last_visible_stem ()->hpos_f () - - st->beam_l ()->first_visible_stem ()->hpos_f (); - dydx = dy/dx; - - // ugh, rather calc from Stem_tremolo_req - beams_i = st->beam_count(RIGHT) >? st->beam_count (LEFT); - } - - Molecule a (lookup_l ()->beam (dydx, w, beam_f)); - a.translate (Offset (-w/2, w / 2 * dydx)); + Real dx = beam->last_visible_stem ()->hpos_f () + - beam->first_visible_stem ()->hpos_f (); + dydx = dx ? dy/dx : 0; + } + else + // urg + dydx = 0.25; + + Real thick = gh_scm2double (get_elt_property ("beam-thickness")); + Real width = gh_scm2double (get_elt_property ("beam-width")); + Molecule a (lookup_l ()->beam (dydx, width, thick)); + a.translate (Offset (-width/2, width / 2 * dydx)); - int abbrev_flags = 1; - { - SCM a = get_elt_property ("abbrev-flags"); - if (gh_number_p (a)) - abbrev_flags = gh_scm2int (a); - } - + int tremolo_flags; + SCM s = get_elt_property ("tremolo-flags"); + if (gh_number_p (s)) + tremolo_flags = gh_scm2int (s); + else + // huh? + tremolo_flags = 1; + + int mult = beam ? beam->get_multiplicity () : 0; + Real interbeam_f = paper_l ()->interbeam_f (mult); Molecule mol; - for (int i = 0; i < abbrev_flags; i++) + for (int i = 0; i < tremolo_flags; i++) { Molecule b (a); b.translate_axis (interbeam_f * i, Y_AXIS); mol.add_molecule (b); } - mol.translate_axis (-mol.extent ()[Y_AXIS].center (), Y_AXIS); - - if (st) - { - if (st->beam_l ()) - { - mol.translate (Offset(st->hpos_f () - hpos_f (), - st->stem_end_position () * half_staff_space - - directional_element (st->beam_l ()).get () * beams_i * interbeam_f)); - } - else - { - /* - Beams should intersect one beamthickness below staff end - */ - Real dy = - mol.extent ()[Y_AXIS].length () / 2 * st->get_direction (); - - /* - uhg. Should use relative coords and placement - */ - Real whole_note_correction = (st && st->invisible_b( )) - ? 0.0 // -st->get_direction () * st->note_delta_f ()/2 - : 0.0; - - dy += st->stem_end_position (); - mol.translate (Offset(st->hpos_f () - hpos_f ()+ - whole_note_correction, dy)); - } + if (tremolo_flags) + mol.translate_axis (-mol.extent ()[Y_AXIS].center (), Y_AXIS); + + Real half_space = Staff_symbol_referencer_interface (stem).staff_space () + / 2; + if (beam) + { + // ugh, rather calc from Stem_tremolo_req + int beams_i = stem->beam_count(RIGHT) >? stem->beam_count (LEFT); + mol.translate (Offset(stem->hpos_f () - hpos_f (), + stem->stem_end_position () * half_space - + directional_element (beam).get () * beams_i * interbeam_f)); + } + else + { + /* + Beams should intersect one beamthickness below stem end + */ + Real dy = stem->stem_end_position () * half_space; + dy -= mol.extent ()[Y_AXIS].length () / 2 * stem->get_direction (); /* - there used to be half a page of code that was long commented out. - Removed in 1.1.35 - */ + uhg. Should use relative coords and placement + */ + Real whole_note_correction; + if (stem->invisible_b ()) + whole_note_correction = -stem->get_direction () + * stem->support_head ()->extent (X_AXIS).length () / 2; + else + whole_note_correction = 0; + + mol.translate (Offset (stem->hpos_f () - hpos_f () + + whole_note_correction, dy)); } return mol; diff --git a/lily/stem.cc b/lily/stem.cc index ce3312a9b1..94417b0634 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -101,6 +101,7 @@ Stem::get_direction () const { Stem * me = (Stem*) this; d = get_default_dir (); + // urg, AAARGH! directional_element (me).set (d); } return d ; diff --git a/ly/engraver.ly b/ly/engraver.ly index 4eb5788468..1d7eb0285b 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -255,20 +255,22 @@ LyricsContext = \translator { }; \translator { \LyricsContext } -\translator{ +ChordNameVoiceContext = \translator { \type "Engraver_group_engraver"; - \consists "Output_property_engraver"; + \name ChordNameVoice ; + \consists "Output_property_engraver"; \consistsend "Axis_group_engraver"; - \name ChordNameVoice ; \consists "Separating_line_group_engraver"; \consists "Chord_name_engraver"; -} - +}; +\translator {\ChordNameVoiceContext} ChordNameContext = \translator { \type "Engraver_group_engraver"; \name ChordNames; + + \consists "Output_property_engraver"; \accepts "ChordNameVoice"; \consistsend "Axis_group_engraver"; }; diff --git a/stepmake/stepmake/c++-vars.make b/stepmake/stepmake/c++-vars.make index 3862835b3e..e273cc7a48 100644 --- a/stepmake/stepmake/c++-vars.make +++ b/stepmake/stepmake/c++-vars.make @@ -25,5 +25,5 @@ ALL_CC_SOURCES += $(HH_FILES) $(INL_FILES) $(CC_FILES) $(YY_FILES) $(LL_FILES) O_FILES+=$(addprefix $(outdir)/, $(CC_FILES:.cc=.o) $(LL_FILES:.ll=.o) $(YY_FILES:.yy=.o)) -TAGS_FILES += $(TCC_FILES) $(HH_FILES) $(INL_FILES) $(CC_FILES) +TAGS_FILES += $(TCC_FILES) $(HH_FILES) $(INL_FILES) $(CC_FILES) $(YY_FILES) $(LL_FILES)