From d395636da46ec87eeee577e9fada14b89a4e3b30 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 20:09:34 +0000 Subject: [PATCH] lilypond-0.1.55 --- VERSION | 2 +- input/sleur.ly | 43 ++++++++++++--- lily/slur.cc | 133 +++++++++++++++++++++++++++++++++++----------- lily/template6.cc | 1 + lily/template7.cc | 2 +- 5 files changed, 139 insertions(+), 42 deletions(-) diff --git a/VERSION b/VERSION index 3729e0a8d1..5532217ea8 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ MAJOR_VERSION=0 MINOR_VERSION=1 -PATCH_LEVEL=54 +PATCH_LEVEL=55 MY_PATCH_LEVEL= # now used as shell script in configure too diff --git a/input/sleur.ly b/input/sleur.ly index 0f53a82adc..964e05a0ca 100644 --- a/input/sleur.ly +++ b/input/sleur.ly @@ -32,14 +32,15 @@ beum = \melodic{ } extend = \melodic{ - 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 | + \octave c; + 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 | } extendbug = \melodic{ @@ -49,10 +50,36 @@ extendbug = \melodic{ [c'8( b g a] [c' d' e' c'] [c' d' e' )c'] c( c' c' )c e( g' g' )e + +} + +blend = \melodic{ + \octave c; + \stemdown; +%% \[4/5c8( c ''c c c\]1/1 c c c )c | + \[4/5c8( c ''f c c\]1/1 c c c )c | + \[4/5c8( c \stemup ''f \stemdown c c\]1/1 c c c )c | + \stemup; + \octave c''; + \[4/5c8( c f'' c c\]1/1 c c c )c | + \[4/5c8( c \stemdown f'' \stemup c c\]1/1 c c c )c | +% \octave c'''; + \stemboth; + c4( 'c16 'e 'g 'b d f a )'c16 c4 | + c4( 'c16 'e 'g 'b d f f )'c16 c4 | + \octave c'; + \stemdown; + c( c'' c'' )c + \stemboth; + e( g' g' )e + e( g' g' )e + e( g' g' )e + e( g' g' )e } \score{ \melodic{ + \blend \shortlong \dirs \complex diff --git a/lily/slur.cc b/lily/slur.cc index e1a8cf926b..8ec8633b5d 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -22,6 +22,7 @@ #include "molecule.hh" #include "debug.hh" #include "boxes.hh" +#include "bezier.hh" void Slur::add (Note_column*n) @@ -130,48 +131,116 @@ Slur::do_post_processing () while (flip(&d) != LEFT); } +static Real +pos_correct (Real x, Real dx, Real dy) +{ + /* + guess how much we can safely increase 'h' + parameter of bow without taking too large + or too many steps. + empiric computer science + */ +// return (1.0 + 2.0 * x / dx) / 4.0; + return 1.0; +} + Real Slur::height_f () const { + Real interline = paper ()->interline_f (); + Real notewidth = paper ()->note_width (); + Real internote = interline / 2; + /* - rather braindead way that of adjusting slur height - for heads/stems that extend beyond default slur - works quite good + having the correct (i.e. exactly the same as the ps stuff) + x,y coordinates is essential. + getting them is quite a mess, currently. */ - Real interline_f = paper ()->interline_f (); - Real nh_f = interline_f / 2; - Real h = 0; + Stem* left_stem =encompass_arr_[0]->stem_l_; + Real left_x = left_stem->hpos_f (); + // ugh, do bow corrections (see brew_mol) + left_x += dx_f_drul_[LEFT] + 0.5 * notewidth; + +// Real left_y = left_stem->dir_ == dir_ ? left_stem->stem_end_f () + dir_ +// : left_stem->stem_begin_f () + 0.5 * dir_; +// left_y *= internote; + // ugh, do bow corrections (see brew_mol) +// left_y = dy_f_drul_[LEFT]; + + // ugh, do bow corrections (see brew_mol) + Real left_y = dy_f_drul_[LEFT]; + + // ugh, where does this asymmetry come from? + if (dir_ == DOWN) + left_y -= dir_ * internote; + Real dx = width ().length (); -// Real dy = (dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]) * nh_f; 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 + lx; - Real ly = stem->dir_ == dir_ ? stem->stem_end_f () : stem->stem_begin_f () - + dir_ * 0.5; - ly *= nh_f; - for (int i = 0; i < encompass_arr_.size (); i++) + Real centre_x = dx / 2; + + + // ugh, need staffheight for bow damping + Bezier_bow b (paper ()); + + if (check_debug && !monitor->silent_b ("Slur")) { - Stem* s = encompass_arr_[i]->stem_l_; - Real sx = abs (centre - s->hpos_f ()); - Real stemy = s->dir_ == dir_ ? s->stem_end_f () : s->stem_begin_f () + dir_ * 0.5; - stemy *= nh_f; - Real sy = dir_ * (stemy - (ly + ((s->hpos_f () - lx) / dx) * dy)); - /* - uhm, correct for guess bezier curve (more if further from centre) - forget the cos alpha... - */ - if (sy > 0.5 * nh_f) - h = h >? (sy * (1 + 2 * sx / dx))*(1 + abs (dy)/32); + cout << "*****************" << endl; + cout << "dir: " << (int)dir_ << endl; + cout << "dx: " << dx << endl; + cout << "dy: " << dy << endl; + cout << "centre: " << centre_x << endl; + for (int i = 0; i < encompass_arr_.size (); i++) + cout << "i: " << i << " x: " + << encompass_arr_[i]->stem_l_->hpos_f () - left_x << endl; } - if ( h < nh_f ) - return 0; - h *= h/(dx*dx*dx); -// h *= 32; -// h *= h; - h *= 40000; - return h; + Real height = 0; + Real dh = 0; + do + { + height += dh; + dh = 0; + b.calc (dx, dy, height, dir_); + + if (check_debug && !monitor->silent_b ("Slur")) + cout << "----" << endl; + for (int i = 1; i < encompass_arr_.size () - 1; i++) + { + Stem* stem = encompass_arr_[i]->stem_l_; + /* + set x to middle of notehead or on exact x position of stem, + according to slur direction + */ + Real x = stem->hpos_f () - left_x + notewidth / 2; + if (stem->dir_ != dir_) + x += notewidth / 2; + else if (stem->dir_ == UP) + x += notewidth; + Real y = stem->dir_ == dir_ ? stem->stem_end_f () + : stem->stem_begin_f () + 1.5 * dir_; + + /* + leave a gap: slur mustn't touch head/stem + */ + y += 2.5 * dir_; + y *= internote; + y -= left_y; + + Real shift = dir_ * (y - b.y (x)); + + if (check_debug && !monitor->silent_b ("Slur")) + { + cout << "x: " << x << " (" << abs (centre_x - x) << ")" << endl; + cout << "y: " << y << ", curve: " << b.y (x) << endl; + cout << "shift: " << shift << endl; + } + + if (shift > 0.1 * internote) + dh = dh >? shift * pos_correct (abs (centre_x - x), dx, dy); + } + } while (dh); + + return height; } IMPLEMENT_IS_TYPE_B1(Slur,Spanner); diff --git a/lily/template6.cc b/lily/template6.cc index 4f7a1ed1ab..3785014d69 100644 --- a/lily/template6.cc +++ b/lily/template6.cc @@ -1,4 +1,5 @@ #include "proto.hh" +#include "pcursor.tcc" #include "plist.tcc" #include "translator.hh" diff --git a/lily/template7.cc b/lily/template7.cc index 7b5d8142ed..868573a374 100644 --- a/lily/template7.cc +++ b/lily/template7.cc @@ -7,8 +7,8 @@ */ #include "proto.hh" -#include "plist.hh" #include "pcursor.tcc" +#include "plist.hh" #include "plist.tcc" #include "music-list.hh" -- 2.39.5