]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.46.jcn1
authorfred <fred>
Sun, 24 Mar 2002 19:37:39 +0000 (19:37 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:37:39 +0000 (19:37 +0000)
63 files changed:
lily/bar-reg.cc
lily/beam.cc
lily/clef-reg.cc
lily/command-request.cc
lily/complex-staff.cc
lily/complex-walker.cc
lily/crescendo.cc
lily/debug.cc
lily/dynamic-reg.cc
lily/global-regs.cc [new file with mode: 0644]
lily/grouping.cc
lily/headreg.cc
lily/identifier.cc
lily/input-music.cc
lily/input-register.cc [new file with mode: 0644]
lily/input-score.cc
lily/input-staff.cc
lily/input.cc [new file with mode: 0644]
lily/key-reg.cc
lily/local-key-reg.cc
lily/lyric-item.cc
lily/lyric-register.cc [new file with mode: 0644]
lily/main.cc
lily/meter-reg.cc
lily/midi-output.cc
lily/midi-walker.cc
lily/musical-request.cc
lily/my-lily-lexer.cc
lily/my-lily-parser.cc
lily/p-col.cc
lily/p-score.cc
lily/register-group.cc
lily/register.cc
lily/score.cc
lily/scores.cc
lily/script-reg.cc
lily/slur-reg.cc
lily/slur.cc
lily/spanner.cc
lily/staff-column.cc
lily/staff-elem-info.cc
lily/staff-elem.cc
lily/staff-info.cc [new file with mode: 0644]
lily/staff-regs.cc [new file with mode: 0644]
lily/staff-sym-reg.cc [new file with mode: 0644]
lily/staff-sym.cc [new file with mode: 0644]
lily/staff-walker.cc
lily/staff.cc
lily/staffline.cc
lily/stem-beam-reg.cc
lily/stem.cc
lily/swallow-reg.cc [new file with mode: 0644]
lily/text-def.cc
lily/text-reg.cc
lily/text-spanner.cc
lily/time-description.cc
lily/voice-element.cc [new file with mode: 0644]
lily/voice-group-regs.cc
lily/voice-regs.cc
lily/voice.cc
lily/walk-regs.cc
lily/warn.cc
mi2mu/midi-track.cc

index 93334497cf6c1a23b3ad1028b9e275e65dd5c508..8450b6bf7e8ab5687c62d9a74f9ddc0fb5fc986c 100644 (file)
@@ -9,7 +9,7 @@
 #include "bar-reg.hh"
 #include "bar.hh"
 #include "command-request.hh"
-#include "score-column.hh"
+//#include "score-column.hh"
 #include "time-description.hh"
 
 Bar_register::Bar_register()
@@ -83,5 +83,6 @@ Bar_register::post_move_processing()
 }
 
 IMPLEMENT_STATIC_NAME(Bar_register);
+ADD_THIS_REGISTER(Bar_register);
 
 
index c4d62b54d2faf83dbefb8e4b27bc5ec2ba8ce884..a20e859e23a03cefda2226205432aa672d5e7553 100644 (file)
@@ -180,8 +180,8 @@ Beam::do_break_at( PCol *, PCol *) const
 void
 Beam::do_pre_processing()
 {
-    left  = (*stems.top())   ->pcol_l_;
-    right = (*stems.bottom())->pcol_l_;    
+    left_col_l_ = (*stems.top())   ->pcol_l_;
+    right_col_l_ = (*stems.bottom())->pcol_l_;    
     assert(stems.size()>1);
     if (!dir_i_)
        set_default_dir();
@@ -278,7 +278,7 @@ Beam::brew_molecule_p() const return out;
        sb.translate(Offset(x, (x * slope  + left_pos)* inter));
        out->add(sb);
     }
-    out->translate(Offset(x0 - left->hpos,0));
+    out->translate(Offset(x0 - left_col_l_->hpos,0));
 }
 
 IMPLEMENT_STATIC_NAME(Beam);
index 403dabb25047ac4674029d9e45fd4a777fffa277..f0bff0374c347e5816e0c3aa7e03cf714fa02bba 100644 (file)
@@ -36,7 +36,7 @@ Clef_register::set_type(String s)
        c0_position_i_= 10;
     }else 
        return false;
-    *get_staff_info().c0_position_i_ = c0_position_i_;
+    *get_staff_info().c0_position_i_l_ = c0_position_i_;
     
     return true;
 }
@@ -45,7 +45,7 @@ void
 Clef_register::read_req(Clef_change_req*c_l)
 {
     if (!set_type(c_l->clef_str_))
-       error("unknown clef type ", c_l->defined_ch_C_);
+       c_l->error("unknown clef type ");
 }
 
 bool
@@ -106,3 +106,4 @@ Clef_register::post_move_processing()
     }
 }
 IMPLEMENT_STATIC_NAME(Clef_register);
+ADD_THIS_REGISTER(Clef_register);
index 7d95dd980dbb3fd5b2d759462ee6f9fbe6d0d13b..dfa448f41f494ce8c348c40586e7011e139a02b1 100644 (file)
@@ -72,7 +72,9 @@ IMPLEMENT_STATIC_NAME(Clef_change_req);
 void
 Clef_change_req::do_print() const
 {
+#ifndef NPRINT
     mtor << clef_str_ ;
+#endif
 }
 
 Clef_change_req::Clef_change_req(String s)
@@ -85,7 +87,9 @@ IMPLEMENT_STATIC_NAME(Group_feature_req);
 void
 Group_feature_req::do_print() const
 {
+#ifndef NPRINT
     mtor << "stemdir " << stemdir_i_;
+#endif
 }
 
 Group_feature_req::Group_feature_req()
@@ -98,7 +102,9 @@ IMPLEMENT_STATIC_NAME(Group_change_req);
 void
 Group_change_req::do_print()const
 {
+#ifndef NPRINT
     mtor << "id : " << newgroup_str_;
+#endif
 }
 /* *************** */
 IMPLEMENT_STATIC_NAME(Terminate_voice_req);
index 661d8332ed4b292ab8b4bf8d52df1220f0dd4465..57d2fc086122b9f536a4c11b1e8442d187c98270 100644 (file)
@@ -1,13 +1,8 @@
 #include "complex-staff.hh"
 #include "complex-walker.hh"
-#include "score.hh"
 #include "p-score.hh"
-#include "staffsym.hh"
-#include "score-column.hh"
 
-const NO_LINES = 5;
-
-/** Aside from putting fields right, this generates the staff symbol.
+/** Aside from putting fields right
  */
 void
 Complex_staff::set_output(PScore* pscore_l )
@@ -15,18 +10,6 @@ Complex_staff::set_output(PScore* pscore_l )
     pstaff_l_ = new PStaff(pscore_l);
     pscore_l_ = pscore_l;
     pscore_l_->add(pstaff_l_);
-
-    Staff_symbol *span_p = new Staff_symbol(NO_LINES);
-    
-    Score_column* col_last
-       =score_l_->find_col(score_l_->last(), false);
-    Score_column* col_first=
-       score_l_->find_col(0, false);
-       
-    span_p->set_extent(col_first->pcol_l_->postbreak_p_,
-                      col_last->pcol_l_->prebreak_p_);
-
-    pscore_l_->typeset_spanner(span_p, pstaff_l_);
 }
 
 
index 09773b1503099016efc92c11a3f3a096e9a922bd..ba7be37cd1e2558f616e90803f4aeea1279b4183 100644 (file)
@@ -5,18 +5,12 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-
-#include "musical-request.hh"
 #include "staff-column.hh"
 #include "voice.hh"
 #include "p-score.hh"
 #include "complex-staff.hh"
 #include "debug.hh"
-#include "voice-group-regs.hh"
-#include "voice-regs.hh"
 #include "complex-walker.hh"
-//#include "misc.hh"
-#include "command-request.hh"
 #include "walk-regs.hh"
 
 void
@@ -37,16 +31,15 @@ Complex_walker::do_announces()
     walk_regs_p_->do_announces();
 }
 
-bool
-Complex_walker::try_command_request(Command_req *req_l)
-{
-    return walk_regs_p_->try_request(req_l);
-}
 
 void
 Complex_walker::try_request(Request*req)
 {
-    walk_regs_p_->try_request(req);
+    bool b =walk_regs_p_->try_request(req);
+    if (!b)
+       
+       req->warning("junking request: "  + String(req->name()));
+    
 }
 
 void
index 29aa3ab84176b1e0f2105a157b47f627ec8bfb96..163e3be7376c229befb865ff40b1738269aad492 100644 (file)
@@ -5,16 +5,17 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-
+#include "dimen.hh"
 #include "crescendo.hh"
 #include "lookup.hh"
 #include "paper-def.hh"
-
+#include "debug.hh"
 Crescendo::Crescendo(int s)
 {
     staff_size_i_ = s;
     grow_dir_i_ =0;
     dir_i_ = -1 ;
+    left_dyn_b_ = right_dyn_b_ =false;
 }
 
 Spanner*
@@ -27,9 +28,24 @@ Crescendo::do_break_at(PCol*, PCol*)const
 Molecule*
 Crescendo::brew_molecule_p() const return m_p ;
 {
+    Real x_off_dim=0.0;
+    Real absdyn_dim = 10 PT;   // UGR
+    
     m_p = new Molecule;
-    Real w_f = width().length();
-    Symbol s( paper()->lookup_l()->hairpin(w_f, grow_dir_i_ < 0) );
+    Real w_dim = width().length();
+    if ( left_dyn_b_ ) {
+       w_dim -= absdyn_dim;
+       x_off_dim += absdyn_dim;
+    }
+    if ( right_dyn_b_ ) {
+       w_dim -= absdyn_dim;
+    }
+    
+    if (w_dim < 0) {
+       error("Crescendo too small");
+       w_dim = 0;
+    }
+    Symbol s( paper()->lookup_l()->hairpin(w_dim, grow_dir_i_ < 0) );
     m_p->add(Atom(s));
     int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ;
     m_p->translate(Offset(0,pos * paper()->internote()));
index 67bcd7068123eda280eef65618c368d2e6e13262..a2bce7c8ce91019fe80e30ee87bfcef43557b768 100644 (file)
@@ -55,6 +55,7 @@ void
 set_debug(bool b)
 {
     check_debug =b;
-}
+    set_flower_debug(*monitor, check_debug);
+  }
 
 
index 5f137035fa20907cea8ac36566006157cfaf7b36..e0e38a7a595fc950559b74754ab6e103199f02e3 100644 (file)
@@ -5,24 +5,28 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-
+#include "debug.hh"
+#include "crescendo.hh"
 #include "dynamic-reg.hh"
 #include "musical-request.hh"
 #include "text-item.hh"
 #include "lookup.hh"
 #include "paper-def.hh"
