From fdccff46ffac7f7a312f54764b7d54f473c86118 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 20:05:44 +0000 Subject: [PATCH] lilypond-0.1.45 --- input/sleur.ly | 17 +++ lily/bow.cc | 26 ++-- lily/horizontal-vertical-group-item.cc | 19 +++ lily/include/bow.hh | 3 +- lily/include/collision.hh | 2 +- .../include/horizontal-vertical-group-item.hh | 33 +++++ lily/include/lookup.hh | 4 +- lily/include/script-column.hh | 2 +- lily/include/slur.hh | 1 + lily/lookup.cc | 2 +- lily/slur.cc | 76 ++++++++--- lily/tex-slur.cc | 7 +- mutopia/J.S.Bach/preludes-4.ly | 127 +++++++++++++----- tex/lily-ps-defs.tex | 12 +- 14 files changed, 253 insertions(+), 78 deletions(-) create mode 100644 lily/horizontal-vertical-group-item.cc create mode 100644 lily/include/horizontal-vertical-group-item.hh diff --git a/input/sleur.ly b/input/sleur.ly index 1226a9b7c0..a0c895286c 100644 --- a/input/sleur.ly +++ b/input/sleur.ly @@ -30,12 +30,29 @@ beum = \melodic{ [c8 c] c4 c4 c4 | } +extend = { + c8(( c c )c c c c )c | + \[4/5c8( c c' c )c\]1/1 c c c c | + \[4/5c8( c c c c'\]1/1 c c c )c | + \[4/5c8( c c c c''\]1/1 c c c )c' | + \[4/5c8( c c c c'\]1/1 c c c )'c | + \[4/5c8( c c' c c\]1/1 c c c )c | + \[4/5c8( c c c ''c\]1/1 c c c )c | + \[4/5c8( c ''c c c\]1/1 c c c )c | +} + \score{ \melodic{ \shortlong \dirs \complex \beum + \stemup; + \octave c''; + \extend + \stemdown; + \octave c'; + \extend } \paper{ } } diff --git a/lily/bow.cc b/lily/bow.cc index 1f75bba5de..7f73df520c 100644 --- a/lily/bow.cc +++ b/lily/bow.cc @@ -11,7 +11,9 @@ #include "molecule.hh" #include "lookup.hh" -Bow::Bow() +IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner); + +Bow::Bow () { dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0; dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0; @@ -19,39 +21,41 @@ Bow::Bow() Offset -Bow::center() const +Bow::center () const { Real dy = dy_f_drul_[RIGHT]-dy_f_drul_[LEFT]; - Real w = width().length (); + Real w = width ().length (); return Offset (w/2,dy ); } +Real +Bow::height_f () const +{ + return 0; +} Molecule* -Bow::brew_molecule_p() const +Bow::brew_molecule_p () const { Molecule*output = new Molecule; - Real w = width().length (); + Real w = width ().length (); Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]; - Real nw_f = paper()->note_width (); - Real nh_f = paper()->internote_f (); + Real nw_f = paper ()->note_width (); w+= (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]); Real round_w = w; // slur lookup rounds the slurwidth . - Atom a = paper()->lookup_l ()->slur (dy_f, round_w, dir_); + Atom a = paper ()->lookup_l ()->slur (dy_f, round_w, height_f (), dir_); Real error = w-round_w; - a.translate (Offset ((dx_f_drul_[LEFT] + 0.5*nw_f) + a.translate (Offset ( (dx_f_drul_[LEFT] + 0.5*nw_f) + error/2, dy_f_drul_[LEFT])); output->add (a); return output; } - -IMPLEMENT_IS_TYPE_B1(Bow,Directional_spanner); diff --git a/lily/horizontal-vertical-group-item.cc b/lily/horizontal-vertical-group-item.cc new file mode 100644 index 0000000000..2b70f21c62 --- /dev/null +++ b/lily/horizontal-vertical-group-item.cc @@ -0,0 +1,19 @@ +/* + horizontal-vertical-group-item.cc -- implement Horizontal_vertical_group_item + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#include "horizontal-vertical-group-item.hh" +#include "p-col.hh" + +void +Horizontal_vertical_group_item::do_print() const +{ + Horizontal_vertical_group_element::do_print(); +} + +IMPLEMENT_IS_TYPE_B2(Horizontal_vertical_group_item,Horizontal_vertical_group_element,Item); diff --git a/lily/include/bow.hh b/lily/include/bow.hh index 5583156743..c2908836d5 100644 --- a/lily/include/bow.hh +++ b/lily/include/bow.hh @@ -20,7 +20,8 @@ protected: Drul_array dy_f_drul_; Drul_array dx_f_drul_; - Molecule*brew_molecule_p() const; + virtual Real height_f () const; + virtual Molecule* brew_molecule_p () const; public: Bow(); DECLARE_MY_RUNTIME_TYPEINFO; diff --git a/lily/include/collision.hh b/lily/include/collision.hh index 6ab5db3fad..08b0706572 100644 --- a/lily/include/collision.hh +++ b/lily/include/collision.hh @@ -10,7 +10,7 @@ #ifndef COLLISION_HH #define COLLISION_HH #include "lily-proto.hh" -#include "elem-group-item.hh" +#include "horizontal-vertical-group-item.hh" /** Resolve conflicts between various Note_columns (chords). diff --git a/lily/include/horizontal-vertical-group-item.hh b/lily/include/horizontal-vertical-group-item.hh new file mode 100644 index 0000000000..733ff639bd --- /dev/null +++ b/lily/include/horizontal-vertical-group-item.hh @@ -0,0 +1,33 @@ +/* + horizontal-vertical-group-item.hh -- declare Horizontal_vertical_group_item + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef HORIZONTAL_VERTICAL_GROUP_ITEM_HH +#define HORIZONTAL_VERTICAL_GROUP_ITEM_HH + +#include "axis-group-item.hh" +#include "elem-group.hh" + + +/** + Treat a collection of items as a unity + */ +class Horizontal_vertical_group_item : public Axis_group_item, public Horizontal_vertical_group_element { +protected: + virtual void do_print() const; + virtual void remove_all() { Horizontal_vertical_group_element::remove_all (); } + virtual void do_unlink () { Horizontal_vertical_group_element::do_unlink (); } + SCORE_HORIZONTAL_VERTICAL_CLONE(Horizontal_vertical_group_item); +public: + virtual void add_element (Graphical_element*e) { Horizontal_vertical_group_element::add_element (e); } + virtual void remove_element (Graphical_element*e) { Horizontal_vertical_group_element::remove_element (e); } + + DECLARE_MY_RUNTIME_TYPEINFO; +}; + +#endif // HORIZONTAL_VERTICAL_GROUP_ITEM_HH diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index e5cf3f10e9..c290cbd64f 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -50,10 +50,10 @@ struct Lookup { Atom bar (String, Real height) const; Atom dots () const; - Atom slur (Real &dy, Real &dx, Direction dir) const; + Atom slur (Real &dy, Real &dx, Real ht, Direction dir) const; Atom plet (Real &dy, Real &dx, Direction dir) const; Atom tex_slur (int dy, Real &dx, Direction dir) const; - Atom ps_slur (Real dy, Real dx, Real dir) const; + Atom ps_slur (Real dy, Real dx, Real ht, Real dir) const; Atom half_slur (int dy, Real &dx, Direction dir, int xpart) const; Atom half_slur_middlepart (Real &dx, Direction dir) const; Atom big_slur (int dy, Real &dx, Direction dir) const; diff --git a/lily/include/script-column.hh b/lily/include/script-column.hh index e5b83984b7..335ed551fe 100644 --- a/lily/include/script-column.hh +++ b/lily/include/script-column.hh @@ -10,7 +10,7 @@ #ifndef SCRIPT_COLUMN_HH #define SCRIPT_COLUMN_HH -#include "elem-group-item.hh" +#include "horizontal-vertical-group-item.hh" /** a struct for treating a group of noteheads (noteheads, stem (chord) and scripts) as a single entity. */ diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 07b9093f9c..8d2212b294 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -25,6 +25,7 @@ protected: virtual void do_add_processing (); virtual void do_pre_processing (); virtual void do_substitute_dependency (Score_elem*, Score_elem*); + virtual Real height_f () const; SCORE_ELEM_CLONE(Slur); DECLARE_MY_RUNTIME_TYPEINFO; diff --git a/lily/lookup.cc b/lily/lookup.cc index a4dc393ec0..da4083afe6 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -164,7 +164,7 @@ Lookup::hairpin (Real &wid, bool decresc, bool continued) const Atom ret; if (embedded_b) { - Real height = 2 PT; + Real height = paper_l_->get_var ("barsize") / 6; embed = "\\embeddedps{\n" ; embed += String (wid) + " " + String (height) + " " diff --git a/lily/slur.cc b/lily/slur.cc index cc2471bec7..88b2c6cc33 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -23,8 +23,6 @@ #include "debug.hh" #include "boxes.hh" - - void Slur::add (Note_column*n) { @@ -33,25 +31,25 @@ Slur::add (Note_column*n) } void -Slur::set_default_dir() +Slur::set_default_dir () { dir_ = DOWN; - for (int i=0; i < encompass_arr_.size(); i ++) + for (int i=0; i < encompass_arr_.size (); i ++) { if (encompass_arr_[i]->dir_ < 0) { - dir_ =UP; + dir_ = UP; break; } } } void -Slur::do_add_processing() +Slur::do_add_processing () { - set_bounds(LEFT, encompass_arr_[0]); + set_bounds (LEFT, encompass_arr_[0]); if (encompass_arr_.size () > 1) - set_bounds(RIGHT, encompass_arr_.top()); + set_bounds (RIGHT, encompass_arr_.top ()); } void @@ -64,28 +62,27 @@ void Slur::do_substitute_dependency (Score_elem*o, Score_elem*n) { int i; - while ((i = encompass_arr_.find_i ((Note_column*)o->item())) >=0) + while ((i = encompass_arr_.find_i ((Note_column*)o->item ())) >=0) { if (n) - encompass_arr_[i] = (Note_column*)n->item(); + encompass_arr_[i] = (Note_column*)n->item (); else encompass_arr_.del (i); } } - static int Note_column_compare (Note_column *const&n1 , Note_column* const&n2) { - return Item::left_right_compare(n1, n2); + return Item::left_right_compare (n1, n2); } void -Slur::do_post_processing() +Slur::do_post_processing () { encompass_arr_.sort (Note_column_compare); if (!dir_) - set_default_dir(); + set_default_dir (); Real interline_f = paper ()->interline_f (); Real inter_f = interline_f / 2; @@ -106,10 +103,10 @@ Slur::do_post_processing() Drul_array extrema; extrema[LEFT] = encompass_arr_[0]; - extrema[RIGHT] = encompass_arr_.top(); + extrema[RIGHT] = encompass_arr_.top (); Direction d=LEFT; - Real nw_f = paper()->note_width (); + Real nw_f = paper ()->note_width (); do { @@ -120,17 +117,60 @@ Slur::do_post_processing() } else if (extrema[d]->stem_l_ && !extrema[d]->stem_l_->transparent_b_) { - dy_f_drul_[d] = (int)rint (extrema[d]->stem_l_->height()[dir_]); + dy_f_drul_[d] = (int)rint (extrema[d]->stem_l_->height ()[dir_]); /* normal slur from notehead centre to notehead centre, minus gap */ dx_f_drul_[d] += -d * gap_f; } else { - dy_f_drul_[d] = (int)rint (extrema[d]->head_positions_interval()[dir_])* inter_f; + dy_f_drul_[d] = (int)rint (extrema[d]->head_positions_interval ()[dir_])* inter_f; } dy_f_drul_[d] += dir_ * interline_f; } while ((d *= -1) != LEFT); } +Real +Slur::height_f () const +{ + /* + rather braindead way that of adjusting slur height + for heads/stems that extend beyond default slur + works quite good + */ + + Real interline_f = paper ()->interline_f (); + Real nh_f = interline_f / 2; + Real h = 0; + Real dx = width ().length (); + Real dy = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]; + Stem* stem = encompass_arr_[0]->stem_l_; + Real lx = stem->hpos_f (); + Real centre = (width ().min () + width ().max ()) / 2; + Real ly = stem->dir_ == dir_ ? stem->stem_end_f () : stem->stem_begin_f () + + dir_ * nh_f / 2; + for (int i = 0; i < encompass_arr_.size (); i++) + { + Stem* stem = encompass_arr_[i]->stem_l_; + Real sx = abs (centre - stem->hpos_f ()); + Real sy = stem->dir_ == dir_ ? stem->stem_end_f () + : stem->stem_begin_f () + dir_ * nh_f / 2; + sy = dir_ * (sy - (ly + ((stem->hpos_f () - lx) / dx) * dy)); + /* + uhm, correct for guess bezier curve (more if further from centre) + forget the cos alpha... + */ + if (sy > 0) + h = h >? sy * (1 + 2 * sx / dx); + } + Real ratio = 1.0/3; // duh + /* + correct h for slur ratio + */ + Real staffheight = paper ()->get_var ("barsize"); + if (h) + h *= ((h * interline_f) / dx ) / ratio; + return h; +} + IMPLEMENT_IS_TYPE_B1(Slur,Spanner); diff --git a/lily/tex-slur.cc b/lily/tex-slur.cc index b0c67cf95b..51af06c230 100644 --- a/lily/tex-slur.cc +++ b/lily/tex-slur.cc @@ -133,12 +133,13 @@ Lookup::half_slur (int dy, Real &dx, Direction dir, int xpart) const } Atom -Lookup::ps_slur (Real dy , Real dx, Real dir) const +Lookup::ps_slur (Real dy , Real dx, Real ht, Real dir) const { String ps = "\\embeddedps{\n"; ps += String_convert::double_str (dx) + " " + String_convert::double_str (dy) + " " + + String_convert::double_str (ht) + " " + String_convert::double_str (dir) + " draw_slur}"; @@ -279,7 +280,7 @@ Lookup::big_slur (int dy , Real &dx, Direction dir) const Atom -Lookup::slur (Real &dy_f , Real &dx, Direction dir) const +Lookup::slur (Real &dy_f , Real &dx, Real ht, Direction dir) const { if (dx < 0) { @@ -289,7 +290,7 @@ Lookup::slur (Real &dy_f , Real &dx, Direction dir) const Atom s; if (postscript_global_b) - s = ps_slur (dy_f, dx, dir); + s = ps_slur (dy_f, dx, ht, dir); else { Real nh = paper_l_->internote_f (); diff --git a/mutopia/J.S.Bach/preludes-4.ly b/mutopia/J.S.Bach/preludes-4.ly index 2d28e33f2a..6086842e71 100644 --- a/mutopia/J.S.Bach/preludes-4.ly +++ b/mutopia/J.S.Bach/preludes-4.ly @@ -6,46 +6,95 @@ enteredby = "jcn"; copyright = "public domain"; } -rh = \melodic{ +\include "paper20.ly" + +one = \melodic{ \octave c''; \textstyle "italic"; - % ugh, start in multi, because of slurring an tieing over bars - \multi 2 < - { - r16\p_"legato" - ['d-1( 'fis-3 'd-1] ['a-2 'b-3 cis-4 'a-3] - [d-3 cis-2 d-1 e-2] [d-1 fis-3 e-2 d-1] | - \textstyle "finger"; - \stemup; - )cis4-2 fis-5 ~ [fis8 fis-4] e4-3 ~ | - e( )d8-2 s s4 s4 | - r8 d4-> cis8-1 ~ cis 'b4-1 'b8 | - } - { -% s1 - \stemdown; - r8 'a4 'a8 'b4.-"2\\_1" cis8 ~ | - cis16\< ['a( cis 'a] [d-2 e fis d-1] - [g-3 fis g a-4] [a-3 b a \!g] | - )fis4-"2\\_3" [e8-2 a-5] | - } - > - \stemboth; + r16\p_"legato" + \textstyle "finger"; + ['d-1( 'fis-3 'd-1] ['a-2 'b-3 cis-4 'a-3] + [d-3 cis-2 d-1 e-2] [d-1 fis-3 e-2 d-1] | + \textstyle "finger"; + \stemup; + )cis4-2 fis-5 ~ [fis8 fis-4] e4-3 ~ | + e16\< \stemboth ['a16( cis 'a] [d-2 e fis d-1] + [g-3 fis g a-4] [a-3 b a \!g] | + \stemup + )fis4-"2\\_3" [e8-2 a-5] | + <[)g!16-5 d> fis-2 g-3 a-4] + \stemboth + [g-3 b a g] | + \textstyle "italic"; + [fis_"dim." e fis-3 g] [fis-3 a-5 g fis] + \textstyle "finger"; + e4-"2\\_5" ~ e16 ['e( 'fis 'g ] | + \textstyle "italic"; + ['a-4_"dim." 'g-1 'a 'b] ['a-2 c-4 'b 'a] + ['g-1 'fis-2 'g-3 'a] ['g-3 'b 'a 'g] | + \stemup + )'fis4\p r16 [''b-1\< d-2 ''b~] <'g4-5 'e-3 ''b> + r16 ['cis-1 'e-2 \!cis] | % cis wants ~ + +} + +two = \melodic{ + \textstyle "finger"; +% ugh: koor +% \translator Staff=bass \octave c; \stemup + fis4-1( e8-2 a4 a4 gis8-2 | + ) a8 + \translator Staff=treble \octave c''; \stemdown + 'a4 'a8 'b4.-"2\\_1" cis8 ~ | + cis8 + \translator Staff=bass \octave c; \stemup + a8 ~ [a d'] ~ d' d'4-> c'8 | + d'8 + \translator Staff=treble \octave c''; \stemdown + d4-> cis8-1 ~ cis 'b4-1 'b8 | + r8 'a4 'a8 + \translator Staff=bass \octave c; \stemup + [g'8-1( fis'-2] )e'4-1 ~ | + e'4 d' ~ [d'16 d-1 cis'-2 g-1] cis'4-2 ~ | + [c'8 a-3] d'4.-1 d'4-> cis'8-2 | + \translator Staff=treble \octave c''; \stemdown + 'd4 \skip 4*3; | +} + +three = \melodic{ + \octave c; + \stemdown; + d4-3 c-4 'b e-3 | + a16 ['a-5\mf( c-3 'a-5] [d-2 e-1 fis-2 d-4] + [g-1 fis-3 g a] [g b a g] | + )fis4 fis e a-4 | + d'16 \stemboth [d-5\f( fis-3 d-5] [a-2 b-1 c'-2 a-4] + [d'-1 c'-3 d' e'] [d'-4 fis'-2 e'-1 ) d'] | + [cis'-3 b-4 cis'-3 d'-2] [c'-4 e'-2 d'-3 c'-4] + \stemdown b4-5 [cis'8-4 b-3(] | + [a-4 )fis-5 b-2 a-3] [gis-4 e-5 a-3 g-4] | + fis4. d8-5 e4-5 a4-3 | + \stemboth + r16 [d-4( fis-2 d-4] [)g8-.-1 'g-.-5] + r16 [e-4( g-2 e-4] [)a8-. 'a-.-5] | +} + +rh = \melodic{ + \one \bar "|."; } + lh = \melodic{ - \octave c; - \clef bass; - s1 | s1 | s1 | s1 -% \multi 2 < -% { \stemup; } -% { \stemdown; } -% > -% \stemboth; | + \clef "bass"; + \multi 2 < + \two + \three + > \bar "|."; } + global = \melodic{ \meter 4/4; \key fis cis; @@ -55,16 +104,24 @@ global = \melodic{ % Allegretto % it would be nice to shut-off fingering... \melodic \type Grandstaff < - < + \type Staff=treble < \global - \rh +% huh? try these iso directly! + \lh +% \one +% \two > - < + \type Staff=bass < \global - \lh + \rh +% or try \two having here, iso above! +% \two +% \three > > \paper{ + \paper_twenty + linewidth= 195.\mm; } \midi{ \tempo 4 = 110; diff --git a/tex/lily-ps-defs.tex b/tex/lily-ps-defs.tex index f93da7cfd2..cab0aaa82c 100644 --- a/tex/lily-ps-defs.tex +++ b/tex/lily-ps-defs.tex @@ -82,6 +82,7 @@ def bind def /draw_cresc { + staffrulethickness setlinewidth /cresc_cont exch def /cresc_ht exch def /cresc_wd exch def @@ -118,14 +119,14 @@ def stroke } bind def - staffheight 2 div - /slurhtlimit exch def + staffheight 2 div /slurhtlimit exch def /slurratio 0.3333 def % % (b*ratio)/(1 + b / htlimit) /getslurcontrol { - slurhtlimit 90 div /slur_alpha exch def + slurhtlimit add /slurheight exch def + slurheight 90 div /slur_alpha exch def slurratio 60 div slur_alpha div /slur_beta exch def slur_beta mul 1 atan slur_alpha mul } bind def @@ -135,12 +136,13 @@ def staffrulethickness setlinewidth 0 0 moveto /slur_dir exch def + /slur_height exch def /slur_dy exch def /slur_dx exch def slur_dy slur_dx lily_distance /slur_b exch def - slur_b getslurcontrol + slur_b slur_height getslurcontrol slur_dir mul /slur_ht exch def - slur_b getslurcontrol /slur_indent exch def + slur_b slur_height getslurcontrol /slur_indent exch def % slur_dy slur_dx atan rotate slur_indent slur_ht -- 2.39.5