+++ /dev/null
-#include "pstaff.hh"
-
-struct Linestaff : PStaff {
-
- int nolines;
-
-/****************/
-
- void brew_molecule_p(Real width);
- Linestaff(int, PScore*);
-};
+++ /dev/null
-/*
- rhythmstaf.hh -- part of LilyPond
-
- (c) 1996,97 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 Rest *get_rest(Rest_req *rq);
- virtual void set_output(PScore *);
-
- virtual Item* get_TYPESET_item(Command*);
- virtual Stem * get_stem(Stem_req *rq);
- virtual Notehead * get_notehead(Note_req *rq, int bot);
- virtual Local_key_item* get_local_key_item();
-};
-
-#endif // MELODICSTAFF_HH
-
-
+++ /dev/null
-/*
- rhythmstaf.hh -- part of LilyPond
-
- (c) 1996,97 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, int b);
- virtual void set_output(PScore *);
-};
-
-#endif // RHYTHMSTAF_HH
-
-
+++ /dev/null
-/*
- simplestaff.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SIMPLESTAFF_HH
-#define SIMPLESTAFF_HH
-
-#include "key.hh"
-#include "stcol.hh"
-#include "staff.hh"
-#include "staffwalker.hh"
-
-/*
- mega-stupido staffs and cols: they do notes one at each moment.
- */
-
-struct Simple_staff;
-struct Note_info {
- Rhythmic_req *rq;
- Array<Script_req*> scripts;
- Note_info();
- Note_info(Rhythmic_req*);
-};
-
-/// column of Simple_staff: store one request
-struct Simple_column : Staff_column {
-
- Array<Note_info> notes;
- Array<Slur_req *> slurs;
- Stem_req *stem_;
- Moment stem_requester_len;
- Beam_req *beam_;
- Simple_staff* staff_l_;
- Text_req *text_;
-
- /****************/
- Slur_req * find_slur(Voice *);
- void typeset_item(Item *, int=1);
- void typeset_item_directional(Item *, int dir, int=1);
-
- Molecule *create_command_mol(Command *com);
-
- void take_request(Request *rq);
- virtual void setup_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_l_;
-
- /****************/
- 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, int b)=0;
- virtual Rest *get_rest(Rest_req *rq);
- virtual void set_output(PScore *);
- virtual Local_key_item* get_local_key_item();
-
- void process_commands( PCursor<Command*> &where);
- virtual void walk();
-
- Simple_staff();
-};
-
-#endif // SIMPLESTAFF_HH
-
-
-
-
+++ /dev/null
-/*
- simplewalker.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SIMPLEWALKER_HH
-#define SIMPLEWALKER_HH
-
-#include "proto.hh"
-#include "grouping.hh"
-
-
-struct Simple_walker: Staff_walker {
- Stem *stem_;
- Array<Notehead *>noteheads;
- Local_key local_key_;
- Key key_;
- Array<int> *oldkey_undo;
- Array<int> typesetkey;
- Beam *beam_;
- Local_key_item *local_key_item_;
- bool wantkey; // urgh
- int processed_bar_priority;
- bool processed_key;
- bool processed_clef;
- Clef clef_;
- Rhythmic_grouping default_grouping;
- Rhythmic_grouping *current_grouping;
- Array<Slur_req*> pending_slur_reqs;
- Array<Slur*> pending_slurs;
-
- /****************/
-
- virtual void do_TYPESET_command(Command*);
- virtual void do_INTERPRET_command(Command*);
- virtual void process_requests();
- virtual void do_post_move();
- ~Simple_walker();
- Simple_walker(Simple_walker const& c);
- void do_note(Note_info);
- Simple_walker(Simple_staff*);
- Simple_column *col();
- Simple_staff *staff();
-
- void do_local_key(Note_req*, Notehead*);
- int find_slur(const Voice*v);
-};
-
-
-#endif // SIMPLEWALKER_HH
-
-
+++ /dev/null
-#include "linepstaff.hh"
-#include "molecule.hh"
-#include "symbol.hh"
-#include "lookup.hh"
-#include "dimen.hh"
-#include "paper.hh"
-#include "pscore.hh"
-
-Linestaff::Linestaff(int l, PScore *s)
- : PStaff(s)
-{
- nolines = l;
-}
-
-void
-Linestaff::brew_molecule_p(Real width)
-{
- Atom a = pscore_l_->paper_l_->lookup_p_->linestaff(nolines,width);
- stafsym_p_ = new Molecule(a);
-}
-
-
-
-
-
-
-
+++ /dev/null
-#include "melodicstaff.hh"
-#include "keyitem.hh"
-#include "stem.hh"
-#include "rest.hh"
-#include "notehead.hh"
-#include "paper.hh"
-#include "molecule.hh"
-#include "linepstaff.hh"
-//#include "rhythmstaff.hh"
-#include "sccol.hh"
-#include "localkeyitem.hh"
-#include "request.hh"
-
-const int NO_LINES=5;
-
-
-void
-Melodic_staff::set_output(PScore*ps)
-{
- theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later.
- Simple_staff::set_output(ps);
-}
-
-
-Notehead*
-Melodic_staff::get_notehead(Note_req *rq, int bottom)
-{
- Notehead *n =new Notehead((NO_LINES-1)*2);
- n->set_rhythmic(rq->rhythmic());
- n->position = rq->note()->height() + bottom;
- n->defined_ch_c_l_m = rq->defined_ch_c_l_m;
- return n;
-}
-
-Item *
-Melodic_staff::get_TYPESET_item(Command*com)
-{
- if (com->args[0] == "KEY") {
- return new Keyitem(NO_LINES); // urgh. depends on clef.
- } else
- return Simple_staff::get_TYPESET_item(com);
-}
-
-Stem *
-Melodic_staff::get_stem(Stem_req*rq)
-{
- Stem * s = new Stem(NO_LINES-1);
- s->flag = rq->balltype;
- return s;
-}
-
-Rest*
-Melodic_staff::get_rest(Rest_req*rq)
-{
- Rest*r = Simple_staff::get_rest(rq);
- if (rq->balltype <= 2)
- r->translate(Offset(0, NO_LINES * paper()->internote()));
- return r;
-}
-
-Local_key_item*
-Melodic_staff::get_local_key_item()
-{
- return new Local_key_item(-2);
-}
-
+++ /dev/null
-#include "molecule.hh"
-#include "score.hh"
-#include "request.hh"
-#include "notehead.hh"
-#include "stem.hh"
-#include "linepstaff.hh"
-#include "rhythmstaff.hh"
-#include "paper.hh"
-#include "sccol.hh"
-#include "rest.hh"
-
-void
-Rhythmic_staff::set_output(PScore*ps)
-{
- theline_l_ = new Linestaff(1,ps);
- Simple_staff::set_output(ps);
-}
-
-Item *
-Rhythmic_staff::get_TYPESET_item(Command *com)
-{
- if (com->args[0] == "KEY" || com->args[0] == "CLEF"||
- com->args[0] == "CURRENTCLEF")
- return 0;
- Item *i = Simple_staff::get_TYPESET_item(com);
- if (!i) return 0;
- i->translate(Offset(0,
- -score_l_->paper_p_->standard_height()/2));
- return i;
-}
-
-Notehead*
-Rhythmic_staff::get_notehead(Note_req *rq, int)
-{
- Notehead *n =new Notehead(1);
- n->set_rhythmic(rq->rhythmic());
- n->position = 0;
- return n;
-}
-
-Stem *
-Rhythmic_staff::get_stem(Stem_req*rq)
-{
- Stem * s = new Stem(0);
- s->flag = rq->balltype;
- return s;
-}
+++ /dev/null
-#include "clefitem.hh"
-#include "request.hh"
-#include "pscore.hh"
-#include "paper.hh"
-#include "simplestaff.hh"
-#include "sccol.hh"
-#include "rest.hh"
-#include "debug.hh"
-#include "bar.hh"
-#include "meter.hh"
-
-Item *
-Simple_staff::get_TYPESET_item(Command *com)
-{
- Item *s=0;
- Array<Scalar> arg( com->args);
- String type =arg[0];
- arg.del(0);
- if (type == "BAR" ) {
- s = new Bar(com->args[1]);
- } else if (type == "METER") {
- s = new Meter(arg);
- } else if (type == "CLEF" || type == "CURRENTCLEF") {
- Clef_item * c = new Clef_item;
- s = c;
- c->change = (type == "CLEF");
- }else{
- WARN << "ignoring TYPESET command for " << type << '\n';
- }
- return s;
-}
-
-
-Interval
-itemlist_width(const Array<Item*> &its)
-{
- Interval iv ;
- iv.set_empty();
-
- for (int j =0; j < its.size(); j++){
- iv.unite (its[j]->width());
-
- }
- return iv;
-}
-
-void
-Simple_column::typeset_item(Item *i, int breakst)
-{
- assert(i);
-
- staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
- staff_l_->theline_l_,breakst);
-
- if (breakst == BREAK_PRE - BREAK_PRE) {
-
- Array<Item*> to_move(
- staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
- score_column_l_->pcol_l_->prebreak_p_));
- Interval column_wid = itemlist_width(to_move);
- assert(!column_wid.empty());
-
- for (int j=0; j < to_move.size(); j++) {
- to_move[j]->translate(Offset(-column_wid.right, 0));
- }
- }
-}
-
-void
-Simple_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH!
-{
- assert(i);
- PCol * c=score_column_l_->pcol_l_;
- if (breakst == 0)
- c = c->prebreak_p_;
- else if (breakst == 2)
- c = c->postbreak_p_;
-
- Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
- c));
- typeset_item(i, breakst);
-
- Interval column_wid = itemlist_width(to_move);
- if (column_wid.empty())
- column_wid = Interval(0,0);
- i->translate(Offset(column_wid[dir] - i->width()[-dir], 0));
-}
-
-void
-Simple_staff::set_output(PScore* ps )
-{
- pscore_l_ = ps;
- pscore_l_->add(theline_l_);
-}
-
-
-Rest*
-Simple_staff::get_rest(Rest_req*rq)
-{
- int b = rq->rhythmic()->balltype;
- int d = rq->rhythmic()->dots;
- return new Rest(b, d);
-}
-
-Local_key_item*
-Simple_staff::get_local_key_item()
-{
- return 0;
-}
-
+++ /dev/null
-#include "request.hh"
-#include "voice.hh"
-#include "staffwalker.hh"
-#include "debug.hh"
-#include "clef.hh"
-#include "staff.hh"
-#include "command.hh"
-#include "simplestaff.hh"
-#include "sccol.hh"
-#include "simplewalker.hh"
-
-
-
-Simple_column::Simple_column(Score_column*s, Simple_staff *rs)
- : Staff_column(s)
-{
- stem_requester_len = 0;
- stem_ = 0;
- staff_l_ = rs;
- beam_ = 0;
- text_=0;
-
-}
-
-Simple_staff::Simple_staff()
-{
- theline_l_ = 0;
-}
-
-
-
-void
-Simple_column::setup_requests()
-{
- for (int i = 0 ; i < v_elts.size(); i ++)
- for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) {
- Request *rq= j;
- if (rq->barcheck()) {
- if (tdescription_->whole_in_measure) {
- warning( "Barcheck failed", rq->defined_ch_c_l_m );
- }
- }
- if (rq->rhythmic()){
- notes.push(rq->rhythmic());
- }
- if (rq->script()) {
- notes.top().scripts.push(rq->script());
- }
- if (rq->stem()) {
- stem_ = rq->stem();
- stem_requester_len = v_elts[i]->duration;
- }
- if (rq->text()) {
- text_ = rq->text();
- }
- if (rq->beam()) {
- beam_ = rq->beam();
- }
- if (rq->slur()) {
- slurs.push(rq->slur());
- }
- }
-}
-
-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()->setup_requests();// TODO
- sc.process();
- }
-}
-Note_info::Note_info()
-{
- rq =0;
-}
-Note_info::Note_info(Rhythmic_req*r) {
- rq = r;
-}
+++ /dev/null
-/*
- UGR!! CHAOS RULEZ
- */
-#include "textspanner.hh"
-#include "script.hh"
-#include "request.hh"
-#include "voice.hh"
-#include "clef.hh"
-#include "beam.hh"
-#include "pscore.hh"
-#include "simplestaff.hh"
-#include "simplewalker.hh"
-#include "sccol.hh"
-#include "stem.hh"
-#include "notehead.hh"
-#include "rest.hh"
-#include "debug.hh"
-#include "keyitem.hh"
-#include "clefitem.hh"
-#include "slur.hh"
-#include "localkeyitem.hh"
-#include "textitem.hh"
-#include "misc.hh"
-
-Rhythmic_grouping
-parse_grouping(Array<Scalar> const &a)
-{
- Array<int> r;
- Array<Moment> grouplen_arr;
- for (int i= 0 ; i < a.size()/2; ) {
- r.push(a[i++]);
- grouplen_arr.push(Moment(1,(int) a[i++]));
- }
- Moment here =0;
-
- Array<Rhythmic_grouping*> children;
- for (int i=0; i < r.size(); i++) {
-
- Moment last = here;
- here += grouplen_arr[i] * Rational(r[i]);
- children.push(
- new Rhythmic_grouping(MInterval(last, here), r[i] ));
- }
- return Rhythmic_grouping(children);
-}
-
-
-
-void
-Simple_walker::do_INTERPRET_command(Command*com)
-{
- Array<Scalar> args(com->args);
- args.del(0);
- if (com->args[0] == "GROUPING") {
- default_grouping = parse_grouping(args);
- }else if (com->args[0] == "NEWMEASURE") {
- local_key_.reset(key_);
-
- } else if (com->args[0] == "KEY") {
-
- if (col()->when() > Moment(0)) {
- assert(!oldkey_undo);
- oldkey_undo = new Array<int>( key_.oldkey_undo(args));
- }
-
- typesetkey = key_.read(args);
- local_key_.reset(key_);
- } else if (com->args[0] == "CLEF") {
- clef_.read(args);
- } else {
- WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n';
- }
-}
-
-void
-Simple_walker::do_TYPESET_command(Command*com)
-{
- /* ignore these commands if non-default versions have been
- processed. */
- if (com->args[0] == "CURRENTKEY")
- if (processed_key)
- return;
- else
- com->args[0] = "KEY"; // urgh
-
- if (com->args[0] == "CURRENTCLEF") {
- if (processed_clef)
- return;
- }
- if (com->args[0] == "BAR") {
-
- if (processed_bar_priority > com->priority)
- return;
- else
- processed_bar_priority = com->priority;
- }
-
- Item* i = staff()->get_TYPESET_item(com);
- if (!i)
- return;
-
- if (com->args[0] == "KEY") {
- ((Keyitem*) i)->read(clef_);
- if (oldkey_undo) {
- ((Keyitem*) i)->read(*oldkey_undo);
- delete oldkey_undo;
- oldkey_undo = 0;
- }
- processed_key = true;
-
- ((Keyitem*) i)->read(typesetkey); // ugh
- }
-
- if (com->args[0] == "CLEF"||com->args[0] == "CURRENTCLEF") {
- processed_clef =true;
- Clef_item*c=(Clef_item*)i;
- c->read(clef_);
- c->change = (break_status != BREAK_POST - BREAK_PRE);
- }
- col()->typeset_item_directional(i, 1, break_status);
-}
-
-void
-Simple_walker::do_local_key(Note_req*n,Notehead* head_p)
-{
- if ( local_key_.oct(n->octave).acc(n->notename) != n->accidental) {
- if (!local_key_item_) {
- local_key_item_ = staff()->get_local_key_item();
- local_key_item_->c0_position = clef_.c0_pos;
- }
- local_key_item_->add(head_p);
- local_key_item_->add(n->octave, n->notename, n->accidental);
- local_key_.oct(n->octave).set(n->notename, n->accidental);
- }
-}
-
-void
-Simple_walker::do_note(Note_info n)
-{
- Simple_column*c = col();
- Simple_staff *s = staff();
- Item*rhythmic=0;
- if (n.rq->note()) {
- Note_req * req = n.rq->note() ;
- const Voice *v = req->elt_l_->voice_l_;
-
- Notehead*n = s->get_notehead(req, clef_.c0_pos);
- rhythmic=n;
- if (stem_)
- stem_->add(n);
-
- if (current_grouping) {
- current_grouping->add_child(
- c->tdescription_->whole_in_measure, req->duration());
- }
- noteheads.push(n);
- int sidx =find_slur(v);
- if (sidx >= 0) {
- pending_slurs[sidx]->add(n);
- }
-
- if (wantkey)
- do_local_key(req,n);
- } else if (n.rq->rest()) {
- rhythmic = s->get_rest(n.rq->rest());
- c->typeset_item(rhythmic);
- }
- for (int i= 0; i < n.scripts.size(); i ++) {
- Script * s_p =new Script(n.scripts[i], 10);
- s_p->set_support(rhythmic);
- s_p->set_stem(stem_);
- c->typeset_item(s_p); // UGR
- }
-}
-
-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 (t = " +String(c->when())+")");
- beam_ = new Beam;
- assert(!current_grouping);
- current_grouping = new Rhythmic_grouping;
- }
-
- for (int i=0; i < c->slurs.size(); i++) {
- Slur_req*sl = c->slurs[i];
-
- if (sl->spantype == Span_req::START) {
- if (find_slur(sl->elt_l_->voice_l_)>=0)
- error( "Too many slurs in voice", sl->defined_ch_c_l_m );
- pending_slur_reqs.push(sl);
- pending_slurs.push(new Slur);
- }
- }
-
- if (c->text_) {
- c->typeset_item(new Text_item(c->text_, 10)); // UGR
- }
-
- if (c->stem_) {
- stem_ = s->get_stem(c->stem_->stem());
- }
-
- for (int i = 0; i < c->notes.size(); i ++) {
- do_note(c->notes[i]);
- }
-
- if (beam_) {
- if (!stem_)
- WARN <<"beamed note should have a stem (t = "
- <<String(c->when())<<")\n";
- else
- beam_->add(stem_);
-
-
- }
- if (stem_) {
- c->typeset_item(stem_);
- /* needed, otherwise placement of
- local_key fucks up */
- }
-
- if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
- if (!beam_) {
- error( "No beam to end", c->beam_->defined_ch_c_l_m );
- }
- default_grouping.extend(current_grouping->interval());
- beam_->set_grouping(default_grouping, *current_grouping);
- pscore_l_->typeset_spanner(beam_, s->theline_l_);
-
- if (c->beam_->nplet) {
- Text_spanner* t = new Text_spanner;
- t->set_support(beam_);
- t->spec.align_i_ = 0;
- t->spec.text_str_ = c->beam_->nplet;
- pscore_l_->typeset_spanner(t, s->theline_l_);
- }
-
- beam_ = 0;
- delete current_grouping;
- current_grouping =0;
- }
- for (int i = 0; i < noteheads.size(); i++) {
- c->typeset_item(noteheads[i]);
- }
- noteheads.set_size(0);
-
- if (local_key_item_) {
- c->typeset_item(local_key_item_);
- local_key_item_ = 0;
- }
- if (stem_) {
- stem_ = 0;
- }
- for (int i=0; i < c->slurs.size(); i++) {
- Slur_req *sl = c->slurs[i];
-
- if (sl->spantype == Span_req::STOP) {
- int idx = find_slur(sl->elt_l_->voice_l_);
- if (idx < 0)
- error( "can't find slur end", sl->defined_ch_c_l_m );
-
- pscore_l_->typeset_spanner(pending_slurs[idx],
- s->theline_l_);
- pending_slurs.del(idx);
- pending_slur_reqs.del(idx);
- }
- }
-
-}
-Simple_walker::Simple_walker(Simple_walker const&)
- : Staff_walker(0, 0)
-{
- assert(false);
-}
-
-Simple_walker::~Simple_walker()
-{
- if (pending_slurs.size())
- WARN << "destructing " << pending_slurs.size() << " Pending slurs ";
- if (beam_)
- WARN << "destructing Beam\n";
- if (local_key_item_)
- WARN<<"destructing Local_key_item\n";
- if (stem_)
- WARN<< "destructing Stem\n";
- delete local_key_item_;
- delete stem_;
- delete beam_;
-
-}
-
-Simple_walker::Simple_walker(Simple_staff*s)
- : Staff_walker(s, s->theline_l_->pscore_l_)
-{
- stem_ = 0;
- beam_ =0;
- oldkey_undo = 0;
- current_grouping = 0;
- Local_key_item * i = s->get_local_key_item();
- wantkey =i;
- delete i;
- local_key_item_ = 0;
- do_post_move();
-}
-
-
-
-Simple_staff*
-Simple_walker::staff()
-{
- return (Simple_staff*) staff_l_;
-}
-
-Simple_column*
-Simple_walker::col()
-{
- return (Simple_column*) *(*this);
-}
-
-void
-Simple_walker::do_post_move()
-{
- processed_clef =false;
- processed_key = false;
- processed_bar_priority = 0;
-}
-
-int
-Simple_walker::find_slur(const Voice *v)
-{
- for (int i=0; i < pending_slur_reqs.size(); i++) {
- if (pending_slur_reqs[i]->elt_l_->voice_l_== v)
- return i;
- }
- return -1;
-}
-
-