+#include "score-column.hh"
 
 Dynamic_register::Dynamic_register()
 {
     dir_i_ =0;
     post_move_processing();
     dynamic_p_ =0;
+    to_end_cresc_p_ = cresc_p_ = 0;
+    cresc_req_l_ = 0;
 }
 
 void
 Dynamic_register::post_move_processing()
 {
-    dynamic_req_l_ = 0;
+    dynamic_req_l_arr_.set_size(0);
 }
 
 bool    
@@ -31,27 +35,54 @@ Dynamic_register::try_request(Request * r)
     Musical_req * m = r->musical();
     if (!m || !m->dynamic())
        return false;
-    assert(!dynamic_req_l_);
-    dynamic_req_l_ = m->dynamic();
+    dynamic_req_l_arr_.push(m->dynamic());
     return true;
 }
 void
 Dynamic_register::process_requests()
 {
-    if(dynamic_req_l_){
-       if (dynamic_req_l_->absdynamic()) {
+    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()) {
            Text_def * td_p = new Text_def;
            td_p->align_i_ = 0;
            String loud =Dynamic_req::loudness_str(
-               dynamic_req_l_->absdynamic()->loudness_);
+               dreq_l->absdynamic()->loudness_);
            
            td_p->text_str_ = paper()->lookup_l()->dynamic(loud).tex;
-           
-
            td_p->style_str_ = "dynamic";
-           
+
+           assert (!dynamic_p_) ; // TODO
+               
            dynamic_p_ = new Text_item(td_p, 10 ); // TODO!
-           announce_element(Staff_elem_info(dynamic_p_, dynamic_req_l_));
+           announce_element(Staff_elem_info(dynamic_p_, dreq_l));
+       } 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_) {
+                   span_l->warning("Can't find cresc to end " );
+               } else {
+                   assert(!to_end_cresc_p_);
+                   to_end_cresc_p_ =cresc_p_;
+                   cresc_p_ = 0;
+               }
+           } else if (span_l->spantype == Span_req::START) {
+               cresc_req_l_ = span_l;
+               assert(!new_cresc_p);
+               new_cresc_p  = new Crescendo(10);
+               new_cresc_p->grow_dir_i_ = span_l->dynamic_dir_i_;
+               announce_element(Staff_elem_info(new_cresc_p, span_l));
+           }
+       }
+    }
+
+    if ( new_cresc_p ) {
+       cresc_p_ = new_cresc_p;
+       cresc_p_->left_col_l_ = get_staff_info().musical_l()->pcol_l_;
+       if (dynamic_p_) {
+           cresc_p_->left_dyn_b_ = true;
        }
     }
 }
@@ -63,6 +94,15 @@ Dynamic_register::pre_move_processing()
        typeset_element(dynamic_p_);
        dynamic_p_ = 0;
     }
+    if ( to_end_cresc_p_) {
+       if (dynamic_p_)
+           to_end_cresc_p_->right_dyn_b_=true;
+       
+       to_end_cresc_p_->right_col_l_ = get_staff_info().musical_l()->pcol_l_;
+       typeset_element(to_end_cresc_p_);
+       to_end_cresc_p_ = 0;
+    }
 }
 
 bool
@@ -79,3 +119,14 @@ Dynamic_register::set_feature(Features i)
 }
 
 IMPLEMENT_STATIC_NAME(Dynamic_register);
