From eab7059ecb0ae5052c339cf0a4f206f5f1b005fa Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:55:20 +0000 Subject: [PATCH] lilypond-0.1.9 --- flower/choleski.cc | 135 ++++++----- flower/data-file.cc | 46 ++-- flower/diagonal-storage.cc | 108 +++++---- flower/directed-graph.cc | 62 ++--- flower/dstream.cc | 103 ++++---- flower/flower-debug.cc | 8 +- flower/flower-version.cc | 6 +- flower/full-storage.cc | 114 ++++----- flower/include/cursor.icc | 60 ++--- flower/include/cursor.tcc | 70 +++--- flower/include/full-storage.icc | 38 +-- flower/include/interval.tcc | 54 ++--- flower/include/link.icc | 58 ++--- flower/include/list.icc | 17 +- flower/include/list.tcc | 53 +++-- flower/include/pcursor.tcc | 8 +- flower/include/plist.icc | 3 +- flower/include/plist.tcc | 11 +- flower/include/pointer.tcc | 34 +-- flower/include/string-data.icc | 112 ++++----- flower/include/string-handle.icc | 59 ++--- flower/interval.cc | 2 +- flower/lgetopt.cc | 202 +++++++++------- flower/matrix-debug.cc | 33 +-- flower/matrix-storage.cc | 77 +++--- flower/matrix.cc | 191 +++++++-------- flower/path.cc | 48 ++-- flower/rational.cc | 4 +- flower/scalar.cc | 39 +-- flower/string-convert.cc | 185 ++++++++------- flower/string.cc | 209 +++++++++-------- flower/stringtest.cc | 137 +++++------ flower/text-db.cc | 19 +- flower/text-stream.cc | 15 +- flower/unionfind.cc | 24 +- flower/vector.cc | 14 +- lily/atom.cc | 32 +-- lily/audio-column.cc | 16 +- lily/audio-item.cc | 22 +- lily/audio-score.cc | 78 +++--- lily/audio-staff.cc | 10 +- lily/axis-group-item.cc | 27 ++- lily/axis-group-spanner.cc | 73 +++--- lily/axis-group.cc | 35 +-- lily/axis.cc | 2 +- lily/bar-column-grav.cc | 31 ++- lily/bar-column.cc | 13 +- lily/bar-grav.cc | 39 +-- lily/bar-number-grav.cc | 12 +- lily/bar.cc | 43 ++-- lily/beam.cc | 259 ++++++++++---------- lily/bow.cc | 50 ++-- lily/boxes.cc | 4 +- lily/break-align-item.cc | 4 +- lily/break.cc | 113 ++++----- lily/clef-grav.cc | 79 ++++--- lily/clef-item.cc | 37 +-- lily/col-info.cc | 22 +- lily/colhpos.cc | 30 +-- lily/collision-grav.cc | 12 +- lily/collision.cc | 121 +++++----- lily/crescendo.cc | 43 ++-- lily/debug.cc | 26 +- lily/dimen.cc | 27 ++- lily/directional-spanner.cc | 6 +- lily/dynamic-grav.cc | 82 ++++--- lily/elem-group-item.cc | 2 +- lily/elem-group.cc | 30 +-- lily/engraver-group.cc | 191 ++++++++------- lily/engraver.cc | 61 ++--- lily/general-script-def.cc | 24 +- lily/global-gravs.cc | 50 ++-- lily/global-performers.cc | 26 +- lily/global-translator.cc | 24 +- lily/grouping.cc | 232 ++++++++++-------- lily/head-column.cc | 33 +-- lily/head-grav.cc | 42 ++-- lily/horizontal-align-item.cc | 75 +++--- lily/horizontal-group-item.cc | 2 +- lily/idealspacing.cc | 16 +- lily/ineq-constrained-qp.cc | 164 +++++++------ lily/input-translator.cc | 72 +++--- lily/item.cc | 59 ++--- lily/key-grav.cc | 55 +++-- lily/key-item.cc | 45 ++-- lily/key-performer.cc | 18 +- lily/key.cc | 18 +- lily/keyword.cc | 71 +++--- lily/leastsquares.cc | 29 +-- lily/lexerinit.cc | 2 +- lily/lily-version.cc | 6 +- lily/line-group-grav.cc | 18 +- lily/line-spacer.cc | 4 +- lily/local-key-item.cc | 68 +++--- lily/lyric-grav.cc | 20 +- lily/lyric-performer.cc | 16 +- lily/main.cc | 108 +++++---- lily/meter-grav.cc | 77 +++--- lily/meter-performer.cc | 18 +- lily/meter.cc | 8 +- lily/midi-def.cc | 40 ++-- lily/midi-stream.cc | 38 +-- lily/midi-walker.cc | 63 ++--- lily/misc.cc | 22 +- lily/molecule.cc | 71 +++--- lily/music-iterator.cc | 213 +++++++++-------- lily/music-list.cc | 43 ++-- lily/music.cc | 18 +- lily/musical-request.cc | 192 +++++++-------- lily/note-column-grav.cc | 74 +++--- lily/note-column.cc | 21 +- lily/note-performer.cc | 25 +- lily/note.cc | 58 ++--- lily/notename-table.cc | 8 +- lily/p-score.cc | 239 ++++++++++--------- lily/performer-group-performer.cc | 88 +++---- lily/performer.cc | 26 +- lily/qlp.cc | 63 ++--- lily/qlpsolve.cc | 124 +++++----- lily/request.cc | 12 +- lily/rest-collision-grav.cc | 19 +- lily/rest-collision.cc | 121 +++++----- lily/rest-column.cc | 2 +- lily/score-align-grav.cc | 21 +- lily/score-align-gravs.cc | 8 +- lily/score-column.cc | 41 ++-- lily/score-elem-info.cc | 8 +- lily/score-elem.cc | 378 ++++++++++++++++-------------- lily/score-grav.cc | 154 ++++++------ lily/score-halign-grav.cc | 16 +- lily/score-performer.cc | 27 ++- lily/score.cc | 170 +++++++------- lily/scoreline.cc | 83 ++++--- lily/scores.cc | 23 +- lily/script-column.cc | 66 +++--- lily/script-def.cc | 48 ++-- lily/script-grav.cc | 27 ++- lily/script.cc | 62 ++--- lily/slur-grav.cc | 46 ++-- lily/slur.cc | 57 ++--- lily/span-bar-grav.cc | 28 ++- lily/span-bar.cc | 66 +++--- lily/span-score-bar-grav.cc | 4 +- lily/span-score-bar.cc | 15 +- lily/spanner-elem-group.cc | 6 +- lily/spanner.cc | 86 +++---- lily/staff-info.cc | 22 +- lily/staff-performer.cc | 38 +-- lily/staff-side.cc | 74 +++--- lily/staff-sym-grav.cc | 16 +- lily/staff-sym.cc | 20 +- lily/super-elem.cc | 21 +- lily/swallow-grav.cc | 2 +- lily/symbol.cc | 10 +- lily/symtable.cc | 23 +- lily/template5.cc | 4 +- lily/tex-beam.cc | 102 ++++---- lily/tex-slur.cc | 242 ++++++++++--------- lily/tex-stream.cc | 54 +++-- lily/tex.cc | 30 +-- lily/text-def.cc | 24 +- lily/text-grav.cc | 29 ++- lily/text-item.cc | 26 +- lily/text-spanner.cc | 46 ++-- lily/tie-grav.cc | 60 +++-- lily/tie.cc | 57 +++-- lily/time-description.cc | 84 +++---- lily/timing-grav.cc | 6 +- lily/translator.cc | 4 +- lily/version.cc | 6 +- lily/vertical-align-elem.cc | 26 +- lily/vertical-align-grav.cc | 19 +- lily/voice-group-gravs.cc | 15 +- lily/warn.cc | 10 +- lily/word-wrap.cc | 60 +++-- mi2mu/mi2mu-version.cc | 6 +- mi2mu/mudela-column.cc | 8 +- mi2mu/mudela-stream.cc | 91 +++---- mi2mu/my-midi-lexer.cc | 41 ++-- mi2mu/version.cc | 2 +- 180 files changed, 5170 insertions(+), 4518 deletions(-) diff --git a/flower/choleski.cc b/flower/choleski.cc index eae3c49cea..4a98301af3 100644 --- a/flower/choleski.cc +++ b/flower/choleski.cc @@ -15,26 +15,28 @@ const Real EPS = 1e-7; // so sue me. Hard coded void Choleski_decomposition::full_matrix_solve (Vector &out, Vector const &rhs)const { - int n= rhs.dim(); - assert (n == L.dim()); - Vector y; - y.set_dim (n); - out.set_dim (n); - - // forward substitution - for (int i=0; i < n; i++) { + int n= rhs.dim(); + assert (n == L.dim()); + Vector y; + y.set_dim (n); + out.set_dim (n); + + // forward substitution + for (int i=0; i < n; i++) + { Real sum (0.0); for (int j=0; j < i; j++) sum += y (j) * L(i,j); y (i) = (rhs (i) - sum)/L(i,i); } - - for (int i=0; i < n; i++) + + for (int i=0; i < n; i++) y (i) /= D(i); - // backward subst - Vector &x (out); // using input as return val. - for (int i=n-1; i >= 0; i--) { + // backward subst + Vector &x (out); // using input as return val. + for (int i=n-1; i >= 0; i--) + { Real sum (0.0); for (int j=i+1; j < n; j++) sum += L(j,i)*x (j); @@ -45,28 +47,30 @@ Choleski_decomposition::full_matrix_solve (Vector &out, Vector const &rhs)const void Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs)const { - int n= rhs.dim(); - int b = L.band_i(); - assert (n == L.dim()); + int n= rhs.dim(); + int b = L.band_i(); + assert (n == L.dim()); - out.set_dim (n); + out.set_dim (n); + + Vector y; + y.set_dim (n); - Vector y; - y.set_dim (n); - - // forward substitution - for (int i=0; i < n; i++) { + // forward substitution + for (int i=0; i < n; i++) + { Real sum (0.0); for (int j= 0 >? i - b; j < i; j++) sum += y (j) * L(i,j); y (i) = (rhs (i) - sum)/L(i,i); } - for (int i=0; i < n; i++) + for (int i=0; i < n; i++) y (i) /= D(i); - // backward subst - Vector &x (out); // using input as return val. - for (int i=n-1; i >= 0; i--) { + // backward subst + Vector &x (out); // using input as return val. + for (int i=n-1; i >= 0; i--) + { Real sum (0.0); for (int j=i+1; j <= i + b&&j < n ; j++) sum += L(j,i)*x (j); @@ -77,18 +81,20 @@ Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs)const void Choleski_decomposition::solve (Vector &x, Vector const &rhs)const { - if (L.band_b()) { + if (L.band_b()) + { band_matrix_solve (x,rhs); - } else + } + else full_matrix_solve (x,rhs); } Vector Choleski_decomposition::solve (Vector rhs)const { - Vector r; - solve (r, rhs); - return r; + Vector r; + solve (r, rhs); + return r; } void @@ -96,14 +102,16 @@ Choleski_decomposition::full_matrix_decompose (Matrix const & P) { int n = P.dim(); - L.unit(); - for (int k= 0; k < n; k++) { - for (int j = 0; j < k; j++){ + L.unit(); + for (int k= 0; k < n; k++) + { + for (int j = 0; j < k; j++) + { Real sum (0.0); for (int l=0; l < j; l++) sum += L(k,l)*L(j,l)*D(l); L(k,j) = (P(k,j) - sum)/D(j); - } + } Real sum=0.0; for (int l=0; l < k; l++) @@ -117,17 +125,19 @@ Choleski_decomposition::full_matrix_decompose (Matrix const & P) void Choleski_decomposition::band_matrix_decompose (Matrix const &P) { - int n = P.dim(); - int b = P.band_i(); - L.unit(); - - for (int i= 0; i < n; i++) { - for (int j = 0 >? i - b; j < i; j++){ + int n = P.dim(); + int b = P.band_i(); + L.unit(); + + for (int i= 0; i < n; i++) + { + for (int j = 0 >? i - b; j < i; j++) + { Real sum (0.0); for (int l=0 >? i - b; l < j; l++) sum += L(i,l)*L(j,l)*D(l); L(i,j) = (P(i,j) - sum)/D(j); - } + } Real sum=0.0; for (int l=0 >? i - b; l < i; l++) @@ -135,8 +145,8 @@ Choleski_decomposition::band_matrix_decompose (Matrix const &P) Real d = P(i,i) - sum; D(i) = d; } - L.try_set_band(); - assert ( L.band_i() == P.band_i ()); + L.try_set_band(); + assert ( L.band_i() == P.band_i ()); } @@ -150,46 +160,47 @@ Choleski_decomposition::Choleski_decomposition (Matrix const & P) : L(P.dim()), D(P.dim ()) { #ifdef PARANOID - assert ((P-P.transposed()).norm ()/P.norm () < EPS); + assert ((P-P.transposed()).norm ()/P.norm () < EPS); #endif - if (P.band_b()) + if (P.band_b()) band_matrix_decompose (P); - else + else full_matrix_decompose (P); #ifdef PARANOID - assert ((original()-P).norm () / P.norm () < EPS); + assert ((original()-P).norm () / P.norm () < EPS); #endif } Matrix Choleski_decomposition::original() const { - Matrix T(L.dim()); - T.set_diag (D); - return L*T*L.transposed(); + Matrix T(L.dim()); + T.set_diag (D); + return L*T*L.transposed(); } Matrix Choleski_decomposition::inverse() const { - int n=L.dim(); - Matrix invm (n); - Vector e_i (n); - Vector inv (n); - for (int i = 0; i < n; i++) { + int n=L.dim(); + Matrix invm (n); + Vector e_i (n); + Vector inv (n); + for (int i = 0; i < n; i++) + { e_i.set_unit (i); solve (inv, e_i); for (int j = 0 ; j=0); - Full_storage f (dim(), 2*s+1); - for (int i=0; i < dim(); i++) { + assert (s>=0); + Full_storage f (dim(), 2*s+1); + for (int i=0; i < dim(); i++) + { int k=-s; for ( ; k < -band_size_i(); k++) f.elem (i,k + s) = 0.0; @@ -61,7 +62,7 @@ Diagonal_storage::set_band_size (int s) f.elem (i, k + s) =0.0; } - band_ = f; + band_ = f; } @@ -72,13 +73,13 @@ Diagonal_storage::set_band_size (int s) void Diagonal_storage::insert_row (int) { - assert (false); + assert (false); } void Diagonal_storage::delete_row (int) { - assert (false); + assert (false); } void @@ -94,9 +95,9 @@ Diagonal_storage::resize (int) void Diagonal_storage::delete_column (int) { - assert (false); + assert (false); } - + Diagonal_storage::~Diagonal_storage() { } @@ -105,27 +106,28 @@ Diagonal_storage::~Diagonal_storage() bool Diagonal_storage::band_elt_b (int i,int j)const { - return abs (i-j) <= band_size_i(); + return abs (i-j) <= band_size_i(); } void Diagonal_storage::assert_valid (int i,int j)const { - assert (band_elt_b (i,j)); - assert (i >=0 && j >=0 && i < dim() && j < dim ()); + assert (band_elt_b (i,j)); + assert (i >=0 && j >=0 && i < dim() && j < dim ()); } void Diagonal_storage::resize_dim (int d) { - Full_storage f (d, 2*band_size_i()+1); - for (int i=0; i < d && i < dim(); i++) { + Full_storage f (d, 2*band_size_i()+1); + for (int i=0; i < d && i < dim(); i++) + { for ( int k=0; k < 2*band_size_i(); k++) f.elem (i,k) = elem (i,k); } - band_ = f; + band_ = f; } @@ -133,16 +135,17 @@ Diagonal_storage::resize_dim (int d) bool Diagonal_storage::mult_ok (int i,int)const { - return i < dim(); + return i < dim(); } void Diagonal_storage::mult_next (int &i, int &j)const { - j++; - if ( j < i - band_size_i()) + j++; + if ( j < i - band_size_i()) j = i- band_size_i(); - if ( j > i + band_size_i() || j >= dim ()) { + if ( j > i + band_size_i() || j >= dim ()) + { i++; j = 0 >? i - band_size_i(); } @@ -151,17 +154,18 @@ Diagonal_storage::mult_next (int &i, int &j)const bool Diagonal_storage::trans_ok (int ,int j)const { - return j < dim(); + return j < dim(); } void Diagonal_storage::trans_next (int &i, int& j)const { - i++; - if ( i < j - band_size_i()) + i++; + if ( i < j - band_size_i()) i = j-band_size_i(); - - if ( i >= dim() || i > j + band_size_i ()) { + + if ( i >= dim() || i > j + band_size_i ()) + { j++; i = 0 >? j - band_size_i(); } @@ -172,23 +176,23 @@ static Real nul_entry=0.0; Real Diagonal_storage::elem (int i, int j)const { - if (abs ( i-j) > band_size_i()) + if (abs ( i-j) > band_size_i()) return 0; - else + else return band_.elem (i, j - i +band_size_i()); } Real & Diagonal_storage::elem (int i, int j) { - /* - if this fails, the previous call fucked up - */ - assert (!nul_entry); + /* + if this fails, the previous call fucked up + */ + assert (!nul_entry); - if (abs ( i-j) > band_size_i()) + if (abs ( i-j) > band_size_i()) return nul_entry; - else + else return band_.elem (i, j - i + band_size_i()); } @@ -200,17 +204,19 @@ bool Diagonal_storage::try_right_multiply (Matrix_storage*dest, const Matrix_storage*right)const { - if ( right->name() != Diagonal_storage::static_name ()) + if ( right->name() != Diagonal_storage::static_name ()) return false; - - const Diagonal_storage* right_diag = (Diagonal_storage const*)right; - int band2 = right_diag->band_size_i(); - int n = dim(); - /* - should check if dest is a Diagonal_storage of sufficient size too. - */ - for (int i=0; i < n; i++) { - for (int j = 0; j < n; j++) { + + const Diagonal_storage* right_diag = (Diagonal_storage const*)right; + int band2 = right_diag->band_size_i(); + int n = dim(); + /* + should check if dest is a Diagonal_storage of sufficient size too. + */ + for (int i=0; i < n; i++) + { + for (int j = 0; j < n; j++) + { int startk = i - band_size_i() >? 0 >? j - band2; int stopk = i + band_size_i() elem (k, j); dest->elem (i, j) = sum; - } + } } - return true; + return true; } IMPLEMENT_IS_TYPE_B1(Diagonal_storage, Matrix_storage); @@ -229,17 +235,17 @@ IMPLEMENT_IS_TYPE_B1(Diagonal_storage, Matrix_storage); Diagonal_storage::Diagonal_storage (Matrix_storage*stor_l, int band_i) { - set_band_size (band_i); - resize_dim (stor_l->dim()); + set_band_size (band_i); + resize_dim (stor_l->dim()); - for ( int i=0,j=0; mult_ok (i,j); mult_next (i,j)) + for ( int i=0,j=0; mult_ok (i,j); mult_next (i,j)) band_.elem (i, j + band_i -i) = stor_l->elem (i,j); } void Diagonal_storage::OK() const { - band_.OK(); + band_.OK(); } IMPLEMENT_VIRTUAL_COPY_CONS(Diagonal_storage, Matrix_storage); diff --git a/flower/directed-graph.cc b/flower/directed-graph.cc index 2c55688011..46511b4c31 100644 --- a/flower/directed-graph.cc +++ b/flower/directed-graph.cc @@ -18,13 +18,13 @@ Link_array const & Directed_graph_node::get_in_edge_arr() const { - return edge_in_l_arr_; + return edge_in_l_arr_; } Link_array const & Directed_graph_node::get_out_edge_arr()const { - return edge_out_l_arr_; + return edge_out_l_arr_; } /** @@ -37,7 +37,7 @@ Directed_graph_node::Directed_graph_node (Directed_graph_node const&) void Directed_graph_node::copy_edges_out (Directed_graph_node const &s) { - for (int i=0; i < s.edge_out_l_arr_.size(); i++) + for (int i=0; i < s.edge_out_l_arr_.size(); i++) add (s.edge_out_l_arr_[i]); } @@ -45,11 +45,12 @@ void Directed_graph_node::OK() const { #ifndef NDEBUG - for (int i=0; i < edge_out_l_arr_.size(); i++) { + for (int i=0; i < edge_out_l_arr_.size(); i++) + { assert (edge_out_l_arr_[i]-> edge_in_l_arr_.find_l (this)); } - for (int i=0; i < edge_in_l_arr_.size(); i++) + for (int i=0; i < edge_in_l_arr_.size(); i++) assert (edge_in_l_arr_[i]->contains_b (this)); #endif } @@ -57,52 +58,53 @@ Directed_graph_node::OK() const bool Directed_graph_node::contains_b (const Directed_graph_node *d)const { - return edge_out_l_arr_.find_l ((Directed_graph_node*)d); + return edge_out_l_arr_.find_l ((Directed_graph_node*)d); } - + void Directed_graph_node::remove_edge_out_idx (int i) { - PARANOID_OK(); - Directed_graph_node * d_l = edge_out_l_arr_.get (i); + PARANOID_OK(); + Directed_graph_node * d_l = edge_out_l_arr_.get (i); - int j = d_l->edge_in_l_arr_.find_i (this); - assert (j>=0); - d_l->edge_in_l_arr_.unordered_del (j); - PARANOID_OK(); + int j = d_l->edge_in_l_arr_.find_i (this); + assert (j>=0); + d_l->edge_in_l_arr_.unordered_del (j); + PARANOID_OK(); } void Directed_graph_node::remove_edge_in (Directed_graph_node *d_l) { - PARANOID_OK(); - d_l->remove_edge_out (this); - PARANOID_OK(); + PARANOID_OK(); + d_l->remove_edge_out (this); + PARANOID_OK(); } void Directed_graph_node::remove_edge_out (Directed_graph_node *d_l) { - PARANOID_OK(); - for (int i=0; i < edge_out_l_arr_.size();) { + PARANOID_OK(); + for (int i=0; i < edge_out_l_arr_.size();) + { if (edge_out_l_arr_[i]== d_l) remove_edge_out_idx (i); else i++; } - PARANOID_OK(); + PARANOID_OK(); } bool Directed_graph_node::linked_b()const { - return edge_out_l_arr_.size() || edge_in_l_arr_.size (); + return edge_out_l_arr_.size() || edge_in_l_arr_.size (); } void Directed_graph_node::junk_links() { - edge_in_l_arr_.set_size (0); - edge_out_l_arr_.set_size (0); + edge_in_l_arr_.set_size (0); + edge_out_l_arr_.set_size (0); } @@ -130,21 +132,21 @@ Directed_graph_node::unlink() Directed_graph_node::~Directed_graph_node() { - assert (!linked_b()); + assert (!linked_b()); } - + void Directed_graph_node::add (Directed_graph_node* dep_l) { - PARANOID_OK(); - if (!dep_l) + PARANOID_OK(); + if (!dep_l) return ; - dep_l->edge_in_l_arr_.push (this); - edge_out_l_arr_.push (dep_l); - PARANOID_OK(); + dep_l->edge_in_l_arr_.push (this); + edge_out_l_arr_.push (dep_l); + PARANOID_OK(); } - + Directed_graph_node::Directed_graph_node() { diff --git a/flower/dstream.cc b/flower/dstream.cc index f6d1d48867..f11576d590 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -23,88 +23,91 @@ const INDTAB = 2; static String strip_pretty (String pretty_str) { - int i = pretty_str.index_i ('('); - if (i>=0) + int i = pretty_str.index_i ('('); + if (i>=0) pretty_str = pretty_str.left_str (i); - - int l = pretty_str.index_last_i (' '); // strip until last ' ' - if (l>=0) + + int l = pretty_str.index_last_i (' '); // strip until last ' ' + if (l>=0) pretty_str = pretty_str.nomid_str (0,l+1); - return pretty_str; + return pretty_str; } static String strip_member (String pret) { - int l=pret.index_last_i (':')-1; - if (l>=0) + int l=pret.index_last_i (':')-1; + if (l>=0) pret = pret.left_str (l); - return pret; + return pret; } Dstream& Dstream::identify_as (String name) { - if (!os_l_) + if (!os_l_) return *this; - - String mem (strip_pretty (name)); - String cl (strip_member (mem)); - String idx = cl; - - if (silent_assoc_p_->elt_b (mem)) + + String mem (strip_pretty (name)); + String cl (strip_member (mem)); + String idx = cl; + + if (silent_assoc_p_->elt_b (mem)) idx = mem; - else if (silent_assoc_p_->elt_b (cl)) + else if (silent_assoc_p_->elt_b (cl)) idx = cl; - else { + else + { (*silent_assoc_p_)[idx] = false; } - local_silence_b_ = (*silent_assoc_p_)[idx]; - if (current_classname_str_ != idx && !local_silence_b_) { + local_silence_b_ = (*silent_assoc_p_)[idx]; + if (current_classname_str_ != idx && !local_silence_b_) + { current_classname_str_=idx; if (!(*silent_assoc_p_)["Dstream"]) *os_l_ << "[" << current_classname_str_ << ":]"; // messy. } - return *this; + return *this; } bool Dstream::silence (String s) { - if (!silent_assoc_p_->elt_b (s)) + if (!silent_assoc_p_->elt_b (s)) return false; - return (*silent_assoc_p_)[s]; + return (*silent_assoc_p_)[s]; } Dstream & Dstream::operator<<(String s) { - output (s); - return *this; + output (s); + return *this; } Dstream & Dstream::operator<<(void const *v_l) { - output (String_convert::pointer_str (v_l)); - return *this; + output (String_convert::pointer_str (v_l)); + return *this; } Dstream & Dstream::operator<<(char const *ch_l) { - output (ch_l); - return *this; + output (ch_l); + return *this; } void Dstream::output (String s) { - if (local_silence_b_|| !os_l_) + if (local_silence_b_|| !os_l_) return ; - - for (char const *cp = s ; *cp; cp++) - switch (*cp) { + + for (char const *cp = s ; *cp; cp++) + switch (*cp) + { case '{': case '[': case '(': indent_level_i_ += INDTAB; @@ -126,33 +129,34 @@ Dstream::output (String s) default: *os_l_ << *cp; break; - } - return ; + } + return ; } Dstream::Dstream (ostream *r, char const * cfg_nm) { - os_l_ = r; - silent_assoc_p_ = new Assoc; - indent_level_i_ = 0; - if (!os_l_) + os_l_ = r; + silent_assoc_p_ = new Assoc; + indent_level_i_ = 0; + if (!os_l_) return; - - char const * fn =cfg_nm ? cfg_nm : ".dstreamrc"; - { + + char const * fn =cfg_nm ? cfg_nm : ".dstreamrc"; + { ifstream ifs (fn); // can't open if (!ifs) return; } - Text_db cfg (fn); - while (! cfg.eof()){ + Text_db cfg (fn); + while (! cfg.eof()){ Text_record r (cfg++); - if (r.size() != 2) { + if (r.size() != 2) + { r.message ("not enough fields in Dstream init."); continue; - } + } (*silent_assoc_p_)[r[0]] = (bool)(int)(Scalar (r[1])); } @@ -161,14 +165,15 @@ Dstream::Dstream (ostream *r, char const * cfg_nm) Dstream::~Dstream() { - delete silent_assoc_p_; - assert (!indent_level_i_) ; + delete silent_assoc_p_; + assert (!indent_level_i_) ; } void Dstream::clear_silence() { - for (Assoc_iter i (*silent_assoc_p_); i.ok(); i++) { + for (Assoc_iter i (*silent_assoc_p_); i.ok(); i++) + { i.val() = 0; } } diff --git a/flower/flower-debug.cc b/flower/flower-debug.cc index 5ea5e50dc0..52156f983a 100644 --- a/flower/flower-debug.cc +++ b/flower/flower-debug.cc @@ -13,11 +13,11 @@ Dstream *flower_dstream = &default_flower_stream; void set_flower_debug (Dstream&ds, bool b) { #ifdef NPRINT - if (b) + if (b) cout << "Debug printout disabled, see the installation guide." << endl; #endif - - flower_check_debug = b; - flower_dstream = &ds; + + flower_check_debug = b; + flower_dstream = &ds; } diff --git a/flower/flower-version.cc b/flower/flower-version.cc index 84cfd803d3..6372f50277 100644 --- a/flower/flower-version.cc +++ b/flower/flower-version.cc @@ -10,7 +10,7 @@ static const int build= char const * flower_version_sz() { - static char v[1024]; - sprintf (v, s, build); - return v; + static char v[1024]; + sprintf (v, s, build); + return v; } diff --git a/flower/full-storage.cc b/flower/full-storage.cc index 34dcdad1b8..ee59ea23ed 100644 --- a/flower/full-storage.cc +++ b/flower/full-storage.cc @@ -12,10 +12,10 @@ void Full_storage::operator=(Full_storage const &fs) { - resize (fs.height_i_, fs.width_i_); - OK(); - fs.OK(); - for (int i=0; i= height_i_ && max_width_i_ >= width_i_); - assert (height_i_ >= 0 && width_i_ >= 0); - assert (els_p_p_||!max_height_i_); + assert (max_height_i_ >= height_i_ && max_width_i_ >= width_i_); + assert (height_i_ >= 0 && width_i_ >= 0); + assert (els_p_p_||!max_height_i_); #endif } @@ -37,18 +37,18 @@ Full_storage::OK() const Full_storage::~Full_storage() { - for (int i=0; i < max_height_i_; i++) + for (int i=0; i < max_height_i_; i++) delete [] els_p_p_[i]; - delete[] els_p_p_; + delete[] els_p_p_; } void Full_storage::resize (int rows, int cols) { - OK(); - resize_cols (rows); - resize_rows (cols); + OK(); + resize_cols (rows); + resize_rows (cols); } @@ -56,14 +56,14 @@ Full_storage::resize (int rows, int cols) bool Full_storage::mult_ok (int i, int) const { - return i < height_i_; + return i < height_i_; } bool Full_storage::trans_ok (int , int j) const { - return j < width_i_; + return j < width_i_; } @@ -71,9 +71,10 @@ Full_storage::trans_ok (int , int j) const void Full_storage::trans_next (int &i, int &j) const { - assert (trans_ok (i,j)); - i++; - if (i >= height_i_) { + assert (trans_ok (i,j)); + i++; + if (i >= height_i_) + { i=0; j ++; } @@ -83,9 +84,10 @@ Full_storage::trans_next (int &i, int &j) const void Full_storage::mult_next (int &i, int &j) const { - assert (mult_ok (i,j)); - j++; - if (j >= width_i_) { + assert (mult_ok (i,j)); + j++; + if (j >= width_i_) + { j=0; i++; } @@ -95,22 +97,22 @@ Full_storage::mult_next (int &i, int &j) const void Full_storage::delete_column (int k) { - assert (0 <= k &&k k ; i--) + assert (0 <= k&& k <=height_i_); + resize_cols (height_i_+1); + for (int i=height_i_-1; i > k ; i--) for (int j=0; j name() != Full_storage::static_name () || + if (dest->name() != Full_storage::static_name () || right->name() != Full_storage::static_name ()) return false; - Full_storage *d_l = (Full_storage*)dest; - Full_storage *r_l = (Full_storage*)right; - - d_l->set_size (height_i_, r_l->width_i_); - for (int i=0; i < d_l->height_i_; i++) - for (int j = 0; j < d_l->width_i_; j++) { + Full_storage *d_l = (Full_storage*)dest; + Full_storage *r_l = (Full_storage*)right; + + d_l->set_size (height_i_, r_l->width_i_); + for (int i=0; i < d_l->height_i_; i++) + for (int j = 0; j < d_l->width_i_; j++) + { Real &r (d_l->els_p_p_[i][j]); r=0.0; for (int k = 0; k < width_i_; k++) r += els_p_p_[i][k] * r_l->els_p_p_[k][j]; - } - return true; - - + } + return true; + + } IMPLEMENT_IS_TYPE_B1(Full_storage,Matrix_storage); void Full_storage::resize_cols (int newh) { - if (newh <= max_height_i_) { + if (newh <= max_height_i_) + { height_i_=newh; return; } - Real ** newa=new Real*[newh]; - int j=0; - for (; j < height_i_; j++) + Real ** newa=new Real*[newh]; + int j=0; + for (; j < height_i_; j++) newa[j] = els_p_p_[j]; - for (; j < newh; j++) + for (; j < newh; j++) newa[j] = new Real[max_width_i_]; - delete[] els_p_p_; - els_p_p_=newa; + delete[] els_p_p_; + els_p_p_=newa; - height_i_ = max_height_i_ = newh; + height_i_ = max_height_i_ = newh; } Full_storage::Full_storage (Matrix_storage*m) { - set_size (m->rows(), m->cols ()); - if ( !m->is_type_b ( Full_storage::static_name())) + set_size (m->rows(), m->cols ()); + if ( !m->is_type_b ( Full_storage::static_name())) for (int i=0; imult_ok (i,j); m->mult_next (i,j)) + for (int i,j=0; m->mult_ok (i,j); m->mult_next (i,j)) els_p_p_[i][j] = m->elem (i,j); } @@ -187,11 +191,13 @@ Full_storage::Full_storage (Matrix_storage*m) void Full_storage::resize_rows (int neww) { - if (neww <= max_width_i_) { + if (neww <= max_width_i_) + { width_i_=neww; return; } - for (int i=0; i < max_height_i_ ; i++) { + for (int i=0; i < max_height_i_ ; i++) + { Real* newa = new Real[neww]; for (int k=0; k < width_i_; k++) newa[k] = els_p_p_[i][k]; @@ -199,7 +205,7 @@ Full_storage::resize_rows (int neww) delete[] els_p_p_[i]; els_p_p_[i] = newa; } - width_i_ = max_width_i_ = neww; + width_i_ = max_width_i_ = neww; } #ifdef INLINE diff --git a/flower/include/cursor.icc b/flower/include/cursor.icc index d0b2439af4..4fce0b1953 100644 --- a/flower/include/cursor.icc +++ b/flower/include/cursor.icc @@ -20,126 +20,126 @@ inline Cursor::Cursor() : list_(*(List *)0) // ugh { - pointer_ = 0; + pointer_ = 0; } template inline Cursor::Cursor (const List& list, Link* pointer) : - list_((List&) list) + list_((List&) list) { - if ( list.size()) - pointer_ = pointer ? pointer : list.top_; - else - pointer_ = pointer; + if ( list.size()) + pointer_ = pointer ? pointer : list.top_; + else + pointer_ = pointer; } template inline Cursor::Cursor (const Cursor& cursor) : - list_( cursor.list_) + list_( cursor.list_) { - pointer_ = cursor.pointer_; + pointer_ = cursor.pointer_; } template inline T& Cursor::thing() { - assert (pointer_); - return pointer_->thing(); + assert (pointer_); + return pointer_->thing(); } template Cursor Cursor::operator =( const Cursor& c) { - assert (&list_ == &c.list_); - pointer_ = c.pointer_; - return *this; + assert (&list_ == &c.list_); + pointer_ = c.pointer_; + return *this; } template inline void Cursor::add (const T& th) { - list_.add (th, *this); + list_.add (th, *this); } template inline void Cursor::insert (const T& th) { - list_.insert (th, *this); + list_.insert (th, *this); } template inline List& Cursor::list() const { - return list_; + return list_; } template inline Link* Cursor::pointer() { - return pointer_; + return pointer_; } template inline bool Cursor::backward()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline bool Cursor::forward()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline bool Cursor::ok()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline void Cursor::next() { - assert (pointer_); - pointer_ = pointer_->next(); + assert (pointer_); + pointer_ = pointer_->next(); } template inline Cursor Cursor::operator ++( int) { - Cursor r (*this); - next(); - return r; + Cursor r (*this); + next(); + return r; } template inline void Cursor::previous() { - assert (pointer_); - pointer_ = pointer_->previous(); + assert (pointer_); + pointer_ = pointer_->previous(); } template inline Cursor Cursor::operator --( int) { - Cursor r (*this); - previous(); - return r; + Cursor r (*this); + previous(); + return r; } diff --git a/flower/include/cursor.tcc b/flower/include/cursor.tcc index 18f1fbb42a..4bf6347a1d 100644 --- a/flower/include/cursor.tcc +++ b/flower/include/cursor.tcc @@ -8,21 +8,21 @@ template void Cursor::backspace() { - Cursor c (*this); - if ( c.ok()) + Cursor c (*this); + if ( c.ok()) c--; - list_.remove (*this); + list_.remove (*this); } template void Cursor::del() { - Cursor c (*this); - if ( c.ok()) + Cursor c (*this); + if ( c.ok()) c++; - list_.remove (*this); - *this = c; + list_.remove (*this); + *this = c; } @@ -30,46 +30,46 @@ template Cursor Cursor::operator -=( int j) { - while (j--) + while (j--) (*this)--; - return *this; + return *this; } template Cursor Cursor::operator +=( int j) { - while (j++) + while (j++) (*this)++; - return *this; + return *this; } template Cursor Cursor::operator +( int i) const { - Cursor r = *this; + Cursor r = *this; - if (i<0) + if (i<0) return r -(-i); - while (i--) + while (i--) r++; - return r; + return r; } template Cursor Cursor::operator -( int i) const { - Cursor r = *this; - if (i<0) + Cursor r = *this; + if (i<0) return r +(-i); - while (i--) + while (i--) r--; - - return r; + + return r; } /* warning: can't use Cursor::operator == (Cursor), @@ -79,31 +79,33 @@ template int Cursor::operator-(Cursor rhs) const { - assert (rhs.list == list); - int dif = 0; + assert (rhs.list == list); + int dif = 0; - // search from *this on further up (positive difference) - Cursor c (*this); - while (c.ok() && c.pointer_ != rhs.pointer_) { + // search from *this on further up (positive difference) + Cursor c (*this); + while (c.ok() && c.pointer_ != rhs.pointer_) + { c--; dif++; } - - if (c.ok()) + + if (c.ok()) goto gotcha; // so, sue me. - // search in direction of bottom. (negative diff) - dif =0; - c=*this; - while (c.ok() && c.pointer_ !=rhs.pointer_) { + // search in direction of bottom. (negative diff) + dif =0; + c=*this; + while (c.ok() && c.pointer_ !=rhs.pointer_) + { dif --; c++; } - assert (c.ok()); + assert (c.ok()); gotcha: - assert ((*this - dif).pointer_ == c.pointer_); - return dif; + assert ((*this - dif).pointer_ == c.pointer_); + return dif; } #endif diff --git a/flower/include/full-storage.icc b/flower/include/full-storage.icc index d71dbe07e7..0e45f15b24 100644 --- a/flower/include/full-storage.icc +++ b/flower/include/full-storage.icc @@ -14,13 +14,13 @@ INLINE void Full_storage::init() { - els_p_p_=0; - height_i_=width_i_=max_height_i_=max_width_i_=0; + els_p_p_=0; + height_i_=width_i_=max_height_i_=max_width_i_=0; } INLINE bool Full_storage::valid (int i, int j)const { - return (i>=0 && i < height_i_) + return (i>=0 && i < height_i_) && (j < width_i_ && j >=0); } @@ -28,64 +28,64 @@ Full_storage::valid (int i, int j)const INLINE Full_storage::Full_storage (Full_storage const&s) { - init(); - (*this) = s; + init(); + (*this) = s; } INLINE Real& Full_storage::elem (int i,int j) { - assert (valid (i,j)); - return els_p_p_[i][j]; + assert (valid (i,j)); + return els_p_p_[i][j]; } INLINE Real Full_storage::elem (int i, int j) const { - assert (valid (i,j)); - return els_p_p_[i][j]; + assert (valid (i,j)); + return els_p_p_[i][j]; } INLINE Full_storage::Full_storage() { - init(); + init(); } INLINE int Full_storage::rows() const { - return height_i_; + return height_i_; } INLINE int Full_storage::cols() const { - return width_i_; + return width_i_; } INLINE int Full_storage::dim()const { - assert (rows()==cols ()); - return rows(); + assert (rows()==cols ()); + return rows(); } INLINE void Full_storage::resize (int i) { - resize (i,i); + resize (i,i); } INLINE Full_storage::Full_storage (int i,int j) { - init(); - set_size (i,j); + init(); + set_size (i,j); } INLINE Full_storage::Full_storage (int i) { - init(); - set_size (i); + init(); + set_size (i); } INLINE diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index efb7644133..50864b7894 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -20,60 +20,60 @@ template int _Interval__compare (const Interval_t&a,Interval_t const&b) { - if (a.left == b.left && a.right == b.right) + if (a.left == b.left && a.right == b.right) return 0; - - if (a.left <= b.left && a.right >= b.right) + + if (a.left <= b.left && a.right >= b.right) return 1; - if (a.left >= b.left && a.right <= b.right) + if (a.left >= b.left && a.right <= b.right) return -1; - return -2; + return -2; } template bool Interval_t::contains_b (Interval_t const& a)const { - int c_i= _Interval__compare (*this, a); - if (c_i == -2) + int c_i= _Interval__compare (*this, a); + if (c_i == -2) return false; - return c_i >= 0; + return c_i >= 0; } template int Interval__compare (const Interval_t&a,Interval_t const&b) { - int i = _Interval__compare (a,b); - if (i < -1) + int i = _Interval__compare (a,b); + if (i < -1) assert (false); - return i; + return i; } template void Interval_t::set_empty() { - left = (T) infinity(); - right = (T) -infinity(); + left = (T) infinity(); + right = (T) -infinity(); } template T Interval_t::length() const { - assert (right >= left); - return right-left; + assert (right >= left); + return right-left; } template void Interval_t::unite (Interval_t h) { - if (h.leftright) + if (h.right>right) right = h.right; } @@ -86,11 +86,11 @@ void Interval_t::intersect (Interval_t h) { #if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - left = h.left >? left; - right = h.right ? left; + right = h.right Interval_t intersect (Interval_t x, Interval_t const &y) { - x.intersect (y); - return x; + x.intersect (y); + return x; } template String Interval_t::str() const { - if (empty_b()) + if (empty_b()) return "[empty]"; - String s ("["); + String s ("["); - return s + String (left) + String ("," ) + String (right ) + String ("]" ); + return s + String (left) + String ("," ) + String (right ) + String ("]" ); } template bool Interval_t::elt_b (T r) { - return r >= left && r <= right; + return r >= left && r <= right; } diff --git a/flower/include/link.icc b/flower/include/link.icc index 68b87a73fc..7699f1dfbc 100644 --- a/flower/include/link.icc +++ b/flower/include/link.icc @@ -8,10 +8,12 @@ void Link::OK() const { #ifndef NDEBUG - if (previous_) { + if (previous_) + { assert (previous_->next_ == this); } - if (next_) { + if (next_) + { assert (next_->previous_ == this); } #endif @@ -20,18 +22,18 @@ Link::OK() const template inline Link::Link (const T& thing) : - thing_( thing) + thing_( thing) { - previous_ = next_ = 0; + previous_ = next_ = 0; } template inline Link::Link (Link* previous, Link* next, const T& thing) : - thing_( thing) + thing_( thing) { - previous_ = previous; - next_ = next; + previous_ = previous; + next_ = next; } template @@ -39,7 +41,7 @@ inline Link* Link::next() { - return next_; + return next_; } template @@ -47,7 +49,7 @@ inline Link* Link::previous() { - return previous_; + return previous_; } template @@ -55,40 +57,40 @@ inline void Link::add (const T& thing) { - - Link* l = new Link( this, next_, thing); - if ( next_) - next_->previous_ = l; - next_ = l; + + Link* l = new Link( this, next_, thing); + if ( next_) + next_->previous_ = l; + next_ = l; } template inline void Link::insert (const T& thing) { - // Link* l = new Link( next_, this, thing); + // Link* l = new Link( next_, this, thing); // bugfix hwn 16/9/96 - Link* l = new Link( previous_, this, thing); - if ( previous_) - previous_->next_ = l; - previous_ = l; + Link* l = new Link( previous_, this, thing); + if ( previous_) + previous_->next_ = l; + previous_ = l; } /* - don't forget to adjust #l#'s top_ and bottom_. - */ + don't forget to adjust #l#'s top_ and bottom_. + */ template inline void Link::remove (List &l) { - if ( previous_) - previous_->next_ = next_; - else + if ( previous_) + previous_->next_ = next_; + else l.top_ = next_; - if ( next_) - next_->previous_ = previous_; - else + if ( next_) + next_->previous_ = previous_; + else l.bottom_ = previous_; } @@ -97,6 +99,6 @@ inline T& Link::thing() { - return thing_; + return thing_; } #endif diff --git a/flower/include/list.icc b/flower/include/list.icc index 83ec3aa796..80d12f56ba 100644 --- a/flower/include/list.icc +++ b/flower/include/list.icc @@ -7,26 +7,27 @@ template inline List::List() { - set_empty(); + set_empty(); } template inline void List::set_empty() { - top_ = bottom_ = 0; - size_ = 0; + top_ = bottom_ = 0; + size_ = 0; } template inline void List::remove (Cursor me) { - if ( me.ok()){ + if ( me.ok()) + { Link *lp = me.pointer(); lp->remove (*this); delete lp; - size_--; + size_--; } } @@ -34,14 +35,14 @@ template inline int List::size() const { - return size_; + return size_; } template inline Cursor List::top()const { - return Cursor( *this, top_); + return Cursor( *this, top_); } @@ -49,7 +50,7 @@ template inline Cursor List::bottom()const { - return Cursor( *this, bottom_); + return Cursor( *this, bottom_); } diff --git a/flower/include/list.tcc b/flower/include/list.tcc index fb64cd3ee0..1233c4821d 100644 --- a/flower/include/list.tcc +++ b/flower/include/list.tcc @@ -18,9 +18,9 @@ template List::List (List const&src) { - set_empty(); - // probably el stupido - for (Cursor c (src); c.ok(); c++) + set_empty(); + // probably el stupido + for (Cursor c (src); c.ok(); c++) bottom().add (c); } @@ -28,37 +28,39 @@ template void List::OK() const { - int i = size_; - Link *lp = top_; - while (i--) { + int i = size_; + Link *lp = top_; + while (i--) + { assert (lp); lp->OK(); lp = lp->next(); } - assert (!lp); - i = size_; - lp = bottom_; - while (i--) { + assert (!lp); + i = size_; + lp = bottom_; + while (i--) + { assert (lp); lp->OK(); lp = lp->previous(); } - assert (!lp); + assert (!lp); } template void List::junk_links() { - Cursor c (*this); - while (c.ok()) + Cursor c (*this); + while (c.ok()) c.del(); } template List::~List() { - junk_links(); + junk_links(); } /** @@ -77,11 +79,12 @@ template void List::add (T const & thing, Cursor &after_me) { - if (!size_) { // not much choice if list is empty - bottom_ = top_ = new Link( thing); + if (!size_) { // not much choice if list is empty + bottom_ = top_ = new Link( thing); if (!after_me.ok()) after_me = bottom(); - } else { // add at aprioprate place + } + else { // add at aprioprate place if (!after_me.ok()) after_me = bottom(); Link *p =after_me.pointer(); @@ -90,19 +93,22 @@ List::add (T const & thing, Cursor &after_me) bottom_ = p->next(); } - size_++; + size_++; } template void List::insert (T const & thing, Cursor &before_me) { - if (!size_) { + if (!size_) + { bottom_ = top_ = new Link( thing); if (!before_me.ok()) before_me = top(); - } else { + } + else + { if (!before_me.ok()) before_me = top(); @@ -113,7 +119,7 @@ List::insert (T const & thing, Cursor &before_me) top_ = p->previous(); } - size_++; + size_++; } @@ -121,8 +127,9 @@ template void List::concatenate (List const&s) { - Cursor b (bottom()); - for (Cursor c (s); c.ok(); c++) { + Cursor b (bottom()); + for (Cursor c (s); c.ok(); c++) + { b.add (c); b++; } diff --git a/flower/include/pcursor.tcc b/flower/include/pcursor.tcc index e8de3d5da1..c2b459a267 100644 --- a/flower/include/pcursor.tcc +++ b/flower/include/pcursor.tcc @@ -5,12 +5,12 @@ void PCursor::junk() { #if !defined (NDEBUG) && defined (PARANOID) - list().OK(); + list().OK(); #endif - delete ptr(); + delete ptr(); #if !defined (NDEBUG)&&defined (PARANOID) - thing() = 0; - list().OK(); + thing() = 0; + list().OK(); #endif } diff --git a/flower/include/plist.icc b/flower/include/plist.icc index f4a3713761..7fda7abb2c 100644 --- a/flower/include/plist.icc +++ b/flower/include/plist.icc @@ -11,7 +11,8 @@ template void PL_copy (Pointer_list &to, Pointer_list const&src) { - for (PCursor pc (src); pc.ok(); pc++) { + for (PCursor pc (src); pc.ok(); pc++) + { T *q = pc; T *p=new T(*q) ; to.bottom().add (p); diff --git a/flower/include/plist.tcc b/flower/include/plist.tcc index f7733d508d..07c1a0118f 100644 --- a/flower/include/plist.tcc +++ b/flower/include/plist.tcc @@ -9,8 +9,9 @@ template void Pointer_list::junk() { - PCursor c (*this); - while (c.ok()) { + PCursor c (*this); + while (c.ok()) + { delete c.remove_p(); } } @@ -19,9 +20,9 @@ template PCursor Link_list::find (T what) const { - PCursor i (*this); - for (; i.ok(); i++) + PCursor i (*this); + for (; i.ok(); i++) if (i.ptr() == what) break; - return i; + return i; } diff --git a/flower/include/pointer.tcc b/flower/include/pointer.tcc index c35f92c497..5eed1f4ef6 100644 --- a/flower/include/pointer.tcc +++ b/flower/include/pointer.tcc @@ -15,7 +15,7 @@ inline T * P::copy_p()const { - return t_p? new T(*t_p) : 0; + return t_p? new T(*t_p) : 0; } template @@ -23,7 +23,7 @@ inline void P::copy (T const *l_C) { - t_p = l_C ? new T(*l_C) : 0; + t_p = l_C ? new T(*l_C) : 0; } template @@ -31,15 +31,15 @@ inline void P::junk() { - delete t_p; - t_p =0; + delete t_p; + t_p =0; } template inline P::P(P const &s) { - t_p = s.copy_p(); + t_p = s.copy_p(); } template @@ -47,15 +47,15 @@ inline P & P::operator =(P const&s) { - junk(); - copy (s.t_p); - return *this; + junk(); + copy (s.t_p); + return *this; } template inline P::~P() { - junk(); + junk(); } template @@ -63,11 +63,11 @@ inline void P::set_p (T * np) { - if (np == t_p) + if (np == t_p) return; - delete t_p; - - t_p = np; + delete t_p; + + t_p = np; } @@ -76,11 +76,11 @@ inline void P::set_l (T const * l_C) { - if (t_p == l_C) + if (t_p == l_C) return; - - junk(); - copy (l_C); + + junk(); + copy (l_C); } diff --git a/flower/include/string-data.icc b/flower/include/string-data.icc index 2a285db24f..6a88eef8c9 100644 --- a/flower/include/string-data.icc +++ b/flower/include/string-data.icc @@ -20,53 +20,54 @@ const int INITIALMAX=8; INLINE void String_data::OKW() { - assert (references == 1); + assert (references == 1); } INLINE void String_data::OK() { - assert (maxlen >= length_i_); - assert (bool (data_byte_p_)); - assert (references >= 1); + assert (maxlen >= length_i_); + assert (bool (data_byte_p_)); + assert (references >= 1); } INLINE String_data::String_data() { - references=0; - maxlen = INITIALMAX; - data_byte_p_ = new Byte[maxlen + 1]; - data_byte_p_[0] = 0; - length_i_ = 0; + references=0; + maxlen = INITIALMAX; + data_byte_p_ = new Byte[maxlen + 1]; + data_byte_p_[0] = 0; + length_i_ = 0; } INLINE String_data::String_data (String_data const &src) { - references=0; - maxlen = length_i_ = src.length_i_; - data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. - memcpy (data_byte_p_, src.data_byte_p_, length_i_ + 1); + references=0; + maxlen = length_i_ = src.length_i_; + data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. + memcpy (data_byte_p_, src.data_byte_p_, length_i_ + 1); } INLINE String_data::~String_data() { - assert (references == 0); - delete[] data_byte_p_; + assert (references == 0); + delete[] data_byte_p_; } INLINE void String_data::setmax (int j) { - OKW(); - if (j > maxlen) { + OKW(); + if (j > maxlen) + { delete data_byte_p_; maxlen = j; data_byte_p_ = new Byte[maxlen + 1]; - + data_byte_p_[0] = 0; length_i_ = 0; } @@ -84,8 +85,9 @@ String_data::setmax (int j) INLINE void String_data::remax (int j) { - OKW(); - if (j > maxlen) { + OKW(); + if (j > maxlen) + { Byte *p = new Byte[j + 1]; memcpy (p, data_byte_p_, ( maxlen = 0 && j <= length_i_); - data_byte_p_[j] = 0; - length_i_ = j; + OKW(); + assert (j >= 0 && j <= length_i_); + data_byte_p_[j] = 0; + length_i_ = j; } INLINE bool String_data::is_binary_bo()const { // return !memchr (data_byte_p_, length_i_, 0); - return ( (int)strlen ((char const*)data_byte_p_) != length_i_ ); + return ( (int)strlen ((char const*)data_byte_p_) != length_i_ ); } INLINE Byte& String_data::operator [](int j) { - assert (j >= 0 && j <= length_i_); - return data_byte_p_[j] ; + assert (j >= 0 && j <= length_i_); + return data_byte_p_[j] ; } INLINE Byte String_data::operator [](int j) const { - assert (j >= 0 && j <= length_i_); - return data_byte_p_[j]; + assert (j >= 0 && j <= length_i_); + return data_byte_p_[j]; } diff --git a/flower/include/string-handle.icc b/flower/include/string-handle.icc index e398e0a4ed..0f97839d82 100644 --- a/flower/include/string-handle.icc +++ b/flower/include/string-handle.icc @@ -19,20 +19,21 @@ INLINE void String_handle::down() { - if (!(--data->references)) delete data; data = 0; + if (!(--data->references)) delete data; data = 0; } /// increase ref count INLINE void String_handle::up (String_data *d) { - data=d; data->references ++; + data=d; data->references ++; } INLINE void String_handle::copy() { - if (data->references !=1){ + if (data->references !=1) + { String_data *newdata = new String_data (*data); down(); up (newdata); @@ -42,68 +43,68 @@ String_handle::copy() INLINE String_handle::String_handle() { - up (new String_data); + up (new String_data); } INLINE String_handle::~String_handle() { - down(); + down(); } INLINE String_handle::String_handle (String_handle const & src) { - up (src.data); + up (src.data); } INLINE Byte* String_handle::byte_l() { - copy(); - return data->byte_l(); + copy(); + return data->byte_l(); } INLINE char* String_handle::ch_l() { - copy(); - return (char*)data->byte_l(); + copy(); + return (char*)data->byte_l(); } INLINE Byte const* String_handle::byte_C() const { - return data->byte_C(); + return data->byte_C(); } INLINE char const* String_handle::ch_C() const { - return (char const*)data->byte_C(); + return (char const*)data->byte_C(); } INLINE void String_handle::operator =(String_handle const &src) { - if (this == &src) + if (this == &src) return; - down(); - up (src.data); + down(); + up (src.data); } INLINE void String_handle::operator += (char const *s) { - copy(); - *data += s; + copy(); + *data += s; } INLINE Byte String_handle::operator[](int j) const { - return (*data)[j]; + return (*data)[j]; } // !NOT SAFE! @@ -111,46 +112,46 @@ String_handle::operator[](int j) const INLINE Byte & String_handle::operator[](int j) { - copy(); // hmm. Not efficient - return data->byte_l()[j]; + copy(); // hmm. Not efficient + return data->byte_l()[j]; } INLINE void String_handle::append (Byte const* byte_C, int length_i) { - copy(); - data->append (byte_C, length_i); + copy(); + data->append (byte_C, length_i); } INLINE void String_handle::set (Byte const* byte_C, int length_i) { - copy(); - data->set (byte_C, length_i); + copy(); + data->set (byte_C, length_i); } INLINE void String_handle::operator = (char const *p) { - copy(); - data->set (p); + copy(); + data->set (p); } INLINE void String_handle::trunc (int j) { - copy(); data->trunc (j); + copy(); data->trunc (j); } INLINE int String_handle::length_i() const { - return data->length_i_; + return data->length_i_; } INLINE bool String_handle::is_binary_bo() const { - return data->is_binary_bo(); + return data->is_binary_bo(); } #endif diff --git a/flower/interval.cc b/flower/interval.cc index a50b10a464..433ca727aa 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -15,5 +15,5 @@ template INTERVAL__INSTANTIATE(Real); Real Interval_t::infinity() { - return HUGE_VAL; + return HUGE_VAL; } diff --git a/flower/lgetopt.cc b/flower/lgetopt.cc index 7ab4eb122b..a73334fe00 100644 --- a/flower/lgetopt.cc +++ b/flower/lgetopt.cc @@ -11,69 +11,76 @@ long Getopt_long::argument_to_i() { - long l; - if (!optional_argument_ch_C_ + long l; + if (!optional_argument_ch_C_ || sscanf (optional_argument_ch_C_, "%ld", &l) != 1) report (E_ILLEGALARG); - - return l; + + return l; } const Long_option_init * Getopt_long::parselong() { - char const *optnm = arg_value_ch_a_a_[array_index_i_] + 2 ; - assert (*optnm); - - char const *endopt = strchr (optnm, '='); - int searchlen = (endopt) ? endopt - optnm : strlen (optnm); - - found_option_l_=0; - for (int i=0; i< table_len_i_; i++) { + char const *optnm = arg_value_ch_a_a_[array_index_i_] + 2 ; + assert (*optnm); + + char const *endopt = strchr (optnm, '='); + int searchlen = (endopt) ? endopt - optnm : strlen (optnm); + + found_option_l_=0; + for (int i=0; i< table_len_i_; i++) + { char const *ln = option_a_[i].longname; - if (ln && !strncmp (ln, optnm, searchlen)) { + if (ln && !strncmp (ln, optnm, searchlen)) + { found_option_l_ = option_a_+i; break; - } - } + } + } - if (!found_option_l_) { + if (!found_option_l_) + { report (E_UNKNOWNOPTION); return 0; } - array_index_i_++; - argument_index_i_ = 0; + array_index_i_++; + argument_index_i_ = 0; - - if (found_option_l_->take_arg) { + + if (found_option_l_->take_arg) + { if (endopt) optional_argument_ch_C_ = endopt +1; // a '=' - else { + else + { optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_]; array_index_i_++; - } + } if (!optional_argument_ch_C_) report (E_ARGEXPECT); - } else { + } + else + { optional_argument_ch_C_ = 0; if (endopt) report (E_NOARGEXPECT); } - - return found_option_l_; + + return found_option_l_; } void Long_option_init::printon (ostream &errorout)const { - if (shortname) + if (shortname) errorout <<"-" << shortname; - if (shortname && longname) + if (shortname && longname) errorout << ", "; - if (longname) + if (longname) errorout << "`--" << longname << "'"; } @@ -81,23 +88,24 @@ Long_option_init::printon (ostream &errorout)const void Getopt_long::report (Errorcod c) { - error_ = c; - if (!error_ostream_l_) + error_ = c; + if (!error_ostream_l_) return; - *error_ostream_l_ << arg_value_ch_a_a_[0] << ": "; - switch (c) { - case E_ARGEXPECT: + *error_ostream_l_ << arg_value_ch_a_a_[0] << ": "; + switch (c) + { + case E_ARGEXPECT: *error_ostream_l_<< "option "; found_option_l_->printon (*error_ostream_l_); *error_ostream_l_ << "requires an argument"<longname << "' does not allow an argument"<printon (*error_ostream_l_); *error_ostream_l_ << '\n'; - default: + default: assert (false); } - exit (2); + exit (2); } - + const Long_option_init * Getopt_long::parseshort() { - char c=arg_value_ch_a_a_[array_index_i_][argument_index_i_]; - found_option_l_=0; - assert (c); - - for (int i=0; i < table_len_i_; i++) - if (option_a_[i].shortname == c) { + char c=arg_value_ch_a_a_[array_index_i_][argument_index_i_]; + found_option_l_=0; + assert (c); + + for (int i=0; i < table_len_i_; i++) + if (option_a_[i].shortname == c) + { found_option_l_ = option_a_+i; break; - } + } - if (!found_option_l_){ + if (!found_option_l_) + { report (E_UNKNOWNOPTION); return 0; } - argument_index_i_++; - if (!found_option_l_->take_arg){ + argument_index_i_++; + if (!found_option_l_->take_arg) + { optional_argument_ch_C_ = 0; return found_option_l_; } - optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_] + argument_index_i_; + optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_] + argument_index_i_; - array_index_i_ ++; - argument_index_i_ = 0; - - if (!optional_argument_ch_C_[0]) { + array_index_i_ ++; + argument_index_i_ = 0; + + if (!optional_argument_ch_C_[0]) + { optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_]; array_index_i_ ++; } - if (!optional_argument_ch_C_) { + if (!optional_argument_ch_C_) + { report (E_ARGEXPECT); } - - return found_option_l_; + + return found_option_l_; } const Long_option_init * Getopt_long::operator()() { - if (!ok()) + if (!ok()) return 0; - - next(); - - if (argument_index_i_) + + next(); + + if (argument_index_i_) return parseshort(); - - const char * argument_C = arg_value_ch_a_a_[array_index_i_]; - - if (argument_C[0] != '-') + + const char * argument_C = arg_value_ch_a_a_[array_index_i_]; + + if (argument_C[0] != '-') return 0; - if (argument_C[1] == '-') {// what to do with "command -- bla" + if (argument_C[1] == '-') {// what to do with "command -- bla" if ( argument_C[2]) return parselong(); else return 0; - } else { - if (argument_C[ 1 ]) { + } + else + { + if (argument_C[ 1 ]) + { argument_index_i_ = 1; return parseshort(); - } else { + } + else + { return 0; - } + } } } Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo) { - option_a_ = lo; - error_ostream_l_ = &cerr; - arg_value_ch_a_a_ = v; - argument_count_i_ = c; - array_index_i_ = 1; - argument_index_i_ = 0; - - // reached end of option table? - table_len_i_ =0; - for (int i = 0; option_a_[i].longname ||option_a_[i].shortname; i++) + option_a_ = lo; + error_ostream_l_ = &cerr; + arg_value_ch_a_a_ = v; + argument_count_i_ = c; + array_index_i_ = 1; + argument_index_i_ = 0; + + // reached end of option table? + table_len_i_ =0; + for (int i = 0; option_a_[i].longname ||option_a_[i].shortname; i++) table_len_i_ ++; } bool Getopt_long::ok()const { - return array_index_i_ < argument_count_i_; + return array_index_i_ < argument_count_i_; } void Getopt_long::next() { - error_ = E_NOERROR; - while (array_index_i_ < argument_count_i_ - && !arg_value_ch_a_a_[array_index_i_][argument_index_i_]) { + error_ = E_NOERROR; + while (array_index_i_ < argument_count_i_ + && !arg_value_ch_a_a_[array_index_i_][argument_index_i_]) + { array_index_i_++; argument_index_i_ = 0; } @@ -220,19 +239,20 @@ Getopt_long::next() char const * Getopt_long::current_arg() { - if (array_index_i_ >= argument_count_i_) + if (array_index_i_ >= argument_count_i_) return 0; - char const * a = arg_value_ch_a_a_[array_index_i_]; - return a + argument_index_i_; + char const * a = arg_value_ch_a_a_[array_index_i_]; + return a + argument_index_i_; } char const * Getopt_long::get_next_arg() { - char const * a = current_arg(); - if (a) { + char const * a = current_arg(); + if (a) + { array_index_i_ ++; argument_index_i_= 0; } - return a; + return a; } diff --git a/flower/matrix-debug.cc b/flower/matrix-debug.cc index 7126c1378e..81aa05f39c 100644 --- a/flower/matrix-debug.cc +++ b/flower/matrix-debug.cc @@ -14,19 +14,21 @@ Matrix::operator String() const { - String s; + String s; #ifndef NPRINT - Matrix_storage const * stor_c_l = dat; - s=String ("matrix { (") + dat->name() + ")\n"; - for (int i=0; i< rows(); i++){ - for (int j = 0; j < cols(); j++) { + Matrix_storage const * stor_c_l = dat; + s=String ("matrix { (") + dat->name() + ")\n"; + for (int i=0; i< rows(); i++) + { + for (int j = 0; j < cols(); j++) + { s+= String (stor_c_l->elem (i,j), "%6f "); - } + } s+="\n"; } - s+="}\n"; + s+="}\n"; #endif - return s; + return s; } @@ -34,21 +36,22 @@ void Matrix::print() const { #ifndef NPRINT - fdebug << *this; + fdebug << *this; #endif } Vector::operator String() const { - String s; + String s; #ifndef NPRINT - s="vector ["; - for (int i=0; i < dim(); i++) { + s="vector ["; + for (int i=0; i < dim(); i++) + { s += String (dat[i], "%6f") + String (' '); } - s+="]"; + s+="]"; #endif - return s; + return s; } @@ -56,6 +59,6 @@ void Vector::print() const { #ifndef NDEBUG - fdebug << *this<<'\n'; + fdebug << *this<<'\n'; #endif } diff --git a/flower/matrix-storage.cc b/flower/matrix-storage.cc index 5ebc0e9072..698f673b25 100644 --- a/flower/matrix-storage.cc +++ b/flower/matrix-storage.cc @@ -12,17 +12,20 @@ void Matrix_storage::set_addition_result (Matrix_storage *&dat, Matrix_storage *right) { - if (dat && dat->name() == Diagonal_storage::static_name () - && right->name() == Diagonal_storage::static_name ()) { + if (dat && dat->name() == Diagonal_storage::static_name () + && right->name() == Diagonal_storage::static_name ()) + { Diagonal_storage *L = (Diagonal_storage*)dat; Diagonal_storage* R = (Diagonal_storage*) right; - if ( R->band_size_i() > L->band_size_i ()) { + if ( R->band_size_i() > L->band_size_i ()) + { L->set_band_size (R->band_size_i()); - } + } return ; } - if (!dat || !dat->is_type_b (Full_storage::static_name())) { + if (!dat || !dat->is_type_b (Full_storage::static_name())) + { Matrix_storage *new_stor = (dat)? new Full_storage (dat) : new Full_storage (right->rows(), right->cols ()); @@ -34,11 +37,11 @@ Matrix_storage::set_addition_result (Matrix_storage *&dat, Matrix_storage *right Matrix_storage* Matrix_storage::get_product_result (Matrix_storage*left, Matrix_storage*right) { - Matrix_storage* dest =0; - set_product_result (dest, left,right); - return dest; + Matrix_storage* dest =0; + set_product_result (dest, left,right); + return dest; } - + /* hairy @@ -47,25 +50,31 @@ void Matrix_storage::set_product_result (Matrix_storage*&dest, Matrix_storage*left, Matrix_storage*right) { - if ( left->name() == Diagonal_storage::static_name () - && right->name() == Diagonal_storage::static_name ()) { + if ( left->name() == Diagonal_storage::static_name () + && right->name() == Diagonal_storage::static_name ()) + { Diagonal_storage *L = (Diagonal_storage*)left; Diagonal_storage* R = (Diagonal_storage*) right; - if (L->band_size_i() + R->band_size_i () < L->dim ()/2) { - if (dest ->name() != Diagonal_storage::static_name ()){ + if (L->band_size_i() + R->band_size_i () < L->dim ()/2) + { + if (dest ->name() != Diagonal_storage::static_name ()) + { delete dest; dest = new Diagonal_storage; - } + } dest->set_size (L->dim()); return; - } + } } - if ( dest && dest->name() == Full_storage::static_name ()) { + if ( dest && dest->name() == Full_storage::static_name ()) + { dest->set_size (left->rows(), right->cols ()); - } else { + } + else + { delete dest; dest = new Full_storage (left->rows(), right->cols ()); } @@ -76,7 +85,7 @@ IMPLEMENT_IS_TYPE_B(Matrix_storage); Matrix_storage * Matrix_storage::get_full (int n, int m) { - return new Full_storage (n,m); + return new Full_storage (n,m); } @@ -85,38 +94,38 @@ Matrix_storage::get_full (int n, int m) Matrix_storage::try_right_multiply (Matrix_storage *, const Matrix_storage *)const { - return false; + return false; } Array Matrix_storage::row (int n) const { - Array r; - for (int j = 0; j < cols(); j++) + Array r; + for (int j = 0; j < cols(); j++) r.push (elem (n,j)); - return r; + return r; } Array Matrix_storage::column (int n) const { - Array r; - for (int i = 0; i < rows(); i++) + Array r; + for (int i = 0; i < rows(); i++) r.push (elem (i,n)); - return r; + return r; } void Matrix_storage::set_size (int rows, int cols) { - - resize (rows,cols); + + resize (rows,cols); } void Matrix_storage::set_size (int rows) { - + resize (rows); } @@ -124,16 +133,16 @@ Matrix_storage::set_size (int rows) void Matrix_storage::set_band (Matrix_storage *&mat, int b) { - Matrix_storage* ns = new Diagonal_storage (mat, b); - delete mat; - mat=ns; + Matrix_storage* ns = new Diagonal_storage (mat, b); + delete mat; + mat=ns; } void Matrix_storage::set_full (Matrix_storage *&mat) { - Matrix_storage* ns = new Full_storage (mat); - delete mat; - mat=ns; + Matrix_storage* ns = new Full_storage (mat); + delete mat; + mat=ns; } diff --git a/flower/matrix.cc b/flower/matrix.cc index fdb6085f7c..3f9b28f835 100644 --- a/flower/matrix.cc +++ b/flower/matrix.cc @@ -13,13 +13,14 @@ bool Matrix::band_b()const { - return dat->is_type_b (Diagonal_storage::static_name()); + return dat->is_type_b (Diagonal_storage::static_name()); } void Matrix::set_full() const { - if ( dat->name() != Full_storage::static_name ()) { + if ( dat->name() != Full_storage::static_name ()) + { Matrix_storage::set_full (((Matrix*)this)->dat); } } @@ -27,64 +28,64 @@ Matrix::set_full() const void Matrix::try_set_band()const { - if (band_b()) + if (band_b()) return; - - int b = band_i(); - if ( b > dim()/2) + + int b = band_i(); + if ( b > dim()/2) return; - // it only looks constant - Matrix*self = (Matrix*)this; - Matrix_storage::set_band (self->dat,b); + // it only looks constant + Matrix*self = (Matrix*)this; + Matrix_storage::set_band (self->dat,b); } Real Matrix::norm() const { - Real r =0.0; - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Real r =0.0; + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) r += sqr (dat->elem (i,j)); - return sqrt (r); + return sqrt (r); } void Matrix::fill (Real r) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=r; } void Matrix::set_diag (Real r) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=(i==j) ? r: 0.0; } void Matrix::set_diag (Vector d) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=(i==j) ? d (i): 0.0; } void Matrix::operator+=(Matrix const &m) { - Matrix_storage::set_addition_result (dat, m.dat); - assert (m.cols() == cols ()); - assert (m.rows() == rows ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Matrix_storage::set_addition_result (dat, m.dat); + assert (m.cols() == cols ()); + assert (m.rows() == rows ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) += m (i,j); } void Matrix::operator-=(Matrix const &m) { - Matrix_storage::set_addition_result (dat, m.dat); - assert (m.cols() == cols ()); - assert (m.rows() == rows ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Matrix_storage::set_addition_result (dat, m.dat); + assert (m.cols() == cols ()); + assert (m.rows() == rows ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) -= m (i,j); } @@ -92,28 +93,30 @@ Matrix::operator-=(Matrix const &m) void Matrix::operator*=(Real a) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) *= a; } void Matrix::operator=(Matrix const &m) { - if (&m == this) + if (&m == this) return ; - delete dat; - dat = m.dat->clone(); + delete dat; + dat = m.dat->clone(); } int Matrix::band_i()const { - if ( band_b()) { + if ( band_b()) + { Diagonal_storage const * diag = (Diagonal_storage*) dat; return diag->band_size_i(); } - int starty = dim(); - while (starty >= 0) { + int starty = dim(); + while (starty >= 0) + { for ( int i = starty, j = 0; i < dim(); i++, j++) if (dat->elem (i,j)) goto gotcha; @@ -123,38 +126,38 @@ Matrix::band_i()const starty --; } gotcha: - return starty; + return starty; } - + Matrix::Matrix (Matrix const &m) { - m.OK(); - - dat = m.dat->clone(); + m.OK(); + + dat = m.dat->clone(); } Matrix::Matrix (int n, int m) { - dat = Matrix_storage::get_full (n,m); - fill (0); + dat = Matrix_storage::get_full (n,m); + fill (0); } Matrix::Matrix (Matrix_storage*stor_p) { - dat = stor_p; + dat = stor_p; } Matrix::Matrix (int n) { - dat = Matrix_storage::get_full (n,n); - fill (0); + dat = Matrix_storage::get_full (n,n); + fill (0); } Matrix::Matrix (Vector v, Vector w) { - dat = Matrix_storage::get_full (v.dim(), w.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + dat = Matrix_storage::get_full (v.dim(), w.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=v (i)*w (j); } @@ -162,52 +165,52 @@ Matrix::Matrix (Vector v, Vector w) Vector Matrix::row (int k) const { - int n=cols(); + int n=cols(); - - Vector v (n); - for (int i=0; i < n; i++) + + Vector v (n); + for (int i=0; i < n; i++) v (i)=dat->elem (k,i); - return v; + return v; } Vector Matrix::col (int k) const { - int n=rows(); - Vector v (n); - for (int i=0; i < n; i++) + int n=rows(); + Vector v (n); + for (int i=0; i < n; i++) v (i)=dat->elem (i,k); - return v; + return v; } Vector Matrix::left_multiply (Vector const & v) const { - Vector dest (v.dim()); - assert (dat->cols()==v.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Vector dest (v.dim()); + assert (dat->cols()==v.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dest (i)+= dat->elem (j,i)*v (j); - return dest; + return dest; } Vector Matrix::operator *(Vector const & v) const { - Vector dest (rows()); - assert (dat->cols()==v.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Vector dest (rows()); + assert (dat->cols()==v.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dest (i)+= dat->elem (i,j)*v (j); - return dest; + return dest; } Matrix operator /(Matrix const& m1,Real a) { - Matrix m (m1); - m /= a; - return m; + Matrix m (m1); + m /= a; + return m; } /* @@ -217,7 +220,8 @@ void Matrix::transpose() // delegate to storage? { #if 1 - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) { + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + { if (i >= j) continue; Real r=dat->elem (i,j); @@ -230,40 +234,41 @@ Matrix::transpose() // delegate to storage? Matrix Matrix::operator-() const { - OK(); - Matrix m (*this); - m*=-1.0; - return m; + OK(); + Matrix m (*this); + m*=-1.0; + return m; } Matrix Matrix::transposed() const { - Matrix m (*this); - m.transpose(); - return m; + Matrix m (*this); + m.transpose(); + return m; } Matrix operator *(Matrix const &m1, Matrix const &m2) { - Matrix result (Matrix_storage::get_product_result (m1.dat, m2.dat)); + Matrix result (Matrix_storage::get_product_result (m1.dat, m2.dat)); - result.set_product (m1,m2); - return result; + result.set_product (m1,m2); + return result; } void Matrix::set_product (Matrix const &m1, Matrix const &m2) { - assert (m1.cols()==m2.rows ()); - assert (cols()==m2.cols () && rows ()==m1.rows ()); - - if (m1.dat->try_right_multiply (dat, m2.dat)) + assert (m1.cols()==m2.rows ()); + assert (cols()==m2.cols () && rows ()==m1.rows ()); + + if (m1.dat->try_right_multiply (dat, m2.dat)) return; - - for (int i=0, j=0; dat->mult_ok (i,j); - dat->mult_next (i,j)) { + + for (int i=0, j=0; dat->mult_ok (i,j); + dat->mult_next (i,j)) + { Real r=0.0; for (int k = 0; k < m1.cols(); k++) r += m1(i,k)*m2(k,j); @@ -274,10 +279,10 @@ Matrix::set_product (Matrix const &m1, Matrix const &m2) void Matrix::insert_row (Vector v, int k) { - int c = cols(); - assert (v.dim()==cols ()); - dat->insert_row (k); - for (int j=0; j < c; j++) + int c = cols(); + assert (v.dim()==cols ()); + dat->insert_row (k); + for (int j=0; j < c; j++) dat->elem (k,j)=v (j); } @@ -285,9 +290,10 @@ Matrix::insert_row (Vector v, int k) void Matrix::swap_columns (int c1, int c2) { - assert (c1>=0&& c1 < cols()&&c2 < cols () && c2 >=0); - int r = rows(); - for (int i=0; i< r; i++) { + assert (c1>=0&& c1 < cols()&&c2 < cols () && c2 >=0); + int r = rows(); + for (int i=0; i< r; i++) + { Real r=dat->elem (i,c1); dat->elem (i,c1) = dat->elem (i,c2); dat->elem (i,c2)=r; @@ -297,9 +303,10 @@ Matrix::swap_columns (int c1, int c2) void Matrix::swap_rows (int c1, int c2) { - assert (c1>=0&& c1 < rows()&&c2 < rows () && c2 >=0); - int c = cols(); - for (int i=0; i< c; i++) { + assert (c1>=0&& c1 < rows()&&c2 < rows () && c2 >=0); + int c = cols(); + for (int i=0; i< c; i++) + { Real r=dat->elem (c1,i); dat->elem (c1,i) = dat->elem (c2,i); dat->elem (c2,i)=r; @@ -310,8 +317,8 @@ Matrix::swap_rows (int c1, int c2) int Matrix::dim() const { - assert (cols() == rows ()); - return rows(); + assert (cols() == rows ()); + return rows(); } diff --git a/flower/path.cc b/flower/path.cc index be5f56a7f0..e880b200ae 100644 --- a/flower/path.cc +++ b/flower/path.cc @@ -17,36 +17,36 @@ void split_path (String path, String &drive, String &dirs, String &filebase, String &extension) { - // peel off components, one by one. - int di = path.index_i (':'); - if (di >= 0) + // peel off components, one by one. + int di = path.index_i (':'); + if (di >= 0) { drive = path.left_str (di + 1); path = path.right_str (path.len() - di -1); - } - else + } + else drive = ""; - - di = path.index_last_i (PATHSEP); - if (di >=0) + + di = path.index_last_i (PATHSEP); + if (di >=0) { dirs = path.left_str (di + 1); path = path.right_str (path.len()-di -1); - } - else + } + else dirs = ""; - - di = path.index_last_i ('.'); - if (di >= 0) + + di = path.index_last_i ('.'); + if (di >= 0) { filebase = path.left_str (di); extension =path.right_str (path.len()-di); - } - else + } + else { extension = ""; filebase = path; - } + } } /** find a file. @@ -57,10 +57,11 @@ String File_path::find (String nm)const { - fdebug << "looking for " << nm << ": "; - if ( !nm.length_i() || ( nm == "-") ) + fdebug << "looking for " << nm << ": "; + if ( !nm.length_i() || ( nm == "-") ) return nm; - for (int i=0; i < size(); i++) { + for (int i=0; i < size(); i++) + { String path = elem(i); if ( path.length_i() ) @@ -70,12 +71,13 @@ File_path::find (String nm)const fdebug << path << "? "; FILE *f = fopen (path.ch_C(), "r"); // ugh! - if (f) { + if (f) + { fdebug << "found\n"; fclose (f); return path; - } + } } - fdebug << "\n"; - return ""; + fdebug << "\n"; + return ""; } diff --git a/flower/rational.cc b/flower/rational.cc index 5b36be916c..11963238b5 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -12,7 +12,7 @@ void print_rat (Rational const &m) { - cout << String (m) << flush; + cout << String (m) << flush; } - + diff --git a/flower/scalar.cc b/flower/scalar.cc index 1a5e54ec27..db0b9ddb8c 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -3,55 +3,56 @@ #include "scalar.hh" Scalar::Scalar (Rational r) - :String (r) + :String (r) { } Scalar::operator Rational() { - int p = index_i ('/'); - if (p == -1) + int p = index_i ('/'); + if (p == -1) return int (*this); - - String s2 = right_str (len()-p-1); - String s1 = left_str (p); + + String s2 = right_str (len()-p-1); + String s1 = left_str (p); - return Rational (s1.value_i(), s2.value_i ()); + return Rational (s1.value_i(), s2.value_i ()); } bool Scalar::isnum() { - int conv = false; - if (len()) { + int conv = false; + if (len()) + { long l =0; conv = sscanf (strh_.ch_C(), "%ld", &l); } - return len() && conv; + return len() && conv; } Scalar::operator Real() { - assert (isnum()); - return value_f(); + assert (isnum()); + return value_f(); } Scalar::operator int() { - assert (isnum()); - return value_i(); + assert (isnum()); + return value_i(); } Scalar::operator bool() const { - if (!len()) + if (!len()) return false; - if (*this == "0") + if (*this == "0") return false; - String u (*this); - if ( u.upper_str() == "FALSE") + String u (*this); + if ( u.upper_str() == "FALSE") return false; - return true; + return true; } diff --git a/flower/string-convert.cc b/flower/string-convert.cc index 2f5ab5bfa3..c105169cee 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -27,119 +27,122 @@ static const int STRING_BUFFER_LEN=1024; String String_convert::bin2hex_str (String bin_str) { - String str; - Byte const* byte_C = bin_str.byte_C(); - for ( int i = 0; i < bin_str.length_i(); i++) { + String str; + Byte const* byte_C = bin_str.byte_C(); + for ( int i = 0; i < bin_str.length_i(); i++) + { str += (char)nibble2hex_byte (*byte_C >> 4); str += (char)nibble2hex_byte (*byte_C++); } - return str; + return str; } int String_convert::bin2_i (String bin_str) { - assert (bin_str.length_i() <= 4); + assert (bin_str.length_i() <= 4); - int result_i = 0; - for ( int i = 0; i < bin_str.length_i(); i++) { + int result_i = 0; + for ( int i = 0; i < bin_str.length_i(); i++) + { result_i <<= 8; result_i += (Byte)bin_str[ i ]; } - return result_i; + return result_i; } // breendet imp from String int String_convert::dec2_i (String dec_str) { - if ( !dec_str.length_i()) - return 0; + if ( !dec_str.length_i()) + return 0; - long l = 0; - int conv = sscanf (dec_str.ch_C(), "%ld", &l); - assert (conv); + long l = 0; + int conv = sscanf (dec_str.ch_C(), "%ld", &l); + assert (conv); - return (int)l; + return (int)l; } String String_convert::i64_str (I64 i64, char const* fmt) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, (fmt ? fmt : "%Ld"), i64); // assume radix 10 - return String (buffer); + return String (buffer); } // breendet imp from String double String_convert::dec2_f (String dec_str) { - if ( !dec_str.length_i()) - return 0; - double d = 0; - int conv = sscanf (dec_str.ch_C(), "%lf", &d); - assert (conv); - return d; + if ( !dec_str.length_i()) + return 0; + double d = 0; + int conv = sscanf (dec_str.ch_C(), "%lf", &d); + assert (conv); + return d; } int String_convert::hex2bin_i (String hex_str, String& bin_str_r) { - if ( hex_str.length_i() % 2) - hex_str = "0" + hex_str; - - bin_str_r = ""; - Byte const* byte_C= hex_str.byte_C(); - int i = 0; - while ( i < hex_str.length_i()) { - int high_i = hex2nibble_i (*byte_C++); - int low_i = hex2nibble_i (*byte_C++); - if ( high_i < 0 || low_i < 0) - return 1; // illegal char - bin_str_r += String ((char)( high_i << 4 | low_i), 1 ); - i += 2; + if ( hex_str.length_i() % 2) + hex_str = "0" + hex_str; + + bin_str_r = ""; + Byte const* byte_C= hex_str.byte_C(); + int i = 0; + while ( i < hex_str.length_i()) + { + int high_i = hex2nibble_i (*byte_C++); + int low_i = hex2nibble_i (*byte_C++); + if ( high_i < 0 || low_i < 0) + return 1; // illegal char + bin_str_r += String ((char)( high_i << 4 | low_i), 1 ); + i += 2; } - return 0; + return 0; } String String_convert::hex2bin_str (String hex_str) { - String str; + String str; // silly, asserts should alway be "on"! // assert (!hex2bin_i (hex_str, str) ); - int error_i = hex2bin_i (hex_str, str); - assert (!error_i); - return str; + int error_i = hex2bin_i (hex_str, str); + assert (!error_i); + return str; } int String_convert::hex2nibble_i (Byte byte) { - if ( byte >= '0' && byte <= '9') - return byte - '0'; - if ( byte >= 'A' && byte <= 'F') - return byte - 'A' + 10; - if ( byte >= 'a' && byte <= 'f') - return byte - 'a' + 10; - return -1; + if ( byte >= '0' && byte <= '9') + return byte - '0'; + if ( byte >= 'A' && byte <= 'F') + return byte - 'A' + 10; + if ( byte >= 'a' && byte <= 'f') + return byte - 'a' + 10; + return -1; } // stupido. Should use int_str() String String_convert::i2dec_str (int i, int length_i, char ch) { - char fill_ch = ch; - if ( fill_ch) - fill_ch = '0'; - - // ugh - String dec_str (i); - - // ugh - return String (fill_ch, length_i - dec_str.length_i()) + dec_str; + char fill_ch = ch; + if ( fill_ch) + fill_ch = '0'; + + // ugh + String dec_str (i); + + // ugh + return String (fill_ch, length_i - dec_str.length_i()) + dec_str; } @@ -147,38 +150,39 @@ String_convert::i2dec_str (int i, int length_i, char ch) String String_convert::u2hex_str (unsigned u, int length_i, char fill_ch) { - String str; - if ( !u) + String str; + if ( !u) str = "0"; #if 1 // both go... - while ( u) { + while ( u) + { str = String ((char)( ( u % 16)["0123456789abcdef"] ) ) + str; u /= 16; } #else - str += int_str (u, "%x"); // hmm. %lx vs. %x -> portability? + str += int_str (u, "%x"); // hmm. %lx vs. %x -> portability? #endif - str = String (fill_ch, length_i - str.length_i()) + str; - while ( ( str.length_i() > length_i) && ( str[ 0 ] == 'f' ) ) - str = str.mid_str (2, INT_MAX); + str = String (fill_ch, length_i - str.length_i()) + str; + while ( ( str.length_i() > length_i) && ( str[ 0 ] == 'f' ) ) + str = str.mid_str (2, INT_MAX); - return str; + return str; } String String_convert::i2hex_str (int i, int length_i, char fill_ch) { - return u2hex_str ((unsigned)i, length_i, fill_ch); + return u2hex_str ((unsigned)i, length_i, fill_ch); } Byte String_convert::nibble2hex_byte (Byte byte) { - if ( ( byte & 0x0f) <= 9 ) + if ( ( byte & 0x0f) <= 9 ) return ( byte & 0x0f) + '0'; - else + else return ( byte & 0x0f) - 10 + 'a'; } /** @@ -190,10 +194,10 @@ String_convert::nibble2hex_byte (Byte byte) String String_convert::int_str (int i, char const* fmt) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, (fmt ? fmt : "%d"), i); // assume radix 10 - return String (buffer); + return String (buffer); } /** @@ -204,49 +208,50 @@ String_convert::int_str (int i, char const* fmt) String String_convert::double_str (double f, char const* fmt) { - char buf[STRING_BUFFER_LEN]; + char buf[STRING_BUFFER_LEN]; - snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); - return String (buf); + snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); + return String (buf); } /** Make a string from a single character. @param - #n# is a repetition count, default value is 1 + #n# is a repetition count, default value is 1 */ String String_convert::char_str (char c, int n) { - n = n >= 0 ? n : 0; - char* ch_p = new char[ n ]; - memset (ch_p, c, n); - String s ((Byte*)ch_p, n); - delete ch_p; - return s; + n = n >= 0 ? n : 0; + char* ch_p = new char[ n ]; + memset (ch_p, c, n); + String s ((Byte*)ch_p, n); + delete ch_p; + return s; } String String_convert::rational_str (Rational r) { - char * n = Itoa (r.numerator()); // LEAK???? - - String s = n; - if (r.denominator() != 1) { + char * n = Itoa (r.numerator()); // LEAK???? + + String s = n; + if (r.denominator() != 1) + { char * d = Itoa (r.denominator()); s += String ('/') + String (d); //delete d; } /* delete n; - */ - return s; + */ + return s; } String String_convert::pointer_str (void const *l) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 - return String (buffer); + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 + return String (buffer); } diff --git a/flower/string.cc b/flower/string.cc index 1bd236114c..6651475b37 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -25,17 +25,17 @@ void* mymemmove (void* dest, void const* src, size_t n); Byte* String::copy_byte_p() const { - Byte const* src = strh_.byte_C(); - Byte* dest = new Byte[strh_.length_i() + 1]; - memcpy (dest, src, strh_.length_i() + 1); - return dest; + Byte const* src = strh_.byte_C(); + Byte* dest = new Byte[strh_.length_i() + 1]; + memcpy (dest, src, strh_.length_i() + 1); + return dest; } void String::print_on (ostream& os) const { - if (!strh_.is_binary_bo()) - os << ch_C(); - else + if (!strh_.is_binary_bo()) + os << ch_C(); + else for ( int i = 0; i < length_i(); i++) os << (Byte)(*this)[ i ]; } @@ -46,24 +46,24 @@ String::print_on (ostream& os) const String& String::operator = (String const&source) { - strh_ = source.strh_; - return *this; + strh_ = source.strh_; + return *this; } String::String (Rational r) { - *this = String_convert::rational_str (r); + *this = String_convert::rational_str (r); } String::String (double f, char const* fmt) { - *this= String_convert::double_str (f,fmt); + *this= String_convert::double_str (f,fmt); } String::String (char c, int n) { - *this = String_convert::char_str (c,n); + *this = String_convert::char_str (c,n); } /** @@ -72,71 +72,71 @@ String::String (char c, int n) */ String::String (int i, char const * format) { - *this = String_convert::int_str (i,format); + *this = String_convert::int_str (i,format); } String::String (bool b) { - *this = (char const*) (b ? "true" : "false"); + *this = (char const*) (b ? "true" : "false"); } String::String (char const* source) { - assert (source); - strh_ = source; + assert (source); + strh_ = source; } String::String (Byte const* byte_l, int length_i) { - strh_.set (byte_l, length_i); + strh_.set (byte_l, length_i); } void String::append (String s) { - strh_.append (s.byte_C(), s.length_i()); + strh_.append (s.byte_C(), s.length_i()); } void String::operator +=(String s) { - append (s); + append (s); } void String::prepend (String s) { - s += *this; - *this = s; + s += *this; + *this = s; } int String::length_i() const { - return strh_.length_i(); + return strh_.length_i(); } Byte const* String::byte_C() const { - return strh_.byte_C(); + return strh_.byte_C(); } char const* String::ch_C() const { - return strh_.ch_C(); + return strh_.ch_C(); } Byte* String::byte_l() { - return strh_.byte_l(); + return strh_.byte_l(); } char* String::ch_l() { - return strh_.ch_l(); + return strh_.ch_l(); } /** @@ -145,50 +145,51 @@ String::ch_l() int String::compare_i (String const& s1, String const& s2) { - Byte const* p1 = s1.byte_C(); - Byte const* p2 = s2.byte_C(); - if ( p1 == p2) + Byte const* p1 = s1.byte_C(); + Byte const* p2 = s2.byte_C(); + if ( p1 == p2) return 0; - int i1 = s1.length_i(); - int i2 = s2.length_i(); + int i1 = s1.length_i(); + int i2 = s2.length_i(); - int result= memcmp (p1, p2, i1 = 0) { + + int index_i = 0; + while (next_i >= 0) + { index_i += next_i; next_i = right_str (length_i() - index_i - length).index_i (string ); } - return index_i; + return index_i; } /** find a character. @@ -202,11 +203,11 @@ String::index_last_i (char const* string) const // UGK! int String::index_i (char c) const { - char const* me = strh_.ch_C(); - char const* p = (char const *) memchr (me,c, length_i()); - if ( p) + char const* me = strh_.ch_C(); + char const* p = (char const *) memchr (me,c, length_i()); + if ( p) return p - me; - return -1; + return -1; } /** @@ -218,13 +219,13 @@ String::index_i (char c) const int String::index_i (String searchfor) const { - char const* me = strh_.ch_C(); - char const* p = (char const *) memmem ( + char const* me = strh_.ch_C(); + char const* p = (char const *) memmem ( me, length_i(), searchfor.ch_C(), searchfor.length_i ()); - - if ( p) + + if ( p) return p - me; - else + else return -1; } @@ -236,59 +237,62 @@ String::index_i (String searchfor) const int String::index_any_i (String set) const { - int n = length_i(); - if ( !n) + int n = length_i(); + if ( !n) return -1; - void const * me_l = (void const *) strh_.ch_C(); - for (int i=0; i < set.length_i(); i++) { + void const * me_l = (void const *) strh_.ch_C(); + for (int i=0; i < set.length_i(); i++) + { char * found=(char*) memchr (me_l, set[i], n ); - if (found) { + if (found) + { return found - me_l; - } + } } - return -1; + return -1; } String String::left_str (int n) const { - if (n >= length_i()) + if (n >= length_i()) return *this; - String retval; - if (n < 1) - return retval; - - retval = *this; - retval.strh_.trunc (n); - return retval; + String retval; + if (n < 1) + return retval; + + retval = *this; + retval.strh_.trunc (n); + return retval; } String String::right_str (int n) const { - if (n > length_i()) + if (n > length_i()) return *this; - - if ( n < 1) - return ""; - - return String (strh_.byte_C() + length_i() - n, n); + + if ( n < 1) + return ""; + + return String (strh_.byte_C() + length_i() - n, n); } String String::nomid_str (int index_i, int n) const { - if ( index_i < 0) { + if ( index_i < 0) + { n += index_i; index_i = 0; } - if ( n <= 0) + if ( n <= 0) return *this; - - return + + return left_str (index_i) + right_str (length_i() - index_i - n) ; } @@ -299,67 +303,68 @@ String::nomid_str (int index_i, int n) const String String::mid_str (int index_i, int n) const { - if (index_i <0) { + if (index_i <0) + { n += index_i; index_i=0; } - - if ( !length_i() || ( index_i < 0) || ( index_i >= length_i () ) || ( n < 1 ) ) + + if ( !length_i() || ( index_i < 0) || ( index_i >= length_i () ) || ( n < 1 ) ) return String(); - if ( ( n > length_i()) || ( index_i + n > length_i () ) ) + if ( ( n > length_i()) || ( index_i + n > length_i () ) ) n = length_i() - index_i; - return String (byte_C() + index_i, n); + return String (byte_C() + index_i, n); } String String::upper_str() const { - String str = *this; - str.to_upper(); - return str; + String str = *this; + str.to_upper(); + return str; } void String::to_upper() { - char *s = (char*)strh_.byte_l(); - strnupr (s ,length_i()); + char *s = (char*)strh_.byte_l(); + strnupr (s ,length_i()); } void String::to_lower() { - char* s = strh_.ch_l(); - strnlwr (s,length_i()); + char* s = strh_.ch_l(); + strnlwr (s,length_i()); } String String::lower_str() const { - String str = *this; - str.to_lower(); - return str; + String str = *this; + str.to_lower(); + return str; } String String::reversed_str() const { - String str = *this; - strrev (str.byte_l(), str.length_i ()); - return str; + String str = *this; + strrev (str.byte_l(), str.length_i ()); + return str; } int String::value_i() const { - return String_convert::dec2_i (*this); + return String_convert::dec2_i (*this); } double String::value_f() const { - return String_convert::dec2_f (*this); + return String_convert::dec2_f (*this); } diff --git a/flower/stringtest.cc b/flower/stringtest.cc index b415de36e2..bc431567b9 100644 --- a/flower/stringtest.cc +++ b/flower/stringtest.cc @@ -11,32 +11,32 @@ void ctors() { - cout << "constructors"< a; - a.push ("abcd"); - a.push ("zxy"); - a.push ("abc"); - a.push (""); - a.sort (String::compare_i); - cout << "compares: "< a; + a.push ("abcd"); + a.push ("zxy"); + a.push ("abc"); + a.push (""); + a.sort (String::compare_i); + cout << "compares: "< fields; assert (!eof()); @@ -34,12 +37,12 @@ Text_db::get_record() { fields.push (s); gobble_white(); - } + } if (get_line() != "") assert (false); - + assert (fields.size()); return Text_record (fields, get_name(), line ()); } diff --git a/flower/text-stream.cc b/flower/text-stream.cc index a8eb695ea2..530c6f8ecd 100644 --- a/flower/text-stream.cc +++ b/flower/text-stream.cc @@ -2,23 +2,24 @@ Text_stream::Text_stream (String fn) { - ios::sync_with_stdio(); - if (fn == "") + ios::sync_with_stdio(); + if (fn == "") { name = ""; f = stdin; - } + } else { name = fn; f = fopen (fn, "r"); - } + } - if (!f) { + if (!f) + { cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; exit (1); - } + } line_no = 1; } @@ -26,6 +27,6 @@ Text_stream::Text_stream (String fn) void Text_stream::message (String s) { - cerr << "\n"< d) - : dat (d) + : dat (d) { } Vector::Vector (Vector const &n) - : dat (n.dat) + : dat (n.dat) { } Vector Vector::operator-() const { - Vector v (*this); - v*=-1; - return v; + Vector v (*this); + v*=-1; + return v; } void Vector::set_unit (int j) { - fill (0.0); - dat[j] = 1.0; + fill (0.0); + dat[j] = 1.0; } diff --git a/lily/atom.cc b/lily/atom.cc index ac3c246a03..fbb6e973f8 100644 --- a/lily/atom.cc +++ b/lily/atom.cc @@ -17,36 +17,36 @@ void Atom::print() const { #ifndef NPRINT - DOUT << "texstring: " < a; - a.push (print_dimen (off_.y())); - a.push (print_dimen (off_.x())); - a.push (sym_.tex); - return substitute_args (s, a); + /* infinity checks. */ + assert (abs (off_.x()) < 100 CM); + assert (abs (off_.y()) < 100 CM); + + // whugh.. Hard coded... + String s ("\\placebox{%}{%}{%}"); + Array a; + a.push (print_dimen (off_.y())); + a.push (print_dimen (off_.x())); + a.push (sym_.tex); + return substitute_args (s, a); } diff --git a/lily/audio-column.cc b/lily/audio-column.cc index e0d87b1a99..1df586be62 100644 --- a/lily/audio-column.cc +++ b/lily/audio-column.cc @@ -14,30 +14,30 @@ Audio_column::Audio_column (Moment at_mom) { - at_mom_ = at_mom; - audio_score_l_ = 0; + at_mom_ = at_mom; + audio_score_l_ = 0; } void Audio_column::add (Audio_item* l) { - audio_item_l_list_.bottom().add (l); - l->audio_column_l_ = this; + audio_item_l_list_.bottom().add (l); + l->audio_column_l_ = this; } Moment Audio_column::at_mom() const { - return at_mom_; + return at_mom_; } void Audio_column::print() const { #ifndef NPRINT - DOUT << "Audio_column {"; - DOUT << "at: " << at_mom_ << "\n"; - DOUT << "}\n"; + DOUT << "Audio_column {"; + DOUT << "at: " << at_mom_ << "\n"; + DOUT << "}\n"; #endif } diff --git a/lily/audio-item.cc b/lily/audio-item.cc index 125541202e..eaa895049a 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -12,19 +12,19 @@ Audio_instrument::Audio_instrument (String instrument_str) : Audio_item (0) { - str_ = instrument_str; + str_ = instrument_str; } Midi_item* Audio_instrument::midi_item_p() { - return new Midi_instrument (0, str_); + return str_.length_i() ? new Midi_instrument( 0, str_ ) : 0; } - + Audio_item::Audio_item (Request* req_l) { - audio_column_l_ = 0; - req_l_ = req_l; + audio_column_l_ = 0; + req_l_ = req_l; } Audio_key::Audio_key (Request* req_l) @@ -35,7 +35,7 @@ Audio_key::Audio_key (Request* req_l) Midi_item* Audio_key::midi_item_p() { - return new Midi_key (this); + return new Midi_key (this); } @@ -47,19 +47,19 @@ Audio_note::Audio_note (Request* req_l) Midi_item* Audio_note::midi_item_p() { - return new Midi_note (this); + return new Midi_note (this); } Audio_tempo::Audio_tempo (int per_minute_4_i) : Audio_item (0) { - per_minute_4_i_ = per_minute_4_i; + per_minute_4_i_ = per_minute_4_i; } Midi_item* Audio_tempo::midi_item_p() { - return new Midi_tempo (this); + return new Midi_tempo (this); } Audio_meter::Audio_meter (Request* req_l) @@ -70,7 +70,7 @@ Audio_meter::Audio_meter (Request* req_l) Midi_item* Audio_meter::midi_item_p() { - return new Midi_meter (this); + return new Midi_meter (this); } Audio_text::Audio_text (Audio_text::Type type, String text_str) @@ -83,7 +83,7 @@ Audio_text::Audio_text (Audio_text::Type type, String text_str) Midi_item* Audio_text::midi_item_p() { - return new Midi_text (this); + return text_str_.length_i() ? new Midi_text( this ) : 0; } diff --git a/lily/audio-score.cc b/lily/audio-score.cc index 57f012e233..1c406c5b7f 100644 --- a/lily/audio-score.cc +++ b/lily/audio-score.cc @@ -21,87 +21,87 @@ Audio_score::Audio_score (Score* l) { - score_l_ = l; + score_l_ = l; } void Audio_score::add (Audio_column* p) { - p->audio_score_l_ = this; - audio_column_p_list_.bottom().add (p); + p->audio_score_l_ = this; + audio_column_p_list_.bottom().add (p); } void Audio_score::output (Midi_stream& midi_stream_r) { - int tracks_i = audio_staff_l_list_.size() + 1; - // ugh - int clocks_per_4_i = 384; - midi_stream_r << Midi_header (1, tracks_i, clocks_per_4_i); - output_header_track (midi_stream_r); - int n = 1; - for ( PCursor i (audio_staff_l_list_); i.ok(); i++ ) + int tracks_i = audio_staff_l_list_.size() + 1; + // ugh + int clocks_per_4_i = 384; + midi_stream_r << Midi_header (1, tracks_i, clocks_per_4_i); + output_header_track (midi_stream_r); + int n = 1; + for ( PCursor i (audio_staff_l_list_); i.ok(); i++ ) i->output (midi_stream_r, n++); } void Audio_score::output_header_track (Midi_stream& midi_stream_r) { - Midi_track midi_track; - - time_t t = time (0); + Midi_track midi_track; + + time_t t = time (0); - // perhaps multiple text events? - String str = String ("Creator: ") + get_version_str() + "\n"; + // perhaps multiple text events? + String str = String ("Creator: ") + get_version_str() + "\n"; - Midi_text creator (Midi_text::TEXT, str); - midi_track.add (Moment (0), &creator ); + Midi_text creator (Midi_text::TEXT, str); + midi_track.add (Moment (0), &creator ); - str = "Automatically generated at "; - str += ctime (&t); - str = str.left_str (str.length_i() - 1); - str += "\n"; - Midi_text generate (Midi_text::TEXT, str); - midi_track.add (Moment (0), &generate ); + str = "Automatically generated at "; + str += ctime (&t); + str = str.left_str (str.length_i() - 1); + str += "\n"; + Midi_text generate (Midi_text::TEXT, str); + midi_track.add (Moment (0), &generate ); - str = "from musical definition: "; + str = "from musical definition: "; - str += score_l_->location_str(); - Midi_text from (Midi_text::TEXT, str); - midi_track.add (Moment (0), &from ); + str += score_l_->location_str(); + Midi_text from (Midi_text::TEXT, str); + midi_track.add (Moment (0), &from ); - Midi_text track_name (Midi_text::TRACK_NAME, "Track " + Midi_text track_name (Midi_text::TRACK_NAME, "Track " + String_convert::i2dec_str (0, 0, '0') ); - midi_track.add (Moment (0), &track_name ); + midi_track.add (Moment (0), &track_name ); - Midi_tempo tempo (score_l_->midi_p_->get_tempo_i (Moment (1, 4) ) ); - midi_track.add (Moment (0), &tempo); + Midi_tempo tempo (score_l_->midi_p_->get_tempo_i (Moment (1, 4) ) ); + midi_track.add (Moment (0), &tempo); - midi_stream_r << midi_track; + midi_stream_r << midi_track; } void Audio_score::add_staff (Audio_staff* l) { - audio_staff_l_list_.bottom().add (l); + audio_staff_l_list_.bottom().add (l); } void Audio_score::add (Audio_element *p) { - audio_elem_p_list_.bottom().add (p); + audio_elem_p_list_.bottom().add (p); } void Audio_score::print() const { #ifndef NPRINT - DOUT << "Audio_score { "; - score_l_->midi_p_->print(); - DOUT << "\ncolumns: "; - for ( PCursor i (audio_column_p_list_); i.ok(); i++ ) + DOUT << "Audio_score { "; + score_l_->midi_p_->print(); + DOUT << "\ncolumns: "; + for ( PCursor i (audio_column_p_list_); i.ok(); i++ ) i->print(); - DOUT << "}\n"; + DOUT << "}\n"; #endif } diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index c23b339b2b..21de1e0c9e 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -15,17 +15,17 @@ void Audio_staff::add (Audio_item* l) { - audio_item_l_list_.bottom().add (l); + audio_item_l_list_.bottom().add (l); } void Audio_staff::output (Midi_stream& midi_stream_r, int track_i) { - Midi_track midi_track; - midi_track.number_i_ = track_i; - for ( Midi_walker i (this, &midi_track); i.ok(); i++ ) + Midi_track midi_track; + midi_track.number_i_ = track_i; + for ( Midi_walker i (this, &midi_track); i.ok(); i++ ) i.process(); - midi_stream_r << midi_track; + midi_stream_r << midi_track; } IMPLEMENT_IS_TYPE_B1(Audio_staff, Audio_element); diff --git a/lily/axis-group-item.cc b/lily/axis-group-item.cc index c39a12c673..325c2a0297 100644 --- a/lily/axis-group-item.cc +++ b/lily/axis-group-item.cc @@ -13,8 +13,9 @@ IMPLEMENT_IS_TYPE_B2(Axis_group_item, Axis_group_element, Item); void Axis_group_item::OK() const { - Link_array elems = axis_admin_.elem_l_arr_; - for (int i=0; i < elems.size(); i++) { + Link_array elems = axis_admin_.elem_l_arr_; + for (int i=0; i < elems.size(); i++) + { Item * it_l = elems[i]->item(); assert (it_l); @@ -26,25 +27,27 @@ Axis_group_item::OK() const void Axis_group_item::do_breakable_col_processing() { - if (!pcol_l_->breakable_b()) + if (!pcol_l_->breakable_b()) return; - OK(); - copy_breakable_items(); - + OK(); + copy_breakable_items(); + - Link_array elems = axis_admin_.elem_l_arr_; - for (int i=0; i < elems.size(); i++) { + Link_array elems = axis_admin_.elem_l_arr_; + for (int i=0; i < elems.size(); i++) + { Item* it_l = elems[i]->item(); - for ( int j=0; j < 2; j++) { + for ( int j=0; j < 2; j++) + { Item *new_l = it_l->find_prebroken_piece (broken_to_a_[j]->pcol_l_); ((Axis_group_item*)broken_to_a_[j])->add_element (new_l); - } + } } - Item::do_breakable_col_processing(); + Item::do_breakable_col_processing(); } void Axis_group_item::do_print() const { - Axis_group_element::do_print(); + Axis_group_element::do_print(); } diff --git a/lily/axis-group-spanner.cc b/lily/axis-group-spanner.cc index a7fd4fa62b..1d45de3ae0 100644 --- a/lily/axis-group-spanner.cc +++ b/lily/axis-group-spanner.cc @@ -17,51 +17,59 @@ void Axis_group_spanner::do_break_processing_if_unbroken() { - Link_array elems = axis_admin_.elem_l_arr_; - Line_of_score *my_line = line_l(); - for (int i=0; i < elems.size(); i++) { - if (!elems[i]->line_l()) { + Link_array elems = axis_admin_.elem_l_arr_; + Line_of_score *my_line = line_l(); + for (int i=0; i < elems.size(); i++) + { + if (!elems[i]->line_l()) + { Item * item_l = elems[i]->item(); if (item_l && item_l->breakable_b_ - && item_l->break_status_i() == 0) { + && item_l->break_status_i() == 0) + { // last two checks are paranoia Item * broken_item_l = item_l->find_prebroken_piece (my_line); add_element (broken_item_l); - } + } remove_element (elems[i]); - } + } } - + } void Axis_group_spanner::do_break_processing() { - set_my_columns(); - bool breaking_self_b = ! Spanner::line_l(); - if (!breaking_self_b) { + set_my_columns(); + bool breaking_self_b = ! Spanner::line_l(); + if (!breaking_self_b) + { do_break_processing_if_unbroken(); Spanner::do_break_processing(); return; } - break_into_pieces (true); - Link_array loose_elems = axis_admin_.elem_l_arr_; - remove_all(); - - for (int i=0; i < loose_elems.size(); i++) { + break_into_pieces (true); + Link_array loose_elems = axis_admin_.elem_l_arr_; + remove_all(); + + for (int i=0; i < loose_elems.size(); i++) + { Score_elem * elt = loose_elems[i]; Line_of_score *elt_line = elt->line_l(); - if ( ! elt_line){ + if ( ! elt_line) + { /* this piece doesn't know where it belongs. Find out if it was broken, and use the broken remains */ - if (elt->spanner()) { + if (elt->spanner()) + { Spanner * sp = elt->spanner(); - for (int j =0; j < broken_into_l_arr_.size(); j++) { + for (int j =0; j < broken_into_l_arr_.size(); j++) + { Axis_group_spanner * my_broken_l = (Axis_group_spanner*)broken_into_l_arr_[j]; @@ -72,13 +80,16 @@ Axis_group_spanner::do_break_processing() if (broken_span_l) my_broken_l->add_element (broken_span_l); - } - } else if (elt->item() + } + } + else if (elt->item() && elt->item()->breakable_b_ - && elt->item()->break_status_i () == 0) { + && elt->item()->break_status_i () == 0) + { // broken items - for (int j =0; j < 2; j++) { + for (int j =0; j < 2; j++) + { Item * my_item = elt->item()->broken_to_a_[j]; Line_of_score * item_line_l = my_item->line_l() ; if ( ! item_line_l) @@ -88,26 +99,28 @@ Axis_group_spanner::do_break_processing() = (Axis_group_spanner*)find_broken_piece (item_line_l); if (v) v->add_element (my_item); - } + } - } - } else { + } + } + else + { /* this piece *does* know where it belongs. Put it in appropriate piece of this spanner */ Axis_group_spanner * my_broken_l = (Axis_group_spanner*)find_broken_piece (elt->line_l()); my_broken_l->add_element (elt); - } + } } - - Spanner::do_break_processing(); + + Spanner::do_break_processing(); } void Axis_group_spanner::do_print() const { - Axis_group_element::do_print(); + Axis_group_element::do_print(); } diff --git a/lily/axis-group.cc b/lily/axis-group.cc index 4e09739471..c0fff81760 100644 --- a/lily/axis-group.cc +++ b/lily/axis-group.cc @@ -13,33 +13,33 @@ /** don't copy anything: an element can only be in one Axis_group_element at one time. */ Axis_group_administration::Axis_group_administration ( - Axis_group_administration const&) + Axis_group_administration const&) { } bool Axis_group_administration::contains_b (Score_elem const *e)const { - return elem_l_arr_.find_l (e); + return elem_l_arr_.find_l (e); } Interval Axis_group_administration::extent (Axis axis)const { - Interval r; - for (int i=0; i < elem_l_arr_.size(); i++) + Interval r; + for (int i=0; i < elem_l_arr_.size(); i++) r.unite (elem_l_arr_[i]->extent (axis)); - return r; + return r; } void Axis_group_administration::add_element (Score_elem*e, Axis_group_element*g, Axis a1, Axis a2) { - assert (! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2]); - e->axis_group_l_a_[a1] = g; - e->axis_group_l_a_[a2] = g; - elem_l_arr_.push ( e); + assert (! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2]); + e->axis_group_l_a_[a1] = g; + e->axis_group_l_a_[a2] = g; + elem_l_arr_.push ( e); } @@ -47,22 +47,23 @@ Axis_group_administration::add_element (Score_elem*e, void Axis_group_administration::remove_element (Score_elem*e, Axis a1, Axis a2) { - assert (contains_b (e)); - elem_l_arr_.unordered_substitute (e,0); - - e->axis_group_l_a_[a1] = 0; - e->axis_group_l_a_[a2] = 0; + assert (contains_b (e)); + elem_l_arr_.unordered_substitute (e,0); + + e->axis_group_l_a_[a1] = 0; + e->axis_group_l_a_[a2] = 0; } void Axis_group_administration::remove_all (Axis a1, Axis a2) { - for (int i=0; i < elem_l_arr_.size(); i++) { + for (int i=0; i < elem_l_arr_.size(); i++) + { Score_elem*e=elem_l_arr_[i]; e->axis_group_l_a_[a1] = 0; e->axis_group_l_a_[a2] = 0; } - elem_l_arr_.clear(); + elem_l_arr_.clear(); } @@ -70,7 +71,7 @@ void Axis_group_administration::print() const { #ifndef NPRINT - for (int i=0; i < elem_l_arr_.size(); i++) + for (int i=0; i < elem_l_arr_.size(); i++) DOUT << elem_l_arr_[i]->name() << ' '; #endif } diff --git a/lily/axis.cc b/lily/axis.cc index 8217484340..d98d745b4c 100644 --- a/lily/axis.cc +++ b/lily/axis.cc @@ -12,5 +12,5 @@ String axis_name_str (Axis a) { - return String (a + 'x'); + return String (a + 'x'); } diff --git a/lily/bar-column-grav.cc b/lily/bar-column-grav.cc index 19b523cf78..4c073ac57e 100644 --- a/lily/bar-column-grav.cc +++ b/lily/bar-column-grav.cc @@ -15,36 +15,42 @@ Bar_column_engraver::Bar_column_engraver() { - bar_l_ =0; - barcol_p_ =0; + bar_l_ =0; + barcol_p_ =0; } void Bar_column_engraver::acknowledge_element (Score_elem_info info) { - if (info.elem_l_->is_type_b (Script::static_name()) + if (info.elem_l_->is_type_b (Script::static_name()) && info.req_l_->command() - && info.origin_grav_l_arr_.size() == 1) { + && info.origin_grav_l_arr_.size() == 1) + { script_l_arr_.push ((Script*)info.elem_l_->item()); - } else { + } + else + { if (info.origin_grav_l_arr_.size() == 1 && info.elem_l_->is_type_b (Bar::static_name())) bar_l_ = (Bar*)info.elem_l_->item(); } - if ( bar_l_ && !barcol_p_) { + if ( bar_l_ && !barcol_p_) + { barcol_p_ = new Bar_column; barcol_p_->breakable_b_ =true; barcol_p_->set_bar (bar_l_); announce_element (Score_elem_info (barcol_p_, 0)); } - if (barcol_p_) { - for (int i=0; i < script_l_arr_.size(); i++) { + if (barcol_p_) + { + for (int i=0; i < script_l_arr_.size(); i++) + { script_l_arr_[i]->breakable_b_ = true; barcol_p_->add (script_l_arr_[i]); - } + } script_l_arr_.clear(); } } @@ -52,7 +58,8 @@ Bar_column_engraver::acknowledge_element (Score_elem_info info) void Bar_column_engraver::do_pre_move_processing() { - if (barcol_p_) { + if (barcol_p_) + { typeset_element (barcol_p_); barcol_p_ =0; } @@ -61,8 +68,8 @@ Bar_column_engraver::do_pre_move_processing() void Bar_column_engraver::do_post_move_processing() { - script_l_arr_.clear(); - bar_l_ =0; + script_l_arr_.clear(); + bar_l_ =0; } IMPLEMENT_IS_TYPE_B1(Bar_column_engraver, Engraver); diff --git a/lily/bar-column.cc b/lily/bar-column.cc index 5f5dbf894b..f4c4d2f96b 100644 --- a/lily/bar-column.cc +++ b/lily/bar-column.cc @@ -11,22 +11,23 @@ Bar_column::Bar_column() { - bar_l_ =0; - breakable_b_ = true; + bar_l_ =0; + breakable_b_ = true; } void Bar_column::set_bar (Bar*b) { - Script_column::add_support (b); - bar_l_ = b; + Script_column::add_support (b); + bar_l_ = b; } void Bar_column::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Script_column::do_substitute_dependency (o,n); - if ( o == bar_l_) { + Script_column::do_substitute_dependency (o,n); + if ( o == bar_l_) + { bar_l_ = n ? (Bar*)n->item() : 0; } } diff --git a/lily/bar-grav.cc b/lily/bar-grav.cc index 740f5d5d04..c390c78a31 100644 --- a/lily/bar-grav.cc +++ b/lily/bar-grav.cc @@ -14,37 +14,43 @@ Bar_engraver::Bar_engraver() { - do_post_move_processing(); + do_post_move_processing(); } bool Bar_engraver::do_try_request (Request*r_l) { - Command_req* c_l = r_l->command(); - if (!c_l|| !c_l->bar()) + Command_req* c_l = r_l->command(); + if (!c_l|| !c_l->bar()) return false; - Bar_req * b= c_l->bar(); - if (bar_req_l_ && bar_req_l_->equal_b (b)) + Bar_req * b= c_l->bar(); + if (bar_req_l_ && bar_req_l_->equal_b (b)) return false; - - bar_req_l_ = b; + + bar_req_l_ = b; - return true; + return true; } void Bar_engraver::do_process_requests() { - if (bar_req_l_) { + if (bar_req_l_) + { bar_p_ = new Bar; bar_p_->type_str_=bar_req_l_->type_str_; - } else if (!get_staff_info().time_C_->whole_in_measure_) { + } + else if (!get_staff_info().time_C_->whole_in_measure_) + { bar_p_ = new Bar; } - - if (bar_p_){ + + if (bar_p_) + { announce_element (Score_elem_info (bar_p_, bar_req_l_)); - } else { + } + else + { Disallow_break_req r; daddy_grav_l_->try_request (&r); } @@ -54,7 +60,8 @@ Bar_engraver::do_process_requests() void Bar_engraver::do_pre_move_processing() { - if (bar_p_) { + if (bar_p_) + { typeset_element (bar_p_); bar_p_ =0; } @@ -63,8 +70,8 @@ Bar_engraver::do_pre_move_processing() void Bar_engraver::do_post_move_processing() { - bar_req_l_ = 0; - bar_p_ =0; + bar_req_l_ = 0; + bar_p_ =0; } diff --git a/lily/bar-number-grav.cc b/lily/bar-number-grav.cc index e824462a76..4a468119c7 100644 --- a/lily/bar-number-grav.cc +++ b/lily/bar-number-grav.cc @@ -15,8 +15,8 @@ Bar_number_grav::Bar_number_grav() { - number_i_ =1; - script_p_ =0; + number_i_ =1; + script_p_ =0; } static Command_script_req dummy; @@ -24,8 +24,9 @@ static Command_script_req dummy; void Bar_number_grav::acknowledge_element (Score_elem_info i) { - if (i.origin_grav_l_arr_.size() == 1 && - i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) { + if (i.origin_grav_l_arr_.size() == 1 && + i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) + { script_p_ = new Script; Text_def *td_p =new Text_def; @@ -41,7 +42,8 @@ Bar_number_grav::acknowledge_element (Score_elem_info i) void Bar_number_grav::do_pre_move_processing() { - if ( script_p_) { + if ( script_p_) + { typeset_element (script_p_); script_p_ =0; } diff --git a/lily/bar.cc b/lily/bar.cc index 2f4b47b3b5..7dc97c7c59 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -15,9 +15,9 @@ Bar::Bar() { - breakable_b_ = true; - type_str_ = "|"; - spanned_i_ = 0; + breakable_b_ = true; + type_str_ = "|"; + spanned_i_ = 0; } @@ -27,17 +27,17 @@ IMPLEMENT_IS_TYPE_B1(Bar,Item); void Bar::do_print()const { - DOUT << type_str_; + DOUT << type_str_; } Molecule* Bar::brew_molecule_p()const { - Paper_def *p = paper(); - Symbol s = p->lookup_l()->bar (type_str_, + Paper_def *p = paper(); + Symbol s = p->lookup_l()->bar (type_str_, p->get_var ("bar_size")); - Molecule*output = new Molecule (Atom (s)); - return output; + Molecule*output = new Molecule (Atom (s)); + return output; } /** @@ -45,27 +45,28 @@ Bar::brew_molecule_p()const TODO: parametrise this (input-settable) */ static char const *bar_breaks[][3] ={ - {":|", ":|:", "|:"}, - {"|", "|", ""}, - {"", "|:", "|:"}, - {"||.", "||.", ""}, - {":|", ":|", ""}, - {0,0,0} + {":|", ":|:", "|:"}, + {"|", "|", ""}, + {"", "|:", "|:"}, + {"||.", "||.", ""}, + {":|", ":|", ""}, + {0,0,0} }; void Bar::do_pre_processing() { - for (int i=0; bar_breaks[i][0]; i++) { + for (int i=0; bar_breaks[i][0]; i++) + { if (bar_breaks[i][1] == type_str_) type_str_ = bar_breaks[i][break_status_i()+1]; } - /* - span_score_bar needs dims, so don't do + /* + span_score_bar needs dims, so don't do + + transparent_b_ = empty_b_ = (type_str_ == ""); - transparent_b_ = empty_b_ = (type_str_ == ""); - - */ + */ } - + diff --git a/lily/beam.cc b/lily/beam.cc index 1f595cddb6..70a1ce88d0 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -31,57 +31,57 @@ struct Stem_info { - Real x; - int dir_i_; - Real idealy_f_; - Real miny_f_; - int beams_i_; - - Stem_info(){} - Stem_info (Stem const *); + Real x; + int dir_i_; + Real idealy_f_; + Real miny_f_; + int beams_i_; + + Stem_info(){} + Stem_info (Stem const *); }; Stem_info::Stem_info (Stem const *s) { - x = s->hpos_f(); - dir_i_ = s->dir_i_; - beams_i_ = intlog2( s->flag_i_) - 2; + x = s->hpos_f(); + dir_i_ = s->dir_i_; + beams_i_ = intlog2( s->flag_i_) - 2; - /* - [todo] - * get algorithm + /* + [todo] + * get algorithm * runtime - Breitkopf + H\"artel: - miny_f_ = interline + #beams * interbeam + Breitkopf + H\"artel: + miny_f_ = interline + #beams * interbeam ideal8 = 2 * interline + interbeam ideal16,32,64,128 = 1.5 * interline + #beams * interbeam - * B\"arenreiter: - miny_f_ = interline + #beams * interbeam + * B\"arenreiter: + miny_f_ = interline + #beams * interbeam ideal8,16 = 2 interline + #beams * interbeam ideal32,64,128 = 1.5 interline + #beams * interbeam - - */ + + */ - Real notehead_y = s->paper()->interline_f (); - // huh? why do i need the / 2 + Real notehead_y = s->paper()->interline_f (); + // huh? why do i need the / 2 // Real interbeam_f = s->paper()->interbeam_f (); - Real interbeam_f = s->paper()->interbeam_f () / 2; - - /* well eh, huh? - idealy_f_ = dir_i_ * s->stem_start_f() + beams_i_ * interbeam_f; - if ( beams_i_ < 3) + Real interbeam_f = s->paper()->interbeam_f () / 2; + + /* well eh, huh? + idealy_f_ = dir_i_ * s->stem_start_f() + beams_i_ * interbeam_f; + if ( beams_i_ < 3) idealy_f_ += 2 * interline_f; - else + else idealy_f_ += 1.5 * interline_f; - */ + */ - idealy_f_ = dir_i_ * s->stem_end_f(); + idealy_f_ = dir_i_ * s->stem_end_f(); - miny_f_ = dir_i_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f; + miny_f_ = dir_i_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f; - idealy_f_ = miny_f_ >? idealy_f_; + idealy_f_ = miny_f_ >? idealy_f_; // assert (miny_f_ <= idealy_f_); } @@ -92,54 +92,58 @@ Stem_info::Stem_info (Stem const *s) Offset Beam::center()const { - Real w=(paper()->note_width () + width ().length ())/2.0; - return Offset (w, (left_pos + w* slope)*paper()->internote_f ()); + Real w=(paper()->note_width () + width ().length ())/2.0; + return Offset (w, (left_pos + w* slope)*paper()->internote_f ()); } Beam::Beam() { - slope = 0; - left_pos = 0.0; + slope = 0; + left_pos = 0.0; } void Beam::add (Stem*s) { - stems.push (s); - s->add_dependency (this); - s->print_flag_b_ = false; + stems.push (s); + s->add_dependency (this); + s->print_flag_b_ = false; } void Beam::set_default_dir() { - int up = 0, down = 0; - int up_count = 0, down_count = 0; + int up = 0, down = 0; + int up_count = 0, down_count = 0; - for (int i=0; i get_center_distance_from_top(); int cur_up = sl->get_center_distance_from_bottom(); - if (cur_down) { + if (cur_down) + { down += cur_down; down_count++; - } - if (cur_up) { + } + if (cur_up) + { up += cur_up; up_count++; - } + } } - if (!down) + if (!down) down_count = 1; - if (!up) + if (!up) up_count = 1; - // the following relation is equal to - // up / up_count > down / down_count - dir_i_ = (up * down_count > down * up_count) ? 1 : -1; + // the following relation is equal to + // up / up_count > down / down_count + dir_i_ = (up * down_count > down * up_count) ? 1 : -1; - for (int i=0; i dir_i_ = dir_i_; } @@ -156,8 +160,9 @@ Beam::set_default_dir() void Beam::solve_slope() { - Array sinfo; - for (int j=0; j sinfo; + for (int j=0; j set_default_extents(); @@ -167,53 +172,59 @@ Beam::solve_slope() Stem_info info (i); sinfo.push (info); } - if (! sinfo.size()) + if (! sinfo.size()) slope = left_pos = 0; - else if (sinfo.size() == 1) { + else if (sinfo.size() == 1) + { slope = 0; left_pos = sinfo[0].idealy_f_; - } else { + } + else + { Real leftx = sinfo[0].x; Least_squares l; - for (int i=0; i < sinfo.size(); i++) { + for (int i=0; i < sinfo.size(); i++) + { sinfo[i].x -= leftx; l.input.push (Offset (sinfo[i].x, sinfo[i].idealy_f_)); - } + } l.minimise (slope, left_pos); } - - Real dy = 0.0; - for (int i=0; i < sinfo.size(); i++) { + + Real dy = 0.0; + for (int i=0; i < sinfo.size(); i++) + { Real y = sinfo[i].x * slope + left_pos; Real my = sinfo[i].miny_f_; if (my - y > dy) dy = my -y; } - left_pos += dy; - left_pos *= dir_i_; + left_pos += dy; + left_pos *= dir_i_; - slope *= dir_i_; + slope *= dir_i_; - /* - This neat trick is by Werner Lemberg, damped = tanh (slope) corresponds - with some tables in [Wanske] - */ - slope = 0.6 * tanh (slope); + /* + This neat trick is by Werner Lemberg, damped = tanh (slope) corresponds + with some tables in [Wanske] + */ + slope = 0.6 * tanh (slope); // ugh - Real sl = slope*paper()->internote_f (); - paper()->lookup_l ()->beam (sl, 20 PT); - slope = sl /paper()->internote_f (); + Real sl = slope*paper()->internote_f (); + paper()->lookup_l ()->beam (sl, 20 PT); + slope = sl /paper()->internote_f (); } void Beam::set_stemlens() { - Real x0 = stems[0]->hpos_f(); - for (int j=0; j hpos_f(); + for (int j=0; j hpos_f()-x0; @@ -225,34 +236,36 @@ Beam::set_stemlens() void Beam::do_post_processing() { - if ( stems.size() < 2) { + if ( stems.size() < 2) + { warning ("Beam with less than 2 stems"); transparent_b_ = true; return ; } - solve_slope(); - set_stemlens(); + solve_slope(); + set_stemlens(); } void Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) { - def.OK(); - cur.OK(); - assert (cur.children.size() == stems.size ()); - - cur.split (def); + def.OK(); + cur.OK(); + assert (cur.children.size() == stems.size ()); + + cur.split (def); - Array b; - { + Array b; + { Array flags; - for (int j=0; j flag_i_))-2; assert (f>0); flags.push (f); - } + } int fi =0; b= cur.generate_beams (flags, fi); b.insert (0,0); @@ -260,7 +273,8 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) assert (stems.size() == b.size ()/2); } - for (int j=0, i=0; i < b.size() && j beams_left_i_ = b[i]; s->beams_right_i_ = b[i+1]; @@ -270,7 +284,7 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) void Beam::do_pre_processing() { - if (!dir_i_) + if (!dir_i_) set_default_dir(); } @@ -279,7 +293,7 @@ Beam::do_pre_processing() Interval Beam::do_width() const { - return Interval (stems[0]->hpos_f(), + return Interval (stems[0]->hpos_f(), stems.top()->hpos_f ()); } @@ -289,19 +303,20 @@ Beam::do_width() const Molecule Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const { - assert (!next || next->hpos_f() > here->hpos_f () ); - assert (!prev || prev->hpos_f() < here->hpos_f () ); + assert (!next || next->hpos_f() > here->hpos_f () ); + assert (!prev || prev->hpos_f() < here->hpos_f () ); // Real dy=paper()->internote_f ()*2; - Real dy = paper()->interbeam_f (); - Real stemdx = paper()->rule_thickness (); - Real sl = slope*paper()->internote_f (); - paper()->lookup_l ()->beam (sl, 20 PT); + Real dy = paper()->interbeam_f (); + Real stemdx = paper()->rule_thickness (); + Real sl = slope*paper()->internote_f (); + paper()->lookup_l ()->beam (sl, 20 PT); - Molecule leftbeams; - Molecule rightbeams; + Molecule leftbeams; + Molecule rightbeams; - /* half beams extending to the left. */ - if (prev) { + /* half beams extending to the left. */ + if (prev) + { int lhalfs= lhalfs = here->beams_left_i_ - prev->beams_right_i_ ; int lwholebeams= here->beams_left_i_ beams_right_i_ ; Real w = (here->hpos_f() - prev->hpos_f ())/4; @@ -310,14 +325,16 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const if (lhalfs) // generates warnings if not a = paper()->lookup_l ()->beam (sl, w); a.translate (Offset (-w, -w * sl)); - for (int j = 0; j < lhalfs; j++) { + for (int j = 0; j < lhalfs; j++) + { Atom b (a); b.translate (-dir_i_ * dy * (lwholebeams+j), Y_AXIS); leftbeams.add (b); - } + } } - if (next){ + if (next) + { int rhalfs = here->beams_right_i_ - next->beams_left_i_; int rwholebeams = here->beams_right_i_ beams_left_i_; @@ -325,25 +342,27 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const Atom a = paper()->lookup_l ()->beam (sl, w + stemdx); int j = 0; - for (; j < rwholebeams; j++) { + for (; j < rwholebeams; j++) + { Atom b (a); b.translate (-dir_i_ * dy * j, Y_AXIS); rightbeams.add (b); - } + } w /= 4; if (rhalfs) a = paper()->lookup_l ()->beam (sl, w); - for (; j < rwholebeams + rhalfs; j++) { + for (; j < rwholebeams + rhalfs; j++) + { Atom b (a); b.translate (-dir_i_ * dy * j, Y_AXIS); rightbeams.add (b); - } + } } - leftbeams.add (rightbeams); - return leftbeams; + leftbeams.add (rightbeams); + return leftbeams; } @@ -351,12 +370,13 @@ Molecule* Beam::brew_molecule_p() const { - Molecule *mol_p = new Molecule; - // huh? inter-what + Molecule *mol_p = new Molecule; + // huh? inter-what // Real inter_f = paper()->interbeam_f (); - Real inter_f = paper()->internote_f (); - Real x0 = stems[0]->hpos_f(); - for (int j=0; j internote_f (); + Real x0 = stems[0]->hpos_f(); + for (int j=0; j 0)? stems[j-1] : 0; Stem * next = (j < stems.size()-1) ? stems[j+1] :0; @@ -366,8 +386,8 @@ Beam::brew_molecule_p() const sb.translate (Offset (x, (x * slope + left_pos)* inter_f)); mol_p->add (sb); } - mol_p->translate (x0 - left_col_l_->hpos_f_, X_AXIS); - return mol_p; + mol_p->translate (x0 - left_col_l_->hpos_f_, X_AXIS); + return mol_p; } @@ -377,15 +397,16 @@ void Beam::do_print()const { #ifndef NPRINT - DOUT << "slope " <is_type_b (Stem::static_name())) { + if (o->is_type_b (Stem::static_name())) + { stems.substitute ((Stem*)o->item(), n?(Stem*) n->item ():0); } } diff --git a/lily/bow.cc b/lily/bow.cc index 728f9817a6..1ef733c61a 100644 --- a/lily/bow.cc +++ b/lily/bow.cc @@ -13,46 +13,46 @@ Bow::Bow() { - left_pos_i_ = right_pos_i_ = 0; - left_dx_f_ = right_dx_f_ = 0.0; + left_pos_i_ = right_pos_i_ = 0; + left_dx_f_ = right_dx_f_ = 0.0; } Offset Bow::center() const { - int dy = right_pos_i_-left_pos_i_; + int dy = right_pos_i_-left_pos_i_; - Real w = width().length (); + Real w = width().length (); - return Offset (w/2,dy * paper()->internote_f ()); + return Offset (w/2,dy * paper()->internote_f ()); } Molecule* Bow::brew_molecule_p() const { - Molecule*output = new Molecule; - Real w = width().length (); - - int dy = right_pos_i_ - left_pos_i_; - - Real nw_f = paper()->note_width (); - Real nh_f = paper()->internote_f (); - - - w+= (right_dx_f_ - left_dx_f_) * nw_f ; - Real round_w = w; // slur lookup rounds the slurwidth . - - Symbol sl = paper()->lookup_l ()->slur (dy , round_w, dir_i_); - - Real error = w-round_w; - - Atom a (sl); - a.translate (Offset ((left_dx_f_ + 0.5)*nw_f + error/2, + Molecule*output = new Molecule; + Real w = width().length (); + + int dy = right_pos_i_ - left_pos_i_; + + Real nw_f = paper()->note_width (); + Real nh_f = paper()->internote_f (); + + + w+= (right_dx_f_ - left_dx_f_) * nw_f ; + Real round_w = w; // slur lookup rounds the slurwidth . + + Symbol sl = paper()->lookup_l ()->slur (dy , round_w, dir_i_); + + Real error = w-round_w; + + Atom a (sl); + a.translate (Offset ((left_dx_f_ + 0.5)*nw_f + error/2, left_pos_i_ * nh_f)); - output->add (a); - return output; + output->add (a); + return output; } diff --git a/lily/boxes.cc b/lily/boxes.cc index 756ce87757..4a219a4864 100644 --- a/lily/boxes.cc +++ b/lily/boxes.cc @@ -8,7 +8,7 @@ Box::Box() Box::Box (Interval ix, Interval iy) { - x() = ix; - y() = iy; + x() = ix; + y() = iy; } diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index d3c9e5df79..b2ffbaee60 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -12,8 +12,8 @@ void Break_align_item::do_pre_processing() { - align_i_ = break_status_i(); - Horizontal_align_item::do_pre_processing(); + align_i_ = break_status_i(); + Horizontal_align_item::do_pre_processing(); } IMPLEMENT_IS_TYPE_B1(Break_align_item, Horizontal_align_item); diff --git a/lily/break.cc b/lily/break.cc index 2fb1935dfe..3ebba2eb63 100644 --- a/lily/break.cc +++ b/lily/break.cc @@ -17,26 +17,26 @@ String Col_stats::str() const { - String s (count_i_); - s += " lines"; - if (count_i_) + String s (count_i_); + s += " lines"; + if (count_i_) s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)"); - - return s; + + return s; } void Col_stats::add (Line_of_cols const& line) { - count_i_++; - cols_i_ += line.size(); + count_i_++; + cols_i_ += line.size(); } Col_stats::Col_stats() { - count_i_ =0; - cols_i_ =0; + count_i_ =0; + cols_i_ =0; } /* **************************************************************** */ @@ -44,49 +44,50 @@ Col_stats::Col_stats() Line_of_cols Break_algorithm::all_cols()const { - Line_of_cols retval; - for (PCursor c (pscore_l_->col_p_list_.top()); - c.ok(); c++) { + Line_of_cols retval; + for (PCursor c (pscore_l_->col_p_list_.top()); + c.ok(); c++) + { retval.push (c); } - return retval; + return retval; } Array Break_algorithm::find_break_indices() const { - Line_of_cols all (all_cols()); - Array retval; - - for (int i=0; i < all.size(); i++) + Line_of_cols all (all_cols()); + Array retval; + + for (int i=0; i < all.size(); i++) if (all[i]->breakable_b()) retval.push (i); - - if ( linelength <=0) + + if ( linelength <=0) while ( retval.size() >2) retval.del (1); - return retval; + return retval; } /// return all breakable columns Line_of_cols Break_algorithm::find_breaks() const { - Line_of_cols all (all_cols()); - Line_of_cols retval; - - for (int i=0; i < all.size(); i++) + Line_of_cols all (all_cols()); + Line_of_cols retval; + + for (int i=0; i < all.size(); i++) if (all[i]->breakable_b()) retval.push (all[i]); - if ( linelength <=0) + if ( linelength <=0) while ( retval.size() >2) retval.del (1); - return retval; + return retval; } @@ -96,86 +97,86 @@ Break_algorithm::find_breaks() const Line_spacer* Break_algorithm::generate_spacing_problem (Line_of_cols curline)const { - Line_spacer * sp= (*get_line_spacer)(); + Line_spacer * sp= (*get_line_spacer)(); - sp->paper_l_ = pscore_l_->paper_l_; - sp->add_column (curline[0], true, 0.0); - for (int i=1; i< curline.size()-1; i++) + sp->paper_l_ = pscore_l_->paper_l_; + sp->add_column (curline[0], true, 0.0); + for (int i=1; i< curline.size()-1; i++) sp->add_column (curline[i]); - if ( linelength > 0) + if ( linelength > 0) sp->add_column (curline.top(), true, linelength); - else + else sp->add_column (curline.top()); - sp->prepare(); - return sp; + sp->prepare(); + return sp; } Break_algorithm::Break_algorithm() { - pscore_l_ = 0; - get_line_spacer =0; - linelength = 0; + pscore_l_ = 0; + get_line_spacer =0; + linelength = 0; } void Break_algorithm::set_pscore (Paper_score*s) { - pscore_l_ = s; - linelength = s->paper_l_->linewidth_f(); - do_set_pscore(); + pscore_l_ = s; + linelength = s->paper_l_->linewidth_f(); + do_set_pscore(); } bool Break_algorithm::feasible (Line_of_cols curline) const { - if (linelength <= 0) + if (linelength <= 0) return true; - - Real l =0; - for (int i=0; i < curline.size(); i++) + + Real l =0; + for (int i=0; i < curline.size(); i++) l +=curline[i]->width().length (); - return l < linelength; + return l < linelength; } void Break_algorithm::problem_OK() const { - if (!pscore_l_->col_p_list_.size()) + if (!pscore_l_->col_p_list_.size()) error ("Score does not have any columns"); - OK(); + OK(); } void Break_algorithm::OK()const { #ifndef NDEBUG - iter_top (pscore_l_->col_p_list_,start); - PCursor end (pscore_l_->col_p_list_.bottom()); - - assert (start->breakable_b()); - assert (end->breakable_b()); + iter_top (pscore_l_->col_p_list_,start); + PCursor end (pscore_l_->col_p_list_.bottom()); + + assert (start->breakable_b()); + assert (end->breakable_b()); #endif } Array Break_algorithm::solve()const { - return do_solve(); + return do_solve(); } void Break_algorithm::do_set_pscore() { - + } void Break_algorithm::print_stats()const { - if (approx_stats_.count_i_) + if (approx_stats_.count_i_) *mlog << "\nApproximated: " << approx_stats_.str() << "\n"; - if (exact_stats_.count_i_) + if (exact_stats_.count_i_) *mlog << "Calculated exactly: " << exact_stats_.str() << "\n"; } diff --git a/lily/clef-grav.cc b/lily/clef-grav.cc index 93abaf2931..1afaa3cc44 100644 --- a/lily/clef-grav.cc +++ b/lily/clef-grav.cc @@ -16,46 +16,55 @@ Clef_engraver::Clef_engraver() { - clef_p_ = 0; - clef_req_l_ =0; - - set_type ("violin"); + clef_p_ = 0; + clef_req_l_ =0; + + set_type ("violin"); } bool Clef_engraver::set_type (String s) { - clef_type_str_ = s; - if (clef_type_str_ == "violin") { + clef_type_str_ = s; + if (clef_type_str_ == "violin") + { c0_position_i_= -2; - } else if (clef_type_str_ == "alto") { + } + else if (clef_type_str_ == "alto") + { c0_position_i_= 4; - } else if (clef_type_str_ == "tenor") { + } + else if (clef_type_str_ == "tenor") + { c0_position_i_= 6; - } else if (clef_type_str_ == "bass") { + } + else if (clef_type_str_ == "bass") + { c0_position_i_= 10; - } else + } + else return false; - - return true; + + return true; } void Clef_engraver::fill_staff_info (Staff_info &i) { - i.c0_position_i_l_ = &c0_position_i_; + i.c0_position_i_l_ = &c0_position_i_; } void Clef_engraver::read_req (Clef_change_req*c_l) { - if (!set_type (c_l->clef_str_)) + if (!set_type (c_l->clef_str_)) c_l->error ("unknown clef type "); } void Clef_engraver::acknowledge_element (Score_elem_info info) { - if (info.elem_l_->name() == Bar::static_name ()) { + if (info.elem_l_->name() == Bar::static_name ()) + { create_clef(); if ( !clef_req_l_) clef_p_->default_b_ = true; @@ -65,37 +74,39 @@ Clef_engraver::acknowledge_element (Score_elem_info info) void Clef_engraver::do_creation_processing() { - create_clef(); - clef_p_->default_b_ = false; + create_clef(); + clef_p_->default_b_ = false; } bool Clef_engraver::do_try_request (Request * r_l) { - Command_req* creq_l= r_l->command(); - if (!creq_l || !creq_l->clefchange()) + Command_req* creq_l= r_l->command(); + if (!creq_l || !creq_l->clefchange()) return false; - clef_req_l_ = creq_l->clefchange(); - - read_req (clef_req_l_); - return true; + clef_req_l_ = creq_l->clefchange(); + + read_req (clef_req_l_); + return true; } void Clef_engraver::create_clef() { - if (!clef_p_) { + if (!clef_p_) + { clef_p_ = new Clef_item; - announce_element (Score_elem_info (clef_p_,clef_req_l_)); + announce_element (Score_elem_info (clef_p_,clef_req_l_)); } - clef_p_->read (*this); + clef_p_->read (*this); } void Clef_engraver::do_process_requests() { - if (clef_req_l_) { + if (clef_req_l_) + { create_clef(); clef_p_->default_b_ = false; } @@ -104,23 +115,23 @@ Clef_engraver::do_process_requests() void Clef_engraver::do_pre_move_processing() { - if (!clef_p_) + if (!clef_p_) return; - typeset_element (clef_p_); - clef_p_ = 0; + typeset_element (clef_p_); + clef_p_ = 0; } - + void Clef_engraver::do_post_move_processing() { - clef_req_l_ = 0; + clef_req_l_ = 0; } void Clef_engraver::do_removal_processing() { - delete clef_p_; - clef_p_ =0; + delete clef_p_; + clef_p_ =0; } diff --git a/lily/clef-item.cc b/lily/clef-item.cc index b1a9c4a665..8a2534b111 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -17,9 +17,10 @@ void Clef_item::do_pre_processing() { - change_b_ = ! (break_status_i() == 1); + change_b_ = ! (break_status_i() == 1); - if (default_b_){ + if (default_b_) + { empty_b_ = (break_status_i() != 1); transparent_b_ = (break_status_i() != 1); } @@ -27,41 +28,41 @@ Clef_item::do_pre_processing() Clef_item::Clef_item() { - breakable_b_ =true; - default_b_ = false; - change_b_ = true; - read ("violin"); + breakable_b_ =true; + default_b_ = false; + change_b_ = true; + read ("violin"); } void Clef_item::read (String t) { - type_= t; - if (type_ == "violin") + type_= t; + if (type_ == "violin") y_off = 2; - if (type_ == "alto") + if (type_ == "alto") y_off = 4; - if (type_ == "tenor") + if (type_ == "tenor") y_off = 6; - if (type_ == "bass") + if (type_ == "bass") y_off = 6; } void Clef_item::read (Clef_engraver const &k) { - read (k.clef_type_str_); + read (k.clef_type_str_); } Molecule* Clef_item::brew_molecule_p()const { - String t = type_; - if (change_b_) + String t = type_; + if (change_b_) t += "_change"; - Symbol s = paper()->lookup_l ()->clef (t); - Molecule*output = new Molecule (Atom (s)); - output->translate (paper()->internote_f () * y_off, Y_AXIS); - return output; + Symbol s = paper()->lookup_l ()->clef (t); + Molecule*output = new Molecule (Atom (s)); + output->translate (paper()->internote_f () * y_off, Y_AXIS); + return output; } diff --git a/lily/col-info.cc b/lily/col-info.cc index deb2dee730..e05498f0e1 100644 --- a/lily/col-info.cc +++ b/lily/col-info.cc @@ -14,28 +14,28 @@ void Colinfo::print() const { #ifndef NPRINT - DOUT << "column { "; - if (fixed()) + DOUT << "column { "; + if (fixed()) DOUT << "fixed at " << fixed_position()<<", "; - assert (pcol_l_); - DOUT << "[" << minleft() << ", " << minright () << "]"; - DOUT <<"}\n"; + assert (pcol_l_); + DOUT << "[" << minleft() << ", " << minright () << "]"; + DOUT <<"}\n"; #endif } Colinfo::Colinfo (PCol *col_l, Real const *fixed_C) { - if (fixed_C) + if (fixed_C) fixpos_p_.set_l (fixed_C); - ugh_b_ = false; - pcol_l_ = col_l; - width = pcol_l_->width(); + ugh_b_ = false; + pcol_l_ = col_l; + width = pcol_l_->width(); } Colinfo::Colinfo() { - ugh_b_ = false; - pcol_l_ =0; + ugh_b_ = false; + pcol_l_ =0; } diff --git a/lily/colhpos.cc b/lily/colhpos.cc index 23d42e65ff..d7850f5c27 100644 --- a/lily/colhpos.cc +++ b/lily/colhpos.cc @@ -14,10 +14,10 @@ Col_hpositions::Col_hpositions() { - energy_f_ = infinity_f; - ugh_b_ = false; - satisfies_constraints_b_ = false; - spacer_l_ =0; + energy_f_ = infinity_f; + ugh_b_ = false; + satisfies_constraints_b_ = false; + spacer_l_ =0; } Col_hpositions::~Col_hpositions() @@ -28,17 +28,17 @@ Col_hpositions::~Col_hpositions() void Col_hpositions::add (PCol*c) { - cols.push (c); + cols.push (c); } void Col_hpositions::print() const { #ifndef NPRINT - DOUT << "energy : " << energy_f_ << '\n'; - DOUT << "line of " << config.size() << " cols\n"; - Vector v (config); - DOUT << v; + DOUT << "energy : " << energy_f_ << '\n'; + DOUT << "line of " << config.size() << " cols\n"; + Vector v (config); + DOUT << v; #endif } @@ -46,29 +46,29 @@ void Col_hpositions::OK()const { #ifndef NDEBUG - assert (config.size() == cols.size ()); + assert (config.size() == cols.size ()); #endif } void Col_hpositions::stupid_solution() { - energy_f_ = infinity_f; - ugh_b_ = true; - config = spacer_l_->default_solution(); + energy_f_ = infinity_f; + ugh_b_ = true; + config = spacer_l_->default_solution(); } void Col_hpositions::solve_line() { - spacer_l_->solve (this); + spacer_l_->solve (this); } void Col_hpositions::approximate_solve_line() { - spacer_l_->lower_bound_solution (this); + spacer_l_->lower_bound_solution (this); } diff --git a/lily/collision-grav.cc b/lily/collision-grav.cc index 600703bcd2..e25f249493 100644 --- a/lily/collision-grav.cc +++ b/lily/collision-grav.cc @@ -13,27 +13,29 @@ void Collision_engraver::acknowledge_element (Score_elem_info i) { - if (!(i.elem_l_->name() == Note_column::static_name ())) + if (!(i.elem_l_->name() == Note_column::static_name ())) return; - if (!col_p_) { + if (!col_p_) + { col_p_ = new Collision; announce_element (Score_elem_info (col_p_,0)); } - col_p_->add ((Note_column*)i.elem_l_->item()); + col_p_->add ((Note_column*)i.elem_l_->item()); } void Collision_engraver::do_pre_move_processing() { - if (col_p_) { + if (col_p_) + { typeset_element (col_p_); col_p_ =0; } } Collision_engraver::Collision_engraver() { - col_p_ =0; + col_p_ =0; } diff --git a/lily/collision.cc b/lily/collision.cc index 798c74be45..a5fd6aee0b 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -18,9 +18,9 @@ Collision::Collision() void Collision::add (Note_column* ncol_l) { - clash_l_arr_.push (ncol_l); - add_element (ncol_l); - add_dependency (ncol_l); + clash_l_arr_.push (ncol_l); + add_element (ncol_l); + add_dependency (ncol_l); } /** should derive of Array. @@ -28,11 +28,11 @@ Collision::add (Note_column* ncol_l) static int idx (int dir, bool h_shift_b) { - assert (abs (dir) == 1); - int j = dir > 0 ? 0 : 3; - if ( h_shift_b) + assert (abs (dir) == 1); + int j = dir > 0 ? 0 : 3; + if ( h_shift_b) j += dir; - return j; + return j; } /** This complicated routine moves note columns around horizontally @@ -46,101 +46,114 @@ int idx (int dir, bool h_shift_b) void Collision::do_pre_processing() { - if (clash_l_arr_.size() <= 1) + if (clash_l_arr_.size() <= 1) return; - - /* - [stem up, stem up shifted, stem down shifted, stem down] - */ - Array clash_group_arr_a[4]; - - for (int i=0; i < clash_l_arr_.size(); i++) { + + /* + [stem up, stem up shifted, stem down shifted, stem down] + */ + Array clash_group_arr_a[4]; + + for (int i=0; i < clash_l_arr_.size(); i++) + { Note_column* c_l = clash_l_arr_[i]; - if (! c_l->dir_i_) { + if (! c_l->dir_i_) + { warning ("No stem direction set. Ignoring column in clash. "); continue; - } + } int d = (c_l->dir_i_); clash_group_arr_a[idx (d, c_l->h_shift_b_)].push (c_l); } - - - for (int j=0; j < 4; j++) { - if (clash_group_arr_a[j].size() > 1) { + + + for (int j=0; j < 4; j++) + { + if (clash_group_arr_a[j].size() > 1) + { warning ("Too many clashing notecolumns. Ignoring them."); return; - } + } } - int d = 1; - do { - if (!clash_group_arr_a[idx (d, false)].size()){ + int d = 1; + do + { + if (!clash_group_arr_a[idx (d, false)].size()) + { clash_group_arr_a[idx (d, false)] = clash_group_arr_a[idx (d, true)]; clash_group_arr_a[idx (d, true)].clear(); - } - } while ((d *= -1) != 1); + } + } while ((d *= -1) != 1); - Interval_t y_extent[4]; - Note_column * col_l_a[4]; - Real x_off [4]; - int y_off[4]; - - for (int j =0 ; j < 4; j++) { + Interval_t y_extent[4]; + Note_column * col_l_a[4]; + Real x_off [4]; + int y_off[4]; + + for (int j =0 ; j < 4; j++) + { if (clash_group_arr_a[j].size()) col_l_a[j] = clash_group_arr_a[j][0]; else col_l_a[j] = 0; - if (col_l_a[j]) { + if (col_l_a[j]) + { y_extent[j] = col_l_a[j]->head_positions_interval(); - } + } x_off [j] = 0.0; y_off[j] = 0; } - - do { + + do + { x_off[idx (d, true)] = d*0.5; - } while ((d *= -1) != 1); + } while ((d *= -1) != 1); - // y_extent: smallest y-pos noteball interval containing all balls - // 4 (0..3) groups: stem up/down; shift on/off; - Interval_t middle (y_extent[idx (-1,0)].max(), + // y_extent: smallest y-pos noteball interval containing all balls + // 4 (0..3) groups: stem up/down; shift on/off; + Interval_t middle (y_extent[idx (-1,0)].max(), y_extent[idx (1,0)].min()); - Interval_t open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1); - do{ + Interval_t open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1); + do + { if (!open_middle.contains_b (y_extent[idx (d,true)])) x_off[idx (d, true)] = d *1.0 ; - } while ((d *= -1) != 1); + } while ((d *= -1) != 1); - if (!middle.empty_b() + if (!middle.empty_b() && middle.length() < 2 && col_l_a[idx (1,0)] && col_l_a[idx (-1,0)]) { // reproduction of bugfix at 3am ? Note_head * nu_l= col_l_a[idx (1,0)]->head_l_arr_[0]; Note_head * nd_l = col_l_a[idx (-1,0)]->head_l_arr_.top(); if (! (nu_l->balltype_i_ == nd_l->balltype_i_ - && nu_l->dots_i_ == nd_l->dots_i_ && middle.length() == 0)) { + && nu_l->dots_i_ == nd_l->dots_i_ && middle.length() == 0)) + { x_off[idx (1,0)] -= 0.5; x_off[idx (1,1)] -= 0.5; x_off[idx (-1,1)] += 0.5; x_off[idx (-1,0)] += 0.5; - } + } - } - Real inter_f = paper()->internote_f (); - Real wid_f = paper()->note_width (); - for (int j=0; j < 4; j++) { - if (col_l_a[j]) { + } + Real inter_f = paper()->internote_f (); + Real wid_f = paper()->note_width (); + for (int j=0; j < 4; j++) + { + if (col_l_a[j]) + { /* collision.cc:138: request for method `translate' is ambiguous (shaddup) */ Offset o (x_off[j] * wid_f, y_off[j] * inter_f); ((Score_elem*)col_l_a[j])->translate (o); - } + } } } @@ -150,6 +163,6 @@ IMPLEMENT_IS_TYPE_B1(Collision, Item); void Collision::do_substitute_dependency (Score_elem*o_l,Score_elem*n_l) { - clash_l_arr_.substitute ((Note_column*)o_l->item(), + clash_l_arr_.substitute ((Note_column*)o_l->item(), (Note_column*)(n_l?n_l->item():0)); } diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 574b91c9ff..d5c16cb442 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -15,16 +15,16 @@ Crescendo::Crescendo() { - grow_dir_i_ =0; - dir_i_ = -1 ; - left_dyn_b_ = right_dyn_b_ =false; - inside_staff_b_ = false; + grow_dir_i_ =0; + dir_i_ = -1 ; + left_dyn_b_ = right_dyn_b_ =false; + inside_staff_b_ = false; } Interval Crescendo::symbol_height()const { - return get_symbol().dim[Y_AXIS]; + return get_symbol().dim[Y_AXIS]; } static Real absdyn_dim = 10 PT; // ugh @@ -32,35 +32,38 @@ static Real absdyn_dim = 10 PT; // ugh Symbol Crescendo::get_symbol()const { - Real w_dim = width().length (); - if ( left_dyn_b_) { + Real w_dim = width().length (); + if ( left_dyn_b_) + { w_dim -= absdyn_dim; } - if ( right_dyn_b_) { + if ( right_dyn_b_) + { w_dim -= absdyn_dim; } - - if (w_dim < 0) { + + if (w_dim < 0) + { warning ("Crescendo too small"); w_dim = 0; } - return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_i_ < 0)); + return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_i_ < 0)); } Molecule* Crescendo::brew_molecule_p() const { - Molecule* m_p =0; - Real x_off_dim=0.0; - if ( left_dyn_b_) + Molecule* m_p =0; + Real x_off_dim=0.0; + if ( left_dyn_b_) x_off_dim += absdyn_dim; - - m_p = new Molecule; - Symbol s (get_symbol()); - m_p->add (Atom (s)); - m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ())); - return m_p; + + m_p = new Molecule; + Symbol s (get_symbol()); + m_p->add (Atom (s)); + m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ())); + return m_p; } diff --git a/lily/debug.cc b/lily/debug.cc index 964353f348..2141be63a4 100644 --- a/lily/debug.cc +++ b/lily/debug.cc @@ -13,11 +13,13 @@ ostream * nulldev =0; // ugh struct _Dinit { - _Dinit() { + _Dinit() + { nulldev = new ofstream ("/dev/null"); monitor = new Dstream (&cout,".dstreamrc"); } - ~_Dinit() { + ~_Dinit() + { delete nulldev; delete monitor; } @@ -31,14 +33,14 @@ struct _Dinit { void mynewhandler() { - assert (false); + assert (false); } void float_handler (int) { - cerr << "Floating point exception .. \n"<< flush; - assert (false); + cerr << "Floating point exception .. \n"<< flush; + assert (false); } /// just to make sure print_rat is linked in @@ -47,13 +49,13 @@ static void (*rat_printer)(Moment const&); void debug_init() { - rat_printer = print_rat; + rat_printer = print_rat; #ifndef NDEBUG - set_new_handler (&mynewhandler); + set_new_handler (&mynewhandler); #endif - set_flower_debug (*monitor, check_debug); - - signal (SIGFPE, float_handler); + set_flower_debug (*monitor, check_debug); + + signal (SIGFPE, float_handler); } bool check_debug=false; @@ -61,8 +63,8 @@ bool check_debug=false; void set_debug (bool b) { - check_debug =b; - set_flower_debug (*monitor, check_debug); + check_debug =b; + set_flower_debug (*monitor, check_debug); } diff --git a/lily/dimen.cc b/lily/dimen.cc index 4809adb951..73fa9d3ca7 100644 --- a/lily/dimen.cc +++ b/lily/dimen.cc @@ -6,34 +6,35 @@ Real parse_dimen (String dim) { - int i=dim.length_i()-1; - char const *s = dim; - while (i > 0 && (isspace (s[i]) || isalpha (s[i]))){ + int i=dim.length_i()-1; + char const *s = dim; + while (i > 0 && (isspace (s[i]) || isalpha (s[i]))) + { i--; } - String unit (s + i+1); - return convert_dimen (dim.value_f(), unit); + String unit (s + i+1); + return convert_dimen (dim.value_f(), unit); } Real convert_dimen (Real quant, String unit) { - if (unit == "cm") + if (unit == "cm") return quant * CM_TO_PT; - if (unit == "pt") + if (unit == "pt") return quant; - if (unit == "mm") + if (unit == "mm") return quant*CM_TO_PT/10; - if (unit == "in") + if (unit == "in") return quant * INCH_TO_PT; - error ("unknown length unit: `" + unit+"'"); + error ("unknown length unit: `" + unit+"'"); } String print_dimen (Real r) { - String s (r, "%.3f"); - s += "pt "; - return s; + String s (r, "%.3f"); + s += "pt "; + return s; } diff --git a/lily/directional-spanner.cc b/lily/directional-spanner.cc index 0e1c058f49..837fae76d9 100644 --- a/lily/directional-spanner.cc +++ b/lily/directional-spanner.cc @@ -3,17 +3,17 @@ void Directional_spanner::set_default_dir() { - dir_i_ = -1; + dir_i_ = -1; } void Directional_spanner::do_pre_processing() { - if (!dir_i_) + if (!dir_i_) set_default_dir(); } Directional_spanner::Directional_spanner() { - dir_i_ = 0; + dir_i_ = 0; } diff --git a/lily/dynamic-grav.cc b/lily/dynamic-grav.cc index 6bfe5585d7..a159d32d72 100644 --- a/lily/dynamic-grav.cc +++ b/lily/dynamic-grav.cc @@ -18,35 +18,37 @@ Dynamic_engraver::Dynamic_engraver() { - dir_i_ =0; - do_post_move_processing(); - dynamic_p_ =0; - to_end_cresc_p_ = cresc_p_ = 0; - cresc_req_l_ = 0; + dir_i_ =0; + do_post_move_processing(); + dynamic_p_ =0; + to_end_cresc_p_ = cresc_p_ = 0; + cresc_req_l_ = 0; } void Dynamic_engraver::do_post_move_processing() { - dynamic_req_l_arr_.clear(); + dynamic_req_l_arr_.clear(); } bool Dynamic_engraver::do_try_request (Request * r) { - Musical_req * m = r->musical(); - if (!m || !m->dynamic()) + Musical_req * m = r->musical(); + if (!m || !m->dynamic()) return false; - dynamic_req_l_arr_.push (m->dynamic()); - return true; + dynamic_req_l_arr_.push (m->dynamic()); + return true; } void Dynamic_engraver::do_process_requests() { - Crescendo* new_cresc_p=0; - for (int i=0; i < dynamic_req_l_arr_.size(); i++) { + Crescendo* new_cresc_p=0; + for (int i=0; i < dynamic_req_l_arr_.size(); i++) + { Dynamic_req *dreq_l = dynamic_req_l_arr_[i]; - if (dreq_l->absdynamic()) { + if (dreq_l->absdynamic()) + { Text_def * td_p = new Text_def; td_p->align_i_ = 0; String loud =Dynamic_req::loudness_str ( @@ -59,46 +61,58 @@ Dynamic_engraver::do_process_requests() dynamic_p_ = new Text_item (td_p); announce_element (Score_elem_info (dynamic_p_, dreq_l)); - } else if (dreq_l->span_dynamic()) { + } + else if (dreq_l->span_dynamic()) + { Span_dynamic_req* span_l = dreq_l->span_dynamic(); - if (span_l->spantype == Span_req::STOP) { - if (!cresc_p_) { + if (span_l->spantype == Span_req::STOP) + { + if (!cresc_p_) + { span_l->warning ("Can't find cresc to end "); - } else { + } + else + { assert (!to_end_cresc_p_); to_end_cresc_p_ =cresc_p_; cresc_p_ = 0; - } - } else if (span_l->spantype == Span_req::START) { + } + } + else if (span_l->spantype == Span_req::START) + { cresc_req_l_ = span_l; assert (!new_cresc_p); new_cresc_p = new Crescendo; new_cresc_p->grow_dir_i_ = span_l->dynamic_dir_i_; announce_element (Score_elem_info (new_cresc_p, span_l)); - } - } + } + } } - if ( new_cresc_p) { + if ( new_cresc_p) + { cresc_p_ = new_cresc_p; cresc_p_->left_col_l_ = get_staff_info().musical_l (); - if (dynamic_p_) { + if (dynamic_p_) + { cresc_p_->left_dyn_b_ = true; - } + } } } void Dynamic_engraver::do_pre_move_processing() { - Staff_symbol* s_l = get_staff_info().staff_sym_l_; - if (dynamic_p_) { + Staff_symbol* s_l = get_staff_info().staff_sym_l_; + if (dynamic_p_) + { dynamic_p_->set_staffsym (s_l); typeset_element (dynamic_p_); dynamic_p_ = 0; } - if ( to_end_cresc_p_) { + if ( to_end_cresc_p_) + { if (dynamic_p_) to_end_cresc_p_->right_dyn_b_=true; @@ -112,7 +126,7 @@ Dynamic_engraver::do_pre_move_processing() void Dynamic_engraver::set_feature (Feature i) { - if (i.type_ == "vdir") + if (i.type_ == "vdir") dir_i_ = i.value_; } @@ -122,17 +136,19 @@ ADD_THIS_ENGRAVER(Dynamic_engraver); Dynamic_engraver::~Dynamic_engraver() { - delete dynamic_p_; - delete to_end_cresc_p_; - if (cresc_p_) { + delete dynamic_p_; + delete to_end_cresc_p_; + if (cresc_p_) + { cresc_req_l_->warning ("unended crescendo"); } - delete cresc_p_; + delete cresc_p_; } void Dynamic_engraver::acknowledge_element (Score_elem_info i) { - if (i.elem_l_->name() == Note_column::static_name ()) { + if (i.elem_l_->name() == Note_column::static_name ()) + { if (dynamic_p_) dynamic_p_->add_support (i.elem_l_); if (to_end_cresc_p_) to_end_cresc_p_->add_support (i.elem_l_); diff --git a/lily/elem-group-item.cc b/lily/elem-group-item.cc index c22739a849..ec744fee45 100644 --- a/lily/elem-group-item.cc +++ b/lily/elem-group-item.cc @@ -13,7 +13,7 @@ void Horizontal_vertical_group_item::do_print()const { - Horizontal_vertical_group_element::do_print(); + Horizontal_vertical_group_element::do_print(); } IMPLEMENT_IS_TYPE_B2(Horizontal_vertical_group_item,Horizontal_vertical_group_element,Item); diff --git a/lily/elem-group.cc b/lily/elem-group.cc index e1902867ad..807573384f 100644 --- a/lily/elem-group.cc +++ b/lily/elem-group.cc @@ -14,26 +14,26 @@ void Axis_group_element::do_unlink() { - remove_all(); + remove_all(); } bool Axis_group_element::contains_b (Score_elem const*e)const { - return axis_admin_.contains_b (e); + return axis_admin_.contains_b (e); } Link_array Axis_group_element::get_extra_dependencies()const { - return axis_admin_.elem_l_arr_; + return axis_admin_.elem_l_arr_; } void Axis_group_element::do_print()const { - axis_admin_.print(); + axis_admin_.print(); } // **************** @@ -42,51 +42,51 @@ Axis_group_element::do_print()const void Vertical_group_element::add_element (Score_elem*e) { - axis_admin_.add_element (e, this, Y_AXIS, Y_AXIS); + axis_admin_.add_element (e, this, Y_AXIS, Y_AXIS); } void Vertical_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e, Y_AXIS, Y_AXIS); + axis_admin_.remove_element (e, Y_AXIS, Y_AXIS); } Interval Vertical_group_element::do_height() const { - return axis_admin_.extent (Y_AXIS); + return axis_admin_.extent (Y_AXIS); } void Vertical_group_element::remove_all() { - axis_admin_.remove_all (Y_AXIS,Y_AXIS); + axis_admin_.remove_all (Y_AXIS,Y_AXIS); } // **************** void Horizontal_group_element::remove_all() { - axis_admin_.remove_all (X_AXIS,X_AXIS); + axis_admin_.remove_all (X_AXIS,X_AXIS); } void Horizontal_group_element::add_element (Score_elem*e) { - axis_admin_.add_element (e,this, X_AXIS,X_AXIS); + axis_admin_.add_element (e,this, X_AXIS,X_AXIS); } void Horizontal_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e,X_AXIS,X_AXIS); + axis_admin_.remove_element (e,X_AXIS,X_AXIS); } Interval Horizontal_group_element::do_width()const { - return axis_admin_.extent (X_AXIS); + return axis_admin_.extent (X_AXIS); } @@ -95,18 +95,18 @@ Horizontal_group_element::do_width()const void Horizontal_vertical_group_element::remove_all() { - axis_admin_.remove_all (X_AXIS,Y_AXIS); + axis_admin_.remove_all (X_AXIS,Y_AXIS); } void Horizontal_vertical_group_element::add_element (Score_elem *e) { - axis_admin_.add_element (e, this, X_AXIS, Y_AXIS); + axis_admin_.add_element (e, this, X_AXIS, Y_AXIS); } void Horizontal_vertical_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e, X_AXIS, Y_AXIS); + axis_admin_.remove_element (e, X_AXIS, Y_AXIS); } diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index acf0c2587e..aae1051fb2 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -20,18 +20,19 @@ Engraver* get_engraver_p (String); void Engraver_group_engraver::print()const { - Engraver::print(); + Engraver::print(); } Engraver_group_engraver::~Engraver_group_engraver() { - assert (removable_b()); + assert (removable_b()); } void Engraver_group_engraver::check_removal() { - for (int i =0; i < group_l_arr_.size();) { + for (int i =0; i < group_l_arr_.size();) + { group_l_arr_[i]->check_removal(); if (group_l_arr_[i]->removable_b()) terminate_engraver (group_l_arr_[i]); @@ -43,20 +44,21 @@ Engraver_group_engraver::check_removal() bool Engraver_group_engraver::removable_b()const { - return !iterator_count_&& !group_l_arr_.size() ; + return !iterator_count_&& !group_l_arr_.size() ; } Engraver_group_engraver::Engraver_group_engraver() { - itrans_l_ = 0; + itrans_l_ = 0; } void Engraver_group_engraver::set_feature (Feature d) { - PCursor i (grav_list_.top()); - // why the while construct? - while (i.ok()) { + PCursor i (grav_list_.top()); + // why the while construct? + while (i.ok()) + { // this construction to ensure clean deletion Engraver *grav_l = i++; grav_l->set_feature (d); @@ -66,8 +68,9 @@ Engraver_group_engraver::set_feature (Feature d) void Engraver_group_engraver::sync_features() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->sync_features(); } @@ -76,8 +79,9 @@ Engraver_group_engraver::sync_features() void Engraver_group_engraver::do_pre_move_processing() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->pre_move_processing(); } @@ -86,8 +90,9 @@ Engraver_group_engraver::do_pre_move_processing() void Engraver_group_engraver::do_process_requests() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->process_requests(); } @@ -97,8 +102,9 @@ Engraver_group_engraver::do_process_requests() void Engraver_group_engraver::do_post_move_processing() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { // this construction to ensure clean deletion Engraver *grav_l = i++; grav_l->post_move_processing(); @@ -109,14 +115,14 @@ Engraver_group_engraver::do_post_move_processing() bool Engraver_group_engraver::contains_b (Engraver* grav_l)const { - bool parent_b = Engraver::contains_b (grav_l); - - if (parent_b) + bool parent_b = Engraver::contains_b (grav_l); + + if (parent_b) return true; - for (PCursor i (grav_list_.top()); i.ok (); i++) + for (PCursor i (grav_list_.top()); i.ok (); i++) if (i->contains_b (grav_l)) return true; - return false; + return false; } @@ -124,29 +130,32 @@ Engraver_group_engraver::contains_b (Engraver* grav_l)const bool Engraver_group_engraver::do_try_request (Request*req_l) { - bool hebbes_b =false; - for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) + bool hebbes_b =false; + for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) hebbes_b =nongroup_l_arr_[i]->try_request (req_l); - if (!hebbes_b && daddy_grav_l_) + if (!hebbes_b && daddy_grav_l_) hebbes_b = daddy_grav_l_->try_request (req_l); - return hebbes_b ; + return hebbes_b ; } bool Engraver_group_engraver::try_request (Request* r) { - return Engraver::try_request (r); + return Engraver::try_request (r); } void Engraver_group_engraver::add (Engraver *grav_p) { - grav_list_.bottom().add (grav_p); - grav_p->daddy_grav_l_ = this; + grav_list_.bottom().add (grav_p); + grav_p->daddy_grav_l_ = this; - if (grav_p->is_type_b (Engraver_group_engraver::static_name())) { + if (grav_p->is_type_b (Engraver_group_engraver::static_name())) + { group_l_arr_.push ((Engraver_group_engraver*)grav_p); - } else { + } + else + { nongroup_l_arr_ .push (grav_p); } } @@ -155,21 +164,21 @@ Engraver_group_engraver::add (Engraver *grav_p) Engraver * Engraver_group_engraver::remove_engraver_p (Engraver*grav_l) { - group_l_arr_.substitute ((Engraver_group_engraver*)grav_l,0); - nongroup_l_arr_.substitute (grav_l,0); - PCursor grav_cur (grav_list_.find (grav_l)); - - return grav_cur.remove_p(); + group_l_arr_.substitute ((Engraver_group_engraver*)grav_l,0); + nongroup_l_arr_.substitute (grav_l,0); + PCursor grav_cur (grav_list_.find (grav_l)); + + return grav_cur.remove_p(); } void Engraver_group_engraver::terminate_engraver (Engraver*r_l) { - DOUT << "Removing " << r_l->name() << " at " << get_staff_info ().when () << "\n"; - r_l->removal_processing(); - Engraver * grav_p =remove_engraver_p (r_l); - - delete grav_p; + DOUT << "Removing " << r_l->name() << " at " << get_staff_info ().when () << "\n"; + r_l->removal_processing(); + Engraver * grav_p =remove_engraver_p (r_l); + + delete grav_p; } IMPLEMENT_IS_TYPE_B2(Engraver_group_engraver,Engraver, Translator); @@ -180,11 +189,11 @@ void Engraver_group_engraver::do_print()const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << "ID: " << id_str_ ; - DOUT << " iterators: " << iterator_count_<< "\n"; - for (PCursor i (grav_list_.top()); i.ok (); i++) + DOUT << "ID: " << id_str_ ; + DOUT << " iterators: " << iterator_count_<< "\n"; + for (PCursor i (grav_list_.top()); i.ok (); i++) i->print(); #endif } @@ -193,24 +202,27 @@ Engraver_group_engraver::do_print()const Engraver_group_engraver* Engraver_group_engraver::find_engraver_l (String n, String id) { - if (name() == n && id_str_ == id) + if (name() == n && id_str_ == id) return this; - Engraver_group_engraver * r = 0; - for (int i =0; !r && i< group_l_arr_.size(); i++) { + Engraver_group_engraver * r = 0; + for (int i =0; !r && i< group_l_arr_.size(); i++) + { r = group_l_arr_[i]->find_engraver_l (n,id); } - - return r; + + return r; } Translator* Engraver_group_engraver::find_get_translator_l (String n,String id) { - Translator * ret=0; - Input_translator * itrans_l= itrans_l_-> recursive_find ( n); - if (itrans_l) { + Translator * ret=0; + Input_translator * itrans_l= itrans_l_-> recursive_find ( n); + if (itrans_l) + { ret = find_engraver_l (n,id); - if (!ret) { + if (!ret) + { Engraver_group_engraver * group = itrans_l-> get_group_engraver_p(); @@ -222,110 +234,115 @@ Engraver_group_engraver::find_get_translator_l (String n,String id) else return ret->find_get_translator_l (n,id); - } - } else if (daddy_grav_l_) + } + } + else if (daddy_grav_l_) ret =daddy_grav_l_->find_get_translator_l (n,id); - else { + else + { warning ("Can't find or create `" + n + "' called `" + id + "'\n"); ret =0; } - return ret; + return ret; } int Engraver_group_engraver::depth_i()const { - return daddy_grav_l_->depth_i() + 1; + return daddy_grav_l_->depth_i() + 1; } Translator* Engraver_group_engraver::ancestor_l (int l) { - if (!l || !daddy_grav_l_) + if (!l || !daddy_grav_l_) return this; - - return daddy_grav_l_->ancestor_l (l-1); + + return daddy_grav_l_->ancestor_l (l-1); } void Engraver_group_engraver::announce_element (Score_elem_info info) { - announce_info_arr_.push (info); - Engraver::announce_element (info); + announce_info_arr_.push (info); + Engraver::announce_element (info); } void Engraver_group_engraver::do_announces() { - for (int i=0; i < group_l_arr_.size(); i++) { + for (int i=0; i < group_l_arr_.size(); i++) + { group_l_arr_[i]->do_announces(); } - - Request dummy_req; + + Request dummy_req; - for (int j =0; j < announce_info_arr_.size(); j++){ - Score_elem_info info = announce_info_arr_[j]; - - if (!info.req_l_) + for (int j =0; j < announce_info_arr_.size(); j++) + { + Score_elem_info info = announce_info_arr_[j]; + + if (!info.req_l_) info.req_l_ = &dummy_req; - for (int i=0; i < nongroup_l_arr_.size(); i++) { // Is this good enough?6 + for (int i=0; i < nongroup_l_arr_.size(); i++) { // Is this good enough?6 if (nongroup_l_arr_[i] != info.origin_grav_l_arr_[0]) nongroup_l_arr_[i]->acknowledge_element (info); } } - announce_info_arr_.clear(); + announce_info_arr_.clear(); } void Engraver_group_engraver::do_removal_processing() { - for (PCursor i (grav_list_.top()); i.ok (); i++) + for (PCursor i (grav_list_.top()); i.ok (); i++) i->removal_processing(); } Staff_info Engraver_group_engraver::get_staff_info()const { - Staff_info inf = Engraver::get_staff_info(); + Staff_info inf = Engraver::get_staff_info(); - for (int i=0; i < nongroup_l_arr_.size(); i++) + for (int i=0; i < nongroup_l_arr_.size(); i++) nongroup_l_arr_[i]->fill_staff_info (inf); - - return inf; + + return inf; } Translator* Engraver_group_engraver::get_default_interpreter() { - // ? - if ( is_bottom_engraver_b()) + // ? + if ( is_bottom_engraver_b()) return daddy_grav_l_->get_default_interpreter(); - Engraver_group_engraver *grav_p= itrans_l_-> + Engraver_group_engraver *grav_p= itrans_l_-> get_default_itrans_l()->get_group_engraver_p (); - add (grav_p); - if (grav_p->is_bottom_engraver_b()) + add (grav_p); + if (grav_p->is_bottom_engraver_b()) return grav_p; - else + else return grav_p->get_default_interpreter(); } bool Engraver_group_engraver::is_bottom_engraver_b()const { - return !itrans_l_->get_default_itrans_l(); + return !itrans_l_->get_default_itrans_l(); } Engraver* Engraver_group_engraver::get_simple_engraver (char const *type)const { - for (int i=0; i < nongroup_l_arr_.size(); i++) { + for (int i=0; i < nongroup_l_arr_.size(); i++) + { if (nongroup_l_arr_[i]->name() == type) return nongroup_l_arr_[i]; } - if ( daddy_grav_l_) + if ( daddy_grav_l_) return daddy_grav_l_->get_simple_engraver (type); - return 0; + return 0; } diff --git a/lily/engraver.cc b/lily/engraver.cc index f3cf488c0c..52eba772e0 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -15,116 +15,117 @@ void Engraver::post_move_processing() { - if (status < CREATION_INITED) { + if (status < CREATION_INITED) + { do_creation_processing(); status = CREATION_INITED; } - if (status >= MOVE_INITED) + if (status >= MOVE_INITED) return; - do_post_move_processing(); - status = MOVE_INITED; + do_post_move_processing(); + status = MOVE_INITED; } void Engraver::removal_processing() { - if ( status < CREATION_INITED) + if ( status < CREATION_INITED) do_creation_processing(); - - do_removal_processing(); + + do_removal_processing(); } bool Engraver::try_request (Request * r) { - if (status < MOVE_INITED) + if (status < MOVE_INITED) post_move_processing(); - return do_try_request (r); + return do_try_request (r); } void Engraver::process_requests() { - if (status < PROCESSED_REQS) + if (status < PROCESSED_REQS) post_move_processing(); - else if (status >= PROCESSED_REQS) + else if (status >= PROCESSED_REQS) return; - - status = PROCESSED_REQS; - do_process_requests(); + + status = PROCESSED_REQS; + do_process_requests(); } void Engraver::pre_move_processing() { - do_pre_move_processing(); - status = CREATION_INITED; + do_pre_move_processing(); + status = CREATION_INITED; } void Engraver::fill_staff_info (Staff_info&) { - + } Scalar Engraver::get_feature (String t) { - return daddy_grav_l_->get_feature (t); + return daddy_grav_l_->get_feature (t); } bool Engraver::do_try_request (Request*) { - return false; + return false; } Engraver::Engraver() { - status = VIRGIN; - daddy_grav_l_ = 0; + status = VIRGIN; + daddy_grav_l_ = 0; } void Engraver::announce_element (Score_elem_info i) { - i.origin_grav_l_arr_.push (this); - daddy_grav_l_->announce_element (i); + i.origin_grav_l_arr_.push (this); + daddy_grav_l_->announce_element (i); } void Engraver::typeset_element (Score_elem*p) { - daddy_grav_l_->typeset_element (p); + daddy_grav_l_->typeset_element (p); } Paper_def* Engraver::paper()const { - return daddy_grav_l_->paper(); + return daddy_grav_l_->paper(); } bool Engraver::contains_b (Engraver *grav_l)const { - return this == grav_l; + return this == grav_l; } Staff_info Engraver::get_staff_info() const { - return daddy_grav_l_->get_staff_info(); + return daddy_grav_l_->get_staff_info(); } void Engraver::print() const { #ifndef NPRINT - DOUT << "\n" << name() << " {"; - do_print(); - DOUT << "}"; + DOUT << "\n" << name() << " {"; + do_print(); + DOUT << "}"; #endif } diff --git a/lily/general-script-def.cc b/lily/general-script-def.cc index 06b678a965..f3b202e805 100644 --- a/lily/general-script-def.cc +++ b/lily/general-script-def.cc @@ -13,47 +13,47 @@ int General_script_def::staff_dir_i()const { - return -1; + return -1; } int General_script_def::rel_stem_dir_i()const { - return 0; + return 0; } int General_script_def::priority_i()const { - return 1000; + return 1000; } bool General_script_def::inside_b()const { - return false; + return false; } bool General_script_def::equal_b (General_script_def const&g)const { - if (name() != g.name ()) + if (name() != g.name ()) return false; - return do_equal_b (&g); + return do_equal_b (&g); } bool General_script_def::do_equal_b (General_script_def const*)const { - return true; + return true; } void General_script_def::print() const { - DOUT << name() << "{"; - do_print(); - DOUT << "}"; + DOUT << name() << "{"; + do_print(); + DOUT << "}"; } void @@ -64,8 +64,8 @@ General_script_def::do_print() const Atom General_script_def::get_atom (Paper_def*, int)const { - Symbol s; - return Atom (s); + Symbol s; + return Atom (s); } IMPLEMENT_IS_TYPE_B(General_script_def); diff --git a/lily/global-gravs.cc b/lily/global-gravs.cc index df0df5322a..784c193939 100644 --- a/lily/global-gravs.cc +++ b/lily/global-gravs.cc @@ -13,14 +13,15 @@ #include "engraver.hh" struct Engraver_table_entry { - String name_str_; - Grav_ctor ctor_l_; - Engraver_table_entry (String s, Grav_ctor f) { + String name_str_; + Grav_ctor ctor_l_; + Engraver_table_entry (String s, Grav_ctor f) + { name_str_ =s; ctor_l_ = f; } - Engraver_table_entry() - { + Engraver_table_entry() + { ctor_l_ =0; } }; @@ -30,38 +31,40 @@ static Array *grav_table=0; void add_engraver (String s, Grav_ctor f) { - if (!grav_table) + if (!grav_table) grav_table = new Array; - - grav_table->push (Engraver_table_entry (s, f)); + + grav_table->push (Engraver_table_entry (s, f)); } Engraver* get_engraver_p (String s) { - for (int i=0; i < grav_table->size(); i++) { + for (int i=0; i < grav_table->size(); i++) + { if ((*grav_table)[i].name_str_ == s) return (*(*grav_table)[i].ctor_l_)(); } - error ("Unknown engraver `" + s +"\'"); - return 0; + error ("Unknown engraver `" + s +"\'"); + return 0; } #if 0 struct Performer_table_entry { - String name_str_; - Perf_ctor ctor_l_; - Performer_table_entry (String s, Perf_ctor f) { + String name_str_; + Perf_ctor ctor_l_; + Performer_table_entry (String s, Perf_ctor f) + { name_str_ =s; ctor_l_ = f; } - Performer_table_entry() - { + Performer_table_entry() + { ctor_l_ =0; - } + } } static Array *perf_table=0; @@ -69,21 +72,22 @@ static Array *perf_table=0; void add_performer (String s, Perf_ctor f) { - if (!perf_table) + if (!perf_table) perf_table = new Array; - - perf_table->push (Performer_table_entry (s, f)); + + perf_table->push (Performer_table_entry (s, f)); } Performer* get_performer_p (String s) { - for (int i=0; i < perf_table->size(); i++) { + for (int i=0; i < perf_table->size(); i++) + { if ((*perf_table)[i].name_str_ == s) return (*(*perf_table)[i].ctor_l_)(); } - error ("Unknown performer `" + s +"\'"); - return 0; + error ("Unknown performer `" + s +"\'"); + return 0; } #endif diff --git a/lily/global-performers.cc b/lily/global-performers.cc index 126a109319..69102aaf23 100644 --- a/lily/global-performers.cc +++ b/lily/global-performers.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "proto.hh" @@ -14,14 +14,15 @@ #include "performer.hh" struct Performer_table_entry { - String name_str_; - Perf_ctor ctor_l_; - Performer_table_entry (String s, Perf_ctor f) { + String name_str_; + Perf_ctor ctor_l_; + Performer_table_entry (String s, Perf_ctor f) + { name_str_ =s; ctor_l_ = f; } - Performer_table_entry() - { + Performer_table_entry() + { ctor_l_ =0; } }; @@ -31,20 +32,21 @@ static Array *perf_table=0; void add_Performer (String s, Perf_ctor f) { - if (!perf_table) + if (!perf_table) perf_table = new Array; - - perf_table->push (Performer_table_entry (s, f)); + + perf_table->push (Performer_table_entry (s, f)); } Performer* get_performer_p (String s) { - for (int i=0; i < perf_table->size(); i++) { + for (int i=0; i < perf_table->size(); i++) + { if ((*perf_table)[i].name_str_ == s) return (*(*perf_table)[i].ctor_l_)(); } - error ("Unknown performer `" + s +"\'"); - return 0; + error ("Unknown performer `" + s +"\'"); + return 0; } diff --git a/lily/global-translator.cc b/lily/global-translator.cc index 39cc56bc3d..f92156e6e4 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -13,45 +13,45 @@ Global_translator::Global_translator() { - score_l_ = 0; - last_mom_ = 0; + score_l_ = 0; + last_mom_ = 0; } Translator* Global_translator::ancestor_l (int) { - return this; + return this; } void Global_translator::add_moment_to_process (Moment m) { - if (m > last_mom_) + if (m > last_mom_) return; - - for (int i=0; i < extra_mom_pq_.size(); i++) + + for (int i=0; i < extra_mom_pq_.size(); i++) if (extra_mom_pq_[i] == m) return; - extra_mom_pq_.insert (m); + extra_mom_pq_.insert (m); } int Global_translator::depth_i()const { - return 0; + return 0; } void Global_translator::set_score (Score *s) { - score_l_ = s; - last_mom_ = score_l_->music_p_->time_int().max (); + score_l_ = s; + last_mom_ = score_l_->music_p_->time_int().max (); } void Global_translator::modify_next (Moment &w) { - while (extra_mom_pq_.size() && + while (extra_mom_pq_.size() && extra_mom_pq_.front() <= w) w =extra_mom_pq_.get(); @@ -60,7 +60,7 @@ Global_translator::modify_next (Moment &w) int Global_translator::moments_left_i()const { - return extra_mom_pq_.size(); + return extra_mom_pq_.size(); } void diff --git a/lily/grouping.cc b/lily/grouping.cc index ffda40e14f..c106db0861 100644 --- a/lily/grouping.cc +++ b/lily/grouping.cc @@ -13,17 +13,18 @@ void Rhythmic_grouping::init() { - interval_ = 0; - children.clear(); + interval_ = 0; + children.clear(); } void Rhythmic_grouping::OK()const { #ifndef NDEBUG - assert (bool (children.size()) != bool (interval_)); + assert (bool (children.size()) != bool (interval_)); - for (int i= 0; i < children.size(); i++) { + for (int i= 0; i < children.size(); i++) + { children[i]->OK(); if (i>0) assert (children[i-1]->interval().right == @@ -35,15 +36,15 @@ Rhythmic_grouping::OK()const Moment Rhythmic_grouping::length() const { - return interval().length (); + return interval().length (); } MInterval Rhythmic_grouping::interval()const { - if (interval_) + if (interval_) return *interval_; - else + else return MInterval (children[0]->interval().left, children.top()->interval ().right); @@ -52,17 +53,19 @@ Rhythmic_grouping::interval()const void Rhythmic_grouping::split (Rhythmic_grouping r) { - if (interval_) + if (interval_) return ; - - r.intersect (interval()); - split (r.intervals()); - - for (int i= 0; i < children.size(); i++) { - if (!children[i]->interval_) { + + r.intersect (interval()); + split (r.intervals()); + + for (int i= 0; i < children.size(); i++) + { + if (!children[i]->interval_) + { Rhythmic_grouping here (r); children[i]->split (here); - } + } } } @@ -70,37 +73,46 @@ Rhythmic_grouping::split (Rhythmic_grouping r) Array Rhythmic_grouping::intervals() { - Array r; - if (interval_ || children.size() == 1) { + Array r; + if (interval_ || children.size() == 1) + { MInterval i (interval()); MInterval r1(i), r2(i); r1.right = r2.left = i.center(); r.push (r1); r.push (r2); - } else { + } + else + { for (int i=0; i < children.size(); i++) r.push (children[i]->interval()); } - return r; + return r; } void Rhythmic_grouping::intersect (MInterval t) { - if (interval_) { + if (interval_) + { interval_->intersect (t); return; } - - for (int i=0; i < children.size(); i++) { + + for (int i=0; i < children.size(); i++) + { MInterval inter = intersection (t, children[i]->interval()); - if (inter.empty_b() || inter.length () <= Rational (0)) { + if (inter.empty_b() || inter.length () <= Rational (0)) + { delete children[i]; children[i] =0; - } else { + } + else + { children[i]->intersect (t); - } + } } - for (int i=0; i < children.size();) { + for (int i=0; i < children.size();) + { if (!children[i]) children.del (i); else @@ -120,164 +132,180 @@ Rhythmic_grouping::intersect (MInterval t) void Rhythmic_grouping::split (Array splitpoints) { - //check on splitpoints.. - int j = 0, i = 0, starti = 0, startj = 0; - - Array ch; - while (1) { + //check on splitpoints.. + int j = 0, i = 0, starti = 0, startj = 0; + + Array ch; + while (1) + { if ( i >= children.size() || j >= splitpoints.size ()) break; assert ( children[starti]->interval().left== splitpoints[startj].left); - if (children[i]->interval().right < splitpoints[j].right) { + if (children[i]->interval().right < splitpoints[j].right) + { i ++; - } else if (children[i]->interval().right > splitpoints[j].right) { + } + else if (children[i]->interval().right > splitpoints[j].right) + { j ++; - } else { + } + else + { - if (i == starti) { + if (i == starti) + { ch.push (children[i]); - } else { + } + else + { Rhythmic_grouping *newchild=new Rhythmic_grouping ( children.slice (starti, i+1)); ch.push (newchild); - } + } i ++; j++; starti = i; startj = j; - } + } } - if (ch.size() != 1) + if (ch.size() != 1) children = ch; } Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n) { - init(); - if (n == 1 || !n) { + init(); + if (n == 1 || !n) + { interval_ = new MInterval (t); return; } - Moment dt = t.length()/Rational (n); - MInterval basic = MInterval (t.left, t.left+dt); - for (int i= 0; i < n; i++) + Moment dt = t.length()/Rational (n); + MInterval basic = MInterval (t.left, t.left+dt); + for (int i= 0; i < n; i++) children.push (new Rhythmic_grouping (dt*Rational (i) + basic)); } Rhythmic_grouping::Rhythmic_grouping (Array r) - :children (r) + :children (r) { - interval_ =0; + interval_ =0; } Rhythmic_grouping::~Rhythmic_grouping() { - junk(); + junk(); } void Rhythmic_grouping::copy (Rhythmic_grouping const&s) { - interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; - for (int i=0; i < s.children.size(); i++) - children.push (new Rhythmic_grouping (*s.children[i])); + interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; + for (int i=0; i < s.children.size(); i++) + children.push (new Rhythmic_grouping (*s.children[i])); } void Rhythmic_grouping::operator=(Rhythmic_grouping const &s) { - junk(); - copy (s); + junk(); + copy (s); } Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s) { - init(); - copy (s); + init(); + copy (s); } void Rhythmic_grouping::junk() { - delete interval_; - for (int i=0; i < children.size(); i++) + delete interval_; + for (int i=0; i < children.size(); i++) delete children[i]; - init(); + init(); } void Rhythmic_grouping::print()const { #ifndef NPRINT - DOUT << "{ \n"; - if (interval_) + DOUT << "{ \n"; + if (interval_) DOUT <<" Interval "<< interval_->str(); - for (int i=0; i < children.size(); i++) { + for (int i=0; i < children.size(); i++) + { children[i]->print(); } - DOUT << "}\n"; + DOUT << "}\n"; #endif } bool Rhythmic_grouping::child_fit_b (Moment start) { - if (children.size()) + if (children.size()) return ( children.top()->interval ().right== start); - return true; + return true; } void Rhythmic_grouping::add_child (Moment start, Moment len) { - Moment stop = start+len; + Moment stop = start+len; - assert (child_fit_b (start)); - children.push (new Rhythmic_grouping (MInterval (start, stop))); + assert (child_fit_b (start)); + children.push (new Rhythmic_grouping (MInterval (start, stop))); } Rhythmic_grouping::Rhythmic_grouping() { - interval_ =0; + interval_ =0; } int min_elt (Array v) { - int i = 1000; // ugh - for (int j = 0 ; j < v.size(); j++) + int i = 1000; // ugh + for (int j = 0 ; j < v.size(); j++) i = i Rhythmic_grouping::generate_beams (Array flags, int &flagidx) { - assert (!interval_) ; - - Array< Array > children_beams; - for (int i=0; i < children.size(); i++) { + assert (!interval_) ; + + Array< Array > children_beams; + for (int i=0; i < children.size(); i++) + { Array child_beams; - if (children[i]->interval_) { + if (children[i]->interval_) + { int f = flags[flagidx++]; child_beams.push (f); - } else { + } + else + { child_beams = children[i]-> generate_beams (flags, flagidx); - } + } children_beams.push (child_beams); } - Array beams; - int lastm, m, nextm; - for (int i=0; i < children_beams.size(); i++) { + Array beams; + int lastm, m, nextm; + for (int i=0; i < children_beams.size(); i++) + { bool add_left = (i >0); bool add_right = (i < children_beams.size() -1); @@ -286,31 +314,34 @@ Rhythmic_grouping::generate_beams (Array flags, int &flagidx) if (add_right) nextm = min_elt (children_beams[i+1]); - if (children_beams[i].size() == 1) { + if (children_beams[i].size() == 1) + { if (add_right) beams.push (m); if (add_left) beams.push (m); - } else { + } + else + { if (add_left) beams.push (lastm translate (m); } @@ -318,33 +349,36 @@ Rhythmic_grouping::translate (Moment m) void Rhythmic_grouping::extend (MInterval m)const { - assert (m.left >= interval().left); - while (m.right >interval().right) { + assert (m.left >= interval().left); + while (m.right >interval().right) + { Array a (children); - for (int i=0; i < a.size(); i++) { + for (int i=0; i < a.size(); i++) + { a[i] =new Rhythmic_grouping (*children[i]); a[i]->translate (children.top()->interval ().right); - } + } ((Rhythmic_grouping*)this)->children.concat (a); } - assert (m.right <= interval().right); - OK(); + assert (m.right <= interval().right); + OK(); } Rhythmic_grouping parse_grouping (Array beat_i_arr, Array elt_length_arr) { - Moment here =0; - assert (beat_i_arr.size() == elt_length_arr.size ()); - - Array children; - for (int i=0; i < beat_i_arr.size(); i++) { + Moment here =0; + assert (beat_i_arr.size() == elt_length_arr.size ()); + + Array children; + for (int i=0; i < beat_i_arr.size(); i++) + { Moment last = here; here += elt_length_arr[i] * Moment (beat_i_arr[i]); children.push ( new Rhythmic_grouping (MInterval (last, here), beat_i_arr[i])); } - return Rhythmic_grouping (children); + return Rhythmic_grouping (children); } diff --git a/lily/head-column.cc b/lily/head-column.cc index af7001db90..a5d1ecbebd 100644 --- a/lily/head-column.cc +++ b/lily/head-column.cc @@ -14,20 +14,22 @@ Head_column::Head_column() { - stem_l_ = 0; - dir_i_ =0; + stem_l_ = 0; + dir_i_ =0; } void Head_column::do_substitute_dependency (Score_elem*o, Score_elem*n) { - Script_column::do_substitute_dependency (o,n); - if (o->name() == Note_head::static_name ()) { + Script_column::do_substitute_dependency (o,n); + if (o->name() == Note_head::static_name ()) + { head_l_arr_.substitute ((Note_head*)o->item(), (n)? (Note_head*)n->item() : 0); } - if (stem_l_ == o) { + if (stem_l_ == o) + { stem_l_ = n ? (Stem*)n->item():0; } } @@ -36,24 +38,24 @@ Head_column::do_substitute_dependency (Score_elem*o, void Head_column::set (Stem*stem_l) { - stem_l_ = stem_l; - Score_elem::add_dependency (stem_l); - for (int i=0; script_l_arr_.size(); i++) + stem_l_ = stem_l; + Score_elem::add_dependency (stem_l); + for (int i=0; script_l_arr_.size(); i++) script_l_arr_[i]->set_stem (stem_l); } void Head_column::add (Script *script_l) { - Script_column::add (script_l) ; - if (stem_l_) + Script_column::add (script_l) ; + if (stem_l_) script_l->set_stem (stem_l_); } void Head_column::add (Note_head *n_l) { - add_support (n_l); - head_l_arr_.push (n_l); + add_support (n_l); + head_l_arr_.push (n_l); } @@ -64,16 +66,17 @@ void Head_column::do_print() const { #ifndef NPRINT - DOUT << "heads: " << head_l_arr_.size(); + DOUT << "heads: " << head_l_arr_.size(); #endif } void Head_column::do_pre_processing() { - if (!dir_i_){ + if (!dir_i_) + { if (stem_l_) dir_i_ = stem_l_->dir_i_; } - Script_column::do_pre_processing(); + Script_column::do_pre_processing(); } diff --git a/lily/head-grav.cc b/lily/head-grav.cc index d1aaaed0af..29da2be66e 100644 --- a/lily/head-grav.cc +++ b/lily/head-grav.cc @@ -11,51 +11,55 @@ Note_head_engraver::Note_head_engraver() { - note_p_ = 0; - do_post_move_processing(); + note_p_ = 0; + do_post_move_processing(); } bool Note_head_engraver::do_try_request (Request *req_l) { - if (note_req_l_) + if (note_req_l_) return false; - - if (req_l->musical() && (req_l->musical ()->note () || req_l->musical ()->rest ())) + + if (req_l->musical() && (req_l->musical ()->note () || req_l->musical ()->rest ())) note_req_l_=req_l->musical()->rhythmic (); - else + else return false; - return true; + return true; } void Note_head_engraver::do_process_requests() { - if (!note_req_l_) + if (!note_req_l_) return; - - Note_head*n_p = new Note_head (8); // ugh - note_p_ = n_p; - n_p->set_rhythmic (note_req_l_->rhythmic()); + + Note_head*n_p = new Note_head (8); // ugh + note_p_ = n_p; + n_p->set_rhythmic (note_req_l_->rhythmic()); - if (note_req_l_->note()) { + if (note_req_l_->note()) + { n_p->position_i_ = note_req_l_->note()->height (); Staff_info inf = get_staff_info(); if (inf.c0_position_i_l_) n_p->position_i_ += *inf.c0_position_i_l_; - } else if (note_req_l_->rest()) { + } + else if (note_req_l_->rest()) + { n_p->rest_b_ = true; } - - Score_elem_info itinf (note_p_,note_req_l_); - announce_element (itinf); + + Score_elem_info itinf (note_p_,note_req_l_); + announce_element (itinf); } void Note_head_engraver::do_pre_move_processing() { - if (note_p_) { + if (note_p_) + { typeset_element (note_p_); note_p_ = 0; } @@ -63,7 +67,7 @@ Note_head_engraver::do_pre_move_processing() void Note_head_engraver::do_post_move_processing() { - note_req_l_ = 0; + note_req_l_ = 0; } diff --git a/lily/horizontal-align-item.cc b/lily/horizontal-align-item.cc index de24eed51d..163a1bf61c 100644 --- a/lily/horizontal-align-item.cc +++ b/lily/horizontal-align-item.cc @@ -14,28 +14,29 @@ void Horizontal_align_item::OK() const { for (int i =0; i < item_l_arr_.size(); i++) - assert ( pcol_l_ == item_l_arr_[i]->pcol_l_); + assert ( pcol_l_ == item_l_arr_[i]->pcol_l_); } bool Horizontal_align_item::contains_b (Item *i)const { - return item_l_arr_.find_l (i); + return item_l_arr_.find_l (i); } void Horizontal_align_item::add (Item *i,int p) { - assert (! contains_b (i)); - priority_i_arr_.push (p); - item_l_arr_.push (i); - add_dependency (i); + assert (! contains_b (i)); + priority_i_arr_.push (p); + item_l_arr_.push (i); + add_dependency (i); } void Horizontal_align_item::do_substitute_dependency (Score_elem*o,Score_elem*n) { - int i; - while ((i = item_l_arr_.find_i (o->item())) >=0) { + int i; + while ((i = item_l_arr_.find_i (o->item())) >=0) + { if (n) item_l_arr_[i] = n->item(); else @@ -44,25 +45,27 @@ Horizontal_align_item::do_substitute_dependency (Score_elem*o,Score_elem*n) } struct Horizontal_align_item_content { - Item * item_l_; - int priority_i_; - static int compare (Horizontal_align_item_content const &h1, - Horizontal_align_item_content const &h2) { + Item * item_l_; + int priority_i_; + static int compare (Horizontal_align_item_content const &h1, + Horizontal_align_item_content const &h2) + { return h1.priority_i_ - h2.priority_i_; } - Horizontal_align_item_content (Item*i, int p) { + Horizontal_align_item_content (Item*i, int p) + { priority_i_ = p; item_l_ = i; } - Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; } + Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; } }; void Horizontal_align_item::do_pre_processing() { - OK(); - { + OK(); + { Array content; for (int i =0; i < item_l_arr_.size(); i++) content.push ( @@ -71,43 +74,47 @@ Horizontal_align_item::do_pre_processing() content.sort (Horizontal_align_item_content::compare); item_l_arr_.clear(); priority_i_arr_.clear(); - for (int i =0; i < content.size(); i++) { + for (int i =0; i < content.size(); i++) + { item_l_arr_.push (content[i].item_l_); priority_i_arr_.push (content[i].priority_i_); - } + } } - - Array dims; - Real total =0; - for (int i =0; i < item_l_arr_.size(); i++) { + + Array dims; + Real total =0; + for (int i =0; i < item_l_arr_.size(); i++) + { Interval item_width= item_l_arr_[i]->width(); - if (item_width.empty_b()) { + if (item_width.empty_b()) + { item_width = Interval (0,0); - } + } dims.push (item_width); total += item_width.length(); } - Real where_f= total * (align_i_-1.0)/2.0; - Real center_dx_f = 0; - for ( int i=0 ; i < item_l_arr_.size(); i++) { + Real where_f= total * (align_i_-1.0)/2.0; + Real center_dx_f = 0; + for ( int i=0 ; i < item_l_arr_.size(); i++) + { Real dx = where_f -dims[i][-1]; item_l_arr_[i]->translate (dx , X_AXIS); if (item_l_arr_[i] == center_l_) center_dx_f = where_f; where_f += dims[i].length(); } - if (center_dx_f && !align_i_) + if (center_dx_f && !align_i_) for ( int i=0 ; i < item_l_arr_.size(); i++) item_l_arr_[i]->translate (- center_dx_f , X_AXIS); - + } Interval Horizontal_align_item::do_width() const { - return Interval (0,0); + return Interval (0,0); } void @@ -117,8 +124,8 @@ Horizontal_align_item::do_print()const Horizontal_align_item::Horizontal_align_item() { - center_l_ = 0; - align_i_ = 0; - empty_b_ = true; - transparent_b_ = true; + center_l_ = 0; + align_i_ = 0; + empty_b_ = true; + transparent_b_ = true; } diff --git a/lily/horizontal-group-item.cc b/lily/horizontal-group-item.cc index 409f2feadf..6b3afaf3da 100644 --- a/lily/horizontal-group-item.cc +++ b/lily/horizontal-group-item.cc @@ -14,5 +14,5 @@ IMPLEMENT_IS_TYPE_B2(Horizontal_group_item, Horizontal_group_element, Axis_group void Horizontal_group_item::do_print() const { - Axis_group_item::do_print(); + Axis_group_item::do_print(); } diff --git a/lily/idealspacing.cc b/lily/idealspacing.cc index 1209cc22f5..16298be1e1 100644 --- a/lily/idealspacing.cc +++ b/lily/idealspacing.cc @@ -15,22 +15,22 @@ void Idealspacing::print() const { #ifndef NPRINT - DOUT << "idealspacing {" ; - DOUT << "distance "<= 0); + assert (hooke_f_ >= 0); } diff --git a/lily/ineq-constrained-qp.cc b/lily/ineq-constrained-qp.cc index 29905fd3ae..f7b204fcff 100644 --- a/lily/ineq-constrained-qp.cc +++ b/lily/ineq-constrained-qp.cc @@ -17,41 +17,42 @@ const int MAXITER=100; // qlpsolve.hh /* - assume x (idx) == value, and adjust constraints, lin and quad accordingly + assume x (idx) == value, and adjust constraints, lin and quad accordingly - TODO: add const_term - */ + TODO: add const_term + */ void Ineq_constrained_qp::eliminate_var (int idx, Real value) { - Vector row (quad.row (idx)); - row*= value; + Vector row (quad.row (idx)); + row*= value; - quad.delete_row (idx); + quad.delete_row (idx); - quad.delete_column (idx); + quad.delete_column (idx); - lin.del (idx); - row.del (idx); - lin +=row ; + lin.del (idx); + row.del (idx); + lin +=row ; - for (int i=0; i < cons.size(); i++) { - consrhs[i] -= cons[i](idx) *value; - cons[i].del (idx); + for (int i=0; i < cons.size(); i++) + { + consrhs[i] -= cons[i](idx) *value; + cons[i].del (idx); } } void Ineq_constrained_qp::add_inequality_cons (Vector c, double r) { - cons.push (c); - consrhs.push (r); + cons.push (c); + consrhs.push (r); } Ineq_constrained_qp::Ineq_constrained_qp (int novars): - quad (novars), - lin (novars), - const_term (0.0) + quad (novars), + lin (novars), + const_term (0.0) { } @@ -59,77 +60,81 @@ void Ineq_constrained_qp::OK() const { #if !defined (NDEBUG) && defined (PARANOID) - assert (cons.size() == consrhs.size ()); - Matrix Qdif= quad - quad.transposed(); - assert (Qdif.norm()/quad.norm () < EPS); + assert (cons.size() == consrhs.size ()); + Matrix Qdif= quad - quad.transposed(); + assert (Qdif.norm()/quad.norm () < EPS); #endif } - + Real Ineq_constrained_qp::eval (Vector v) { - return v * quad * v + lin * v + const_term; + return v * quad * v + lin * v + const_term; } int min_elt_index (Vector v) { - Real m=infinity_f; - int idx=-1; - for (int i = 0; i < v.dim(); i++){ - if (v (i) < m) { + Real m=infinity_f; + int idx=-1; + for (int i = 0; i < v.dim(); i++) + { + if (v (i) < m) + { idx = i; m = v (i); - } + } assert (v (i) <= infinity_f); } - return idx; + return idx; } /**the numerical solving. Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) - Prentice Hall. + Prentice Hall. - Section 13.3 + Section 13.3 - This is a "projected gradient" algorithm. Starting from a point x - the next point is found in a direction determined by projecting - the gradient onto the active constraints. (well, not really the - gradient. The optimal solution obeying the active constraints is - tried. This is why H = Q^-1 in initialisation)) + This is a "projected gradient" algorithm. Starting from a point x + the next point is found in a direction determined by projecting + the gradient onto the active constraints. (well, not really the + gradient. The optimal solution obeying the active constraints is + tried. This is why H = Q^-1 in initialisation)) - */ + */ Vector Ineq_constrained_qp::constraint_solve (Vector start) const { - if (!dim()) + if (!dim()) return Vector (0); - - // experimental - if (quad.dim() > 10) + + // experimental + if (quad.dim() > 10) quad.try_set_band(); - - Active_constraints act (this); - act.OK(); + + Active_constraints act (this); + act.OK(); - - Vector x (start); - Vector gradient=quad*x+lin; + + Vector x (start); + Vector gradient=quad*x+lin; // Real fvalue = x*quad*x/2 + lin*x + const_term; // it's no use. - Vector last_gradient (gradient); - int iterations=0; - - while (iterations++ < MAXITER) { + Vector last_gradient (gradient); + int iterations=0; + + while (iterations++ < MAXITER) + { Vector direction= - act.find_active_optimum (gradient); - + DOUT << "gradient "<< gradient<< "\ndirection " << direction<<"\n"; - if (direction.norm() > EPS) { + if (direction.norm() > EPS) + { DOUT << act.status() << '\n'; Real minalf = infinity_f; @@ -141,19 +146,21 @@ Ineq_constrained_qp::constraint_solve (Vector start) const we know the optimum on this "hyperplane". Check if we bump into the edges of the simplex */ - - for (Inactive_iter ia (act); ia.ok(); ia++) { + + for (Inactive_iter ia (act); ia.ok(); ia++) + { if (ia.vec() * direction >= 0) continue; Real alfa= - (ia.vec()*x - ia.rhs ())/ (ia.vec()*direction); - if (minalf > alfa) { + if (minalf > alfa) + { minidx = ia; minalf = alfa; - } - } + } + } Real unbounded_alfa = 1.0; Real optimal_step = min (minalf, unbounded_alfa); @@ -164,48 +171,55 @@ Ineq_constrained_qp::constraint_solve (Vector start) const DOUT << "step = " << optimal_step<< " (|dx| = " << deltax.norm() << ")\n"; - if (minalf < unbounded_alfa) { + if (minalf < unbounded_alfa) + { /* bumped into an edge. try again, in smaller space. */ act.add (minidx.idx()); DOUT << "adding cons "<< minidx.idx()<<'\n'; continue; - } + } /*ASSERT: we are at optimal solution for this "plane"*/ - - - } + + + } Vector lagrange_mult=act.get_lagrange (gradient); int m= min_elt_index (lagrange_mult); - if (m>=0 && lagrange_mult (m) > 0) { + if (m>=0 && lagrange_mult (m) > 0) + { break; // optimal sol. - } else if (m<0) { + } + else if (m<0) + { assert (gradient.norm() < EPS) ; break; - } + } DOUT << "dropping cons " << m<<'\n'; act.drop (m); } - if (iterations >= MAXITER) + if (iterations >= MAXITER) WARN<<"didn't converge!\n"; - - DOUT << ": found " << x<<" in " << iterations <<" iterations\n"; - assert_solution (x); - return x; + + DOUT << ": found " << x<<" in " << iterations <<" iterations\n"; + assert_solution (x); + return x; } - + Vector Ineq_constrained_qp::solve (Vector start)const { - /* no hassle if no constraints*/ - if ( ! cons.size()) { + /* no hassle if no constraints*/ + if ( ! cons.size()) + { Choleski_decomposition chol (quad); return - chol.solve (lin); - } else { + } + else + { return constraint_solve (start); } } diff --git a/lily/input-translator.cc b/lily/input-translator.cc index ddc0163053..34a65b7f3e 100644 --- a/lily/input-translator.cc +++ b/lily/input-translator.cc @@ -17,27 +17,27 @@ bool Input_translator::is_name_b (String n) { - for (int i=0; i < alias_str_arr_.size(); i++) + for (int i=0; i < alias_str_arr_.size(); i++) if (alias_str_arr_[i] == n) return true; - return false; + return false; } void Input_translator::print() const { #ifndef NPRINT - if ( ! check_debug) + if ( ! check_debug) return ; - DOUT << base_str_ <<" " << type_str_<<" {\n"; - DOUT << "Consists of "; - for (int i=0; i< consists_str_arr_.size(); i++) + DOUT << base_str_ <<" " << type_str_<<" {\n"; + DOUT << "Consists of "; + for (int i=0; i< consists_str_arr_.size(); i++) DOUT << consists_str_arr_[i] << ','; - if (contains_itrans_p_list_.size()) + if (contains_itrans_p_list_.size()) DOUT << "\nContains " ; - for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) + for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) i->print(); - DOUT << "}\n"; + DOUT << "}\n"; #endif } @@ -46,86 +46,90 @@ Input_translator::print() const Input_translator * Input_translator::recursive_find (String nm) { - if ( is_name_b (nm)) + if ( is_name_b (nm)) return this; - Input_translator * r =0; - // what bout for() ? - PCursor i (contains_itrans_p_list_.top()); - for (; !r &&i.ok(); i++) { + Input_translator * r =0; + // what bout for() ? + PCursor i (contains_itrans_p_list_.top()); + for (; !r &&i.ok(); i++) + { if (i->recursive_find (nm)) r = i.ptr(); } - return r; + return r; } Input_translator * Input_translator::find_itrans_l (String nm) { - for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) + for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) if (i->is_name_b (nm)) return i; - return 0; + return 0; } Engraver_group_engraver * Input_translator::get_group_engraver_p() { - assert (base_str_ == "Engraver"); - Engraver_group_engraver * grav_p = (Engraver_group_engraver*) + assert (base_str_ == "Engraver"); + Engraver_group_engraver * grav_p = (Engraver_group_engraver*) get_engraver_p (type_str_); - for (int i=0; i < consists_str_arr_.size(); i++) { + for (int i=0; i < consists_str_arr_.size(); i++) + { grav_p->add (get_engraver_p (consists_str_arr_[i])); } - grav_p->itrans_l_ = this; - grav_p->id_str_ = default_id_str_; - return grav_p; + grav_p->itrans_l_ = this; + grav_p->id_str_ = default_id_str_; + return grav_p; } Performer_group_performer* Input_translator::get_group_performer_p() { - assert (base_str_ == "Performer"); - Performer_group_performer * perf_p = (Performer_group_performer*) + assert (base_str_ == "Performer"); + Performer_group_performer * perf_p = (Performer_group_performer*) get_performer_p (type_str_); - for (int i=0; i < consists_str_arr_.size(); i++) { + for (int i=0; i < consists_str_arr_.size(); i++) + { perf_p->add (get_performer_p (consists_str_arr_[i])); } - perf_p->itrans_l_ = this; - perf_p->id_str_ = default_id_str_; - return perf_p; + perf_p->itrans_l_ = this; + perf_p->id_str_ = default_id_str_; + return perf_p; } bool Input_translator::accept_req_b() { - return ! contains_itrans_p_list_.size(); + return ! contains_itrans_p_list_.size(); } void Input_translator::add (Input_translator *ip) { - contains_itrans_p_list_.bottom().add (ip); + contains_itrans_p_list_.bottom().add (ip); } Input_translator* Input_translator::get_default_itrans_l() { - if ( contains_itrans_p_list_.size()) + if ( contains_itrans_p_list_.size()) return contains_itrans_p_list_.top(); - else + else return 0; } Input_translator_list::Input_translator_list (Input_translator_list const &s) { - for (PCursor pc (s); pc.ok(); pc++) { + for (PCursor pc (s); pc.ok(); pc++) + { Input_translator *q = pc; Input_translator *p=new Input_translator (*q) ; bottom().add (p); diff --git a/lily/item.cc b/lily/item.cc index b47ac190e9..6c4a7699c8 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -14,10 +14,10 @@ Item::Item() { - breakable_b_ = false; - break_status_i_ = 0; - pcol_l_ = 0; - broken_to_a_[0] = broken_to_a_[1]=0; + breakable_b_ = false; + break_status_i_ = 0; + pcol_l_ = 0; + broken_to_a_[0] = broken_to_a_[1]=0; } IMPLEMENT_IS_TYPE_B1(Item, Score_elem); @@ -26,7 +26,7 @@ void Item::do_print() const { #ifndef NPRINT - DOUT << "(unknown)"; + DOUT << "(unknown)"; #endif } @@ -34,28 +34,29 @@ Item::do_print() const Real Item::hpos_f()const { - return pcol_l_->hpos_f_ + absolute_coordinate (X_AXIS); + return pcol_l_->hpos_f_ + absolute_coordinate (X_AXIS); } Line_of_score * Item::line_l()const { - return pcol_l_->line_l_; + return pcol_l_->line_l_; } int Item::break_status_i() const { - return break_status_i_; + return break_status_i_; } void Item::copy_breakable_items() { - if ( broken_to_a_[0] || broken_to_a_[1]) + if ( broken_to_a_[0] || broken_to_a_[1]) return; - Item *new_copies[2]; - for (int i=0; i < 2; i++) { + Item *new_copies[2]; + for (int i=0; i < 2; i++) + { Item * item_p = clone()->item (); item_p->copy_dependencies (*this); @@ -64,56 +65,56 @@ Item::copy_breakable_items() item_p->handle_prebroken_dependencies(); new_copies[i] =item_p; } - broken_to_a_= new_copies; + broken_to_a_= new_copies; } void Item::do_breakable_col_processing() { - if (!breakable_b_ || !pcol_l_->breakable_b()) + if (!breakable_b_ || !pcol_l_->breakable_b()) return; - copy_breakable_items(); - handle_prebroken_dependencies(); + copy_breakable_items(); + handle_prebroken_dependencies(); - /* - Otherwise the broken items won't be pre_process()'ed. - */ - add_dependency (broken_to_a_[0]); - add_dependency (broken_to_a_[1]); + /* + Otherwise the broken items won't be pre_process()'ed. + */ + add_dependency (broken_to_a_[0]); + add_dependency (broken_to_a_[1]); } Item* Item::find_prebroken_piece (Line_of_score*l) const { - if (line_l() == l) + if (line_l() == l) return (Item*)this; - else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l) + else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l) return broken_to_a_[0]; - else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l) + else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l) return broken_to_a_[1]; - return 0; + return 0; } Item* Item::find_prebroken_piece (PCol*c)const { - if (c == pcol_l_) + if (c == pcol_l_) return (Item *) this; // ugh - if (c == pcol_l_->prebreak_p_) + if (c == pcol_l_->prebreak_p_) return (Item *) broken_to_a_[0]; - else if (c==pcol_l_->postbreak_p_) + else if (c==pcol_l_->postbreak_p_) return (Item *)broken_to_a_[1]; - assert (false); + assert (false); } void Item::handle_prebroken_dependencies() { - if ( breakable_b_) + if ( breakable_b_) Score_elem::handle_prebroken_dependencies(); } diff --git a/lily/key-grav.cc b/lily/key-grav.cc index a29879bbf4..96d51998c4 100644 --- a/lily/key-grav.cc +++ b/lily/key-grav.cc @@ -20,14 +20,15 @@ Key_engraver::Key_engraver() { - kit_p_ = 0; - do_post_move_processing(); + kit_p_ = 0; + do_post_move_processing(); } void Key_engraver::create_key() { - if (!kit_p_) { + if (!kit_p_) + { int c0_i=0; Staff_info inf = get_staff_info(); @@ -36,31 +37,34 @@ Key_engraver::create_key() kit_p_ = new Key_item (c0_i); announce_element (Score_elem_info (kit_p_,keyreq_l_)); - kit_p_->read (*this); + kit_p_->read (*this); } } bool Key_engraver::do_try_request (Request * req_l) { - Command_req* creq_l= req_l->command(); - if (!creq_l|| !creq_l->keychange()) + Command_req* creq_l= req_l->command(); + if (!creq_l|| !creq_l->keychange()) return false; - - if (keyreq_l_) + + if (keyreq_l_) return false; // TODO - keyreq_l_ = creq_l->keychange(); - read_req (keyreq_l_); - return true; + keyreq_l_ = creq_l->keychange(); + read_req (keyreq_l_); + return true; } void Key_engraver::acknowledge_element (Score_elem_info info) { - Command_req * r_l = info.req_l_->command() ; - if (r_l && r_l->clefchange()) { + Command_req * r_l = info.req_l_->command() ; + if (r_l && r_l->clefchange()) + { create_key(); - } else if (info.elem_l_->name() == Bar::static_name ()) { + } + else if (info.elem_l_->name() == Bar::static_name ()) + { if ( !keyreq_l_) default_key_b_ = true; create_key(); @@ -71,9 +75,12 @@ Key_engraver::acknowledge_element (Score_elem_info info) void Key_engraver::do_process_requests() { - if (key_.multi_octave_b_) { + if (key_.multi_octave_b_) + { assert (false); // TODO . - } else if (keyreq_l_) { + } + else if (keyreq_l_) + { create_key(); } } @@ -81,7 +88,8 @@ Key_engraver::do_process_requests() void Key_engraver::do_pre_move_processing() { - if (kit_p_) { + if (kit_p_) + { kit_p_->default_b_ = default_key_b_; typeset_element (kit_p_); kit_p_ = 0; @@ -89,13 +97,14 @@ Key_engraver::do_pre_move_processing() } - + void Key_engraver::read_req (Key_change_req * r) { - key_.multi_octave_b_ = r->multi_octave_b_; - accidental_idx_arr_.clear(); - for (int i = 0; i < r->melodic_p_arr_.size(); i ++) { + key_.multi_octave_b_ = r->multi_octave_b_; + accidental_idx_arr_.clear(); + for (int i = 0; i < r->melodic_p_arr_.size(); i ++) + { Melodic_req * m_l =r->melodic_p_arr_[i]; int n_i =m_l->notename_i_; int a_i = m_l->accidental_i_; @@ -111,8 +120,8 @@ Key_engraver::read_req (Key_change_req * r) void Key_engraver::do_post_move_processing() { - keyreq_l_ = 0; - default_key_b_ = false; + keyreq_l_ = 0; + default_key_b_ = false; } diff --git a/lily/key-item.cc b/lily/key-item.cc index c765fd0206..12276dcbbf 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -22,17 +22,18 @@ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ Key_item::Key_item (int c) { - breakable_b_ =true; - default_b_ = false; - set_c_position (c); + breakable_b_ =true; + default_b_ = false; + set_c_position (c); } void Key_item::read (Key_engraver const & key_grav_r) { - assert (!key_grav_r.key_.multi_octave_b_); - const Array &idx_arr =key_grav_r.accidental_idx_arr_; - for (int i = 0 ; i< idx_arr.size(); i++) { + assert (!key_grav_r.key_.multi_octave_b_); + const Array &idx_arr =key_grav_r.accidental_idx_arr_; + for (int i = 0 ; i< idx_arr.size(); i++) + { int note = idx_arr[i]; int acc = ((Key &) key_grav_r.key_).oct (0).acc (note); @@ -43,44 +44,47 @@ Key_item::read (Key_engraver const & key_grav_r) void Key_item::set_c_position (int c0) { - int octaves =(abs (c0) / 7) +1 ; - c_position=(c0 + 7*octaves)%7; + int octaves =(abs (c0) / 7) +1 ; + c_position=(c0 + 7*octaves)%7; } void Key_item::add (int p, int a) { - if ((a<0 && p>FLAT_TOP_PITCH) || - (a>0 && p>SHARP_TOP_PITCH)) { - p -= 7; /* Typeset below c_position */ + if ((a<0 && p>FLAT_TOP_PITCH) || + (a>0 && p>SHARP_TOP_PITCH)) + { + p -= 7; /* Typeset below c_position */ } - pitch.push (p); - acc.push (a); + pitch.push (p); + acc.push (a); } Molecule* Key_item::brew_molecule_p()const { - Molecule*output = new Molecule; - Real inter = paper()->internote_f (); - - for (int i =0; i < pitch.size(); i++) { + Molecule*output = new Molecule; + Real inter = paper()->internote_f (); + + for (int i =0; i < pitch.size(); i++) + { Symbol s= paper()->lookup_l ()->accidental (acc[i]); Atom a (s); a.translate ((c_position + pitch[i]) * inter, Y_AXIS); Molecule m (a); output->add_right (m); } - if ( pitch.size()) { + if ( pitch.size()) + { Molecule m (paper()->lookup_l ()->fill (Box ( Interval (0, paper()->note_width ()), Interval (0,0)))); output->add_right (m); } - return output; + return output; } IMPLEMENT_IS_TYPE_B1(Key_item,Item); @@ -88,7 +92,8 @@ IMPLEMENT_IS_TYPE_B1(Key_item,Item); void Key_item::do_pre_processing() { - if (default_b_) { + if (default_b_) + { empty_b_ = transparent_b_ = (break_status_i() != 1); } } diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 0dfe7092f1..d4d0527aa0 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -17,7 +17,7 @@ ADD_THIS_PERFORMER(Key_performer); Key_performer::Key_performer() { - key_req_l_ = 0; + key_req_l_ = 0; } Key_performer::~Key_performer() @@ -28,31 +28,31 @@ void Key_performer::do_print() const { #ifndef NPRINT - if ( key_req_l_) - key_req_l_->print(); + if ( key_req_l_) + key_req_l_->print(); #endif } void Key_performer::process_requests() { - if ( key_req_l_) + if ( key_req_l_) play (new Audio_key (key_req_l_) ); - key_req_l_ = 0; + key_req_l_ = 0; } bool Key_performer::do_try_request (Request* req_l) { - if ( key_req_l_) + if ( key_req_l_) return false; - if ( req_l->command()) + if ( req_l->command()) key_req_l_ = req_l->command()->keychange (); - if ( key_req_l_) + if ( key_req_l_) return true; - return false; + return false; } diff --git a/lily/key.cc b/lily/key.cc index d755b68b3d..1a7892d4b1 100644 --- a/lily/key.cc +++ b/lily/key.cc @@ -16,40 +16,40 @@ const int ZEROOCTAVE=7; Octave_key::Octave_key() { - accidental_i_arr_.set_size (7); - for (int i= 0; i < 7 ; i++) + accidental_i_arr_.set_size (7); + for (int i= 0; i < 7 ; i++) accidental_i_arr_[i] = 0; } Key::Key() { - multi_octave_b_ = false; - octaves.set_size (OCTAVES); + multi_octave_b_ = false; + octaves.set_size (OCTAVES); } Octave_key& Key::oct (int i) { - return octaves[i+ZEROOCTAVE]; + return octaves[i+ZEROOCTAVE]; } void Octave_key::set (int i, int a) { - assert (a > -3 && a < 3); - accidental_i_arr_[i]=a; + assert (a > -3 && a < 3); + accidental_i_arr_[i]=a; } void Key::set (int o, int n , int a) { - octaves[o + ZEROOCTAVE].set (n,a); + octaves[o + ZEROOCTAVE].set (n,a); } void Key::set (int n, int a) { - for (int i= 0; i < OCTAVES ; i++) + for (int i= 0; i < OCTAVES ; i++) octaves[i].set (n,a); } diff --git a/lily/keyword.cc b/lily/keyword.cc index 4eec8b4f72..f027ee86d9 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -9,36 +9,36 @@ /* for the keyword table */ struct Keyword_ent { - char const *name; - int tokcode; + char const *name; + int tokcode; }; struct Keyword_table { - Keyword_ent *table; - int maxkey; - Keyword_table (Keyword_ent *); - int lookup (char const *s) const; + Keyword_ent *table; + int maxkey; + Keyword_table (Keyword_ent *); + int lookup (char const *s) const; }; /* for qsort */ int - tabcmp (void const * p1, void const * p2) + tabcmp (void const * p1, void const * p2) { - return strcmp (((Keyword_ent const *) p1)->name, - ((Keyword_ent const *) p2)->name); + return strcmp (((Keyword_ent const *) p1)->name, + ((Keyword_ent const *) p2)->name); } Keyword_table::Keyword_table (Keyword_ent *tab) { - table = tab; + table = tab; - /* count keywords */ - for (maxkey = 0; table[maxkey].name; maxkey++); + /* count keywords */ + for (maxkey = 0; table[maxkey].name; maxkey++); - /* sort them */ - qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); + /* sort them */ + qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); } /* @@ -47,30 +47,31 @@ Keyword_table::Keyword_table (Keyword_ent *tab) int Keyword_table::lookup (char const *s)const { - int lo, - hi, - cmp, - result; - lo = 0; - hi = maxkey; + int lo, + hi, + cmp, + result; + lo = 0; + hi = maxkey; - /* binary search */ - do - { - cmp = (lo + hi) / 2; + /* binary search */ + do + { + cmp = (lo + hi) / 2; - result = strcmp (s, table[cmp].name); + result = strcmp (s, table[cmp].name); - if (result < 0) - hi = cmp; - else - lo = cmp; + if (result < 0) + hi = cmp; + else + lo = cmp; } - while (hi - lo > 1); - if (!strcmp (s, table[lo].name)) - { - return table[lo].tokcode; - } else - return -1; /* not found */ + while (hi - lo > 1); + if (!strcmp (s, table[lo].name)) + { + return table[lo].tokcode; + } + else + return -1; /* not found */ } diff --git a/lily/leastsquares.cc b/lily/leastsquares.cc index 7f274bf4d1..ab718a97f7 100644 --- a/lily/leastsquares.cc +++ b/lily/leastsquares.cc @@ -2,23 +2,24 @@ void Least_squares::OK() const { - assert (input.size() > 1); - Real dx = 0.0; - for (int i=1; i < input.size(); i++) + assert (input.size() > 1); + Real dx = 0.0; + for (int i=1; i < input.size(); i++) dx += abs (input[i-1].x() - input[i].x ()); - assert (dx); + assert (dx); } void Least_squares::minimise (Real &coef, Real &offset) { - OK(); - Real sx = 0.0; - Real sy = 0.0; - Real sqx =0.0; - Real sxy = 0.0; + OK(); + Real sx = 0.0; + Real sy = 0.0; + Real sqx =0.0; + Real sxy = 0.0; - for (int i=0; i < input.size();i++) { + for (int i=0; i < input.size();i++) + { Real x=input[i].x(); Real y = input[i].y(); sx += x; @@ -26,10 +27,10 @@ Least_squares::minimise (Real &coef, Real &offset) sqx += sqr (x); sxy += x*y; } - int N = input.size(); - + int N = input.size(); + - coef = (N * sxy - sx*sy)/(N*sqx - sqr (sx)); - offset = (sy - coef * sx)/N; + coef = (N * sxy - sx*sy)/(N*sqx - sqr (sx)); + offset = (sy - coef * sx)/N; } diff --git a/lily/lexerinit.cc b/lily/lexerinit.cc index 698bc8bf7b..6f5cd27f26 100644 --- a/lily/lexerinit.cc +++ b/lily/lexerinit.cc @@ -26,5 +26,5 @@ yylex() { bool busy_parsing() { - return lexer; + return lexer; } diff --git a/lily/lily-version.cc b/lily/lily-version.cc index 65d8c72548..68a6b49037 100644 --- a/lily/lily-version.cc +++ b/lily/lily-version.cc @@ -10,7 +10,7 @@ static const int build= char const * lily_version_sz() { - static char v[1024]; // ugh - sprintf (v, s, build); - return v; + static char v[1024]; // ugh + sprintf (v, s, build); + return v; } diff --git a/lily/line-group-grav.cc b/lily/line-group-grav.cc index f023df2e1a..9d544d061e 100644 --- a/lily/line-group-grav.cc +++ b/lily/line-group-grav.cc @@ -15,13 +15,13 @@ Line_group_engraver::Line_group_engraver() { - staffline_p_ =0; + staffline_p_ =0; } void Line_group_engraver::acknowledge_element (Score_elem_info elem) { - if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS]) + if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS]) staffline_p_->add_element (elem.elem_l_); } @@ -29,19 +29,19 @@ Line_group_engraver::acknowledge_element (Score_elem_info elem) void Line_group_engraver::do_removal_processing() { - staffline_p_->right_col_l_ = get_staff_info().command_pcol_l (); - typeset_element (staffline_p_); - staffline_p_ = 0; + staffline_p_->right_col_l_ = get_staff_info().command_pcol_l (); + typeset_element (staffline_p_); + staffline_p_ = 0; } void Line_group_engraver::do_creation_processing() { - staffline_p_ = new Vertical_group_spanner ; - staffline_p_->left_col_l_ = get_staff_info().command_pcol_l (); + staffline_p_ = new Vertical_group_spanner ; + staffline_p_->left_col_l_ = get_staff_info().command_pcol_l (); - // don't broadcast to self. - announce_element (Score_elem_info (staffline_p_,0)); + // don't broadcast to self. + announce_element (Score_elem_info (staffline_p_,0)); } diff --git a/lily/line-spacer.cc b/lily/line-spacer.cc index 3729744ec0..5f51ad3ad4 100644 --- a/lily/line-spacer.cc +++ b/lily/line-spacer.cc @@ -11,10 +11,10 @@ Line_spacer::Line_spacer() { - paper_l_ =0; + paper_l_ =0; } Paper_def* Line_spacer::paper_l()const { - return paper_l_ ; + return paper_l_ ; } diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 51464e9eb6..b81adc5fcf 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -19,59 +19,62 @@ Local_key_item::Local_key_item (int i) { - c0_position = i; + c0_position = i; } void Local_key_item::add_support (Item*head_l) { - support_items_.push (head_l); - add_dependency (head_l); + support_items_.push (head_l); + add_dependency (head_l); } void Local_key_item::add (Melodic_req*m_l) { - add (m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); + add (m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); } void Local_key_item::add (int o, int p , int a) { - Local_acc l; - l.octave_i_ = o; - l.name_i_ = p; - l.accidental_i_ = a; - for (int i=0; i< accs.size(); i++) + Local_acc l; + l.octave_i_ = o; + l.name_i_ = p; + l.accidental_i_ = a; + for (int i=0; i< accs.size(); i++) if (!Local_acc::compare (l, accs[i])) return; - - accs.push (l); + + accs.push (l); } void Local_key_item::do_pre_processing() { - accs.sort (Local_acc::compare); + accs.sort (Local_acc::compare); } Molecule* Local_key_item::brew_molecule_p()const { - Molecule* output = new Molecule; - Molecule*octmol = 0; - int lastoct = -100; - for (int i = 0; i < accs.size(); i++) { + Molecule* output = new Molecule; + Molecule*octmol = 0; + int lastoct = -100; + for (int i = 0; i < accs.size(); i++) + { // do one octave - if (accs[i].octave_i_ != lastoct) { - if (octmol){ + if (accs[i].octave_i_ != lastoct) + { + if (octmol) + { Real dy =lastoct*7*paper()->internote_f (); octmol->translate (dy, Y_AXIS); output->add (*octmol); delete octmol; - } + } octmol= new Molecule; - } + } lastoct = accs[i].octave_i_; Symbol s =paper()->lookup_l ()->accidental (accs[i].accidental_i_); Atom a (s); @@ -81,28 +84,29 @@ Local_key_item::brew_molecule_p()const octmol->add_right (a); } - if (octmol){ + if (octmol) + { Real dy =lastoct*7*paper()->internote_f (); octmol->translate (dy, Y_AXIS); output->add (*octmol); delete octmol; } - Interval head_width=itemlist_width (support_items_); - output->translate (-output->extent().x ().right + head_width.left , X_AXIS); - - return output; + Interval head_width=itemlist_width (support_items_); + output->translate (-output->extent().x ().right + head_width.left , X_AXIS); + + return output; } int Local_acc::compare (Local_acc&a, Local_acc&b) { - if (a.octave_i_ - b.octave_i_) + if (a.octave_i_ - b.octave_i_) return a.octave_i_ - b.octave_i_; - if (a.name_i_ - b.name_i_) + if (a.name_i_ - b.name_i_) return a.name_i_ - b.name_i_; - - return a.accidental_i_ - b.accidental_i_; + + return a.accidental_i_ - b.accidental_i_; }; IMPLEMENT_IS_TYPE_B1(Local_key_item,Item); @@ -110,8 +114,8 @@ IMPLEMENT_IS_TYPE_B1(Local_key_item,Item); void Local_key_item::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Item* o_l = o->item(); - Item* n_l = n?n->item():0; + Item* o_l = o->item(); + Item* n_l = n?n->item():0; - support_items_.substitute (o_l, n_l); + support_items_.substitute (o_l, n_l); } diff --git a/lily/lyric-grav.cc b/lily/lyric-grav.cc index c4a09ac34c..c29b46d5fe 100644 --- a/lily/lyric-grav.cc +++ b/lily/lyric-grav.cc @@ -15,25 +15,26 @@ Lyric_engraver::Lyric_engraver() { - lreq_l_ =0; - lyric_item_p_ =0; + lreq_l_ =0; + lyric_item_p_ =0; } bool Lyric_engraver::do_try_request (Request*r) { - Musical_req * m =r->musical(); - if (!m || ! m->lreq_l()) + Musical_req * m =r->musical(); + if (!m || ! m->lreq_l()) return false; - lreq_l_ = m->lreq_l(); + lreq_l_ = m->lreq_l(); - return true; + return true; } void Lyric_engraver::do_process_requests() { - if ( lreq_l_) { + if ( lreq_l_) + { lyric_item_p_ = new Text_item (lreq_l_->tdef_p_); lyric_item_p_->translate (paper()->note_width ()/2 , X_AXIS); @@ -46,13 +47,14 @@ Lyric_engraver::do_process_requests() void Lyric_engraver::do_post_move_processing() { - lreq_l_ =0; + lreq_l_ =0; } void Lyric_engraver::do_pre_move_processing() { - if ( lyric_item_p_){ + if ( lyric_item_p_) + { typeset_element (lyric_item_p_); lyric_item_p_ =0; } diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index b440939393..b800f3d1ad 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -28,27 +28,27 @@ void Lyric_performer::do_print() const { #ifndef NPRINT - if ( lreq_arr_.size()) - lreq_arr_[ 0 ]->print(); + if ( lreq_arr_.size()) + lreq_arr_[ 0 ]->print(); #endif } void Lyric_performer::process_requests() { - if ( lreq_arr_.size()) + if ( lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i() ) play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_) ); - lreq_arr_.clear(); + lreq_arr_.clear(); } bool Lyric_performer::do_try_request (Request* req_l) { - Musical_req* m_l = req_l->musical(); - if ( !m_l || ! m_l->lreq_l()) + Musical_req* m_l = req_l->musical(); + if ( !m_l || ! m_l->lreq_l()) return false; - lreq_arr_.push (m_l->lreq_l()); + lreq_arr_.push (m_l->lreq_l()); - return true; + return true; } diff --git a/lily/main.cc b/lily/main.cc index a32b0a6a86..eb9f611543 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -28,27 +28,27 @@ int exit_status_i_; void destill_inname (String &name_str_r); Long_option_init theopts[] = { - {1, "output", 'o'}, - {0, "warranty", 'w'}, - {0, "help", 'h'}, - {0, "debug", 'd'}, - {1, "init", 'i'}, - {1, "include", 'I'}, - {0, "midi", 'M'}, - {0, "ignore-version", 'V'}, - {0,0,0} + {1, "output", 'o'}, + {0, "warranty", 'w'}, + {0, "help", 'h'}, + {0, "debug", 'd'}, + {1, "init", 'i'}, + {1, "include", 'I'}, + {0, "midi", 'M'}, + {0, "ignore-version", 'V'}, + {0,0,0} }; void usage() { - cout << - "Usage: lilypond [options] [mudela-file]\n" + cout << + "Usage: lilypond [options] [mudela-file]\n" "Typeset and or produce midi output from mudela-file or stdin\n" "\n" "Options:\n" " -d, --debug enable debugging output\n" - " -I, --include=DIR add DIR to search path\n" + " -I, --include=DIR add DIR to search path\n" " -i, --init=FILE use FILE as init file\n" " -h, --help this help\n" " -w, --warranty show warranty and copyright\n" @@ -71,14 +71,14 @@ usage() "\n"; ; - - + + } void notice() { - cout << + cout << "\n" "GNU LilyPond -- The GNU Project music typesetter.\n" "Copyright 1996,97 by\n" @@ -106,49 +106,54 @@ static File_path path; void do_one_file (String init_str, String file_str) { - if ( init_str != "" && "" == path.find (init_str) ) { + if ( init_str != "" && "" == path.find (init_str) ) + { error ( "Can not find `" + init_str +"\'"); return ; } - if ( file_str!= "" && path.find (file_str) == "" ) { + if ( file_str!= "" && path.find (file_str) == "" ) + { error ( "Can not find `" + file_str + "'"); return ; } - - Sources sources; - source_l_g = &sources; - source_l_g->set_path (&path); - { + + Sources sources; + source_l_g = &sources; + source_l_g->set_path (&path); + { My_lily_parser parser (source_l_g); parser.set_version_check (version_ignore_b_); parser.parse_file (init_str, file_str); } - do_scores(); - source_l_g = 0; + do_scores(); + source_l_g = 0; } int main (int argc, char **argv) { - debug_init(); // should be first + debug_init(); // should be first - // must override (come before) "/usr/local/share/lilypond"! - char const * env_l=getenv ("LILYINCLUDE"); - if (env_l) { + // must override (come before) "/usr/local/share/lilypond"! + char const * env_l=getenv ("LILYINCLUDE"); + if (env_l) + { path.add (env_l); } - path.add (""); - path.add (String (DIR_DATADIR) + "/init/" ); - - path.push (DIR_DATADIR); - - Getopt_long oparser (argc, argv,theopts); - cout << get_version_str() << endl; - String init_str ("symbol.ly"); - - while (Long_option_init const * opt = oparser()) { - switch ( opt->shortname){ + path.add (""); + path.add (String (DIR_DATADIR) + "/init/" ); + + path.push (DIR_DATADIR); + + Getopt_long oparser (argc, argv,theopts); + cout << get_version_str() << endl; + String init_str ("symbol.ly"); + + while (Long_option_init const * opt = oparser()) + { + switch ( opt->shortname) + { case 'o': set_default_output (oparser.optional_argument_ch_C_); break; @@ -178,31 +183,33 @@ main (int argc, char **argv) default: assert (false); break; - } + } } - int p=0; - const char *arg ; - while ( (arg= oparser.get_next_arg())) { + int p=0; + const char *arg ; + while ( (arg= oparser.get_next_arg())) + { String f (arg); destill_inname (f); do_one_file (init_str,f); p++; } - if (!p) { + if (!p) + { do_one_file (init_str, ""); } - return exit_status_i_; + return exit_status_i_; } /// make input file name: add default extension. "" is stdin. void destill_inname (String &name_str_r) { - if ( name_str_r.length_i()) - { - if (name_str_r[ 0 ] != '-') + if ( name_str_r.length_i()) + { + if (name_str_r[ 0 ] != '-') { String a,b,c,d; split_path (name_str_r,a,b,c,d); @@ -211,7 +218,8 @@ destill_inname (String &name_str_r) if (d == "") d = ".ly"; name_str_r = a+b+c+d; - } - } else name_str_r = ""; + } + } + else name_str_r = ""; } diff --git a/lily/meter-grav.cc b/lily/meter-grav.cc index eff12b4a6c..7f5a0d3bc8 100644 --- a/lily/meter-grav.cc +++ b/lily/meter-grav.cc @@ -13,78 +13,93 @@ Meter_engraver::Meter_engraver() { - meter_req_l_ = 0; - meter_p_ =0; - default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh + meter_req_l_ = 0; + meter_p_ =0; + default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh } void Meter_engraver::fill_staff_info (Staff_info&inf) { - inf.time_C_ = &time_; - inf.rhythmic_C_ = &default_grouping_; + inf.time_C_ = &time_; + inf.rhythmic_C_ = &default_grouping_; } bool Meter_engraver::do_try_request (Request*r) { - bool gotcha = false; + bool gotcha = false; - if (r->command() && r->command ()->timing ()) { + if (r->command() && r->command ()->timing ()) + { gotcha = true; Timing_req * tr_l = r->command()->timing (); Meter_change_req *m_l = tr_l->meterchange(); - if (m_l) { + if (m_l) + { meter_req_l_ = m_l; int b_i= m_l->beats_i_; int o_i = m_l->one_beat_i_; if (! time_.allow_meter_change_b()) tr_l->warning ("Meter change not allowed here"); - else{ + else + { time_.set_meter (b_i, o_i); default_grouping_ = Rhythmic_grouping (MInterval (0,Moment (b_i, o_i)), b_i); - } - } else if (tr_l->partial()) { + } + } + else if (tr_l->partial()) + { Moment m = tr_l->partial()->duration_; String error = time_.try_set_partial_str (m); - if (error != "") { + if (error != "") + { tr_l->warning (error); - } else + } + else time_.setpartial (m); - } else if (tr_l->barcheck()) { - if (time_.whole_in_measure_) { + } + else if (tr_l->barcheck()) + { + if (time_.whole_in_measure_) + { tr_l ->warning ("Barcheck failed"); time_.whole_in_measure_ = 0; // resync time_.error_b_ = true; - } + } - } else if (tr_l->cadenza()) { + } + else if (tr_l->cadenza()) + { time_.set_cadenza (tr_l->cadenza()->on_b_); - } else if (tr_l->measuregrouping()) { + } + else if (tr_l->measuregrouping()) + { default_grouping_ = parse_grouping ( tr_l->measuregrouping()->beat_i_arr_, tr_l->measuregrouping()->elt_length_arr_); } } - - return gotcha; + + return gotcha; } void Meter_engraver::do_creation_processing() { - time_.when_ = get_staff_info().when (); + time_.when_ = get_staff_info().when (); } void Meter_engraver::do_process_requests() { - if (meter_req_l_) { + if (meter_req_l_) + { Array args; args.push (meter_req_l_->beats_i_); args.push (meter_req_l_->one_beat_i_); @@ -92,33 +107,35 @@ Meter_engraver::do_process_requests() meter_p_ = new Meter (args); } - if (meter_p_) + if (meter_p_) announce_element (Score_elem_info (meter_p_, meter_req_l_)); } void Meter_engraver::do_pre_move_processing() { - if (meter_p_) { + if (meter_p_) + { typeset_element (meter_p_); meter_p_ =0; meter_req_l_ = 0; } - Engraver_group_engraver * grav_l = daddy_grav_l_; - while (grav_l->daddy_grav_l_) { + Engraver_group_engraver * grav_l = daddy_grav_l_; + while (grav_l->daddy_grav_l_) + { grav_l = grav_l->daddy_grav_l_; } - - assert (grav_l->name() == Score_engraver::static_name ()); - if (!time_.cadenza_b_) + + assert (grav_l->name() == Score_engraver::static_name ()); + if (!time_.cadenza_b_) ((Score_engraver*)grav_l)->add_moment_to_process (time_.next_bar_moment()); } void Meter_engraver::do_post_move_processing() { - time_.add (get_staff_info().when () - time_.when_); + time_.add (get_staff_info().when () - time_.when_); } diff --git a/lily/meter-performer.cc b/lily/meter-performer.cc index 6d6d1ee4a9..0d23bb9a9b 100644 --- a/lily/meter-performer.cc +++ b/lily/meter-performer.cc @@ -15,7 +15,7 @@ ADD_THIS_PERFORMER(Meter_performer); Meter_performer::Meter_performer() { - meter_req_l_ = 0; + meter_req_l_ = 0; } Meter_performer::~Meter_performer() @@ -26,31 +26,31 @@ void Meter_performer::do_print() const { #ifndef NPRINT - if ( meter_req_l_) - meter_req_l_->print(); + if ( meter_req_l_) + meter_req_l_->print(); #endif } void Meter_performer::process_requests() { - if ( meter_req_l_) + if ( meter_req_l_) play (new Audio_meter (meter_req_l_) ); - meter_req_l_ = 0; + meter_req_l_ = 0; } bool Meter_performer::do_try_request (Request* req_l) { - if ( meter_req_l_) + if ( meter_req_l_) return false; - if ( req_l->command()) + if ( req_l->command()) meter_req_l_ = req_l->command()->meterchange (); - if ( meter_req_l_) + if ( meter_req_l_) return true; - return false; + return false; } diff --git a/lily/meter.cc b/lily/meter.cc index dc7efa3a5c..e8fcd8f9f0 100644 --- a/lily/meter.cc +++ b/lily/meter.cc @@ -5,16 +5,16 @@ #include "lookup.hh" Meter::Meter (Arraya) - :args (a) + :args (a) { - breakable_b_ = true; + breakable_b_ = true; } Molecule* Meter::brew_molecule_p()const { - Symbol s = paper()->lookup_l ()->meter (args); - return new Molecule (Atom (s)); + Symbol s = paper()->lookup_l ()->meter (args); + return new Molecule (Atom (s)); } diff --git a/lily/midi-def.cc b/lily/midi-def.cc index 95b3e25b0c..2307155ba8 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -29,66 +29,66 @@ int Midi_def::num_i_s = 4; Midi_def::Midi_def() { - outfile_str_ = ""; - itrans_p_ = 0; - // ugh - set_tempo (Moment (1, 4), 60 ); + outfile_str_ = ""; + itrans_p_ = 0; + // ugh + set_tempo (Moment (1, 4), 60 ); } Midi_def::Midi_def (Midi_def const& s) { - whole_seconds_f_ = s.whole_seconds_f_; - itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_) : 0; - outfile_str_ = s.outfile_str_; + whole_seconds_f_ = s.whole_seconds_f_; + itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_) : 0; + outfile_str_ = s.outfile_str_; } Midi_def::~Midi_def() { - delete itrans_p_; + delete itrans_p_; } Real Midi_def::duration_to_seconds_f (Moment mom) { - if ( !mom) + if ( !mom) return 0; - - return Moment (whole_seconds_f_) * mom; + + return Moment (whole_seconds_f_) * mom; } Global_translator* Midi_def::get_global_translator_p() const { - return itrans_p_->get_group_performer_p()->global_l (); + return itrans_p_->get_group_performer_p()->global_l (); } int Midi_def::get_tempo_i (Moment moment) { - return Moment (whole_seconds_f_) * Moment (60 ) * moment; + return Moment (whole_seconds_f_) * Moment (60 ) * moment; } void Midi_def::print() const { #ifndef NPRINT - DOUT << "Midi {"; - DOUT << "4/min: " << Real (60) / ( whole_seconds_f_ * 4 ); - DOUT << "out: " << outfile_str_; - DOUT << "}\n"; + DOUT << "Midi {"; + DOUT << "4/min: " << Real (60) / ( whole_seconds_f_ * 4 ); + DOUT << "out: " << outfile_str_; + DOUT << "}\n"; #endif } void Midi_def::set (Input_translator* itrans_p) { - delete itrans_p_; - itrans_p_ = itrans_p; + delete itrans_p_; + itrans_p_ = itrans_p; } void Midi_def::set_tempo (Moment moment, int count_per_minute_i) { - whole_seconds_f_ = Moment (count_per_minute_i) / Moment (60 ) / moment; + whole_seconds_f_ = Moment (count_per_minute_i) / Moment (60 ) / moment; } diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index fadd2f06f5..5f1b3ee501 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -17,52 +17,52 @@ Midi_stream::Midi_stream (String filename_str) { - filename_str_ = filename_str; - os_p_ = 0; - open(); + filename_str_ = filename_str; + os_p_ = 0; + open(); } Midi_stream::~Midi_stream() { - delete os_p_; + delete os_p_; } Midi_stream& Midi_stream::operator <<( String str) { - if ( check_debug) + if ( check_debug) str = String_convert::bin2hex_str (str); - - *os_p_ << str; + + *os_p_ << str; - if ( check_debug) - *os_p_ << "\n"; + if ( check_debug) + *os_p_ << "\n"; - return *this; + return *this; } Midi_stream& Midi_stream::operator <<( Midi_item const& mitem_c_r) { // *this << mitem_c_r.str(); - mitem_c_r.output (this); - if ( check_debug) - *os_p_ << "\n"; - return *this; + mitem_c_r.output (this); + if ( check_debug) + *os_p_ << "\n"; + return *this; } Midi_stream& Midi_stream::operator <<( int i) { - // output binary string ourselves - *this << Midi_item::i2varint_str (i); - return *this; + // output binary string ourselves + *this << Midi_item::i2varint_str (i); + return *this; } void Midi_stream::open() { - os_p_ = new ofstream (filename_str_); - if ( !*os_p_) + os_p_ = new ofstream (filename_str_); + if ( !*os_p_) error ("can't open `" + filename_str_ + "\'"); } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 1827eb39e2..aea8fcc0d7 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "midi-walker.hh" @@ -17,26 +17,26 @@ Midi_note_event::Midi_note_event() { - ignore_b_ = false; + ignore_b_ = false; } int compare (Midi_note_event const& left, Midi_note_event const& right) { - return sign (left.key - right.key); + return sign (left.key - right.key); } Midi_walker::Midi_walker (Audio_staff* audio_staff_l, Midi_track* track_l) - : PCursor( audio_staff_l->audio_item_l_list_) + : PCursor( audio_staff_l->audio_item_l_list_) { - track_l_ = track_l; - last_mom_ = 0; + track_l_ = track_l; + last_mom_ = 0; } Midi_walker::~Midi_walker() { - // ugh - do_stop_notes (last_mom_ + Moment (10, 1) ); + // ugh + do_stop_notes (last_mom_ + Moment (10, 1) ); } /** @@ -45,22 +45,24 @@ Midi_walker::~Midi_walker() void Midi_walker::do_start_note (Midi_note* note_l) { - Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom (); - for ( int i=0; i < stop_note_queue.size(); i++) { - if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) { + Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom (); + for ( int i=0; i < stop_note_queue.size(); i++) + { + if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) + { if ( stop_note_queue[ i ].key < stop_mom) stop_note_queue[ i ].ignore_b_ = true; else // skip the stopnote return; - } + } } - Midi_note_event e; - e.val = new Midi_note_off (note_l); - e.key = stop_mom; - stop_note_queue.insert (e); - - output_event (ptr()->audio_column_l_->at_mom (), note_l); + Midi_note_event e; + e.val = new Midi_note_off (note_l); + e.key = stop_mom; + stop_note_queue.insert (e); + + output_event (ptr()->audio_column_l_->at_mom (), note_l); } /** @@ -69,7 +71,8 @@ Midi_walker::do_start_note (Midi_note* note_l) void Midi_walker::do_stop_notes (Moment max_mom) { - while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) { + while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) + { Midi_note_event e = stop_note_queue.get(); if ( e.ignore_b_) continue; @@ -87,24 +90,26 @@ Midi_walker::do_stop_notes (Moment max_mom) void Midi_walker::output_event (Moment now_mom, Midi_item* l) { - Moment delta_t = now_mom - last_mom_ ; - last_mom_ += delta_t; - track_l_->add (delta_t, l); + Moment delta_t = now_mom - last_mom_ ; + last_mom_ += delta_t; + track_l_->add (delta_t, l); } void Midi_walker::process() { - do_stop_notes (ptr()->audio_column_l_->at_mom ()); + do_stop_notes (ptr()->audio_column_l_->at_mom ()); - Midi_item* p = ptr()->midi_item_p (); - p->channel_i_ = track_l_->number_i_; - - if ( p->name() != Midi_note::static_name ()) + Midi_item* p = ptr()->midi_item_p (); + if ( !p ) + return; + p->channel_i_ = track_l_->number_i_; + + if ( p->name() != Midi_note::static_name ()) output_event (ptr()->audio_column_l_->at_mom (), p); - else + else do_start_note ((Midi_note*)p); - delete p; + delete p; } diff --git a/lily/misc.cc b/lily/misc.cc index 946e27e4bb..d150d55792 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -14,32 +14,34 @@ int intlog2(int d) { - int i=0; - while (!(d&1)) { + int i=0; + while (!(d&1)) + { d/= 2; i++; } - assert (!(d/2)); - return i; + assert (!(d/2)); + return i; } double log_2(double x) { - return log (x) /log (2.0); + return log (x) /log (2.0); } #if 1 Interval itemlist_width (const Array &its) { - Interval iv ; - iv.set_empty(); - - for (int j =0; j < its.size(); j++){ + Interval iv ; + iv.set_empty(); + + for (int j =0; j < its.size(); j++) + { iv.unite (its[j]->width()); } - return iv; + return iv; } #endif diff --git a/lily/molecule.cc b/lily/molecule.cc index 663a554e93..ad176da26f 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -17,39 +17,40 @@ String Molecule::TeX_string() const { - String s; - for (iter_top (ats,c); c.ok(); c++) + String s; + for (iter_top (ats,c); c.ok(); c++) s+=c->TeX_string(); - return s; + return s; } Box Molecule::extent() const { - Box b; - for (iter_top (ats,c); c.ok(); c++) + Box b; + for (iter_top (ats,c); c.ok(); c++) b.unite (c->extent()); - return b; + return b; } void Molecule::translate (Offset o) { - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->translate (o); } void Molecule::translate (Real x,Axis a) { - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->translate (x,a); } void Molecule::add (Molecule const &m) { - for (iter_top (m.ats,c); c.ok(); c++) { + for (iter_top (m.ats,c); c.ok(); c++) + { add (**c); } } @@ -57,78 +58,82 @@ Molecule::add (Molecule const &m) void Molecule::add_right (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } - Real xof=extent().x ().right - m.extent ().x ().left; + Real xof=extent().x ().right - m.extent ().x ().left; - - Molecule toadd (m); - toadd.translate (Offset (xof, 0.0)); - add (toadd); + + Molecule toadd (m); + toadd.translate (Offset (xof, 0.0)); + add (toadd); } void Molecule::add_left (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } Real xof=extent().x ().left - m.extent ().x ().right; - Molecule toadd (m); - toadd.translate (Offset (xof, 0.0)); - add (toadd); + Molecule toadd (m); + toadd.translate (Offset (xof, 0.0)); + add (toadd); } void Molecule::add_top (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } Real yof=extent().y ().right - m.extent ().y ().left; - Molecule toadd (m); - toadd.translate (yof, Y_AXIS); - add (toadd); + Molecule toadd (m); + toadd.translate (yof, Y_AXIS); + add (toadd); } void Molecule::add_bottom (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } - Real yof=extent().y ().left- m.extent ().y ().right; - Molecule toadd (m); - toadd.translate (yof, Y_AXIS); - add (toadd); + Real yof=extent().y ().left- m.extent ().y ().right; + Molecule toadd (m); + toadd.translate (yof, Y_AXIS); + add (toadd); } void Molecule::operator = (Molecule const &) { - assert (false); + assert (false); } Molecule::Molecule (Molecule const &s) { - add (s); + add (s); } void Molecule::print() const { #ifndef NPRINT - if (! check_debug) + if (! check_debug) return; - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->print(); #endif } @@ -136,5 +141,5 @@ Molecule::print() const void Molecule::add (Atom const &a) { - ats.bottom().add (new Atom (a)); + ats.bottom().add (new Atom (a)); } diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 2314320165..56a6476ff6 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -29,60 +29,60 @@ void Music_iterator::print() const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << name() << "{"; - DOUT << "report to " << + DOUT << name() << "{"; + DOUT << "report to " << report_to_l() << " (" << report_to_l ()->name () << ")\n"; - DOUT << "next at " << next_moment() << " "; - do_print(); - DOUT << "}\n"; + DOUT << "next at " << next_moment() << " "; + do_print(); + DOUT << "}\n"; #endif } Translator * Music_iterator::get_req_translator_l() { - assert (report_to_l()); - if (report_to_l()->is_bottom_engraver_b ()) + assert (report_to_l()); + if (report_to_l()->is_bottom_engraver_b ()) return report_to_l(); - set_translator (report_to_l()->get_default_interpreter ()); - return report_to_l(); + set_translator (report_to_l()->get_default_interpreter ()); + return report_to_l(); } void Music_iterator::push_translator (Translator*t) { - report_to_l_arr_.push (t); - t->iterator_count_ ++; + report_to_l_arr_.push (t); + t->iterator_count_ ++; } void Music_iterator::pop_translator() { - report_to_l()->iterator_count_ --; - assert (report_to_l()->iterator_count_ >=0); - report_to_l_arr_.pop(); + report_to_l()->iterator_count_ --; + assert (report_to_l()->iterator_count_ >=0); + report_to_l_arr_.pop(); } Translator* Music_iterator::report_to_l()const { - if (! report_to_l_arr_.size()) + if (! report_to_l_arr_.size()) return 0; - return report_to_l_arr_.top(); + return report_to_l_arr_.top(); } void Music_iterator::set_translator (Translator*trans) { - if (report_to_l()==trans) + if (report_to_l()==trans) return; - if ( report_to_l()) + if ( report_to_l()) pop_translator(); - if (trans) + if (trans) push_translator (trans); } @@ -94,86 +94,90 @@ Music_iterator::construct_children() Music_iterator::~Music_iterator() { - set_translator (0); + set_translator (0); } Moment Music_iterator::next_moment()const { - return 0; + return 0; } void Music_iterator::process_and_next (Moment) { - first_b_ = false; + first_b_ = false; } bool Music_iterator::ok()const { - return first_b_; + return first_b_; } Music_iterator* Music_iterator::static_get_iterator_p (Music *m, Translator *report_l) { - Music_iterator * p =0; - if (m->is_type_b (Request_chord::static_name())) + Music_iterator * p =0; + if (m->is_type_b (Request_chord::static_name())) p = new Request_chord_iterator ((Request_chord*) m); - else if (m->is_type_b (Chord::static_name())) + else if (m->is_type_b (Chord::static_name())) p = new Chord_iterator ((Chord*) m); - else if (m->is_type_b (Voice::static_name())) + else if (m->is_type_b (Voice::static_name())) p = new Voice_iterator ((Voice*) m); - - if (m -> type_str_ != "") { + + if (m -> type_str_ != "") + { Translator * a =report_l-> find_get_translator_l (m-> type_str_, m->id_str_); p->set_translator (a); - } + } - if (! p->report_to_l()) + if (! p->report_to_l()) p ->set_translator (report_l); - - return p; + + return p; } Music_iterator* Music_iterator::get_iterator_p (Music*m)const { - Music_iterator*p = static_get_iterator_p (m,report_to_l()); - p->daddy_iter_l_ = (Music_iterator*)this; - p->construct_children(); - return p; + Music_iterator*p = static_get_iterator_p (m,report_to_l()); + p->daddy_iter_l_ = (Music_iterator*)this; + p->construct_children(); + return p; } Music_iterator::Music_iterator() { - daddy_iter_l_ =0; - first_b_ = true; + daddy_iter_l_ =0; + first_b_ = true; } /* ************** */ Chord_iterator::Chord_iterator (Chord const *chord_C) { - chord_C_ = chord_C; + chord_C_ = chord_C; } void Chord_iterator::construct_children() { - int j = 0; - for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; - i.ok(); j++, i++) { + int j = 0; + for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; + i.ok(); j++, i++) + { Music_iterator * mi = get_iterator_p (i.ptr()); - if ( mi->ok()) { + if ( mi->ok()) + { set_translator (mi->report_to_l()->ancestor_l ( chord_C_->multi_level_i_) ); children_p_list_.bottom().add (mi); - } else + } + else delete mi; } } @@ -181,7 +185,8 @@ void Chord_iterator::do_print() const { #ifndef NPRINT - for (PCursor i (children_p_list_.top()); i.ok (); i++) { + for (PCursor i (children_p_list_.top()); i.ok (); i++) + { i->print(); } #endif @@ -190,16 +195,18 @@ Chord_iterator::do_print() const void Chord_iterator::process_and_next (Moment until) { - for (PCursor i (children_p_list_.top()); i.ok ();) { - if (i->next_moment() == until) { + for (PCursor i (children_p_list_.top()); i.ok ();) + { + if (i->next_moment() == until) + { i->process_and_next (until); - } + } if (!i->ok()) delete i.remove_p(); else i++; } - Music_iterator::process_and_next (until); + Music_iterator::process_and_next (until); } @@ -208,10 +215,10 @@ IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator); Moment Chord_iterator::next_moment()const { - Moment next_ = infinity_mom; - for (PCursor i (children_p_list_.top()); i.ok (); i++) + Moment next_ = infinity_mom; + for (PCursor i (children_p_list_.top()); i.ok (); i++) next_ = next_ next_moment() ; - return next_; + return next_; } @@ -219,7 +226,7 @@ Chord_iterator::next_moment()const bool Chord_iterator::ok()const { - return children_p_list_.size(); + return children_p_list_.size(); } /* ************** */ @@ -227,60 +234,64 @@ Chord_iterator::ok()const void Voice_iterator::do_print()const { - if (iter_p_) + if (iter_p_) iter_p_->print(); } Voice_iterator::Voice_iterator (Voice const*v) - : PCursor ( v->music_p_list_) + : PCursor ( v->music_p_list_) { - here_mom_ = v->offset_mom_; - voice_C_ = v; - iter_p_ =0; + here_mom_ = v->offset_mom_; + voice_C_ = v; + iter_p_ =0; } void Voice_iterator::construct_children() { - while (PCursor::ok()) { + while (PCursor::ok()) + { start_next_element(); - if ( !iter_p_->ok()) { + if ( !iter_p_->ok()) + { leave_element(); - } else { + } + else + { set_voice_translator(); break; - } + } } } void Voice_iterator::leave_element() { - delete iter_p_; - iter_p_ =0; - MInterval elt_time = ptr()->time_int (); - if (!elt_time.empty_b()) + delete iter_p_; + iter_p_ =0; + MInterval elt_time = ptr()->time_int (); + if (!elt_time.empty_b()) here_mom_ += elt_time.length(); - PCursor::next(); + PCursor::next(); } void Voice_iterator::start_next_element() { - assert (!iter_p_); - iter_p_ = get_iterator_p (ptr()); + assert (!iter_p_); + iter_p_ = get_iterator_p (ptr()); } void Voice_iterator::set_voice_translator() { - if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) + if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) set_translator (iter_p_->report_to_l()); } Voice_iterator::~Voice_iterator() { - assert (! iter_p_); + assert (! iter_p_); } @@ -289,42 +300,48 @@ IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator); void Voice_iterator::process_and_next (Moment until) { - while (1) { + while (1) + { Moment local_until = until - here_mom_; - while ( iter_p_->ok()) { + while ( iter_p_->ok()) + { Moment here = iter_p_->next_moment(); if (here != local_until) goto loopexit; iter_p_->process_and_next (local_until); - } + } - if (!iter_p_->ok()) { + if (!iter_p_->ok()) + { leave_element(); - if ( PCursor::ok()) { + if ( PCursor::ok()) + { start_next_element(); set_voice_translator(); - } else { + } + else + { goto loopexit; - } - } + } + } } loopexit: - Music_iterator::process_and_next (until); + Music_iterator::process_and_next (until); } Moment Voice_iterator::next_moment()const { - return iter_p_->next_moment() + here_mom_; + return iter_p_->next_moment() + here_mom_; } bool Voice_iterator::ok()const { - return iter_p_; + return iter_p_; } @@ -333,21 +350,21 @@ IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator); void Request_chord_iterator::construct_children() { - get_req_translator_l(); + get_req_translator_l(); } Request_chord_iterator::Request_chord_iterator (Request_chord*el_l) { - elt_l_ = el_l; - elt_duration_ = el_l->time_int().length (); - last_b_ = false; + elt_l_ = el_l; + elt_duration_ = el_l->time_int().length (); + last_b_ = false; } bool Request_chord_iterator::ok()const { - return (elt_duration_ && !last_b_) || first_b_; + return (elt_duration_ && !last_b_) || first_b_; } @@ -355,34 +372,36 @@ Request_chord_iterator::ok()const Moment Request_chord_iterator::next_moment()const { - Moment m (0); - if (!first_b_) + Moment m (0); + if (!first_b_) m = elt_duration_; - return m; + return m; } void Request_chord_iterator::do_print() const { #ifndef NPRINT - DOUT << "duration: " << elt_duration_; + DOUT << "duration: " << elt_duration_; #endif } void Request_chord_iterator::process_and_next (Moment mom) { - if ( first_b_) { - for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) { + if ( first_b_) + { + for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) + { assert (i->is_type_b (Request::static_name())); Request * req_l = (Request*)i.ptr(); bool gotcha = report_to_l()->try_request (req_l); if (!gotcha) req_l->warning ("Junking request: " + String (req_l->name())); - } + } first_b_ = false; } - if ( mom >= elt_duration_) + if ( mom >= elt_duration_) last_b_ = true; } diff --git a/lily/music-list.cc b/lily/music-list.cc index 8fd903f0d3..ad10bce46e 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -13,10 +13,10 @@ #include "music-list.hh" Music_list::Music_list (Music_list const&s) - : Music (s) + : Music (s) { - multi_level_i_ = s.multi_level_i_; - for (iter (s.music_p_list_.top(), i); i.ok (); i++) + multi_level_i_ = s.multi_level_i_; + for (iter (s.music_p_list_.top(), i); i.ok (); i++) add (i->clone()); } @@ -27,17 +27,17 @@ IMPLEMENT_IS_TYPE_B1(Chord,Music_list); MInterval Chord::time_int()const { - MInterval m; - for (iter (music_p_list_.top(), i); i.ok (); i++) + MInterval m; + for (iter (music_p_list_.top(), i); i.ok (); i++) m.unite (i->time_int()); - return m; + return m; } void Chord::translate (Moment m) { - for (iter (music_p_list_.top(), i); i.ok (); i++) + for (iter (music_p_list_.top(), i); i.ok (); i++) i->translate (m); } @@ -48,51 +48,52 @@ Chord::Chord() Voice::Voice() { - offset_mom_ =0; + offset_mom_ =0; } MInterval Voice::time_int() const { - Moment last=0; - for (iter (music_p_list_.top(), i); i.ok (); i++) { + Moment last=0; + for (iter (music_p_list_.top(), i); i.ok (); i++) + { MInterval interval = i->time_int(); - /* + /* c4 <> c4 - */ + */ if ( !interval.empty_b()) last += interval.length(); } - return offset_mom_ + MInterval (0,last); + return offset_mom_ + MInterval (0,last); } void Voice::translate (Moment dt) { - offset_mom_ += dt; + offset_mom_ += dt; } Music_list::Music_list() { - multi_level_i_ = 0; + multi_level_i_ = 0; } void Music_list::add (Music*m_p) { - if (!m_p) + if (!m_p) return; - m_p->parent_music_l_ = this; - music_p_list_.bottom().add (m_p); + m_p->parent_music_l_ = this; + music_p_list_.bottom().add (m_p); } void Music_list::transpose (Melodic_req const*rq) { - for (iter (music_p_list_.top(),i); i.ok (); i++) + for (iter (music_p_list_.top(),i); i.ok (); i++) i->transpose (rq); } @@ -100,7 +101,7 @@ void Music_list::do_print()const { #ifndef NPRINT - for (iter (music_p_list_.top(),i); i.ok (); i++) + for (iter (music_p_list_.top(),i); i.ok (); i++) i->print(); #endif } @@ -110,5 +111,5 @@ IMPLEMENT_IS_TYPE_B1(Request_chord, Chord); Request_chord::Request_chord() { - multi_level_i_ =0; + multi_level_i_ =0; } diff --git a/lily/music.cc b/lily/music.cc index b9dcde679d..6cd34fc2a0 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -14,27 +14,27 @@ MInterval Music::time_int() const { - return MInterval (0,0); + return MInterval (0,0); } void Music::print()const { #ifndef NPRINT - if ( ! check_debug) + if ( ! check_debug) return ; - DOUT << name() << "{"; - if (type_str_!="" || id_str_!="") + DOUT << name() << "{"; + if (type_str_!="" || id_str_!="") DOUT << "`" <= 7) { + int old_pitch = pitch(); + int delta_pitch = delta.pitch(); + octave_i_ += delta.octave_i_; + notename_i_ += delta.notename_i_; + while (notename_i_ >= 7) + { notename_i_ -= 7; octave_i_ ++; } - int new_pitch = pitch(); - int delta_acc = new_pitch - old_pitch - delta_pitch; - - accidental_i_ -= delta_acc; - if (abs (accidental_i_) > 2) { + int new_pitch = pitch(); + int delta_acc = new_pitch - old_pitch - delta_pitch; + + accidental_i_ -= delta_acc; + if (abs (accidental_i_) > 2) + { delta.warning ("transposition makes accidental larger than 2"); } } @@ -114,31 +116,31 @@ IMPLEMENT_IS_TYPE_B1(Melodic_req,Musical_req); bool Melodic_req::do_equal_b (Request*r)const { - Melodic_req* m= r->musical()->melodic (); - return !compare (*m, *this); + Melodic_req* m= r->musical()->melodic (); + return !compare (*m, *this); } int Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2) { - int o= m1.octave_i_ - m2.octave_i_; - int n = m1.notename_i_ - m2.notename_i_; - int a = m1.accidental_i_ - m2.accidental_i_; - - if (o) + int o= m1.octave_i_ - m2.octave_i_; + int n = m1.notename_i_ - m2.notename_i_; + int a = m1.accidental_i_ - m2.accidental_i_; + + if (o) return o; - if ( n) + if ( n) return n; - if (a) + if (a) return a; - return 0; + return 0; } void Melodic_req::do_print() const { #ifndef NPRINT - DOUT << "notename: " << notename_i_ + DOUT << "notename: " << notename_i_ << " acc: " <musical()->rhythmic (); + Rhythmic_req* rh = r->musical()->rhythmic (); - return !compare (*this, *rh); + return !compare (*this, *rh); } void Rhythmic_req::set_duration (Duration d) { - duration_ = d; + duration_ = d; } Rhythmic_req::Rhythmic_req() @@ -192,22 +194,22 @@ void Rhythmic_req::do_print() const { #ifndef NPRINT - DOUT << "duration { " <align_i_ = 0; // centre - dir_i_ = -1; // lyrics below (invisible) staff + def_p->align_i_ = 0; // centre + dir_i_ = -1; // lyrics below (invisible) staff } @@ -216,21 +218,21 @@ IMPLEMENT_IS_TYPE_B2(Lyric_req,Musical_req,Rhythmic_req); void Lyric_req::do_print() const { - Rhythmic_req::do_print(); - Text_req::do_print(); + Rhythmic_req::do_print(); + Text_req::do_print(); } /* *************** */ bool Note_req::do_equal_b (Request*r)const { - return Rhythmic_req::do_equal_b (r) && Melodic_req::do_equal_b (r); + return Rhythmic_req::do_equal_b (r) && Melodic_req::do_equal_b (r); } Note_req::Note_req() { - forceacc_b_ = false; + forceacc_b_ = false; } IMPLEMENT_IS_TYPE_B2(Note_req,Melodic_req,Rhythmic_req); @@ -239,11 +241,12 @@ void Note_req::do_print() const { #ifndef NPRINT - Melodic_req::do_print(); - if (forceacc_b_) { + Melodic_req::do_print(); + if (forceacc_b_) + { DOUT << " force accidental\n"; } - Rhythmic_req::do_print(); + Rhythmic_req::do_print(); #endif } /* *************** */ @@ -253,13 +256,13 @@ IMPLEMENT_IS_TYPE_B1(Rest_req,Rhythmic_req); void Rest_req::do_print() const { - Rhythmic_req::do_print(); + Rhythmic_req::do_print(); } /* *************** */ Beam_req::Beam_req() { - nplet = 0; + nplet = 0; } IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req); @@ -276,20 +279,20 @@ Slur_req::do_print()const{} bool Span_req:: do_equal_b (Request*r)const { - Span_req * s = r->span(); - return spantype - s->spantype; + Span_req * s = r->span(); + return spantype - s->spantype; } Span_req::Span_req() { - spantype = NOSPAN; + spantype = NOSPAN; } /* *************** */ Script_req::Script_req (Script_req const&s) { - dir_i_ = s.dir_i_; - scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone() : 0; + dir_i_ = s.dir_i_; + scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone() : 0; } /* @@ -300,15 +303,15 @@ Script_req::Script_req (Script_req const&s) bool Script_req::do_equal_b (Request*r)const { - Script_req * s = r->script(); - - return scriptdef_p_->equal_b (*s->scriptdef_p_); + Script_req * s = r->script(); + + return scriptdef_p_->equal_b (*s->scriptdef_p_); } Script_req::Script_req() { - dir_i_ = 0; - scriptdef_p_ = 0; + dir_i_ = 0; + scriptdef_p_ = 0; } @@ -318,15 +321,15 @@ void Script_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; - scriptdef_p_->print(); + DOUT << " dir " << dir_i_ ; + scriptdef_p_->print(); #endif } void Musical_script_req::do_print() const { - Script_req::do_print(); + Script_req::do_print(); } @@ -335,27 +338,27 @@ IMPLEMENT_IS_TYPE_B2(Musical_script_req,Musical_req, Script_req); Script_req::~Script_req() { - delete scriptdef_p_; + delete scriptdef_p_; } /* *************** */ Text_req::~Text_req() { - delete tdef_p_; - tdef_p_ = 0; + delete tdef_p_; + tdef_p_ = 0; } Text_req::Text_req (Text_req const& src) { - tdef_p_ = new Text_def (*src.tdef_p_); - dir_i_ = src.dir_i_; + tdef_p_ = new Text_def (*src.tdef_p_); + dir_i_ = src.dir_i_; } Text_req::Text_req (int dir_i, Text_def* tdef_p) { - dir_i_ = dir_i; - tdef_p_ = tdef_p; + dir_i_ = dir_i; + tdef_p_ = tdef_p; } @@ -365,8 +368,8 @@ void Text_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; - tdef_p_->print(); + DOUT << " dir " << dir_i_ ; + tdef_p_->print(); #endif } @@ -380,7 +383,7 @@ Skip_req::do_print() const { #ifndef NPRINT - DOUT << "duration: " << duration(); + DOUT << "duration: " << duration(); #endif } @@ -391,7 +394,7 @@ IMPLEMENT_IS_TYPE_B1(Dynamic_req,Musical_req); void Dynamic_req::do_print() const { - Musical_req::do_print(); + Musical_req::do_print(); } @@ -401,37 +404,38 @@ void Absolute_dynamic_req::do_print() const { #ifndef NPRINT - Dynamic_req::do_print(); - DOUT << " loudness " <name(); - return (nC == Script::static_name() || nC == Note_head::static_name () + char const*nC = elem_C->name(); + return (nC == Script::static_name() || nC == Note_head::static_name () || nC == Stem::static_name()); } Note_column* Note_column_engraver::note_col_l() { - if (!ncol_p_){ + if (!ncol_p_) + { ncol_p_ = new Note_column; announce_element (Score_elem_info (ncol_p_, 0)); } - return ncol_p_; + return ncol_p_; } Rest_column * Note_column_engraver::rest_col_l() { - if (!restcol_p_) { + if (!restcol_p_) + { restcol_p_ = new Rest_column; announce_element (Score_elem_info (restcol_p_,0)); } - return restcol_p_; + return restcol_p_; } void Note_column_engraver::acknowledge_element (Score_elem_info i) { - if (!acceptable_elem_b (i.elem_l_)) + if (!acceptable_elem_b (i.elem_l_)) return; - char const*nC = i.elem_l_->name(); + char const*nC = i.elem_l_->name(); - if (nC == Script::static_name() && i.req_l_ && i.req_l_->musical ()) { + if (nC == Script::static_name() && i.req_l_ && i.req_l_->musical ()) + { script_l_arr_.push ((Script*)i.elem_l_->item()); - } else if (nC == Note_head::static_name()) { + } + else if (nC == Note_head::static_name()) + { Note_head * h_l = (Note_head*)i.elem_l_->item(); if (h_l->rest_b_) rest_col_l()->add (h_l); else note_col_l()->add (h_l); - } else if (nC == Stem::static_name()){ + } + else if (nC == Stem::static_name()) + { stem_l_ = (Stem*)i.elem_l_->item(); } - if ( ncol_p_ || restcol_p_) { - if ( stem_l_) { + if ( ncol_p_ || restcol_p_) + { + if ( stem_l_) + { if (restcol_p_&& !restcol_p_->stem_l_) restcol_p_->set (stem_l_); if (ncol_p_ && !ncol_p_->stem_l_) ncol_p_->set (stem_l_); - } - - - for (int i=0; i < script_l_arr_.size(); i++) { + } + + + for (int i=0; i < script_l_arr_.size(); i++) + { if (restcol_p_) restcol_p_->add (script_l_arr_[i]); if ( ncol_p_) ncol_p_->add (script_l_arr_[i]); - } - + } + script_l_arr_.clear(); } @@ -86,7 +96,8 @@ Note_column_engraver::acknowledge_element (Score_elem_info i) void Note_column_engraver::do_pre_move_processing() { - if (ncol_p_) { + if (ncol_p_) + { if (! ncol_p_->h_shift_b_) ncol_p_->h_shift_b_ = h_shift_b_; if (! ncol_p_->dir_i_) @@ -95,7 +106,8 @@ Note_column_engraver::do_pre_move_processing() typeset_element (ncol_p_); ncol_p_ =0; } - if (restcol_p_) { + if (restcol_p_) + { if (! restcol_p_->dir_i_) restcol_p_->dir_i_ = dir_i_; @@ -107,27 +119,27 @@ Note_column_engraver::do_pre_move_processing() void Note_column_engraver::do_post_move_processing() { - script_l_arr_.clear(); - stem_l_ =0; + script_l_arr_.clear(); + stem_l_ =0; } void Note_column_engraver::set_feature (Feature i) { - if (i.type_ == "vdir") + if (i.type_ == "vdir") dir_i_ = i.value_; - if (i.type_ == "hshift") + if (i.type_ == "hshift") h_shift_b_ = (bool)(int)i.value_; } Note_column_engraver::Note_column_engraver() { - dir_i_ =0; - h_shift_b_ = false; - - ncol_p_=0; - restcol_p_ =0; - do_post_move_processing(); + dir_i_ =0; + h_shift_b_ = false; + + ncol_p_=0; + restcol_p_ =0; + do_post_move_processing(); } diff --git a/lily/note-column.cc b/lily/note-column.cc index 343414c035..19cf429928 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -17,26 +17,26 @@ IMPLEMENT_IS_TYPE_B1(Note_column,Head_column); void Note_column::set (Stem*s) { - stem_l_ = s; - add_support (s); + stem_l_ = s; + add_support (s); } Note_column::Note_column() { - h_shift_b_ =false; + h_shift_b_ =false; } void Note_column::sort() { - head_l_arr_.sort (Note_head::compare); + head_l_arr_.sort (Note_head::compare); } - + Interval_t Note_column::head_positions_interval()const { - ((Note_column*)this)->sort(); - return Interval_t ( head_l_arr_[0]->position_i_, + ((Note_column*)this)->sort(); + return Interval_t ( head_l_arr_[0]->position_i_, head_l_arr_.top()->position_i_); } @@ -45,10 +45,11 @@ Note_column::head_positions_interval()const void Note_column::do_pre_processing() { - if (!dir_i_&& !stem_l_){ + if (!dir_i_&& !stem_l_) + { dir_i_ = (head_positions_interval().center () >= 5) ? -1 : 1; } - Head_column::do_pre_processing(); + Head_column::do_pre_processing(); } - + diff --git a/lily/note-performer.cc b/lily/note-performer.cc index e9e5dd5ca7..dd2ac9da14 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -19,15 +19,16 @@ ADD_THIS_PERFORMER(Note_performer); Note_performer::Note_performer() { - note_req_l_ = 0; + note_req_l_ = 0; } void Note_performer::do_print() const { #ifndef NPRINT - if ( note_req_l_) { - note_req_l_->print(); + if ( note_req_l_) + { + note_req_l_->print(); } #endif } @@ -35,23 +36,23 @@ Note_performer::do_print() const void Note_performer::process_requests() { - // this is _really_ braindead, but it generates some output - if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) + // this is _really_ braindead, but it generates some output + if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) return; - play (new Audio_note (note_req_l_) ); - note_req_l_ = 0; + play (new Audio_note (note_req_l_) ); + note_req_l_ = 0; } bool Note_performer::do_try_request (Request* req_l) { - if ( note_req_l_) + if ( note_req_l_) return false; - - if ( !req_l->musical() || !req_l->musical ()->note ()) + + if ( !req_l->musical() || !req_l->musical ()->note ()) return false; - note_req_l_ = req_l->musical()->melodic (); - return true; + note_req_l_ = req_l->musical()->melodic (); + return true; } diff --git a/lily/note.cc b/lily/note.cc index 2b1a8c447b..ec84dbba52 100644 --- a/lily/note.cc +++ b/lily/note.cc @@ -20,37 +20,38 @@ String * get_scriptdef (char c) { - String s; - switch (c) { - case '^' : s = "marcato"; + String s; + switch (c) + { + case '^' : s = "marcato"; break; - case '+' : s = "stopped"; + case '+' : s = "stopped"; break; - case '-' : s = "tenuto"; + case '-' : s = "tenuto"; break; - case '|': s = "staccatissimo"; + case '|': s = "staccatissimo"; break; - case 'o' : s = ""; + case 'o' : s = ""; break; - case '>' : s = "accent"; + case '>' : s = "accent"; break; - case 'v' : s = ""; + case 'v' : s = ""; break; - case '.' : s = "staccato"; + case '.' : s = "staccato"; break; - default: + default: assert (false); } - return new String (s); + return new String (s); } Request* get_script_req (int d , General_script_def*def) { - Musical_script_req* script_req_p = new Musical_script_req; - script_req_p->dir_i_ =d; - script_req_p->scriptdef_p_=def; - return script_req_p; + Musical_script_req* script_req_p = new Musical_script_req; + script_req_p->dir_i_ =d; + script_req_p->scriptdef_p_=def; + return script_req_p; } @@ -58,28 +59,29 @@ get_script_req (int d , General_script_def*def) Request* get_stemdir_req (int d) { - d = sign (long (d)); - Group_feature_req * gfreq_p = new Group_feature_req; - gfreq_p->type_str_ = "vdir"; - gfreq_p->value_str_ = String (d); - return gfreq_p; + d = sign (long (d)); + Group_feature_req * gfreq_p = new Group_feature_req; + gfreq_p->type_str_ = "vdir"; + gfreq_p->value_str_ = String (d); + return gfreq_p; } Request* get_hshift_req (int i) { Group_feature_req * gfreq_p = new Group_feature_req; - gfreq_p->type_str_ = "hshift"; - gfreq_p->value_str_ = String (i); - return gfreq_p; + gfreq_p->type_str_ = "hshift"; + gfreq_p->value_str_ = String (i); + return gfreq_p; } - + Request* get_grouping_req (Array i_arr) { - Measure_grouping_req * mr_p = new Measure_grouping_req; - for (int i=0; i elt_length_arr_.push (Moment (1, i_arr[i++])); mr_p->beat_i_arr_.push (i_arr[i++]); } - return mr_p; + return mr_p; } diff --git a/lily/notename-table.cc b/lily/notename-table.cc index 325d91e5f8..049f0cdfcb 100644 --- a/lily/notename-table.cc +++ b/lily/notename-table.cc @@ -15,14 +15,14 @@ template class P; void Notename_table::add (String s, Melodic_req *m_p) { - elem (s).set_p (m_p); + elem (s).set_p (m_p); } Melodic_req* Notename_table::get_l (String s) { - if (! elt_b (s)) + if (! elt_b (s)) return 0; - return elem (s); + return elem (s); } - + diff --git a/lily/p-score.cc b/lily/p-score.cc index 73ab917422..dbf5d84525 100644 --- a/lily/p-score.cc +++ b/lily/p-score.cc @@ -21,97 +21,103 @@ Paper_score::Paper_score (Paper_def*p) { - paper_l_ = p; - super_elem_l_ = new Super_elem; - typeset_element (super_elem_l_); + paper_l_ = p; + super_elem_l_ = new Super_elem; + typeset_element (super_elem_l_); } Paper_score::~Paper_score() { - super_elem_l_->unlink_all(); + super_elem_l_->unlink_all(); } void Paper_score::typeset_element (Score_elem * elem_p) { - elem_p_list_.bottom().add (elem_p); - elem_p->pscore_l_ = this; + elem_p_list_.bottom().add (elem_p); + elem_p->pscore_l_ = this; - elem_p->add_processing(); + elem_p->add_processing(); } void Paper_score::typeset_item (Item *i, PCol *c) { - assert (c && i); - int breakstat = i->break_status_i_; + assert (c && i); + int breakstat = i->break_status_i_; - if (breakstat == -1) { + if (breakstat == -1) + { c = c->prebreak_p_; - }else if (breakstat == 1) { + }else if (breakstat == 1) + { c = c->postbreak_p_; } - c->add (i); - typeset_element (i); + c->add (i); + typeset_element (i); } void Paper_score::typeset_broken_spanner (Spanner*span_p) { - span_p->left_col_l_->starters.bottom().add (span_p); - assert (span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_); + span_p->left_col_l_->starters.bottom().add (span_p); + assert (span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_); - typeset_element (span_p); + typeset_element (span_p); } void Paper_score::typeset_unbroken_spanner (Spanner*span_p) { - span_p_list_.bottom().add (span_p); - span_p->pscore_l_=this; + span_p_list_.bottom().add (span_p); + span_p->pscore_l_=this; - if (span_p->left_col_l_) + if (span_p->left_col_l_) span_p->left_col_l_->used_b_ = true; - if ( span_p->right_col_l_) + if ( span_p->right_col_l_) span_p->right_col_l_->used_b_ = true; - - // do not init start/stop fields. These are for broken spans only. - span_p->add_processing(); + + // do not init start/stop fields. These are for broken spans only. + span_p->add_processing(); } void Paper_score::clean_cols() { - int rank_i = 0; - for (iter_top (col_p_list_,c); c.ok();) - if (!c->used_b()) { + int rank_i = 0; + for (iter_top (col_p_list_,c); c.ok();) + if (!c->used_b()) + { delete c.remove_p(); - } else { + } + else + { c->set_rank (rank_i++); c++; - } + } } void Paper_score::add (PCol *p) { - p->pscore_l_ = this; - if (p->breakable_b()){ + p->pscore_l_ = this; + if (p->breakable_b()) + { p->prebreak_p_->pscore_l_ = this; p->postbreak_p_->pscore_l_ = this; } - col_p_list_.bottom().add (p); + col_p_list_.bottom().add (p); } void Paper_score::output (Tex_stream &ts) { - ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n"; - ts<< super_elem_l_->TeX_string(); - ts << "\n\\EndLilyPondOutput"; + ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n"; + ts<< super_elem_l_->TeX_string(); + ts << "\n\\EndLilyPondOutput"; } @@ -119,9 +125,9 @@ void Paper_score::OK()const { #ifndef NDEBUG - for (iter_top (col_p_list_,cc); cc.ok(); cc++) + for (iter_top (col_p_list_,cc); cc.ok(); cc++) cc->OK(); - for (PCursor i (elem_p_list_.top()); i.ok (); i++) + for (PCursor i (elem_p_list_.top()); i.ok (); i++) i->OK(); #endif } @@ -130,118 +136,127 @@ void Paper_score::print() const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << "Paper_score { "; - paper_l_->print(); - DOUT << "\n elements: "; - for (iter_top (elem_p_list_,cc); cc.ok(); cc++) + DOUT << "Paper_score { "; + paper_l_->print(); + DOUT << "\n elements: "; + for (iter_top (elem_p_list_,cc); cc.ok(); cc++) cc->print(); - DOUT << "\n unbroken spanners: "; - for (iter (span_p_list_.top(), i); i.ok (); i++) + DOUT << "\n unbroken spanners: "; + for (iter (span_p_list_.top(), i); i.ok (); i++) i->print(); - DOUT << "\ncolumns: "; - for (iter_top (col_p_list_,cc); cc.ok(); cc++) + DOUT << "\ncolumns: "; + for (iter_top (col_p_list_,cc); cc.ok(); cc++) cc->print(); - - DOUT << "}\n"; + + DOUT << "}\n"; #endif } void Paper_score::preprocess() { - super_elem_l_->breakable_col_processing(); - super_elem_l_->pre_processing(); + super_elem_l_->breakable_col_processing(); + super_elem_l_->pre_processing(); } void Paper_score::postprocess() { - super_elem_l_->post_processing(); - super_elem_l_->molecule_processing(); + super_elem_l_->post_processing(); + super_elem_l_->molecule_processing(); } PCursor Paper_score::find_col (PCol const *c)const { - PCol const *what = c; - if (what->daddy_l_) + PCol const *what = c; + if (what->daddy_l_) what = what->daddy_l_; - - return col_p_list_.find ((PCol*)what); + + return col_p_list_.find ((PCol*)what); } void Paper_score::set_breaking (Array const &breaking) { - super_elem_l_->line_of_score_l_->set_breaking (breaking); - super_elem_l_->break_processing(); + super_elem_l_->line_of_score_l_->set_breaking (breaking); + super_elem_l_->break_processing(); - for (iter (span_p_list_.top(),i); i.ok ();) { + for (iter (span_p_list_.top(),i); i.ok ();) + { Spanner *span_p = i.remove_p(); - if (span_p->broken_b()) { + if (span_p->broken_b()) + { span_p->unlink(); delete span_p; - }else{ + }else + { typeset_broken_spanner (span_p); - } + } } - for (iter (elem_p_list_.top(),i); i.ok () ;) { + for (iter (elem_p_list_.top(),i); i.ok () ;) + { Item *i_l =i->item(); - if ( i_l && !i_l->pcol_l_->line_l_) { + if ( i_l && !i_l->pcol_l_->line_l_) + { i_l->unlink(); delete i.remove_p(); - } else + } + else i++; } - for (iter_top (col_p_list_, i); i.ok(); i++) + for (iter_top (col_p_list_, i); i.ok(); i++) i->clean_breakable_items(); } void Paper_score::calc_breaking() { - Break_algorithm *algorithm_p; - Array sol; - bool try_wrap = ! paper_l_->get_var ("castingalgorithm"); + Break_algorithm *algorithm_p; + Array sol; + bool try_wrap = ! paper_l_->get_var ("castingalgorithm"); - if (!try_wrap) { + if (!try_wrap) + { algorithm_p = new Gourlay_breaking ; algorithm_p->set_pscore (this); sol = algorithm_p->solve(); delete algorithm_p; - if ( ! sol.size()) { + if ( ! sol.size()) + { warning ("Can not solve this casting problem exactly; revert to Word_wrap"); try_wrap = true; - } + } } - if (try_wrap) { + if (try_wrap) + { algorithm_p = new Word_wrap; algorithm_p->set_pscore (this); sol = algorithm_p->solve(); delete algorithm_p; } - set_breaking (sol); + set_breaking (sol); } void Paper_score::process() { - clean_cols(); - print(); - *mlog << "Preprocessing elements... " < i (elem_p_list_.top()); i.ok (); i++) + for (PCursor i (elem_p_list_.top()); i.ok (); i++) assert (i->status() >= 9); #endif } @@ -250,56 +265,58 @@ Paper_score::process() Link_array Paper_score::breakable_col_range (PCol*l,PCol*r)const { - Link_array ret; + Link_array ret; - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) { + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) + { if (start->breakable_b()) ret.push (start); start++; } - return ret; + return ret; } Link_array Paper_score::col_range (PCol*l,PCol*r)const { - Link_array ret; - - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - ret.push (l); - - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) + Link_array ret; + + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + ret.push (l); + + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) ret.push (start++); - ret.push (r); - return ret; + ret.push (r); + return ret; } Link_array Paper_score::broken_col_range (PCol*l,PCol*r)const { - Link_array ret; + Link_array ret; - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) { + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) + { if (start->breakable_b() && !start->line_l_) ret.push (start); start++; } - return ret; + return ret; } diff --git a/lily/performer-group-performer.cc b/lily/performer-group-performer.cc index 2669123133..ea11129e25 100644 --- a/lily/performer-group-performer.cc +++ b/lily/performer-group-performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996, 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "performer-group-performer.hh" @@ -22,12 +22,15 @@ Performer_group_performer::~Performer_group_performer() void Performer_group_performer::add (Performer *perf_p) { - perf_p_list_.bottom().add (perf_p); - perf_p->daddy_perf_l_ = this; + perf_p_list_.bottom().add (perf_p); + perf_p->daddy_perf_l_ = this; - if (perf_p->is_type_b (Performer_group_performer::static_name())) { + if (perf_p->is_type_b (Performer_group_performer::static_name())) + { group_l_arr_.push ((Performer_group_performer*)perf_p); - } else { + } + else + { nongroup_l_arr_ .push (perf_p); } } @@ -35,22 +38,22 @@ Performer_group_performer::add (Performer *perf_p) Translator* Performer_group_performer::ancestor_l (int l) { - if (!l || !daddy_perf_l_) + if (!l || !daddy_perf_l_) return this; - - return daddy_perf_l_->ancestor_l (l - 1); + + return daddy_perf_l_->ancestor_l (l - 1); } int Performer_group_performer::depth_i() const { - return daddy_perf_l_->depth_i() + 1; + return daddy_perf_l_->depth_i() + 1; } void Performer_group_performer::do_creation_processing() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) i->creation_processing(); } @@ -58,9 +61,9 @@ void Performer_group_performer::do_print()const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) i->print(); #endif } @@ -68,29 +71,31 @@ Performer_group_performer::do_print()const void Performer_group_performer::do_removal_processing() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) i->do_removal_processing(); } bool Performer_group_performer::do_try_request (Request* req_l) { - bool hebbes_b =false; - for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) + bool hebbes_b =false; + for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) hebbes_b =nongroup_l_arr_[i]->try_request (req_l); - if ( !hebbes_b && daddy_perf_l_) + if ( !hebbes_b && daddy_perf_l_) hebbes_b = daddy_perf_l_->try_request (req_l); - return hebbes_b ; + return hebbes_b ; } Translator* Performer_group_performer::find_get_translator_l (String n,String id) { - Translator * ret=0; - Input_translator* itrans_l= itrans_l_-> recursive_find ( n); - if (itrans_l) { + Translator * ret=0; + Input_translator* itrans_l= itrans_l_-> recursive_find ( n); + if (itrans_l) + { ret = find_performer_l (n,id); - if (!ret) { + if (!ret) + { Performer_group_performer * group = itrans_l-> get_group_performer_p(); @@ -102,66 +107,69 @@ Performer_group_performer::find_get_translator_l (String n,String id) else return ret->find_get_translator_l (n,id); - } - } else if (daddy_perf_l_) + } + } + else if (daddy_perf_l_) ret =daddy_perf_l_->find_get_translator_l (n,id); - else { + else + { warning ("Can't find or create `" + n + "' called `" + id + "'\n"); ret =0; } - return ret; + return ret; } Performer_group_performer* Performer_group_performer::find_performer_l (String n, String id) { - if (name() == n && id_str_ == id) + if (name() == n && id_str_ == id) return this; - Performer_group_performer * r = 0; - for (int i =0; !r && i< group_l_arr_.size(); i++) { + Performer_group_performer * r = 0; + for (int i =0; !r && i< group_l_arr_.size(); i++) + { r = group_l_arr_[i]->find_performer_l (n,id); } - - return r; + + return r; } Translator* Performer_group_performer::get_default_interpreter() { - // ? - if ( is_bottom_performer_b()) + // ? + if ( is_bottom_performer_b()) return daddy_perf_l_->get_default_interpreter(); - Performer_group_performer *perf_p= itrans_l_-> + Performer_group_performer *perf_p= itrans_l_-> get_default_itrans_l()->get_group_performer_p (); - add (perf_p); - if (perf_p->is_bottom_performer_b()) + add (perf_p); + if (perf_p->is_bottom_performer_b()) return perf_p; - else + else return perf_p->get_default_interpreter(); } bool Performer_group_performer::is_bottom_performer_b() const { - return !itrans_l_->get_default_itrans_l(); + return !itrans_l_->get_default_itrans_l(); } void Performer_group_performer::print() const { - Performer::print(); + Performer::print(); } void Performer_group_performer::process_requests() { - for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) + for ( PCursor i (perf_p_list_.top()); i.ok (); i++ ) i->process_requests(); } bool Performer_group_performer::try_request (Request* r) { - return Performer::try_request (r); + return Performer::try_request (r); } diff --git a/lily/performer.cc b/lily/performer.cc index 5e6fc2d953..ad2f9805ed 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996, 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ @@ -16,8 +16,8 @@ IMPLEMENT_IS_TYPE_B(Performer); Performer::Performer() { - daddy_perf_l_ = 0; - init_b_ =false; + daddy_perf_l_ = 0; + init_b_ =false; } Performer::~Performer() @@ -32,22 +32,22 @@ Performer::do_print() const void Performer::play (Audio_element* p) { - daddy_perf_l_->play (p); + daddy_perf_l_->play (p); } int Performer::get_tempo_i()const { - return daddy_perf_l_->get_tempo_i(); + return daddy_perf_l_->get_tempo_i(); } void Performer::print() const { #ifndef NPRINT - DOUT << "\n" << name() << " {"; - do_print(); - DOUT << "}"; + DOUT << "\n" << name() << " {"; + do_print(); + DOUT << "}"; #endif } @@ -59,22 +59,24 @@ Performer::process_requests() bool Performer::do_try_request (Request* req_l) { - return false; + return false; } bool Performer::try_request (Request*r) { - if (!init_b_) { + if (!init_b_) + { creation_processing(); } - return do_try_request (r); + return do_try_request (r); } void Performer::creation_processing() { - if (!init_b_) { + if (!init_b_) + { do_creation_processing(); init_b_ = true; } diff --git a/lily/qlp.cc b/lily/qlp.cc index 6625b68bab..b7f9eee739 100644 --- a/lily/qlp.cc +++ b/lily/qlp.cc @@ -12,67 +12,71 @@ void Mixed_qp::add_equality_cons (Vector , double) { - assert (false); + assert (false); } void Mixed_qp::add_fixed_var (int i, Real r) { - eq_cons.push (i); - eq_consrhs.push (r); + eq_cons.push (i); + eq_consrhs.push (r); } /** - eliminate appropriate variables, until we have a Ineq_constrained_qp - then solve that. + eliminate appropriate variables, until we have a Ineq_constrained_qp + then solve that. - PRE - cons should be ascending - */ + PRE + cons should be ascending + */ Vector Mixed_qp::solve (Vector start) const { - if (!dim()) + if (!dim()) return Vector (0); - - print(); - Ineq_constrained_qp pure (*this); - - for (int i= eq_cons.size()-1; i>=0; i--) { + + print(); + Ineq_constrained_qp pure (*this); + + for (int i= eq_cons.size()-1; i>=0; i--) + { pure.eliminate_var (eq_cons[i], eq_consrhs[i]); start.del (eq_cons[i]); } - Vector sol = pure.solve (start); - for (int i= 0; i < eq_cons.size(); i++) { + Vector sol = pure.solve (start); + for (int i= 0; i < eq_cons.size(); i++) + { sol.insert (eq_consrhs[i],eq_cons[i]); } - return sol; + return sol; } void Ineq_constrained_qp::assert_solution (Vector sol) const { - Array binding; - for (int i=0; i < cons.size(); i++) { + Array binding; + for (int i=0; i < cons.size(); i++) + { Real R=cons[i] * sol- consrhs[i]; assert (R> -EPS); if (R < EPS) binding.push (i); } - // KKT check... - // todo + // KKT check... + // todo } void Ineq_constrained_qp::print() const { #ifndef NPRINT - DOUT << "Quad " << quad; - DOUT << "lin " << lin <<"\n" + DOUT << "Quad " << quad; + DOUT << "lin " << lin <<"\n" << "const " << const_term<<"\n"; - for (int i=0; i < cons.size(); i++) { + for (int i=0; i < cons.size(); i++) + { DOUT << "constraint["<= " << consrhs[i]; DOUT << "\n"; } @@ -80,7 +84,7 @@ Ineq_constrained_qp::print() const } Mixed_qp::Mixed_qp (int n) - : Ineq_constrained_qp (n) + : Ineq_constrained_qp (n) { } @@ -88,8 +92,8 @@ void Mixed_qp::OK() const { #ifndef NDEBUG - Ineq_constrained_qp::OK(); - assert (eq_consrhs.size() == eq_cons.size ()); + Ineq_constrained_qp::OK(); + assert (eq_consrhs.size() == eq_cons.size ()); #endif } @@ -97,8 +101,9 @@ void Mixed_qp::print() const { #ifndef NPRINT - Ineq_constrained_qp::print(); - for (int i=0; i < eq_cons.size(); i++) { + Ineq_constrained_qp::print(); + for (int i=0; i < eq_cons.size(); i++) + { DOUT << "eq cons "<cons.size ()); - assert (H.dim() == opt->dim ()); - assert (active.size() == A.rows ()); - Array allcons; - - for (int i=0; i < opt->cons.size(); i++) + H.OK(); + A.OK(); + assert (active.size() +inactive.size () == opt->cons.size ()); + assert (H.dim() == opt->dim ()); + assert (active.size() == A.rows ()); + Array allcons; + + for (int i=0; i < opt->cons.size(); i++) allcons.push (0); - for (int i=0; i < active.size(); i++) { + for (int i=0; i < active.size(); i++) + { int j = active[i]; allcons[j]++; } - for (int i=0; i < inactive.size(); i++) { + for (int i=0; i < inactive.size(); i++) + { int j = inactive[i]; allcons[j]++; } - for (int i=0; i < allcons.size(); i++) + for (int i=0; i < allcons.size(); i++) assert (allcons[i] == 1); #endif } @@ -62,25 +66,26 @@ Active_constraints::OK() Vector Active_constraints::get_lagrange (Vector gradient) { - return (A*gradient); + return (A*gradient); } void Active_constraints::add (int k) { - // add indices - int cidx=inactive[k]; - active.push (cidx); - - inactive.swap (k,inactive.size()-1); - inactive.pop(); - - Vector a (opt->cons[cidx]); - // update of matrices - Vector Ha = H*a; - Real aHa = a*Ha; - Vector addrow (Ha.dim()); - if (abs (aHa) > EPS) { + // add indices + int cidx=inactive[k]; + active.push (cidx); + + inactive.swap (k,inactive.size()-1); + inactive.pop(); + + Vector a (opt->cons[cidx]); + // update of matrices + Vector Ha = H*a; + Real aHa = a*Ha; + Vector addrow (Ha.dim()); + if (abs (aHa) > EPS) + { /* a != 0, so if Ha = O(EPS), then Ha * aH / aHa = O(EPS^2/EPS) @@ -88,72 +93,73 @@ Active_constraints::add (int k) if H*a == 0, the constraints are dependent. */ H -= Matrix (Ha/aHa , Ha); - + /* sorry, don't know how to justify this. .. */ addrow=Ha; - addrow/= aHa; + addrow/= aHa; A -= Matrix (A*a, addrow); A.insert_row (addrow,A.rows()); - }else + }else WARN << "degenerate constraints"; } void Active_constraints::drop (int k) { - int q=active.size()-1; + int q=active.size()-1; - // drop indices - inactive.push (active[k]); - active.swap (k,q); - A.swap_rows (k,q); - active.pop(); + // drop indices + inactive.push (active[k]); + active.swap (k,q); + A.swap_rows (k,q); + active.pop(); - Vector a (A.row (q)); - if (a.norm() > EPS) { + Vector a (A.row (q)); + if (a.norm() > EPS) + { /* */ - Real q = a*opt->quad*a; + Real q = a*opt->quad*a; Matrix aaq (a,a/q); H += aaq; A -= A*opt->quad*aaq; - }else + }else WARN << "degenerate constraints"; #ifndef NDEBUG - Vector rem_row (A.row (q)); - assert (rem_row.norm() < EPS); + Vector rem_row (A.row (q)); + assert (rem_row.norm() < EPS); #endif - - A.delete_row (q); + + A.delete_row (q); } Active_constraints::Active_constraints (Ineq_constrained_qp const *op) - : A(0,op->dim()), + : A(0,op->dim()), H(op->dim()), opt (op) { - for (int i=0; i < op->cons.size(); i++) + for (int i=0; i < op->cons.size(); i++) inactive.push (i); - Choleski_decomposition chol (op->quad); + Choleski_decomposition chol (op->quad); - /* - ugh. - */ - H=chol.inverse(); - OK(); + /* + ugh. + */ + H=chol.inverse(); + OK(); } /** Find the optimum which is in the planes generated by the active - constraints. - */ + constraints. + */ Vector Active_constraints::find_active_optimum (Vector g) { - return H*g; + return H*g; } diff --git a/lily/request.cc b/lily/request.cc index 0b177e39ac..1b431d2f2d 100644 --- a/lily/request.cc +++ b/lily/request.cc @@ -20,24 +20,24 @@ Request::do_print() const MInterval Request::time_int() const { - return MInterval (0, duration()); + return MInterval (0, duration()); } bool Request::equal_b (Request *r)const { - if ( is_type_b ( r->name()) ) + if ( is_type_b ( r->name()) ) return r->do_equal_b ((Request*)this); - if ( r->is_type_b (name())) + if ( r->is_type_b (name())) return do_equal_b (r); - return false; + return false; } bool Request::do_equal_b (Request*)const { - return false; + return false; } - + diff --git a/lily/rest-collision-grav.cc b/lily/rest-collision-grav.cc index 7f3dc02507..86a4030bdf 100644 --- a/lily/rest-collision-grav.cc +++ b/lily/rest-collision-grav.cc @@ -19,13 +19,14 @@ ADD_THIS_ENGRAVER(Rest_collision_engraver); Rest_collision_engraver::Rest_collision_engraver() { - rest_collision_p_ =0; + rest_collision_p_ =0; } void Rest_collision_engraver::make_collision() { - if (!rest_collision_p_) { + if (!rest_collision_p_) + { rest_collision_p_ = new Rest_collision; announce_element (Score_elem_info (rest_collision_p_, 0)); } @@ -33,12 +34,15 @@ Rest_collision_engraver::make_collision() void Rest_collision_engraver::acknowledge_element (Score_elem_info i) { - char const * nC = i.elem_l_->name(); - if (nC == Note_column::static_name()) { + char const * nC = i.elem_l_->name(); + if (nC == Note_column::static_name()) + { // what should i do, what should _engraver do? make_collision(); rest_collision_p_->add ((Note_column*)i.elem_l_->item()); - } else if (nC == Rest_column::static_name()) { + } + else if (nC == Rest_column::static_name()) + { make_collision(); rest_collision_p_->add ((Rest_column*)i.elem_l_->item()); } @@ -47,7 +51,8 @@ Rest_collision_engraver::acknowledge_element (Score_elem_info i) void Rest_collision_engraver::do_pre_move_processing() { - if (rest_collision_p_) { + if (rest_collision_p_) + { typeset_element (rest_collision_p_); rest_collision_p_ = 0; } @@ -57,7 +62,7 @@ void Rest_collision_engraver::do_print() const { #ifndef NPRINT - if ( rest_collision_p_) + if ( rest_collision_p_) rest_collision_p_->print(); #endif } diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 10fb35ec70..d5b4217f7e 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -21,82 +21,84 @@ IMPLEMENT_IS_TYPE_B1(Rest_collision,Item); void Rest_collision::add (Note_column *nc_l) { - add_dependency (nc_l); - ncol_l_arr_.push (nc_l); + add_dependency (nc_l); + ncol_l_arr_.push (nc_l); } void Rest_collision::add (Rest_column *rc_l) { - add_dependency (rc_l); - rest_l_arr_.push (rc_l); + add_dependency (rc_l); + rest_l_arr_.push (rc_l); } void Rest_collision::do_post_processing() { - /* - handle rest under beam (do_post: beams are calculated now) - - [todo] - i-d like to have access to the beam itself, - iso only the (half-initialised?) stem - - what about combination of collisions and rest under beam - */ - - // no rests to collide - if (!rest_l_arr_.size()) - return; - // can this happen? - Stem* stem_l = rest_l_arr_[0]->stem_l_; - if (!stem_l) - return; - // no beam - if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_)) - return; - - int dir_i = rest_l_arr_[0]->dir_i_; - int midpos = 4; + /* + handle rest under beam (do_post: beams are calculated now) + + [todo] + i-d like to have access to the beam itself, + iso only the (half-initialised?) stem + + what about combination of collisions and rest under beam + */ + + // no rests to collide + if (!rest_l_arr_.size()) + return; + // can this happen? + Stem* stem_l = rest_l_arr_[0]->stem_l_; + if (!stem_l) + return; + // no beam + if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_)) + return; + + int dir_i = rest_l_arr_[0]->dir_i_; + int midpos = 4; #if 1 - // ugh - int stem_length_i = 7 - 2; - // ugh, Stem::stem_start vs Stem::stem_end - int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i; + // ugh + int stem_length_i = 7 - 2; + // ugh, Stem::stem_start vs Stem::stem_end + int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i; #else // nogo: stem_start not set for rests? - int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2; + int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2; #endif - rest_l_arr_[0]->translate_heads (pos); + rest_l_arr_[0]->translate_heads (pos); } void Rest_collision::do_pre_processing() { - /* - handle rest-rest and rest-note collisions + /* + handle rest-rest and rest-note collisions - [todo] - decide not to print rest if too crowded? - */ + [todo] + decide not to print rest if too crowded? + */ - // no rests to collide - if (!rest_l_arr_.size()) - return; + // no rests to collide + if (!rest_l_arr_.size()) + return; - // no partners to collide with - if (rest_l_arr_.size() + ncol_l_arr_.size () < 2) + // no partners to collide with + if (rest_l_arr_.size() + ncol_l_arr_.size () < 2) return; - // meisjes met meisjes - if (!ncol_l_arr_.size()) { + // meisjes met meisjes + if (!ncol_l_arr_.size()) + { int dy = rest_l_arr_.size() > 2 ? 6 : 4; rest_l_arr_[0]->translate_heads (rest_l_arr_[0]->dir_i_ *dy); // top is last element... rest_l_arr_.top()->translate_heads (rest_l_arr_.top ()->dir_i_* dy); } - // meisjes met jongetjes - else { + // meisjes met jongetjes + else + { #if 0 // breendet: rests go always under // geen gemug, trug op je rug int dir_i = -1; @@ -107,7 +109,7 @@ Rest_collision::do_pre_processing() // hope it's 4: if it works->doco int midpos = 4; - // minimum move + // minimum move int minpos = 4; // quart rest height @@ -115,13 +117,14 @@ Rest_collision::do_pre_processing() int size_i = 6; int sep_i = 3 + size_i / 2; - for (int i = 0; i < ncol_l_arr_.size(); i++) { + for (int i = 0; i < ncol_l_arr_.size(); i++) + { // how to know whether to sort? ncol_l_arr_[i]->sort(); for ( int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++) minpos = minpos >? dir_i * (ncol_l_arr_[i]->head_l_arr_[j]->position_i_ -midpos) + sep_i; - } + } rest_l_arr_[0]->translate_heads (dir_i * minpos); #endif } @@ -131,23 +134,23 @@ void Rest_collision::do_print() const { #ifndef NPRINT - DOUT << "rests: " << rest_l_arr_.size() << ", "; - DOUT << "cols: " << ncol_l_arr_.size(); + DOUT << "rests: " << rest_l_arr_.size() << ", "; + DOUT << "cols: " << ncol_l_arr_.size(); #endif } void Rest_collision::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Item*o_l = o->item(); - Item*n_l = n?n->item():0; - - rest_l_arr_.substitute ((Rest_column*)o_l,(Rest_column*)n_l); - ncol_l_arr_.substitute ((Note_column*)o_l,(Note_column*)n_l); + Item*o_l = o->item(); + Item*n_l = n?n->item():0; + + rest_l_arr_.substitute ((Rest_column*)o_l,(Rest_column*)n_l); + ncol_l_arr_.substitute ((Note_column*)o_l,(Note_column*)n_l); } Rest_collision::Rest_collision() { - transparent_b_ = true; - empty_b_ = true; + transparent_b_ = true; + empty_b_ = true; } diff --git a/lily/rest-column.cc b/lily/rest-column.cc index 3b17ca9ac7..0c7260ee62 100644 --- a/lily/rest-column.cc +++ b/lily/rest-column.cc @@ -22,7 +22,7 @@ IMPLEMENT_IS_TYPE_B1(Rest_column,Head_column); void Rest_column::translate_heads (int dy_i) { - for (int i=0; i < head_l_arr_.size(); i++) + for (int i=0; i < head_l_arr_.size(); i++) head_l_arr_[i]->position_i_ += dy_i; } diff --git a/lily/score-align-grav.cc b/lily/score-align-grav.cc index c66cdebd48..d86903eb7b 100644 --- a/lily/score-align-grav.cc +++ b/lily/score-align-grav.cc @@ -13,15 +13,16 @@ Score_align_engraver::Score_align_engraver() { - type_ch_C_ = 0; - priority_i_ =0; - align_p_=0; + type_ch_C_ = 0; + priority_i_ =0; + align_p_=0; } void Score_align_engraver::do_pre_move_processing() { - if (align_p_) { + if (align_p_) + { typeset_element (align_p_); align_p_ =0; } @@ -30,19 +31,21 @@ Score_align_engraver::do_pre_move_processing() void Score_align_engraver::acknowledge_element (Score_elem_info inf) { - if (inf.elem_l_->is_type_b (type_ch_C_)) { - - if (!align_p_) { + if (inf.elem_l_->is_type_b (type_ch_C_)) + { + + if (!align_p_) + { align_p_ = new Horizontal_group_item; align_p_->breakable_b_ = true; announce_element (Score_elem_info (align_p_,0)); - } + } Score_elem * unbound_elem = inf.elem_l_; while ( unbound_elem->axis_group_l_a_[X_AXIS]) unbound_elem = unbound_elem->axis_group_l_a_[X_AXIS]; align_p_->add_element (unbound_elem); } - + } IMPLEMENT_IS_TYPE_B1(Score_align_engraver,Engraver); diff --git a/lily/score-align-gravs.cc b/lily/score-align-gravs.cc index 995c6fbdd6..32127d1886 100644 --- a/lily/score-align-gravs.cc +++ b/lily/score-align-gravs.cc @@ -16,10 +16,10 @@ class C ## _align_engraver : public Score_align_engraver \ { \ public: \ - DECLARE_MY_RUNTIME_TYPEINFO; \ - C ## _align_engraver() : Score_align_engraver () \ - { type_ch_C_ = T::static_name();\ - priority_i_ = p;} \ + DECLARE_MY_RUNTIME_TYPEINFO; \ + C ## _align_engraver() : Score_align_engraver () \ + { type_ch_C_ = T::static_name();\ + priority_i_ = p;} \ }; \ ADD_THIS_ENGRAVER(C ## _align_engraver); \ IMPLEMENT_IS_TYPE_B1(C ## _align_engraver, Score_align_engraver) ; diff --git a/lily/score-column.cc b/lily/score-column.cc index 9accf652a9..d6f4e739a5 100644 --- a/lily/score-column.cc +++ b/lily/score-column.cc @@ -12,56 +12,57 @@ Score_column::Score_column (Moment w) { - when_ = w; - musical_b_ = false; + when_ = w; + musical_b_ = false; } void Score_column::print() const { #ifndef NPRINT - DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n'; - DOUT << "durations: ["; - for (int i=0; i < durations.size(); i++) + DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n'; + DOUT << "durations: ["; + for (int i=0; i < durations.size(); i++) DOUT << durations[i] << " "; - DOUT << "]\n"; - PCol::print(); - DOUT << "}\n"; + DOUT << "]\n"; + PCol::print(); + DOUT << "}\n"; #endif } int Moment_compare (Moment const &m1, Moment const &m2) { - return sign (m1-m2); + return sign (m1-m2); } void Score_column::preprocess() { - durations.sort (Moment_compare); + durations.sort (Moment_compare); } void Score_column::add_duration (Moment d) { - assert (d); - for (int i = 0; i< durations.size(); i++) { + assert (d); + for (int i = 0; i< durations.size(); i++) + { if (d == durations[i]) return ; } - durations.push (d); + durations.push (d); } void Score_column::do_set_breakable() { - Score_column *c1 = new Score_column (when_); - Score_column *c2 = new Score_column (when_); - prebreak_p_ =c1; - postbreak_p_ = c2; - c1->durations = durations; - c2->durations = durations; - c1->musical_b_ + Score_column *c1 = new Score_column (when_); + Score_column *c2 = new Score_column (when_); + prebreak_p_ =c1; + postbreak_p_ = c2; + c1->durations = durations; + c2->durations = durations; + c1->musical_b_ = c2->musical_b_ = musical_b_; } diff --git a/lily/score-elem-info.cc b/lily/score-elem-info.cc index 07e7a100b6..4bfd4c2a16 100644 --- a/lily/score-elem-info.cc +++ b/lily/score-elem-info.cc @@ -11,14 +11,14 @@ Score_elem_info::Score_elem_info (Score_elem*s_l, Request*r_l) { - elem_l_ = s_l; - req_l_ = r_l; + elem_l_ = s_l; + req_l_ = r_l; } Score_elem_info::Score_elem_info() { - elem_l_ = 0; - req_l_ = 0; + elem_l_ = 0; + req_l_ = 0; } diff --git a/lily/score-elem.cc b/lily/score-elem.cc index a471ddf5bb..5569e5bf83 100644 --- a/lily/score-elem.cc +++ b/lily/score-elem.cc @@ -24,25 +24,25 @@ Score_elem* Score_elem::dependency (int i)const { - return (Score_elem*) get_out_edge_arr()[i]; + return (Score_elem*) get_out_edge_arr()[i]; } int Score_elem::dependency_size() const { - return get_out_edge_arr().size (); + return get_out_edge_arr().size (); } Score_elem* Score_elem::dependent (int i) const { - return (Score_elem*) get_in_edge_arr()[i]; + return (Score_elem*) get_in_edge_arr()[i]; } int Score_elem::dependent_size() const { - return get_in_edge_arr().size (); + return get_in_edge_arr().size (); } @@ -50,60 +50,60 @@ Score_elem::dependent_size() const String Score_elem::TeX_string_without_offset (Offset o)const { - if (transparent_b_) + if (transparent_b_) return ""; - String s ("\\placebox{%}{%}{%}"); - Array a; - a.push (print_dimen (o.y())); - a.push (print_dimen (o.x())); - String t = output->TeX_string(); - if (t == "") + String s ("\\placebox{%}{%}{%}"); + Array a; + a.push (print_dimen (o.y())); + a.push (print_dimen (o.x())); + String t = output->TeX_string(); + if (t == "") return t; - a.push (t); - String r; - if (check_debug) + a.push (t); + String r; + if (check_debug) r = String ("\n%start: ") + name() + "\n"; - r += substitute_args (s, a);; - return r; + r += substitute_args (s, a);; + return r; } String Score_elem::TeX_string() const { - assert (status_ > POSTCALCED); - return TeX_string_without_offset (offset_); + assert (status_ > POSTCALCED); + return TeX_string_without_offset (offset_); } void Score_elem::copy_dependencies (Score_elem const &s) { - /* called from derived ctor, so most info points to the same deps - as (Directed_graph_node&)s. Nobody points to us, so don't copy - dependents. - */ - copy_edges_out (s); + /* called from derived ctor, so most info points to the same deps + as (Directed_graph_node&)s. Nobody points to us, so don't copy + dependents. + */ + copy_edges_out (s); } Score_elem::Score_elem (Score_elem const&s) { - transparent_b_ = s.transparent_b_; - empty_b_ = s.empty_b_; - axis_group_l_a_[0] = axis_group_l_a_[1] =0; - status_ = s.status_; - assert (!s.output); - output = 0; - pscore_l_ = s.pscore_l_; - offset_ = Offset (0,0); + transparent_b_ = s.transparent_b_; + empty_b_ = s.empty_b_; + axis_group_l_a_[0] = axis_group_l_a_[1] =0; + status_ = s.status_; + assert (!s.output); + output = 0; + pscore_l_ = s.pscore_l_; + offset_ = Offset (0,0); } Score_elem::~Score_elem() { - // some paranoia to prevent weird segv's - assert (status_ < DELETED); - delete output; - status_ = DELETED; - output = 0; + // some paranoia to prevent weird segv's + assert (status_ < DELETED); + delete output; + status_ = DELETED; + output = 0; } @@ -113,55 +113,55 @@ Score_elem::~Score_elem() Real Score_elem::absolute_coordinate (Axis a)const { - Real r = offset_[a]; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; + Real r = offset_[a]; + for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a]) r += axis_group_l->offset_[a]; - return r; + return r; } Offset Score_elem::absolute_offset() const { - return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS)); + return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS)); } void Score_elem::translate (Real y, Axis a) { - offset_[a] += y; + offset_[a] += y; } Real Score_elem::relative_coordinate (Axis_group_element*e, Axis a)const { - Real r =0.0; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; + Real r =0.0; + for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; axis_group_l != e; axis_group_l = axis_group_l->axis_group_l_a_[a]) r += axis_group_l->offset_[a]; - return r; + return r; } Axis_group_element* Score_elem::common_group (Score_elem const* s, Axis a)const { - Link_array my_groups; - for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; + Link_array my_groups; + for ( Axis_group_element * axis_group_l = axis_group_l_a_[a]; axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a]) my_groups.push (axis_group_l); - Axis_group_element* common_l=0; - for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a]; + Axis_group_element* common_l=0; + for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a]; !common_l && axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a]) common_l = my_groups.find_l (axis_group_l); - return common_l; + return common_l; } @@ -169,61 +169,66 @@ Score_elem::common_group (Score_elem const* s, Axis a)const void Score_elem::translate (Offset O) { - offset_ += O; + offset_ += O; } Interval Score_elem::do_width() const { - Interval r; + Interval r; - if (!output){ + if (!output) + { Molecule*m = brew_molecule_p(); r = m->extent().x (); delete m; - } else + } + else r = output->extent().x (); - return r; + return r; } Interval Score_elem::width() const { - return extent (X_AXIS); + return extent (X_AXIS); } Interval Score_elem::extent (Axis a)const { - Interval r; - if ( !empty_b_) { + Interval r; + if ( !empty_b_) + { r = (a == X_AXIS)? do_width(): do_height (); } - - if (!r.empty_b()) // float exception on DEC Alpha + + if (!r.empty_b()) // float exception on DEC Alpha r+=offset_[a]; - return r; + return r; } Interval Score_elem::do_height() const { - Interval r; - if (!output){ + Interval r; + if (!output) + { Molecule*m = brew_molecule_p(); r = m->extent().y (); delete m; - } else + } + else r = output->extent().y (); - return r; + return r; } Interval Score_elem::height() const { - return extent (Y_AXIS); + return extent (Y_AXIS); } /* @@ -233,170 +238,172 @@ void Score_elem::print()const { #ifndef NPRINT - DOUT << name() << "{\n"; - DOUT << "dets: " << dependent_size() << "dependencies: " << + DOUT << name() << "{\n"; + DOUT << "dets: " << dependent_size() << "dependencies: " << dependency_size(); - if (offset_.x() || offset_.y ()) + if (offset_.x() || offset_.y ()) DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")"; - DOUT << "\n"; + DOUT << "\n"; - do_print(); - if (output) + do_print(); + if (output) output->print(); - - DOUT << "}\n"; + + DOUT << "}\n"; #endif } Score_elem::Score_elem() { - transparent_b_ = empty_b_ = false; - axis_group_l_a_[0] = axis_group_l_a_[1] =0; - pscore_l_=0; - offset_ = Offset (0,0); - output = 0; - status_ = ORPHAN; + transparent_b_ = empty_b_ = false; + axis_group_l_a_[0] = axis_group_l_a_[1] =0; + pscore_l_=0; + offset_ = Offset (0,0); + output = 0; + status_ = ORPHAN; } Paper_def* Score_elem::paper() const { - assert (pscore_l_); - return pscore_l_->paper_l_; + assert (pscore_l_); + return pscore_l_->paper_l_; } void Score_elem::add_processing() { - if (status_ >= VIRGIN) + if (status_ >= VIRGIN) return; - status_ = VIRGIN; - do_add_processing(); + status_ = VIRGIN; + do_add_processing(); } void Score_elem::pre_processing() { - if (status_ >= PRECALCED) + if (status_ >= PRECALCED) return; - assert (status_ != PRECALCING); // cyclic dependency - status_ = PRECALCING; + assert (status_ != PRECALCING); // cyclic dependency + status_ = PRECALCING; - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->pre_processing(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->pre_processing(); - - do_pre_processing(); - status_ = PRECALCED; + + do_pre_processing(); + status_ = PRECALCED; } void Score_elem::breakable_col_processing() { - if (status_ >= PREBROKEN) + if (status_ >= PREBROKEN) return; - if (status_== PREBREAKING) { + if (status_== PREBREAKING) + { status_ = PREBROKEN; return ; } - status_ = PREBREAKING; + status_ = PREBREAKING; - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->breakable_col_processing(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->breakable_col_processing(); - - do_breakable_col_processing(); - status_ = PREBROKEN; + + do_breakable_col_processing(); + status_ = PREBROKEN; } void Score_elem::break_processing() { - if (status_ >= BROKEN) + if (status_ >= BROKEN) return; - if (status_ == BREAKING) { + if (status_ == BREAKING) + { status_ = BROKEN; return; } - status_ = BREAKING; + status_ = BREAKING; - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->break_processing(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->break_processing(); - + - - do_break_processing(); - status_ = BROKEN; + + do_break_processing(); + status_ = BROKEN; } void Score_elem::do_break_processing() { - handle_broken_dependencies(); + handle_broken_dependencies(); } void Score_elem::post_processing() { - if (status_ >= POSTCALCED) + if (status_ >= POSTCALCED) return; - assert (status_ != POSTCALCING);// cyclic dependency - status_=POSTCALCING; + assert (status_ != POSTCALCING);// cyclic dependency + status_=POSTCALCING; - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->post_processing(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->post_processing(); - + - do_post_processing(); - status_=POSTCALCED; + do_post_processing(); + status_=POSTCALCED; } Score_elem::Status Score_elem::status()const { - return status_; + return status_; } void Score_elem::molecule_processing() { - if (status_ >= OUTPUT) + if (status_ >= OUTPUT) return; - status_ = OUTPUT; // do it only once. + status_ = OUTPUT; // do it only once. - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->molecule_processing(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->molecule_processing(); - + - if (transparent_b_) + if (transparent_b_) return ; - output= brew_molecule_p(); + output= brew_molecule_p(); } /* @@ -412,7 +419,7 @@ Score_elem::do_post_processing() void Score_elem::do_breakable_col_processing() { - handle_prebroken_dependencies(); + handle_prebroken_dependencies(); } void @@ -443,15 +450,15 @@ IMPLEMENT_IS_TYPE_B(Score_elem); Molecule* Score_elem::brew_molecule_p()const { - Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0)))); - return new Molecule (a); + Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0)))); + return new Molecule (a); } Line_of_score * Score_elem::line_l()const { - return 0; + return 0; } /* @@ -463,26 +470,27 @@ Score_elem::line_l()const void Score_elem::remove_dependency (Score_elem*e) { - remove_edge_out (e); - substitute_dependency (e, 0); + remove_edge_out (e); + substitute_dependency (e, 0); } void Score_elem::add_dependency (Score_elem*e) { - Directed_graph_node::add (e); + Directed_graph_node::add (e); } void Score_elem::substitute_dependency (Score_elem* old, Score_elem* new_l) { - do_substitute_dependency (old,new_l); - old->do_substitute_dependent (this, 0); + do_substitute_dependency (old,new_l); + old->do_substitute_dependent (this, 0); } void Score_elem::junk_dependencies() { - while ( dependency_size()) { + while ( dependency_size()) + { remove_edge_out (dependency (0)); } } @@ -490,37 +498,42 @@ Score_elem::junk_dependencies() void Score_elem::handle_broken_dependencies() { - Line_of_score *line = line_l(); - if (!line) + Line_of_score *line = line_l(); + if (!line) return; - Link_array remove_us_arr; - for (int i=0; i < dependency_size(); i++) { + Link_array remove_us_arr; + for (int i=0; i < dependency_size(); i++) + { Score_elem * elt = dependency (i); - if (elt->line_l() != line){ - if (elt->spanner()) { + if (elt->line_l() != line) + { + if (elt->spanner()) + { Spanner * sp = elt->spanner(); Spanner * broken = sp->find_broken_piece (line); substitute_dependency (sp, broken); add_dependency (broken); - } else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b () - && elt->item()->break_status_i () == 0) { + } + else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b () + && elt->item()->break_status_i () == 0) + { Item * my_item = elt->item()->find_prebroken_piece (line); substitute_dependency (elt, my_item); if (my_item) add_dependency (my_item); - } + } remove_us_arr.push (elt); - } + } } - remove_us_arr.default_sort(); - remove_us_arr.uniq(); - for (int i=0; i old_arr, new_arr; - - for (int i=0; i < dependency_size(); i++) { + Link_array old_arr, new_arr; + + for (int i=0; i < dependency_size(); i++) + { Score_elem * elt = dependency (i); Item *it_l = elt->item(); if (it_l && it_l->breakable_b_) - if (item()) { + if (item()) + { Score_elem *new_l = it_l->find_prebroken_piece (item()->pcol_l_); - if (new_l != elt) { + if (new_l != elt) + { new_arr.push (new_l); old_arr.push (elt); - } - }else { + } + }else + { new_arr.push (it_l->broken_to_a_[0]); old_arr.push (0); old_arr.push (0); new_arr.push (it_l->broken_to_a_[1]); - } + } } - - for (int i=0; i < old_arr.size(); i++) + + for (int i=0; i < old_arr.size(); i++) if (old_arr[i]) substitute_dependency (old_arr[i], new_arr[i]); - status_ = PREBROKEN; + status_ = PREBROKEN; } @@ -572,28 +589,30 @@ Score_elem::handle_prebroken_dependencies() void Score_elem::unlink_all() { - for (int i=0; i < dependency_size(); i++) + for (int i=0; i < dependency_size(); i++) dependency (i)->unlink_all(); - Link_array extra (get_extra_dependencies()); - for (int i=0; i < extra.size(); i++) + Link_array extra (get_extra_dependencies()); + for (int i=0; i < extra.size(); i++) extra[i]->unlink_all(); - - junk_links(); - axis_group_l_a_[0] = axis_group_l_a_[1] =0; + + junk_links(); + axis_group_l_a_[0] = axis_group_l_a_[1] =0; } void Score_elem::unlink() { - do_unlink(); - while ( dependency_size()) { + do_unlink(); + while ( dependency_size()) + { do_substitute_dependency (dependency (0),0); remove_edge_out_idx (0); } - while ( dependent_size()) { + while ( dependent_size()) + { dependent (0)->remove_dependency (this); } - for (int j=0; j < 2; j++) + for (int j=0; j < 2; j++) if ( axis_group_l_a_[j]) axis_group_l_a_[j]->remove_element (this); @@ -603,7 +622,8 @@ void Score_elem::OK()const { #ifndef NDEBUG - for (int i=0; i < dependency_size(); i++) { + for (int i=0; i < dependency_size(); i++) + { dependency (i)->OK(); } #endif @@ -612,6 +632,6 @@ Score_elem::OK()const Link_array Score_elem::get_extra_dependencies()const { - Link_array empty; - return empty; + Link_array empty; + return empty; } diff --git a/lily/score-grav.cc b/lily/score-grav.cc index acfa137c1d..96192d66f9 100644 --- a/lily/score-grav.cc +++ b/lily/score-grav.cc @@ -23,62 +23,62 @@ void Score_engraver::set_score (Score *s) { - Global_translator::set_score (s); - scoreline_l_ = s->pscore_p_->super_elem_l_->line_of_score_l_; + Global_translator::set_score (s); + scoreline_l_ = s->pscore_p_->super_elem_l_->line_of_score_l_; } Score_engraver::Score_engraver() { - disallow_break_b_ = false; - scoreline_l_ =0; - command_column_l_ =0; - musical_column_l_ =0; - breaks_i_ =0; + disallow_break_b_ = false; + scoreline_l_ =0; + command_column_l_ =0; + musical_column_l_ =0; + breaks_i_ =0; } void Score_engraver::prepare (Moment w) { - set_columns (new Score_column (w), new Score_column (w)); - - - disallow_break_b_ = false; - post_move_processing(); + set_columns (new Score_column (w), new Score_column (w)); + + + disallow_break_b_ = false; + post_move_processing(); } void Score_engraver::finish() { - if ( (breaks_i_%8)) + if ( (breaks_i_%8)) *mlog << "[" << breaks_i_ << "]" << flush; - check_removal(); - removal_processing(); + check_removal(); + removal_processing(); } void Score_engraver::do_creation_processing() { - scoreline_l_->left_col_l_ = get_staff_info().command_pcol_l (); - scoreline_l_->left_col_l_ ->set_breakable(); - Engraver_group_engraver::do_creation_processing(); + scoreline_l_->left_col_l_ = get_staff_info().command_pcol_l (); + scoreline_l_->left_col_l_ ->set_breakable(); + Engraver_group_engraver::do_creation_processing(); } void Score_engraver::do_removal_processing() { - Engraver_group_engraver::do_removal_processing(); - scoreline_l_->right_col_l_ = get_staff_info().command_pcol_l (); - scoreline_l_->right_col_l_ ->set_breakable(); - typeset_all(); - set_columns (0,0); + Engraver_group_engraver::do_removal_processing(); + scoreline_l_->right_col_l_ = get_staff_info().command_pcol_l (); + scoreline_l_->right_col_l_ ->set_breakable(); + typeset_all(); + set_columns (0,0); } void Score_engraver::process() { - process_requests(); + process_requests(); do_announces(); pre_move_processing(); check_removal(); @@ -87,32 +87,35 @@ Score_engraver::process() void Score_engraver::announce_element (Score_elem_info info) { - announce_info_arr_.push (info); - info.origin_grav_l_arr_.push (this); - + announce_info_arr_.push (info); + info.origin_grav_l_arr_.push (this); + } void Score_engraver::do_announces() { - /* All elements are propagated to the top upon announcement. If - something was created during one run of - Engraver_group_engraver::do_announces, then - announce_info_arr_.size() will be nonzero again + /* All elements are propagated to the top upon announcement. If + something was created during one run of + Engraver_group_engraver::do_announces, then + announce_info_arr_.size() will be nonzero again - */ - while (announce_info_arr_.size()) { + */ + while (announce_info_arr_.size()) + { for (int i=0; i musical(); - if (m && m->rhythmic()) { + if (m && m->rhythmic()) + { musical_column_l_->add_duration (m->duration()); - } - } + } + } Engraver_group_engraver::do_announces(); } } @@ -121,79 +124,92 @@ Score_engraver::do_announces() void Score_engraver::typeset_element (Score_elem *elem_p) { - if ( elem_p->item() && elem_p->item ()->breakable_b_) { + if ( elem_p->item() && elem_p->item ()->breakable_b_) + { nobreak_item_p_arr_.push (elem_p->item()); - } else + } + else musical_item_p_arr_.push (elem_p); } void Score_engraver::typeset_all() { - PCol * c= get_staff_info().command_pcol_l (); - Paper_score *ps_l = score_l_->pscore_p_; + PCol * c= get_staff_info().command_pcol_l (); + Paper_score *ps_l = score_l_->pscore_p_; - for (int i =0; i < nobreak_item_p_arr_.size(); i++) { + for (int i =0; i < nobreak_item_p_arr_.size(); i++) + { ps_l->typeset_item (nobreak_item_p_arr_[i], c); // should get rid of this.. . scoreline_l_->add_dependency (nobreak_item_p_arr_[i]); } - nobreak_item_p_arr_.clear(); - - for (int i=0; i < musical_item_p_arr_.size(); i++) { + nobreak_item_p_arr_.clear(); + + for (int i=0; i < musical_item_p_arr_.size(); i++) + { PCol* m = get_staff_info().musical_pcol_l (); Score_elem *elem_p = musical_item_p_arr_[i]; scoreline_l_->add (elem_p); - if (elem_p->spanner()) { + if (elem_p->spanner()) + { ps_l->typeset_unbroken_spanner (elem_p->spanner()); - } else if (elem_p->item()) { + } + else if (elem_p->item()) + { ps_l->typeset_item (elem_p->item(), m); - } else + } + else assert (false); } - musical_item_p_arr_.clear(); + musical_item_p_arr_.clear(); } void Score_engraver::do_pre_move_processing() { - if ( !disallow_break_b_){ + if ( !disallow_break_b_) + { get_staff_info().command_pcol_l ()->set_breakable (); breaks_i_ ++; if ( ! (breaks_i_%8)) *mlog << "[" << breaks_i_ << "]" << flush; } - // this generates all items. - Engraver_group_engraver::do_pre_move_processing(); - - typeset_all(); + // this generates all items. + Engraver_group_engraver::do_pre_move_processing(); + + typeset_all(); } void Score_engraver::set_columns (Score_column *new_command_l, Score_column *new_musical_l) { - if ( command_column_l_ && command_column_l_->used_b()) + if ( command_column_l_ && command_column_l_->used_b()) score_l_->pscore_p_->add (command_column_l_); - else { + else + { delete command_column_l_ ; command_column_l_ =0; } - if (new_command_l) { + if (new_command_l) + { command_column_l_ = new_command_l; command_column_l_->musical_b_ = false; } - if ( musical_column_l_ && musical_column_l_->used_b()) + if ( musical_column_l_ && musical_column_l_->used_b()) score_l_->pscore_p_->add (musical_column_l_); - else { + else + { delete musical_column_l_; musical_column_l_ = 0; } - - if (new_musical_l) { + + if (new_musical_l) + { musical_column_l_ = new_musical_l; musical_column_l_->musical_b_ = true; } @@ -203,17 +219,17 @@ Score_engraver::set_columns (Score_column *new_command_l, Staff_info Score_engraver::get_staff_info()const { - Staff_info inf; + Staff_info inf; - inf.command_l_ = command_column_l_; - inf.musical_l_ = musical_column_l_; - return inf; + inf.command_l_ = command_column_l_; + inf.musical_l_ = musical_column_l_; + return inf; } Paper_def* Score_engraver::paper()const { - return score_l_->paper_p_; + return score_l_->paper_p_; } @@ -221,10 +237,10 @@ Score_engraver::paper()const bool Score_engraver::do_try_request (Request*r) { - bool gotcha = Engraver_group_engraver::do_try_request (r); - if ( !gotcha && r->command() && r->command ()->disallowbreak ()) + bool gotcha = Engraver_group_engraver::do_try_request (r); + if ( !gotcha && r->command() && r->command ()->disallowbreak ()) disallow_break_b_ = true; - return gotcha; + return gotcha; } IMPLEMENT_IS_TYPE_B1(Score_engraver,Engraver_group_engraver); diff --git a/lily/score-halign-grav.cc b/lily/score-halign-grav.cc index 08f194171c..c694c50ee2 100644 --- a/lily/score-halign-grav.cc +++ b/lily/score-halign-grav.cc @@ -13,13 +13,14 @@ Score_horizontal_align_engraver::Score_horizontal_align_engraver() { - halign_p_ =0; + halign_p_ =0; } void Score_horizontal_align_engraver::do_pre_move_processing() { - if (halign_p_) { + if (halign_p_) + { typeset_element (halign_p_); halign_p_ =0; } @@ -29,16 +30,17 @@ Score_horizontal_align_engraver::do_pre_move_processing() void Score_horizontal_align_engraver::acknowledge_element (Score_elem_info i) { - Engraver* reg = i.origin_grav_l_arr_[0]; - if (reg->is_type_b ( + Engraver* reg = i.origin_grav_l_arr_[0]; + if (reg->is_type_b ( Score_align_engraver::static_name())) - { + { Score_align_engraver * align_grav_l = (Score_align_engraver*) reg; - if (!halign_p_) { + if (!halign_p_) + { halign_p_ = new Break_align_item; halign_p_->breakable_b_ = true; announce_element (Score_elem_info (halign_p_,0)); - } + } Item * it = i.elem_l_->item(); if (align_grav_l->type_ch_C_ == Bar::static_name()) halign_p_->center_l_ = it; diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 53c2a283f7..eabe401926 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -38,56 +38,59 @@ Score_performer::~Score_performer() Translator* Score_performer::ancestor_l (int l) { - return Global_translator::ancestor_l (l); + return Global_translator::ancestor_l (l); } int Score_performer::depth_i() const { - return Global_translator::depth_i(); + return Global_translator::depth_i(); } void Score_performer::finish() { - Performer_group_performer::do_removal_processing(); + Performer_group_performer::do_removal_processing(); } void Score_performer::play (Audio_element * p) { - if (p->is_type_b (Audio_item::static_name())) { + if (p->is_type_b (Audio_item::static_name())) + { audio_column_l_->add ((Audio_item*)p); - } else if (p->is_type_b (Audio_staff::static_name())) { + } + else if (p->is_type_b (Audio_staff::static_name())) + { score_l_->audio_score_p_->add_staff ((Audio_staff*)p); } - score_l_->audio_score_p_->add (p); + score_l_->audio_score_p_->add (p); } void Score_performer::prepare (Moment m) { - now_mom_ = m; - audio_column_l_ = new Audio_column (m); - score_l_->audio_score_p_->add (audio_column_l_); + now_mom_ = m; + audio_column_l_ = new Audio_column (m); + score_l_->audio_score_p_->add (audio_column_l_); } void Score_performer::process() { - process_requests(); + process_requests(); } void Score_performer::set_score (Score* score_l) { - Global_translator::set_score (score_l); + Global_translator::set_score (score_l); } @@ -100,5 +103,5 @@ Score_performer::start() int Score_performer::get_tempo_i()const { - return score_l_->midi_p_->get_tempo_i (Moment (1, 4)); + return score_l_->midi_p_->get_tempo_i (Moment (1, 4)); } diff --git a/lily/score.cc b/lily/score.cc index 8a8a473a81..fd11b56542 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -22,59 +22,66 @@ #include "music-iterator.hh" #include "music.hh" #include "global-translator.hh" +#include "header.hh" extern String default_out_fn; Score::Score() { - pscore_p_=0; - audio_score_p_ = 0; - paper_p_ = 0; - midi_p_ = 0; - errorlevel_i_ = 0; + header_p_ =0; + pscore_p_=0; + audio_score_p_ = 0; + paper_p_ = 0; + midi_p_ = 0; + errorlevel_i_ = 0; } Score::Score (Score const &s) { - assert (!pscore_p_); - music_p_ = s.music_p_->clone(); - midi_p_ = new Midi_def (*s.midi_p_); - paper_p_ = new Paper_def (*s.paper_p_); + assert (!pscore_p_); + music_p_ = s.music_p_->clone(); + midi_p_ = new Midi_def (*s.midi_p_); + paper_p_ = new Paper_def (*s.paper_p_); + header_p_ = new Header(*s.header_p_); } Score::~Score() { - delete music_p_; - delete pscore_p_; - delete audio_score_p_; - delete paper_p_; - delete midi_p_; + delete header_p_; + delete music_p_; + delete pscore_p_; + delete audio_score_p_; + delete paper_p_; + delete midi_p_; } void Score::run_translator (Global_translator * trans_l) { - trans_l->set_score (this); - Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_, + trans_l->set_score (this); + Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_, trans_l); - iter->construct_children(); + iter->construct_children(); - if ( ! iter->ok()) { + if ( ! iter->ok()) + { delete iter; warning ("Need music in a score"); errorlevel_i_ =1; return ; } - - trans_l->start(); - - while ( iter->ok() || trans_l->moments_left_i ()) { + + trans_l->start(); + + while ( iter->ok() || trans_l->moments_left_i ()) + { Moment w = infinity_mom; - if (iter->ok()) { + if (iter->ok()) + { w = iter->next_moment(); DOUT << w; iter->print(); - } + } trans_l->modify_next (w); trans_l->prepare (w); trans_l->print(); @@ -82,125 +89,128 @@ Score::run_translator (Global_translator * trans_l) iter->process_and_next (w); trans_l->process(); } - delete iter; - trans_l->finish(); + delete iter; + trans_l->finish(); } void Score::process() { - print(); - paper(); - midi(); + print(); + paper(); + midi(); } void Score::midi() { - if ( !midi_p_) + if ( !midi_p_) return; - - *mlog << "\nCreating MIDI elements ..." << flush; - audio_score_p_ = new Audio_score (this); - - Global_translator* score_trans= midi_p_->get_global_translator_p(); - run_translator (score_trans); - delete score_trans; - - if (errorlevel_i_){ + + *mlog << "\nCreating MIDI elements ..." << flush; + audio_score_p_ = new Audio_score (this); + + Global_translator* score_trans= midi_p_->get_global_translator_p(); + run_translator (score_trans); + delete score_trans; + + if (errorlevel_i_) + { // should we? hampers debugging. warning ("Errors found, /*not processing score*/"); // return; } - *mlog << endl; + *mlog << endl; - midi_output(); + midi_output(); } - + void Score::paper() { - if (!paper_p_) + if (!paper_p_) return; - - *mlog << "\nCreating elements ..." << flush; - pscore_p_ = new Paper_score (paper_p_); - - Global_translator * score_trans= paper_p_->get_global_translator_p(); - run_translator (score_trans); - delete score_trans; - - if (errorlevel_i_) { + + *mlog << "\nCreating elements ..." << flush; + pscore_p_ = new Paper_score (paper_p_); + + Global_translator * score_trans= paper_p_->get_global_translator_p(); + run_translator (score_trans); + delete score_trans; + + if (errorlevel_i_) + { // should we? hampers debugging. warning ("Errors found, /*not processing score*/"); // return; } - - *mlog << endl; - pscore_p_->process(); + + *mlog << endl; + pscore_p_->process(); - // output - paper_output(); + // output + paper_output(); } void Score::midi_output() { - if ( midi_p_->outfile_str_ == "") + if ( midi_p_->outfile_str_ == "") midi_p_->outfile_str_ = default_out_fn + ".midi"; - Midi_stream midi_stream (midi_p_->outfile_str_); - *mlog << "MIDI output to " << midi_p_->outfile_str_ << " ..." << endl; + Midi_stream midi_stream (midi_p_->outfile_str_); + *mlog << "MIDI output to " << midi_p_->outfile_str_ << " ..." << endl; - audio_score_p_->output (midi_stream); - *mlog << endl; + audio_score_p_->output (midi_stream); + *mlog << endl; } void Score::paper_output() { - if (paper_p_->outfile_str_=="") + if (paper_p_->outfile_str_=="") paper_p_->outfile_str_ = default_out_fn + ".tex"; - if ( errorlevel_i_) { + if ( errorlevel_i_) + { *mlog << "lilypond: warning: no output to: " << paper_p_->outfile_str_ << " (errorlevel=" << errorlevel_i_ << ")" << endl; - return; + return; } - *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n"; - - Tex_stream the_output (paper_p_->outfile_str_); - - the_output << "% outputting Score, defined at: " << + *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n"; + + Tex_stream the_output (paper_p_->outfile_str_); + + the_output << "% outputting Score, defined at: " << location_str() << "\n"; - pscore_p_->output (the_output); + pscore_p_->output (the_output); } void Score::print() const { #ifndef NPRINT - DOUT << "score {\n"; - music_p_->print(); - if (midi_p_) + DOUT << "score {\n"; + music_p_->print(); + if (midi_p_) midi_p_->print(); - - DOUT << "}\n"; + + DOUT << "}\n"; #endif } void Score::set (Paper_def *pap_p) { - delete paper_p_; - paper_p_ = pap_p; + delete paper_p_; + paper_p_ = pap_p; } void Score::set (Midi_def* midi_p) { - delete midi_p_; - midi_p_ = midi_p; + delete midi_p_; + midi_p_ = midi_p; } diff --git a/lily/scoreline.cc b/lily/scoreline.cc index fc64123533..7bb391211a 100644 --- a/lily/scoreline.cc +++ b/lily/scoreline.cc @@ -22,13 +22,14 @@ String Line_of_score::TeX_string() const { - String s ("\\hbox{%<- line of score\n"); - if (error_mark_b_) + String s ("\\hbox{%<- line of score\n"); + if (error_mark_b_) s+= "\\scorelineerrormark"; - - - Real lastpos = cols[0]->hpos_f_; - for (int i=0; i < cols.size(); i++){ + + + Real lastpos = cols[0]->hpos_f_; + for (int i=0; i < cols.size(); i++) + { PCol* col_l= cols[i]; // all items in the current line & staff. String chunk_str; @@ -36,35 +37,39 @@ Line_of_score::TeX_string() const Link_array elems; - if (col_l->error_mark_b_) { + if (col_l->error_mark_b_) + { chunk_str += String ("\\columnerrormark"); - } + } // now output the items. - for (iter_top (col_l->its,j); j.ok(); j++) { + for (iter_top (col_l->its,j); j.ok(); j++) + { elems.push (j); - } + } // spanners. - for (iter_top (col_l->starters,j); j.ok(); j++) { + for (iter_top (col_l->starters,j); j.ok(); j++) + { if (j->name() != name ()) elems.push (j); - } + } - for (int j =0; j< elems.size(); j++) { + for (int j =0; j< elems.size(); j++) + { Offset o = elems[j]->absolute_offset(); o[X_AXIS] += cols[i]->hpos_f_; s += elems[j]->TeX_string_without_offset (o); - } + } } - s += "}"; - return s; + s += "}"; + return s; } Line_of_score::Line_of_score() { - error_mark_b_ = 0; + error_mark_b_ = 0; } @@ -76,21 +81,22 @@ IMPLEMENT_IS_TYPE_B1(Line_of_score,Spanner); void Line_of_score::add (Score_elem*e) { - // avoid excess dependencies. - if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1])) + // avoid excess dependencies. + if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1])) add_dependency (e); } bool Line_of_score::contains_b (PCol const* c)const { - return cols.find_l ((PCol*)c); + return cols.find_l ((PCol*)c); } void Line_of_score::set_breaking (Array const &breaking) { - for (int j=0; j < breaking.size(); j++) { + for (int j=0; j < breaking.size(); j++) + { const Array &curline (breaking[j].cols); const Array &errors (breaking[j].error_col_l_arr_); const Array &config (breaking[j].config); @@ -101,26 +107,30 @@ Line_of_score::set_breaking (Array const &breaking) Line_of_score *line_l=0; Line_of_score *line_p =0; - if (breaking.size() >1) { + if (breaking.size() >1) + { line_p = (Line_of_score*)clone()->spanner (); line_p->copy_dependencies (*this); line_l = line_p; - } else + } + else line_l = this; ((Array &)line_l->cols) = curline; line_l->left_col_l_ = curline[0]; line_l->right_col_l_= curline.top(); - if (line_p) { + if (line_p) + { pscore_l_->typeset_broken_spanner (line_p); broken_into_l_arr_.push (line_p); - } + } - for (int i=0; i < curline.size(); i++){ + for (int i=0; i < curline.size(); i++) + { curline[i]->hpos_f_ = config[i]; curline[i]->line_l_ = (Line_of_score*)line_l; - } + } } } @@ -132,26 +142,27 @@ Line_of_score::break_into_pieces (bool) Link_array Line_of_score::get_lines()const { - Link_array ret; + Link_array ret; - if (broken_into_l_arr_.size()) - for (int i=0; i < broken_into_l_arr_.size(); i++) { + if (broken_into_l_arr_.size()) + for (int i=0; i < broken_into_l_arr_.size(); i++) + { ret.push ((Line_of_score*)broken_into_l_arr_[i]); - } - else + } + else ret.push ((Line_of_score*)this); // ugh - - return ret; + + return ret; } void Line_of_score::do_print()const { - Spanner::do_print(); + Spanner::do_print(); } Interval Line_of_score::do_width()const { - return Spanner::do_width(); + return Spanner::do_width(); } diff --git a/lily/scores.cc b/lily/scores.cc index fbd646b7a2..446e419a3d 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -18,37 +18,42 @@ String default_out_fn = "lelie"; void do_scores() { - for (int i=0; i < score_array_global.size(); i++) { + for (int i=0; i < score_array_global.size(); i++) + { Score *&is_p = score_array_global[i]; - if (only_midi) { + if (only_midi) + { delete is_p->paper_p_; is_p->paper_p_ = 0; - } + } - if (is_p->errorlevel_i_) { + if (is_p->errorlevel_i_) + { is_p->warning ("Score contains errors. Will not process it. "); exit_status_i_ |= 1; - } else { + } + else + { is_p->print(); is_p->process(); - } + } delete is_p; is_p =0; } - score_array_global.clear(); + score_array_global.clear(); } void add_score (Score * s) { - score_array_global.push (s); + score_array_global.push (s); } void set_default_output (String s) { - default_out_fn = s; + default_out_fn = s; } diff --git a/lily/script-column.cc b/lily/script-column.cc index 9d9231e549..836541ce16 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -19,9 +19,9 @@ IMPLEMENT_IS_TYPE_B1(Script_column,Horizontal_vertical_group_item); void Script_column::add (Script*s_l) { - script_l_arr_.push (s_l); - add_dependency (s_l); - add_element (s_l); + script_l_arr_.push (s_l); + add_dependency (s_l); + add_element (s_l); } @@ -29,59 +29,66 @@ void Script_column::do_print()const { #ifndef NPRINT - DOUT << "scripts: " << script_l_arr_.size() << '\n'; + DOUT << "scripts: " << script_l_arr_.size() << '\n'; #endif } static int idx (bool inside, int dir) { - int j = (dir+1); - if ( !inside) + int j = (dir+1); + if ( !inside) j ++; - return j; + return j; } void Script_column::do_pre_processing() { - if (!script_l_arr_.size()) + if (!script_l_arr_.size()) return; - - /* up+inside, up+outside, down+inside, down+outside */ - Array placed_l_arr_a[4]; - for (int i=0; i < script_l_arr_.size(); i++) { + + /* up+inside, up+outside, down+inside, down+outside */ + Array placed_l_arr_a[4]; + for (int i=0; i < script_l_arr_.size(); i++) + { Script*s_l = script_l_arr_[i]; placed_l_arr_a[idx (s_l->inside_staff_b_ , s_l->dir_i_) ].push (s_l); } - - for (int j =0; j <4; j++) { + + for (int j =0; j <4; j++) + { placed_l_arr_a[j].sort (Script::compare); } - for (int j =0; j < 4; j++) { + for (int j =0; j < 4; j++) + { if (placed_l_arr_a[j].size()) for (int i=0; i < support_l_arr_.size(); i++) placed_l_arr_a[j][0]->add_support (support_l_arr_[i]); } - - Item * support_l=0; - int j = 0; - for (; j < 2; j++) { - for (int i=0; i < placed_l_arr_a[j].size(); i++) { + + Item * support_l=0; + int j = 0; + for (; j < 2; j++) + { + for (int i=0; i < placed_l_arr_a[j].size(); i++) + { if (support_l) placed_l_arr_a[j][i]->add_support (support_l); support_l = placed_l_arr_a[j][i]; - } + } } - support_l = 0; - for (; j < 4; j++) { - for (int i=0; i < placed_l_arr_a[j].size(); i++) { + support_l = 0; + for (; j < 4; j++) + { + for (int i=0; i < placed_l_arr_a[j].size(); i++) + { if (support_l) placed_l_arr_a[j][i]->add_support (support_l); support_l = placed_l_arr_a[j][i]; - } + } } } @@ -89,15 +96,16 @@ Script_column::do_pre_processing() void Script_column::add_support (Item*i_l) { - support_l_arr_.push (i_l); - add_dependency (i_l); - add_element (i_l); + support_l_arr_.push (i_l); + add_dependency (i_l); + add_element (i_l); } void Script_column::do_substitute_dependency (Score_elem*o,Score_elem*n) { - if (o->item()) { + if (o->item()) + { script_l_arr_.substitute ((Script*)o->item(),(Script*) (n?n->item ():0)); support_l_arr_.substitute (o->item(), (n?n->item ():0)); } diff --git a/lily/script-def.cc b/lily/script-def.cc index a1970dc8d2..6a53aba982 100644 --- a/lily/script-def.cc +++ b/lily/script-def.cc @@ -14,23 +14,23 @@ Script_def::Script_def() { - inside_staff_b_ = false; - symidx_str_ = "unknown" ; - rel_stem_dir_i_ =0; - staff_dir_i_ = -1; - invertsym_b_ = 0; - priority_i_ =0; + inside_staff_b_ = false; + symidx_str_ = "unknown" ; + rel_stem_dir_i_ =0; + staff_dir_i_ = -1; + invertsym_b_ = 0; + priority_i_ =0; } void Script_def::set_from_input (String idx, bool follow, int stem, int staff ,bool invert, int priority_i) { - inside_staff_b_ = follow; - symidx_str_ = idx ; - rel_stem_dir_i_ =stem; - staff_dir_i_ = staff; - invertsym_b_ = invert; - priority_i_ =priority_i; + inside_staff_b_ = follow; + symidx_str_ = idx ; + rel_stem_dir_i_ =stem; + staff_dir_i_ = staff; + invertsym_b_ = invert; + priority_i_ =priority_i; } @@ -38,7 +38,7 @@ void Script_def::do_print() const { #ifndef NPRINT - DOUT << "Script_def{ idx: " << symidx_str_ + DOUT << "Script_def{ idx: " << symidx_str_ << " direction, stem: " << rel_stem_dir_i_ << " staff : " << staff_dir_i_ << "}\n"; #endif } @@ -46,8 +46,8 @@ Script_def::do_print() const bool Script_def::do_equal_b (General_script_def const *g)const { - Script_def const * c = (Script_def const*) g; - return (symidx_str_ == c->symidx_str_ && + Script_def const * c = (Script_def const*) g; + return (symidx_str_ == c->symidx_str_ && rel_stem_dir_i_ == c->rel_stem_dir_i_&& staff_dir_i_ == c->staff_dir_i_&& invertsym_b_ == c->invertsym_b_); @@ -56,29 +56,29 @@ Script_def::do_equal_b (General_script_def const *g)const int Script_def::staff_dir_i() const { - return staff_dir_i_; + return staff_dir_i_; } int Script_def::rel_stem_dir_i() const { - return rel_stem_dir_i_; + return rel_stem_dir_i_; } bool Script_def::inside_b() const { - return inside_staff_b_; + return inside_staff_b_; } Atom Script_def::get_atom (Paper_def *p , int d)const { - String preidx_str =""; - if (invertsym_b_&& d < 0) + String preidx_str =""; + if (invertsym_b_&& d < 0) preidx_str = "-"; - return p->lookup_l()->script (preidx_str + symidx_str_); + return p->lookup_l()->script (preidx_str + symidx_str_); } @@ -87,8 +87,8 @@ IMPLEMENT_IS_TYPE_B1(Script_def,General_script_def); int Script_def::priority_i()const { - return priority_i_; + return priority_i_; } - - + + diff --git a/lily/script-grav.cc b/lily/script-grav.cc index 6c01af322a..f66b2eb3b1 100644 --- a/lily/script-grav.cc +++ b/lily/script-grav.cc @@ -12,29 +12,31 @@ Script_engraver::Script_engraver() { - do_post_move_processing(); + do_post_move_processing(); } bool Script_engraver::do_try_request (Request *r_l) { - if (!r_l->musical() || ! r_l->musical ()->musicalscript ()) + if (!r_l->musical() || ! r_l->musical ()->musicalscript ()) return false ; - - for (int i=0; i < script_req_l_arr_.size(); i++) { + + for (int i=0; i < script_req_l_arr_.size(); i++) + { if ( r_l->equal_b (script_req_l_arr_[i])) return true; } - script_req_l_arr_.push (r_l->script()); - - return true; + script_req_l_arr_.push (r_l->script()); + + return true; } void Script_engraver::do_process_requests() { - for (int i=0; i < script_req_l_arr_.size(); i++){ + for (int i=0; i < script_req_l_arr_.size(); i++) + { Script_req* l=script_req_l_arr_[i]; Script *p =new Script; p->dir_i_ = l->dir_i_; @@ -47,19 +49,20 @@ Script_engraver::do_process_requests() void Script_engraver::do_pre_move_processing() { - Staff_symbol* s_l = get_staff_info().staff_sym_l_; - for (int i=0; i < script_p_arr_.size(); i++) { + Staff_symbol* s_l = get_staff_info().staff_sym_l_; + for (int i=0; i < script_p_arr_.size(); i++) + { Script*script_p = script_p_arr_[i]; script_p->set_staffsym (s_l); typeset_element (script_p); } - script_p_arr_.clear(); + script_p_arr_.clear(); } void Script_engraver::do_post_move_processing() { - script_req_l_arr_.clear(); + script_req_l_arr_.clear(); } diff --git a/lily/script.cc b/lily/script.cc index dbbda19724..e27086c40d 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -17,15 +17,16 @@ void Script::do_print() const { #ifndef NPRINT - specs_l_->print(); + specs_l_->print(); #endif } void Script::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Staff_side::do_substitute_dependency (o,n); - if (o == stem_l_) { + Staff_side::do_substitute_dependency (o,n); + if (o == stem_l_) + { stem_l_ = n ? (Stem*)n->item() : 0; } } @@ -33,69 +34,74 @@ Script::do_substitute_dependency (Score_elem*o,Score_elem*n) void Script::set_stem (Stem*st_l) { - stem_l_ = st_l; - add_support (st_l); + stem_l_ = st_l; + add_support (st_l); } Script::Script() { - specs_l_ = 0; - inside_staff_b_ = false; - stem_l_ = 0; - dir_i_ = 0; + specs_l_ = 0; + inside_staff_b_ = false; + stem_l_ = 0; + dir_i_ = 0; } void Script::set_default_dir() { - int s_i=specs_l_->rel_stem_dir_i(); - if (s_i) { + int s_i=specs_l_->rel_stem_dir_i(); + if (s_i) + { if (stem_l_) dir_i_ = stem_l_->dir_i_ * s_i; - else{ + else + { specs_l_->warning ("Script needs stem direction"); dir_i_ = -1; - } - } else { + } + } + else + { dir_i_ =specs_l_->staff_dir_i(); } - assert (dir_i_); + assert (dir_i_); } Interval Script::do_width() const { - return specs_l_->get_atom (paper(), dir_i_).extent ().x (); + return specs_l_->get_atom (paper(), dir_i_).extent ().x (); } void Script::do_pre_processing() { - if (breakable_b_ && break_status_i() != 1) { + if (breakable_b_ && break_status_i() != 1) + { transparent_b_ = empty_b_ = true; } - - if (!dir_i_) + + if (!dir_i_) set_default_dir(); - inside_staff_b_ = specs_l_->inside_b(); + inside_staff_b_ = specs_l_->inside_b(); } Interval Script::symbol_height()const { - return specs_l_->get_atom (paper(), dir_i_).extent ().y (); + return specs_l_->get_atom (paper(), dir_i_).extent ().y (); } Molecule* Script::brew_molecule_p() const { - Real dy = paper()->internote_f (); - - Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_i_)); - out->translate (dy * pos_i_, Y_AXIS); - return out; + Real dy = paper()->internote_f (); + + Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_i_)); + out->translate (dy * pos_i_, Y_AXIS); + return out; } @@ -104,6 +110,6 @@ IMPLEMENT_IS_TYPE_B2(Script,Item,Staff_side); int Script::compare (Script *const&l1, Script *const&l2) { - return l1->specs_l_->priority_i() - l2->specs_l_->priority_i (); + return l1->specs_l_->priority_i() - l2->specs_l_->priority_i (); } - + diff --git a/lily/slur-grav.cc b/lily/slur-grav.cc index 3c4b1814e7..1657e2e12a 100644 --- a/lily/slur-grav.cc +++ b/lily/slur-grav.cc @@ -15,18 +15,19 @@ bool Slur_engraver::do_try_request (Request *req_l) { - Musical_req *mus_l = req_l->musical(); - if (!mus_l || !mus_l->slur()) + Musical_req *mus_l = req_l->musical(); + if (!mus_l || !mus_l->slur()) return false; - new_slur_req_l_arr_.push (mus_l->slur()); - return true; + new_slur_req_l_arr_.push (mus_l->slur()); + return true; } void Slur_engraver::acknowledge_element (Score_elem_info info) { - if (info.elem_l_->name() == Note_column::static_name ()) { + if (info.elem_l_->name() == Note_column::static_name ()) + { Note_column *col_l =(Note_column*) info.elem_l_->item() ;// ugh for (int i = 0; i < slur_l_stack_.size(); i++) slur_l_stack_[i]->add (col_l); @@ -38,7 +39,7 @@ Slur_engraver::acknowledge_element (Score_elem_info info) void Slur_engraver::set_feature (Feature f) { - if (f.type_ == "vdir") + if (f.type_ == "vdir") dir_i_ = f.value_ ; } @@ -47,55 +48,62 @@ Slur_engraver::set_feature (Feature f) */ Slur_engraver::Slur_engraver() { - dir_i_ =0; + dir_i_ =0; } void Slur_engraver::do_process_requests() { - Array start_slur_l_arr_; - for (int i=0; i< new_slur_req_l_arr_.size(); i++) { + Array start_slur_l_arr_; + for (int i=0; i< new_slur_req_l_arr_.size(); i++) + { Slur_req* slur_req_l = new_slur_req_l_arr_[i]; // end slur: move the slur to other array - if (slur_req_l->spantype == Span_req::STOP) { + if (slur_req_l->spantype == Span_req::STOP) + { if (slur_l_stack_.empty()) slur_req_l->warning ("can't find slur to end"); - else { + else + { end_slur_l_arr_.push (slur_l_stack_.pop()); requests_arr_.pop(); - } - } else if (slur_req_l->spantype == Span_req::START) { + } + } + else if (slur_req_l->spantype == Span_req::START) + { // push a new slur onto stack. //(use temp. array to wait for all slur STOPs) Slur * s_p =new Slur; requests_arr_.push (slur_req_l); start_slur_l_arr_.push (s_p); announce_element (Score_elem_info (s_p, slur_req_l)); - } + } } - for (int i=0; i < start_slur_l_arr_.size(); i++) + for (int i=0; i < start_slur_l_arr_.size(); i++) slur_l_stack_.push (start_slur_l_arr_[i]); } void Slur_engraver::do_pre_move_processing() { - for (int i = 0; i < end_slur_l_arr_.size(); i++) { + for (int i = 0; i < end_slur_l_arr_.size(); i++) + { if (dir_i_) end_slur_l_arr_[i]->dir_i_ = dir_i_; typeset_element (end_slur_l_arr_[i]); } - end_slur_l_arr_.clear(); + end_slur_l_arr_.clear(); } void Slur_engraver::do_post_move_processing() { - new_slur_req_l_arr_.clear(); + new_slur_req_l_arr_.clear(); } Slur_engraver::~Slur_engraver() { - for (int i=0; i < requests_arr_.size(); i++) { + for (int i=0; i < requests_arr_.size(); i++) + { requests_arr_[i]->warning ("unterminated slur"); } } diff --git a/lily/slur.cc b/lily/slur.cc index bb49473129..54c5b5009d 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -30,35 +30,38 @@ void Slur::add (Note_column*n) { - encompass_arr_.push (n); - add_dependency (n); + encompass_arr_.push (n); + add_dependency (n); } void Slur::set_default_dir() { - dir_i_ = -1; - for (int i=0; i < encompass_arr_.size(); i ++) { - if (encompass_arr_[i]->dir_i_ < 0) { + dir_i_ = -1; + for (int i=0; i < encompass_arr_.size(); i ++) + { + if (encompass_arr_[i]->dir_i_ < 0) + { dir_i_ =1; break; - } + } } } void Slur::do_pre_processing() { - right_col_l_ = encompass_arr_.top()->pcol_l_; - left_col_l_ = encompass_arr_[0]->pcol_l_; + right_col_l_ = encompass_arr_.top()->pcol_l_; + left_col_l_ = encompass_arr_[0]->pcol_l_; } void Slur::do_substitute_dependency (Score_elem*o, Score_elem*n) { - int i; - while ((i = encompass_arr_.find_i ((Note_column*)o->item())) >=0) { + int i; + while ((i = encompass_arr_.find_i ((Note_column*)o->item())) >=0) + { if (n) encompass_arr_[i] = (Note_column*)n->item(); else @@ -70,29 +73,29 @@ Slur::do_substitute_dependency (Score_elem*o, Score_elem*n) static int Note_column_compare (Note_column *const&n1 , Note_column* const&n2) { - return n1->pcol_l_->rank_i() - n2->pcol_l_->rank_i (); + return n1->pcol_l_->rank_i() - n2->pcol_l_->rank_i (); } void Slur::do_post_processing() { - encompass_arr_.sort (Note_column_compare); - if (!dir_i_) + encompass_arr_.sort (Note_column_compare); + if (!dir_i_) set_default_dir(); - Real inter_f = paper()->internote_f (); - - if (encompass_arr_[0]->stem_l_) - left_pos_i_ = rint (encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f); - else - left_pos_i_ = rint ( encompass_arr_[0]->head_positions_interval()[dir_i_]); - - if (encompass_arr_.top()->stem_l_) - right_pos_i_ = rint (encompass_arr_.top()->stem_l_->height ()[dir_i_]/inter_f); - else - right_pos_i_ = rint (encompass_arr_.top()->head_positions_interval ()[dir_i_]); - - left_pos_i_ += dir_i_; - right_pos_i_ += dir_i_; + Real inter_f = paper()->internote_f (); + + if (encompass_arr_[0]->stem_l_) + left_pos_i_ = rint (encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f); + else + left_pos_i_ = rint ( encompass_arr_[0]->head_positions_interval()[dir_i_]); + + if (encompass_arr_.top()->stem_l_) + right_pos_i_ = rint (encompass_arr_.top()->stem_l_->height ()[dir_i_]/inter_f); + else + right_pos_i_ = rint (encompass_arr_.top()->head_positions_interval ()[dir_i_]); + + left_pos_i_ += dir_i_; + right_pos_i_ += dir_i_; } IMPLEMENT_IS_TYPE_B1(Slur,Spanner); diff --git a/lily/span-bar-grav.cc b/lily/span-bar-grav.cc index 737a4b92b9..cb7a592cf3 100644 --- a/lily/span-bar-grav.cc +++ b/lily/span-bar-grav.cc @@ -12,31 +12,34 @@ Span_bar_engraver::Span_bar_engraver() { - spanbar_p_ =0; - valign_l_ =0; + spanbar_p_ =0; + valign_l_ =0; } Span_bar* Span_bar_engraver::get_span_bar_p()const { - return new Span_bar; + return new Span_bar; } void Span_bar_engraver::acknowledge_element (Score_elem_info i) { - int depth = i.origin_grav_l_arr_.size(); - if ( depth > 1 + int depth = i.origin_grav_l_arr_.size(); + if ( depth > 1 && i.elem_l_->is_type_b (Bar::static_name()) ) - { + { bar_l_arr_.push ((Bar*)i.elem_l_->item()); - if (bar_l_arr_.size() >= 2 && !spanbar_p_) { + if (bar_l_arr_.size() >= 2 && !spanbar_p_) + { spanbar_p_ = get_span_bar_p(); announce_element (Score_elem_info (spanbar_p_,0)); - } - } else if (i.elem_l_->is_type_b (Vertical_align_spanner::static_name()) - && i.origin_grav_l_arr_.size() <= 2) { + } + } + else if (i.elem_l_->is_type_b (Vertical_align_spanner::static_name()) + && i.origin_grav_l_arr_.size() <= 2) + { valign_l_ = (Vertical_align_spanner*)i.elem_l_->spanner(); } } @@ -44,14 +47,15 @@ Span_bar_engraver::acknowledge_element (Score_elem_info i) void Span_bar_engraver::do_pre_move_processing() { - if (spanbar_p_) { + if (spanbar_p_) + { for (int i=0; i < bar_l_arr_.size() ; i++) spanbar_p_->add (bar_l_arr_[i]); spanbar_p_->set (valign_l_); typeset_element (spanbar_p_); spanbar_p_ =0; } - bar_l_arr_.set_size (0); + bar_l_arr_.set_size (0); } diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 08340ce390..152e9a7cd8 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -17,9 +17,9 @@ void Span_bar::add (Bar*b) { - b->spanned_i_ ++; - spanning_l_arr_.push (b); - add_dependency (b); + b->spanned_i_ ++; + spanning_l_arr_.push (b); + add_dependency (b); } @@ -27,67 +27,77 @@ Span_bar::add (Bar*b) void Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n) { - Bar * bold = 0; - if (o->is_type_b (Bar::static_name())) + Bar * bold = 0; + if (o->is_type_b (Bar::static_name())) bold = (Bar*)o->item(); - else + else return; - bold->spanned_i_ --; - Bar * b =0; - if (n && n->is_type_b (Bar::static_name())) { + bold->spanned_i_ --; + Bar * b =0; + if (n && n->is_type_b (Bar::static_name())) + { b = (Bar*)n->item(); b->spanned_i_ ++; } - - spanning_l_arr_.substitute (bold , b); + + spanning_l_arr_.substitute (bold , b); } void Span_bar::set (Vertical_align_element *a) { - add_dependency (a); + add_dependency (a); } - + Interval Span_bar::do_width() const { - return paper()->lookup_l ()->bar (type_str_, 40 PT).dim.x (); // ugh + return paper()->lookup_l ()->bar (type_str_, 40 PT).dim.x (); // ugh } void Span_bar::do_pre_processing() { - if ( spanning_l_arr_.size() < 1) { + if ( spanning_l_arr_.size() < 1) + { transparent_b_ = true; empty_b_ =true; - } else { + } + else + { if (type_str_ == "") type_str_ = spanning_l_arr_[0]->type_str_; - if (type_str_ =="") { + if (type_str_ =="") + { transparent_b_=true; empty_b_ = true; - } else if ( type_str_ == "|:") { + } + else if ( type_str_ == "|:") + { type_str_ = ".|"; - } else if ( type_str_ == ":|"){ + } + else if ( type_str_ == ":|") + { type_str_ = "|."; - } + } } } Symbol Span_bar::get_bar_sym (Real dy) const { - return paper()->lookup_l ()->bar (type_str_, dy); + return paper()->lookup_l ()->bar (type_str_, dy); } Molecule* Span_bar::brew_molecule_p()const { - Interval y_int; - for (int i=0; i < spanning_l_arr_.size(); i++) { + Interval y_int; + for (int i=0; i < spanning_l_arr_.size(); i++) + { Axis_group_element *common = common_group (spanning_l_arr_[i], Y_AXIS); @@ -97,10 +107,10 @@ Span_bar::brew_molecule_p()const y_int.unite (y + spanning_l_arr_[i]->height()); } - Symbol s = get_bar_sym (y_int.length()); - Molecule*output = new Molecule (Atom (s)); - output->translate ( y_int[-1], Y_AXIS); - return output; + Symbol s = get_bar_sym (y_int.length()); + Molecule*output = new Molecule (Atom (s)); + output->translate ( y_int[-1], Y_AXIS); + return output; } @@ -108,5 +118,5 @@ IMPLEMENT_IS_TYPE_B1(Span_bar,Bar); Span_bar::Span_bar() { - type_str_ = ""; + type_str_ = ""; } diff --git a/lily/span-score-bar-grav.cc b/lily/span-score-bar-grav.cc index 4afd1358d7..b09322c329 100644 --- a/lily/span-score-bar-grav.cc +++ b/lily/span-score-bar-grav.cc @@ -12,7 +12,7 @@ Span_bar* Span_score_bar_engraver::get_span_bar_p() const { - return new Span_score_bar; + return new Span_score_bar; } @@ -22,7 +22,7 @@ IMPLEMENT_IS_TYPE_B1(Piano_bar_engraver, Span_score_bar_engraver); Span_bar* Piano_bar_engraver::get_span_bar_p() const { - return new Piano_brace; + return new Piano_brace; } ADD_THIS_ENGRAVER(Piano_bar_engraver); diff --git a/lily/span-score-bar.cc b/lily/span-score-bar.cc index 35e34fe601..a7592d5320 100644 --- a/lily/span-score-bar.cc +++ b/lily/span-score-bar.cc @@ -13,15 +13,16 @@ Span_score_bar::Span_score_bar() { - type_str_ = "|"; + type_str_ = "|"; } void Span_score_bar::do_pre_processing() { - Span_bar::do_pre_processing(); - - if ( break_status_i() != 1) { + Span_bar::do_pre_processing(); + + if ( break_status_i() != 1) + { empty_b_ = transparent_b_ = true; } } @@ -30,16 +31,16 @@ Span_score_bar::do_pre_processing() Symbol Piano_brace::get_bar_sym (Real dy)const { - return paper()->lookup_l ()->vbrace (dy); + return paper()->lookup_l ()->vbrace (dy); } Interval Piano_brace::do_width()const { - return Interval (0,0); + return Interval (0,0); } IMPLEMENT_IS_TYPE_B1(Span_score_bar, Span_bar); IMPLEMENT_IS_TYPE_B1(Piano_brace, Span_score_bar); - + diff --git a/lily/spanner-elem-group.cc b/lily/spanner-elem-group.cc index d463c2889d..3eb1f94f77 100644 --- a/lily/spanner-elem-group.cc +++ b/lily/spanner-elem-group.cc @@ -16,15 +16,15 @@ IMPLEMENT_IS_TYPE_B2(Spanner_elem_group,Spanner,Horizontal_vertical_group_elemen Interval Spanner_elem_group::do_width() const { - return Spanner::do_width(); + return Spanner::do_width(); } void Spanner_elem_group::do_print() const { #ifndef NPRINT - Spanner::do_print(); - Horizontal_vertical_group_element::do_print(); + Spanner::do_print(); + Horizontal_vertical_group_element::do_print(); #endif } diff --git a/lily/spanner.cc b/lily/spanner.cc index 09ab9d73c0..eac107ba8d 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -18,17 +18,17 @@ void Spanner::do_print()const { #ifndef NPRINT - DOUT << "Between col "; - if ( left_col_l_) - DOUT << left_col_l_->rank_i(); - else + DOUT << "Between col "; + if ( left_col_l_) + DOUT << left_col_l_->rank_i(); + else DOUT << "nop"; - DOUT << ", "; - if ( right_col_l_) - DOUT << right_col_l_->rank_i(); - else + DOUT << ", "; + if ( right_col_l_) + DOUT << right_col_l_->rank_i(); + else DOUT << "nop"; - if (broken_into_l_arr_.size()) + if (broken_into_l_arr_.size()) DOUT << "with broken pieces\n"; #endif } @@ -36,22 +36,23 @@ Spanner::do_print()const void Spanner::break_into_pieces (bool copy_deps_b) { - if ( broken_into_l_arr_.size()) + if ( broken_into_l_arr_.size()) return; - PCol * left = left_col_l_; - PCol * right = right_col_l_; - if (left->daddy_l_) left = left->daddy_l_; - if (right->daddy_l_) right = right->daddy_l_; - - - Link_array break_cols = pscore_l_->broken_col_range (left,right); - Link_array broken_into_l_arr; - - break_cols.insert (left,0); - break_cols.push (right); - - for (int i=1; i < break_cols.size(); i++) { + PCol * left = left_col_l_; + PCol * right = right_col_l_; + if (left->daddy_l_) left = left->daddy_l_; + if (right->daddy_l_) right = right->daddy_l_; + + + Link_array break_cols = pscore_l_->broken_col_range (left,right); + Link_array broken_into_l_arr; + + break_cols.insert (left,0); + break_cols.push (right); + + for (int i=1; i < break_cols.size(); i++) + { Spanner* span_p = clone()->spanner (); if (copy_deps_b) span_p->copy_dependencies (*this); @@ -70,8 +71,8 @@ Spanner::break_into_pieces (bool copy_deps_b) pscore_l_->typeset_broken_spanner (span_p); broken_into_l_arr.push (span_p); } - - broken_into_l_arr_ = broken_into_l_arr; + + broken_into_l_arr_ = broken_into_l_arr; } void @@ -79,20 +80,23 @@ Spanner::set_my_columns() { if (!left_col_l_->line_l_) left_col_l_ = left_col_l_->postbreak_p_; - if (!right_col_l_->line_l_) + if (!right_col_l_->line_l_) right_col_l_ = right_col_l_->prebreak_p_; } void Spanner::do_break_processing() { - set_my_columns(); - - if (!line_l()) { + set_my_columns(); + + if (!line_l()) + { break_into_pieces (true); for (int i=0; i < broken_into_l_arr_.size(); i++) broken_into_l_arr_[i]->handle_broken_dependencies(); - } else { + } + else + { handle_broken_dependencies(); } } @@ -100,42 +104,42 @@ Spanner::do_break_processing() Spanner::Spanner() { - left_col_l_ = right_col_l_ = 0; + left_col_l_ = right_col_l_ = 0; } Interval Spanner::do_width()const { - Real r = right_col_l_->hpos_f_; - Real l = left_col_l_->hpos_f_; - assert (*left_col_l_ < *right_col_l_); - assert (r>=l); + Real r = right_col_l_->hpos_f_; + Real l = left_col_l_->hpos_f_; + assert (*left_col_l_ < *right_col_l_); + assert (r>=l); - return Interval (0, r-l); + return Interval (0, r-l); } Line_of_score * Spanner::line_l()const { - if ( left_col_l_->line_l_ != right_col_l_->line_l_) + if ( left_col_l_->line_l_ != right_col_l_->line_l_) return 0; - return left_col_l_->line_l_; + return left_col_l_->line_l_; } Spanner* Spanner::find_broken_piece (Line_of_score*l)const { - for (int i=0; i < broken_into_l_arr_.size(); i++) + for (int i=0; i < broken_into_l_arr_.size(); i++) if (broken_into_l_arr_[i]->line_l() == l) return broken_into_l_arr_[i]; - return 0; + return 0; } bool Spanner::broken_b()const { - return broken_into_l_arr_.size(); + return broken_into_l_arr_.size(); } diff --git a/lily/staff-info.cc b/lily/staff-info.cc index f1c4a9ab7f..0857fb9b55 100644 --- a/lily/staff-info.cc +++ b/lily/staff-info.cc @@ -14,45 +14,45 @@ Score* Staff_info::score_l() { - return score_l_; + return score_l_; } Staff_info::Staff_info() { - score_l_ =0; - c0_position_i_l_ = 0; - time_C_ = 0; - rhythmic_C_ =0; - break_allowed_b_ = 0; + score_l_ =0; + c0_position_i_l_ = 0; + time_C_ = 0; + rhythmic_C_ =0; + break_allowed_b_ = 0; } Score_column* Staff_info::musical_l() { - return musical_l_; + return musical_l_; } Score_column* Staff_info::command_l() { - return command_l_; + return command_l_; } PCol* Staff_info::command_pcol_l() { - return command_l(); + return command_l(); } PCol* Staff_info::musical_pcol_l() { - return musical_l(); + return musical_l(); } Moment Staff_info::when() { - return command_l()->when (); + return command_l()->when (); } diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 3bfb05286b..80bbf00a30 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -19,51 +19,55 @@ ADD_THIS_PERFORMER(Staff_performer); Staff_performer::Staff_performer() { - audio_staff_p_ = 0; + audio_staff_p_ = 0; } Staff_performer::~Staff_performer() { - delete audio_staff_p_; + delete audio_staff_p_; } void Staff_performer::do_creation_processing() { - audio_staff_p_ = new Audio_staff; + audio_staff_p_ = new Audio_staff; - // staff name - play (new Audio_text (Audio_text::TRACK_NAME, instrument_str())); - - // instrument description - play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str())); + if (instrument_str().length_i()) + { + // staff name + play (new Audio_text ( Audio_text::TRACK_NAME, instrument_str ())); + // instrument description + play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str ())); + } - // tempo - play (new Audio_tempo (get_tempo_i())); + // tempo + play(new Audio_tempo(get_tempo_i())); - // instrument - play (new Audio_instrument (instrument_str())); + if (instrument_str ().length_i ()) + // instrument + play (new Audio_instrument (instrument_str ())); } void Staff_performer::do_removal_processing() { - Performer::play (audio_staff_p_); - audio_staff_p_ = 0; + Performer::play (audio_staff_p_); + audio_staff_p_ = 0; } String Staff_performer::instrument_str() { - return Translator::id_str_; + return Translator::id_str_; } void Staff_performer::play (Audio_element* p) { - if (p->is_type_b (Audio_item::static_name())) { + if (p->is_type_b (Audio_item::static_name())) + { audio_staff_p_->add ((Audio_item*)p); } - Performer::play (p); + Performer::play (p); } diff --git a/lily/staff-side.cc b/lily/staff-side.cc index 704dc21ede..5d9bd748ab 100644 --- a/lily/staff-side.cc +++ b/lily/staff-side.cc @@ -16,98 +16,106 @@ void Staff_side::set_staffsym (Staff_symbol* s_l) { - staff_sym_l_ = s_l; - add_dependency (s_l); + staff_sym_l_ = s_l; + add_dependency (s_l); } Staff_side::Staff_side() { - pos_i_ =0; - sym_int_ = Interval (0,0); - staff_size_i_ = 0; - staff_sym_l_=0; - dir_i_ =0; - inside_staff_b_ =false; + pos_i_ =0; + sym_int_ = Interval (0,0); + staff_size_i_ = 0; + staff_sym_l_=0; + dir_i_ =0; + inside_staff_b_ =false; } void Staff_side::read_staff_sym() { - if (! staff_sym_l_) + if (! staff_sym_l_) return ; - staff_size_i_ = staff_sym_l_->steps_i(); + staff_size_i_ = staff_sym_l_->steps_i(); } Interval Staff_side::support_height() const { - Interval r; - - for (int i=0; i < support_l_arr_.size(); i++) + Interval r; + + for (int i=0; i < support_l_arr_.size(); i++) r.unite (support_l_arr_[i]->height()); - if (r.empty_b()) { + if (r.empty_b()) + { r = Interval (0,0); } - return r; + return r; } void Staff_side::add_support (Score_elem*i) { - support_l_arr_.push (i); - add_dependency (i); + support_l_arr_.push (i); + add_dependency (i); } int Staff_side::get_position_i()const { - if (!dir_i_) { + if (!dir_i_) + { warning ("Staff_side::get_position_i(): " "somebody forgot to set my vertical direction, returning -20"); return -20; } - + - Real y=0; - Real inter_f = paper()-> internote_f (); - if (!inside_staff_b_) { + Real y=0; + Real inter_f = paper()-> internote_f (); + if (!inside_staff_b_) + { y = (dir_i_ > 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2; y *=inter_f; Interval v= support_height(); - if (dir_i_ > 0) { + if (dir_i_ > 0) + { y = y >? (v.max() + 2*inter_f); - } else if (dir_i_ < 0) { + } + else if (dir_i_ < 0) + { y = y internote_f ())); } void Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n) { - support_l_arr_.unordered_substitute (o,n); - if (staff_sym_l_ == o) + support_l_arr_.unordered_substitute (o,n); + if (staff_sym_l_ == o) staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0; } diff --git a/lily/staff-sym-grav.cc b/lily/staff-sym-grav.cc index 5aff3e3536..6adfae1826 100644 --- a/lily/staff-sym-grav.cc +++ b/lily/staff-sym-grav.cc @@ -15,12 +15,12 @@ const NO_LINES = 5; void Staff_sym_engraver::fill_staff_info (Staff_info&i) { - i.staff_sym_l_ = span_p_; + i.staff_sym_l_ = span_p_; } Staff_sym_engraver::~Staff_sym_engraver() { - assert (!span_p_); + assert (!span_p_); } Staff_sym_engraver::Staff_sym_engraver() @@ -31,17 +31,17 @@ Staff_sym_engraver::Staff_sym_engraver() void Staff_sym_engraver::do_creation_processing() { - span_p_ = new Staff_symbol (NO_LINES); - span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh - announce_element (Score_elem_info (span_p_, 0)); + span_p_ = new Staff_symbol (NO_LINES); + span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh + announce_element (Score_elem_info (span_p_, 0)); } void Staff_sym_engraver::do_removal_processing() { - span_p_->right_col_l_ = get_staff_info().command_pcol_l (); - typeset_element (span_p_); - span_p_ =0; + span_p_->right_col_l_ = get_staff_info().command_pcol_l (); + typeset_element (span_p_); + span_p_ =0; } diff --git a/lily/staff-sym.cc b/lily/staff-sym.cc index 4e1a81d955..4542d2e3dc 100644 --- a/lily/staff-sym.cc +++ b/lily/staff-sym.cc @@ -15,7 +15,7 @@ Staff_symbol::Staff_symbol (int l) { - no_lines_i_ = l; + no_lines_i_ = l; } @@ -25,34 +25,34 @@ void Staff_symbol::do_print()const { #ifndef NPRINT - Spanner::do_print(); - DOUT << "lines: " << no_lines_i_; + Spanner::do_print(); + DOUT << "lines: " << no_lines_i_; #endif } Molecule* Staff_symbol::brew_molecule_p() const { - Atom a = paper()->lookup_l ()->linestaff (no_lines_i_, width ().length ()); - return new Molecule (a); + Atom a = paper()->lookup_l ()->linestaff (no_lines_i_, width ().length ()); + return new Molecule (a); } void Staff_symbol::set_extent (PCol*p1, PCol*p2) { - assert (p1&&p2); - left_col_l_ = p1; - right_col_l_ = p2; + assert (p1&&p2); + left_col_l_ = p1; + right_col_l_ = p2; } Real Staff_symbol::inter_note_f()const { - return paper()->internote_f (); + return paper()->internote_f (); } int Staff_symbol::steps_i() const { - return no_lines_i_*2; + return no_lines_i_*2; } diff --git a/lily/super-elem.cc b/lily/super-elem.cc index 5ca4a6c9c3..7ee2db3b9a 100644 --- a/lily/super-elem.cc +++ b/lily/super-elem.cc @@ -14,41 +14,42 @@ String Super_elem::TeX_string()const { - String s; - for (int i=0; i < lines_arr_.size(); i++){ + String s; + for (int i=0; i < lines_arr_.size(); i++) + { s += lines_arr_[i]->TeX_string(); if (i + 1get_lines(); - for (int i =0; i < lines_arr_.size(); i++) + lines_arr_ = line_of_score_l_->get_lines(); + for (int i =0; i < lines_arr_.size(); i++) add_dependency (lines_arr_[i]); } - + void Super_elem::do_substitute_dependency (Score_elem*o,Score_elem* n) { - if (line_of_score_l_ == o->spanner()) + if (line_of_score_l_ == o->spanner()) line_of_score_l_ = n?(Line_of_score*)n->spanner():0; } Super_elem::Super_elem() { - line_of_score_l_ = new Line_of_score ; + line_of_score_l_ = new Line_of_score ; } void Super_elem::do_add_processing() { - pscore_l_->typeset_unbroken_spanner (line_of_score_l_); - add_dependency (line_of_score_l_); + pscore_l_->typeset_unbroken_spanner (line_of_score_l_); + add_dependency (line_of_score_l_); } diff --git a/lily/swallow-grav.cc b/lily/swallow-grav.cc index 385cd55c44..84de4871b5 100644 --- a/lily/swallow-grav.cc +++ b/lily/swallow-grav.cc @@ -15,5 +15,5 @@ ADD_THIS_ENGRAVER(Swallow_engraver); bool Swallow_engraver::do_try_request (Request*) { - return true; + return true; } diff --git a/lily/symbol.cc b/lily/symbol.cc index a4c95b304e..2f7834b89c 100644 --- a/lily/symbol.cc +++ b/lily/symbol.cc @@ -3,19 +3,19 @@ Symbol::Symbol() - : dim (Interval (0,0),Interval (0,0)) + : dim (Interval (0,0),Interval (0,0)) { - tex = "\\unknown"; + tex = "\\unknown"; } Symbol::Symbol (String s, Box b) - : dim (b) + : dim (b) { - tex = s; + tex = s; } String Symbol::str()const { - return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))"; + return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))"; } diff --git a/lily/symtable.cc b/lily/symtable.cc index 35f4c4166e..92ef19852f 100644 --- a/lily/symtable.cc +++ b/lily/symtable.cc @@ -21,14 +21,16 @@ Symtables::Symtables() Symtables::Symtables (Symtables const &s) { - for (Assoc_iter i (s); i.ok(); i++) { + for (Assoc_iter i (s); i.ok(); i++) + { add (i.key(), new Symtable (*i.val ())); } } Symtables::~Symtables() { - for (Assoc_iter i (*this); i.ok(); i++) { + for (Assoc_iter i (*this); i.ok(); i++) + { delete i.val(); } } @@ -36,9 +38,10 @@ Symtables::~Symtables() Symbol Symtable::lookup (String s) const { - if (elt_b (s)) + if (elt_b (s)) return (*this)[s]; - else { + else + { warning ("Symtable `" + id_str+ "\': unknown symbol `" +s+"'\n"); Symbol sy; return sy; @@ -48,12 +51,13 @@ Symtable::lookup (String s) const Symtable* Symtables::operator()(String s) { - return Assoc::operator[](s); + return Assoc::operator[](s); } void Symtables::print() const { - for (Assoc_iter i (*this); i.ok(); i++) { + for (Assoc_iter i (*this); i.ok(); i++) + { DOUT << "table \'" << i.key() << "\' {\n"; i.val()->print (); DOUT << "}\n"; @@ -62,7 +66,8 @@ Symtables::print() const void Symtable::print() const { - for (Assoc_iter i (*this); i.ok(); i++) { + for (Assoc_iter i (*this); i.ok(); i++) + { DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n"; } } @@ -70,6 +75,6 @@ Symtable::print() const void Symtables::add (String s, Symtable*p) { - p-> id_str = s; - Assoc::add (s,p); + p-> id_str = s; + Assoc::add (s,p); } diff --git a/lily/template5.cc b/lily/template5.cc index bf7523d7d8..d038d3d31c 100644 --- a/lily/template5.cc +++ b/lily/template5.cc @@ -20,11 +20,11 @@ template INTERVAL__INSTANTIATE(int); Rational Interval_t::infinity() { - return Rational (INT_MAX); + return Rational (INT_MAX); } int Interval_t::infinity() { - return INT_MAX; + return INT_MAX; } diff --git a/lily/tex-beam.cc b/lily/tex-beam.cc index 6f835e204a..f20ded05e4 100644 --- a/lily/tex-beam.cc +++ b/lily/tex-beam.cc @@ -16,91 +16,95 @@ Symbol Lookup::beam_element (int sidx, int widx, Real slope) const { - Symbol bs=(*symtables_)("beamslopes")->lookup ("slope"); - - Array args; - args.push (sidx); - args.push (widx); - bs.tex = substitute_args (bs.tex,args); - int w = 2 << widx; - Real width = w PT; - bs.dim.x() = Interval (0,width); - bs.dim.y() = Interval (0,width*slope); - return bs; + Symbol bs=(*symtables_)("beamslopes")->lookup ("slope"); + + Array args; + args.push (sidx); + args.push (widx); + bs.tex = substitute_args (bs.tex,args); + int w = 2 << widx; + Real width = w PT; + bs.dim.x() = Interval (0,width); + bs.dim.y() = Interval (0,width*slope); + return bs; } // ugh.. hard wired tex-code. static int slope_index (Real &s) { - if (abs (s) > 0.5) { + if (abs (s) > 0.5) + { WARN << "beam steeper than 0.5 (" << s << ")\n"; s = sign (s) * 0.5; } - int i = int (rint (s * 20.0)); + int i = int (rint (s * 20.0)); - s = i/20.0; - if (s>0) + s = i/20.0; + if (s>0) return 6*i +122; - else + else return -6 * i+ 186; } Symbol Lookup::rule_symbol (Real height, Real width) const { - Symbol bs=(*symtables_)("beamslopes")->lookup ("horizontal"); - Array args; - args.push (print_dimen (height)); - args.push (print_dimen (width)); - bs.tex = substitute_args (bs.tex,args); - bs.dim.x() = Interval (0,width); - bs.dim.y() = Interval (0,height); - return bs; + Symbol bs=(*symtables_)("beamslopes")->lookup ("horizontal"); + Array args; + args.push (print_dimen (height)); + args.push (print_dimen (width)); + bs.tex = substitute_args (bs.tex,args); + bs.dim.x() = Interval (0,width); + bs.dim.y() = Interval (0,height); + return bs; } Symbol Lookup::beam (Real &slope, Real width) const { - int sidx = slope_index (slope); - if (!slope) + int sidx = slope_index (slope); + if (!slope) return rule_symbol (2 PT, width); - if (width < 2 PT) { + if (width < 2 PT) + { WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n"; width = 2 PT; } - Real elemwidth = 64 PT; - int widx = 5; + Real elemwidth = 64 PT; + int widx = 5; - Molecule m; - - while (elemwidth > width) { + Molecule m; + + while (elemwidth > width) + { widx --; elemwidth /= 2.0; } - Real overlap = elemwidth/4; - Real last_x = width - elemwidth; - Real x = overlap; - Atom elem (beam_element (sidx, widx, slope)); - Atom a (elem); - m.add (a); - while (x < last_x) { + Real overlap = elemwidth/4; + Real last_x = width - elemwidth; + Real x = overlap; + Atom elem (beam_element (sidx, widx, slope)); + Atom a (elem); + m.add (a); + while (x < last_x) + { a=elem; a.translate (Offset (x-overlap, (x-overlap)*slope)); m.add (a); x += elemwidth - overlap; } - a=elem; - a.translate (Offset (last_x, (last_x) * slope)); - m.add (a); - - Symbol ret; - ret.tex = m.TeX_string(); - ret.dim.y() = Interval (0,width*slope); - ret.dim.x() = Interval (0,width); - - return ret; + a=elem; + a.translate (Offset (last_x, (last_x) * slope)); + m.add (a); + + Symbol ret; + ret.tex = m.TeX_string(); + ret.dim.y() = Interval (0,width*slope); + ret.dim.x() = Interval (0,width); + + return ret; } diff --git a/lily/tex-slur.cc b/lily/tex-slur.cc index a8d30583c7..b494ec5c1a 100644 --- a/lily/tex-slur.cc +++ b/lily/tex-slur.cc @@ -19,204 +19,216 @@ static char direction_char (int y_sign) { - char c='#'; - switch (y_sign){ - case -1: + char c='#'; + switch (y_sign) + { + case -1: c = 'd'; break; - case 0: + case 0: c = 'h'; break; - case 1: + case 1: c = 'u'; break; - default: + default: assert (false); } - return c; + return c; } Symbol Lookup::half_slur_middlepart (Real &dx, int dir) const { - if (dx >= 400 PT) {// todo + if (dx >= 400 PT) {// todo WARN<<"halfslur too large" <= 96 PT) { + int widx; + + if (dx >= 96 PT) + { WARN << "Slur half too wide." << print_dimen (orig_dx) << " shrinking (ugh)\n"; dx = 96 PT; } - widx = int (rint (dx/12.0)); - dx = widx*12.0; - if (widx) + widx = int (rint (dx/12.0)); + dx = widx*12.0; + if (widx) widx --; - else { + else + { WARN << "slur too narrow " << print_dimen (orig_dx)<<"\n"; } - Symbol s; - s.dim.x() = Interval (0,dx); - s.dim.y() = Interval (min (0,dy), max (0,dy)); + Symbol s; + s.dim.x() = Interval (0,dx); + s.dim.y() = Interval (min (0,dy), max (0,dy)); - String f = String ("\\hslurchar"); + String f = String ("\\hslurchar"); - f+= direction_char (dir); + f+= direction_char (dir); - int hidx = dy; - if (hidx <0) + int hidx = dy; + if (hidx <0) hidx = -hidx; - hidx --; - int idx =-1; + hidx --; + int idx =-1; - idx = widx * 16 + hidx; - if (xpart < 0) + idx = widx * 16 + hidx; + if (xpart < 0) idx += 128; - - assert (idx < 256); - f+=String ("{") + String (idx ) + "}"; + + assert (idx < 256); + f+=String ("{") + String (idx ) + "}"; - - s.tex = f; + + s.tex = f; - return s; + return s; } Symbol Lookup::slur (int dy , Real &dx, int dir) const { - assert (dx >=0 && abs (dir) <= 1); - int y_sign = sign (dy); + assert (dx >=0 && abs (dir) <= 1); + int y_sign = sign (dy); - bool large = abs (dy) > 8; + bool large = abs (dy) > 8; - if (y_sign) { + if (y_sign) + { large |= dx>= 4*16 PT; - } else + } + else large |= dx>= 4*54 PT; - - if (large) { + + if (large) + { return big_slur (dy, dx, dir); } - Real orig_dx = dx; - int widx = int (floor (dx/4.0)); // slurs better too small.. - dx = 4.0 * widx; - if (widx) + Real orig_dx = dx; + int widx = int (floor (dx/4.0)); // slurs better too small.. + dx = 4.0 * widx; + if (widx) widx --; - else { + else + { WARN << "slur too narrow: " << print_dimen (orig_dx) << "\n"; } - int hidx = dy; - if (hidx <0) + int hidx = dy; + if (hidx <0) hidx = -hidx; - hidx --; - if (hidx > 8) { + hidx --; + if (hidx > 8) + { WARN<<"slur to steep: " << dy << " shrinking (ugh)\n"; } - - Symbol s; - s.dim.x() = Interval (0,dx); - s.dim.y() = Interval (min (0,dy), max (0,dy)); + + Symbol s; + s.dim.x() = Interval (0,dx); + s.dim.y() = Interval (min (0,dy), max (0,dy)); - String f = String ("\\slurchar") + String (direction_char (y_sign)); + String f = String ("\\slurchar") + String (direction_char (y_sign)); - int idx=-1; - if (y_sign) { + int idx=-1; + if (y_sign) { idx = hidx * 16 + widx; if (dir < 0) idx += 128; - } else { - if (dx >= 4*54 PT) { + } + else + { + if (dx >= 4*54 PT) + { WARN << "slur too wide: " << print_dimen (dx) << " shrinking (ugh)\n"; dx = 4*54 PT; - } + } idx = widx; if (dir < 0) idx += 54; } - - assert (idx < 256); - f+=String ("{") + String (idx ) + "}"; - s.tex = f; - - Atom a (s); - a.translate (dx/2, X_AXIS); - s.dim = a.extent(); - s.tex = a.TeX_string(); - return s; + + assert (idx < 256); + f+=String ("{") + String (idx ) + "}"; + s.tex = f; + + Atom a (s); + a.translate (dx/2, X_AXIS); + s.dim = a.extent(); + s.tex = a.TeX_string(); + return s; } Symbol Lookup::big_slur (int dy , Real &dx, int dir) const { - assert (dx >= 24 PT); - Real slur_extra =abs (dy) /2.0 + 2; - int l_dy = int (Real (dy)/2 + slur_extra*dir); - int r_dy = dy - l_dy; - - Real internote_f = paper_l_->internote_f(); - Real left_wid = dx/4.0; - Real right_wid = left_wid; - - Atom l = half_slur (l_dy, left_wid, dir, -1); - Atom r = half_slur (r_dy, right_wid, dir, 1); - Real mid_wid = dx - left_wid - right_wid; - - Atom m = half_slur (0, mid_wid, dir, 0); - - Molecule mol; - mol.add (l); - Atom a (m); - a.translate (slur_extra * internote_f, Y_AXIS); - mol.add_right (m); - mol.add_right (r); - mol.translate (l_dy * internote_f, Y_AXIS); - Symbol s; - s.tex = mol.TeX_string(); - s.dim = mol.extent(); - return s; + assert (dx >= 24 PT); + Real slur_extra =abs (dy) /2.0 + 2; + int l_dy = int (Real (dy)/2 + slur_extra*dir); + int r_dy = dy - l_dy; + + Real internote_f = paper_l_->internote_f(); + Real left_wid = dx/4.0; + Real right_wid = left_wid; + + Atom l = half_slur (l_dy, left_wid, dir, -1); + Atom r = half_slur (r_dy, right_wid, dir, 1); + Real mid_wid = dx - left_wid - right_wid; + + Atom m = half_slur (0, mid_wid, dir, 0); + + Molecule mol; + mol.add (l); + Atom a (m); + a.translate (slur_extra * internote_f, Y_AXIS); + mol.add_right (m); + mol.add_right (r); + mol.translate (l_dy * internote_f, Y_AXIS); + Symbol s; + s.tex = mol.TeX_string(); + s.dim = mol.extent(); + return s; } diff --git a/lily/tex-stream.cc b/lily/tex-stream.cc index ee08205c10..a9d826c3c7 100644 --- a/lily/tex-stream.cc +++ b/lily/tex-stream.cc @@ -24,42 +24,45 @@ const int MAXLINELEN = 200; Tex_stream::Tex_stream (String filename) { - os = new ofstream (filename); - if (!*os) + os = new ofstream (filename); + if (!*os) error ("can't open `" + filename+"\'"); - nest_level = 0; - line_len_i_ = 0; - outputting_comment=false; - header(); + nest_level = 0; + line_len_i_ = 0; + outputting_comment=false; + header(); } void Tex_stream::header() { - *os << "% Creator: " << get_version_str() << "\n"; - *os << "% Automatically generated, at "; - time_t t (time (0)); - *os << ctime (&t)<<"\n"; + *os << "% Creator: " << get_version_str() << "\n"; + *os << "% Automatically generated, at "; + time_t t (time (0)); + *os << ctime (&t)<<"\n"; } Tex_stream::~Tex_stream() { - delete os; - assert (nest_level == 0); + delete os; + assert (nest_level == 0); } // print string. don't forget indent. Tex_stream & Tex_stream::operator<<(String s) { - - for (char const *cp = s; *cp; cp++) { - if (outputting_comment) { + + for (char const *cp = s; *cp; cp++) + { + if (outputting_comment) + { *os << *cp; - if (*cp == '\n') { + if (*cp == '\n') + { outputting_comment=false; - } + } continue; - } + } line_len_i_ ++; switch (*cp) { @@ -75,10 +78,11 @@ Tex_stream::operator<<(String s) nest_level--; *os << *cp; - if (nest_level < 0) { + if (nest_level < 0) + { delete os; // we want to see the remains. assert (nest_level>=0); - } + } /* FALLTHROUGH */ case '\n': @@ -93,17 +97,17 @@ Tex_stream::operator<<(String s) default: *os << *cp; break; - } + } } - return *this; + return *this; } void Tex_stream::break_line() { - *os << "%\n"; - *os << String (' ', nest_level); - line_len_i_ = 0; + *os << "%\n"; + *os << String (' ', nest_level); + line_len_i_ = 0; } /* *************************************************************** */ diff --git a/lily/tex.cc b/lily/tex.cc index 6e5e987f5d..fb0348a051 100644 --- a/lily/tex.cc +++ b/lily/tex.cc @@ -14,40 +14,40 @@ String vstrut (Real h) { - return String ("\\vrule height ") + print_dimen (h) + "depth 0pt width 0pt"; + return String ("\\vrule height ") + print_dimen (h) + "depth 0pt width 0pt"; } static void substitute_arg (String& r, String arg) { - int p = r.index_i ('%'); - if (p < 0) + int p = r.index_i ('%'); + if (p < 0) return ; - r = r.left_str (p) + arg + r.right_str (r.length_i() - p -1); + r = r.left_str (p) + arg + r.right_str (r.length_i() - p -1); } String substitute_args (String source, Array args) { - String retval (source); - for (int i = 0 ; i < args.size(); i++) - substitute_arg (retval, args[i]); - /* - while (retval.index_i ('%') >= 0) - substitute_arg (retval, ""); + String retval (source); + for (int i = 0 ; i < args.size(); i++) + substitute_arg (retval, args[i]); + /* + while (retval.index_i ('%') >= 0) + substitute_arg (retval, ""); */ - return retval; + return retval; } String substitute_args (String source, Array args) { - Array sv; - for (int i = 0 ; i < args.size(); i++) + Array sv; + for (int i = 0 ; i < args.size(); i++) sv.push (args[i]); - - return substitute_args (source, sv); + + return substitute_args (source, sv); } diff --git a/lily/text-def.cc b/lily/text-def.cc index e0de0eb79b..a2ce8730cf 100644 --- a/lily/text-def.cc +++ b/lily/text-def.cc @@ -16,46 +16,46 @@ Interval Text_def::width (Paper_def * p) const { - Atom a = get_atom (p,0); + Atom a = get_atom (p,0); - Real guess_width_f = text_str_.length_i() * a.sym_.dim.x ().length (); // ugh - Interval i (0, guess_width_f); - i += - (align_i_ + 1)* i.center(); - return i; + Real guess_width_f = text_str_.length_i() * a.sym_.dim.x ().length (); // ugh + Interval i (0, guess_width_f); + i += - (align_i_ + 1)* i.center(); + return i; } void Text_def::do_print() const { #ifndef NPRINT - DOUT << "align " <align_i_ && text_str_ == def->text_str_ + Text_def const *def= (Text_def*)gdef; + return align_i_ == def->align_i_ && text_str_ == def->text_str_ && style_str_ == def->style_str_; } Atom Text_def::get_atom (Paper_def *p, int) const { - return p->lookup_l()->text (style_str_, text_str_, -align_i_); + return p->lookup_l()->text (style_str_, text_str_, -align_i_); } void Text_def::print() const { - DOUT << "Text `" << text_str_ << "\', style " << + DOUT << "Text `" << text_str_ << "\', style " << style_str_ << "align " << align_i_ << '\n'; } diff --git a/lily/text-grav.cc b/lily/text-grav.cc index 3165fc87a9..4abff4f444 100644 --- a/lily/text-grav.cc +++ b/lily/text-grav.cc @@ -12,34 +12,36 @@ Text_engraver::Text_engraver() { - text_p_ = 0; - dir_i_ =0; - do_post_move_processing(); + text_p_ = 0; + dir_i_ =0; + do_post_move_processing(); } bool Text_engraver::do_try_request (Request*req_l) { - Musical_req *m = req_l->musical(); - if (!m || ! m->text()) + Musical_req *m = req_l->musical(); + if (!m || ! m->text()) return false; - if (text_req_l_ && text_req_l_->equal_b (m)) + if (text_req_l_ && text_req_l_->equal_b (m)) return false; - text_req_l_ = m->text(); - return true; + text_req_l_ = m->text(); + return true; } void Text_engraver::acknowledge_element (Score_elem_info i) { - if (text_p_ && i.elem_l_->name() == Note_column::static_name ()) { + if (text_p_ && i.elem_l_->name() == Note_column::static_name ()) + { text_p_->add_support (i.elem_l_); } } void Text_engraver::do_process_requests() { - if (text_req_l_) { + if (text_req_l_) + { text_p_ = new Text_item (text_req_l_->tdef_p_, text_req_l_->dir_i_); // ugh announce_element (Score_elem_info (text_p_, text_req_l_)); } @@ -47,7 +49,8 @@ Text_engraver::do_process_requests() void Text_engraver::do_pre_move_processing() { - if (text_p_) { + if (text_p_) + { if (dir_i_ && !text_p_->dir_i_) text_p_->dir_i_ = dir_i_; Staff_symbol* s_l = get_staff_info().staff_sym_l_; @@ -60,13 +63,13 @@ Text_engraver::do_pre_move_processing() void Text_engraver::set_feature (Feature i) { - if (i.type_ == "vdir") + if (i.type_ == "vdir") dir_i_ = i.value_; } void Text_engraver::do_post_move_processing() { - text_req_l_ = 0; + text_req_l_ = 0; } IMPLEMENT_IS_TYPE_B1(Text_engraver,Engraver); diff --git a/lily/text-item.cc b/lily/text-item.cc index 951976a16a..db87a8d152 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -16,45 +16,45 @@ Text_item::Text_item (General_script_def*tdef_l, int d) { - dir_i_ = d; - fat_b_ = false; - tdef_p_ = tdef_l->clone(); + dir_i_ = d; + fat_b_ = false; + tdef_p_ = tdef_l->clone(); } Text_item::~Text_item() { - delete tdef_p_; + delete tdef_p_; } void Text_item::do_pre_processing() { - if (!dir_i_) + if (!dir_i_) dir_i_ = -1; } Interval Text_item::symbol_height()const { - return tdef_p_->get_atom (paper(), dir_i_).sym_.dim.y (); + return tdef_p_->get_atom (paper(), dir_i_).sym_.dim.y (); } - + Molecule* Text_item::brew_molecule_p() const { - Atom a (tdef_p_->get_atom (paper(), dir_i_)); + Atom a (tdef_p_->get_atom (paper(), dir_i_)); /* if ( fat_b_) a.sym.dim.x = tdef_p_->width (paper()); */ - Molecule* mol_p = new Molecule (a); + Molecule* mol_p = new Molecule (a); - if (dir_i_<0) // should do something better anyway. + if (dir_i_<0) // should do something better anyway. mol_p->translate (-mol_p->extent().y ().left , Y_AXIS); - mol_p->translate (pos_i_ * paper()->internote_f (), Y_AXIS); - - return mol_p; + mol_p->translate (pos_i_ * paper()->internote_f (), Y_AXIS); + + return mol_p; } diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 0e6226bf1f..1ab46bbb62 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -18,17 +18,17 @@ void Text_spanner::set_support (Directional_spanner*d) { - if (support_span_l_) + if (support_span_l_) remove_dependency (support_span_l_); - - support_span_l_ =d; - add_dependency (d); + + support_span_l_ =d; + add_dependency (d); } Text_spanner::Text_spanner() { - spec_p_ = 0; - support_span_l_ = 0; + spec_p_ = 0; + support_span_l_ = 0; } @@ -37,58 +37,58 @@ IMPLEMENT_IS_TYPE_B1(Text_spanner,Spanner); void Text_spanner::do_print() const { - spec_p_->print(); + spec_p_->print(); } void Text_spanner::do_post_processing() { - text_off_ = support_span_l_->center() + + text_off_ = support_span_l_->center() + Offset (0,support_span_l_->dir_i_ * paper()->internote_f () * 4); // todo } Molecule* Text_spanner::brew_molecule_p() const { - Atom tsym (spec_p_->get_atom (paper(),0)); - tsym.translate (text_off_); + Atom tsym (spec_p_->get_atom (paper(),0)); + tsym.translate (text_off_); - Molecule*output = new Molecule; - output->add (tsym); - return output; + Molecule*output = new Molecule; + output->add (tsym); + return output; } void Text_spanner::do_pre_processing() { - right_col_l_ = support_span_l_->right_col_l_; - left_col_l_ = support_span_l_->left_col_l_; - assert (left_col_l_ && right_col_l_); + right_col_l_ = support_span_l_->right_col_l_; + left_col_l_ = support_span_l_->left_col_l_; + assert (left_col_l_ && right_col_l_); } Interval Text_spanner::height()const { - return brew_molecule_p()->extent ().y (); + return brew_molecule_p()->extent ().y (); } void Text_spanner::do_substitute_dependency (Score_elem* o, Score_elem*n) { - if (support_span_l_ == o) + if (support_span_l_ == o) support_span_l_ = (Directional_spanner*) (n?n->spanner():0); } Text_spanner::~Text_spanner() { - delete spec_p_; + delete spec_p_; } Text_spanner::Text_spanner (Text_spanner const&s) - : Spanner (s) + : Spanner (s) { - support_span_l_ = s.support_span_l_; - spec_p_ = s.spec_p_? s.spec_p_->clone() : 0; - text_off_ = s.text_off_; + support_span_l_ = s.support_span_l_; + spec_p_ = s.spec_p_? s.spec_p_->clone() : 0; + text_off_ = s.text_off_; } diff --git a/lily/tie-grav.cc b/lily/tie-grav.cc index cbe5f35f7b..660d1da948 100644 --- a/lily/tie-grav.cc +++ b/lily/tie-grav.cc @@ -14,27 +14,28 @@ Tie_engraver::Tie_engraver() { - end_tie_p_ = 0; - tie_p_ = 0; - req_l_ =0; - end_req_l_ =0; - end_mom_ = -1; - melodic_req_l_ = 0; - end_melodic_req_l_ =0; - dir_i_ = 0; + end_tie_p_ = 0; + tie_p_ = 0; + req_l_ =0; + end_req_l_ =0; + end_mom_ = -1; + melodic_req_l_ = 0; + end_melodic_req_l_ =0; + dir_i_ = 0; } void Tie_engraver::sync_features() { - dir_i_ = get_feature ("vdir"); + dir_i_ = get_feature ("vdir"); } - + void Tie_engraver::do_post_move_processing() { - if (tie_p_ && get_staff_info().when () == end_mom_) { + if (tie_p_ && get_staff_info().when () == end_mom_) + { end_tie_p_ = tie_p_; end_req_l_ = req_l_; end_melodic_req_l_ = melodic_req_l_; @@ -47,27 +48,29 @@ Tie_engraver::do_post_move_processing() bool Tie_engraver::acceptable_request_b (Request*r) { - return r->musical() && r->musical ()->tie (); + return r->musical() && r->musical ()->tie (); } bool Tie_engraver::do_try_request (Request*r) { - if (!acceptable_request_b (r)) + if (!acceptable_request_b (r)) return false; - if (req_l_) { + if (req_l_) + { return false; } - req_l_ = r->musical()->tie (); - end_mom_ = r->parent_music_l_->time_int().length () + req_l_ = r->musical()->tie (); + end_mom_ = r->parent_music_l_->time_int().length () + get_staff_info().when (); - return true; + return true; } void Tie_engraver::do_process_requests() { - if (req_l_ && ! tie_p_) { + if (req_l_ && ! tie_p_) + { tie_p_ = new Tie; } } @@ -75,25 +78,29 @@ Tie_engraver::do_process_requests() void Tie_engraver::acknowledge_element (Score_elem_info i) { - if (i.elem_l_->name() == Note_head::static_name ()) { - if (tie_p_) { + if (i.elem_l_->name() == Note_head::static_name ()) + { + if (tie_p_) + { tie_p_->set_head (-1, (Note_head*)i.elem_l_->item()); melodic_req_l_ = i.req_l_->musical()->melodic (); - } + } - if (end_tie_p_) { + if (end_tie_p_) + { end_tie_p_->set_head (1, (Note_head*)i.elem_l_->item()); if (!Melodic_req::compare ( *end_melodic_req_l_, *melodic_req_l_)) end_tie_p_->same_pitch_b_ = true; announce_element (Score_elem_info (end_tie_p_,end_req_l_)); - } + } } } void Tie_engraver::do_pre_move_processing() { - if (end_tie_p_) { + if (end_tie_p_) + { if (dir_i_) end_tie_p_->dir_i_ = dir_i_; @@ -106,7 +113,8 @@ Tie_engraver::do_pre_move_processing() Tie_engraver::~Tie_engraver() { - if (tie_p_) { + if (tie_p_) + { req_l_->warning ("unended Tie"); delete tie_p_; } @@ -115,7 +123,7 @@ Tie_engraver::~Tie_engraver() void Tie_engraver::set_feature (Feature f) { - if (f.type_ == "vdir") + if (f.type_ == "vdir") dir_i_ = f.value_; } diff --git a/lily/tie.cc b/lily/tie.cc index 5daf0614d7..ba7d75a3b8 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -15,37 +15,40 @@ void Tie::set_head (int x_pos, Note_head * head_l) { - if (x_pos >0) { + if (x_pos >0) + { assert (!right_head_l_); right_head_l_ = head_l; - } else { + } + else + { assert (!left_head_l_); left_head_l_ = head_l; } - add_dependency (head_l); + add_dependency (head_l); } Tie::Tie() { - right_head_l_ =0; - left_head_l_ =0; - same_pitch_b_ =false; + right_head_l_ =0; + left_head_l_ =0; + same_pitch_b_ =false; } void Tie::set_default_dir() { - int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ; - dir_i_ = (m < 5)? -1:1; // ugh + int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ; + dir_i_ = (m < 5)? -1:1; // ugh } - + void Tie::do_add_processing() { - assert (left_head_l_ && right_head_l_); - left_col_l_ = left_head_l_ -> pcol_l_; - right_col_l_ = right_head_l_ -> pcol_l_; + assert (left_head_l_ && right_head_l_); + left_col_l_ = left_head_l_ -> pcol_l_; + right_col_l_ = right_head_l_ -> pcol_l_; } /** @@ -54,27 +57,31 @@ Tie::do_add_processing() void Tie::do_post_processing() { - assert (left_head_l_ || right_head_l_); - left_pos_i_ = (left_head_l_)? + assert (left_head_l_ || right_head_l_); + left_pos_i_ = (left_head_l_)? left_head_l_->position_i_ : right_head_l_->position_i_; - right_pos_i_ = (right_head_l_) ? + right_pos_i_ = (right_head_l_) ? right_head_l_->position_i_ : left_head_l_->position_i_; - if ( right_head_l_ && right_head_l_->extremal_i_) { + if ( right_head_l_ && right_head_l_->extremal_i_) + { right_pos_i_ += 2*dir_i_; right_dx_f_ -= 0.25; - } else + } + else right_dx_f_ -= 0.5; - if (left_head_l_ && left_head_l_->extremal_i_) { + if (left_head_l_ && left_head_l_->extremal_i_) + { left_pos_i_ += 2*dir_i_; left_dx_f_ += 0.25; - } else + } + else left_dx_f_ += 0.5; - - if (!right_head_l_) + + if (!right_head_l_) right_pos_i_ = left_pos_i_; - if (! left_head_l_) + if (! left_head_l_) left_pos_i_ = right_pos_i_; } @@ -83,10 +90,10 @@ Tie::do_post_processing() void Tie::do_substitute_dependency (Score_elem*o, Score_elem*n) { - Note_head *new_l =n?(Note_head*)n->item():0; - if (o->item() == left_head_l_) + Note_head *new_l =n?(Note_head*)n->item():0; + if (o->item() == left_head_l_) left_head_l_ = new_l; - else if (o->item() == right_head_l_) + else if (o->item() == right_head_l_) right_head_l_ = new_l; } diff --git a/lily/time-description.cc b/lily/time-description.cc index dd8c5616d9..b60d007ede 100644 --- a/lily/time-description.cc +++ b/lily/time-description.cc @@ -12,66 +12,69 @@ String Time_description::str()const { - String s ("Time_description { "); - if (cadenza_b_) + String s ("Time_description { "); + if (cadenza_b_) s+=String (" (cadenza) "); - s+= "at "; - s+=when_; - s+="\nmeter " + String (whole_per_measure_/one_beat_) +":" + + s+= "at "; + s+=when_; + s+="\nmeter " + String (whole_per_measure_/one_beat_) +":" + String (Rational (Rational (1)/one_beat_)); - s+= "\nposition "+String (bars_i_) + ":"+ whole_in_measure_ +"\n}\n"; - return s; + s+= "\nposition "+String (bars_i_) + ":"+ whole_in_measure_ +"\n}\n"; + return s; } void Time_description::print() const { #ifndef NPRINT - DOUT << str(); + DOUT << str(); #endif } void Time_description::OK() const { #ifndef NDEBUG - if (!cadenza_b_) + if (!cadenza_b_) assert (whole_in_measure_ < whole_per_measure_); - assert (Moment (0) <= whole_in_measure_); - assert (one_beat_); + assert (Moment (0) <= whole_in_measure_); + assert (one_beat_); #endif } void Time_description::set_cadenza (bool b) { - if (cadenza_b_ && !b) { - if (whole_in_measure_) { + if (cadenza_b_ && !b) + { + if (whole_in_measure_) + { bars_i_ ++; // should do? whole_in_measure_ = 0; - } + } } - cadenza_b_ = b ; + cadenza_b_ = b ; } Time_description::Time_description() { - error_b_ = false; - whole_per_measure_ = 1; - whole_in_measure_ =0; - one_beat_ = Moment (1,4); - when_ = 0; - bars_i_ = 0; - cadenza_b_ = false; + error_b_ = false; + whole_per_measure_ = 1; + whole_in_measure_ =0; + one_beat_ = Moment (1,4); + when_ = 0; + bars_i_ = 0; + cadenza_b_ = false; } void Time_description::add (Moment dt) { - assert (dt >= Rational (0)); - when_ += dt; - whole_in_measure_ += dt; + assert (dt >= Rational (0)); + when_ += dt; + whole_in_measure_ += dt; - while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_) { + while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_) + { whole_in_measure_ -= whole_per_measure_; bars_i_ ++; } @@ -80,15 +83,15 @@ Time_description::add (Moment dt) void Time_description::set_meter (int l, int o) { - assert (o); - one_beat_ = Rational (1)/Moment (o); - whole_per_measure_ = Moment (l) * one_beat_; + assert (o); + one_beat_ = Rational (1)/Moment (o); + whole_per_measure_ = Moment (l) * one_beat_; } bool Time_description::allow_meter_change_b() { - return!(whole_in_measure_); + return!(whole_in_measure_); } /** @@ -99,44 +102,45 @@ Time_description::allow_meter_change_b() String Time_description::try_set_partial_str (Moment p)const { - if (p whole_per_measure_) + if (p > whole_per_measure_) return ("Partial measure too large"); - return ""; + return ""; } void Time_description::setpartial (Moment p) { - whole_in_measure_ = whole_per_measure_ - p; + whole_in_measure_ = whole_per_measure_ - p; } Moment Time_description::barleft()const { - assert (!cadenza_b_); - return whole_per_measure_-whole_in_measure_; + assert (!cadenza_b_); + return whole_per_measure_-whole_in_measure_; } int Time_description::compare (Time_description const &t1, Time_description const&t2) { - int i = sign (t1.when_-t2.when_); + int i = sign (t1.when_-t2.when_); - if (!i) { + if (!i) + { assert (t1.bars_i_==t2.bars_i_); assert (t1.one_beat_ == t2.one_beat_); assert (t1.whole_in_measure_ == t2.whole_in_measure_); assert (t1.whole_per_measure_ == t2.whole_per_measure_); } - return i; + return i; } Moment Time_description::next_bar_moment() const { - return when_ + barleft(); + return when_ + barleft(); } diff --git a/lily/timing-grav.cc b/lily/timing-grav.cc index d86cf2c9bb..251c806536 100644 --- a/lily/timing-grav.cc +++ b/lily/timing-grav.cc @@ -13,14 +13,14 @@ Timing_engraver::Timing_engraver() { - default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh + default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh } void Timing_engraver::fill_staff_info (Staff_info &inf) { - inf.time_C_ = &time_; - inf.rhythmic_C_ = &default_grouping_; + inf.time_C_ = &time_; + inf.rhythmic_C_ = &default_grouping_; } diff --git a/lily/translator.cc b/lily/translator.cc index eda6e50e0c..b902387529 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -10,7 +10,7 @@ Translator::Translator() { - iterator_count_ = 0; + iterator_count_ = 0; } @@ -19,7 +19,7 @@ IMPLEMENT_IS_TYPE_B(Translator); bool Translator::try_request (Request*) { - return false; + return false; } diff --git a/lily/version.cc b/lily/version.cc index eed3e39ca8..c219dfcd61 100644 --- a/lily/version.cc +++ b/lily/version.cc @@ -7,8 +7,8 @@ extern char const * lily_version_sz(); String get_version_str() { - String s = lily_version_sz(); - s+="/"; - s+=flower_version_sz(); + String s = lily_version_sz(); + s+="/"; + s+=flower_version_sz(); return s; } diff --git a/lily/vertical-align-elem.cc b/lily/vertical-align-elem.cc index 33d191f901..2ddc1a29c6 100644 --- a/lily/vertical-align-elem.cc +++ b/lily/vertical-align-elem.cc @@ -12,16 +12,16 @@ void Vertical_align_element::add (Score_elem*el_l) { - assert (! contains_b (el_l)); - elem_l_arr_.push (el_l); - add_dependency (el_l); + assert (! contains_b (el_l)); + elem_l_arr_.push (el_l); + add_dependency (el_l); } void Vertical_align_element::do_substitute_dependency (Score_elem*o,Score_elem*n) { - int i; - while ((i = elem_l_arr_.find_i (o))>=0) + int i; + while ((i = elem_l_arr_.find_i (o))>=0) if (n) elem_l_arr_[i] = n; else @@ -37,8 +37,9 @@ Vertical_align_element::do_substitute_dependency (Score_elem*o,Score_elem*n) void Vertical_align_element::do_post_processing() { - Array dims; - for (int i=0; i < elem_l_arr_.size(); i++) { + Array dims; + for (int i=0; i < elem_l_arr_.size(); i++) + { Interval y = elem_l_arr_[i]->height() ; if (y.empty_b()) y = Interval (0,0); @@ -46,8 +47,9 @@ Vertical_align_element::do_post_processing() dims.push (y); } - Real where_f=0; - for ( int i=0 ; i < elem_l_arr_.size(); i++) { + Real where_f=0; + for ( int i=0 ; i < elem_l_arr_.size(); i++) + { elem_l_arr_[i]->translate (- dims[i][1] - where_f, Y_AXIS); where_f += dims[i].length(); } @@ -56,13 +58,13 @@ Vertical_align_element::do_post_processing() bool Vertical_align_element::contains_b (Score_elem const *e)const { - return elem_l_arr_.find_l (e); + return elem_l_arr_.find_l (e); } Vertical_align_element::Vertical_align_element() { - transparent_b_ = true; - empty_b_ =true; + transparent_b_ = true; + empty_b_ =true; } diff --git a/lily/vertical-align-grav.cc b/lily/vertical-align-grav.cc index b2f3218ee0..dcaaf028bd 100644 --- a/lily/vertical-align-grav.cc +++ b/lily/vertical-align-grav.cc @@ -12,31 +12,32 @@ Vertical_align_engraver::Vertical_align_engraver() { - valign_p_ =0; + valign_p_ =0; } void Vertical_align_engraver::do_creation_processing() { - valign_p_ =new Vertical_align_spanner; - valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ; - announce_element (Score_elem_info (valign_p_ , 0)); + valign_p_ =new Vertical_align_spanner; + valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ; + announce_element (Score_elem_info (valign_p_ , 0)); } void Vertical_align_engraver::do_removal_processing() { - valign_p_->right_col_l_ = get_staff_info().command_pcol_l (); - typeset_element (valign_p_); - valign_p_ =0; + valign_p_->right_col_l_ = get_staff_info().command_pcol_l (); + typeset_element (valign_p_); + valign_p_ =0; } void Vertical_align_engraver::acknowledge_element (Score_elem_info i) { - if ( i.origin_grav_l_arr_.size() == 2 && + if ( i.origin_grav_l_arr_.size() == 2 && i.elem_l_->is_type_b (Vertical_group_element::static_name()) && - !i.elem_l_->axis_group_l_a_[Y_AXIS] ) { + !i.elem_l_->axis_group_l_a_[Y_AXIS] ) + { assert (!valign_p_->contains_b (i.elem_l_)); valign_p_->add ( i.elem_l_); diff --git a/lily/voice-group-gravs.cc b/lily/voice-group-gravs.cc index 24e448582d..66235afb14 100644 --- a/lily/voice-group-gravs.cc +++ b/lily/voice-group-gravs.cc @@ -16,21 +16,22 @@ Voice_group_engravers::Voice_group_engravers() { - dir_i_ =0; + dir_i_ =0; } bool Voice_group_engravers::do_try_request (Request*r_l) { - Command_req* c_l = r_l->command(); - if (c_l&& c_l->groupfeature()) { + Command_req* c_l = r_l->command(); + if (c_l&& c_l->groupfeature()) + { Feature f; f.type_ = c_l->groupfeature()->type_str_; f.value_ = c_l->groupfeature()->value_str_; set_feature (f); return true; } - return Engraver_group_engraver::do_try_request (r_l); + return Engraver_group_engraver::do_try_request (r_l); } @@ -41,7 +42,7 @@ void Voice_group_engravers::do_print() const { #ifndef NPRINT - Engraver_group_engraver::do_print(); + Engraver_group_engraver::do_print(); #endif } @@ -50,9 +51,9 @@ Voice_group_engravers::do_print() const Scalar Voice_group_engravers::get_feature (String f) { - if (f == "vdir") + if (f == "vdir") return dir_i_; - Engraver_group_engraver::get_feature (f); + Engraver_group_engraver::get_feature (f); } ADD_THIS_ENGRAVER(Voice_group_engravers); diff --git a/lily/warn.cc b/lily/warn.cc index 02707c67c7..0dcee118ab 100644 --- a/lily/warn.cc +++ b/lily/warn.cc @@ -25,14 +25,14 @@ ostream *mlog (&cerr); void error_t (String const & s, Moment const & r) { - String t_mom = String (trunc (r)) + String (r - Moment (trunc (r))); - String e=s+ " (t = " + t_mom + ")"; - error (e); + String t_mom = String (trunc (r)) + String (r - Moment (trunc (r))); + String e=s+ " (t = " + t_mom + ")"; + error (e); } void error_t (String const & s, Time_description const &t_tdes) { - String e=s+ " (at t=" + String (t_tdes.bars_i_) + ": " + String (t_tdes.whole_in_measure_) + ")\n"; - error (e); + String e=s+ " (at t=" + String (t_tdes.bars_i_) + ": " + String (t_tdes.whole_in_measure_) + ")\n"; + error (e); } diff --git a/lily/word-wrap.cc b/lily/word-wrap.cc index 4a0f9ffff7..beddf0d753 100644 --- a/lily/word-wrap.cc +++ b/lily/word-wrap.cc @@ -23,79 +23,89 @@ Array Word_wrap::do_solve()const { - problem_OK(); - - PCursor curcol (pscore_l_->col_p_list_.top()); - Array breaking; - Line_of_cols breakpoints (find_breaks()); - assert (breakpoints.size()>=2); - - int break_idx_i=0; - while ( break_idx_i < breakpoints.size() -1) { + problem_OK(); + + PCursor curcol (pscore_l_->col_p_list_.top()); + Array breaking; + Line_of_cols breakpoints (find_breaks()); + assert (breakpoints.size()>=2); + + int break_idx_i=0; + while ( break_idx_i < breakpoints.size() -1) + { Col_hpositions minimum; Col_hpositions current; - // do another line + // do another line PCol *post = breakpoints[break_idx_i]->postbreak_p_; current.add (post); curcol++; // skip the breakable. break_idx_i++; - while (break_idx_i < breakpoints.size()) { + while (break_idx_i < breakpoints.size()) + { // add another measure. - while (breakpoints[break_idx_i] != curcol.ptr()){ + while (breakpoints[break_idx_i] != curcol.ptr()) + { current.add (curcol); curcol++; - } + } current.add (breakpoints[break_idx_i]->prebreak_p_); current.spacer_l_ = generate_spacing_problem (current.cols); // try to solve - if (!feasible (current.cols)) { - if (!minimum.cols.size()) { + if (!feasible (current.cols)) + { + if (!minimum.cols.size()) + { warning ("Ugh, this measure is too long, breakpoint: " + String (break_idx_i) + " (generating stupido solution)"); current.stupid_solution(); current.energy_f_ = - 1; // make sure we break out. - } else + } + else current.energy_f_ = infinity_f; // make sure we go back - } else { + } + else + { current.solve_line(); current.print(); - } + } delete current.spacer_l_; current.spacer_l_ =0; // update minimum, or backup. - if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0) { + if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0) + { minimum = current; - } else { // we're one col too far. + } + else { // we're one col too far. break_idx_i--; while (curcol.ptr() != breakpoints[break_idx_i]) curcol --; break; // do the next line. - } + } // add nobreak version of breakable column current.cols.top()=breakpoints[break_idx_i]; curcol ++; break_idx_i++; - } + } *mlog << "[" <filename_str_; - *os_p_ << "\n\n"; - // ugh - *os_p_ << "\\version \"0.1.1\";\n"; + *os_p_ << "% Creator: " << mi2mu_version_str() << "\n"; + *os_p_ << "% Automatically generated, at "; + time_t t (time (0)); + *os_p_ << ctime (&t); + *os_p_ << "% from input file: "; + *os_p_ << midi_parser_l_g->filename_str_; + *os_p_ << "\n\n"; + // ugh + *os_p_ << "\\version \"0.1.1\";\n"; } void Mudela_stream::open() { - os_p_ = new ofstream (filename_str_); - if (!*os_p_) + os_p_ = new ofstream (filename_str_); + if (!*os_p_) error ("can't open: `" + filename_str_ + "\'"); } void Mudela_stream::output (String str) { - for (int i = 0; i < str.length_i(); i++) { + for (int i = 0; i < str.length_i(); i++) + { char c = str[ i ]; - switch (c) { + switch (c) + { case '{' : case '<' : handle_pending_indent(); @@ -140,26 +143,28 @@ Mudela_stream::output (String str) void Mudela_stream::output_wrapped (String str) { - // enough room left -> doit - if (column_i_ + str.length_i() <= wrap_column_i_) { + // enough room left -> doit + if (column_i_ + str.length_i() <= wrap_column_i_) + { output (str); return; } - // we're at BOL already; this will never fit -> doit - if (column_i_ == indent_i_ * INDENT_i) { + // we're at BOL already; this will never fit -> doit + if (column_i_ == indent_i_ * INDENT_i) + { output (str); return; } - - // ok, let's wrap - // preserve comment mode - if (comment_mode_b_) + + // ok, let's wrap + // preserve comment mode + if (comment_mode_b_) output (String ("\n%")); - else + else output (String ("\n")); - - output (str); + + output (str); } diff --git a/mi2mu/my-midi-lexer.cc b/mi2mu/my-midi-lexer.cc index 63dfb06d8f..483fce6927 100644 --- a/mi2mu/my-midi-lexer.cc +++ b/mi2mu/my-midi-lexer.cc @@ -12,20 +12,20 @@ int yylex() { - return midi_lexer_l_g->yylex(); + return midi_lexer_l_g->yylex(); } My_midi_lexer* midi_lexer_l_g = 0; My_midi_lexer::My_midi_lexer (String &filename_str, Sources * sources) { - source_file_l_ = sources->get_file_l(filename_str); - if (!source_file_l_) + source_file_l_ = sources->get_file_l(filename_str); + if (!source_file_l_) ::error ("can't find: `" + filename_str + "'"); - switch_streams (source_file_l_->istream_l(), 0); - errorlevel_i_ = 0; - char_count_ = 0; - running_status_i_ = 0; + switch_streams (source_file_l_->istream_l(), 0); + errorlevel_i_ = 0; + char_count_ = 0; + running_status_i_ = 0; } My_midi_lexer::~My_midi_lexer() @@ -36,19 +36,23 @@ My_midi_lexer::~My_midi_lexer() void My_midi_lexer::error (char const* sz_l) { - if (1|| !source_file_l_) { + if (1|| !source_file_l_) + { cerr << "error at EOF: `" << sz_l << "'\n"; - } else { + } + else + { // FIXME #if 0 char const* ch_C = here_ch_C(); - if (ch_C) { + if (ch_C) + { ch_C--; while ( (*ch_C == ' ') || (*ch_C == '\t') || (*ch_C == '\n')) ch_C--; ch_C++; - } + } errorlevel_i_ |= 1; error (sz_l); #endif @@ -58,29 +62,30 @@ My_midi_lexer::error (char const* sz_l) char const* My_midi_lexer::here_ch_C() { - return source_file_l_->ch_C() + char_count_ ; + return source_file_l_->ch_C() + char_count_ ; } int My_midi_lexer::varint2_i (String str) { - int var_i = 0; + int var_i = 0; - for (int i = 0; i < str.length_i(); i++) { + for (int i = 0; i < str.length_i(); i++) + { Byte byte = str[ i ]; var_i <<= 7; var_i += byte & 0x7f; if (! (byte & 0x80)) return var_i; } - cout << "\nvarint2_i:" << String_convert::bin2hex_str (str) << endl; - assert (0); // illegal varint - return 0; + cout << "\nvarint2_i:" << String_convert::bin2hex_str (str) << endl; + assert (0); // illegal varint + return 0; } int My_midi_lexer::close_i() { - return 0; + return 0; } diff --git a/mi2mu/version.cc b/mi2mu/version.cc index 1c630664d8..57299cd358 100644 --- a/mi2mu/version.cc +++ b/mi2mu/version.cc @@ -7,7 +7,7 @@ const char * mi2mu_version_sz(); String mi2mu_version_str() { - return String (mi2mu_version_sz()) + return String (mi2mu_version_sz()) + "/" + flower_version_sz() + " of " + __DATE__ + " " + __TIME__; } -- 2.39.5