From 0c4e1a570b2ad2868f830c567a106666c5378923 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 12 Nov 1996 00:09:28 +0000 Subject: [PATCH] lilypond-0.0.9 --- Makefile | 80 +++++------------- hdr/Makefile | 8 ++ hdr/item.hh | 56 +++++++++++++ src/meter.cc | 20 +++++ src/pscore.cc | 205 +++++++++++++++++++++++++++++++++++++++++++++ src/rhythmstaff.cc | 62 ++++++++++++++ 6 files changed, 373 insertions(+), 58 deletions(-) create mode 100644 hdr/Makefile create mode 100644 hdr/item.hh create mode 100644 src/meter.cc create mode 100644 src/pscore.cc create mode 100644 src/rhythmstaff.cc diff --git a/Makefile b/Makefile index 2d8fa8a3ca..8f05ad90f8 100644 --- a/Makefile +++ b/Makefile @@ -1,55 +1,13 @@ -MAJVER=0 -MINVER=0 -PATCHLEVEL=8 - -TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) - -# -# - -include Sources.make -progdocs=$(hdr) $(mycc) -gencc=parser.cc lexer.cc -cc=$(mycc) $(gencc) -obs=$(cc:.cc=.o) - - -#dist -.EXPORT_ALL_VARIABLES: - -DOCDIR=docdir -VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) -PACKAGENAME=lilypond -DNAME=$(PACKAGENAME)-$(VERSION) -othersrc=lexer.l parser.y -SCRIPTS=make_version make_patch genheader -IFILES=dimen.tex symbol.ini suzan.ly maartje.ly\ - lilyponddefs.tex test.tex .dstreamrc -OFILES=Makefile Sources.make COPYING README -DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) - -#compiling -LOADLIBES=-L$(FLOWERDIR) -lflower -FLOWERDIR=../flower -# speedy -#DEFINES=-DNDEBUG -DNPRINT -O2 -# lots of debugging info -DEFINES=-g - -CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -W -pedantic -FLEX=flex -BISON=bison -exe=$(PACKAGENAME) - -################################################################## +include Make.variables $(exe): $(obs) - $(CXX) -o $@ $(obs) $(LOADLIBES) + $(CXX) -o $@ $^ $(LOADLIBES) + clean: rm -f $(exe) *.o $(DOCDIR)/* core distclean: clean - rm -f TAGS depend version.hh $(gencc) .GENERATE *~ + rm -f depend version.hh $(gencc) .GENERATE *~ all: kompijl doc @@ -58,8 +16,13 @@ doc: -mkdir $(DOCDIR) doc++ -p -I -d $(DOCDIR) $(progdocs) -depend: Sources.make .GENERATE - $(CXX) $(CXXFLAGS) -MM $(cc) > $@ +depend: Sources.make .GENERATE + touch depend + $(MAKE) realdepend + + +$(OBJECTDIR)/%.o: $(CCDIR)/%.cc + $(CXX) -c $(CXXFLAGS) $(OUTPUT_OPTION) # hack to create these sources once, before the dependencies .GENERATE: @@ -68,25 +31,26 @@ depend: Sources.make .GENERATE $(MAKE) $(gencc) rm -f depend +realdepend: $(cc) + $(CXX) $(CXXFLAGS) -MM $^ | perl -ne 's/^(.+)\.o/'$(OBJECTDIR)'\/\1.o/; print;' > depend + include depend -parser.cc: parser.y +$(CCDIR)/parser.cc: parser.y $(BISON) -d $< - mv parser.tab.h parser.hh - mv parser.tab.c parser.cc + mv $(CCDIR)/parser.tab.h $(HEADERDIR)/parser.hh + mv $(CCDIR)/parser.tab.c $(CCDIR)/parser.cc parser.hh: parser.cc version.o: $(obs) version.hh version.hh: Makefile make_version - make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@ + make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $(HEADERDIR)/$@ -lexer.cc: lexer.l +src/lexer.cc: lexer.l $(FLEX) -+ -t $< > $@ -DDIR=$(TOPDIR)/$(DNAME) -SUBDIRS=Documentation dist: -mkdir $(DDIR) ln $(DFILES) $(DDIR)/ @@ -98,7 +62,7 @@ dist: rm -rf $(DDIR)/ -TAGS: $(mycc) $(hdr) Sources.make - etags -CT $(mycc) $(hdr) - +TAGS: + $(MAKE) -C $(HEADERDIR) TAGS + $(MAKE) -C $(CCDIR) TAGS \ No newline at end of file diff --git a/hdr/Makefile b/hdr/Makefile new file mode 100644 index 0000000000..81a8f4595c --- /dev/null +++ b/hdr/Makefile @@ -0,0 +1,8 @@ +default: + $(MAKE) -C .. + +dist: + ln Makefile $(hdr) $(DDIR)/$(HEADERDIR) + +TAGS: $(hdr) + etags -CT $(hdr) diff --git a/hdr/item.hh b/hdr/item.hh new file mode 100644 index 0000000000..33b60831c1 --- /dev/null +++ b/hdr/item.hh @@ -0,0 +1,56 @@ +#ifndef ITEM_HH +#define ITEM_HH + +#include "glob.hh" +#include "boxes.hh" +#include "string.hh" + +/// a horizontally fixed size element of the score +struct Item { + /// indirection to the column it is in + PCol * pcol_; + + /// indirection to the pstaff it is in + PStaff *pstaff_; + + /// member: the symbols + Molecule *output; + + /// + Offset offset_; + /** + This is needed, because #output# may still be + NULL. + */ + /****************/ + + void translate(Offset); + + /// do calculations after determining horizontal spacing + virtual void postprocess(); + + /// do calculations before determining horizontal spacing + virtual void preprocess(); + /** + This is executed directly after the item is added to the + PScore + */ + + virtual Interval width() const; + virtual Interval height() const; + String TeXstring () const ; + Item(); + void print()const; + virtual ~Item(); + Paperdef *paper() const; +}; +/** Item is the datastructure for printables whose width is known + before the spacing is calculated + + NB. This doesn't mean an Item has to initialize the output field before + spacing calculation. + +*/ + + +#endif diff --git a/src/meter.cc b/src/meter.cc new file mode 100644 index 0000000000..0afa8ea1a1 --- /dev/null +++ b/src/meter.cc @@ -0,0 +1,20 @@ +#include "string.hh" +#include "molecule.hh" +#include "meter.hh" +#include "paper.hh" +#include "lookup.hh" + + +Meter::Meter(svec a) + :args(a) +{ +} +void +Meter::preprocess() +{ + Parametric_symbol *p = paper()->lookup_->meter("general"); + Symbol s = p->eval(args); + delete p; + output = new Molecule(Atom(s)); +} + diff --git a/src/pscore.cc b/src/pscore.cc new file mode 100644 index 0000000000..8d7067760f --- /dev/null +++ b/src/pscore.cc @@ -0,0 +1,205 @@ +// utility functions for PScore +#include "debug.hh" +#include "spanner.hh" +#include "paper.hh" +#include "molecule.hh" +#include "dimen.hh" +#include "scoreline.hh" +#include "pscore.hh" +#include "tstream.hh" + + +void +PScore::clean_cols() +{ + for (PCursor c(cols); c.ok(); ) + if (!c->used) { + c.del(); + } else + c++; +} + + +void +PScore::add(PStaff *s) +{ + assert(s->pscore_ == this); + staffs.bottom().add(s); +} + +void +PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) +{ + assert(c && i && s); +// assert(!breakstat != 4 || c->breakable() ); + if (breakstat == 0) { + typeset_item(i, c->prebreak, s); + return; + } + + if (breakstat == 2) { + typeset_item(i, c->postbreak, s); + return; + } + + + its.bottom().add(i); + s->add(i); + c->add(i); + + /* first do this, because i->width() may follow the 0-pointer */ + i->preprocess(); + + + if (c->daddy && c == c->daddy->prebreak) { // makeshift. + + Interval iv (i->width()); + if (!iv.empty()) { + svec col_its (select_items(s, c)); + for (int j =0; j < col_its.sz(); j++) + col_its[j]->translate(Offset(-iv.length(),0)); + i->translate (Offset(-iv.max, 0)); + } + } + +} + +void +PScore::typeset_spanner(Spanner*sp, PStaff*ps) +{ + sp->preprocess(); + sp->pstaff_ = ps; + spanners.bottom().add(sp); + ps->spans.bottom().add(sp); + sp->left->starters.bottom().add(sp); + sp->right->stoppers.bottom().add(sp); +} + + +void +PScore::add_line(svec curline, svec config) +{ + Line_of_score *p = new Line_of_score(curline,this); + lines.bottom().add(p); + for (int i=0; i < curline.sz(); i++){ + PCol *c=(PCol *)curline[i]; // so, this isn't really const. + c->hpos= config[i]; + } +} + +Idealspacing* +PScore::get_spacing(PCol*l, PCol*r) +{ + assert(l!=r); + for (PCursor ic (suz); ic.ok(); ic++) { + if (ic->left == l && ic->right == r){ + return ic; + } + } + + Idealspacing*ip =new Idealspacing(l,r); + suz.bottom().add(ip); + + return ip; +} + + +/* + return all breakable columns + */ +svec +PScore::find_breaks() const +{ + svec retval; + for (PCursor c(cols); c.ok(); c++) + if (c->breakable()) + retval.add(c); + + return retval; +} + +void +PScore::add(PCol *p) +{ + cols.bottom().add(p); +} + +PScore::PScore( Paperdef*p) +{ + paper_ = p; +} + +void +PScore::output(Tex_stream &ts) +{ + int l=1; + + for (PCursor lic(lines); lic.ok(); lic++) { + ts << "% line of score no. " << l++ <<"\n"; + ts << lic->TeXstring(); + if ((lic+1).ok()) + ts << "\\interscoreline\n"; + } +} + + +svec +PScore::select_items(PStaff*ps , PCol*pc) +{ + svec ret; + assert(ps && pc); + for (PCursor ic(pc->its); ic.ok(); ic++){ + if (ic->pstaff_ == ps) + ret.add((Item*)(const Item*)ic); + } + return ret; +} + +void +PScore::OK()const +{ +#ifdef NDEBUG + for (PCursor cc(cols); cc.ok(); cc++) + cc->OK(); + for (PCursor ic(suz); ic.ok(); ic++) + ic->OK(); +#endif +} + +void +PScore::print() const +{ +#ifndef NPRINT + mtor << "PScore { "; + paper_->print(); + mtor << "\ncolumns: "; + for (PCursor cc(cols); cc.ok(); cc++) + cc->print(); + + mtor << "\nideals: "; + for (PCursor ic(suz); ic.ok(); ic++) + ic->print(); + mtor << "}\n"; +#endif +} + +void +PScore::preprocess() +{ +#if 0 + for (PCursor ic(its); ic.ok(); ic++){ + ic->preprocess(); + } +#endif +} + +void +PScore::postprocess() +{ + for (PCursor ic(spanners); ic.ok(); ic++) { + ic->process(); + } + for (PCursor ic(its); ic.ok(); ic++){ + ic->postprocess(); + } +} diff --git a/src/rhythmstaff.cc b/src/rhythmstaff.cc new file mode 100644 index 0000000000..e584254bfd --- /dev/null +++ b/src/rhythmstaff.cc @@ -0,0 +1,62 @@ +#include "molecule.hh" +#include "notehead.hh" +#include "stem.hh" +#include "linestaff.hh" +#include "rhythmstaff.hh" +#include "paper.hh" +#include "sccol.hh" +#include "rest.hh" + +void +Rhythmic_staff::set_output(PScore*ps) +{ + theline = new Linestaff(1,ps); + Simple_staff::set_output(ps); +} + +Item * +Rhythmic_staff::get_TYPESET_item(Command *com) +{ + Item *i = Simple_staff::get_TYPESET_item(com); + i->translate(Offset(0, + -score_->paper_->standard_height()/2)); + return i; +} + +Notehead* +Rhythmic_staff::get_notehead(Note_req *rq) +{ + int b = rq->rhythmic()->balltype; + int d = rq->rhythmic()->dots; + + Notehead *n =new Notehead(1); + n->balltype = b; + n->dots =d; + n->position = 0; + return n; +} + +Stem * +Rhythmic_staff::get_stem(Stem_req*rq) +{ + Stem * s = new Stem(0); + s->flag = rq->stem_number; + return s; +} + +/* + creation + */ +Staff * +get_new_rhythmstaff() +{ + return new Rhythmic_staff; +} + + + +Rhythmic_staff* +Rhythmic_staff::clone() const +{ + return new Rhythmic_staff(*this); +} -- 2.39.5