+ADD_THIS_REGISTER(Dynamic_register);
+
+Dynamic_register::~Dynamic_register()
+{
+    delete dynamic_p_;
+    delete to_end_cresc_p_;
+    if (cresc_p_) {
+       cresc_req_l_->warning("unended crescendo");
+    }
+    delete cresc_p_;
+}
diff --git a/lily/global-regs.cc b/lily/global-regs.cc
new file mode 100644 (file)
index 0000000..207cc16
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+  global-regs.cc -- implement 
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "input-register.hh"
+#include "debug.hh"
+#include "register.hh"
+
+struct Request_register_table_entry {
+    String name_str_;
+    Reg_ctor ctor_l_;
+    Request_register_table_entry(String s, Reg_ctor f) {
+       name_str_ =s;
+       ctor_l_ = f;
+    }
+    Request_register_table_entry()
+    {
+       ctor_l_ =0;
+    }
+};
+
+static Array<Request_register_table_entry> *reg_table=0;
+
+void
+add_request_register(String s, Reg_ctor f)
+{
+    if (!reg_table)
+       reg_table = new Array<Request_register_table_entry>;
+    
+    reg_table->push(Request_register_table_entry(s, f));
+}
+
+
+Request_register*
+get_nongroup_register_p(String s)
+{
+    for (int i=0; i < reg_table->size(); i++) {
+       if ((*reg_table)[i].name_str_ == s)
+           return (*(*reg_table)[i].ctor_l_)();
+    }
+    error("Unknown register `" + s +"\'");
+    return 0;
+}
index bc665a19c03a453b309e0c391f008354a8cab16b..2e59f05bd242b3fdbe8e8c22a907ab4b8539d3e2 100644 (file)
@@ -93,7 +93,7 @@ Rhythmic_grouping::intersect(MInterval t)
     
     for (int i=0; i < children.size(); i++) {
        MInterval inter = intersection(t, children[i]->interval());
-       if (inter.empty() || inter.length() <= Rational( 0 )) {
+       if (inter.empty_b() || inter.length() <= Rational( 0 )) {
            delete children[i];
            children[i] =0;
        } else {
index 61232d25b8ca9779ee3cee9037722a7de259040c..318ed3a60725bc619fad8e3dd9c08b8ceb87d48e 100644 (file)
@@ -46,7 +46,7 @@ Notehead_register::process_requests()
        note_p_ = n_p;
        n_p->set_rhythmic(note_req_l_->rhythmic());
        n_p->position = note_req_l_->note()->height() +
-           *get_staff_info().c0_position_i_;
+           *get_staff_info().c0_position_i_l_;
     } else {
        note_p_ = new Rest ( note_req_l_->rhythmic()->duration_);
        if (note_req_l_->rhythmic()->duration_.type_i_ <= 2)
@@ -75,3 +75,4 @@ Notehead_register::post_move_processing()
 }
 
 IMPLEMENT_STATIC_NAME(Notehead_register);
+ADD_THIS_REGISTER(Notehead_register);
index 0eab514cb5ab5e2f2317feec031143987096ec46..8b989f9868b4bff908165956734d87662b92efbf 100644 (file)
@@ -11,7 +11,7 @@
 #include "identifier.hh"
 #include "my-lily-lexer.hh"
 #include "debug.hh"
-
+#include "input-register.hh"
 #include "input-score.hh" 
 #include "symtable.hh"
 #include "input-staff.hh"
@@ -19,6 +19,7 @@
 #include "lookup.hh"
 #include "script-def.hh"
 #include "request.hh"
+#include "input-register.hh"
 
 void
 Identifier::error(String expect)
@@ -29,13 +30,12 @@ Identifier::error(String expect)
 }
 
 Identifier::Identifier(String n, int code)
-    : name(n) 
+    :  name(n) 
 {
     token_code_i_ = code; 
     data = 0;
     accessed_b_ = 0;
     init_b_ = 0;
-    defined_ch_C_ = 0;
 }
 
 void
@@ -61,6 +61,8 @@ DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
 DEFAULT_PRINT(Request_id, Request, request);
 DEFAULT_PRINT(Score_id, Input_score, score);
+DEFAULT_PRINT(Input_regs_id, Input_register, iregs);
+
 void
 Real_id::do_print() const
 {
@@ -85,12 +87,18 @@ Idclass::~Idclass() { delete accessor(false); }\
 Idclass::Idclass(String s, Class*st, int code):Identifier(s,code) { data = st; }\
 
 
-implement_id_class(Real_id, Real, real)
-implement_id_class(Script_id, Script_def, script)
-implement_id_class(Lookup_id, Lookup, lookup)
-implement_id_class(Symtables_id, Symtables, symtables)
-implement_id_class(Staff_id, Input_staff, staff)
-implement_id_class(M_chord_id, Music_general_chord, mchord)
-implement_id_class(M_voice_id, Music_voice, mvoice)
-implement_id_class(Score_id, Input_score, score)
-implement_id_class(Request_id, Request, request)
+implement_id_class(Real_id, Real, real);
+implement_id_class(Script_id, Script_def, script);
+implement_id_class(Lookup_id, Lookup, lookup);
+implement_id_class(Symtables_id, Symtables, symtables);
+implement_id_class(Staff_id, Input_staff, staff);
+implement_id_class(M_chord_id, Music_general_chord, mchord);
+implement_id_class(M_voice_id, Music_voice, mvoice);
+implement_id_class(Score_id, Input_score, score);
+implement_id_class(Request_id, Request, request);
+implement_id_class(Input_regs_id, Input_register, iregs);
+
+Identifier::Identifier(Identifier const&)
+{
+    assert(false);
+}
index e407c87dd567b4711a10c00e72977e6040b9eac5..9ba683817993cd3718065435b003d4013b03b243 100644 (file)
@@ -12,7 +12,7 @@ Input_music::check_plet(Voice_element* velt_l)
        if ( i->plet() ) {
            Moment start_moment = 0;
            if ( !find_plet_start_b( i->plet()->type_c_, start_moment ) ) {
-               error( "begin of plet not found", i->defined_ch_C_ );
+               i ->error( "begin of plet not found");
                break;
            }
            Moment moment = 0;
diff --git a/lily/input-register.cc b/lily/input-register.cc
new file mode 100644 (file)
index 0000000..e038b18
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+  input-register.cc -- implement Input_register
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "debug.hh"
+#include "register.hh"
+#include "input-register.hh"
+Input_register::~Input_register()
+{}
+
+Input_register::Input_register()
+{
+}
+
+bool
+Input_register::group_b()const
+{
+    return ireg_list_.size();
+}
+
+Array<String>
+Input_register::get_nongroups_str_arr()const
+{
+    Array<String> s_arr;
+    for (iter_top(ireg_list_, i); i.ok(); i++) {
+       if (!i->group_b())
+           s_arr.push(i->name_str_);
+    }
+    return s_arr;
+}
+
+Input_register*
+Input_register::get_ireg_l(String nm)const
+{
+    for (iter_top(ireg_list_, i); i.ok(); i++) {
+       if (i->name_str_ == nm)
+           return i;
+    }
+    return 0;
+}
+Array<Request_register*>
+Input_register::get_nongroup_p_arr() const return a;
+{
+    Array<String> sa(get_nongroups_str_arr());
+    for (int i=0; i < sa.size(); i++)
+       a.push(get_nongroup_register_p(sa[i]));
+}
+
+void
+Input_register::add(Input_register *p)
+{
+    ireg_list_.bottom().add(p);
+}
+
+void
+Input_register::print() const
+{
+#ifndef NPRINT
+    mtor << name_str_ << " { ";
+    for (iter_top(ireg_list_, i); i.ok(); i++)
+       i->print();
+    mtor <<" }\n";
+#endif 
+}
+       
+
+Input_register::Input_register(Input_register const&s)
+    : Input(s)
+{
+    name_str_ = s.name_str_;
+    for (iter_top(s.ireg_list_, i); i.ok(); i++)
+       add(new Input_register(*i.ptr()));
+}
index ed7d831eeaaefa50f2ec18bc03fb002c3250c04c..a2dacc048e6fd2da205fccc384801d70eb45ff4d 100644 (file)
@@ -37,10 +37,10 @@ Input_score::set(Midi_def* midi_p)
 }
  
 Input_score::Input_score(Input_score const&s)
+    : Input(s)
 {
     paper_p_ = (s.paper_p_)? new Paper_def(*s.paper_p_) :0;
     midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0;
-    defined_ch_C_ = s.defined_ch_C_;
     errorlevel_i_ = s.errorlevel_i_;
 }
 
@@ -48,7 +48,7 @@ Score*
 Input_score::parse()
 {
     Score *s_p = new Score;
-    s_p->defined_ch_C_= defined_ch_C_;
+
     s_p->errorlevel_i_ = errorlevel_i_;
     if (midi_p_)
        s_p->set(new Midi_def(*midi_p_));
@@ -72,7 +72,6 @@ Input_score::~Input_score()
 
 Input_score::Input_score()
 {
-    defined_ch_C_=0;
     paper_p_= 0;
     midi_p_ = 0;
     errorlevel_i_ = 0;
index 9262851f3cdf07a00836d1d66e01923d4058ec82..618d98f012554a60fc0c050c636cdca810c6040f 100644 (file)
 #include "input-staff.hh"
 #include "staff.hh"
 #include "complex-staff.hh"
-#include "lyric-staff.hh"
-
 #include "my-lily-lexer.hh"
+#include "input-register.hh"
 
-
-Input_staff::Input_staff(String s)
+Input_staff::Input_staff()
 {
-    type= s;
-    defined_ch_C_ = 0;
+    ireg_p_ =0;
 }
 
 void
@@ -32,18 +29,10 @@ Input_staff::add(Input_music*m)
 Staff*
 Input_staff::parse(Score*score_l)
 {
-    Staff *p=0;
-    if (type == "melodic")
-       p = new Complex_staff;
-    else if (type == "lyric")
-       p = new Lyric_staff;
-    else {
-       error( "Unknown staff-type `" + type +"\'", defined_ch_C_ );
-       exit( 1 );
-    }
-
+    Staff *p=new Complex_staff;
+   
     p->score_l_ = score_l;
-    
+    p->ireg_p_ = (ireg_p_)? new Input_register(*ireg_p_):0;
     for (iter_top(music_,i); i.ok(); i++) {
        Voice_list vl = i->convert();
        p->add(vl);
@@ -52,11 +41,12 @@ Input_staff::parse(Score*score_l)
 }
 
 Input_staff::Input_staff(Input_staff const&s)
+    : Input(s)
 {    
     for (iter_top(s.music_,i); i.ok(); i++)
        add(i->clone());
-    defined_ch_C_ = s.defined_ch_C_;
-    type = s.type;
+
+    ireg_p_ = (s.ireg_p_)? new Input_register(*s.ireg_p_):0;
 }
 
 void
@@ -66,9 +56,11 @@ Input_staff::print() const
     mtor << "Input_staff {\n";
     for (iter_top(music_,i); i.ok(); i++)
        i->print();
+    ireg_p_->print();
     mtor << "}\n";
 #endif
 }
 Input_staff::~Input_staff()
 {
+    delete ireg_p_;
 }
diff --git a/lily/input.cc b/lily/input.cc
new file mode 100644 (file)
index 0000000..1ff4e86
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+  input.cc -- implement Input
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "proto.hh"
+#include "input.hh"
+#include "string.hh"
+#include "source.hh"
+#include "source-file.hh"
+
+Input::Input(Sources*s, char const *cl)
+{
+    sources_l_=s;
+    defined_ch_C_=cl;
+}
+
+Input::Input()
+{
+    sources_l_ = 0;
+    defined_ch_C_ = 0;
+}
+
+Input::Input(Input const &s)
+{
+    sources_l_ = s.sources_l_;
+    defined_ch_C_ = s.defined_ch_C_;
+}
+
+void
+Input::set_spot(Input const &i)
+{
+    *this  = i;
+}
+
+void
+Input::message(String message_str)const
+{
+    String str = "";
+    Source_file* sourcefile_l=0;
+    
+    if (sources_l_) 
+       sourcefile_l = sources_l_->sourcefile_l( defined_ch_C_ );
+    
+    if ( sourcefile_l ) {
+       str += sourcefile_l->file_line_no_str(defined_ch_C_) + String(": ");
+    }
+    
+    str += message_str;
+    if ( sourcefile_l ) {
+       str += ":\n";
+       str += sourcefile_l->error_str( defined_ch_C_);
+    }
+    /*
+    if ( busy_parsing() )
+       cerr << endl;
+       */
+    cerr << str << endl;
+}
+
+void
+Input::warning( String message_str)const
+{
+    message( "warning: " + message_str);
+}
+void
+Input::error(String s)const
+{
+    message("error: "+ s);
+    exit (1);
+}
+
+String
+Input::location_str()const
+{
+    Source_file * sourcefile_l=0;
+    if (sources_l_)
+       sourcefile_l = sources_l_->sourcefile_l (defined_ch_C_);
+    if (sourcefile_l) 
+       return sourcefile_l->file_line_no_str(defined_ch_C_);
+    else
+       return "(location unknown)";
+}
index 83fb84c0cdd7db4ee4a799a084532d396c0975c5..ca98995b1cf3d865c8ae4282640068a7f290f0d8 100644 (file)
@@ -39,7 +39,7 @@ Key_register::acknowledge_element(Staff_elem_info info)
 {
     Command_req * r_l = info.req_l_->command() ;
     if (r_l && r_l->clefchange() && !kit_p_) {
-       int c0_i= *get_staff_info().c0_position_i_;
+       int c0_i= *get_staff_info().c0_position_i_l_;
         kit_p_ = new Key_item(c0_i);
         kit_p_->read(*this);
         announce_element(Staff_elem_info(kit_p_, keyreq_l_));
@@ -57,7 +57,7 @@ Key_register::process_requests()
     }
 
      if ( default_key_b_ || keyreq_l_) {
-        int c0_i= *get_staff_info().c0_position_i_;
+        int c0_i= *get_staff_info().c0_position_i_l_;
         kit_p_ = new Key_item(c0_i);
         kit_p_->read(*this);
         announce_element(Staff_elem_info(kit_p_, keyreq_l_));
@@ -98,3 +98,4 @@ Key_register::post_move_processing()
     kit_p_ = 0;
 }
 IMPLEMENT_STATIC_NAME(Key_register);
+ADD_THIS_REGISTER(Key_register);
index ea7e66b7d7af42a4d8dba74cdf09b1f1bbf3ef57..876a0ecf01aa5955e99c847c6a27908d612948f6 100644 (file)
@@ -40,7 +40,7 @@ Local_key_register::acknowledge_element(Staff_elem_info info)
        
 
            if (!key_item_p_) {
-               key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_);
+               key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_l_);
            }
            
            key_item_p_->add(note_l_);
@@ -64,7 +64,8 @@ Local_key_register::process_requests()
        if (key_C_)  
            local_key_.reset(*key_C_);
        else if( time_C_->when_ >Moment(0))
-           warning ("Help me! can't figure  current key", 0);
+           warning ("Help me! can't figure  current key", (const char*)0);
     }
 }
 IMPLEMENT_STATIC_NAME(Local_key_register);
+ADD_THIS_REGISTER(Local_key_register);
index 1a54f12bcaa118bb62dd28b6cd7ece7caf676b2b..8bca62e9c939ddf7ba4f97d726157e1f30a9cdad 100644 (file)
@@ -22,5 +22,5 @@ Lyric_item::do_pre_processing()
 
     // test context-error
     if ( tdef_l()->text_str_.index_i( "Gates" ) >=0)// :-)
-       warning( "foul word", tdef_l()->defined_ch_C_ );
+       tdef_l()->warning( "foul word");
 }
diff --git a/lily/lyric-register.cc b/lily/lyric-register.cc
new file mode 100644 (file)
index 0000000..73f0def
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+  lyric-register.cc -- implement Lyric_register
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "staff-walker.hh"
+#include "lyric-register.hh"
+#include "lyric-item.hh"
+#include "musical-request.hh"
+
+Lyric_register::Lyric_register()
+{
+    
+}
+
+bool
+Lyric_register::try_request(Request*r)
+{
+    Musical_req * m =r->musical();
+    if (!m || ! m->lreq_l()) 
+       return false;
+    lreq_arr_.push(m->lreq_l());
+
+    return true;
+}
+
+void
+Lyric_register::process_requests()
+{
+    for (int i=0; i < lreq_arr_.size(); i++) {
+       Item *lp = new Lyric_item(lreq_arr_[i],i);
+       typeset_element(lp);
+    }
+    get_staff_info().walk_l_->allow_break();
+}
+
+void
+Lyric_register::post_move_processing()
+{
+    lreq_arr_.set_size(0);
+}
+
+
+bool
+Lyric_register::acceptable_request_b(Request*r)
+{
+    Musical_req * m =r->musical();
+    return (!m || ! m->lreq_l()) ;
+}
+
+IMPLEMENT_STATIC_NAME(Lyric_register);
+ADD_THIS_REGISTER(Lyric_register);
index dd38e5cad5604a3072e3f2729ad477911464174f..1576773e860582bfc50b6c3969d48930087a55df 100644 (file)
@@ -21,7 +21,6 @@
 
 Sources* source_l_g = 0;
 bool only_midi = false;
-extern void parse_file(String,String);
 
 
 void
@@ -96,33 +95,35 @@ notice()
        "USA.\n";
 }
 
