From: fred Date: Tue, 26 Mar 2002 21:49:56 +0000 (+0000) Subject: lilypond-1.1.45 X-Git-Tag: release/1.5.59~2433 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4c20c7982fee65132dc1eb0096d114f1454d0ec3;p=lilypond.git lilypond-1.1.45 --- diff --git a/Documentation/gnu-music.yo b/Documentation/gnu-music.yo index 4e6e3148ed..e37331dcd5 100644 --- a/Documentation/gnu-music.yo +++ b/Documentation/gnu-music.yo @@ -86,8 +86,3 @@ it()Libraries for reading and writing various audio/music/notation formats. ) -Find sponsors. This project will take a long time, and in its infant -stages, having a hard and small core which does a lot of work, is more -efficient than lots of people doing small subprojects. Finanicial -support would be desirable. - diff --git a/input/test/dynamics.fly b/input/test/dynamics.fly new file mode 100644 index 0000000000..4b586d5c07 --- /dev/null +++ b/input/test/dynamics.fly @@ -0,0 +1,2 @@ +c''4 \p c \ff c^\ff +c \p \< \! c \ff\> c \!c-\p diff --git a/lily/align-element.cc b/lily/align-element.cc index 82111b9e2e..0e0b5a5605 100644 --- a/lily/align-element.cc +++ b/lily/align-element.cc @@ -97,6 +97,15 @@ Align_element::do_side_processing () { dims.push (y); Score_element *e =dynamic_cast(elem_l_arr_[i]); + + SCM extra_dims = e->get_elt_property (extra_space_scm_sym); + if (extra_dims != SCM_BOOL_F) + { + extra_dims = SCM_CDR (extra_dims); + dims.top ()[LEFT] -= gh_scm2double (SCM_CAR (extra_dims)); + dims.top ()[RIGHT] += gh_scm2double (SCM_CAR (extra_dims)); + } + elems.push (e); } } diff --git a/lily/bar-script-engraver.cc b/lily/bar-script-engraver.cc index a0e33d0d8e..a7f59dea8e 100644 --- a/lily/bar-script-engraver.cc +++ b/lily/bar-script-engraver.cc @@ -36,6 +36,12 @@ Bar_script_engraver::do_creation_processing () } } +/* + Some interesting item came across. Lets attach the text and the + positioner to the item. + +*/ + void Bar_script_engraver::do_acknowledge_element (Item *i) { @@ -47,6 +53,8 @@ Bar_script_engraver::do_acknowledge_element (Item *i) staff_side_p_->dim_cache_[axis_]->parent_l_ = i->dim_cache_[axis_]; + if (!text_p_->dim_cache_[other_axis]->parent_l_) + text_p_->dim_cache_[other_axis]->parent_l_ = i->dim_cache_[other_axis]; staff_side_p_->add_support (i); /* diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index 8fd12ab3b6..ab9c805824 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -8,6 +8,7 @@ #include "break-align-item.hh" #include "dimensions.hh" +#include "p-score.hh" void Break_align_item::do_pre_processing() @@ -17,9 +18,56 @@ Break_align_item::do_pre_processing() Axis_align_item::do_pre_processing(); } + + + Break_align_item::Break_align_item () { stacking_dir_ = RIGHT; threshold_interval_[SMALLER] = 1.5 PT; set_axis (X_AXIS); } + +void +Break_align_item::add_breakable_item (Item *it) +{ + SCM pr = it->remove_elt_property (break_priority_scm_sym); + + if (pr == SCM_BOOL_F) + return; + + int priority = gh_scm2int (SCM_CDR (pr)); + + Score_element * column_l = get_elt_by_priority (priority); + Axis_group_item * hg=0; + if (column_l) + { + hg = dynamic_cast (column_l); + } + else + { + hg = new Axis_group_item; + hg->set_axes (X_AXIS,X_AXIS); + + /* + this is quite ridiculous, but we do this anyway, to ensure that no + 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); + + pscore_l_->typeset_element (hg); + add_element_priority (hg, priority); + + 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/collision.cc b/lily/collision.cc index b4136ae520..1b1f1be105 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -36,8 +36,8 @@ int idx (int dir, bool h_shift_b) return j; } -/** This complicated routine moves note columns around horizontally - (and rests vertically) to ensure that notes don't clash. +/** This complicated routine moves note columns around horizontally to + ensure that notes don't clash. This should be done better, probably. diff --git a/lily/command-request.cc b/lily/command-request.cc index 335c929042..6cbd2bc92f 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -1,5 +1,5 @@ /* - commandrequest.cc -- implement Nonmusical reqs + command-request.cc -- implement non-musical reqs source file of the GNU LilyPond music typesetter @@ -91,9 +91,6 @@ Partial_measure_req::do_print() const DOUT << length_mom_; } - - - void Time_signature_change_req::do_print() const { @@ -105,7 +102,8 @@ Time_signature_change_req::do_print() const bool Time_signature_change_req::do_equal_b (Request * r) const { - Time_signature_change_req * m = dynamic_cast (r); + Time_signature_change_req * m + = dynamic_cast (r); return m && m->beats_i_ == beats_i_ && one_beat_i_ == m->one_beat_i_; diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 409e29a4b8..b499af90b6 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -17,22 +17,17 @@ Crescendo::Crescendo () { grow_dir_ =0; - dir_ = DOWN; dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false; } -Interval -Crescendo::symbol_height () const -{ - return get_symbol ().dim_[Y_AXIS]; -} -static Real absdyn_dim = 10 PT; // ugh + Molecule Crescendo::get_symbol () const { Real w_dim = extent (X_AXIS).length (); + Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten")); if (dyn_b_drul_[LEFT]) { w_dim -= absdyn_dim; @@ -64,6 +59,7 @@ Molecule* Crescendo::do_brew_molecule_p () const { Molecule* m_p =0; + Real absdyn_dim = paper_l ()-> get_realvar (ly_symbol ("crescendo_shorten")); Real x_off_dim=0.0; if (dyn_b_drul_[LEFT]) x_off_dim += absdyn_dim; @@ -71,9 +67,8 @@ Crescendo::do_brew_molecule_p () const m_p = new Molecule; Molecule s (get_symbol ()); m_p->add_molecule (s); - m_p->translate (Offset (x_off_dim, coordinate_offset_f_)); + m_p->translate_axis (x_off_dim, X_AXIS); return m_p; } - diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index b5d5d37906..b0670d5236 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -27,6 +27,9 @@ class Dynamic_engraver : public Engraver { G_text_item * text_p_; G_staff_side_item * staff_side_p_; + G_staff_side_spanner * ss_span_p_; + G_staff_side_spanner * to_end_ss_span_p_; + Crescendo * to_end_cresc_p_; Crescendo * cresc_p_; @@ -54,6 +57,7 @@ Dynamic_engraver::Dynamic_engraver() text_p_ =0; staff_side_p_ =0; to_end_cresc_p_ = cresc_p_ = 0; + ss_span_p_ = to_end_ss_span_p_=0; cresc_req_l_ = 0; } @@ -95,6 +99,7 @@ void Dynamic_engraver::do_process_requests() { Crescendo* new_cresc_p=0; + G_staff_side_spanner * new_sss_p =0; for (int i=0; i < dynamic_req_l_arr_.size(); i++) { if (Text_script_req *absd = @@ -133,7 +138,7 @@ Dynamic_engraver::do_process_requests() announce_element (Score_element_info (staff_side_p_, absd)); } else if (Span_req *span_l - = dynamic_cast (dynamic_req_l_arr_[i])) + = dynamic_cast (dynamic_req_l_arr_[i])) { if (span_l->span_dir_ == STOP) { @@ -145,11 +150,14 @@ Dynamic_engraver::do_process_requests() { assert (!to_end_cresc_p_); to_end_cresc_p_ =cresc_p_; + to_end_ss_span_p_ = ss_span_p_ ; + cresc_p_ = 0; + ss_span_p_ =0; Scalar prop = get_property ("dynamicDir", 0); if (prop.isnum_b ()) { - to_end_cresc_p_->dir_ = (Direction) (int) prop; + to_end_ss_span_p_->dir_ = (Direction) (int) prop; } } @@ -161,6 +169,11 @@ Dynamic_engraver::do_process_requests() new_cresc_p = new Crescendo; new_cresc_p->grow_dir_ = (span_l->span_type_str_ == "crescendo") ? BIGGER : SMALLER; announce_element (Score_element_info (new_cresc_p, span_l)); + + new_sss_p = new G_staff_side_spanner; + new_sss_p->set_victim (new_cresc_p); + new_sss_p->axis_ = Y_AXIS; + announce_element (Score_element_info (new_sss_p, span_l)); } } } @@ -171,11 +184,15 @@ Dynamic_engraver::do_process_requests() { ::warning (_ ("Too many crescendi here")); typeset_element (cresc_p_); + typeset_element (ss_span_p_); cresc_p_ = 0; + ss_span_p_ =0; } cresc_p_ = new_cresc_p; + ss_span_p_ = new_sss_p; cresc_p_->set_bounds(LEFT,get_staff_info().musical_pcol_l ()); + ss_span_p_->set_bounds (LEFT,get_staff_info().musical_pcol_l ()); if (text_p_) { cresc_p_->dyn_b_drul_[LEFT] = true; @@ -201,6 +218,8 @@ Dynamic_engraver::do_removal_processing () if (cresc_p_) { typeset_element (cresc_p_ ); + typeset_element (ss_span_p_); + ss_span_p_ =0; cresc_req_l_->warning (_ ("unended crescendo")); cresc_p_ =0; } @@ -214,9 +233,13 @@ Dynamic_engraver::typeset_all () if (to_end_cresc_p_) { to_end_cresc_p_->set_bounds(RIGHT,get_staff_info().musical_pcol_l ()); + to_end_ss_span_p_->set_bounds(RIGHT,get_staff_info().musical_pcol_l ()); typeset_element (to_end_cresc_p_); + typeset_element (to_end_ss_span_p_); to_end_cresc_p_ =0; + to_end_ss_span_p_ =0; } + if (text_p_) { typeset_element (text_p_); @@ -237,10 +260,10 @@ Dynamic_engraver::acknowledge_element (Score_element_info i) if (staff_side_p_) staff_side_p_->add_support (i.elem_l_); - if (to_end_cresc_p_) - to_end_cresc_p_->add_support (i.elem_l_); + if (to_end_ss_span_p_) + to_end_ss_span_p_->add_support (i.elem_l_); - if (cresc_p_) - cresc_p_->add_support (i.elem_l_); + if (ss_span_p_) + ss_span_p_->add_support (i.elem_l_); } } diff --git a/lily/g-staff-side.cc b/lily/g-staff-side.cc index 91a6a18195..437f34fe21 100644 --- a/lily/g-staff-side.cc +++ b/lily/g-staff-side.cc @@ -1,5 +1,5 @@ /* - g-staff-side.cc -- implement G_staff_side_item + g-staff-side.cc -- implement G_staff_side_element source file of the GNU LilyPond music typesetter @@ -13,7 +13,7 @@ #include "warn.hh" #include "dimensions.hh" -G_staff_side_item::G_staff_side_item () +G_staff_side_element::G_staff_side_element () { dir_ = CENTER; to_position_l_ = 0; @@ -25,7 +25,7 @@ G_staff_side_item::G_staff_side_item () void -G_staff_side_item::do_pre_processing () +G_staff_side_element::do_pre_processing () { if (!dir_) dir_ = get_default_direction (); @@ -35,14 +35,14 @@ G_staff_side_item::do_pre_processing () } Direction -G_staff_side_item::get_default_direction () const +G_staff_side_element::get_default_direction () const { return DOWN; } void -G_staff_side_item::set_victim (Score_element *e) +G_staff_side_element::set_victim (Score_element *e) { add_dependency (e); to_position_l_ = e; @@ -50,7 +50,7 @@ G_staff_side_item::set_victim (Score_element *e) } void -G_staff_side_item::add_support (Score_element*e) +G_staff_side_element::add_support (Score_element*e) { add_dependency (e); support_l_arr_.push (e); @@ -58,7 +58,7 @@ G_staff_side_item::add_support (Score_element*e) void -G_staff_side_item::do_substitute_element_pointer (Score_element*o, Score_element*n) +G_staff_side_element::do_substitute_element_pointer (Score_element*o, Score_element*n) { Staff_symbol_referencer::do_substitute_element_pointer (o,n); if (o == to_position_l_) @@ -68,7 +68,7 @@ G_staff_side_item::do_substitute_element_pointer (Score_element*o, Score_element } void -G_staff_side_item::position_self () +G_staff_side_element::position_self () { if (to_position_l_ && to_position_l_->get_elt_property (transparent_scm_sym) != SCM_BOOL_F) @@ -85,6 +85,7 @@ G_staff_side_item::position_self () { Score_element * e = support_l_arr_ [i]; Real coord = e->relative_coordinate (common, axis_); + dim.unite (coord + e->extent (axis_)); } } @@ -116,7 +117,7 @@ G_staff_side_item::position_self () } void -G_staff_side_item::do_post_processing () +G_staff_side_element::do_post_processing () { if (axis_ == Y_AXIS) position_self (); @@ -124,7 +125,7 @@ G_staff_side_item::do_post_processing () void -G_staff_side_item::do_add_processing () +G_staff_side_element::do_add_processing () { if (staff_support_b_ && axis_ == Y_AXIS && staff_symbol_l ()) @@ -134,7 +135,7 @@ G_staff_side_item::do_add_processing () } Interval -G_staff_side_item::do_height () const +G_staff_side_element::do_height () const { Interval i; if (to_position_l_) @@ -142,6 +143,19 @@ G_staff_side_item::do_height () const return i; } +void +G_staff_side_element::do_print () const +{ +#ifndef NPRINT + if (to_position_l_) + DOUT << "positioning " << to_position_l_->name(); + + DOUT << "axis == " << axis_name_str (axis_) + << ", dir == " << to_str (dir_ ); +#endif +} + + Interval G_staff_side_item::do_width () const { @@ -150,14 +164,15 @@ G_staff_side_item::do_width () const return to_position_l_->extent (X_AXIS); return i; } + void G_staff_side_item::do_print () const { -#ifndef NPRINT - if (to_position_l_) - DOUT << "positioning " << to_position_l_->name(); + G_staff_side_element::do_print (); +} - DOUT << "axis == " << axis_name_str (axis_) - << ", dir == " << to_str (dir_ ); -#endif +void +G_staff_side_spanner::do_print () const +{ + G_staff_side_element::do_print (); } diff --git a/lily/g-stem-staff-side.cc b/lily/g-stem-staff-side.cc index 446e0649a6..4d96f2ff52 100644 --- a/lily/g-stem-staff-side.cc +++ b/lily/g-stem-staff-side.cc @@ -51,5 +51,5 @@ G_stem_staff_side_item::do_pre_processing () gh_double2scm(stem_l_->staff_line_leading_f () * gh_scm2double (p))); } - G_staff_side_item :: do_pre_processing (); + G_staff_side_item::do_pre_processing (); } diff --git a/lily/graphical-element.cc b/lily/graphical-element.cc index 10daaef6c1..89bdd3b95a 100644 --- a/lily/graphical-element.cc +++ b/lily/graphical-element.cc @@ -130,3 +130,13 @@ Graphical_element::name () const { return classname (this); } + +void +Graphical_element::print () const +{ +#ifndef NPRINT + DOUT << classname (this) << "{\n"; + do_print (); + DOUT << "}\n"; +#endif +} diff --git a/lily/include/break-align-item.hh b/lily/include/break-align-item.hh index d2b98fa7ce..120f14920d 100644 --- a/lily/include/break-align-item.hh +++ b/lily/include/break-align-item.hh @@ -15,9 +15,12 @@ /// align breakable items (clef, bar, etc.) class Break_align_item : public Axis_align_item { + protected: virtual void do_pre_processing(); public: + void add_breakable_item (Item *it); + Break_align_item (); VIRTUAL_COPY_CONS(Score_element); diff --git a/lily/include/crescendo.hh b/lily/include/crescendo.hh index f054deb541..f0364a2c03 100644 --- a/lily/include/crescendo.hh +++ b/lily/include/crescendo.hh @@ -10,12 +10,11 @@ #ifndef CRESCENDO_HH #define CRESCENDO_HH -#include "staff-side.hh" #include "spanner.hh" /** The hairpin symbol. (cresc) */ -class Crescendo : public Spanner , public Staff_side { +class Crescendo : public Spanner { public: int grow_dir_; @@ -26,8 +25,6 @@ public: protected: VIRTUAL_COPY_CONS(Score_element); virtual Molecule*do_brew_molecule_p() const; - virtual Interval symbol_height() const; - private: Molecule get_symbol() const; diff --git a/lily/include/g-staff-side.hh b/lily/include/g-staff-side.hh index e6808863a6..9acdbca344 100644 --- a/lily/include/g-staff-side.hh +++ b/lily/include/g-staff-side.hh @@ -10,6 +10,7 @@ #ifndef G_STAFF_SIDE_HH #define G_STAFF_SIDE_HH +#include "spanner.hh" #include "item.hh" #include "staff-symbol-referencer.hh" @@ -23,7 +24,7 @@ Amount of extra space to add. */ -class G_staff_side_item : public Item, public Staff_symbol_referencer +class G_staff_side_element : public Staff_symbol_referencer { void position_self (); @@ -35,7 +36,7 @@ public: //junkme. bool staff_support_b_; - G_staff_side_item (); + G_staff_side_element (); void set_victim (Score_element*); void add_support (Score_element*); @@ -43,7 +44,6 @@ public: virtual Direction get_default_direction () const; protected: virtual Interval do_height () const; - virtual Interval do_width () const; virtual void do_print () const; virtual void do_add_processing (); virtual void do_substitute_element_pointer (Score_element*,Score_element*); @@ -51,5 +51,22 @@ protected: virtual void do_post_processing (); }; +class G_staff_side_item : public G_staff_side_element, public Item +{ +public: + VIRTUAL_COPY_CONS(Score_element); +protected: + virtual Interval do_width () const; + virtual void do_print () const; +}; + +class G_staff_side_spanner : public G_staff_side_element, public Spanner +{ +public: + VIRTUAL_COPY_CONS(Score_element); +protected: + virtual void do_print () const; +}; + #endif /* G_STAFF_SIDE_HH */ diff --git a/lily/include/graphical-element.hh b/lily/include/graphical-element.hh index c84a21f717..819a0ea31f 100644 --- a/lily/include/graphical-element.hh +++ b/lily/include/graphical-element.hh @@ -62,6 +62,7 @@ public: Graphical_element *parent_l (Axis a) const; virtual void do_print () const; + virtual void print () const; }; #endif // GRAPHICAL_ELEMENT_HH diff --git a/lily/include/ly-symbols.hh b/lily/include/ly-symbols.hh index 7d94aa2ceb..dc99b23c71 100644 --- a/lily/include/ly-symbols.hh +++ b/lily/include/ly-symbols.hh @@ -28,6 +28,7 @@ DECLARE_LY_SYMBOL(change); DECLARE_LY_SYMBOL(damping); DECLARE_LY_SYMBOL(dashed); DECLARE_LY_SYMBOL(extremal); +DECLARE_LY_SYMBOL(extra_space); DECLARE_LY_SYMBOL(dir_forced); DECLARE_LY_SYMBOL(extender_height); DECLARE_LY_SYMBOL(filledbox); diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index a8f51ab6e8..16aee2493e 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -73,6 +73,7 @@ public: String style_str_; protected: VIRTUAL_COPY_CONS(Music); + virtual bool do_equal_b (Request*)const; virtual void do_print () const; }; diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 59512ca5e1..cb81818d3d 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -171,6 +171,13 @@ Text_script_req::do_print () const << ", style = " << style_str_; } +bool +Text_script_req::do_equal_b (Request *r) const +{ + Text_script_req * t = dynamic_cast(r); + return t && t->text_str_ == text_str_ && t->style_str_ == style_str_; +} + void Articulation_req::do_print () const { diff --git a/lily/request.cc b/lily/request.cc index 1cb84c9481..7c833def05 100644 --- a/lily/request.cc +++ b/lily/request.cc @@ -9,17 +9,11 @@ #include "request.hh" #include "debug.hh" - - - void Request::do_print() const { } - - - bool Request::equal_b (Request *r) const { @@ -30,6 +24,5 @@ bool Request::do_equal_b (Request*) const { return true; - } diff --git a/lily/score-priority-engraver.cc b/lily/score-priority-engraver.cc index 463cff1ca1..0948bc7537 100644 --- a/lily/score-priority-engraver.cc +++ b/lily/score-priority-engraver.cc @@ -6,7 +6,6 @@ (c) 1997--1999 Han-Wen Nienhuys */ - #include "axis-group-item.hh" #include "score-priority-engraver.hh" #include "item.hh" @@ -31,27 +30,11 @@ Score_priority_engraver::do_pre_move_processing() typeset_element (halign_p_); halign_p_ =0; } - -} - -void -Score_priority_engraver::add_horizontal_group (Item* it, int priority) -{ - if (!halign_p_) - { - halign_p_ = new Break_align_item; - halign_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); - announce_element (Score_element_info (halign_p_,0)); - } - - if (priority == 0) - halign_p_->center_l_ = it; - - halign_p_->add_element_priority (it, priority); - - column_p_arr_.push (it); } +/* + TODO: move this logic into Break_align_item + */ void Score_priority_engraver::acknowledge_element (Score_element_info inf) { @@ -61,40 +44,20 @@ Score_priority_engraver::acknowledge_element (Score_element_info inf) if (c->empty_b () || c->parent_l_) return; - SCM pr = item_l->remove_elt_property (break_priority_scm_sym); - - if (pr == SCM_BOOL_F) - return; - - bool breakable = (item_l->remove_elt_property (breakable_scm_sym) != SCM_BOOL_F); + bool breakable + = (item_l->remove_elt_property (breakable_scm_sym) != SCM_BOOL_F); if (!breakable) return ; - - int priority = gh_scm2int (SCM_CDR (pr)); - - Score_element * column_l = 0; - if (halign_p_) - column_l = halign_p_->get_elt_by_priority (priority); - Axis_group_item * hg=0; - if (column_l) - { - hg = dynamic_cast (column_l); - } - else + + + if (!halign_p_) { - hg = new Axis_group_item; - hg->set_axes (X_AXIS,X_AXIS); - hg->set_elt_property (ly_symbol("origin"), - SCM_EOL); - announce_element (Score_element_info (hg,0)); - add_horizontal_group (hg, priority); + halign_p_ = new Break_align_item; + halign_p_->set_elt_property (breakable_scm_sym, SCM_BOOL_T); + announce_element (Score_element_info (halign_p_,0)); } - - hg->set_elt_property (ly_symbol("origin"), - scm_cons (gh_str02scm (item_l->name()), - hg->get_elt_property (ly_symbol ("origin")))); - hg->add_element (item_l); - + + halign_p_->add_breakable_item (item_l); } } diff --git a/lily/single-malt-grouping-item.cc b/lily/single-malt-grouping-item.cc index 6d5e2e1767..77848e79fa 100644 --- a/lily/single-malt-grouping-item.cc +++ b/lily/single-malt-grouping-item.cc @@ -39,7 +39,7 @@ Single_malt_grouping_item::my_width () const if (pc != il->column_l ()) { /* this shouldn't happen, but let's continue anyway. */ - warning (_("Single_malt_grouping_item: I've been drinking too much (fixme)")); + programming_error (_("Single_malt_grouping_item: I've been drinking too much")); continue; /*UGH UGH*/ } diff --git a/ly/params.ly b/ly/params.ly index c18c9a85f4..845417014a 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -135,6 +135,10 @@ extender_height = 0.8*\staffline; % Multi-measure rests mmrest_x_minimum = 2.0*\staffheight; + +% chop off this much when next to pp / ff sign. +crescendo_shorten = 4.0 * \interline; + % in internote. restcollision_minimum_dist = 3.0; restcollision_minimum_beamdist = 1.5; diff --git a/scripts/abc-2-ly.py b/scripts/abc-2-ly.py index f1e5dd9ab7..6d3af3a519 100644 --- a/scripts/abc-2-ly.py +++ b/scripts/abc-2-ly.py @@ -7,16 +7,20 @@ # (not finished.) # -name = 'abc-to-ly' +program_name = 'abc-to-ly' version = '0.1' - +import __main__ import getopt import sys import re import string + + header = {} global_voice_stuff = [] default_len = 4 +global_key = [0] * 7 # UGH + def dump_header (hdr): @@ -26,20 +30,10 @@ def dump_header (hdr): print '};' def set_default_length (s): - m = re.match ('1/(.*)$', s) + m = re.search ('1/([0-9]+)', s) if m: - default_len = string.atoi ( m.group (1)) + __main__.default_len = string.atoi ( m.group (1)) -def parse_timesig (s): - m = re.match ('^M: *(.*)$', s) - if m: - print '\meter %s; ' % m.group (1) - -def parse_key (s): - m = re.match ('^K: *(.*)$', s) - if m: - print '\key %s; ' % m.group (1) - def gulp_file(f): try: i = open(f) @@ -56,6 +50,104 @@ def gulp_file(f): return s +# pitch manipulation. Tuples are (name, alteration). +# 0 is (central) C. Alteration -1 is a flat, Alteration +1 is a sharp +# pitch in semitones. +def semitone_pitch (tup): + p =0 + + t = tup[0] + p = p + 12 * (t / 7) + t = t % 7 + + if t > 2: + p = p- 1 + + p = p + t* 2 + tup[1] + return p + +def fifth_above_pitch (tup): + (n, a) = (tup[0] + 4, tup[1]) + + difference = 7 - (semitone_pitch ((n,a)) - semitone_pitch (tup)) + a = a + difference + + return (n,a) + +def sharp_keys (): + p = (0,0) + l = [] + k = 0 + while 1: + l.append (p) + (t,a) = fifth_above_pitch (p) + if semitone_pitch((t,a)) % 12 == 0: + break + + p = (t % 7, a) + return l + +def flat_keys (): + p = (0,0) + l = [] + k = 0 + while 1: + l.append (p) + (t,a) = quart_above_pitch (p) + if semitone_pitch((t,a)) % 12 == 0: + break + + p = (t % 7, a) + return l + +def quart_above_pitch (tup): + (n, a) = (tup[0] + 3, tup[1]) + + difference = 5 - (semitone_pitch ((n,a)) - semitone_pitch (tup)) + a = a + difference + + return (n,a) + + +def compute_key (k): + k = string.lower (k) + intkey = (ord (k[0]) - ord('a') + 5) % 7 + intkeyacc =0 + k = k[1:] + + if k and k[0] == 'b': + intkeyacc = -1 + k = k[1:] + elif k and k[0] == '#': + intkeyacc = 1 + k = k[1:] + + keytup = (intkey, intkeyacc) + + sharp_key_seq = sharp_keys () + flat_key_seq = flat_keys () + + accseq = None + accsign = 0 + if keytup in sharp_key_seq: + accsign = 1 + key_count = sharp_key_seq.index (keytup) + accseq = map (lambda x: (4*x -1 ) % 7, range (1, key_count + 1)) + + elif keytup in flat_key_seq: + accsign = -1 + key_count = flat_key_seq.index (keytup) + accseq = map (lambda x: (3*x + 3 ) % 7, range (1, key_count + 1)) + else: + raise "Huh" + + key_table = [0] * 7 + for a in accseq: + key_table[a] = key_table[a] + accsign + + + return key_table + def try_parse_header_line (ln): m = re.match ('^(.): *(.*)$', ln) @@ -67,6 +159,8 @@ def try_parse_header_line (ln): if g == 'M': global_voice_stuff.append ('\\time %s;' % a) if g == 'K': + __main__.global_key =compute_key (a)# ugh. + global_voice_stuff.append ('\\key %s;' % a) if g == 'O': header ['origin'] = a @@ -87,9 +181,44 @@ def try_parse_header_line (ln): return m +def pitch_to_mudela_name (name, acc): + s = '' + if acc < 0: + s = 'es' + acc = -acc + elif acc > 0: + s = 'is' + + if name > 4: + name = name -7 + return chr (name + ord('c')) + s * acc + +def octave_to_mudela_quotes (o): + s ='' + if o < 0: + o = -o + s=',' + else: + s ='\'' -# WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP ! + return s * o + +def parse_num (str): + durstr = '' + while str[0] in "1234567890": + durstr = durstr + str[0] + str = str[1:] + + n = None + if durstr: + n =string.atoi (durstr) + return (str,n) + +def duration_to_mudela_duration (multiply_tup, defaultlen): + base = 1 + +# WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP ! def try_parse_note (str): mud = '' @@ -98,7 +227,7 @@ def try_parse_note (str): slur_begin = 1 str = str[1:] - acc = None + acc = 0 if str[0] in '^=_': c = str[0] str = str[1:] @@ -117,7 +246,7 @@ def try_parse_note (str): notename = 0 if str[0] in "abcdefg": - notename = ord(str[0]) - ord('a') + notename = (ord(str[0]) - ord('a') + 5)%7 str = str[1:] else: return str # failed; not a note! @@ -128,20 +257,24 @@ def try_parse_note (str): while str[0] == '\'': octave = octave + 1 str = str[1:] - divide =0 + + num = 0 + den = 0 + + (str, num) = parse_num (str) + if not num: + num = 1 + if str[0] == '/': divide =1 str = str[1:] - durstr = '' - while str[0] in "1234567890": - durstr = durstr + str[0] - str = str[1:] + (str, den) =parse_num (str) - duration_mult = 1 - if durstr: - duration_mult = string.atoi (durstr) + if not den: den = 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) - slur_end =0 if str[0] == ')': slur_begin = 1 @@ -191,7 +324,7 @@ def parse_file (fn): def identify(): - print '%s %s' % (name, version) + print '%s %s' % (program_name, version) def help (): print r""" @@ -201,6 +334,8 @@ says huh when confused. Does not do chords. Go ahead and fix me. -h, --help this help. """ + + identify() (options, files) = getopt.getopt (sys.argv[1:], 'h', ['help'])