From 6bf1606d827527f02953add0988a4fbbf0dc0c4e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 6 Aug 2001 14:19:40 +0200 Subject: [PATCH] release: 1.5.4 ========== * midi2ly bugfixes: don't print ';' in .ly output. * small cleanup of input/bugs/ * bugfix: nested grace notes; added input/regression/grace-nest.ly * Bugfix: add double alterations to keyAccidentalOrder (Mats) * Fixes for PostScript beams and stems. 1.5.2.h --- CHANGES | 13 +- VERSION | 4 +- input/bugs/braces.ly | 3 + input/bugs/dots.ly | 2 +- input/bugs/grace-clef.ly | 3 - input/bugs/grace-dynamic.ly | 5 +- input/bugs/grace-finger.ly | 3 +- input/bugs/grace-gets-slur.ly | 11 - input/bugs/grace-pedal.ly | 7 - input/bugs/nest-core.ly | 8 - input/bugs/newgrace.ly | 8 - input/bugs/sbug.ly | 8 - input/bugs/triplet.ly | 10 - input/regression/grace-nest.ly | 12 + input/regression/grace-start.ly | 2 + input/regression/grace-sync.ly | 6 +- lily/auto-beam-engraver.cc | 2 +- lily/beam-engraver.cc | 2 +- lily/grace-iterator.cc | 6 +- lily/grace-music.cc | 4 +- lily/include/moment.hh | 8 +- lily/include/sequential-music-iterator.hh | 26 +- lily/midi-item.cc | 2 +- lily/moment.cc | 34 +- lily/music-sequence.cc | 10 +- lily/paper-stream.cc | 3 +- lily/parser.yy | 2 +- lily/script-engraver.cc | 6 +- lily/separation-item.cc | 8 + lily/sequential-music-iterator.cc | 66 ++- lily/spacing-spanner.cc | 616 ++++++++++++++++++++++ ly/engraver-init.ly | 4 +- ly/grace-init.ly | 13 +- make/out/lilypond.lsm | 8 +- make/out/lilypond.redhat.spec | 4 +- make/out/lilypond.suse.spec | 4 +- midi2ly/lilypond-item.cc | 2 +- midi2ly/lilypond-stream.cc | 2 +- scripts/etf2ly.py | 15 +- scripts/ly2dvi.py | 3 +- 40 files changed, 803 insertions(+), 152 deletions(-) delete mode 100644 input/bugs/grace-clef.ly delete mode 100644 input/bugs/grace-pedal.ly delete mode 100644 input/bugs/nest-core.ly delete mode 100644 input/bugs/newgrace.ly delete mode 100644 input/bugs/sbug.ly delete mode 100644 input/bugs/triplet.ly create mode 100644 input/regression/grace-nest.ly diff --git a/CHANGES b/CHANGES index d0644b08e0..78a9eaa2a5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,15 @@ -1.5.3.jcn1 +1.5.3.hwn1 ========== -* Fixes for PostScript beams and stems. +* midi2ly bugfixes: don't print ';' in .ly output. -1.5.3 -===== +* small cleanup of input/bugs/ + +* bugfix: nested grace notes; added input/regression/grace-nest.ly + +* Bugfix: add double alterations to keyAccidentalOrder (Mats) + +* Fixes for PostScript beams and stems. 1.5.2.hwn1 ========== diff --git a/VERSION b/VERSION index 6b8ac095df..c76a3bf252 100644 --- a/VERSION +++ b/VERSION @@ -1,8 +1,8 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 -PATCH_LEVEL=3 -MY_PATCH_LEVEL=jcn1 +PATCH_LEVEL=4 +MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/bugs/braces.ly b/input/bugs/braces.ly index 10d474ef81..04179b0ec3 100644 --- a/input/bugs/braces.ly +++ b/input/bugs/braces.ly @@ -1,3 +1,6 @@ +% this bug apparently caused by dvips + mf rounding. + + \header { texidoc="Run this through ly2dvi to show differerent brace sizes" } diff --git a/input/bugs/dots.ly b/input/bugs/dots.ly index f48fe19b75..ff1d7f20ff 100644 --- a/input/bugs/dots.ly +++ b/input/bugs/dots.ly @@ -1,6 +1,6 @@ \header { - texidoc = "Dots should remain close to the heads they belong to, but should not overlap."; + texidoc = "Dots should remain close to the heads they belong to, but should not overlap." } diff --git a/input/bugs/grace-clef.ly b/input/bugs/grace-clef.ly deleted file mode 100644 index 460ee4d094..0000000000 --- a/input/bugs/grace-clef.ly +++ /dev/null @@ -1,3 +0,0 @@ -\score {\notes\context Voice { -c4 \clef bass \grace c'8 c4 - }} diff --git a/input/bugs/grace-dynamic.ly b/input/bugs/grace-dynamic.ly index b79d9753fd..89b002c4cf 100644 --- a/input/bugs/grace-dynamic.ly +++ b/input/bugs/grace-dynamic.ly @@ -1,3 +1,4 @@ - -\score { \notes {\grace {c'_\f} d e f g}} + % ? + + \score { \notes \context Voice {\grace {c'_\f} d e f g}} diff --git a/input/bugs/grace-finger.ly b/input/bugs/grace-finger.ly index 38095ef78b..077b407038 100644 --- a/input/bugs/grace-finger.ly +++ b/input/bugs/grace-finger.ly @@ -1,6 +1,7 @@ - + % ? + \score { \notes \context Voice = VA \relative c'' { \grace {[b8^1 c^2]} d4^3 diff --git a/input/bugs/grace-gets-slur.ly b/input/bugs/grace-gets-slur.ly index 65703e7b81..8b13789179 100644 --- a/input/bugs/grace-gets-slur.ly +++ b/input/bugs/grace-gets-slur.ly @@ -1,12 +1 @@ - -\score { - \notes\relative c''{ - \grace g8 g'2 ( )g - } - \paper { - linewidth=40.\mm; - indent=0.; - } -} - diff --git a/input/bugs/grace-pedal.ly b/input/bugs/grace-pedal.ly deleted file mode 100644 index 0d381d1dda..0000000000 --- a/input/bugs/grace-pedal.ly +++ /dev/null @@ -1,7 +0,0 @@ - -% dumps core: 1.3.93 -\score{ - \notes{ - \grace { } <)gis'2 e> - } -} diff --git a/input/bugs/nest-core.ly b/input/bugs/nest-core.ly deleted file mode 100644 index c8ebfe3c61..0000000000 --- a/input/bugs/nest-core.ly +++ /dev/null @@ -1,8 +0,0 @@ -\header{ -texidoc="running this through ly2dvi, or with -Hheader dumps core" -tagline="{" -} - -\score { - \notes c -} \ No newline at end of file diff --git a/input/bugs/newgrace.ly b/input/bugs/newgrace.ly deleted file mode 100644 index 9db2a2b46e..0000000000 --- a/input/bugs/newgrace.ly +++ /dev/null @@ -1,8 +0,0 @@ -\score { \notes { - \clef bass - <{ - \grace { [c16 ] } - \relative b, b2 - } > -} -} diff --git a/input/bugs/sbug.ly b/input/bugs/sbug.ly deleted file mode 100644 index fae779b608..0000000000 --- a/input/bugs/sbug.ly +++ /dev/null @@ -1,8 +0,0 @@ -% the \stopped collides with the -%beam. - - -% stopped disappeared ?? -\score { \notes { -\clef "G"; \stemUp [a''8^\stopped a''8_\stopped] -}} diff --git a/input/bugs/triplet.ly b/input/bugs/triplet.ly deleted file mode 100644 index 9992897582..0000000000 --- a/input/bugs/triplet.ly +++ /dev/null @@ -1,10 +0,0 @@ -\header { -texidoc="manual beam override is ignored in first triplet" -} - -\score { - \context Voice \notes\relative c'' { - \times 2/3 { < [ a8 c > < a c > < a c ] > } - \times 2/3 < { [ a8 a a ] } { c c c ] } > - } -} diff --git a/input/regression/grace-nest.ly b/input/regression/grace-nest.ly new file mode 100644 index 0000000000..71ca4b43e3 --- /dev/null +++ b/input/regression/grace-nest.ly @@ -0,0 +1,12 @@ +\header { +texidoc = "grace code should not be confused by nested sequential musics, containing grace notes; practically speaking, this means that the end-bar and measure bar coincide in this example." + +} +\score{ +\notes + +{ c''2 { \grace b'16 c''2 } \bar "|." } + \paper { +} + } + diff --git a/input/regression/grace-start.ly b/input/regression/grace-start.ly index 1094d3b5fd..5c0c5dff67 100644 --- a/input/regression/grace-start.ly +++ b/input/regression/grace-start.ly @@ -3,7 +3,9 @@ texidoc = "Pieces may begin with grace notes." } \score {\notes \relative c' \context Staff { \grace { [a'16 f] } g1 + \bar "||" % test if | and || are synced. \grace { [a16 bes] } c1 + \bar "||" % test if | and || are synced. } \paper { linewidth = -1. } } diff --git a/input/regression/grace-sync.ly b/input/regression/grace-sync.ly index 0ddcdf37f8..419ccdeb14 100644 --- a/input/regression/grace-sync.ly +++ b/input/regression/grace-sync.ly @@ -3,10 +3,10 @@ } \score {\notes < \context Staff { c2 - \ngrace c8 - c2 c4 } + \grace c8 + c2 c4 } \context Staff = SB { c2 \clef bass - %\ngrace { [dis8 ( d8] } + \grace { [dis8 ( d8] } ) c2 c4 } \context Staff = SC { c2 c2 c4 } diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 94671aabf0..781f03393f 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -399,7 +399,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info) /* ignore grace notes. */ - if (bool (beam_start_location_.grace_mom_) != bool (now_mom ().grace_mom_)) + if (bool (beam_start_location_.grace_part_) != bool (now_mom ().grace_part_)) return ; diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 7b506953c8..122a7ecd3c 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -242,7 +242,7 @@ Beam_engraver::acknowledge_grob (Grob_info info) { Moment now = now_mom(); - if(bool (now.grace_mom_ ) != bool (beam_start_mom_.grace_mom_)) + if(bool (now.grace_part_ ) != bool (beam_start_mom_.grace_part_)) return ; Item *stem_l = dynamic_cast (info.elem_l_); diff --git a/lily/grace-iterator.cc b/lily/grace-iterator.cc index 9248e071f8..fde8167730 100644 --- a/lily/grace-iterator.cc +++ b/lily/grace-iterator.cc @@ -22,10 +22,10 @@ Grace_iterator::~Grace_iterator () void -Grace_iterator::process (Moment m ) +Grace_iterator::process (Moment m) { Moment main ; - main.main_part_ = m.grace_mom_; + main.main_part_ = music_length_.grace_part_ + m.grace_part_; Music_wrapper_iterator::process (main); } @@ -43,7 +43,7 @@ Grace_iterator::pending_moment () const Moment cp =Music_wrapper_iterator::pending_moment(); Moment pending; - pending.grace_mom_ = - music_length_.main_part_ + cp.main_part_; + pending.grace_part_ = cp.main_part_- music_length_.grace_part_ ; return pending; } diff --git a/lily/grace-music.cc b/lily/grace-music.cc index 9e88f7b835..27c88c6f7b 100644 --- a/lily/grace-music.cc +++ b/lily/grace-music.cc @@ -21,7 +21,7 @@ Grace_music::length_mom () const { Moment l = Music_wrapper::length_mom (); Moment gl; - gl.grace_mom_ = l.main_part_ + l.grace_mom_ ; + gl.grace_part_ = l.main_part_ + l.grace_part_ ; return gl; } @@ -29,7 +29,7 @@ Grace_music::length_mom () const Moment Grace_music::start_mom () const { - return Music::start_mom (); + return - length_mom (); } Grace_music::Grace_music () diff --git a/lily/include/moment.hh b/lily/include/moment.hh index fca85bb458..a882bb0986 100644 --- a/lily/include/moment.hh +++ b/lily/include/moment.hh @@ -14,7 +14,8 @@ #include "rational.hh" /** - Rationals with glue for Guilification; + Musical timing (Main-timing, grace-timing) with glue for + Guilification; */ class Moment { @@ -26,7 +27,8 @@ public: Moment (Rational m); - + Moment operator - () const; + void operator += (Moment const &m); void operator -= (Moment const &m); @@ -34,7 +36,7 @@ public: void operator /= (Moment const &m); Rational main_part_; - Rational grace_mom_; + Rational grace_part_; void set_infinite (int k); diff --git a/lily/include/sequential-music-iterator.hh b/lily/include/sequential-music-iterator.hh index 6f13f44141..fcedb517f7 100644 --- a/lily/include/sequential-music-iterator.hh +++ b/lily/include/sequential-music-iterator.hh @@ -12,11 +12,35 @@ #include "music-iterator.hh" +/* + + This is a lookahead list for grace notes. + + { ... X \grace Y Z ... } + + normally, the ending of X is the start of Z. In case of a grace + note, we take off a little at the end of X. What is stored: START + (start point of X), LENGTH (length of X), GRACE_START (start_music + of Y), and the next fixup element. + + This is also done for nested musics, i.e. + + voiceA = \notes { \grace b16 c'2 } + voiceB = \notes { c'2 \voiceA } + + the iterator for voiceB will contain a fixup entry with (START=0/1, + LENGTH=2/1, GRACE_START=(0G-1/16) ) + + Graces at the start of a sequential music iterator are handled + by initting here_mom_ with Music::start_music (); no fixups are needed. + +*/ struct Grace_skip { Moment start_; Rational length_; - Rational grace_length_; + + Rational grace_start_; Grace_skip *next_; }; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 2e9d260163..11f6bd559f 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -98,7 +98,7 @@ String Midi_event::str () const { Rational rat_dt = (delta_mom_.main_part_ * Rational (384) + - delta_mom_.grace_mom_ * Rational (100))*Rational (4); + delta_mom_.grace_part_ * Rational (100))*Rational (4); int delta_i = int (rat_dt); String delta_str = Midi_item::i2varint_str (delta_i); diff --git a/lily/moment.cc b/lily/moment.cc index ca6188f944..5a3ff5f8fc 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -98,7 +98,7 @@ Moment::compare (Moment const &a, Moment const &b) if (c) return c; - return Rational::compare (a.grace_mom_, b.grace_mom_); + return Rational::compare (a.grace_part_, b.grace_part_); } Moment::Moment () @@ -109,32 +109,32 @@ Moment::Moment () Moment::Moment (int m) { main_part_ = Rational(m); - grace_mom_ = Rational( 0); + grace_part_ = Rational( 0); } Moment::Moment (int m, int n) { main_part_ = Rational (m,n); - grace_mom_ = Rational (0); + grace_part_ = Rational (0); } Moment::Moment (Rational m) { main_part_ = m; - grace_mom_ = Rational (0); + grace_part_ = Rational (0); } void Moment::operator += (Moment const &src) { main_part_ +=src.main_part_ ; - grace_mom_ += src.grace_mom_; + grace_part_ += src.grace_part_; } void Moment::operator -= (Moment const &src) { main_part_ -= src.main_part_ ; - grace_mom_ -= src.grace_mom_; + grace_part_ -= src.grace_part_; } /* @@ -144,7 +144,7 @@ void Moment::operator *= (Moment const &src) { main_part_ *= src.main_part_ ; - grace_mom_ *= src.main_part_; + grace_part_ *= src.main_part_; } /* @@ -154,7 +154,7 @@ void Moment::operator /= (Moment const &src) { main_part_ /= src.main_part_ ; - grace_mom_ /= src.main_part_; + grace_part_ /= src.main_part_; } @@ -174,7 +174,7 @@ Moment::num () const { return main_part_.num (); } Moment::operator bool () { - return main_part_ || grace_mom_; + return main_part_ || grace_part_; } void @@ -187,5 +187,19 @@ Moment::set_infinite (int k) String Moment::str () const { - return main_part_.str (); + String s = main_part_.str (); + if (grace_part_) + { + s += "G" + grace_part_.str (); + } + return s; +} + +Moment +Moment::operator - ( ) const +{ + Moment m; + m.grace_part_ = -grace_part_; + m.main_part_ = -main_part_; + return m; } diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index 47927f6cb9..17da5f4674 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -75,15 +75,15 @@ Music_sequence::cumulative_length () const for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) { Moment l = unsmob_music (gh_car (s))->length_mom (); - if (last_len.grace_mom_ && l.main_part_) + if (last_len.grace_part_ && l.main_part_) { - last_len.grace_mom_ = Rational (0); + last_len.grace_part_ = Rational (0); } cumulative += last_len; last_len = l; } - last_len.grace_mom_ = Rational (0); + last_len.grace_part_ = Rational (0); cumulative += last_len; return cumulative; @@ -170,9 +170,9 @@ Music_sequence::first_start () const if (l.main_part_) return mus->start_mom (); - else if (l.grace_mom_) + else if (l.grace_part_) { - m.grace_mom_ = - l.grace_mom_; + m.grace_part_ = - l.grace_part_; return m; } } diff --git a/lily/paper-stream.cc b/lily/paper-stream.cc index ba3c9ee115..d2bbeb3f9c 100644 --- a/lily/paper-stream.cc +++ b/lily/paper-stream.cc @@ -71,7 +71,8 @@ Paper_stream::Paper_stream (String filename) Paper_stream::~Paper_stream () { close_file_stream (os_); - assert (nest_level == 0); + if (nest_level != 0) + programming_error ("Brace nesting in paper output doesn't match"); } // print string. don't forget indent. diff --git a/lily/parser.yy b/lily/parser.yy index 4f4747ab5a..b9f4793d2c 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -806,7 +806,7 @@ Composite_music: chm->set_spot (*$3->origin ()); } | GRACE Music { -#if 1 +#if 0 /* The other version is for easier debugging of Sequential_music_iterator in combination with grace notes. diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 70844dc5b6..17aec42ba0 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -139,8 +139,10 @@ Script_engraver::acknowledge_grob (Grob_info inf) } if (Side_position_interface::get_axis (e) == X_AXIS && !e->parent_l (Y_AXIS)) - e->set_parent (inf.elem_l_, Y_AXIS); - + { + e->set_parent (inf.elem_l_, Y_AXIS); + e->add_dependency (inf.elem_l_); // ?? + } Side_position_interface::add_support (e,inf.elem_l_); } } diff --git a/lily/separation-item.cc b/lily/separation-item.cc index b5642dbc26..522cde9ac1 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -60,6 +60,14 @@ Separation_item::my_width (Grob *me) } } + SCM pad = me->get_grob_property ("padding"); + + if (gh_number_p (pad)) + { + w[RIGHT] += gh_scm2double (pad)/2; + w[LEFT] -= gh_scm2double (pad)/2; + } + return w; // add this->offset_ ? this-> relative_coordinate ()? } diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index e02847f991..7a6b240a15 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -27,8 +27,6 @@ here_mom_ = sum (length (musiclist [start ... cursor>)) %) */ - - Sequential_music_iterator::Sequential_music_iterator () { cursor_ = SCM_EOL; @@ -59,33 +57,33 @@ Grace_skip * get_grace_skips (SCM cursor) { Moment here (0); - Moment last (here); + Moment last (-1); Grace_skip *head = 0; Grace_skip **tail = &head; - bool first = true; - for (; gh_pair_p (cursor); cursor = gh_cdr (cursor)) { Music * mus = unsmob_music (gh_car (cursor)); Moment l =mus->length_mom (); - if (l.main_part_) - { - first = false; - last = here; - here += l; - } - else if(l.grace_mom_ && !first) + Moment s = mus->start_mom (); + + if (s.grace_part_ && last >= Moment (0)) { - assert (!l.main_part_); Grace_skip *p =new Grace_skip; p->start_ = last; p->length_ = (here - last).main_part_; - p->grace_length_ = l.grace_mom_; + p->grace_start_ = s.grace_part_; p->next_ = 0; *tail = p; tail = &(*tail)->next_; } + + if (l.main_part_) + { + l.grace_part_ = Rational (0); + last = here; + here += l; + } } return head; } @@ -123,24 +121,31 @@ Sequential_music_iterator::next_element () Moment len =iter_p_->music_length_mom (); Moment start = iter_p_->music_start_mom (); assert (!grace_skips_ || grace_skips_->start_ >= here_mom_); - + if (len.main_part_ && grace_skips_ && grace_skips_->start_ == here_mom_) { Moment sk; sk.main_part_ = grace_skips_->length_; here_mom_ += sk; - here_mom_.grace_mom_ = - grace_skips_->grace_length_; + here_mom_.grace_part_ = grace_skips_->grace_start_; Grace_skip * n =grace_skips_->next_; - delete grace_skips_; + delete grace_skips_; grace_skips_ = n; } - else if (len.grace_mom_) + else if (len.grace_part_ && !len.main_part_) { - here_mom_.grace_mom_ =0; + here_mom_.grace_part_ =0; } else { + /* + !len.grace_part_ || len.main_part_ + + We skip over a big chunk (mainpart != 0). Any starting graces + in that chunk are compensated by subtracting START. + + */ here_mom_ += len - start; } @@ -157,7 +162,6 @@ Sequential_music_iterator::next_element () move to context of child iterator if it is deeper down in the hierarchy. */ - void Sequential_music_iterator::descend_to_child () { @@ -254,7 +258,7 @@ Sequential_music_iterator::process (Moment until) do the stuff/note/rest preceding a grace. */ Moment u = until; - u.grace_mom_ = 0; + u.grace_part_ = 0; iter_p_->process (u - here_mom_); } else @@ -279,16 +283,22 @@ Sequential_music_iterator::pending_moment () const { Moment cp = iter_p_->pending_moment (); - if (grace_skips_ - && here_mom_ == grace_skips_->start_ + /* + Fix-up a grace note halfway in the music. + */ + if (grace_skips_ && here_mom_ == grace_skips_->start_ && cp.main_part_ >= grace_skips_->length_) { - cp += here_mom_ ; - cp.grace_mom_ = - grace_skips_->grace_length_; - return cp; + cp += here_mom_ ; + cp.grace_part_ = grace_skips_->grace_start_; + return cp; + } - else - return cp + here_mom_ - iter_p_->music_start_mom (); + + /* + Fix-up a grace note at the start of the music. + */ + return cp + here_mom_ - iter_p_->music_start_mom (); } diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index e69de29bb2..636757b94d 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -0,0 +1,616 @@ +/* + spacing-spanner.cc -- implement Spacing_spanner + + source file of the GNU LilyPond music typesetter + + (c) 1999--2001 Han-Wen Nienhuys + + */ + +#include "spacing-spanner.hh" +#include "paper-column.hh" +#include "dimensions.hh" +#include "paper-def.hh" +#include "warn.hh" +#include "paper-score.hh" +#include "line-of-score.hh" +#include "misc.hh" + +void +Spacing_spanner::set_interface (Grob*me) +{ + me->set_extent_callback (SCM_EOL, X_AXIS); + me->set_extent_callback (SCM_EOL, Y_AXIS) ; +} + +#if 0 +struct Note_run +{ + Array idxes; + int start, end; + Moment duration; + int count; +}; + +int +column_compare (Grob *const &t1, Grob *const &t2) +{ + return Moment::compare (Paper_column::when_mom (t1), + Paper_column::when_mom (t2)); +} + + +Note_run +run_length (Moment dt, int i, Array const &moms, + Link_array runs) +{ + int k = 0; + Array idxes; + + idxes.push (i); + while (1) + { + Moment next = moms[i] + dt; + while (i < moms.size () && moms[i] < next) + i++; + if (i == moms.size () || moms[i] != next) + break; + + idxes.push (i); + k++; + } + + Moment dur = idxes.size () +} + +void +find_runs (Grob*me, Link_array cols) +{ + Link_array filter_cols; + Array col_moments; + for (int i = 0; i < cols.size (); i++) + { + Moment w = Paper_column::when_mom (cols[i]); + + if (!w.grace_part_ && Paper_column::musical_b (cols[i])) + { + filter_cols.push (cols[i]); + col_moments.push (w); + } + } + + Moment end_mom = col_moments.top (); + for (int i = 0; i < col_moments.size () ; i++) + { + for (int j = i+1; j < col_moments.size (); j++) + { + Moment dt = Paper_column::col_momentsfilter_cols + } + } +} +#endif + +/* + + The algorithm is partly taken from : + + John S. Gourlay. ``Spacing a Line of Music,'' Technical Report + OSU-CISRC-10/87-TR35, Department of Computer and Information + Science, The Ohio State University, 1987. + + TOO HAIRY. + + TODO: write comments + + */ +void +Spacing_spanner::do_measure (Grob*me, Link_array const & cols) +{ + Moment shortest; + Moment mean_shortest; + + /* + space as if this duration is present. + */ + Moment base_shortest_duration = *unsmob_moment (me->get_grob_property ("maximum-duration-for-spacing")); + shortest.set_infinite (1); + + int n = 0; + for (int i =0 ; i < cols.size (); i++) + { + if (Paper_column::musical_b (cols[i])) + { + Moment *when = unsmob_moment (cols[i]->get_grob_property ("when")); + + /* + ignore grace notes for shortest notes. + */ + if (when && when->grace_part_) + continue; + + SCM st = cols[i]->get_grob_property ("shortest-starter-duration"); + Moment this_shortest = *unsmob_moment (st); + shortest = shortest springs; + for (int i= 0; i < cols.size () - 1; i++) + { + Item * l = dynamic_cast (cols[i]); + Item * r = dynamic_cast (cols[i+1]); + Item * lb = dynamic_cast (l->find_prebroken_piece (RIGHT)); + Item * rb = dynamic_cast (r->find_prebroken_piece (LEFT)); + + Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}}; + + + /* + left refers to the space that is associated with items of the left column, so you have + + LC <- left_space -><- right_space -> RC + <- total space -> + + + typically, right_space is non-zero when there are + accidentals in RC + + */ + for (int j=0; j < 4; j++) + { + Paper_column * lc = dynamic_cast (combinations[j][0]); + Paper_column *rc = dynamic_cast (combinations[j][1]); + if (!lc || !rc) + continue; + + Spring s; + s.item_l_drul_[LEFT] = lc; + s.item_l_drul_[RIGHT] = rc; + + SCM hint = lc->get_grob_property ("extra-space"); + SCM next_hint = rc->get_grob_property ("extra-space"); + SCM stretch_hint = lc->get_grob_property ("stretch-distance"); + SCM next_stretch_hint = rc->get_grob_property ("stretch-distance"); + + Real left_distance = 0; + if (gh_pair_p (hint)) + { + left_distance = gh_scm2double (gh_cdr (hint)); + } + // 2nd condition should be (i+1 < col_count ()), ie. not the last column in score. FIXME + else if (!Paper_column::musical_b (lc) && i+1 < cols.size ()) + { + left_distance= default_bar_spacing (me,lc,rc,shortest get_grob_property ("space-factor"); + if (gh_number_p (lc->get_grob_property ("column-space-strength")) + && (Item::breakable_b (lc) || lc->original_l_)) + { + s.strength_f_ = + gh_scm2double (lc->get_grob_property ("column-space-strength")); + } + else if (gh_number_p (sfac)) + left_distance *= gh_scm2double (sfac); + + + Real right_dist = 0.0; + if (gh_pair_p (next_hint)) + { + right_dist += - gh_scm2double (gh_car (next_hint)); + } + else + { + Interval ext (rc->extent (rc, X_AXIS)); + right_dist = ext.empty_b () ? 0.0 : - ext [LEFT]; + } + + /* + don't want to create too much extra space for accidentals + */ + if (Paper_column::musical_b (rc)) + { + if (to_boolean (rc->get_grob_property ("contains-grace"))) + right_dist *= gh_scm2double (rc->get_grob_property ("before-grace-spacing-factor")); // fixme. + else + right_dist *= gh_scm2double (lc->get_grob_property ("before-musical-spacing-factor")); + } + + s.distance_f_ = left_distance + right_dist; + + Real stretch_dist = 0.; + if (gh_number_p (stretch_hint)) + stretch_dist += gh_scm2double (stretch_hint); + else + stretch_dist += left_distance; + + if (gh_pair_p (next_stretch_hint)) + // see regtest spacing-tight + stretch_dist += - gh_scm2double (gh_car (next_stretch_hint)); + else + stretch_dist += right_dist; + + if (s.distance_f_ <0) + { + programming_error ("Negative dist, setting to 1.0 PT"); + s.distance_f_ = 1.0; + } + if (stretch_dist == 0.0) + { + /* + \bar "". We give it 0 space, with high strength. + */ + s.strength_f_ = 20.0; + } + else + s.strength_f_ /= stretch_dist; + + springs.push (s); + } + } + + Spacing_spanner::stretch_to_regularity (me, &springs, cols); + for (int i=springs.size (); i --;) + springs[i].add_to_cols (); +} + +/* + Look at COLS, searching for columns that have 'regular-distance-to + set. A sequence of columns that have this property set should have + an equal distance (an equispaced run). Extract the projected + distance from SPRINGS, and scale SPRINGS for the equispaced run, to the + widest space necessary. + + + TODO: + + -- inefficient code; maybe it is easier to twiddle with the springs + after they've become grob properties (ie. have their + minimum-distances set) + + -- does not adjust strength field of the springs very well: result + awkward spacing at the start of a line. (?) + + -- will be confused when there are multiple equispaced runs in a measure. + + -- dealing with springs for line breaks is a little tricky; in any + case, we will only space per measure. + + -- we scale to actual distances, not to optical effects. Eg. if the + equispaced run contains optical corrections, then the scaling will + cancel those. + + -- Regular_spacing_engraver doesn't mark the first column of the + next bar, making the space before a barline too short, in this case + + + x<- 16ths--> x(8th) + x(8th) x(8th) <- equispaced run. + +*/ + +void +Spacing_spanner::stretch_to_regularity (Grob *me, + Array * springs, + Link_array const & cols) +{ + /* + Find the starting column of the run. REGULAR-DISTANCE-TO points + back to a previous column, so we look ahead to find a column + pointing back to the first one. + + */ + Grob * first_regular_spaced_col = 0; + for (int i = 0 ; i < cols.size () && !first_regular_spaced_col; i++) + { + SCM rdt = cols[i]->get_grob_property ("regular-distance-to"); + if (cols.find_l (unsmob_grob (rdt))) + first_regular_spaced_col = unsmob_grob (rdt); + } + for (int i = springs->size (); i-- ;) + springs->elem (i).set_to_cols (); + + int i; + for (i = 0; i < springs->size () + && springs->elem (i).item_l_drul_[RIGHT] != first_regular_spaced_col; + i++) + ; + + + if (i==springs->size ()) + return ; + + Real maxdist = 0.0; + Real dist =0.0; + Grob *last_col = first_regular_spaced_col; + Grob *last_regular_spaced_col = first_regular_spaced_col; + + + /* + find the max distance for this run. + */ + for (int j = i; j < springs->size (); j++) + { + Spring *s = &(springs->elem_ref (j)); + if (s->item_l_drul_[LEFT] != last_col) + continue; + + dist += s->distance_f_; + + last_col = s->item_l_drul_[RIGHT]; + SCM rdt = last_col->get_grob_property ("regular-distance-to"); + if (unsmob_grob (rdt) == last_regular_spaced_col) + { + maxdist = maxdist >? dist; + dist = 0.0; + last_regular_spaced_col = last_col; + } + + } + + /* + Scale the springs + */ + dist =0.0; + last_col = first_regular_spaced_col; + last_regular_spaced_col = first_regular_spaced_col; + for (int j = i; j < springs->size (); j++) + { + Spring *s = &springs->elem_ref (j); + if (s->item_l_drul_[LEFT] != last_col) + continue; + dist += s->distance_f_; + + last_col = s->item_l_drul_[RIGHT]; + SCM rdt = last_col->get_grob_property ("regular-distance-to"); + if (unsmob_grob (rdt) == last_regular_spaced_col) + { + do { + springs->elem_ref (i).distance_f_ *= maxdist / dist; + springs->elem_ref (i).strength_f_ *= dist / maxdist; + } while (i++ < j); + last_regular_spaced_col = last_col; + dist =0.0; + } + } +} + +/** + Do something if breakable column has no spacing hints set. + */ +Real +Spacing_spanner::default_bar_spacing (Grob*me, Grob *lc, Grob *rc, + Moment shortest) +{ + Real symbol_distance = lc->extent (lc,X_AXIS)[RIGHT] ; + Real durational_distance = 0; + Moment delta_t = Paper_column::when_mom (rc) - Paper_column::when_mom (lc); + + /* + ugh should use shortest_playing distance + */ + if (delta_t) + { + durational_distance = get_duration_space (me, delta_t, shortest); + } + + return symbol_distance >? durational_distance; +} + + +/** + Get the measure wide ant for arithmetic spacing. + + @see + John S. Gourlay. ``Spacing a Line of Music,'' Technical Report + OSU-CISRC-10/87-TR35, Department of Computer and Information Science, + The Ohio State University, 1987. + + */ +Real +Spacing_spanner::get_duration_space (Grob*me, Moment d, Moment shortest) +{ + Real log = log_2 (shortest); + Real k = gh_scm2double (me->get_grob_property ("arithmetic-basicspace")) + - log; + + return (log_2 (d) + k) * gh_scm2double (me->get_grob_property ("arithmetic-multiplier")); +} + + +Real +Spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, + Moment shortest) +{ + Moment shortest_playing_len = 0; + SCM s = lc->get_grob_property ("shortest-playing-duration"); + + // SCM s = lc->get_grob_property ("mean-playing-duration"); + if (unsmob_moment (s)) + shortest_playing_len = *unsmob_moment (s); + + if (! shortest_playing_len) + { + programming_error ("can't find a ruling note at " + Paper_column::when_mom (lc).str ()); + shortest_playing_len = 1; + } + + if (! shortest) + { + programming_error ("no minimum in measure at " + Paper_column::when_mom (lc).str ()); + shortest = 1; + } + Moment delta_t = Paper_column::when_mom (rc) - Paper_column::when_mom (lc); + Real dist = get_duration_space (me, shortest_playing_len, shortest); + + + /* + ugh: 0.1 is an arbitrary distance. + */ + dist *= (double) (delta_t.main_part_ / shortest_playing_len.main_part_) + + 0.1 * (double) (delta_t.grace_part_ / shortest_playing_len.main_part_); + + + + /* + UGH: KLUDGE! + */ + + if (delta_t > Moment (1,32)) + dist += stem_dir_correction (me, lc,rc); + + + Moment *lm = unsmob_moment (lc->get_grob_property ("when")); + Moment *rm = unsmob_moment (rc->get_grob_property ("when")); + + if (lm && rm) + { + if (lm->grace_part_ && rm->grace_part_) + dist *= 0.5; + else if (!rm->grace_part_ && lm->grace_part_) + dist *= 0.7; + } + + + return dist; +} + + +/** + Correct for optical illusions. See [Wanske] p. 138. The combination + up-stem + down-stem should get extra space, the combination + down-stem + up-stem less. + + This should be more advanced, since relative heights of the note + heads also influence required correction. + + Also might not work correctly in case of multi voices or staff + changing voices + + TODO: lookup correction distances? More advanced correction? + Possibly turn this off? + + TODO: have to check wether the stems are in the same staff. + + This routine reads the DIR-LIST property of both its L and R arguments. */ +Real +Spacing_spanner::stem_dir_correction (Grob*me, Grob*l, Grob*r) +{ + SCM dl = l->get_grob_property ("dir-list"); + SCM dr = r->get_grob_property ("dir-list"); + + if (scm_ilength (dl) != 1 || scm_ilength (dr) != 1) + return 0.; + + dl = gh_car (dl); + dr = gh_car (dr); + + assert (gh_number_p (dl) && gh_number_p (dr)); + int d1 = gh_scm2int (dl); + int d2 = gh_scm2int (dr); + + if (d1 == d2) + return 0.0; + + + Real correction = 0.0; + Real ssc = gh_scm2double (me->get_grob_property ("stem-spacing-correction")); + + if (d1 && d2 && d1 * d2 == -1) + { + correction = d1 * ssc; + } + else + programming_error ("Stem directions not set correctly for optical correction"); + return correction; +} + + +MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs,1); +SCM +Spacing_spanner::set_springs (SCM smob) +{ + Grob *me = unsmob_grob (smob); + Link_array all (me->pscore_l_->line_l_->column_l_arr ()) ; + + int j = 0; + + for (int i = 1; i < all.size (); i++) + { + Grob *sc = all[i]; + if (Item::breakable_b (sc)) + { + Link_array measure (all.slice (j, i+1)); + do_measure (me, measure); + j = i; + } + } + + /* + farewell, cruel world + */ + me->suicide (); + return SCM_UNSPECIFIED; +} + + + +/* + maximum-duration-for-spacing +From: bf250@freenet.carleton.ca (John Sankey) +To: gnu-music-discuss@gnu.org +Subject: note spacing suggestion +Date: Mon, 10 Jul 2000 11:28:03 -0400 (EDT) + +Currently, Lily spaces notes by starting with a basic distance, +arithmetic_multiplier, which it applies to the minimum duration note +of the bar. Then she adds a logarithmic increment, scaled from +arithmetic_basicspace, for longer notes. (Then, columns are aligned +and justified.) Fundamentally, this matches visual spacing to musical +weight and works well. + +A lot of the time in music, I see a section basically in melodic +notes that occasionally has a rapid ornamental run (scale). So, there +will be a section in 1/4 notes, then a brief passage in 1/32nds, then +a return to long notes. Currently, Lily gives the same horizontal +space to the 1/32nd notes in their bar (even if set in small size as +is commonly done for cadenzii) as she gives to 1/4 notes in bars +where 1/4 note is the minimum duration. The resulting visual weight +does not match the musical weight over the page. + +Looking at the music I am typesetting, I feel that Lily's spacing +could be significantly improved if, with no change in the basic +method used, arithmetic_multiplier could be applied referred to the +same duration throughout a piece. Of course, the current method +should be retained for those who have already set music in it, so I +suggest a property called something like arithmetic_base=16 to fix +1/16 duration as the reference for arithmetic_multiplier; the default +would be a dynamic base is it is now. + +Does anyone else feel that this would be a useful improvement for +their music? (Of course, if arithmetic_multiplier became a regular +property, this could be used to achieve a similar result by +tweaking.) + + */ diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index c8ec356f52..729a926b01 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -381,7 +381,9 @@ ScoreContext = \translator { keyAccidentalOrder = #'( (6 . -1) (2 . -1) (5 . -1 ) (1 . -1) (4 . -1) (0 . -1) (3 . -1) (3 . 1) (0 . 1) (4 . 1) (1 . 1) (5 . 1) (2 . 1) (6 . 1) - ) + (6 . -2) (2 . -2) (5 . -2 ) (1 . -2) (4 . -2) (0 . -2) (3 . -2) + (3 . 2) (0 . 2) (4 . 2) (2 . 2) (5 . 2) (2 . 2) (6 . 2) + ) breakAlignOrder = #'( Instrument_name Left_edge_item diff --git a/ly/grace-init.ly b/ly/grace-init.ly index 92e9c30c2f..b9a895cdc4 100644 --- a/ly/grace-init.ly +++ b/ly/grace-init.ly @@ -18,8 +18,11 @@ startGraceMusic = { \property Voice.Beam \override #'space-function = #grace-beam-space-function \property Voice.Beam \override #'thickness = #0.3 - % must use staff. Accidentals should also be smaller. - \property Staff.fontSize = #-2 + % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will + % be smaller as well. + + \property Voice.fontSize = #-2 + \property Staff.LocalKeyItem \override #'font-relative-size = #-2 } stopGraceMusic = { @@ -34,5 +37,9 @@ stopGraceMusic = { \property Voice.Stem \revert #'length \property Voice.Stem \revert #'direction - \property Staff.fontSize \unset + % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will + % be smaller as well. + + \property Voice.fontSize \unset + \property Staff.LocalKeyItem \revert #'font-relative-size } diff --git a/make/out/lilypond.lsm b/make/out/lilypond.lsm index 59caa945c2..6a6618c207 100644 --- a/make/out/lilypond.lsm +++ b/make/out/lilypond.lsm @@ -1,15 +1,15 @@ Begin3 Title: LilyPond -Version: 1.5.3 -Entered-date: 29JUL01 +Version: 1.5.4 +Entered-date: 06AUG01 Description: @BLURB@ Keywords: music notation typesetting midi fonts engraving Author: hanwen@cs.uu.nl (Han-Wen Nienhuys) janneke@gnu.org (Jan Nieuwenhuizen) Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys) Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert - 1000k lilypond-1.5.3.tar.gz + 1000k lilypond-1.5.4.tar.gz Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/ - 1000k lilypond-1.5.3.tar.gz + 1000k lilypond-1.5.4.tar.gz Copying-policy: GPL End diff --git a/make/out/lilypond.redhat.spec b/make/out/lilypond.redhat.spec index d703e0339f..1aaf025a8d 100644 --- a/make/out/lilypond.redhat.spec +++ b/make/out/lilypond.redhat.spec @@ -1,11 +1,11 @@ %define info yes Name: lilypond -Version: 1.5.3 +Version: 1.5.4 Release: 1 License: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.3.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.4.tar.gz Summary: Create and print music notation URL: http://www.cs.uu.nl/~hanwen/lilypond BuildRoot: /tmp/lilypond-install diff --git a/make/out/lilypond.suse.spec b/make/out/lilypond.suse.spec index 4ee22f615f..60b01fe3c3 100644 --- a/make/out/lilypond.suse.spec +++ b/make/out/lilypond.suse.spec @@ -14,11 +14,11 @@ Distribution: SuSE Linux 7.0 (i386) Name: lilypond -Version: 1.5.3 +Version: 1.5.4 Release: 2 Copyright: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.3.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.5.4.tar.gz # music notation software for.. ? Summary: A program for printing sheet music. URL: http://www.lilypond.org/ diff --git a/midi2ly/lilypond-item.cc b/midi2ly/lilypond-item.cc index 4c3830a637..977f44e70e 100644 --- a/midi2ly/lilypond-item.cc +++ b/midi2ly/lilypond-item.cc @@ -311,7 +311,7 @@ Lilypond_skip::str () return ""; String str = "\\skip "; - str += Duration_convert::dur2_str (dur) + "; "; + str += Duration_convert::dur2_str (dur); return str; } diff --git a/midi2ly/lilypond-stream.cc b/midi2ly/lilypond-stream.cc index aee29cef2b..1f476649a6 100644 --- a/midi2ly/lilypond-stream.cc +++ b/midi2ly/lilypond-stream.cc @@ -100,7 +100,7 @@ Lilypond_stream::header() *os_p_ << filename_str_g; *os_p_ << "\n\n"; // ugh - *os_p_ << "\\version \"1.4.0\";\n"; + *os_p_ << "\\version \"1.4.0\"\n"; } void diff --git a/scripts/etf2ly.py b/scripts/etf2ly.py index 1c9487df19..7b902765f2 100644 --- a/scripts/etf2ly.py +++ b/scripts/etf2ly.py @@ -174,16 +174,7 @@ def lily_notename (tuple2): (n, a) = tuple2 nn = chr ((n+ 2)%7 + ord ('a')) - if a == -1: - nn = nn + 'es' - elif a == -2: - nn = nn + 'eses' - elif a == 1: - nn = nn + 'is' - elif a == 2: - nn = nn + 'isis' - - return nn + return nn + {-2:'eses', -1:'es', 0:'', 1:'is', 2:'isis'}[a] class Tuplet: @@ -729,6 +720,10 @@ Add None to LIST until it contains entry number NO. return list def read_finale_value (str): + """ +Pry off one value from STR. The value may be $hex, decimal, or "string". +Return: (value, rest-of-STR) + """ while str and str[0] in ' \t\n': str = str[1:] diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index 1e9a7329b3..63ded478b5 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -538,7 +538,8 @@ lily output file in TFILES after that, and return the Latex file constructed. ' ''' if extra['pagenumber'] and extra['pagenumber'][-1] and extra['pagenumber'][-1] != 'no': - s = s + '\\pagestyle{plain}\n' + s = s + '\setcounter{page}{%s}\n' % (extra['pagenumber'][-1]) + s = s + '\\pagestyle{plain}\n' else: s = s + '\\pagestyle{empty}\n' -- 2.39.2