-static File_path * path =0;
-struct Main_init {
-    Main_init() {
-       path = new File_path(String(DIR_DATADIR)+"/init/");
-       path->push(DIR_DATADIR );
-       debug_init();
-    }
-    ~Main_init() {
-       delete path;
-    }
-} main_init;
+static File_path * path_l =0;
 
 void
 do_one_file(String init_str, String file_str)
 {
-    source_l_g = new Sources;
-    source_l_g->set_path(path);
-    My_lily_parser parser(source_l_g);
-    parser.parse_file(init_str, file_str);
+    Sources sources;
+    source_l_g = &sources; 
+    source_l_g->set_path(path_l);
+    {
+       My_lily_parser parser(source_l_g);
+       parser.parse_file(init_str, file_str);
+    }
     do_scores();
-    delete source_l_g;
     source_l_g = 0;
 }
 
 int
 main (int argc, char **argv)
 {    
+    debug_init();              // should be first
+    File_path path(String(DIR_DATADIR)+"/init/") ;
+    path_l = & path;
+    path_l->push(DIR_DATADIR );
+
+    char const * env_l=getenv("LILYINCLUDE");
+    if (env_l) {
+       path.add(env_l);
+    }
+    
     Getopt_long oparser(argc, argv,theopts);
     cout << get_version_str() << endl;
     String init_str("symbol.ini");
@@ -137,7 +138,7 @@ main (int argc, char **argv)
            exit(0);
            break;
        case 'I':
-           path->push(oparser.optarg);
+           path.push(oparser.optarg);
            break;
        case 'i':
            init_str = oparser.optarg;
@@ -172,11 +173,6 @@ main (int argc, char **argv)
 
     return 0;
 }
-String
-find_file(String f)
-{
-    return path->find(f);
-}
 
 /// make input file name: add default extension. "" is stdin.
 void
index 3c500e6042733a8a6ef03dba3ceb6a9acea64d18..c4ef7b9bb17fe2321742ffe00e97b3159e463703 100644 (file)
@@ -63,3 +63,4 @@ Meter_register::post_move_processing()
     meter_p_ =0;
 }
 IMPLEMENT_STATIC_NAME(Meter_register);
+ADD_THIS_REGISTER(Meter_register);
index 5992cf9505e05d71cdbc904e7e1e5660811b938d..c239e82af5a1e2ed87f2cfc329c0a45bf1d7ef01 100644 (file)
@@ -83,12 +83,15 @@ Midi_output::header()
     str += ",\n";
     Midi_text generate( Midi_text::TEXT, str );
     midi_track.add( Moment( 0 ), &generate );
+
+#if 0 // TODO!
     Source_file* sourcefile_l = source_l_g->sourcefile_l( score_l_->defined_ch_C_ );
     if ( sourcefile_l ) {
-       str = "from musical definition: " 
+       str += "from musical definition: " 
            + sourcefile_l->file_line_no_str(score_l_->defined_ch_C_);
 
     }
+#endif
     Midi_text from( Midi_text::TEXT, str );
     midi_track.add( Moment( 0 ), &from );
 
index ef1ea8382a4d3bf6e4746b89af67388a5a4cae36..a024458349b22e55828f3e42c6e9dd41c5876d58 100644 (file)
@@ -82,7 +82,7 @@ Midi_walker::process_requests()
        Command_req *c_l = ptr()->commandreq_l_arr_[i]->command();
        Meter_change_req* meter_l = c_l->meterchange();
        if ( meter_l )
-           output_event( Midi_time( meter_l->beats_i_, meter_l->one_beat_i_, 18 ), 0 );
+           output_event( Midi_time( meter_l->beats_i_, meter_l->one_beat_i_, 18 ),  0 );
        Key_change_req* key_l = c_l->keychange();
        if ( key_l ) {
            int sharps_i = key_l->sharps_i();
index c7a848a18f071a584c703bb8ef188e05a6daf837..1ba4fd7801d1306efb1d05b8969528fa5198b736 100644 (file)
@@ -65,12 +65,11 @@ Span_req::do_print() const
 Request::Request()
 {
     elt_l_ = 0;
-    defined_ch_C_ = 0;
 }
 Request::Request(Request const&src)
+    :Input(src)
 {
     elt_l_ = 0;
-    defined_ch_C_ = src.defined_ch_C_;
 }
 /* *************** */
 Spacing_req::Spacing_req()
@@ -115,8 +114,7 @@ Melodic_req::transpose(Melodic_req const & delta)
     }
     accidental_i_ += delta.accidental_i_;
     if (abs(accidental_i_) > 2) {
-       warning("transposition makes accidental larger than 2", 
-               delta.defined_ch_C_);
+       delta.warning("transposition makes accidental larger than 2");
     }
 }
 
@@ -363,7 +361,7 @@ Request::voice_l()
     if (!elt_l_)
        return 0;
     else
-       return (Voice*)elt_l_->voice_l_;
+       return (Voice*)elt_l_->voice_C_;
 }
 /* *************** */
 
index 57909e87086413edc856c826600e7ab32b0f5e8c..2bb88b7448bffa53d59cbb0d49c31cdab2d77025 100644 (file)
@@ -26,9 +26,11 @@ static Keyword_ent the_key_tab[]={
     "clef", CLEF,
     "cm", CM_T,
     "duration", DURATIONCOMMAND,
-    "dynamic", DYNAMIC,
+    "absdynamic", ABSDYNAMIC,
+    "group", GROUP,
     "geometric", GEOMETRIC,
     "in", IN_T,
+    "inputregister", INPUT_REGS,
     "lyric", LYRIC,
     "key", KEY,
     "melodic" , MELODIC,
@@ -51,6 +53,7 @@ static Keyword_ent the_key_tab[]={
     "start", START_T,
     "stem", STEM,
     "table", TABLE,
+    "spandynamic", SPANDYNAMIC, 
     "symboltables", SYMBOLTABLES,
     "tempo", TEMPO,
     "texid", TEXID,
@@ -103,7 +106,7 @@ My_lily_lexer::~My_lily_lexer()
        mtor << "deleting: " << ai.key()<<'\n';
        Identifier *i_p = ai.val();
        if (!i_p->accessed_b_ && !i_p->init_b_)
-           warning("Variable not used", i_p->defined_ch_C_);
+           i_p->warning("Variable not used");
        
        delete ai.val();
     }
index 9924a78a7e39f2405ff44c5c5d24c0c89abf962e..0696d91912cb74dfbfb9a8ed6d8c9b27c2a61881 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  my-lily-parser.cc -- implement 
+  my-lily-parser.cc -- implement My_lily_parser
 
   source file of the LilyPond music typesetter
 
@@ -45,18 +45,20 @@ My_lily_parser::parse_file(String init, String s)
     lexer_p_ = new My_lily_lexer;
 
     set_debug();
+    init_parse_b_ = true;
 
     lexer_p_->new_input(init, source_l_);
     do_yyparse();
     print_declarations();
    
     init_parse_b_ = false;
+    set_debug();
     lexer_p_->new_input(s, source_l_);
     do_yyparse();
 
 
     if(!define_spot_array_.empty())
-       warning("Braces don't match.",0);
+       warning("Braces don't match.");
 }
 
 My_lily_parser::~My_lily_parser()
@@ -67,7 +69,7 @@ My_lily_parser::~My_lily_parser()
 void
 My_lily_parser::remember_spot()
 {
-    define_spot_array_.push(here_ch_C());
+    define_spot_array_.push(here_input());
 }
 
 char const * 
@@ -109,7 +111,7 @@ My_lily_parser::get_word_element(Text_def* tdef_p, Duration * duration_p)
     Lyric_req* lreq_p = new Lyric_req(tdef_p);
 
     lreq_p->duration_ = *duration_p;
-     lreq_p->defined_ch_C_ = here_ch_C();
+    lreq_p->set_spot( here_input());
 
     velt_p->add(lreq_p);
 
@@ -121,11 +123,11 @@ Voice_element *
 My_lily_parser::get_rest_element(String,  Duration * duration_p )
 {    
     Voice_element* velt_p = new Voice_element;
-    velt_p->defined_ch_C_ = lexer_p_->here_ch_C();
+    velt_p->set_spot( here_input());
 
     Rest_req * rest_req_p = new Rest_req;
     rest_req_p->duration_ = *duration_p;
-     rest_req_p->defined_ch_C_ = here_ch_C();
+    rest_req_p->set_spot( here_input());
 
     velt_p->add(rest_req_p);
     delete duration_p;
@@ -136,18 +138,18 @@ Voice_element *
 My_lily_parser::get_note_element(Note_req *rq, Duration * duration_p )
 {
     Voice_element*v = new Voice_element;
-    v->defined_ch_C_ = here_ch_C();
+    v->set_spot( here_input());
     
     if (duration_p->type_i_ >= 2) {
        Stem_req * stem_req_p = new Stem_req();
        stem_req_p->duration_ = *duration_p;
        
-       stem_req_p->defined_ch_C_ = here_ch_C();
+       stem_req_p->set_spot( here_input());
        v->add(stem_req_p);
     }
 
     rq->set_duration(*duration_p);
-    rq->defined_ch_C_ = here_ch_C();
+    rq->set_spot( here_input());
 
 
     v->add(rq);
@@ -199,7 +201,7 @@ My_lily_parser::get_parens_request(char c)
        break;
     }
 
-    req_p->defined_ch_C_ = here_ch_C();
+    req_p->set_spot( here_input());
     return req_p;
 }
 
@@ -212,7 +214,6 @@ My_lily_parser::My_lily_parser(Sources * source_l)
     textstyle_str_="roman";            // in lexer?
     error_level_i_ = 0;
     last_duration_mode = false;
-    defined_ch_C_ = 0;
     fatal_error_i_ = 0;
 }
 
@@ -228,3 +229,15 @@ My_lily_parser::add_requests(Voice_element*v)
     }
     post_reqs.set_size(0);
 }
