From: fred Date: Tue, 26 Mar 2002 21:50:05 +0000 (+0000) Subject: lilypond-1.1.46 X-Git-Tag: release/1.5.59~2425 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=86376605fbc172356d9f94e5008139729730a944;p=lilypond.git lilypond-1.1.46 --- diff --git a/NEWS b/NEWS index 7f62b95684..4b1694fbf5 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,20 @@ -pl 45 (may 28) +pl 45.hwn1 + - Audio broadcast & acknowledge. + - more advanced spacing for prefatory matter + - tuplet appearance tweaking + + +pl 45.uu1 + - glossary fixes (thanks Dirk). + +pl 44.jcn2 + - bf: auto-beamer: long standing br form AM + +********* + +pl 45 (may 28) + - reinstalled Thread (there you are, John) - german vocab. diff --git a/lily/align-element.cc b/lily/align-element.cc index 0e0b5a5605..56011a3fe1 100644 --- a/lily/align-element.cc +++ b/lily/align-element.cc @@ -86,7 +86,6 @@ Align_element::do_pre_processing () void Align_element::do_side_processing () { - sort_elements (); Array dims; Link_array elems; @@ -103,7 +102,7 @@ Align_element::do_side_processing () { extra_dims = SCM_CDR (extra_dims); dims.top ()[LEFT] -= gh_scm2double (SCM_CAR (extra_dims)); - dims.top ()[RIGHT] += gh_scm2double (SCM_CAR (extra_dims)); + dims.top ()[RIGHT] += gh_scm2double (SCM_CDR (extra_dims)); } elems.push (e); diff --git a/lily/audio-item-info.cc b/lily/audio-item-info.cc new file mode 100644 index 0000000000..6ca17ecadf --- /dev/null +++ b/lily/audio-item-info.cc @@ -0,0 +1,26 @@ +/* + Audio-element-info.cc -- implement Audio_element_info + + source file of the GNU LilyPond music typesetter + + (c) 1997--1999 Han-Wen Nienhuys +*/ + +#include "audio-element-info.hh" +#include "request.hh" + +Audio_element_info::Audio_element_info (Audio_element*s_l, Music *r_l) +{ + elem_l_ = s_l; + req_l_ = r_l; +} + + +Audio_element_info::Audio_element_info() +{ + elem_l_ = 0; + req_l_ = 0; +} + + + diff --git a/lily/bar-script-engraver.cc b/lily/bar-script-engraver.cc index a7f59dea8e..2e5a2eb8e1 100644 --- a/lily/bar-script-engraver.cc +++ b/lily/bar-script-engraver.cc @@ -93,7 +93,7 @@ Bar_script_engraver::cast_to_interesting_item (Score_element *e) void Bar_script_engraver::acknowledge_element (Score_element_info inf) { - if (inf.origin_grav_l_arr_.size () == 1) + if (inf.origin_trans_l_arr_.size () == 1) { Item *i=cast_to_interesting_item (inf.elem_l_); if (!i) @@ -102,7 +102,7 @@ Bar_script_engraver::acknowledge_element (Score_element_info inf) /* Only put numbers on bars that are at our own level (don't put numbers over the staffs of a GrandStaff, only over the GrandStaff itself */ - if (inf.origin_grav_l_arr_.size () != 1) + if (inf.origin_trans_l_arr_.size () != 1) return; do_acknowledge_element (i); diff --git a/lily/base-span-bar-engraver.cc b/lily/base-span-bar-engraver.cc index 1616106156..e28362da15 100644 --- a/lily/base-span-bar-engraver.cc +++ b/lily/base-span-bar-engraver.cc @@ -28,7 +28,7 @@ Base_span_bar_engraver::get_span_bar_p() const void Base_span_bar_engraver::acknowledge_element (Score_element_info i) { - int depth = i.origin_grav_l_arr_.size(); + int depth = i.origin_trans_l_arr_.size(); if (depth > 1 && dynamic_cast (i.elem_l_)) { diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index ab9c805824..e8e314a567 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -6,15 +6,63 @@ (c) 1997--1999 Han-Wen Nienhuys */ +#include "lily-guile.hh" #include "break-align-item.hh" #include "dimensions.hh" #include "p-score.hh" +#include "paper-def.hh" void Break_align_item::do_pre_processing() { align_dir_ = break_status_dir(); flip (&align_dir_); + sort_elements (); + + + Link_array elems; + for (int i=0; i < elem_l_arr_.size(); i++) + { + Interval y = elem_l_arr_[i]->extent(axis ()); + if (!y.empty_b()) + elems.push (dynamic_cast (elem_l_arr_[i])); + } + + + if (elems.size ()) + { + Score_element *current_elt =elems[0]; + SCM current_origin = current_elt->get_elt_property (origin_scm_sym); + + if (current_origin != SCM_BOOL_F) + current_origin = SCM_CDR (current_origin); + + for (int i=1; i < elems.size (); i++) + { + Score_element *next_elt = elems[i]; + SCM next_origin = next_elt->get_elt_property (origin_scm_sym); + if (next_origin != SCM_BOOL_F) + { + next_origin = SCM_CDR(next_origin); + SCM extra_space = scm_eval (scm_listify (ly_symbol ("break-align-spacer"), + current_origin, + next_origin, + SCM_UNDEFINED)); + + + Real spc = gh_scm2double (extra_space); + spc *= paper_l ()->get_realvar (interline_scm_sym); + + current_elt->set_elt_property (extra_space_scm_sym, + scm_cons (gh_double2scm (0.0), + gh_double2scm (spc))); + + } + current_elt = next_elt; + current_origin = next_origin; + } + + } Axis_align_item::do_pre_processing(); } @@ -54,8 +102,7 @@ Break_align_item::add_breakable_item (Item *it) warning bells about missing Y refpoints go off later on. */ hg->dim_cache_[Y_AXIS]->parent_l_ = dim_cache_[Y_AXIS]; - hg->set_elt_property (ly_symbol("origin"), - SCM_EOL); + hg->set_elt_property (ly_symbol("origin"), gh_str02scm (it->name())); pscore_l_->typeset_element (hg); add_element_priority (hg, priority); @@ -63,10 +110,12 @@ Break_align_item::add_breakable_item (Item *it) if (priority == 0) center_l_ = hg; } - + + /* hg->set_elt_property (ly_symbol("origin"), scm_cons (gh_str02scm (it->name()), hg->get_elt_property (ly_symbol ("origin")))); + */ hg->add_element (it); diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index 104793dca4..5c35cd74e8 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -50,7 +50,7 @@ Engraver_group_engraver::do_announces() for (int i=0; i < nongroups.size(); i++) { // Is this good enough? Engraver * eng = dynamic_cast (nongroups[i]); - if (eng && eng!= info.origin_grav_l_arr_[0]) + if (eng && eng!= info.origin_trans_l_arr_[0]) eng->acknowledge_element (info); } } @@ -83,10 +83,3 @@ Engraver_group_engraver::get_staff_info() const -Engraver_group_engraver::~Engraver_group_engraver () -{ -} - -Engraver_group_engraver::Engraver_group_engraver () -{ -} diff --git a/lily/engraver.cc b/lily/engraver.cc index fde31b7593..a94d69eedb 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -19,11 +19,10 @@ Engraver::fill_staff_info (Staff_info&) } - void Engraver::announce_element (Score_element_info i) { - i.origin_grav_l_arr_.push (this); + i.origin_trans_l_arr_.push (this); daddy_grav_l()->announce_element (i); } diff --git a/lily/include/align-element.hh b/lily/include/align-element.hh index edc88cab90..6c5689b934 100644 --- a/lily/include/align-element.hh +++ b/lily/include/align-element.hh @@ -25,7 +25,6 @@ */ class Align_element : public virtual Axis_group_element { Hash_table priority_i_hash_; - void sort_elements (); public: Interval threshold_interval_ ; @@ -56,6 +55,7 @@ public: Score_element *get_elt_by_priority (int) const; int get_priority (Score_element*) const; protected: + void sort_elements (); virtual void do_print() const; virtual void do_substitute_element_pointer (Score_element*,Score_element*); virtual void do_post_processing() ; diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh new file mode 100644 index 0000000000..293fff867b --- /dev/null +++ b/lily/include/audio-element-info.hh @@ -0,0 +1,29 @@ +/* + audio-item-info.hh -- declare Audio_item_info + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef AUDIO_ITEM_INFO_HH +#define AUDIO_ITEM_INFO_HH + +#include "lily-proto.hh" +#include "parray.hh" + +/** + Data container for broadcasts + */ +struct Audio_element_info { + Audio_element * elem_l_; + Music *req_l_; + Link_array origin_trans_l_arr_; + + Audio_element_info (Audio_element*, Music*); + Audio_element_info(); +}; + + +#endif diff --git a/lily/include/engraver-group.hh b/lily/include/engraver-group.hh index ec32684831..fdebf2a0cb 100644 --- a/lily/include/engraver-group.hh +++ b/lily/include/engraver-group.hh @@ -28,8 +28,6 @@ protected: Array announce_info_arr_; public: VIRTUAL_COPY_CONS(Translator); - Engraver_group_engraver(); - ~Engraver_group_engraver(); virtual Staff_info get_staff_info() const; virtual void do_announces(); diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index b7eea3d2f5..395b277dd9 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -34,11 +34,12 @@ SCM array_to_list (SCM *a , int l); void read_lily_scm_file (String); -void init_symbols (); +void init_lily_guile (); + #include "ly-symbols.hh" /* - DIY gc protection. + Do It Yourself GC protection. */ SCM ly_protect_scm (SCM s); SCM ly_unprotect_scm (SCM s); diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index d573c8fdcf..3647c56a26 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -22,6 +22,7 @@ struct All_font_metrics; struct Articulation_req; struct Atom; struct Audio_element; +struct Audio_element_info; struct Audio_column; struct Audio_item; struct Audio_key; diff --git a/lily/include/ly-symbols.hh b/lily/include/ly-symbols.hh index dc99b23c71..18135bbf89 100644 --- a/lily/include/ly-symbols.hh +++ b/lily/include/ly-symbols.hh @@ -43,6 +43,7 @@ DECLARE_LY_SYMBOL(molecule); DECLARE_LY_SYMBOL(notewidth); DECLARE_LY_SYMBOL(non_default); DECLARE_LY_SYMBOL(octave_dir); +DECLARE_LY_SYMBOL(origin); DECLARE_LY_SYMBOL(output); DECLARE_LY_SYMBOL(padding); DECLARE_LY_SYMBOL(pianobrace); diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index b8c03cccef..16eb2e8ccb 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -20,7 +20,11 @@ class Performer_group_performer : public Performer, public virtual Translator_group { public: VIRTUAL_COPY_CONS(Translator); - + + virtual void do_announces(); + virtual void announce_element (Audio_element_info); +protected: + Array announce_info_arr_; }; #endif // PERFORMER_GROUP_PERFORMER_HH diff --git a/lily/include/performer.hh b/lily/include/performer.hh index 92b2d77be0..03fea2f259 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -8,7 +8,7 @@ #ifndef PERFORMER_HH #define PERFORMER_HH -#include "lily-proto.hh" +#include "audio-element-info.hh" #include "array.hh" #include "request.hh" #include "score-element-info.hh" @@ -22,12 +22,16 @@ class Performer : public virtual Translator{ public: VIRTUAL_COPY_CONS(Translator); - + friend class Performer_group_performer; Performer_group_performer* daddy_perf_l() const; protected: + virtual void announce_element (Audio_element_info); + virtual void acknowledge_element (Audio_element_info); + virtual void process_acknowledged (); virtual int get_tempo_i() const; virtual void play (Audio_element * elem_p ); }; #endif // PERFORMER_HH + diff --git a/lily/include/score-element-info.hh b/lily/include/score-element-info.hh index 1f22b63e46..b9cd13aa27 100644 --- a/lily/include/score-element-info.hh +++ b/lily/include/score-element-info.hh @@ -10,7 +10,6 @@ #ifndef STAFFELEMINFO_HH #define STAFFELEMINFO_HH -#include "scalar.hh" #include "lily-proto.hh" #include "parray.hh" @@ -20,7 +19,7 @@ struct Score_element_info { Score_element * elem_l_; Music *req_l_; - Link_array origin_grav_l_arr_; + Link_array origin_trans_l_arr_; Score_element_info (Score_element*, Music*); Score_element_info(); diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index bb9996fbd6..a34dc222b0 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -40,10 +40,8 @@ public: String id_str_; - VIRTUAL_COPY_CONS(Translator); - void set_acceptor (String accepts, bool add); void set_element (String elt, bool add); void add_last_element (String elt); @@ -67,7 +65,6 @@ public: void check_removal (); - Translator *get_simple_translator (String) const; Translator_group *find_existing_translator_l (String n, String id); Translator_group *find_create_translator_l (String n, String id); diff --git a/lily/key-item.cc b/lily/key-item.cc index a3b646b0e5..d11424b41e 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -126,14 +126,6 @@ Key_item::do_brew_molecule_p() const output->add_at_edge (X_AXIS, RIGHT, m, 0); } - if (pitch_arr_.size()) - { - Molecule m (lookup_l ()->fill (Box ( - Interval (0, paper_l ()->note_width ()), - Interval (0,0)))); - - output->add_at_edge (X_AXIS, RIGHT, m,0 ); - } return output; } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index bec431671e..46d5908d47 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -121,3 +121,26 @@ array_to_list (SCM *a , int l) return list; } +SCM +ly_warning (SCM str) +{ + assert (gh_string_p (str)); + warning ("scheme: " + ly_scm2string (str)); + return SCM_BOOL_T; +} + +void +init_functions () +{ + scm_make_gsubr ("ly-warn", 1, 0, 0, ly_warning); +} + + +extern void init_symbols (); + +void +init_lily_guile () +{ + init_symbols(); + init_functions (); +} diff --git a/lily/main.cc b/lily/main.cc index 947140abbe..b5f0c3170e 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -255,7 +255,7 @@ main_prog (int argc, char **argv) */ extern void ly_init_protection(); ly_init_protection(); - init_symbols (); + init_lily_guile (); read_lily_scm_file ( "lily.scm"); cout << endl; diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index a7d10c7c3a..c44d68ad7d 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -14,3 +14,53 @@ ADD_THIS_TRANSLATOR(Performer_group_performer); + +void +Performer_group_performer::announce_element (Audio_element_info info) +{ + announce_info_arr_.push (info); + Performer::announce_element (info); +} + +void +Performer_group_performer::do_announces() +{ + Link_array groups = group_l_arr (); + for (int i=0; i < groups.size(); i++) + { + Performer_group_performer * group = dynamic_cast (groups[i]); + if (group) + { + group->do_announces(); + } + } + + Request dummy_req; + + Link_array nongroups = nongroup_l_arr (); + while (announce_info_arr_.size ()) + { + for (int j =0; j < announce_info_arr_.size(); j++) + { + Audio_element_info info = announce_info_arr_[j]; + + if (!info.req_l_) + info.req_l_ = &dummy_req; + for (int i=0; i < nongroups.size(); i++) + { // Is this good enough? + Performer * eng = dynamic_cast (nongroups[i]); + if (eng && eng!= info.origin_trans_l_arr_[0]) + eng->acknowledge_element (info); + } + } + announce_info_arr_.clear (); + for (int i=0; i < nongroups.size(); i++) + { + Performer * eng = dynamic_cast (nongroups[i]); + if (eng) + eng->process_acknowledged (); + } + + } +} + diff --git a/lily/performer.cc b/lily/performer.cc index 82dce90299..62ac44481e 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -11,9 +11,6 @@ #include "performer-group-performer.hh" #include "debug.hh" - - - void Performer::play (Audio_element* p) { @@ -33,3 +30,21 @@ Performer::daddy_perf_l () const ?dynamic_cast (daddy_trans_l_) : 0; } + +void +Performer::acknowledge_element (Audio_element_info) +{ +} + +void +Performer::process_acknowledged () +{ +} + + +void +Performer::announce_element (Audio_element_info i) +{ + i.origin_trans_l_arr_.push (this); + daddy_perf_l()->announce_element (i); +} diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index 1e5aa7eed2..a8f601e9ee 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -60,7 +60,7 @@ Rest_engraver::do_process_requests () String reststyle = get_property ("restStyle", 0); if (reststyle.length_i ()) rest_p_->set_elt_property (style_scm_sym, - gh_str02scm (reststyle.ch_C())); + gh_str02scm (reststyle.ch_C())); } announce_element (Score_element_info (rest_p_, rest_req_l_)); } diff --git a/lily/score-element.cc b/lily/score-element.cc index 7be075b6ec..f77f9c9e8c 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -136,6 +136,8 @@ Score_element::print() const { #ifndef NPRINT DOUT << classname(this) << "{\n"; + if (check_debug && !monitor->silent_b ("Score_element")) + ly_display_scm (element_property_alist_); DOUT << "dependencies: " << dependency_size(); if (original_l_) DOUT << "Copy "; diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 8938ebd8fe..8cd17a52d8 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -82,7 +82,7 @@ void Score_engraver::announce_element (Score_element_info info) { announce_info_arr_.push (info); - info.origin_grav_l_arr_.push (this); + info.origin_trans_l_arr_.push (this); if (Spanner *s = dynamic_cast (info.elem_l_)) pscore_p_->typeset_unbroken_spanner (s); diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 4729fc302e..3da26d540c 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -56,6 +56,7 @@ void Score_performer::process() { process_requests(); + do_announces (); pre_move_processing(); check_removal(); } diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index 2d352365f6..11d66d7587 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -38,7 +38,7 @@ void Staff_margin_engraver::acknowledge_element (Score_element_info inf) { Item *i = cast_to_interesting_item (inf.elem_l_); - if (!i || inf.origin_grav_l_arr_.size() != 1) + if (!i || inf.origin_trans_l_arr_.size() != 1) return; diff --git a/lily/tuplet-spanner.cc b/lily/tuplet-spanner.cc index adcb935f25..9ff1e89bde 100644 --- a/lily/tuplet-spanner.cc +++ b/lily/tuplet-spanner.cc @@ -36,12 +36,14 @@ Tuplet_spanner::do_brew_molecule_p () const Molecule num (lookup_l ()->text ("italic", number_str_)); num.align_to (X_AXIS, CENTER); - num.translate_axis (dir_ * paper_l ()->get_realvar (interline_scm_sym), Y_AXIS); - + Real interline = paper_l ()->get_realvar (interline_scm_sym); + if (beam_l_arr_.size () == 1 && !bracket_visibility_b_) { Beam *beam_l = beam_l_arr_[0]; Directional_spanner* ds = dynamic_cast(beam_l); + + num.translate_axis (dir_ * interline, Y_AXIS); num.translate (ds->center ()); num.translate_axis (ncw, X_AXIS); } @@ -51,7 +53,9 @@ Tuplet_spanner::do_brew_molecule_p () const Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_] - column_arr_[0]->extent (Y_AXIS) [dir_]; Real w = extent (X_AXIS).length () + ncw; - // num.align_to (Y_AXIS, CENTER); + num.align_to (Y_AXIS, CENTER); + num.translate_axis (dir_ * interline, Y_AXIS); + num.translate (Offset (w/2, dy/2)); mol_p->add_molecule (lookup_l ()->plet (dy, w, dir_)); } @@ -60,6 +64,7 @@ Tuplet_spanner::do_brew_molecule_p () const { mol_p->add_molecule (num); } + mol_p->translate_axis (dir_ * interline, Y_AXIS); } return mol_p; } diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 891c1b98d1..7a21264159 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -58,8 +58,8 @@ Vertical_align_engraver::do_removal_processing() bool Vertical_align_engraver::qualifies_b (Score_element_info i) const { - Translator * t = i.origin_grav_l_arr_[0]; - int sz = i.origin_grav_l_arr_.size() ; + Translator * t = i.origin_trans_l_arr_[0]; + int sz = i.origin_trans_l_arr_.size() ; #if 0 return (sz == 1 && dynamic_cast (t)) @@ -78,7 +78,7 @@ Vertical_align_engraver::acknowledge_element (Score_element_info i) { valign_p_->add_element (i.elem_l_); } - else if (dynamic_cast(i.elem_l_) && i.origin_grav_l_arr_.size ()) + else if (dynamic_cast(i.elem_l_) && i.origin_trans_l_arr_.size ()) { i.elem_l_->add_dependency (valign_p_); } diff --git a/mf/feta-klef.mf b/mf/feta-klef.mf index 6a3f659785..32265045c8 100644 --- a/mf/feta-klef.mf +++ b/mf/feta-klef.mf @@ -15,8 +15,8 @@ fet_begingroup("clefs"); % def set_horizontal_spacing = save left_space ,right_space; - left_space# = reduced_il#; - right_space# = reduced_il#; + left_space# = 0; + right_space# = 0; enddef; diff --git a/ps/lily.ps b/ps/lily.ps index cd020ac71b..662ac2ec53 100644 --- a/ps/lily.ps +++ b/ps/lily.ps @@ -77,12 +77,12 @@ 0 0 moveto - 0 tuplet_h lineto + 0 tuplet_h dir mul lineto tuplet_dx tuplet_gapx sub 2 div - tuplet_dy tuplet_gapy sub 2 div tuplet_h add lineto + tuplet_dy tuplet_gapy sub 2 div tuplet_h dir mul add lineto tuplet_dx tuplet_gapx add 2 div - tuplet_dy tuplet_gapy add 2 div tuplet_h add moveto - tuplet_dx tuplet_dy tuplet_h add lineto + tuplet_dy tuplet_gapy add 2 div tuplet_h dir mul add moveto + tuplet_dx tuplet_dy tuplet_h dir mul add lineto tuplet_dx tuplet_dy lineto stroke } bind def diff --git a/scm/lily.scm b/scm/lily.scm index 74d1d2f10d..cc68e713a0 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -80,8 +80,37 @@ (define Piano_bar_engraver_visibility postbreak_only_visibility) (define Staff_group_bar_engraver_visibility postbreak_only_visibility) - - +;; Spacing constants for prefatory matter. +;; +;; rules for this are complicated. See [Wanske] page 126 -- 134 +;; +;; +(define space-alist + '( + (("Clef_item" "Key_item") . 2.5) + (("Key_item" "Time_signature") . 2.5) + (("Clef_item" "Time_signature") . 2.75) + (("Staff_bar" "Clef_item") . 1.0) + (("Clef_item" "Staff_bar") . 3.7) + (("Time_signature" "Staff_bar") . 2.0) + (("Key_item" "Staff_bar") . 2.5) + (("Span_bar" "Clef_item") . 1.0) + (("Clef_item" "Span_bar") . 3.7) + (("Time_signature" "Span_bar") . 2.0) + (("Key_item" "Span_bar") . 2.5) + (("Staff_bar" "Time_signature") . 1.0) + ) + + ) + +(define (break-align-spacer this next) + (let ((entry (assoc `(,this ,next) space-alist))) + (if entry + (cdr entry) + (begin (ly-warn (string-append "Unknown spacing pair " this ", " next)) + 0.0)))) + + ;;;;;;;; TeX diff --git a/scripts/abc-2-ly.py b/scripts/abc-2-ly.py index 6d3af3a519..b818d04351 100644 --- a/scripts/abc-2-ly.py +++ b/scripts/abc-2-ly.py @@ -14,13 +14,36 @@ import getopt import sys import re import string +import mpz header = {} global_voice_stuff = [] default_len = 4 global_key = [0] * 7 # UGH +DIGITS='0123456789' +def gcd (a, b): + while a % b: + a,b = b, a % b + return b + +class Rational: + def __init__ (self, n, d = 1): + self.num = n + self.den = d + + def simplify (self): + g = gcd (self.num, self.den) + self.num = self.num / g + self.den = self.den /g + if self.den < 0: + self.den = - self.den + self.num = - self.num + + def __sub__ (self, other): + pass + def dump_header (hdr): @@ -205,7 +228,7 @@ def octave_to_mudela_quotes (o): def parse_num (str): durstr = '' - while str[0] in "1234567890": + while str[0] in DIGITS: durstr = durstr + str[0] str = str[1:] @@ -215,11 +238,24 @@ def parse_num (str): return (str,n) -def duration_to_mudela_duration (multiply_tup, defaultlen): +def duration_to_mudela_duration (multiply_tup, defaultlen, dots): base = 1 + # (num / den) / defaultlen < 1/base + while base * multiply_tup[0] < defaultlen * multiply_tup[1]: + base = base * 2 + + + return '%d%s' % ( base, '.'* dots) + +class Parser_state: + def __init__ (self): + self.next_dots = 0 + self.next_den = 1 + + # WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP ! -def try_parse_note (str): +def try_parse_note (str, parser_state): mud = '' slur_begin =0 @@ -259,21 +295,38 @@ def try_parse_note (str): str = str[1:] num = 0 - den = 0 + den = parser_state.next_den + parser_state.next_den = 1 (str, num) = parse_num (str) if not num: num = 1 if str[0] == '/': - divide =1 - str = str[1:] - (str, den) =parse_num (str) - - if not den: den = 1 + while str[0] == '/': + str= str[1:] + d = 2 + if str[0] in DIGITS: + (str, d) =parse_num (str) + + den = den * d + + current_dots = parser_state.next_dots + parser_state.next_dots = 0 + while str[0] == '>': + str = str [1:] + current_dots = current_dots + 1; + parser_state.next_den = parser_state.next_den * 2 + + while str[0] == '<': + str = str [1:] + den = den * 2 + parser_state.next_dots = parser_state.next_dots + 1 + - print duration_to_mudela_duration ((num,den), default_len) - print '%s%s%d' % (pitch_to_mudela_name(notename, acc + global_key[notename]) , octave_to_mudela_quotes (octave), duration_mult) + + print '%s%s%s' % (pitch_to_mudela_name(notename, acc + global_key[notename]) , octave_to_mudela_quotes (octave), + duration_to_mudela_duration ((num,den), default_len, current_dots)) slur_end =0 if str[0] == ')': @@ -289,27 +342,46 @@ def junk_space (str): return str +def try_parse_escape (str): + if str [0] != '\\': + return str + + str = str[1:] + if str[0] == 'K': + compute_key () + + return str + + def try_parse_bar (str): if str[0] == '|': str = str[1:] return str -def try_parse_body_line (ln): + + +def try_parse_body_line (ln, state): prev_ln = '' while ln and ln != prev_ln: prev_ln = ln - ln = try_parse_note (ln) + ln = try_parse_note (ln, state) ln = try_parse_bar (ln) ln = junk_space (ln) + ln = try_parse_escape (ln) if ln: print 'Huh %s' % ln + + + + def parse_file (fn): f = open (fn) ls = f.readlines () head = 1 + state = Parser_state () for l in ls: if re.match ('^[\t ]*(%.*)?$', l): continue @@ -320,7 +392,7 @@ def parse_file (fn): head = 0 if not head: - m = try_parse_body_line (l) + m = try_parse_body_line (l,state) def identify():