From 05cf5c58c7d4999faa83fc83216274b590e8a722 Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 8 Nov 1996 23:55:49 +0000 Subject: [PATCH] lilypond-0.0.9 --- hdr/melodicstaff.hh | 27 +++++++++++ hdr/rhythmstaff.hh | 27 +++++++++++ hdr/simplestaff.hh | 79 +++++++++++++++++++++++++++++++++ src/melodicstaff.cc | 59 ++++++++++++++++++++++++ src/simplestaff.cc | 66 +++++++++++++++++++++++++++ src/simplewalker.cc | 106 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 364 insertions(+) create mode 100644 hdr/melodicstaff.hh create mode 100644 hdr/rhythmstaff.hh create mode 100644 hdr/simplestaff.hh create mode 100644 src/melodicstaff.cc create mode 100644 src/simplestaff.cc create mode 100644 src/simplewalker.cc diff --git a/hdr/melodicstaff.hh b/hdr/melodicstaff.hh new file mode 100644 index 0000000000..b447102de6 --- /dev/null +++ b/hdr/melodicstaff.hh @@ -0,0 +1,27 @@ +/* + rhythmstaf.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef MELODICSTAFF_HH +#define MELODICSTAFF_HH + +#include "simplestaff.hh" + +/// five line staff, no multiple voices +struct Melodic_staff : public Simple_staff +{ + + /****************/ + + virtual void set_output(PScore *); + virtual Melodic_staff*clone()const; + + virtual Stem * get_stem(Stem_req *rq); + virtual Notehead * get_notehead(Note_req *rq); +}; + +#endif // MELODICSTAFF_HH + + diff --git a/hdr/rhythmstaff.hh b/hdr/rhythmstaff.hh new file mode 100644 index 0000000000..46c35107d2 --- /dev/null +++ b/hdr/rhythmstaff.hh @@ -0,0 +1,27 @@ +/* + rhythmstaf.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef RHYTHMSTAF_HH +#define RHYTHMSTAF_HH + +#include "simplestaff.hh" + +/// all notes on one line +struct Rhythmic_staff : public Simple_staff +{ + + /****************/ + + virtual Item *get_TYPESET_item(Command*); + virtual Stem *get_stem(Stem_req *rq); + virtual Notehead * get_notehead(Note_req *rq); + virtual void set_output(PScore *); + virtual Rhythmic_staff*clone()const; +}; + +#endif // RHYTHMSTAF_HH + + diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh new file mode 100644 index 0000000000..c5c025a166 --- /dev/null +++ b/hdr/simplestaff.hh @@ -0,0 +1,79 @@ +/* + simplestaff.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SIMPLESTAFF_HH +#define SIMPLESTAFF_HH + +#include "stcol.hh" +#include "staff.hh" +#include "swalker.hh" +/* + mega-stupido staffs and cols: they do notes one at each moment. + */ + +struct Simple_staff; + +/// column of Simple_staff: store one request +struct Simple_column : Staff_column { + + svec notes; + Stem_req *stem_; + Beam_req *beam_; + Simple_staff* staff_; + + /****************/ + + virtual void typeset_item(Item *, int=1); + + Molecule *create_command_mol(Command *com); + + void take_request(Request *rq); + virtual void process_requests(); + + Simple_column(Score_column*s,Simple_staff*rs); +}; + + +/// Simple staff: one voicegroup at a time +struct Simple_staff : Staff { + /// indirection to the PStaff. + PStaff *theline; + + /****************/ + Staff_column*create_col(Score_column*); + + virtual Item *get_TYPESET_item(Command*); + virtual Stem *get_stem(Stem_req *rq)=0; + virtual Notehead *get_notehead(Note_req *rq)=0; + virtual Rest *get_rest(Rest_req *rq); + virtual void set_output(PScore *); + + void process_commands( PCursor &where); + virtual void walk(); + + Simple_staff(); +}; + +struct Simple_walker: Staff_walker { + Stem *stem_; + svecnoteheads; + Beam *beam_; + + /****************/ + + virtual void process_command(Command*); + virtual void process_requests(); + Simple_walker(Simple_staff*); + Simple_column *col(); + Simple_staff *staff(); +}; + + +#endif // SIMPLESTAFF_HH + + + + diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc new file mode 100644 index 0000000000..17916d2f22 --- /dev/null +++ b/src/melodicstaff.cc @@ -0,0 +1,59 @@ +#include "melodicstaff.hh" +#include "stem.hh" +#include "rest.hh" +#include "notehead.hh" +#include "paper.hh" +#include "molecule.hh" +#include "linestaff.hh" +#include "rhythmstaff.hh" +#include "sccol.hh" + +const int NO_LINES=5; +const int BOTTOM_POSITION=2; // e is on bottom line of 5-staff... + +void +Melodic_staff::set_output(PScore*ps) +{ + theline = new Linestaff(NO_LINES,ps); + Simple_staff::set_output(ps); +} + + +Notehead* +Melodic_staff::get_notehead(Note_req *rq) +{ + int b = rq->rhythmic()->balltype; + int d = rq->rhythmic()->dots; + + Notehead *n =new Notehead((NO_LINES-1)*2); + n->balltype =b; + n->dots = d; + n->position = rq->note()->height() - BOTTOM_POSITION; + return n; +} + + +Stem * +Melodic_staff::get_stem(Stem_req*rq) +{ + Stem * s = new Stem(NO_LINES-1); + s->flag = rq->stem_number; + return s; +} + +/* + creation + */ +Staff * +get_new_melodicstaff() +{ + return new Melodic_staff; +} + + + +Melodic_staff* +Melodic_staff::clone()const +{ + return new Melodic_staff(*this); +} diff --git a/src/simplestaff.cc b/src/simplestaff.cc new file mode 100644 index 0000000000..5150d5478a --- /dev/null +++ b/src/simplestaff.cc @@ -0,0 +1,66 @@ +#include "request.hh" +#include "swalker.hh" +#include "debug.hh" +#include "staff.hh" +#include "command.hh" +#include "simplestaff.hh" +#include "sccol.hh" + + + + +Simple_column::Simple_column(Score_column*s, Simple_staff *rs) + : Staff_column(s) +{ + stem_ = 0; + staff_ = rs; + beam_ = 0; +} + +Simple_staff::Simple_staff() +{ + theline = 0; +} + +/** + accept: + + BREAK: all + TYPESET: bar, meter, + + */ + + + +void +Simple_column::process_requests() +{ + for (int i = 0 ; i < v_elts.sz(); i ++) + for (PCursor rqc(v_elts[i]->reqs); rqc.ok(); rqc++) { + Request *rq= rqc; + if (rq->rhythmic()){ + notes.add( rq->rhythmic()); + } + if (rq->stem()) { + stem_ = rq->stem(); + } + + if (rq->beam()) { + beam_ = rq->beam(); + } + } +} +Staff_column* +Simple_staff::create_col(Score_column*s) +{ + return new Simple_column(s,this); +} +void +Simple_staff::walk() +{ + for (Simple_walker sc(this); sc.ok(); sc++) { + sc.col()->process_requests();// TODO + sc.process(); + } +} + diff --git a/src/simplewalker.cc b/src/simplewalker.cc new file mode 100644 index 0000000000..ad9019ac33 --- /dev/null +++ b/src/simplewalker.cc @@ -0,0 +1,106 @@ +#include "request.hh" +#include "beam.hh" +#include "pscore.hh" +#include "simplestaff.hh" +#include "sccol.hh" +#include "stem.hh" +#include "notehead.hh" +#include "rest.hh" +#include "debug.hh" + +void +Simple_walker::process_command(Command*com) +{ + switch (com->code){ + case BREAK_PRE: + case BREAK_MIDDLE: + case BREAK_POST: + case BREAK_END: + (*this)->score_column->set_breakable(); + break_status = com->code- BREAK_PRE; + break; + case INTERPRET: + break; + + case TYPESET: + { + Item* i = staff()->get_TYPESET_item(com); + col()->typeset_item(i, break_status); + } + break; + + default : + break; + } +} + +void +Simple_walker::process_requests() +{ + Simple_column*c = col(); + Simple_staff *s = staff(); + if (c->beam_&& c->beam_->spantype == Span_req::START) { + if (beam_) + error("Too many beams"); + beam_ = new Beam; + } + + if (c->stem_) { + stem_ = s->get_stem(c->stem_->stem()); + c->typeset_item(stem_); + } + + for (int i = 0; i < c->notes.sz(); i ++) { + Rhythmic_req*rq = c->notes[i]; + if (rq->note()) { + Notehead*n = s->get_notehead(rq->note()); + stem_->add(n); + noteheads.add(n); + } + + if (rq->rest()) { + c->typeset_item( s->get_rest(rq->rest()) ); + } + } + + + if (beam_) { + beam_->add(stem_); + } + + if (c->beam_&& c->beam_->spantype == Span_req::STOP) { + pscore_->typeset_spanner(beam_, s->theline); + beam_ = 0; + } + for (int i = 0; i < noteheads.sz(); i++) { + c->typeset_item(noteheads[i]); + } + noteheads.set_size(0); + + if (stem_) { + stem_ = 0; + } +} + +Simple_walker::Simple_walker(Simple_staff*s) + : Staff_walker(s, s->theline->pscore_) +{ + stem_ = 0; + beam_ =0; +} + + + +Simple_staff* +Simple_walker::staff() +{ + return (Simple_staff*) staff_; +} + +Simple_column* +Simple_walker::col() +{ + return (Simple_column*) *(*this); +} + + -- 2.39.5