+
+Input
+My_lily_parser::pop_spot()
+{
+    return define_spot_array_.pop();
+}
+
+Input
+My_lily_parser::here_input()const
+{
+    return Input(source_l_, here_ch_C());
+}
index 3ace8fba82341f3a0d35ffd87020385919d118f3..c47a4b2d275d446374b28e4883a28aeef3295594 100644 (file)
@@ -1,3 +1,11 @@
+/*
+  p-col.cc -- implement PCol
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "p-col.hh"
 #include "p-score.hh"
 #include "p-staff.hh"
@@ -10,7 +18,7 @@ PCol::width() const
 
     for (iter_top(its,i); i.ok(); i++)
        w.unite(i->width());
-    if (w.empty())
+    if (w.empty_b())
        w.unite(Interval(0,0));
     return w;
 }
@@ -18,15 +26,6 @@ PCol::width() const
 int
 PCol::rank() const
 {
-#if 0
-    if(!pscore_l_)
-       return -1;
-    PCursor<PCol*> me=pscore_l_->find_col( (PCol*)this);
-    if (!me.ok())
-       return -1;
-    PCursor<PCol*> bot(pscore_l_->cols.top());
-    return me - bot;
-#endif
     assert(rank_i_ != -1);
     return rank_i_;
 }
@@ -47,8 +46,7 @@ PCol::print() const
 #ifndef NPRINT
     mtor << "PCol {";
 
-    if (rank() >= 0)
-       mtor << "rank: " << rank_i_ << '\n';
+    mtor << "rank: " << rank_i_ << '\n';
 
     mtor << "# symbols: " << its.size() ;
     if (breakable_b()){
index 800d3287cf5292a26a7c9cb04d95365f693e0988..d31762e54ae94c317a1ea91b1580abe43336044c 100644 (file)
@@ -220,10 +220,10 @@ PScore::find_col(PCol const *c)const
 void
 PScore::add_broken(Spanner*s)
 {
-    assert(s->left->line_l_ == s->right->line_l_);
+    assert(s->left_col_l_->line_l_ == s->right_col_l_->line_l_);
     broken_spans.bottom().add(s);
-    s->left->starters.bottom().add (s);
-    s->right->stoppers.bottom().add (s);
+    s->left_col_l_->starters.bottom().add (s);
+    s->right_col_l_->stoppers.bottom().add (s);
 }
 
 void
index 0725d6c16b8b7dbd850875e11bb64e8b80e7a029..18be472825ab366b1d7a76b27f2725e24149faf4 100644 (file)
@@ -12,7 +12,7 @@
 #include "register.hh"
 
 bool
-Register_group_register::acceptable_request_b(Request* r)
+Register_group_register::acceptable_request_b(Request* r)const
 {
     for (iter_top(reg_list_, i); i.ok(); i++) {
        if (i->acceptable_request_b(r))
@@ -65,7 +65,7 @@ Register_group_register::acknowledge_element(Staff_elem_info info)
 }
 
 bool
-Register_group_register::contains_b(Request_register* reg_l)
+Register_group_register::contains_b(Request_register* reg_l)const
 {
     bool parent_b = Request_register::contains_b(reg_l);
     
@@ -93,6 +93,12 @@ Register_group_register::try_request(Request*req_l)
     }
     return false;
 }
+void
+Register_group_register::add(Array<Request_register*> p_arr)
+{
+    for (int i =0; i<p_arr.size(); i++)
+       add(p_arr[i]);
+}
 
 void
 Register_group_register::add(Request_register *reg_p)
@@ -122,6 +128,7 @@ Register_group_register::terminate_register(Request_register*r_l)
 }
 
 IMPLEMENT_STATIC_NAME(Register_group_register);
+ADD_THIS_REGISTER(Register_group_register);
 
 void
 Register_group_register::do_print()const
index b9edcf9d584486528e01577396c45588977bf00b..2c3f2ec1af3b9d2c9077d925d02ef031d1433105 100644 (file)
@@ -61,7 +61,7 @@ Request_register::acceptable_request_b(Request*)const
 }
 
 bool
-Request_register::contains_b(Request_register *reg_l)
+Request_register::contains_b(Request_register *reg_l)const
 {
     return this == reg_l;
 }
@@ -76,9 +76,9 @@ void
 Request_register::print() const
 {
 #ifndef NPRINT
-    mtor << name() << " {";
+    mtor << "\n" << name() << " {";
     do_print();
-    mtor << "}\n";
+    mtor << "}";
 #endif
 }
 
index b6a3f2cd839e2e54da79668ca8ddf5957a02cea2..88f7dee6df606dd0a60e2929f5a10cfc1477292e 100644 (file)
@@ -27,7 +27,7 @@ Score::setup_music()
     *mlog << "\nSetting up music ..." << flush;
     if (last() == Moment(0)) {
        errorlevel_i_ |= 1;
-       error("Need to have music in a score.", defined_ch_C_);
+       input_.error("Need to have music in a score.");
     }
 
     for (iter_top(staffs_,i); i.ok(); i++) {
@@ -234,7 +234,6 @@ Score::Score()
     paper_p_ = 0;
     midi_p_ = 0;
     errorlevel_i_ = 0;
-    defined_ch_C_ = 0;
 }
 
 Score::~Score()
@@ -261,9 +260,9 @@ Score::paper_output()
     Tex_stream the_output(paper_p_->outfile);
     
     the_output << "% outputting Score, defined at: " <<
-       source_l_g->
-       sourcefile_l (defined_ch_C_)->file_line_no_str(defined_ch_C_) << "\n";
+       input_.location_str() << "\n";
     pscore_p_->output(the_output);
+    
 }
 
 void
index 3115cb50072409d290ee74dd801570f65e67c79c..22526b42bd3cddc7173edbe98a7eae007ea5b9be 100644 (file)
@@ -14,8 +14,7 @@ do_scores()
     for (int i=0; i < score_array_global.size(); i++) {
        Input_score* &is_p = score_array_global[i];
        if (is_p->errorlevel_i_) {
-           warning("Score contains errors. Will not process it. ",
-                   is_p->defined_ch_C_);
+           is_p->warning("Score contains errors. Will not process it. ");
            delete is_p;
            continue;
        } 
index b782066c31453eb696fdb6e6362f903e27c4da4b..cd7b0814297cfa106d81ea349397697fec6d75e8 100644 (file)
@@ -75,3 +75,4 @@ Script_register::set_feature(Features i)
        dir_i_ = i.direction_i_;
 }
 IMPLEMENT_STATIC_NAME(Script_register);
+ADD_THIS_REGISTER(Script_register);
index 935a86468c82c001ed5c8bd076588a7de5bbabda..8acf6a1fec944100ff2276340d20ccd8c84498f2 100644 (file)
@@ -57,8 +57,8 @@ Slur_register::process_requests()
        // end slur: move the slur to other array
        if (slur_req_l->spantype == Span_req::STOP) {
            if (slur_l_stack_.empty())
-               warning("can't find slur to end",
-                     slur_req_l->defined_ch_C_);
+               
+                     slur_req_l->warning("can't find slur to end");
            else {
                end_slur_l_arr_.push(slur_l_stack_.pop());
                requests_arr_.pop();
@@ -95,7 +95,8 @@ Slur_register::post_move_processing()
 Slur_register::~Slur_register()
 {
     for (int i=0; i < requests_arr_.size(); i++) {
-       warning("unterminated slur", requests_arr_[i]->defined_ch_C_);
+       requests_arr_[i]->warning("unterminated slur");
     }
 }
 IMPLEMENT_STATIC_NAME(Slur_register);
+ADD_THIS_REGISTER(Slur_register);
index 8de13e023aeb59937b11f89a52c82cba23fc47b1..6e8e9e5f69495ce23884e49762c6e2d27e46c80f 100644 (file)
@@ -59,8 +59,8 @@ Slur::set_default_dir()
 void
 Slur::do_pre_processing()
 {
-    right  = encompass.top()->pcol_l_;
-    left = encompass[0]->pcol_l_;    
+    right_col_l_  = encompass.top()->pcol_l_;
+    left_col_l_ = encompass[0]->pcol_l_;    
 }
 
 Spanner*
@@ -74,9 +74,9 @@ Slur::do_break_at(PCol*l, PCol*r) const
        if (encompass[i]->pcol_l_->line_l_==l->line_l_)
            ret->encompass.push(encompass[i]);
     }
-    if (right != r)
+    if (right_col_l_ != r)
        ret->open_right = true;
-    if (left != l)
+    if (left_col_l_ != l)
        ret->open_left = true;
 
 
index 87a01078aa675e08e805cd2624610e63960ef980..d2a8c2bc756a59224670a4155cdc7d1cb033f895 100644 (file)
@@ -17,28 +17,29 @@ Spanner::broken_at(PCol*c1, PCol *c2)const
 {
     Spanner *span_p = do_break_at(c1,c2);
 
-    for (int i=0; i < dependants.size(); i++) {
-       dependants[i]->substitute_dependency((Staff_elem*)this, span_p); 
+    for (int i=0; i < dependant_l_arr_.size(); i++) {
+       dependant_l_arr_[i]->
+           substitute_dependency((Staff_elem*)this, span_p); 
     }
     
-    span_p->left = c1;
-    span_p->right = c2;
+    span_p->left_col_l_ = c1;
+    span_p->right_col_l_ = c2;
     
     return span_p;
 }
 
 Spanner::Spanner()
 {
-    left = right = 0;
+    left_col_l_ = right_col_l_ = 0;
 }
 
 
 Interval
 Spanner::width()const
 {
-    Real r = right->hpos;
-    Real l = left->hpos;
-    assert(*left < *right);
+    Real r = right_col_l_->hpos;
+    Real l = left_col_l_->hpos;
+    assert(*left_col_l_ < *right_col_l_);
     assert(r>=l);
        
     return Interval(0, r-l);
index baca3a0a98f3cfb8e99cbbbda0e9573d610cf83d..96c837fb573a512c2704dec3e5400edf98144aae 100644 (file)
@@ -121,6 +121,9 @@ align_items(Array<Item*> item_l_arr)
     Interval wid(0,0);
     for  (int i =0; i < item_l_arr.size(); i++) {
        Interval item_width= item_l_arr[i]->width();
+       if (item_width.empty_b()) {
+           item_width = Interval(0,0);
+       }
        Real dx =wid.right - item_width.left;
        item_width += dx;
        item_l_arr[i]->translate(Offset(dx ,0));
index 9a6283e373a34a982da3db9925e74ab3c6460a5b..1bb9db32d4224379d12ad0726c99e38f7d133413 100644 (file)
@@ -36,3 +36,5 @@ Features::dir(int d) return f;
     f.initialiser_b_ = true;
     f.direction_i_ = d;
 }
+
+
index d623d3b49a0518466791fd3c6e9d5d1397441396..4db170e0853f87d14f3fd286c6b16737fb58f102 100644 (file)
@@ -14,8 +14,8 @@ Staff_elem::TeXstring() const
 }
 
 Staff_elem::Staff_elem(Staff_elem const&s)
-    : dependants(s.dependants),
-      dependencies(s.dependencies)
+      :dependancy_l_arr_(s.dependancy_l_arr_),
+        dependant_l_arr_(s.dependant_l_arr_)
 {
     status = s.status;
     assert(!s.output);
@@ -25,7 +25,7 @@ Staff_elem::Staff_elem(Staff_elem const&s)
 }
 /**
   TODO:
-  If deleted, then remove dependants depency!
+  If deleted, then remove dependant_l_arr_ depency!
   */
 Staff_elem::~Staff_elem()
 {
@@ -49,7 +49,7 @@ Staff_elem::width() const
     } else
        r = output->extent().x;
   
-    if (!r.empty()) // float exception on DEC Alpha
+    if (!r.empty_b()) // float exception on DEC Alpha
        r+=offset_.x;
 
     return r;
@@ -66,7 +66,7 @@ Staff_elem::height() const
     } else
        r = output->extent().y;
     
