From 2d7c1ac162602922361690360bc3cfebf11fc8b8 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 21:44:34 +0000 Subject: [PATCH] lilypond-1.1.7 --- NEWS | 17 ++++ VERSION | 2 +- init/engraver.ly | 3 + init/lily.scm | 26 ++++-- input/test/repeat.fly | 1 + lily/include/lookup.hh | 1 + lily/include/repeat-engraver.hh | 42 ++++++++++ lily/include/volta-spanner.hh | 37 +++++++++ lily/lookup.cc | 20 ++++- lily/repeat-engraver.cc | 140 ++++++++++++++++++++++++++++++++ lily/repeated-music-iterator.cc | 91 +++++++++++++++++++++ lily/volta-spanner.cc | 82 +++++++++++++++++++ mf/cmr10.afm.in | 2 +- ps/lily.ps | 19 ++++- tex/lily-ps-defs.tex | 1 + 15 files changed, 468 insertions(+), 16 deletions(-) create mode 100644 input/test/repeat.fly create mode 100644 lily/include/repeat-engraver.hh create mode 100644 lily/include/volta-spanner.hh create mode 100644 lily/repeat-engraver.cc create mode 100644 lily/repeated-music-iterator.cc create mode 100644 lily/volta-spanner.cc diff --git a/NEWS b/NEWS index b340ce878b..129bd32d4f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,21 @@ +pl6.jcn5 + - repeatbars, volta-spanner work, alternative iteration still broken + - volta symbol + +pl5.szmulewicz2 + - more GUILE stuff. + - tutorial doco updates + +pl6.jcn4 + - volta-spanner + - repeat-engraver + - repeat/alternative music layout (hehe) + +pl6.uu1 + - Doco of music iterators. +******** +pl 6 pl5.szmulewicz1 - rtti stuff diff --git a/VERSION b/VERSION index 9fa405bb94..af5d5f0449 100644 --- a/VERSION +++ b/VERSION @@ -1,7 +1,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 -PATCH_LEVEL=6 +PATCH_LEVEL=7 MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a diff --git a/init/engraver.ly b/init/engraver.ly index 48c0145b5b..c34f9df8f3 100644 --- a/init/engraver.ly +++ b/init/engraver.ly @@ -20,6 +20,7 @@ StaffContext=\translator { \consists "Key_engraver"; \consists "Local_key_engraver"; \consists "Time_signature_engraver"; + \consists "Repeat_engraver"; \consists "Staff_symbol_engraver"; \consists "Collision_engraver"; \consists "Rest_collision_engraver"; @@ -76,6 +77,7 @@ RhythmicStaffContext=\translator{ \consists "Separating_line_group_engraver"; \name RhythmicStaff; \consists "Bar_engraver"; + \consists "Repeat_engraver"; \consists "Time_signature_engraver"; \consists "Staff_symbol_engraver"; \accepts "Voice"; @@ -206,6 +208,7 @@ HaraKiriStaffContext = \translator { \consists "Bar_engraver"; \consists "Clef_engraver"; + \consists "Repeat_engraver"; \consists "Key_engraver"; \consists "Time_signature_engraver"; \consists "Local_key_engraver"; diff --git a/init/lily.scm b/init/lily.scm index e045426a26..f813358ede 100644 --- a/init/lily.scm +++ b/init/lily.scm @@ -43,9 +43,9 @@ (string-append (number->string (cadr c)) " "))) ;;;;;;;; TeX -; (define (tex action) +;(define (tex action) -(define +(define (beam-tex width slope thick) (embedded-ps-tex (beam-ps width slope thick))) @@ -169,7 +169,14 @@ (text-tex f s) (string-append "\\set" f "{" s "}")) +(define + (tuplet-tex dx dy dir) + (embedded-ps-tex (tuplet-ps dx dy dir))) + +(define + (volta-tex w last) + (embedded-ps-tex (volta-ps w last))) ;;;;;;;;;;;; PS @@ -289,6 +296,12 @@ (string-append "(" s ") set" f " ")) +(define + (volta-ps w last) + (string-append + (numbers->string (list w (inexact->exact last))) + "draw_volta")) + ;;; output definitions (define @@ -454,10 +467,6 @@ (numbers->string (list dx dy (inexact->exact dir))) "draw_tuplet")) -(define - (tuplet-tex dx dy dir) - (embedded-ps-tex (tuplet-ps dx dy dir))) - (define (stem o kern width height depth) ((invoke-output o "stem") kern width height depth)) @@ -476,14 +485,15 @@ (startrepeat o h) ((invoke-output o "invoke-dim1") "startrepeat" h)) - (define (stop-line o) ((invoke-output o "stop-line"))) - (define (stoprepeat o h) ((invoke-output o "invoke-dim1") "stoprepeat" h)) +(define + (volta o w last) + ((invoke-output o "volta") w last)) diff --git a/input/test/repeat.fly b/input/test/repeat.fly new file mode 100644 index 0000000000..d96792051a --- /dev/null +++ b/input/test/repeat.fly @@ -0,0 +1 @@ +a b c d \repeat 2 { { c c c c d d d d } } \alternative { { e e e e } { e e e g } } c c c c c c c c diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 5b5685a40c..e236e56f66 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -55,6 +55,7 @@ public: Atom text (String style, String text) const; Atom vbrace (Real &dy) const; Atom vbracket (Real &dy) const; + Atom volta (Real w, bool last_b) const; Atom special_time_signature (String, Array) const; Atom time_signature (Array) const; diff --git a/lily/include/repeat-engraver.hh b/lily/include/repeat-engraver.hh new file mode 100644 index 0000000000..e3d6f9ef3a --- /dev/null +++ b/lily/include/repeat-engraver.hh @@ -0,0 +1,42 @@ +/* + repeat-engraver.hh -- declare Repeat_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef REPEAT_ENGRAVER_HH +#define REPEAT_ENGRAVER_HH + +#include "engraver.hh" + +/** + Generate repeat-bars |: :| for repeated-music + */ +class Repeat_engraver : public Engraver +{ +public: + Repeat_engraver (); + VIRTUAL_COPY_CONS(Translator); + +protected: + virtual void acknowledge_element (Score_element_info i); + virtual void do_removal_processing (); + virtual bool do_try_music (Music *req_l); + virtual void do_process_requests(); + virtual void do_pre_move_processing(); + virtual void do_post_move_processing(); + +private: + Link_array repeated_music_arr_; + Link_array alternative_music_arr_; + Link_array bar_p_arr_; + Link_array volta_p_arr_; + Array stop_mom_arr_; + Array alternative_start_mom_arr_; + Array alternative_stop_mom_arr_; +}; + +#endif // REPEAT_ENGRAVER_HH + diff --git a/lily/include/volta-spanner.hh b/lily/include/volta-spanner.hh new file mode 100644 index 0000000000..18fd91a939 --- /dev/null +++ b/lily/include/volta-spanner.hh @@ -0,0 +1,37 @@ +/* + volta-spanner.hh -- part of GNU LilyPond + + (c) 1997--1998 Jan Nieuwenhuizen +*/ + +#ifndef VOLTA_SPANNER_HH +#define VOLTA_SPANNER_HH + +#include "text-def.hh" +#include "pointer.hh" +#include "directional-spanner.hh" + +/** Volta bracket with number */ + +class Volta_spanner : public Directional_spanner +{ +public: + Volta_spanner (); + + void add_column (Note_column*); + + P tdef_p_; + Link_array column_arr_; + bool last_b_; + +protected: + virtual Molecule* brew_molecule_p () const; + VIRTUAL_COPY_CONS(Score_element); + + virtual void do_add_processing (); + virtual void do_post_processing (); + virtual void do_substitute_dependency (Score_element*,Score_element*); +}; + +#endif // VOLTA_SPANNER_HH + diff --git a/lily/lookup.cc b/lily/lookup.cc index e579ca8231..1c3d1c7145 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -181,8 +181,8 @@ Lookup::dashed_slur (Array controls, Real thick, Real dash) const // (lambda (o) (dashed-slur o thick dash '(stuff)) a.lambda_ = - ly_append (ly_lambda_o (), - gh_list (ly_append (ly_func_o ("dashed-slur"), + gh_append2 (ly_lambda_o (), + gh_list (gh_append2 (ly_func_o ("dashed-slur"), gh_cons (gh_double2scm (thick), gh_cons (gh_double2scm (dash), gh_list (ly_quote_scm (gh_list (sc[1], sc[2], sc[3], sc[0], SCM_UNDEFINED)), SCM_UNDEFINED)))), SCM_UNDEFINED)); @@ -380,9 +380,10 @@ Lookup::text (String style, String text) const ; else { - if (afm_p) + int c = text[i]; + if (afm_p && ((c >= 0) && (c < afm_p->char_metrics_.size ()))) { - Adobe_font_char_metric m = afm_p->char_metrics_[(int)text[i]]; + Adobe_font_char_metric m = afm_p->char_metrics_[c]; w += m.B_.x ().length (); DOUT << to_str (m.B_.x ().length ()) << " "; } @@ -537,4 +538,15 @@ Lookup::vbracket (Real &y) const return a; } +Atom +Lookup::volta (Real w, bool last_b) const +{ + Array arr; + arr.push (w); + arr.push (last_b); + Atom a; + a.lambda_ = (lambda_scm ("volta", arr)); + a.str_ = "volta"; + return a; +} diff --git a/lily/repeat-engraver.cc b/lily/repeat-engraver.cc new file mode 100644 index 0000000000..110169fa37 --- /dev/null +++ b/lily/repeat-engraver.cc @@ -0,0 +1,140 @@ +/* + repeat-engraver.cc -- implement Repeat_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "repeat-engraver.hh" +#include "bar.hh" +#include "musical-request.hh" +#include "multi-measure-rest.hh" +#include "command-request.hh" +#include "time-description.hh" +#include "engraver-group.hh" +#include "repeated-music.hh" +#include "time-description.hh" +#include "volta-spanner.hh" +#include "note-column.hh" + +ADD_THIS_TRANSLATOR (Repeat_engraver); + +Repeat_engraver::Repeat_engraver () +{ +} + +bool +Repeat_engraver::do_try_music (Music* m) +{ + if (Repeated_music* r = dynamic_cast (m)) + { + repeated_music_arr_.push (r); + stop_mom_arr_.push (now_moment () + r->duration ()); + // urg, something broken with alternative time... + //Moment alt_mom = now_moment () + r->repeat_p_->duration (); + Moment alt_mom = now_moment (); + for (PCursor i (r->alternative_p_->music_p_list_p_->top ()); i.ok (); i++) + { + alternative_music_arr_.push (i.ptr ()); + alternative_start_mom_arr_.push (alt_mom); + // urg, something broken with alternative time... + // alt_mom += i->duration (); + alt_mom += Moment (1); + alternative_stop_mom_arr_.push (alt_mom); + } + return true; + } + return false; +} + +void +Repeat_engraver::acknowledge_element (Score_element_info i) +{ + Moment now = now_moment (); + if (Note_column *nc = dynamic_cast (i.elem_l_)) + { + for (int i = 0; i < volta_p_arr_.size (); i++) + if ((now >= alternative_start_mom_arr_[i]) && volta_p_arr_[i]) + volta_p_arr_[i]->add_column (nc); + } +} + +void +Repeat_engraver::do_removal_processing () +{ + for (int i = 0; i < bar_p_arr_.size (); i++) + if (bar_p_arr_[i]) + typeset_element (bar_p_arr_[i]); + for (int i = 0; i < volta_p_arr_.size (); i++) + if (volta_p_arr_[i]) + typeset_element (volta_p_arr_[i]); +} + +void +Repeat_engraver::do_process_requests () +{ + for (int i = bar_p_arr_.size (); i < repeated_music_arr_.size (); i++) + { + Bar* bar_p = new Bar; + bar_p-> type_str_ = "|:"; + bar_p_arr_.push (bar_p); + announce_element (Score_element_info (bar_p, repeated_music_arr_[i])); + } + int bees = volta_p_arr_.size (); + for (int i = volta_p_arr_.size (); i < alternative_music_arr_.size (); i++) + { + Volta_spanner* v = new Volta_spanner; + if (i == alternative_music_arr_.size () - 1) + v->last_b_ = true; + Text_def* t = new Text_def; + t->text_str_ = to_str (i - bees + 1); + v->tdef_p_.set_p (t); + volta_p_arr_.push (v); + announce_element (Score_element_info (v, alternative_music_arr_[i])); + } +} + +void +Repeat_engraver::do_pre_move_processing () +{ + for (int i = bar_p_arr_.size (); i--; ) + { + if (bar_p_arr_[i]) + { + typeset_element (bar_p_arr_[i]); + bar_p_arr_[i] = 0; + } + } +} + +void +Repeat_engraver::do_post_move_processing () +{ + Moment now = now_moment (); + for (int i = bar_p_arr_.size (); i--; ) + { + if (now >= stop_mom_arr_[i]) + { + Bar* bar_p = new Bar; + bar_p-> type_str_ = ":|"; + typeset_element (bar_p); + bar_p_arr_.del (i); + stop_mom_arr_.del (i); + repeated_music_arr_.del (i); + } + } + for (int i = volta_p_arr_.size (); i--; ) + { + //if (now >= alternative_start_mom_arr_[i]) + if (now >= alternative_stop_mom_arr_[i]) + { + if (volta_p_arr_[i]) + { + typeset_element (volta_p_arr_[i]); + volta_p_arr_[i] = 0; + } + } + } +} + diff --git a/lily/repeated-music-iterator.cc b/lily/repeated-music-iterator.cc new file mode 100644 index 0000000000..66180fda76 --- /dev/null +++ b/lily/repeated-music-iterator.cc @@ -0,0 +1,91 @@ +/* + repeated-music-iterator.cc -- implement Repeated_music_iterator + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen + + */ + +#include "repeated-music-iterator.hh" +#include "repeated-music.hh" +#include "musical-request.hh" +#include "translator-group.hh" +#include "command-request.hh" + +Repeated_music_iterator::Repeated_music_iterator () +{ + repeat_iter_p_ = 0; + alternative_iter_p_ = 0; +} + +Repeated_music_iterator::~Repeated_music_iterator () +{ + delete repeat_iter_p_; + delete alternative_iter_p_; +} + +void +Repeated_music_iterator::do_print () const +{ + if (repeat_iter_p_) repeat_iter_p_->print (); + if (alternative_iter_p_) alternative_iter_p_->print (); +} + +void +Repeated_music_iterator::construct_children () +{ + repeat_iter_p_ = get_iterator_p (repeated_music_l ()->repeat_p_); +} + +void +Repeated_music_iterator::do_process_and_next (Moment m) +{ + if (first_b_) + { + bool success = report_to_l ()->try_music (repeated_music_l ()); + if (!success) + music_l_->warning ( _("No one to print a volta bracket")); + } + if (repeat_iter_p_->ok ()) + repeat_iter_p_->process_and_next (m); + else + { + if (!alternative_iter_p_) + { + delete repeat_iter_p_; + repeat_iter_p_ = 0; + alternative_iter_p_ = dynamic_cast + (get_iterator_p (repeated_music_l ()->alternative_p_)); + } + alternative_iter_p_->process_and_next (m); + } + Music_iterator::do_process_and_next (m); +} + +Moment +Repeated_music_iterator::next_moment () const +{ + if (repeat_iter_p_) + return repeat_iter_p_->next_moment (); + else if (alternative_iter_p_) + return alternative_iter_p_->next_moment (); + return 0; +} + +bool +Repeated_music_iterator::ok () const +{ + if (repeat_iter_p_) + return repeat_iter_p_->ok (); + else if (alternative_iter_p_) + return alternative_iter_p_->ok (); + return false; +} + +Repeated_music* +Repeated_music_iterator::repeated_music_l () const +{ + return (Repeated_music*)Music_iterator::music_l_; +} + diff --git a/lily/volta-spanner.cc b/lily/volta-spanner.cc new file mode 100644 index 0000000000..884f8c9dd2 --- /dev/null +++ b/lily/volta-spanner.cc @@ -0,0 +1,82 @@ +/* + volta-spanner.cc -- implement Volta_spanner + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Jan Nieuwenhuizen +*/ + +#include "atom.hh" +#include "box.hh" +#include "debug.hh" +#include "lookup.hh" +#include "molecule.hh" +#include "note-column.hh" +#include "p-col.hh" +#include "paper-def.hh" +#include "volta-spanner.hh" +#include "stem.hh" +#include "text-def.hh" + +/* + Hmm, should probably make generic Bracket_spanner, + or and derive Plet and volta spanner from that. + */ + +Volta_spanner::Volta_spanner () +{ + dir_ = UP; + last_b_ = false; + tdef_p_.set_p (new Text_def); + tdef_p_->align_dir_ = CENTER; + tdef_p_->style_str_ = "nummer"; +} + +Molecule* +Volta_spanner::brew_molecule_p () const +{ + Molecule* mol_p = new Molecule; + + if (column_arr_.size ()){ + Real w = width ().length (); + Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_] + - column_arr_[0]->extent (Y_AXIS) [dir_]; + + Atom num (tdef_p_->get_atom (paper (), CENTER)); + mol_p->add_atom (num); + mol_p->add_atom (lookup_l ()->volta (w, last_b_)); + } + return mol_p; +} + +void +Volta_spanner::do_add_processing () +{ + if (column_arr_.size ()) + { + set_bounds (LEFT, column_arr_[0]); + set_bounds (RIGHT, column_arr_.top ()); + } +} + +void +Volta_spanner::do_post_processing () +{ + if (column_arr_.size()) + translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS); +} + +void +Volta_spanner::do_substitute_dependency (Score_element* o, Score_element* n) +{ + if (Note_column *onc = dynamic_cast (o)) + column_arr_.substitute (onc, dynamic_cast (n)); +} + +void +Volta_spanner::add_column (Note_column*n) +{ + column_arr_.push (n); + add_dependency (n); +} + diff --git a/mf/cmr10.afm.in b/mf/cmr10.afm.in index df080fdfd3..78a59e7e2b 100644 --- a/mf/cmr10.afm.in +++ b/mf/cmr10.afm.in @@ -25,7 +25,7 @@ C 20; Character-20; B 0.00 0.00 5.24290 6.59002 C 21; Character-21; B 0.00 0.00 5.24290 7.28178 C 22; Character-22; B 0.00 0.00 5.24290 5.95357 C 23; Character-23; B 0.00 0.00 7.86434 7.28178 -C 24; Character-24; B 0.00 0.00 4.66035 0 +C 24; Character-24; B 0.00 0.00 4.66035 0.0 C 25; Character-25; B 0.00 0.00 5.24291 7.28178 C 26; Character-26; B 0.00 0.00 7.57307 4.51470 C 27; Character-27; B 0.00 0.00 8.15562 4.51470 diff --git a/ps/lily.ps b/ps/lily.ps index 32c75a0f25..6ea6920d23 100644 --- a/ps/lily.ps +++ b/ps/lily.ps @@ -16,7 +16,7 @@ closepath fill } bind def -/draw_decrescendo % cont height width +/draw_decrescendo % width height cons { stafflinethickness setlinewidth /cresc_cont exch def @@ -31,7 +31,7 @@ stroke } bind def -/draw_crescendo % cont height width +/draw_crescendo % width height cons { stafflinethickness setlinewidth /cresc_cont exch def @@ -76,6 +76,21 @@ stroke } bind def +/draw_volta % w last +{ + /last exch def + /volta_w exch def + staffheight 2 div /volta_h exch def + volta_t setlinewidth + 0 0 moveto + 0 volta_h lineto + volta_w volta_h lineto + last 0 eq { + volta_w 0 lineto + } if + stroke +} bind def + /draw_slur { stafflinethickness setlinewidth diff --git a/tex/lily-ps-defs.tex b/tex/lily-ps-defs.tex index 93bf012315..7fb1fcfec7 100644 --- a/tex/lily-ps-defs.tex +++ b/tex/lily-ps-defs.tex @@ -82,6 +82,7 @@ bracket_v /bracket_u exch def 50 /bracket_alpha exch def staffheight 4 div /interline exch def stafflinethickness 1.2 mul /tuplet_t exch def +stafflinethickness 1.2 mul /volta_t exch def 1 setlinecap} } -- 2.39.5