-    if (!r.empty())
+    if (!r.empty_b())
        r+=offset_.y;
 
   
@@ -121,9 +121,9 @@ Staff_elem::pre_processing()
     assert(status != PRECALCING); // cyclic dependency
     status = PRECALCING;
 
-    for (int i=0; i < dependencies.size(); i++)
-       if (dependencies[i])
-           dependencies[i]->pre_processing();
+    for (int i=0; i < dependancy_l_arr_.size(); i++)
+       if (dependancy_l_arr_[i])
+           dependancy_l_arr_[i]->pre_processing();
 
     
     do_pre_processing();
@@ -137,9 +137,9 @@ Staff_elem::post_processing()
     assert(status != POSTCALCING);// cyclic dependency
     status=POSTCALCING;        
 
-    for (int i=0; i < dependencies.size(); i++)
-       if (dependencies[i])
-           dependencies[i]->post_processing();
+    for (int i=0; i < dependancy_l_arr_.size(); i++)
+       if (dependancy_l_arr_[i])
+           dependancy_l_arr_[i]->post_processing();
     do_post_processing();
     status=POSTCALCED;
 }
@@ -150,9 +150,9 @@ Staff_elem::molecule_processing()
     if (status >= OUTPUT)
        return;
     status = OUTPUT;           // do it only once.
-    for (int i=0; i < dependencies.size(); i++)
-       if (dependencies[i])
-           dependencies[i]->molecule_processing();
+    for (int i=0; i < dependancy_l_arr_.size(); i++)
+       if (dependancy_l_arr_[i])
+           dependancy_l_arr_[i]->molecule_processing();
 
     output= brew_molecule_p();
 }
@@ -176,26 +176,26 @@ void
 Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep)
 {
     bool hebbes_b=false;
-    for (int i=0; i < dependencies.size(); i++) {
-       if (dependencies[i] == old){
-           dependencies[i] = newdep;
+    for (int i=0; i < dependancy_l_arr_.size(); i++) {
+       if (dependancy_l_arr_[i] == old){
+           dependancy_l_arr_[i] = newdep;
            hebbes_b = true;
-       } else if (dependencies[i] == newdep) {
+       } else if (dependancy_l_arr_[i] == newdep) {
            hebbes_b = true;
        }
     }
     if (!hebbes_b)
-       dependencies.push(newdep);
+       dependancy_l_arr_.push(newdep);
 }
 
 void
 Staff_elem::add_dependency(Staff_elem * p)
 {
-    for (int i=0; i < dependencies.size(); i ++)
-       if (dependencies[i] == p)
+    for (int i=0; i < dependancy_l_arr_.size(); i ++)
+       if (dependancy_l_arr_[i] == p)
            return;
     
-    dependencies.push(p);
-    p->dependants.push(p);
+    dependancy_l_arr_.push(p);
+    p->dependant_l_arr_.push(p);
 }
 IMPLEMENT_STATIC_NAME(Staff_elem);
diff --git a/lily/staff-info.cc b/lily/staff-info.cc
new file mode 100644 (file)
index 0000000..b6fb13d
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+  staff-info.cc -- implement Staff_info
+
+  source file of the LilyPond music typesetter
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "staff.hh"
+#include "proto.hh"
+#include "staff-info.hh"
+#include "score-column.hh"
+#include "complex-walker.hh"
+#include "staff-column.hh"
+
+Staff*
+Staff_info::staff_l()
+{
+    return walk_l_->staff_l_;
+}
+
+Score*
+Staff_info::score_l()
+{
+    return staff_l()->score_l_;
+}
+Staff_info::Staff_info()
+{
+    c0_position_i_l_ = 0;
+    walk_l_ = 0;
+    time_C_ = 0;
+    rhythmic_C_ =0;
+    break_allowed_b_ = 0;
+}
+
+Staff_column*
+Staff_info::column_l()
+{
+    return  walk_l_->ptr();
+}
+
+Score_column*
+Staff_info::musical_l()
+{
+    return column_l() -> musical_column_l_;
+}
+
+Score_column*
+Staff_info::command_l()
+{
+    return column_l() -> command_column_l_;
+}
+PCol*
+Staff_info::command_pcol_l()
+{
+    return command_l()->pcol_l_;
+}
+
+Moment
+Staff_info::when()
+{
+    return walk_l_->when();
+}
+
diff --git a/lily/staff-regs.cc b/lily/staff-regs.cc
new file mode 100644 (file)
index 0000000..e22d328
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+  staff-regs.cc -- implement Staff_registers
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "staff-sym.hh"
+#include "voice-group-regs.hh"
+#include "voice-regs.hh"
+#include "staff-regs.hh"
+#include "command-request.hh"
+#include "bar.hh"
+#include "debug.hh"
+#include "input-register.hh"
+
+Staff_info
+Staff_registers::get_staff_info() return inf;
+{
+    inf = Request_register::get_staff_info();
+    inf.c0_position_i_l_ = &c0_position_i_;
+}
+
+Staff_registers::Staff_registers(Input_register const*ireg_C)
+{
+    c0_position_i_ = 0;
+    base_position_i_ =0;
+    add( ireg_C->get_nongroup_p_arr());
+    ireg_C_ =ireg_C;
+}
+
+/** Magic function which takes a Voice_registers out of one of its own
+  children, and puts it in another. This also handles the push and
+  popgroup feature.  */
+void
+Staff_registers::change_group(Group_change_req * greq_l,
+                              Voice_registers *voice_regs_l,
+                              Voice_group_registers * old_group)
+{
+
+    Voice_registers *regs_p = (old_group)
+       ? (Voice_registers*) old_group->get_register_p(
+           voice_regs_l)
+       : new Voice_registers(
+           greq_l->voice_l(), ireg_C_->get_ireg_l("Voice_group_registers")
+           ->get_ireg_l("Voice_registers"));
+
+    String new_str = greq_l->newgroup_str_;
+    String old_str;
+    if (old_group)
+        old_str = old_group->group_id_str_;
+    if ( new_str[0] == '+') {
+       new_str = old_str + new_str;
+    } else if (new_str[0] == '-') {
+       int idx = old_str.index_last_i('+');
+       if (idx >=0)
+           new_str = old_str.left_str ( idx );
+    }
+    Voice_group_registers * new_group_l = get_group(new_str);
+    new_group_l->add(regs_p);
+    
+    mtor << "processed change_group " << get_staff_info().when()<<"\n";
+    print();
+}
+
+Voice_group_registers *
+Staff_registers::get_group(String id)
+{
+    for (int i=0; i < group_l_arr_.size(); i++) {
+       if (group_l_arr_[i]->group_id_str_ == id)
+           return group_l_arr_[i];
+    }
+    Voice_group_registers *group_p = 
+       new Voice_group_registers(id, ireg_C_->get_ireg_l("Voice_group_registers"));
+    group_l_arr_.push(group_p);
+    add(group_p);
+    return group_p;
+}
+
+
+void
+Staff_registers::terminate_register(Request_register * reg)
+{
+    for (int i=0; i < group_l_arr_.size(); i++) {
+       if (group_l_arr_[i] == reg) {
+           group_l_arr_.del(i);
+           Register_group_register::terminate_register(reg);
+           return;
+       }
+    }
+    assert(false);
+}
+
+bool
+Staff_registers::try_request(Request * r)
+{
+    bool b = Register_group_register::try_request(r);
+    if (!b) {
+       Command_req * cr_l = r->command() ;
+       
+       if (cr_l && cr_l->groupchange()) {
+           change_group(cr_l->groupchange(), 0, 0);
+           b = true;
+       } else 
+           b= false;
+    }
+    return b;
+}
+
+IMPLEMENT_STATIC_NAME(Staff_registers);
+
+bool
+Staff_registers::acceptable_request_b(Request*r)const
+{
+    return Register_group_register::acceptable_request_b(r) ||
+       (r->command() && r->command()->groupchange());
+}
+
diff --git a/lily/staff-sym-reg.cc b/lily/staff-sym-reg.cc
new file mode 100644 (file)
index 0000000..34a53a5
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+  staff-sym-reg.cc -- implement Staff_sym_register
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "staff-sym-reg.hh"
+#include "staff-sym.hh"
+#include "score.hh"
+#include "p-col.hh"
+
+const NO_LINES = 5;
+
+Staff_sym_register::Staff_sym_register()
+{
+   span_p_ = 0;
+   last_mom_ =0;
+}
+
+void
+Staff_sym_register::post_move_processing()
+{
+    if (!span_p_ && !last_mom_) {
+       span_p_= new Staff_symbol(NO_LINES);
+       span_p_->left_col_l_ =
+           get_staff_info().command_pcol_l()->postbreak_p_; // GUH
+    }
+    if (!last_mom_) {
+       last_mom_ = get_staff_info().score_l()->last();
+    }
+}
+
+
+void
+Staff_sym_register::pre_move_processing()
+{
+    Staff_info i=get_staff_info();
+    if ( span_p_ && i.when() == last_mom_) {
+       span_p_->right_col_l_ = i.command_pcol_l()->prebreak_p_;
+       typeset_element(span_p_);
+       span_p_ =0;
+    }
+}
+
+IMPLEMENT_STATIC_NAME(Staff_sym_register);
+ADD_THIS_REGISTER(Staff_sym_register);
+Staff_sym_register::~Staff_sym_register()
+{
+    assert(!span_p_);
+    delete span_p_;
+}
diff --git a/lily/staff-sym.cc b/lily/staff-sym.cc
new file mode 100644 (file)
index 0000000..9eb0e76
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  staffsym.cc -- implement Staff_symbol
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "staff-sym.hh"
+#include "lookup.hh"
+#include "paper-def.hh"
+#include "debug.hh"
+
+
+
+Staff_symbol::Staff_symbol(int l)
+{
+    no_lines_i_ = l;
+}
+
+IMPLEMENT_STATIC_NAME(Staff_symbol);
+
+void
+Staff_symbol::do_print()const
+{
+    mtor << "lines: " << no_lines_i_;
+}
+
+Molecule*
+Staff_symbol::brew_molecule_p() const
+{
+    Atom a  = paper()->lookup_l()->linestaff(no_lines_i_, width().length());
+    return new Molecule(a);
+}
+
+Spanner*
+Staff_symbol::do_break_at(PCol*p1, PCol*p2)const
+{
+    Staff_symbol *span_p=new Staff_symbol(*this);
+    return span_p;
+}
+
+void
+Staff_symbol::set_extent(PCol*p1, PCol*p2)
+{
+    assert(p1&&p2);
+    left_col_l_ = p1;
+    right_col_l_ = p2;
+}
index 32cd6dab1f64fc4f12234bb1fb0d66d5b7c8145f..ea37d9d63eaf2ce87b43e422784eb3f0677e15a9 100644 (file)
@@ -57,7 +57,11 @@ Staff_walker::process_timing_reqs()
        if (tr_l->meterchange()) {
            int b_i=tr_l->meterchange()->beats_i_;
            int o_i = tr_l->meterchange()->one_beat_i_;
-           time_.set_meter(b_i, o_i);
+           if (! time_.allow_meter_change_b() )
+               
+                       tr_l->warning("Meterchange should be at start of measure");
+           else
+               time_.set_meter(b_i, o_i);
                        
            *default_grouping = Rhythmic_grouping(
                MInterval(0,Moment(b_i, o_i)), b_i);
@@ -69,7 +73,7 @@ Staff_walker::process_timing_reqs()
        if (tr_l->partial()) {
            time_.setpartial(tr_l->partial()->duration_);
        } else if (tr_l->barcheck() && time_.whole_in_measure_) {
-           warning( "Barcheck failed", tr_l->defined_ch_C_ );
+           tr_l ->warning( "Barcheck failed");
        } else if (tr_l->cadenza()) {
            time_.set_cadenza(tr_l->cadenza()->on_b_);
        } else if (tr_l->measuregrouping()) {
index b23f163d29fd8f8eb4886e93178d31de2be56628..d9623fe4363380b443e5fc7933eed5a47fabb795 100644 (file)
@@ -5,20 +5,17 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-
+#include "input-register.hh"
 #include "proto.hh"
-#include "plist.hh"
 #include "staff.hh"
 #include "score.hh"
 #include "voice.hh"
-#include "staff-walker.hh"
 #include "staff-column.hh"
 #include "score-column.hh"
 #include "voice-element.hh"
 #include "debug.hh"
 #include "musical-request.hh"
 #include "command-request.hh" // todo
-#include "midi-stream.hh"
 #include "pqueue.hh"
 
 
@@ -163,12 +160,14 @@ Staff::print() const
     for (iter_top(voice_list_,i); i.ok(); i++) {
        i->print();     
     }
+    ireg_p_->print();
     mtor <<"}\n";
 #endif
 }
 
 Staff::Staff()
 {    
+    ireg_p_ =0;
     score_l_ =0;
     pscore_l_ =0;
     pstaff_l_ =0;
index a0ac8a6f99d27aba974d6d9d115ad6575e76c419..742cee60c2653398a9090e4609a6e68440c3803e 100644 (file)
@@ -11,7 +11,9 @@
 static String
 make_vbox(Interval i)
 {
-    Real r = (i.empty()) ? 0.0 : i.length();
+    if (i.empty_b()) 
+       i = Interval(0,0);
+    Real r = i.length();
     String s("\\vbox to ");
     s += print_dimen(r);
     s += "{\\vskip "+print_dimen(i.right)+" ";
@@ -64,8 +66,8 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
     PCol *linestop = sc->cols.bottom();
     
     for (iter_top(pstaff_l_->spans,i); i.ok(); i++) {
-       PCol *brokenstart = &max(*linestart, *i->left);
-       PCol *brokenstop = &min(*linestop, *i->right);
+       PCol *brokenstart = &max(*linestart, *i->left_col_l_);
+       PCol *brokenstop = &min(*linestop, *i->right_col_l_);
        if ( *brokenstart < *brokenstop) {
            Spanner*span_p =i->broken_at(brokenstart,brokenstop);
            line_of_score_l_->pscore_l_-> // higghl
index 9169f785995d30ca0164cf3ee3217a33532cfa8b..80aa4507719754bb67a977aea59e3f5cf4d73387 100644 (file)
@@ -88,8 +88,8 @@ Stem_beam_register::process_requests()
 
        if (beam_p_) {
            if (stem_req_l_->duration_.type_i_<= 4)
-               warning( "stem doesn't fit in Beam",
-                        stem_req_l_->defined_ch_C_);
+               
+                        stem_req_l_->warning( "stem doesn't fit in Beam");
            else
                beam_p_->add(stem_p_);
            stem_p_->print_flag = false;
@@ -146,7 +146,7 @@ Stem_beam_register::post_move_processing()
 Stem_beam_register::~Stem_beam_register()
 {
     if (beam_p_)
-       warning("unterminated beam", start_req_l_->defined_ch_C_);
+       start_req_l_->warning("unterminated beam");
 }
 
 void
@@ -156,3 +156,4 @@ Stem_beam_register::set_feature(Features i)
 }
 
 IMPLEMENT_STATIC_NAME(Stem_beam_register);
+ADD_THIS_REGISTER(Stem_beam_register);
index 5e6592c482e4b5ce82ea99cc3d066cbf77d8baf9..047aec7b9f21a86516d4997ead7d38d34f9c116e 100644 (file)
@@ -42,7 +42,7 @@ Stem::set_stemend(Real se)
 
     // todo: margins
     if (!  ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0))  )        
-       warning("Weird stem size; check for narrow beams",0);
+       warning("Weird stem size; check for narrow beams");
     
     top = (dir < 0) ? maxnote           : se;
     bot = (dir < 0) ? se  : minnote;
@@ -107,7 +107,7 @@ void
 Stem::set_default_extents()
 {
     if (minnote > maxnote) {
-       warning("Empty stem. Ugh!", 0);
+       warning("Empty stem. Ugh!");
        minnote = -10;
        maxnote = 20;
     }
diff --git a/lily/swallow-reg.cc b/lily/swallow-reg.cc
new file mode 100644 (file)
index 0000000..24a20ef
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+  swallow-reg.cc -- implement Swallow_register
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "swallow-reg.hh"
+
+IMPLEMENT_STATIC_NAME(Swallow_register);
+ADD_THIS_REGISTER(Swallow_register);
+
+bool
+Swallow_register::acceptable_request_b(Request*) const
+{
+    return true;
+}
+
+bool
+Swallow_register::try_request(Request*) 
+{
+    return true;
+}
index 22affae7edbc6a29546f2d0ea61c2344849eafdd..71fb743886a7dd877a2a22041f7db224c96acb7d 100644 (file)
@@ -8,7 +8,6 @@ Text_def::Text_def()
 {   
     align_i_ = 1;                      // right
     style_str_ = "roman";
-    defined_ch_C_ = 0;
 }
 bool
 Text_def::compare(Text_def const &def)
index fbe54a5db4e0f7e19769c581e1debde379c663e9..5c61f6179dcc97e0451ae291efaec10b29fa1705 100644 (file)
@@ -58,3 +58,4 @@ Text_register::post_move_processing()
     text_req_l_ = 0;
 }
 IMPLEMENT_STATIC_NAME(Text_register);
+ADD_THIS_REGISTER(Text_register);
index 77ab800bdbd080e53c7e9f7771216c98e391808d..fbc04ca4c605be3f90cf9ba6f4dbd8502a923ea6 100644 (file)
@@ -55,9 +55,9 @@ Text_spanner::brew_molecule_p() const
 void
 Text_spanner::do_pre_processing()
 {
-    right = support->right;
-    left = support->left;
-    assert(left && right);
+    right_col_l_ = support->right_col_l_;
+    left_col_l_ = support->left_col_l_;
+    assert(left_col_l_ && right_col_l_);
 }
 
 Interval
index cdc0071a926e5f5181635d5d116612c050623ff5..2266b61b334e4ecbd0a05accca2ed4c33f99e6fd 100644 (file)
@@ -85,7 +85,11 @@ Time_description::set_meter(int l, int o)
     if(whole_in_measure_)
        error_t("Meterchange should be at start of measure", *this);
 }
-
+bool
+Time_description::allow_meter_change_b()
+{
+    return!(whole_in_measure_);
+}
 void
 Time_description::setpartial(Moment p)
 {
diff --git a/lily/voice-element.cc b/lily/voice-element.cc
new file mode 100644 (file)
index 0000000..b499e3d
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+  voice-elt.cc -- implement Voice_element
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "proto.hh"
+#include "plist.hh"
+#include "debug.hh"
+#include "voice.hh"
+#include "voice-element.hh"
+#include "musical-request.hh"
+#include "command-request.hh"
+
+
+void
+Voice_element::transpose(Melodic_req const&d)const
+{
+    for (iter_top(reqs,i); i.ok(); i++) {
+       i->transpose(d);
+      }
+}
+
+void
+Voice_element::print() const
+{
+#ifndef NPRINT
+    mtor << "voice_element { dur :"<< duration_ <<"\n";
+    for (iter_top(reqs,rc); rc.ok(); rc++) {
+       rc->print();
+    }
+    mtor << "}\n";
+#endif
+}
+
+void
+Voice_element::add(Request*r)
+{
+    if (r->duration()) {
+       assert (!duration_  || duration_ == r->duration());
+       duration_ = r->duration();
+    }
+    
+    r->elt_l_ = this;
+    reqs.bottom().add(r);
+}
+
+
+Voice_element::Voice_element()
+{
+    voice_C_ = 0;
+    duration_ = 0;
+}
+
+Voice_element::Voice_element(Voice_element const&src)
+    : Input(src)
+{
+  
+    voice_C_=0;
+    for (iter_top(src.reqs, i); i.ok(); i++)
+       add(i->clone());
+
+}
+bool
+Voice_element::find_plet_start_b(char c, Moment& moment_r)// b unused?
+{
+    assert( c == ']' );
+    moment_r += duration_;
+    for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
+       if (i->beam() && i->beam()->spantype == Span_req::START )
+           return true;
+    }
+    return false;
+}
+
+void
+Voice_element::set_default_group(String s)
+{
+    for (iter_top(reqs, i); i.ok(); i++)
+       if (i->command() &&i->command()->groupchange())
+           return ;
+    Group_change_req *greq = new Group_change_req;
+    greq->newgroup_str_ = s;
+    add(greq);
+}
+
+void
+Voice_element::set_plet_backwards(Moment& now_moment_r,
+                                 Moment until_moment, int num_i, int den_i)
+{
+    now_moment_r += duration_;
+    if ( now_moment_r > until_moment )
+       return;
+    for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
+       if (i->beam() && i->beam()->spantype == Span_req::START )
+           i->beam()->nplet = den_i;
+       if (i->rhythmic()) {
+           i->rhythmic()->duration_.plet_.type_i_ = den_i;
+           i->rhythmic()->duration_.plet_.iso_i_  = num_i;
+           
+       }
+    }
+}
index b9351bd8e8edb923abed6703947a64f4ad749ac0..476b204a53c73920be2b4363c94620d57e313b53 100644 (file)
 #include "voice-regs.hh"
 #include "voice-group-regs.hh"
 #include "register.hh"
-#include "text-reg.hh"
-#include "stem-beam-reg.hh"
-#include "script-reg.hh"
 #include "complex-walker.hh"
 #include "command-request.hh"
 #include "debug.hh"
-#include "dynamic-reg.hh"
+#include "input-register.hh"
 
 static int temp_id_count;
 
-Voice_group_registers::Voice_group_registers(String id)
+Voice_group_registers::Voice_group_registers(String id,
+                                            Input_register const *ireg_C)
 {
-    add(new Dynamic_register);
-    add(new Text_register);
-    add(new Stem_beam_register);
-    add(new Script_register);
-    
+    ireg_C_ =ireg_C;
+    Register_group_register::add(ireg_C->get_nongroup_p_arr());
     if (id=="")                        // UGH
        id = __FUNCTION__ + String(temp_id_count++);
     group_id_str_ = id;
@@ -44,35 +39,15 @@ Voice_group_registers::try_request(Request*r_l)
     }
     return false;
 gotcha:
-    if (r_l->groupfeature()) {
-       set_feature(Features::dir(r_l->groupfeature()->stemdir_i_));
+    Command_req* c_l = r_l->command();
+    if (c_l&& c_l->groupfeature()) {
+       set_feature(Features::dir(c_l->groupfeature()->stemdir_i_));
        return true;
     }
     return Register_group_register::try_request(r_l);
 }
 
 
-bool
-Voice_group_registers::static_acceptable_request_b(Request*r)
-{
-    return (r->stem() || r->beam() || r->text() || r->script() ||
-           r->groupfeature());
-}
-
-void
-Voice_group_registers::terminate_register(Request_register*r_l)
-{
-    if (r_l->name() == Voice_registers::static_name()) {
-       for (int i=0; i <voice_regs_l_.size(); i++) {
-           if (r_l == voice_regs_l_[i])
-               voice_regs_l_.del(i);
-           mtor << "Terminating voice_reg " ;
-           Register_group_register::terminate_register(r_l);
-           return;
-       }
-    }
-    assert(false);
-}
 IMPLEMENT_STATIC_NAME(Voice_group_registers);
 
 void
@@ -107,3 +82,15 @@ Voice_group_registers::post_move_processing()
     }
     Register_group_register::post_move_processing();
 }
+
+Request_register *
+Voice_group_registers::get_register_p(Request_register *reg_l)
+{
+     if (reg_l->name() == Voice_registers::static_name()) {
+       for (int i=0; i <voice_regs_l_.size(); i++) {
+           if (reg_l == voice_regs_l_[i])
+               voice_regs_l_.del(i);
+       }
+     }
+     return Register_group_register::get_register_p(reg_l);
+}
index 2aa7f18eb002d600d0f58cf2b6c127d943694815..55732e52a24065a8af2fc04e7b95f1fe38244f70 100644 (file)
 #include "musical-request.hh"
 #include "voice-regs.hh"
 #include "register.hh"
-#include "slur-reg.hh"
-#include "headreg.hh"
-#include "walk-regs.hh"
+#include "staff-regs.hh"       // needed because somebody has to delete us.
 #include "debug.hh"
+#include "input-register.hh"
+#include "voice-group-regs.hh"
 
-Voice_registers::Voice_registers(Voice *v_p)
+Voice_registers::Voice_registers(Voice *v_p, Input_register const*ireg_C)
 {
+    ireg_C_ = ireg_C;
     voice_l_ = v_p;
-    add(new Notehead_register);
-    add(new Slur_register);
+    add(ireg_C->get_nongroup_p_arr());
 }
 
 void
@@ -42,8 +42,12 @@ Voice_registers::try_request(Request*r_l)
        daddy_reg_l_->terminate_register(this);
        return true;            // scary. We're deleted now.. 
     } else if (c&&c->groupchange()) {
-
-       ((Walker_registers*)daddy_reg_l_->daddy_reg_l_)->       // scary.
+       /* this is scary as well. The groupchange has to be handled by
+        the Staff_registers, which are two levels up in the hierarchy
+        */
+         
+       assert(daddy_reg_l_->name() == Voice_group_registers::static_name());
+       ((Staff_registers*)daddy_reg_l_->daddy_reg_l_)->        // scary.
            change_group(c->groupchange(), this,
                         (Voice_group_registers*)daddy_reg_l_); // UGR!
        return true;
@@ -56,7 +60,7 @@ bool
 Voice_registers::acceptable_request_b(Request*r)
 {
     Command_req *  c_l = r->command();
-    return  r->groupchange() || (c_l&&c_l->terminate())
+    return   (c_l&&(c_l->terminate()||c_l->groupchange()))
        || Register_group_register::acceptable_request_b(r);
 }
 IMPLEMENT_STATIC_NAME(Voice_registers);
index d76b3ebe83f975e7f3e49e21ef8ccef1e9ae7b01..a5e10f7fd985847ca067cff56322ac6d6f94be6b 100644 (file)
@@ -65,7 +65,7 @@ Voice::Voice()
 void
 Voice::add(Voice_element*v)
 {
-    v->voice_l_ = this;
+    v->voice_C_ = this;
     elts.bottom().add(v);
 }
 
index b258bd559d23b42ebcabe28b4eb30b1d68da02da..e0221462e793d430711379f25befa4a578287d72 100644 (file)
@@ -5,32 +5,26 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-
 #include "debug.hh"
-#include "clef-reg.hh"
-#include "local-key-reg.hh"
-#include "key-reg.hh"
-#include "meter-reg.hh"
-#include "bar-reg.hh"
-#include "bar.hh"
 #include "walk-regs.hh"
+#include "staff-regs.hh"
 #include "staff-elem.hh"
 #include "staff.hh"
 #include "complex-walker.hh"
 #include "staff-column.hh"
-#include "voice-group-regs.hh"
-#include "voice-regs.hh"
-#include "command-request.hh"
 #include "score-walker.hh"
+#include "bar.hh"              // needed for Bar::static_name
+#include "input-register.hh"
 
 Walker_registers::Walker_registers(Complex_walker *w)
 {
     walk_l_ = w;
-    add( new Bar_register);
-    add( new Clef_register);
-    add( new Key_register);
-    add( new Meter_register);
-    add( new Local_key_register);
+    Input_register * ireg_l = w->staff_l_->ireg_p_;
+    if (ireg_l->name_str_ == "Staff_registers") 
+       add(new Staff_registers(ireg_l));
+    else {
+       add(ireg_l->get_nongroup_p_arr());
+    }
 }
 
 void
@@ -101,70 +95,12 @@ Walker_registers::post_move_processing()
     Register_group_register::post_move_processing();
 }
 
-void
-Walker_registers::change_group(Group_change_req * greq_l,
-                              Voice_registers *voice_regs_l,
-                              Voice_group_registers * old_group)
-{
-    Voice_registers *regs_p = (old_group)
-       ? (Voice_registers*) old_group->get_register_p(voice_regs_l)
-       : new Voice_registers(greq_l->voice_l());
-    Voice_group_registers * new_group_l = get_group(greq_l->newgroup_str_);
-    new_group_l->add(regs_p);
-    
-    mtor << "processed change request";
-    print();
-}
-
-Voice_group_registers *
-Walker_registers::get_group(String id)
-{
-    for (int i=0; i < group_l_arr_.size(); i++) {
-       if (group_l_arr_[i]->group_id_str_ == id)
-           return group_l_arr_[i];
-    }
-    Voice_group_registers *group_p = new Voice_group_registers(id);
-    group_l_arr_.push(group_p);
-    add(group_p);
-    return group_p;
-}
-
-void
-Walker_registers::terminate_register(Request_register * reg)
-{
-    for (int i=0; i < group_l_arr_.size(); i++) {
-       if (group_l_arr_[i] == reg) {
-           group_l_arr_.del(i);
-           Register_group_register::terminate_register(reg);
-           return;
-       }
-    }
-    assert(false);
-}
-
-bool
-Walker_registers::try_request(Request * r)
-{
-    bool b = Register_group_register::try_request(r);
-    if (!b) {
-       Command_req * cr_l = r->command() ;
-       
-       if (cr_l && cr_l->groupchange()) {
-           change_group(cr_l->groupchange(), 0, 0);
-       } else 
-           warning("junking request: "  + String(r->name()),
-                   r->defined_ch_C_);
-    }
-    return b;
-}
-
 
 Staff_info
 Walker_registers::get_staff_info() return inf;
 {
     if (walk_l_->score_walk_l_)        // we get called ctors
        inf.break_allowed_b_ = walk_l_->score_walk_l_->break_allowed_b();
-    inf.c0_position_i_ = &walk_l_->c0_position_i_;
     inf.walk_l_ = walk_l_;
     inf.time_C_ = &walk_l_->time_;
     inf.rhythmic_C_ = walk_l_->default_grouping;
index 2b9f1db767d265d4a5a2cfcef701e71834aab139..4240aa04b5459a6da8f2b0f6d64c3bd28a8320f8 100644 (file)
@@ -1,3 +1,11 @@
+/*
+  warn.cc -- implement warning and error messages. Needs cleanup.
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "proto.hh"
 #include "plist.hh"
 #include "debug.hh"
 #include "source-file.hh"
 #include "source.hh"
 #include "main.hh"
+#include "input.hh"
 
 ostream &warnout (cerr);
 ostream *mlog(&cerr);
-/*
-void
-warning(String s)
-{
-    WARN << s;
-}
-*/
+
 
 void
 error(String s)
@@ -44,7 +47,7 @@ error_t(String const & s, Time_description const &t_tdes)
 void
 message( String message_str, char const* context_ch_C )
 {
-    String str = "";           //"lilypond: ";// GNU format messages!
+    String str = "";
     Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C );
     if ( sourcefile_l ) {
        str += sourcefile_l->file_line_no_str(context_ch_C) + String(": ");
@@ -76,3 +79,16 @@ error( String message_str, char const* context_ch_C )
         lexer->errorlevel_i_ |= 1;*/
 //    exit( 1 );
 }
+
+
+void
+warning(String m)
+{
+    warning(m, (char*)0);
+}
+
+void
+message(String m)
+{
+    error(m, (char*)0);
+}
index 18de844098b55da6ee090175ad65210f27c577cc..ecf889bba652dfdd31a662b88e18248ada1b24cd 100644 (file)
@@ -143,7 +143,7 @@ Midi_track::output_mudela( Lily_stream& lily_stream_r )
                        tor( NORMAL_ver ) << '[' << flush; 
 
                if ( bars_i > bar_i ) { 
-                       Moment into_bar_mom = now_mom - ( bars_i - 1 ) * bar_mom;
+                       Moment into_bar_mom = now_mom - Moment( bars_i - 1 ) * bar_mom;
                        if ( bars_i > 1 ) {
                                if ( !into_bar_mom )
                                        lily_stream_r << "|";