From cd6fbd39e456ab3ff353c38fc5ae1997e61390f2 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 30 Nov 1996 12:09:32 +0100 Subject: [PATCH] release: 0.0.9 --- Documentation/CodingStyle | 44 ++++- Documentation/Makefile | 3 +- Documentation/breaking | 38 +++++ Make.variables | 71 ++++++++ Makefile | 80 +++------ README | 31 +++- Sources.make | 19 ++- flower/Makefile | 6 +- flower/README | 4 +- flower/TODO | 2 - flower/dstream.cc | 5 +- flower/list.cc | 40 +++-- flower/list.hh | 18 +-- flower/list.inl | 7 - flower/pcursor.hh | 7 +- flower/plist.hh | 4 +- hdr/Makefile | 8 + hdr/bar.hh | 18 +++ hdr/beam.hh | 44 +++++ boxes.hh => hdr/boxes.hh | 5 + command.hh => hdr/command.hh | 11 +- const.hh => hdr/const.hh | 0 debug.hh => hdr/debug.hh | 0 dimen.hh => hdr/dimen.hh | 0 glob.hh => hdr/glob.hh | 0 globvars.hh => hdr/globvars.hh | 0 identifier.hh => hdr/identifier.hh | 0 item.hh => hdr/item.hh | 21 ++- keyword.hh => hdr/keyword.hh | 0 hdr/leastsquares.hh | 19 +++ lexer.hh => hdr/lexer.hh | 3 +- linespace.hh => hdr/linespace.hh | 6 +- linestaff.hh => hdr/linestaff.hh | 0 lookupsyms.hh => hdr/lookup.hh | 8 +- main.hh => hdr/main.hh | 0 hdr/melodicstaff.hh | 27 ++++ hdr/meter.hh | 18 +++ misc.hh => hdr/misc.hh | 0 molecule.hh => hdr/molecule.hh | 0 notehead.hh => hdr/notehead.hh | 0 notename.hh => hdr/notename.hh | 0 paper.hh => hdr/paper.hh | 10 +- parseconstruct.hh => hdr/parseconstruct.hh | 9 +- pcol.hh => hdr/pcol.hh | 2 +- proto.hh => hdr/proto.hh | 5 +- pscore.hh => hdr/pscore.hh | 20 ++- pstaff.hh => hdr/pstaff.hh | 0 qlp.hh => hdr/qlp.hh | 0 qlpsolve.hh => hdr/qlpsolve.hh | 0 request.hh => hdr/request.hh | 82 ++++++---- hdr/rest.hh | 33 ++++ hdr/rhythmstaff.hh | 27 ++++ sccol.hh => hdr/sccol.hh | 10 +- scommands.hh => hdr/scommands.hh | 8 +- score.hh => hdr/score.hh | 0 line.hh => hdr/scoreline.hh | 28 +--- simplestaff.hh => hdr/simplestaff.hh | 42 +++-- spanner.hh => hdr/spanner.hh | 28 +++- staff.hh => hdr/staff.hh | 2 +- hdr/staffline.hh | 29 ++++ stcol.hh => hdr/stcol.hh | 9 +- stem.hh => hdr/stem.hh | 34 +++- hdr/swalker.hh | 34 ++++ symbol.hh => hdr/symbol.hh | 0 symtable.hh => hdr/symtable.hh | 0 tex.hh => hdr/tex.hh | 0 tstream.hh => hdr/tstream.hh | 0 voice.hh => hdr/voice.hh | 0 item.cc | 52 ------ kortjakje.ly | 40 +++++ lilyponddefs.tex | 20 ++- maartje.ly | 15 +- make_patch | 9 +- melodicstaff.cc | 78 --------- melodicstaff.hh | 32 ---- objects/Makefile | 2 + rhythmstaff.cc | 76 --------- rhythmstaff.hh | 36 ----- simpleprint.cc | 75 --------- simplestaff.cc | 91 ----------- spanner.cc | 33 ---- src/Makefile | 8 + src/bar.cc | 18 +++ src/beam.cc | 179 +++++++++++++++++++++ boxes.cc => src/boxes.cc | 0 break.cc => src/break.cc | 19 ++- calcideal.cc => src/calcideal.cc | 0 command.cc => src/command.cc | 0 debug.cc => src/debug.cc | 0 dimen.cc => src/dimen.cc | 0 getcommands.cc => src/getcommands.cc | 0 identifier.cc => src/identifier.cc | 2 +- src/item.cc | 73 +++++++++ keyword.cc => src/keyword.cc | 0 src/leastsquares.cc | 25 +++ lexer.l => src/lexer.l | 47 ++++-- linespace.cc => src/linespace.cc | 21 ++- linestaff.cc => src/linestaff.cc | 2 +- lookupsyms.cc => src/lookup.cc | 2 +- main.cc => src/main.cc | 15 +- src/melodicstaff.cc | 59 +++++++ src/meter.cc | 20 +++ misc.cc => src/misc.cc | 0 molecule.cc => src/molecule.cc | 21 ++- note.cc => src/note.cc | 81 +++++++++- notehead.cc => src/notehead.cc | 6 +- notename.cc => src/notename.cc | 0 paper.cc => src/paper.cc | 10 +- parser.y => src/parser.y | 75 ++++++++- pcol.cc => src/pcol.cc | 3 +- pscore.cc => src/pscore.cc | 51 ++++-- pstaff.cc => src/pstaff.cc | 0 qlp.cc => src/qlp.cc | 0 qlpsolve.cc => src/qlpsolve.cc | 0 request.cc => src/request.cc | 28 ++-- src/rest.cc | 47 ++++++ src/rhythmstaff.cc | 62 +++++++ sccol.cc => src/sccol.cc | 0 scommands.cc => src/scommands.cc | 17 +- score.cc => src/score.cc | 0 src/scoreline.cc | 43 +++++ scores.cc => src/scores.cc | 0 src/simpleprint.cc | 55 +++++++ src/simplestaff.cc | 66 ++++++++ src/simplewalker.cc | 106 ++++++++++++ src/spanner.cc | 54 +++++++ staff.cc => src/staff.cc | 7 +- line.cc => src/staffline.cc | 60 ++----- stcol.cc => src/stcol.cc | 0 src/stem.cc | 156 ++++++++++++++++++ src/swalker.cc | 32 ++++ symbol.cc => src/symbol.cc | 0 symtable.cc => src/symtable.cc | 4 +- table.cc => src/table.cc | 3 + template1.cc => src/template1.cc | 4 +- template2.cc => src/template2.cc | 2 +- template3.cc => src/template3.cc | 0 tex.cc => src/tex.cc | 0 src/texbeam.cc | 99 ++++++++++++ tstream.cc => src/tstream.cc | 0 version.cc => src/version.cc | 0 voice.cc => src/voice.cc | 1 + warn.cc => src/warn.cc | 0 stem.cc | 99 ------------ suzan.ly | 8 - symbol.ini | 15 +- 146 files changed, 2284 insertions(+), 959 deletions(-) create mode 100644 Documentation/breaking create mode 100644 Make.variables create mode 100644 hdr/Makefile create mode 100644 hdr/bar.hh create mode 100644 hdr/beam.hh rename boxes.hh => hdr/boxes.hh (93%) rename command.hh => hdr/command.hh (91%) rename const.hh => hdr/const.hh (100%) rename debug.hh => hdr/debug.hh (100%) rename dimen.hh => hdr/dimen.hh (100%) rename glob.hh => hdr/glob.hh (100%) rename globvars.hh => hdr/globvars.hh (100%) rename identifier.hh => hdr/identifier.hh (100%) rename item.hh => hdr/item.hh (75%) rename keyword.hh => hdr/keyword.hh (100%) create mode 100644 hdr/leastsquares.hh rename lexer.hh => hdr/lexer.hh (84%) rename linespace.hh => hdr/linespace.hh (94%) rename linestaff.hh => hdr/linestaff.hh (100%) rename lookupsyms.hh => hdr/lookup.hh (79%) rename main.hh => hdr/main.hh (100%) create mode 100644 hdr/melodicstaff.hh create mode 100644 hdr/meter.hh rename misc.hh => hdr/misc.hh (100%) rename molecule.hh => hdr/molecule.hh (100%) rename notehead.hh => hdr/notehead.hh (100%) rename notename.hh => hdr/notename.hh (100%) rename paper.hh => hdr/paper.hh (59%) rename parseconstruct.hh => hdr/parseconstruct.hh (65%) rename pcol.hh => hdr/pcol.hh (98%) rename proto.hh => hdr/proto.hh (96%) rename pscore.hh => hdr/pscore.hh (84%) rename pstaff.hh => hdr/pstaff.hh (100%) rename qlp.hh => hdr/qlp.hh (100%) rename qlpsolve.hh => hdr/qlpsolve.hh (100%) rename request.hh => hdr/request.hh (93%) create mode 100644 hdr/rest.hh create mode 100644 hdr/rhythmstaff.hh rename sccol.hh => hdr/sccol.hh (85%) rename scommands.hh => hdr/scommands.hh (76%) rename score.hh => hdr/score.hh (100%) rename line.hh => hdr/scoreline.hh (52%) rename simplestaff.hh => hdr/simplestaff.hh (54%) rename spanner.hh => hdr/spanner.hh (73%) rename staff.hh => hdr/staff.hh (97%) create mode 100644 hdr/staffline.hh rename stcol.hh => hdr/stcol.hh (89%) rename stem.hh => hdr/stem.hh (52%) create mode 100644 hdr/swalker.hh rename symbol.hh => hdr/symbol.hh (100%) rename symtable.hh => hdr/symtable.hh (100%) rename tex.hh => hdr/tex.hh (100%) rename tstream.hh => hdr/tstream.hh (100%) rename voice.hh => hdr/voice.hh (100%) delete mode 100644 item.cc create mode 100644 kortjakje.ly delete mode 100644 melodicstaff.cc delete mode 100644 melodicstaff.hh create mode 100644 objects/Makefile delete mode 100644 rhythmstaff.cc delete mode 100644 rhythmstaff.hh delete mode 100644 simpleprint.cc delete mode 100644 simplestaff.cc delete mode 100644 spanner.cc create mode 100644 src/Makefile create mode 100644 src/bar.cc create mode 100644 src/beam.cc rename boxes.cc => src/boxes.cc (100%) rename break.cc => src/break.cc (86%) rename calcideal.cc => src/calcideal.cc (100%) rename command.cc => src/command.cc (100%) rename debug.cc => src/debug.cc (100%) rename dimen.cc => src/dimen.cc (100%) rename getcommands.cc => src/getcommands.cc (100%) rename identifier.cc => src/identifier.cc (93%) create mode 100644 src/item.cc rename keyword.cc => src/keyword.cc (100%) create mode 100644 src/leastsquares.cc rename lexer.l => src/lexer.l (84%) rename linespace.cc => src/linespace.cc (94%) rename linestaff.cc => src/linestaff.cc (93%) rename lookupsyms.cc => src/lookup.cc (99%) rename main.cc => src/main.cc (88%) create mode 100644 src/melodicstaff.cc create mode 100644 src/meter.cc rename misc.cc => src/misc.cc (100%) rename molecule.cc => src/molecule.cc (85%) rename note.cc => src/note.cc (64%) rename notehead.cc => src/notehead.cc (91%) rename notename.cc => src/notename.cc (100%) rename paper.cc => src/paper.cc (89%) rename parser.y => src/parser.y (76%) rename pcol.cc => src/pcol.cc (97%) rename pscore.cc => src/pscore.cc (81%) rename pstaff.cc => src/pstaff.cc (100%) rename qlp.cc => src/qlp.cc (100%) rename qlpsolve.cc => src/qlpsolve.cc (100%) rename request.cc => src/request.cc (86%) create mode 100644 src/rest.cc create mode 100644 src/rhythmstaff.cc rename sccol.cc => src/sccol.cc (100%) rename scommands.cc => src/scommands.cc (93%) rename score.cc => src/score.cc (100%) create mode 100644 src/scoreline.cc rename scores.cc => src/scores.cc (100%) create mode 100644 src/simpleprint.cc create mode 100644 src/simplestaff.cc create mode 100644 src/simplewalker.cc create mode 100644 src/spanner.cc rename staff.cc => src/staff.cc (95%) rename line.cc => src/staffline.cc (64%) rename stcol.cc => src/stcol.cc (100%) create mode 100644 src/stem.cc create mode 100644 src/swalker.cc rename symbol.cc => src/symbol.cc (100%) rename symtable.cc => src/symtable.cc (92%) rename table.cc => src/table.cc (92%) rename template1.cc => src/template1.cc (86%) rename template2.cc => src/template2.cc (94%) rename template3.cc => src/template3.cc (100%) rename tex.cc => src/tex.cc (100%) create mode 100644 src/texbeam.cc rename tstream.cc => src/tstream.cc (100%) rename version.cc => src/version.cc (100%) rename voice.cc => src/voice.cc (98%) rename warn.cc => src/warn.cc (100%) delete mode 100644 stem.cc delete mode 100644 suzan.ly diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index c5d730c0a6..2c621ee06c 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle @@ -1,3 +1,5 @@ +-*-text-*- + CODING STANDARDS: Functions and methods do not return errorcodes, but use assert for @@ -19,14 +21,15 @@ INDENTATION, in emacs: CLASSES and TYPES: This_is_a_class + AClass_name (for Abbreviation_class_name) DATA MEMBERS - Class:member + Class::member -if the member's name resembles its type, then we use +if the member's name resembles its type, then I use - Class Fubular { ..} + class Fubular { ..} Class::fubular_ @@ -52,4 +55,37 @@ class Class { Class documentation. */ -Unfortunately most of the code isn't really documented that good. \ No newline at end of file +Unfortunately most of the code isn't really documented that good. + +CLASSNAMES (2) + +A lot of classes in LilyPond start with 'P', this is to distinguish +certain parts of LilyPond: the P stands for Printer, and the P-classes +are supposed to be more lowlevel than the others. Example: + + Staff uses PStaff, PScore and PCol to do the typesetting of +symbols. Staff is are the "brains" for PStaff + +NB: in PCursor (which is part of the library) P stands for PointerCursor + + +MEMBERS(2) + +Standard methods: + + ///check that *this satisfies its invariants, abort if not. + void OK() const + + /// print *this (and substructures) to debugging log + void print() const + + /// add some data to *this; + add( .. ) + /** + Presence of these methods usually imply that it is not feasible to this + via a constructor + */ + + /// replace some data of *this + set( .. ) + diff --git a/Documentation/Makefile b/Documentation/Makefile index da2847045e..e8adae90d7 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,4 +1,5 @@ -DOCFILES=CodingStyle algorithms Makefile +DOCFILES=CodingStyle algorithms Makefile breaking + dist: ln $(DOCFILES) $(DDIR)/Documentation/ \ No newline at end of file diff --git a/Documentation/breaking b/Documentation/breaking new file mode 100644 index 0000000000..ea1ada7e10 --- /dev/null +++ b/Documentation/breaking @@ -0,0 +1,38 @@ +[Source files: command.hh, scommands.cc] + +BREAKING, PREBREAK POSTBREAK, etc. + +So what's the deal with PREBREAK and POSTBREAK and all this +stuff? + +Let's take text as an example. In German some compound +words change their spelling if they are broken: "backen" becomes +"bak-ken". TeX has a mechanism to deal with this, you would define +the spelling of "backen" in TeX in this way + + \discretionary{bak-}{ken}{backen} + +These 3 arguments are called "prebreak", "postbreak" and "nobreak" +text. + +The same problem exists when typesetting music. If a line of music is +broken, the next line usually gets a clef. So in TeX terms, the clef +is a postbreak. The same thing happens with meter signs: Normally the +meter follows the bar. If a line is broken at that bar, the bar along +with the meter stays on the "last" line, but the next line also gets a +meter sign after the clef. Using the previous notation, + + \discretionary{bar meter}{clef meter}{ bar meter } + +In Lilypond, we have the same concepts (and the same +terminology). Each (nonrhythmic) symbol is typeset using a Command +(code: TYPESET). At a breakpoint, TYPESET commands can be grouped +using separators (in lower case): + + BREAK_PRE, typeset(bar), typeset(meter), + BREAK_MID, typeset(bar), typeset(meter), + BREAK_POST, typeset(clef), typeset(meter), BREAK_END + +The BREAK command sequence is terminated with BREAK_END, so other +commands (like INTERPRET) may follow this sequence. + diff --git a/Make.variables b/Make.variables new file mode 100644 index 0000000000..3d83d00ba7 --- /dev/null +++ b/Make.variables @@ -0,0 +1,71 @@ +#### +#### USER CONFIGURABLE +#### + +# speedy +#DEFINES=-DNDEBUG -DNPRINT -O2 + +# lots of debugging info +DEFINES=-g + +# turn off -pipe if linker doesn't support it +EXTRACXXFLAGS=-pipe -Wall -W -pedantic + +#### +#### EN USER CONFIGURABLE part. +#### + +# version info +MAJVER=0 +MINVER=0 +PATCHLEVEL=9 +VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) + +# directories +TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) +OBJECTDIR=objects +HEADERDIR=hdr +CCDIR=src + +vpath %.cc $(CCDIR) +vpath %.hh $(HEADERDIR) +vpath %.y $(CCDIR) +vpath %.l $(CCDIR) +vpath %.o $(OBJECTDIR) + +# +# +include Sources.make +progdocs=$(hdr) $(mycc) +gencc=parser.cc lexer.cc +cc=$(mycc) $(gencc) +obs=$(cc:.cc=.o) + + +#dist +.EXPORT_ALL_VARIABLES: + +DOCDIR=docdir + +PACKAGENAME=lilypond +DNAME=$(PACKAGENAME)-$(VERSION) + +# distribution files. +othersrc=lexer.l parser.y +SCRIPTS=make_version make_patch genheader +IFILES=dimen.tex symbol.ini kortjakje.ly maartje.ly\ + lilyponddefs.tex test.tex .dstreamrc +OFILES=Makefile Make.variables Sources.make COPYING README +DFILES=$(OFILES) $(IFILES) $(SCRIPTS) + +#compiling +LOADLIBES=-L$(FLOWERDIR) -lflower +FLOWERDIR=../flower + +CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS) +FLEX=flex +BISON=bison +exe=$(PACKAGENAME) +OUTPUT_OPTION=$< -o $@ +DDIR=$(TOPDIR)/$(DNAME) +SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR) 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/README b/README index fd1c616b3a..cfee5ea3c9 100644 --- a/README +++ b/README @@ -6,7 +6,11 @@ This is a beta version of LilyPond (a music typesetter). This release is preliminary, please do not distribute. Please send your helpful comments and patches to me, - hanwen@stack.urc.tue.nl + hanwen@stack.urc.tue.nl + +LilyPond is updated very frequently, the latest version is always available at: + + ftp://pcnov095.win.tue.nl/pub/lilypond PREREQUISITES @@ -18,6 +22,14 @@ COMPILING You will need GNU C++ v2.7 or better and GNU make. If you actually want to use this, you'd better use the "speedy" compilation flags in the Makefile. +Do: + + tar zxf flower-1.11.9.tar.gz + mv flower-1.11.9 flower + cd flower; make; cd .. + tar zxf lilypond-1.2.13.tar.gz + cd lilypond-1.2.13 + make why G++ >= 2.7? LilyPond & flower lib uses builtin bool and typeof. @@ -32,20 +44,22 @@ what I type in my xterm: This is what the output looks like over here. -hw:~/musix/spacer$ lilypond maartje.ly -LilyPond version 0.0.6 compiled on Nov 2 1996 at 01:25:29 -Parsing ... [maartje.ly] +hw:~/musix/spacer$ lilypond kortjakje.ly +LilyPond version 0.0.9 compiled on Nov 7 1996 at 23:38:21 +Parsing ... [kortjakje.ly] +Processing ... Calculating ... output to lelie.uit... + hw:~/musix/spacer$ tex test This is TeX, Version 3.14159 (C version 6.1) (test.tex Hyphenation patterns for english, dutch, loaded. (lilyponddefs.tex) (lelie.uit) [1] ) -Output written on test.dvi (1 page, 1964 bytes). +Output written on test.dvi (1 page, 3076 bytes). Transcript written on test.log. + hw:~/musix/spacer$ xdvi test& -[1] 3130 -hw:~/musix/spacer$ +[1] 1667 PROBLEMS @@ -59,7 +73,8 @@ HOW DOES IT WORK * Use The Source, Luke. If you don't know C++, you can try editing .dstreamrc for copious debugging output. -* see also the subdir Documentation +* also the subdir Documentation/ it contains some in depth matter +on LilyPond algorithms * The source is commented in the DOC++ style. Check out doc++ at diff --git a/Sources.make b/Sources.make index 6e860c07d4..2894394f94 100644 --- a/Sources.make +++ b/Sources.make @@ -2,29 +2,32 @@ # sourcefiles to be shipped. Also for dependencies hdr= qlp.hh linespace.hh qlpsolve.hh\ - pcol.hh proto.hh pstaff.hh line.hh\ + pcol.hh proto.hh pstaff.hh scoreline.hh staffline.hh\ const.hh glob.hh molecule.hh boxes.hh pscore.hh item.hh tex.hh\ request.hh voice.hh command.hh staff.hh linestaff.hh \ tstream.hh rhythmstaff.hh\ parseconstruct.hh debug.hh globvars.hh keyword.hh\ misc.hh score.hh notename.hh lexer.hh symtable.hh\ - symbol.hh main.hh dimen.hh paper.hh lookupsyms.hh\ + symbol.hh main.hh dimen.hh paper.hh lookup.hh\ sccol.hh stcol.hh scommands.hh melodicstaff.hh\ identifier.hh simplestaff.hh spanner.hh stem.hh\ - notehead.hh + notehead.hh leastsquares.hh beam.hh rest.hh\ + swalker.hh bar.hh meter.hh mycc= qlp.cc qlpsolve.cc \ - break.cc linespace.cc molecule.cc line.cc\ - pscore.cc tex.cc item.cc pcol.cc staff.cc rhythmstaff.cc\ - score.cc note.cc main.cc misc.cc \ + break.cc linespace.cc molecule.cc staffline.cc\ + pscore.cc tex.cc item.cc pcol.cc staff.cc \ + rhythmstaff.cc score.cc note.cc main.cc misc.cc\ symbol.cc request.cc notename.cc voice.cc\ keyword.cc linestaff.cc table.cc command.cc\ warn.cc debug.cc symtable.cc boxes.cc\ pstaff.cc tstream.cc\ calcideal.cc scores.cc identifier.cc \ - dimen.cc paper.cc lookupsyms.cc scommands.cc\ + dimen.cc paper.cc lookup.cc scommands.cc\ sccol.cc stcol.cc getcommands.cc simplestaff.cc\ melodicstaff.cc simpleprint.cc stem.cc\ - spanner.cc notehead.cc\ + spanner.cc notehead.cc leastsquares.cc beam.cc\ + texbeam.cc rest.cc swalker.cc scoreline.cc\ + simplewalker.cc bar.cc meter.cc\ template1.cc template2.cc template3.cc\ version.cc \ No newline at end of file diff --git a/flower/Makefile b/flower/Makefile index dffea2fb37..b39b1f213d 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=8 +PATCHLEVEL=10 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) @@ -13,6 +13,7 @@ include Sources.make obs=$(cc:.cc=.o) staticlib=libflower.a + $(staticlib): $(obs) $(AR) cr libflower.a $(obs) @@ -24,8 +25,10 @@ depend: Sources.make clean: rm -f $(obs) $(staticlib) + realclean: clean rm -f depend + DFILES=$(hh) $(cc) $(inl) $(templatecc) Makefile Sources.make TODO README DDIR=$(DNAME) @@ -34,6 +37,7 @@ dist: ln $(DFILES) $(DDIR)/ tar cfz $(DNAME).tar.gz $(DDIR)/* rm -rf $(DDIR)/ + TAGS: etags -CT $(inl) $(cc) $(hh) diff --git a/flower/README b/flower/README index d33c68f3df..6706447fcf 100644 --- a/flower/README +++ b/flower/README @@ -1,5 +1,7 @@ This library contains some general purpose routines which aren't -standardised yet. It was written by: +standardised libraries yet. It may be replaced by STL in time + +It was written by: Han-Wen Nienhuys diff --git a/flower/TODO b/flower/TODO index ef0ab6bac6..9d4ade3bcd 100644 --- a/flower/TODO +++ b/flower/TODO @@ -1,7 +1,5 @@ * PCursor -> Pointer_cursor / PointerCursor ? - * remove List::List(element) - * efficient copy cons for List * extend Interval diff --git a/flower/dstream.cc b/flower/dstream.cc index 8540e734cf..6cfc62eb3d 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -114,7 +114,10 @@ Dstream::Dstream(ostream *r, const char * cfg_nm ) Text_db cfg(fn); while (! cfg.eof()){ Text_record r( cfg++); - assert(r.sz() == 2); + if (r.sz() != 2) { + r.message("not enough fields in Dstream init."); + continue; + } (*silent)[r[0]] = r[1].to_bool(); } diff --git a/flower/list.cc b/flower/list.cc index ce5e366cc8..55e1e20507 100644 --- a/flower/list.cc +++ b/flower/list.cc @@ -36,7 +36,6 @@ List::OK() const template -inline List::~List() { Cursor next(*this); @@ -48,14 +47,17 @@ List::~List() } template -inline void -List::add( const T& thing, Cursor after_me ) +void +List::add( const T& thing, Cursor &after_me ) { if (!size_) { // not much choice if list is empty bottom_ = top_ = new Link( thing ); + if (!after_me.ok()) + after_me = bottom(); } else { // add at aprioprate place - Link *p = ( after_me.ok() ) ? - after_me.pointer() : bottom().pointer(); + if (!after_me.ok()) + after_me = bottom(); + Link *p =after_me.pointer(); p->add(thing); if (p == bottom_) // adjust bottom_ if necessary. bottom_ = p->next(); @@ -75,23 +77,37 @@ List::add( const T& thing, Cursor after_me ) */ template -inline void -List::insert( const T& thing, Cursor before_me ) +void +List::insert( const T& thing, Cursor &before_me ) { if (!size_) { bottom_ = top_ = new Link( thing ); + if (!before_me.ok()) + before_me = top(); + } else { - Link *p = - (before_me.ok())? - before_me.pointer() : top().pointer(); + if (!before_me.ok()) + before_me = top(); + + Link *p = before_me.pointer() ; p->insert(thing); if (p == top_) top_ = p->previous(); } - - size_++; + size_++; } + +template +void +List::concatenate(List const&s) +{ + Cursor b(bottom()); + for (Cursor c(s); c.ok(); c++) { + b.add(c); + b++; + } +} #endif diff --git a/flower/list.hh b/flower/list.hh index 1516e16642..117e1862e4 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -1,5 +1,3 @@ -// list.hh - #ifndef __LIST_HH #define __LIST_HH @@ -7,7 +5,7 @@ class ostream; template class Cursor; template class Link; -/// all purpose list +/// all-purpose doubly linked list template class List { @@ -15,11 +13,7 @@ class List List(List const&src); /// construct empty list - List(); - - /// construct list from first item. - List( const T& thing ); - + List(); virtual ~List(); Cursor bottom(); @@ -30,6 +24,10 @@ class List protected: friend class Cursor; friend class Link; + + void concatenate(List const &s); + + /// make *this empty void set_empty(); /** @@ -37,10 +35,10 @@ class List */ /// add after after_me - void add( const T& thing, Cursor after_me ); + void add( const T& thing, Cursor &after_me ); /// put thing before #before_me# - void insert( const T& thing, Cursor before_me ); + void insert( const T& thing, Cursor &before_me ); virtual void remove( Cursor me ); /** Remove link pointed to by me. diff --git a/flower/list.inl b/flower/list.inl index d71e947050..c3ee7e2948 100644 --- a/flower/list.inl +++ b/flower/list.inl @@ -18,13 +18,6 @@ List::set_empty() size_ = 0; } -template -inline -List::List( const T& thing ) -{ - set_empty(); - add( thing, Cursor( *this, bottom_ ) ); -} template inline void List::remove( Cursor me ) diff --git a/flower/pcursor.hh b/flower/pcursor.hh index 5e535300d7..c9cc53411f 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -24,6 +24,7 @@ struct PCursor : public Cursor { PCursor operator +( int no) const { return PCursor (Cursor::operator+(no)); } + PCursor(const PointerList & l) : Cursor (l) {} PCursor( const Cursor& cursor ) : Cursor(cursor) { } @@ -34,13 +35,17 @@ struct PCursor : public Cursor { T operator ->() const { return ptr(); } operator T() { return ptr(); } T operator *() { return ptr(); } + void add(const T& p ) { Cursor::add((void*) p); } + void insert(const T& p ) { Cursor::insert((void*) p);} private: // Cursor::operator void*; // sigh }; /** -don't create PointerList's + don't create PointerList's. + This cursor is just an interface class for Cursor. It takes care of the + appropriate type casts */ diff --git a/flower/plist.hh b/flower/plist.hh index 78df40cb17..ea2c0ecdae 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -16,8 +16,8 @@ class PointerList : public List public: PCursor top() { return PCursor (List::top()); } PCursor bottom() { return PCursor (List::bottom()); } - - PointerList( const T& thing ) : List( thing ) { } + void concatenate(PointerList const &s) { List::concatenate(s); } +// PointerList( const T& thing ) : List( thing ) { } PointerList() {} }; 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/bar.hh b/hdr/bar.hh new file mode 100644 index 0000000000..187fadfe78 --- /dev/null +++ b/hdr/bar.hh @@ -0,0 +1,18 @@ +/* + bar.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef BAR_HH +#define BAR_HH +#include "item.hh" + +struct Bar: Item { + String type; + + Bar(String type); + void preprocess(); +}; +#endif // BAR_HH + diff --git a/hdr/beam.hh b/hdr/beam.hh new file mode 100644 index 0000000000..4cbc2ea0c2 --- /dev/null +++ b/hdr/beam.hh @@ -0,0 +1,44 @@ +/* + beam.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef BEAM_HH +#define BEAM_HH +#include "proto.hh" +#include "spanner.hh" +#include "list.hh" + +/// a beam connects multiple stems +struct Beam: public Spanner { + List stems; + Real slope; + Real left_pos; + /// -1 below heads, +1 above heads. + int dir; + + /****************/ + + virtual Interval width()const; + + Spanner *broken_at(const PCol *, const PCol *) const; + Beam(); + void add(Stem*); + void process(); + void calculate(); + void set_default_dir(); + void preprocess(); + Interval height()const; + void print() const; + + void set_stemlens(); +private: + void solve_slope(); + void brew_molecule(); +}; +/** Beam adjusts the stems its owns to make sure that they reach the + beam and that point in the correct direction */ + +#endif // BEAM_HH + diff --git a/boxes.hh b/hdr/boxes.hh similarity index 93% rename from boxes.hh rename to hdr/boxes.hh index 5d0be85452..15beb8c372 100644 --- a/boxes.hh +++ b/hdr/boxes.hh @@ -59,6 +59,11 @@ struct Interval { min =m; max = M; } + Interval &operator += (Real r) { + min += r; + max +=r; + return *this; + } }; diff --git a/command.hh b/hdr/command.hh similarity index 91% rename from command.hh rename to hdr/command.hh index 3e90067075..e13669f46c 100644 --- a/command.hh +++ b/hdr/command.hh @@ -1,7 +1,7 @@ #ifndef COMMAND_HH #define COMMAND_HH -#include "glob.hh" +#include "glob.hh" #include "vray.hh" #include "string.hh" @@ -11,6 +11,7 @@ enum Commandcode { TYPESET, BREAK_PRE,BREAK_MIDDLE, BREAK_POST, BREAK_END }; + /// set a nonrythmical symbol struct Command { Commandcode code; @@ -18,7 +19,11 @@ struct Command { Real when; /// analogous to argv[] svec args; + + /// int priority; + /** in what order relative to other TYPESET commands (eg, bar + should precede meter). Highest priority first. */ /****************/ @@ -53,7 +58,8 @@ struct Command { they change the interpretation of other commands or requests. example: shift output vertically, set the key. \item[BREAK_XXX] These commands group TYPESET commands in - prebreak and postbreak commands. \See{Col}. + prebreak and postbreak commands. See Documentation/breaking + Staff can insert additional commands in a sequence of BREAK_XXX commands, eg. key change commands @@ -73,6 +79,7 @@ struct Command { Commands can be freely copied, they do not have virtual methods. + */ diff --git a/const.hh b/hdr/const.hh similarity index 100% rename from const.hh rename to hdr/const.hh diff --git a/debug.hh b/hdr/debug.hh similarity index 100% rename from debug.hh rename to hdr/debug.hh diff --git a/dimen.hh b/hdr/dimen.hh similarity index 100% rename from dimen.hh rename to hdr/dimen.hh diff --git a/glob.hh b/hdr/glob.hh similarity index 100% rename from glob.hh rename to hdr/glob.hh diff --git a/globvars.hh b/hdr/globvars.hh similarity index 100% rename from globvars.hh rename to hdr/globvars.hh diff --git a/identifier.hh b/hdr/identifier.hh similarity index 100% rename from identifier.hh rename to hdr/identifier.hh diff --git a/item.hh b/hdr/item.hh similarity index 75% rename from item.hh rename to hdr/item.hh index b450ab59ea..33b60831c1 100644 --- a/item.hh +++ b/hdr/item.hh @@ -7,14 +7,24 @@ /// a horizontally fixed size element of the score struct Item { - const PCol * col; - Molecule *output; - + /// indirection to the column it is in + PCol * pcol_; + + /// indirection to the pstaff it is in PStaff *pstaff_; - /** needed for knowing at which staff to output this item - */ + + /// 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(); @@ -32,6 +42,7 @@ struct Item { Item(); void print()const; virtual ~Item(); + Paperdef *paper() const; }; /** Item is the datastructure for printables whose width is known before the spacing is calculated diff --git a/keyword.hh b/hdr/keyword.hh similarity index 100% rename from keyword.hh rename to hdr/keyword.hh diff --git a/hdr/leastsquares.hh b/hdr/leastsquares.hh new file mode 100644 index 0000000000..71586d8d5c --- /dev/null +++ b/hdr/leastsquares.hh @@ -0,0 +1,19 @@ +/* + leastsquare.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef LEASTSQUARE_HH +#define LEASTSQUARE_HH +#include "vray.hh" +#include "boxes.hh" + +struct Least_squares { + svec input; + void minimise(Real &coef, Real &offset); +}; + + +#endif // LEASTSQUARE_HH + diff --git a/lexer.hh b/hdr/lexer.hh similarity index 84% rename from lexer.hh rename to hdr/lexer.hh index ec7c9b929f..e2537da410 100644 --- a/lexer.hh +++ b/hdr/lexer.hh @@ -6,11 +6,12 @@ void new_input(String s); bool close_input(); int yylex(); -void yyerror(char *s); +void yyerror(const char *s); int lookup_keyword(String s); Identifier* lookup_identifier(String s); void add_identifier(Identifier*i); void delete_identifiers(); +void kill_lexer(); #endif diff --git a/linespace.hh b/hdr/linespace.hh similarity index 94% rename from linespace.hh rename to hdr/linespace.hh index b9d850c602..54704508e6 100644 --- a/linespace.hh +++ b/hdr/linespace.hh @@ -9,13 +9,13 @@ /// helper struct for #Spacing_problem# struct Colinfo { - const PCol *col; + const PCol *pcol_; bool fixed; Real fixpos; Colinfo(); void print() const; - Real minright()const { return col->width().max; } - Real minleft()const { return -col->width().min; } + Real minright() const { return pcol_->width().max; } + Real minleft() const { return -pcol_->width().min; } }; diff --git a/linestaff.hh b/hdr/linestaff.hh similarity index 100% rename from linestaff.hh rename to hdr/linestaff.hh diff --git a/lookupsyms.hh b/hdr/lookup.hh similarity index 79% rename from lookupsyms.hh rename to hdr/lookup.hh index 1ec0d04d10..6bf89c0093 100644 --- a/lookupsyms.hh +++ b/hdr/lookup.hh @@ -15,13 +15,19 @@ struct Lookup { Parametric_symbol *linestaff(int n); Parametric_symbol *meter(String); Parametric_symbol *stem(); + + Symbol beam_element(int,int,Real=0); + /// round slope to closest TeXslope + Symbol beam(Real&,Real); Symbol streepjes(int pos); /** pos == 3 : 3 lines above staff (extending below note) pos == -3: below staff */ - + + Symbol rule_symbol(Real height, Real width); + Symbol ball(int); Symbol flag(int); Symbol rest(int); diff --git a/main.hh b/hdr/main.hh similarity index 100% rename from main.hh rename to hdr/main.hh 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/meter.hh b/hdr/meter.hh new file mode 100644 index 0000000000..6af8817265 --- /dev/null +++ b/hdr/meter.hh @@ -0,0 +1,18 @@ +/* + meter.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef METER_HH +#define METER_HH +#include "item.hh" + +struct Meter: Item { + svec args; + + Meter(svec args) ; + void preprocess(); +}; +#endif // METER_HH + diff --git a/misc.hh b/hdr/misc.hh similarity index 100% rename from misc.hh rename to hdr/misc.hh diff --git a/molecule.hh b/hdr/molecule.hh similarity index 100% rename from molecule.hh rename to hdr/molecule.hh diff --git a/notehead.hh b/hdr/notehead.hh similarity index 100% rename from notehead.hh rename to hdr/notehead.hh diff --git a/notename.hh b/hdr/notename.hh similarity index 100% rename from notename.hh rename to hdr/notename.hh diff --git a/paper.hh b/hdr/paper.hh similarity index 59% rename from paper.hh rename to hdr/paper.hh index ffe4f795a8..84932a36ab 100644 --- a/paper.hh +++ b/hdr/paper.hh @@ -2,14 +2,16 @@ #include "real.hh" #include "string.hh" +/// symbols, dimensions and constants struct Paperdef { Lookup *lookup_; String outfile; Real linewidth; + /// how much space does a whole note take (ideally?) Real whole_width; - // ideal = geometric_ ^ log2(duration) + /// ideal = geometric_ ^ log2(duration) Real geometric_; /****************/ @@ -17,9 +19,15 @@ struct Paperdef { Paperdef(); ~Paperdef(); Real interline()const; + Real rule_thickness()const; Real standard_height()const; Real note_width() const; void print() const; Real duration_to_dist(Real); }; +/** This struct takes care of all kinds of symbols, dimensions and + constants. Most of them are related to the point-size of the fonts, + so therefore, the lookup table for symbols is also in here. + see TODO + */ diff --git a/parseconstruct.hh b/hdr/parseconstruct.hh similarity index 65% rename from parseconstruct.hh rename to hdr/parseconstruct.hh index ea5c2fe55a..259303e1a8 100644 --- a/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -1,6 +1,10 @@ - #include "proto.hh" +template +struct svec; + +void set_default_duration(String); +void set_default_pitch(String); Staff * get_new_rhythmstaff(); Voice_element * get_note_element(String,String); Voice_element* get_rest_element(String,String); @@ -9,4 +13,5 @@ Staff * get_new_melodicstaff(); Command* get_meterchange_command( int,int); Command* get_meter_command( Real,int,int); Command* get_skip_command( int,Real); - +Request* get_request(char); +void add_requests( Voice_element*v, svec&req); diff --git a/pcol.hh b/hdr/pcol.hh similarity index 98% rename from pcol.hh rename to hdr/pcol.hh index f28617190a..fa9516edb4 100644 --- a/pcol.hh +++ b/hdr/pcol.hh @@ -41,7 +41,7 @@ struct PCol { /****************************************************************/ - void add(const Item*i); + void add(Item*i); Interval width() const; ~PCol(); diff --git a/proto.hh b/hdr/proto.hh similarity index 96% rename from proto.hh rename to hdr/proto.hh index 268eda6b53..d674ca429a 100644 --- a/proto.hh +++ b/hdr/proto.hh @@ -85,6 +85,9 @@ class Parametric_symbol; struct Lookup; struct Symtables; struct Symtable; - +struct Stem; +struct Notehead; +struct Beam; +struct Rest; #endif // PROTO_HH diff --git a/pscore.hh b/hdr/pscore.hh similarity index 84% rename from pscore.hh rename to hdr/pscore.hh index 91436b369e..70e783c889 100644 --- a/pscore.hh +++ b/hdr/pscore.hh @@ -61,6 +61,10 @@ struct PScore { void add(PStaff *); /// add item void typeset_item(Item *, PCol *,PStaff*,int=1); + + /// add an Spanner + void typeset_spanner(Spanner*, PStaff*); + /// add to bottom of pcols void add(PCol*); /** @@ -73,13 +77,23 @@ struct PScore { get the spacing between c1 and c2, create one if necessary. */ - + /// return argument as a cursor. PCursor find_col(PCol *); + + /// delete unused columns void clean_cols(); - void problem_OK()const ; - void OK()const ; + + + /// check if the spacing/breaking problem is well-stated + void problem_OK() const; + + /// invarinants + void OK()const; PScore(Paperdef*); void print() const; + + /// does curline fit on the paper? + bool feasible(svec curline) const; }; /** notes, signs, symbols in a score can be grouped in two ways: horizontally (staffwise), and vertically (columns). #PScore# diff --git a/pstaff.hh b/hdr/pstaff.hh similarity index 100% rename from pstaff.hh rename to hdr/pstaff.hh diff --git a/qlp.hh b/hdr/qlp.hh similarity index 100% rename from qlp.hh rename to hdr/qlp.hh diff --git a/qlpsolve.hh b/hdr/qlpsolve.hh similarity index 100% rename from qlpsolve.hh rename to hdr/qlpsolve.hh diff --git a/request.hh b/hdr/request.hh similarity index 93% rename from request.hh rename to hdr/request.hh index 04664966b3..1911f20219 100644 --- a/request.hh +++ b/hdr/request.hh @@ -11,13 +11,15 @@ struct Request { /****************/ + Request(); + virtual void print()const ; virtual Note_req *note() {return 0;} virtual Stem_req *stem() {return 0;} virtual Rest_req *rest() {return 0;} + virtual Span_req *span() {return 0;} + virtual Beam_req *beam() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0;} - Request(Voice_element*); - Request(); virtual Real duration() const { return 0.0; } virtual Request* clone() const =0; }; @@ -61,7 +63,7 @@ struct Rhythmic_req : Request { /****************/ Real duration() const; - Rhythmic_req(Voice_element*); + Rhythmic_req(); Rhythmic_req*rhythmic() { return this;} void print ()const; Request*clone() const; @@ -78,7 +80,7 @@ struct Note_req : Rhythmic_req { // return height from central c (in halflines) int height()const; - Note_req(Voice_element*v); + Note_req(); Note_req*note() { return this;} virtual void print() const; Request*clone() const; @@ -96,8 +98,9 @@ based on ottava commands and the appropriate clef. ///Put a rest on the staff. struct Rest_req : Rhythmic_req { + void print()const; - Rest_req(Voice_element*v) : Rhythmic_req(v) { } + Rest_req * rest() { return this;} Request*clone() const ; }; @@ -109,11 +112,50 @@ Why a request? It might be a good idea to not typeset the rest, if the paper is struct Stem_req : Request { /// 4,8,16, .. int stem_number; + virtual Stem_req *stem() {return this;} - Stem_req(Voice_element*v, int s) : Request(v) { stem_number = s; } + Stem_req(int s) { stem_number = s; } Request*clone() const; }; +/// requests to start or stop something. +struct Span_req : Request { + /// should the spanner start or stop, or is it unwanted? + enum { + NOSPAN, START, STOP + } spantype ; + + Span_req*span() { return this; } + Span_req(); + virtual Request*clone()const; +}; +/** + This type of request typically results in the creation of a #Spanner# +*/ + + +///Start / stop a beam at this note. +struct Beam_req : Span_req { + int nplet; + + /****************/ + + Beam_req(); + virtual Beam_req * beam() { return this; } + virtual Request*clone()const; +}; +/** Staff will have to combine this with the stem_request, since the + number of flags that a stem wants to carry will determine the + number of beams. if #nplet# is set, the staff will try to put an + appropriate number over the beam + + */ + +/// a slur +struct Slur_req : Span_req { + virtual Request*clone()const; +}; + #if 0 @@ -151,29 +193,6 @@ enum Loudness { FFF, FF, F, MF, MP, P, PP, PPP } ; -/// requests to start or stop something. -struct Span_req : Request { - /// should the spanner start or stop, or is it unwanted? - enum { - NOSPAN, START, STOP - } spantype ; -}; -/** - This type of request typically results in the creation of a #Spanner# -*/ - - -///Start / stop a beam at this note. -struct Beam_req : Span_req { - int nplet; -}; -/** Staff will have to combine this with the stem_request, since the - number of flags that a stem wants to carry will determine the - number of beams. if #nplet# is set, the staff will try to put an - appropriate number over the beam - - [what to do if the nplet fields of start and stop conflict?] - */ ///Start / stop a slur or a bracket. struct Bracket_req : Span_req { @@ -184,11 +203,6 @@ Start/stop a bracket at this note. if #nplet# is set, the staff will try to put an appropriate number over the bracket */ -/// a slur -struct Slur_req : Span_req { - -}; - /// helper in the hierarchy struct Dynamic { Real subtime; diff --git a/hdr/rest.hh b/hdr/rest.hh new file mode 100644 index 0000000000..c5d0d7f995 --- /dev/null +++ b/hdr/rest.hh @@ -0,0 +1,33 @@ +/* + rest.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef REST_HH +#define REST_HH +#include "item.hh" + +/// ball at the end of the stem +struct Rest : public Item +{ + int dots; + int balltype; + + /****************/ + + void preprocess(); + Rest(int dur,int dots); + void print()const; +private: + void brew_molecole(); +}; +/** + takes care of: + + * help lines + * proper placing of dots + + */ +#endif + 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/sccol.hh b/hdr/sccol.hh similarity index 85% rename from sccol.hh rename to hdr/sccol.hh index 21a341d17f..f18b659e7e 100644 --- a/sccol.hh +++ b/hdr/sccol.hh @@ -10,16 +10,20 @@ struct Score_column { + + /// indirection to column PCol * pcol; + /// length of notes/rests in this column svec durations; + Real when; /// bool musical; - - Score_column(Real when); - + /****************/ + + Score_column(Real when); static int compare(Score_column & c1, Score_column &c2) { return sgn(c1.when - c2.when); } diff --git a/scommands.hh b/hdr/scommands.hh similarity index 76% rename from scommands.hh rename to hdr/scommands.hh index 9106f2bfcc..ae908d7647 100644 --- a/scommands.hh +++ b/hdr/scommands.hh @@ -9,6 +9,7 @@ #include "vray.hh" #include "plist.hh" +/// the list of commands in Score struct Score_commands : public PointerList { void process_add(Command); Score_commands*parse(Real last)const; @@ -27,7 +28,12 @@ struct Score_commands : public PointerList { PCursor last); }; /** the list of commands in Score. Put in a separate class, since it - otherwise clutters the methods of Score. */ + otherwise clutters the methods of Score. + + This class serves two purposes: it stores the commands (via + parser_add()) in the yacc parser. at a later stage, some 'high + level' commands are converted (method: parse()) + */ #endif diff --git a/score.hh b/hdr/score.hh similarity index 100% rename from score.hh rename to hdr/score.hh diff --git a/line.hh b/hdr/scoreline.hh similarity index 52% rename from line.hh rename to hdr/scoreline.hh index 641ddf257d..3da47d30dc 100644 --- a/line.hh +++ b/hdr/scoreline.hh @@ -1,17 +1,14 @@ -#ifndef LINE_HH -#define LINE_HH - /* - horizontal structures for broken scores. + scoreline.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys */ -#include "real.hh" +#ifndef SCORELINE_HH +#define SCORELINE_HH #include "plist.hh" +#include "proto.hh" #include "vray.hh" -#include "glob.hh" -#include "pstaff.hh" - - /// the columns of a score that form one line. struct @@ -32,17 +29,4 @@ Line_of_score { bool element(const PCol *c); }; -/// one broken line of staff. -struct Line_of_staff { - PointerList brokenspans; - Line_of_score const * scor; - const PStaff *pstaff_; - - /****************/ - - String TeXstring() const; - Line_of_staff(Line_of_score*, PStaff *); - Interval height() const; -}; - #endif diff --git a/simplestaff.hh b/hdr/simplestaff.hh similarity index 54% rename from simplestaff.hh rename to hdr/simplestaff.hh index c965765adb..c5c025a166 100644 --- a/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -9,6 +9,7 @@ #include "stcol.hh" #include "staff.hh" +#include "swalker.hh" /* mega-stupido staffs and cols: they do notes one at each moment. */ @@ -18,44 +19,61 @@ struct Simple_staff; /// column of Simple_staff: store one request struct Simple_column : Staff_column { - Request *the_note; + svec notes; Stem_req *stem_; - + Beam_req *beam_; Simple_staff* staff_; /****************/ - virtual void typeset_stem(Stem_req *rq)=0; - virtual void typeset_req(Request *rq)=0; - virtual void typeset_command(Command *, int brs)=0; + virtual void typeset_item(Item *, int=1); Molecule *create_command_mol(Command *com); - Molecule *create_req_mol(Request *rq); - void take_request(Request *rq); - - virtual void process_commands( ); + + void take_request(Request *rq); virtual void process_requests(); Simple_column(Score_column*s,Simple_staff*rs); }; -/// Simple staff: one note at a time +/// 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); - void grant_requests(); -// virtual Staff*clone()const; + 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/spanner.hh b/hdr/spanner.hh similarity index 73% rename from spanner.hh rename to hdr/spanner.hh index 1908d2f013..3940cebf60 100644 --- a/spanner.hh +++ b/hdr/spanner.hh @@ -10,20 +10,34 @@ /// a symbol which is attached between two columns. struct Spanner { - const PCol *left, *right; - Parametric_symbol *strets; + PCol *left, *right; PStaff * pstaff_; + Molecule *output ; + + /****************/ + + String TeXstring () const ; + Spanner(); + Paperdef*paper() const; + + virtual Interval height()const=0; + /** + PRE: + processed + */ + virtual Interval width()const; + virtual void process(); + virtual void preprocess(); + + /// clone a piece of this spanner. - virtual Spanner *broken_at(const PCol *c1, const PCol *c2) const; + virtual Spanner *broken_at(const PCol *c1, const PCol *c2) const=0; /** PRE c1 >= start, c2 <= stop */ - /****************/ - String TeXstring () const ; - Spanner(); - virtual void process(); + virtual void print() const; }; /** Spanner should know about the items which it should consider: e.g. slurs should be steep enough to "enclose" all those items. This diff --git a/staff.hh b/hdr/staff.hh similarity index 97% rename from staff.hh rename to hdr/staff.hh index f2c7294de0..ee95864fa9 100644 --- a/staff.hh +++ b/hdr/staff.hh @@ -57,7 +57,7 @@ struct Staff { ****************************************************************/ virtual Staff*clone()const=0; virtual void set_output(PScore * destination)=0; - virtual void grant_requests()=0; + virtual void walk()=0; virtual Staff_column * create_col(Score_column * )=0; virtual ~Staff() { } }; diff --git a/hdr/staffline.hh b/hdr/staffline.hh new file mode 100644 index 0000000000..a04078923c --- /dev/null +++ b/hdr/staffline.hh @@ -0,0 +1,29 @@ +/* + staffline.hh -- horizontal structures for broken scores. + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef STAFFLINE_HH +#define STAFFLINE_HH + +#include "real.hh" +#include "plist.hh" +#include "vray.hh" +#include "glob.hh" +#include "pstaff.hh" + +/// one broken line of staff. +struct Line_of_staff { + PointerList brokenspans; + Line_of_score const * scor; + const PStaff *pstaff_; + + /****************/ + + String TeXstring() const; + Line_of_staff(Line_of_score*, PStaff *); + Interval height() const; +}; + +#endif diff --git a/stcol.hh b/hdr/stcol.hh similarity index 89% rename from stcol.hh rename to hdr/stcol.hh index 1d8b09c61e..17469a4db5 100644 --- a/stcol.hh +++ b/hdr/stcol.hh @@ -11,11 +11,16 @@ /// store simultaneous requests struct Staff_column { + /// indirection Score_column *score_column; /// fields to collect data vertically. svec v_elts; + + /// idem svec s_commands; + + /****************/ Staff_column(Score_column*s); bool mus() const; @@ -24,9 +29,9 @@ struct Staff_column { /**************************************************************** VIRTUAL ****************************************************************/ - //virtual Staff_column *clone() const=0; + virtual void process_requests()=0; - virtual void process_commands()=0; + virtual ~Staff_column() { } }; diff --git a/stem.hh b/hdr/stem.hh similarity index 52% rename from stem.hh rename to hdr/stem.hh index acbebe0d92..6b7bc55d7d 100644 --- a/stem.hh +++ b/hdr/stem.hh @@ -1,5 +1,5 @@ /* - stem.hh -- part of LilyPond + stem.hh -- (c) 1996 Han-Wen Nienhuys */ @@ -13,22 +13,44 @@ struct Stem : public Item { // heads the stem encompasses (positions) int minnote, maxnote; + /// false if in beam + bool print_flag; + + /// needed for determining direction/length int staff_center; // extent of the stem (positions) - int bot, top; - + Real bot, top; + /** + fractional, since Beam has to adapt them. + */ + + Real stemlen; // flagtype? 4 none, 8 8th flag, 0 = beam. int flag; - + + ///geen gedonder, jij gaat onder + int dir; + /** + -1 stem points down, +1: stem points up + */ + + Real stem_xoffset; /****************/ - + + /// ensure that this Stem also encompasses the Notehead #n# + void add(Notehead*n); + Real hpos()const; + void set_stemend(Real); + void set_default_dir(); + void set_default_stemlen(); + void set_default_extents(); void postprocess(); Stem(int center); void print() const; Interval width() const; private: - void calculate(); + void brew_molecole(); }; /** diff --git a/hdr/swalker.hh b/hdr/swalker.hh new file mode 100644 index 0000000000..c00923ff99 --- /dev/null +++ b/hdr/swalker.hh @@ -0,0 +1,34 @@ + +/* + swalker.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SWALKER_HH +#define SWALKER_HH + +#include "staff.hh" + +struct Staff_walker : public PCursor { + Staff * staff_; + PScore * pscore_; + + int break_status; + + /****************/ + int priority() const; // Command + Real when() const; + virtual ~Staff_walker(); + Staff_walker(Staff*, PScore*); + void process() ; + virtual void process_command(Command *)=0; + virtual void process_requests()=0; +}; +/** + manage run-time info when walking staffcolumns such as: key, + meter, pending beams & slurs + */ + +#endif // SWALKER_HH + diff --git a/symbol.hh b/hdr/symbol.hh similarity index 100% rename from symbol.hh rename to hdr/symbol.hh diff --git a/symtable.hh b/hdr/symtable.hh similarity index 100% rename from symtable.hh rename to hdr/symtable.hh diff --git a/tex.hh b/hdr/tex.hh similarity index 100% rename from tex.hh rename to hdr/tex.hh diff --git a/tstream.hh b/hdr/tstream.hh similarity index 100% rename from tstream.hh rename to hdr/tstream.hh diff --git a/voice.hh b/hdr/voice.hh similarity index 100% rename from voice.hh rename to hdr/voice.hh diff --git a/item.cc b/item.cc deleted file mode 100644 index f10187bbb2..0000000000 --- a/item.cc +++ /dev/null @@ -1,52 +0,0 @@ -#include "line.hh" -#include "symbol.hh" -#include "molecule.hh" -#include "pcol.hh" - -void -Item::postprocess() -{ - // default: do nothing -} - - -void -Item::preprocess() -{ - // default: do nothing -} - -String -Item::TeXstring() const -{ - return output->TeXstring(); -} - -Interval -Item::width() const -{ - return output->extent().x; -} - -Interval -Item::height() const -{ - return output->extent().y; -} - -Item::~Item() -{ - delete output; -} - -Item::Item() -{ - col = 0; - output = 0; - pstaff_ = 0; -} -void -Item::print() const -{ - output->print(); -} diff --git a/kortjakje.ly b/kortjakje.ly new file mode 100644 index 0000000000..4c555c88eb --- /dev/null +++ b/kortjakje.ly @@ -0,0 +1,40 @@ +% "Ah, je vous dirai, maman" (Mozart) +% +% bare bones version. (written down from memory :-) + +melodie = voice { + $ \octave c + %%% theme + c c g g a a g2 f f e e d d c2 + %%% var 1 + c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4 + f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4 + $ +} + +begeleiding = voice { + $ \octave ``c + %%% theme + `c c e c f c e c d `b c `a `f `g `c2 + %%%% var 1 + r8 e8() c r8 e8() c r8 f8()c r8 e8()c + r8 d8()`b r8 c8()`a r8 `a8()`f r8 `e8()`c + $ +} + + +score { + melodicstaff { + voice { melodie } + } + melodicstaff { + voice { begeleiding } + } + paper { + unitspace 2.5cm + } + commands { + meter 2 4 + skip 16:0 + } +} \ No newline at end of file diff --git a/lilyponddefs.tex b/lilyponddefs.tex index 41748636de..9cf064fee8 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -43,9 +43,13 @@ \mdef\doubledot{'01} \mdef\tripledot{'02} \mdef\mussepline{155} -\mdef\ieigthflag{45} -\mdef\isixteenthflag{46} -\mdef\ithirtysecondflag{47} + + +\mdef\deigthflag{45} +\mdef\dsixteenthflag{46} +\mdef\dthirtysecondflag{47} + +% pointing up \mdef\ueigthflag{40} \mdef\usixteenthflag{41} \mdef\uthirtysecondflag{42} @@ -55,10 +59,10 @@ \def\generalmeter#1#2{\vbox to 0pt{\vss\rm\hbox{#1}\hbox{#2}}} \def\lineseparator{\vbox{\mussepline\vskip -5pt\mussepline}} -\def\beauty{ - \par\vskip 10pt\par - \hskip -5pt\lineseparator% \hbox to 1cm{\kern -5mm\hrulefill} - \vskip 10pt +\def\beauty{% + \par\vskip 10pt plus 30pt minus 10pt\par + \hskip -5pt\lineseparator + \par\vskip 10pt plus 30pt minus 10pt\par } \def\interstaffline{% @@ -114,3 +118,5 @@ } +\def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}} +\def\rulesym#1#2{\vrule height #1 width #2} \ No newline at end of file diff --git a/maartje.ly b/maartje.ly index e12fc345e6..4c32f09c9a 100644 --- a/maartje.ly +++ b/maartje.ly @@ -2,20 +2,29 @@ ritme = rhythmstaff { voice { $ c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ } } + melody= melodicstaff { - voice { $ ''c2.. r8 r4 r8 r16 r32 r32 d8 e8 f8 g8 ''fis1 a8 b8 'c8 c8 ''c8 ```c8 c4 c4 c4 c4 $ } + voice { $ + ''c2.. r8 r4 r8 r16 r32 r32 + [d8 e8 f8 g8] [d8 e8 f8 g8] + ''fis1 + a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4 + \duration 16 `b16 `a16 `g16 `f16 \duration 4 + c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c$ + } } score { paper { - unitspace 3 cm + geometric 1.4 + unitspace 3.0 cm } staff { ritme } staff { melody } % staff { melody } commands { meter 4 4 - skip 3:0 + skip 2:0 meter 2 4 skip 19:0 } diff --git a/make_patch b/make_patch index 2e9246f4d7..8747fe6b84 100755 --- a/make_patch +++ b/make_patch @@ -3,29 +3,30 @@ old=$1 new=$2 nm=$3- -newarc=$nm$new.tar.gz -oldarc=$nm$old.tar.gz +newarc=../releases/$nm$new.tar.gz +oldarc=../releases/$nm$old.tar.gz if [ ! -x $nm$new ] then echo untarring .. - tar zfxv $nm$new.tar.gz if [ ! -f $newarc ] then echo cant find $newarc exit fi + tar zfxv $newarc fi if [ ! -x $nm$old ] then echo untarring - tar zfxv $nm$old.tar.gz + if [ ! -f $oldarc ] then echo cant find oldarc exit fi + tar zfxv $oldarc fi #(cd $nm$old; touch depend; make clean) diff --git a/melodicstaff.cc b/melodicstaff.cc deleted file mode 100644 index 2937f45dfe..0000000000 --- a/melodicstaff.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include "melodicstaff.hh" -#include "stem.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); -} - -void -Melodic_column::typeset_command(Command *com, int breakst) -{ - Molecule*m=create_command_mol(com); - Item *i =new Item; - i->output = m; - typeset_item(i, breakst); -} - -void -Melodic_column::typeset_req(Request *rq) -{ - Item *i ; - if (rq->note()) { - Notehead *n =new Notehead((NO_LINES-1)*2); - n->balltype = rq->rhythmic()->balltype; - n->dots = rq->rhythmic()->dots; - n->position = rq->note()->height() - BOTTOM_POSITION; - i = n; - } else if (rq->rest()) { - i =new Item; - Molecule*m=create_req_mol(rq); - i->output=m; - } - typeset_item(i); -} - - -void -Melodic_column::typeset_stem(Stem_req*rq) -{ - Stem * s = new Stem(NO_LINES); - int n = the_note->note()->height()-BOTTOM_POSITION; - s->minnote =s->maxnote=n; - s->flag = rq->stem_number; - typeset_item(s); -} - -/* - creation - */ -Staff * -get_new_melodicstaff() -{ - return new Melodic_staff; -} - - -Staff_column* -Melodic_staff::create_col(Score_column*s) -{ - return new Melodic_column(s,this); -} - -Melodic_staff* -Melodic_staff::clone()const -{ - return new Melodic_staff(*this); -} diff --git a/melodicstaff.hh b/melodicstaff.hh deleted file mode 100644 index 5c417b84a5..0000000000 --- a/melodicstaff.hh +++ /dev/null @@ -1,32 +0,0 @@ -/* - 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 -{ - Staff_column * create_col(Score_column*); - virtual void set_output(PScore *); - virtual Melodic_staff*clone()const; -}; - -struct Melodic_column : public Simple_column { - virtual void typeset_req(Request *rq); - virtual void typeset_stem(Stem_req *rq); - virtual void typeset_command(Command *, int brs); - // virtual void typeset_item(Item*, int=1); - Melodic_column(Score_column*s,Simple_staff*rs) : - Simple_column(s,rs) { } -// virtual Melodic_column*clone()const; -}; - -#endif // MELODICSTAFF_HH - - diff --git a/objects/Makefile b/objects/Makefile new file mode 100644 index 0000000000..701ad6d5b9 --- /dev/null +++ b/objects/Makefile @@ -0,0 +1,2 @@ +dist: + ln Makefile $(DDIR)/objects/ \ No newline at end of file diff --git a/rhythmstaff.cc b/rhythmstaff.cc deleted file mode 100644 index 98d17d522c..0000000000 --- a/rhythmstaff.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include "molecule.hh" -#include "notehead.hh" -#include "stem.hh" -#include "linestaff.hh" -#include "rhythmstaff.hh" -#include "paper.hh" -#include "sccol.hh" - - -void -Rhythmic_staff::set_output(PScore*ps) -{ - theline = new Linestaff(1,ps); - Simple_staff::set_output(ps); -} - - -void -Rhythmic_column::typeset_command(Command *com, int breakst) -{ - Item *i =new Item; - Molecule*m = create_command_mol(com); - i->output=m; - m->translate(Offset(0, - -staff_->score_->paper_->standard_height()/2)); - typeset_item(i, breakst); -} - -void -Rhythmic_column::typeset_req(Request *rq) -{ - Item *i ; - if (rq->note()) { - Notehead *n =new Notehead(1); - n->balltype = rq->rhythmic()->balltype; - n->dots = rq->rhythmic()->dots; - n->position = 0; - i = n; - } else if (rq->rest()) { - i =new Item; - Molecule*m=create_req_mol(rq); - i->output=m; - } - typeset_item(i); -} - -void -Rhythmic_column::typeset_stem(Stem_req*rq) -{ - Stem * s = new Stem(0); - s->minnote = s->maxnote = 0; - s->flag = rq->stem_number; - typeset_item(s); -} - -/* - creation - */ -Staff * -get_new_rhythmstaff() -{ - return new Rhythmic_staff; -} - - -Staff_column* -Rhythmic_staff::create_col(Score_column*s) -{ - return new Rhythmic_column(s,this); -} - -Rhythmic_staff* -Rhythmic_staff::clone() const -{ - return new Rhythmic_staff(*this); -} diff --git a/rhythmstaff.hh b/rhythmstaff.hh deleted file mode 100644 index 130f6483b9..0000000000 --- a/rhythmstaff.hh +++ /dev/null @@ -1,36 +0,0 @@ -/* - 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 -{ - // Rhythmic_staff(); - Staff_column * create_col(Score_column*); - virtual void set_output(PScore *); - virtual Rhythmic_staff*clone()const; -}; - -/// this does the typesetting -struct Rhythmic_column : public Simple_column { - virtual void typeset_req(Request *rq); - virtual void typeset_stem(Stem_req *rq); - virtual void typeset_command(Command *, int brs); - - -// virtual void typeset_item(Item *rq, int=1); - Rhythmic_column(Score_column*s,Simple_staff*rs) : - Simple_column(s,rs) { } -// virtual Rhythmic_column*clone()const; -}; - -#endif // RHYTHMSTAF_HH - - diff --git a/simpleprint.cc b/simpleprint.cc deleted file mode 100644 index b069978dce..0000000000 --- a/simpleprint.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include "lookupsyms.hh" -#include "request.hh" -#include "pscore.hh" -#include "paper.hh" -#include "simplestaff.hh" -#include "molecule.hh" -#include "sccol.hh" - -Molecule * -Simple_column::create_req_mol(Request *rq) -{ - assert(rq->rest()); - Symbol s; - int dots=0; - if (rq->rest()) - s = staff_->paper()->lookup_->rest(rq->rest()->balltype); - - if (rq->rhythmic()) - dots=rq->rhythmic()->dots; - - - Molecule *m = new Molecule(Atom(s)); - if (dots) { - Symbol d = staff_->paper()->lookup_->dots(dots); - Molecule dm; - dm.add(Atom(d)); - m->add_right(dm); - } - return m; -} - -Molecule * -Simple_column::create_command_mol(Command *com) -{ - Symbol s; - - if (com -> args[0] == "BAR" ) { - s = staff_->paper()->lookup_->bar(com->args[1]); - } else if (com->args[0] == "METER") { - Parametric_symbol *p = staff_->paper()->lookup_->meter("general"); - svec arg( com->args); - arg.del(0); - s = p->eval(arg); - } else - assert(false); - - Molecule * m =new Molecule(Atom(s)); - { - Interval wid; - svec sv(staff_->pscore_-> - select_items(staff_->theline, score_column->pcol)); - for (int j=0; joutput->extent().x); - } - if (!wid.empty()) - m->translate(Offset(wid.max,0)); - } - - return m; -} - -void -Simple_column::typeset_item(Item *i, int breakst) -{ - // ugh - staff_->pscore_->typeset_item(i, score_column->pcol, - staff_->theline,breakst); -} - -void -Simple_staff::set_output(PScore* ps ) -{ - pscore_ = ps; - pscore_->add(theline); -} diff --git a/simplestaff.cc b/simplestaff.cc deleted file mode 100644 index 97250b48cb..0000000000 --- a/simplestaff.cc +++ /dev/null @@ -1,91 +0,0 @@ -#include "request.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) -{ - the_note = 0; - stem_ = 0; - staff_ = rs; -} - -Simple_staff::Simple_staff() -{ - theline = 0; -} - -void -Simple_column::process_commands( ) -{ - int breakstat = BREAK_END - BREAK_PRE; - for (int i = 0 ; i < s_commands.sz(); i++) { - Command *com = s_commands[i]; - switch (com->code){ - case INTERPRET: - break; - case BREAK_PRE: - case BREAK_MIDDLE: - case BREAK_POST: - case BREAK_END: - score_column->set_breakable(); - breakstat = com->code- BREAK_PRE; - break; - - case TYPESET: - typeset_command ( com , breakstat); - break; - default : - break; - } - } -} -/** - 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()){ - if (the_note){ - WARN << "too many notes.\n"; - } - the_note = rq; - - } - if (rq->stem()) { - stem_ = rq->stem(); - } - - } -} - -void -Simple_staff::grant_requests() -{ - for (PCursor cc(cols); cc.ok(); cc++) { - Simple_column *rp = (Simple_column*)*cc; - if (rp->the_note) - rp->typeset_req( rp->the_note); - if (rp->stem_) - rp->typeset_stem(rp->stem_->stem()); - } -} - - diff --git a/spanner.cc b/spanner.cc deleted file mode 100644 index be30c04659..0000000000 --- a/spanner.cc +++ /dev/null @@ -1,33 +0,0 @@ - -#include "spanner.hh" -#include "line.hh" - -#include "symbol.hh" -#include "molecule.hh" -#include "pcol.hh" - -String -Spanner::TeXstring() const -{ - assert(right->line); - Real w = left->hpos - right->hpos; - return strets->eval(w).tex; -} - -// todo. -Spanner * -Spanner::broken_at(const PCol *c1, const PCol *c2) const -{ - Spanner *sp = new Spanner(*this); - sp->left = c1; - sp->right = c2; - return sp; -} - -Spanner::Spanner() -{ - pstaff_=0; - strets=0; - left = right = 0; -} - diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000000..65374e807e --- /dev/null +++ b/src/Makefile @@ -0,0 +1,8 @@ +default: + $(MAKE) -C .. + +dist: + ln Makefile $(mycc) $(othersrc) $(DDIR)/src + +TAGS: $(mycc) + etags -CT $(mycc) diff --git a/src/bar.cc b/src/bar.cc new file mode 100644 index 0000000000..bb66f2b777 --- /dev/null +++ b/src/bar.cc @@ -0,0 +1,18 @@ +#include "bar.hh" +#include "string.hh" +#include "molecule.hh" +#include "paper.hh" +#include "lookup.hh" + + +Bar::Bar( String t) +{ + type = t; +} +void +Bar::preprocess() +{ + Symbol s = paper()->lookup_->bar(type); + output = new Molecule(Atom(s)); +} + diff --git a/src/beam.cc b/src/beam.cc new file mode 100644 index 0000000000..49214c91f2 --- /dev/null +++ b/src/beam.cc @@ -0,0 +1,179 @@ +#include "beam.hh" +#include "debug.hh" +#include "symbol.hh" +#include "molecule.hh" +#include "leastsquares.hh" +#include "pcol.hh" +#include "stem.hh" +#include "paper.hh" +#include "lookup.hh" + + +struct Stem_info { + Real x; + Real idealy; + Real miny; + int no_beams; + + Stem_info(){} + Stem_info(const Stem*); +}; +Stem_info::Stem_info(const Stem*s) +{ + x = s->hpos(); + int dir = s->dir; + idealy = MAX(dir*s->top, dir*s->bot); + miny = MAX(dir*s->minnote, dir*s-> maxnote); + assert(miny <= idealy); + no_beams = s->flag; +} + +/****************/ + +Beam::Beam() +{ + slope = 0; + left_pos = 0.0; + dir =0; +} + +void +Beam::add(Stem*s) +{ + stems.bottom().add(s); + s->print_flag = false; +} + +void +Beam::set_default_dir() +{ + int dirs[2]; + dirs[0]=0; dirs[1] =0; + for (PCursor sc(stems); sc.ok(); sc++) { + sc->set_default_dir(); + dirs[(sc->dir+1)/2] ++; + } + dir = (dirs[0] > dirs[1]) ? -1 : 1; + for (PCursor sc(stems); sc.ok(); sc++) { + sc->dir = dir; + } +} + +void +Beam::solve_slope() +{ + svec sinfo; + for (PCursorsc(stems); sc.ok(); sc++) { + sc->set_default_extents(); + Stem_info i(sc); + sinfo.add(i); + } + Real leftx = sinfo[0].x; + Least_squares l; + for (int i=0; i < sinfo.sz(); i++) { + sinfo[i].x -= leftx; + l.input.add(Offset(sinfo[i].x, sinfo[i].idealy)); + } + + l.minimise(slope, left_pos); + Real dy = 0.0; + for (int i=0; i < sinfo.sz(); i++) { + Real y = sinfo[i].x * slope + left_pos; + Real my = sinfo[i].miny; + + if (my - y > dy) + dy = my -y; + } + left_pos += dy; + left_pos *= dir; + slope *= dir; + + {Real inter =paper()->interline()/2; + Real unitslope = slope*inter; + + // set beamslope, for setting stems correctly + // ignoring return. + Symbol sy = paper()->lookup_->beam(unitslope, width().length()); + slope =unitslope / inter; + } +} + +void +Beam::set_stemlens() +{ + PCursor s(stems); + Real x0 = s->hpos(); + for (; s.ok() ; s++) { + Real x = s->hpos()-x0; + s->set_stemend(left_pos + slope * x); + } +} + +void +Beam::calculate() +{ + assert(stems.size()>1); + if (!dir) + set_default_dir(); + + solve_slope(); + set_stemlens(); +} + +void +Beam::process() +{ + calculate(); + brew_molecule(); +} + + +// todo. +Spanner * +Beam::broken_at(const PCol *, const PCol *) const +{ + return new Beam(*this); +} + +void +Beam::preprocess() +{ + left = (*stems.top()) ->pcol_; + right = (*stems.bottom())->pcol_; +} + +Interval +Beam::height() const +{ + return output->extent().y; +} + +Interval +Beam::width() const +{ + Beam * me = (Beam*) this; // ugh + return Interval( (*me->stems.top()) ->hpos(), + (*me->stems.bottom()) ->hpos() ); +} + +void +Beam::brew_molecule() +{ + Real inter=paper()->interline()/2; + Real sl = slope*inter; + Real w = width().length() + paper()->rule_thickness(); + Symbol s = paper()->lookup_->beam(sl,w); + + Atom a(s); + + Real dx = width().min -left->hpos; + a.translate(Offset(dx,left_pos*inter)); + output = new Molecule(a); +} + +void +Beam::print()const +{ + mtor << "Beam, slope " < curline) const return the_sol; } +bool +PScore::feasible(svec curline) const +{ + Real l =0; + for (int i=0; i < curline.sz(); i++) + l +=curline[i]->width().length(); + return l < paper_->linewidth; +} void PScore::problem_OK() const @@ -98,11 +106,16 @@ PScore::calc_breaking() curcol++; } current.add(breakpoints[i]->prebreak ); + if (!feasible(current.line)) { + if (!minimum.line.sz()) + error("sorry, this measure is too long"); + break; + } current.setsol(solve_line(current.line)); current.print(); - if (current.energy < minimum.energy) { - minimum = current; + if (current.energy < minimum.energy) { + minimum = current; } else { // we're one col too far. i--; while (curcol != breakpoints[i]) diff --git a/calcideal.cc b/src/calcideal.cc similarity index 100% rename from calcideal.cc rename to src/calcideal.cc diff --git a/command.cc b/src/command.cc similarity index 100% rename from command.cc rename to src/command.cc diff --git a/debug.cc b/src/debug.cc similarity index 100% rename from debug.cc rename to src/debug.cc diff --git a/dimen.cc b/src/dimen.cc similarity index 100% rename from dimen.cc rename to src/dimen.cc diff --git a/getcommands.cc b/src/getcommands.cc similarity index 100% rename from getcommands.cc rename to src/getcommands.cc diff --git a/identifier.cc b/src/identifier.cc similarity index 93% rename from identifier.cc rename to src/identifier.cc index 5405d5f710..024fe06486 100644 --- a/identifier.cc +++ b/src/identifier.cc @@ -2,7 +2,7 @@ #include "identifier.hh" #include "staff.hh" #include "lexer.hh" -#include "parser.hh" + Identifier::Identifier(String n) :name (n) diff --git a/src/item.cc b/src/item.cc new file mode 100644 index 0000000000..914c924a99 --- /dev/null +++ b/src/item.cc @@ -0,0 +1,73 @@ +#include "pstaff.hh" +#include "pscore.hh" +#include "symbol.hh" +#include "molecule.hh" +#include "pcol.hh" + +void +Item::translate(Offset O) +{ + offset_ += O; +} + +void +Item::postprocess() +{ + // default: do nothing +} + + +void +Item::preprocess() +{ + // default: do nothing +} + +String +Item::TeXstring() const +{ + Item * me = (Item*) this; + output->translate(offset_); // ugh? + me ->offset_ = Offset(0,0); // URRGGH! + return output->TeXstring(); +} + +Interval +Item::width() const +{ + Interval i =output->extent().x ; + return i+=offset_.x; +} + +Interval +Item::height() const +{ + Interval i =output->extent().y; + return i+=offset_.y; +} + +Item::~Item() +{ + delete output; +} + +Item::Item() +{ + pcol_ = 0; + output = 0; + pstaff_ = 0; +} +void +Item::print() const +{ + assert(output); + output->print(); +} + +Paperdef* +Item::paper() const +{ + assert(pstaff_); + return pstaff_->pscore_->paper_; +} + diff --git a/keyword.cc b/src/keyword.cc similarity index 100% rename from keyword.cc rename to src/keyword.cc diff --git a/src/leastsquares.cc b/src/leastsquares.cc new file mode 100644 index 0000000000..1e1c91cee3 --- /dev/null +++ b/src/leastsquares.cc @@ -0,0 +1,25 @@ +#include "leastsquares.hh" + +void +Least_squares::minimise(Real &coef, Real &offset) +{ + Real sx = 0.0; + Real sy = 0.0; + Real sqx =0.0; + Real sxy = 0.0; + + for (int i=0; i < input.sz();i++) { + Real x=input[i].x; + Real y = input[i].y; + sx += x; + sy += y; + sqx += sqr(x); + sxy += x*y; + } + int N = input.sz(); + + + coef = (N * sxy - sx*sy )/(N*sqx - sqr(sx)); + offset = (sy - coef * sx)/N; + +} diff --git a/lexer.l b/src/lexer.l similarity index 84% rename from lexer.l rename to src/lexer.l index 220b07ccf8..1e3443e56e 100644 --- a/lexer.l +++ b/src/lexer.l @@ -25,6 +25,8 @@ const int DOTPRINT=50; // every 50 lines dots %x incl %x quote + +NOTECOMMAND \\{WORD} OPTSIGN !? NOTENAMEI A|B|C|D|E|F|G|As|Bes|Ces|Des|Es|Fes|Ges|Ais|Bis|Cis|Dis|Eis|Fis|Gis NOTENAMEII a|b|c|d|e|f|g|as|bes|ces|des|es|fes|ges|ais|bis|cis|dis|eis|fis|gis @@ -45,6 +47,17 @@ REAL [0-9]+(\.[0-9]*)? BEGIN(notes); return '$'; } +{NOTECOMMAND} { + String c = YYText() +1; + int l = lookup_keyword(c); + if (l == -1) { + String e("unknown NOTECOMMAND: \\"); + e += c; + yyerror(e); + } + return l; +} + {RESTNAME} { const char *s = YYText(); yylval.string = new String (s); @@ -61,6 +74,8 @@ REAL [0-9]+(\.[0-9]*)? yylval.string = new String (YYText()); return DURATION; } +\| { +} [:space:]+ { } [ \t\n]+ { @@ -71,8 +86,18 @@ REAL [0-9]+(\.[0-9]*)? \$ { BEGIN(INITIAL); return '$'; } +[\[){] { /* parens () are NO mistake */ + yylval.c = YYText()[0]; + return OPEN_REQUEST_PARENS; +} +[\]()}] { /* parens () are NO mistake */ + yylval.c = YYText()[0]; + return CLOSE_REQUEST_PARENS; +} + . { - error("lexer error: illegal character found: " + String(YYText())); + String s("lexer error: illegal character found: " + String(YYText())); + yyerror(s); } \" { @@ -178,9 +203,9 @@ close_input() cout << "]" << flush; - if (include_stack.empty()) - return false ; - else + if (include_stack.empty()) { + return false ; + } else lexer->switch_streams(include_stack.top()); return true; } @@ -191,18 +216,14 @@ yylex() { } void -yyerror(char *s) +yyerror(const char *s) { *mlog << "error in line " << lexer->lineno() << ": " << s << '\n'; exit(1); } - -#if 0 - -{NOTENAME} { - yylval.string = new String (YYText()); - return NOTENAME; +void +kill_lexer() +{ + delete lexer; } - -#endif diff --git a/linespace.cc b/src/linespace.cc similarity index 94% rename from linespace.cc rename to src/linespace.cc index 17c16ef4ef..6b16c9afab 100644 --- a/linespace.cc +++ b/src/linespace.cc @@ -10,7 +10,7 @@ bool Spacing_problem::contains(const PCol *w) { for (int i=0; i< cols.sz(); i++) - if (cols[i].col == w) + if (cols[i].pcol_ == w) return true; return false; } @@ -19,7 +19,7 @@ int Spacing_problem::col_id(const PCol *w)const { for (int i=0; i< cols.sz(); i++) - if (cols[i].col == w) + if (cols[i].pcol_ == w) return i; assert(false); } @@ -29,16 +29,21 @@ Spacing_problem::OK() const { #ifndef NDEBUG Union_find connected(cols.sz()); - + svec fixed; for (int i=0; i < ideals.sz(); i++) { assert(ideals[i]->hooke > 0); int l = col_id(ideals[i]->left); int r = col_id(ideals[i]->right); connected.connect(l,r); } - + for (int i = 0; i < cols.sz(); i++) + if (cols[i].fixed) + fixed.add(i); for (int i = 0; i < cols.sz(); i++) { - assert( connected.equiv(0,i)); + bool c=false; + for (int j =0; j\n" "\n" - "\n" " This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License version 2\n" "as published by the Free Software Foundation.\n" @@ -53,6 +60,10 @@ main (int argc, char **argv) notice(); exit(0); break; + case 'h': + help(); + exit(0); + break; default: assert(false); break; 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/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/misc.cc b/src/misc.cc similarity index 100% rename from misc.cc rename to src/misc.cc diff --git a/molecule.cc b/src/molecule.cc similarity index 85% rename from molecule.cc rename to src/molecule.cc index 8fca34836b..e8c4d2adec 100644 --- a/molecule.cc +++ b/src/molecule.cc @@ -4,6 +4,7 @@ #include "molecule.hh" #include "symbol.hh" #include "debug.hh" +#include "tex.hh" void Atom::print() const @@ -74,7 +75,11 @@ Molecule::add(const Molecule &m) void Molecule::add_right(const Molecule &m) { - Real xof=extent().x.max - m.extent().x.min; + if (!ats.size()) { + add(m); + return; + } + Real xof=extent().x.max - m.extent().x.min; Molecule toadd(m); toadd.translate(Offset(xof, 0.0)); add(toadd); @@ -83,6 +88,10 @@ Molecule::add_right(const Molecule &m) void Molecule::add_left(const Molecule &m) { + if (!ats.size()) { + add(m); + return; + } Real xof=extent().x.min - m.extent().x.max; Molecule toadd(m); toadd.translate(Offset(xof, 0.0)); @@ -93,7 +102,11 @@ Molecule::add_left(const Molecule &m) void Molecule::add_top(const Molecule &m) { - Real yof=extent().y.max - m.extent().y.min; + if (!ats.size()) { + add(m); + return; + } + Real yof=extent().y.max - m.extent().y.min; Molecule toadd(m); toadd.translate(Offset(0,yof)); add(toadd); @@ -102,6 +115,10 @@ Molecule::add_top(const Molecule &m) void Molecule::add_bot(const Molecule &m) { + if (!ats.size()) { + add(m); + return; + } Real yof=extent().y.min- m.extent().y.max; Molecule toadd(m); toadd.translate(Offset(0,yof)); diff --git a/note.cc b/src/note.cc similarity index 64% rename from note.cc rename to src/note.cc index b897ce0e66..0041bb7238 100644 --- a/note.cc +++ b/src/note.cc @@ -1,12 +1,14 @@ #include + #include "string.hh" #include "real.hh" #include "debug.hh" #include "request.hh" #include "voice.hh" #include "notename.hh" +#include "vray.hh" -int default_duration = 4; +int default_duration = 4, default_dots=0, default_octave=0; void parse_duration(const char *a, int &j, int &intdur, int &dots) @@ -17,17 +19,17 @@ parse_duration(const char *a, int &j, int &intdur, int &dots) durstr += a[j++]; } - dots=0; + dots=default_dots; while (a[j] == '.') { j++; dots++; } + intdur = (durstr.len()) ? durstr.value():default_duration; - mtor << "dur " << intdur << "dots " << dots<= 2) { - Stem_req * st = new Stem_req(v, dur); + Stem_req * st = new Stem_req(dur); v->add(st); } @@ -131,11 +133,74 @@ get_rest_element(String, String durstr) parse_duration(durstr, i, dur, dots); i=0; - Rest_req * rq = new Rest_req(v); + Rest_req * rq = new Rest_req; rq->balltype = dur; rq->dots = dots; rq->print(); v->add(rq); + return v; } + +void +set_default_duration(String d) +{ + int i=0; + parse_duration(d, i, default_duration, default_dots); +} + + +void +set_default_pitch(String d) +{ + int i=0; + bool b; + int l,s; + parse_pitch(d, i, default_octave, b, l,s); +} + +Request* +get_request(char c) +{ + Request* ret=0; + switch (c) { + case '[': + case ']': + ret = new Beam_req; + break; + + case ')': + case '(': + ret = new Slur_req; + break; + default: + assert(false); + break; + } + + switch (c) { + case '(': + case '[': + ret->span()->spantype = Span_req::START; + break; + case ')': + case ']': + ret->span()->spantype = Span_req::STOP; + break; + default: + assert(false); + break; + } + + return ret; +} + +void +add_requests(Voice_element *v, svec &req) +{ + for (int i = 0; i < req.sz(); i++) { + v->add(req[i]); + } + req.set_size(0); +} diff --git a/notehead.cc b/src/notehead.cc similarity index 91% rename from notehead.cc rename to src/notehead.cc index fe026b1036..a103e69b3d 100644 --- a/notehead.cc +++ b/src/notehead.cc @@ -1,10 +1,8 @@ #include "notehead.hh" #include "dimen.hh" #include "debug.hh" -#include "pstaff.hh" -#include "pscore.hh" #include "paper.hh" -#include "lookupsyms.hh" +#include "lookup.hh" #include "molecule.hh" @@ -35,7 +33,7 @@ Notehead::brew_molecole() assert(pstaff_); assert(!output); - Paperdef *p = pstaff_->pscore_->paper_; + Paperdef *p = paper(); Real dy = p->interline()/2; Symbol s = p->lookup_->ball(balltype); diff --git a/notename.cc b/src/notename.cc similarity index 100% rename from notename.cc rename to src/notename.cc diff --git a/paper.cc b/src/paper.cc similarity index 89% rename from paper.cc rename to src/paper.cc index 89f9a9fe5c..8cd98339d4 100644 --- a/paper.cc +++ b/src/paper.cc @@ -2,7 +2,7 @@ #include "paper.hh" #include "debug.hh" -#include "lookupsyms.hh" +#include "lookup.hh" #include "dimen.hh" #include "textdb.hh" @@ -20,13 +20,17 @@ Paperdef::duration_to_dist(Real d) { return whole_width * pow(geometric_, log2(d)); } - +Real +Paperdef::rule_thickness()const +{ + return convert_dimen(0.4, "pt"); +} Paperdef::Paperdef() { lookup_ = new Lookup(); parse(); linewidth = convert_dimen(15,"cm"); // in cm for now - whole_width= 6*note_width(); + whole_width= 8*note_width(); geometric_ = PHI; } diff --git a/parser.y b/src/parser.y similarity index 76% rename from parser.y rename to src/parser.y index 3ce26028b1..691d306e78 100644 --- a/parser.y +++ b/src/parser.y @@ -17,6 +17,7 @@ #define YYDEBUG 1 #endif +svec pre_reqs, post_reqs; %} @@ -32,19 +33,25 @@ Score *score; const char *consstr; Paperdef *paper; + Request* request; int i; + char c; } %token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT %token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS -%token MELODICSTAFF GEOMETRIC START +%token MELODICSTAFF GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND -%type unit %token IDENTIFIER %token NEWIDENTIFIER %token PITCH DURATION RESTNAME %token REAL %token STRING +%token OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS + + +%type unit + %type declaration %type paper_block paper_body %type dim @@ -56,6 +63,8 @@ %type melodicstaff_block melodicstaff_body staffdecl %type int %type score_commands_block score_commands_body +%type post_request pre_request + %% @@ -167,7 +176,7 @@ voice_block: voice_body: IDENTIFIER { $$ = new Voice(*$1->voice()); } | voice_elts_dollar { $$ = $1; } - | voice_body START REAL { $$->start = $3; } + | voice_body START_T REAL { $$->start = $3; } ; @@ -181,17 +190,66 @@ voice_elts: /* empty */ { $$ = new Voice; } - | voice_elts voice_elt { - $$->add($2); + | voice_elts pre_requests voice_elt post_requests { + add_requests($3, pre_reqs); + add_requests($3, post_reqs); + $$->add($3); } + + | voice_elts voice_command { } ; -voice_elt: - PITCH DURATION { $$ = get_note_element(*$1, *$2); +post_requests: + { + assert(post_reqs.empty()); + } + | post_requests post_request { + post_reqs.add($2); + } + ; +post_request: + CLOSE_REQUEST_PARENS { $$ = get_request($1); } + ; + +pre_requests: + | pre_requests pre_request { + pre_reqs.add($2); } - | RESTNAME DURATION { $$ = get_rest_element(*$1, *$2); + ; +pre_request: + OPEN_REQUEST_PARENS { $$ = get_request($1); } + ; +/* +*/ +voice_command: + DURATIONCOMMAND DURATION { + set_default_duration(*$2); + delete $2; + } + | OCTAVECOMMAND PITCH { + set_default_pitch(*$2); + delete $2; + } + ; + +voice_elt: + PITCH DURATION { + $$ = get_note_element(*$1, *$2); + delete $1; + delete $2; + } + | RESTNAME DURATION { + $$ = get_rest_element(*$1, *$2); + delete $1; + delete $2; + } + | PITCH { $$ = get_note_element(*$1, ""); + delete $1; + } + | RESTNAME { $$ = get_rest_element(*$1, ""); + delete $1; } ; @@ -229,5 +287,6 @@ parse_file(String s) new_input(s); yyparse(); delete_identifiers(); + kill_lexer(); *mlog << "\n"; } diff --git a/pcol.cc b/src/pcol.cc similarity index 97% rename from pcol.cc rename to src/pcol.cc index 1ae06519ac..902f57bab2 100644 --- a/pcol.cc +++ b/src/pcol.cc @@ -109,9 +109,10 @@ PCol::~PCol() } void -PCol::add(const Item *i) +PCol::add( Item *i) { its.bottom().add(i); + i->pcol_ = this; used = true; } diff --git a/pscore.cc b/src/pscore.cc similarity index 81% rename from pscore.cc rename to src/pscore.cc index 3f6f289d26..8d7067760f 100644 --- a/pscore.cc +++ b/src/pscore.cc @@ -1,12 +1,14 @@ // utility functions for PScore #include "debug.hh" +#include "spanner.hh" #include "paper.hh" #include "molecule.hh" #include "dimen.hh" -#include "line.hh" +#include "scoreline.hh" #include "pscore.hh" #include "tstream.hh" + void PScore::clean_cols() { @@ -21,7 +23,8 @@ PScore::clean_cols() void PScore::add(PStaff *s) { - staffs.bottom().add(s); + assert(s->pscore_ == this); + staffs.bottom().add(s); } void @@ -38,21 +41,41 @@ PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) 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]->output->translate(Offset(-iv.length(),0)); - i->output->translate (Offset(-iv.max, 0)); + col_its[j]->translate(Offset(-iv.length(),0)); + i->translate (Offset(-iv.max, 0)); } } - its.bottom().add(i); - s->add(i); - c->add(i); - i->preprocess(); + +} + +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) { @@ -80,6 +103,10 @@ PScore::get_spacing(PCol*l, PCol*r) return ip; } + +/* + return all breakable columns + */ svec PScore::find_breaks() const { @@ -87,7 +114,7 @@ PScore::find_breaks() const for (PCursor c(cols); c.ok(); c++) if (c->breakable()) retval.add(c); - + return retval; } @@ -115,6 +142,7 @@ PScore::output(Tex_stream &ts) } } + svec PScore::select_items(PStaff*ps , PCol*pc) { @@ -142,7 +170,7 @@ void PScore::print() const { #ifndef NPRINT - mtor << "PScore { paper "; + mtor << "PScore { "; paper_->print(); mtor << "\ncolumns: "; for (PCursor cc(cols); cc.ok(); cc++) @@ -168,6 +196,9 @@ PScore::preprocess() void PScore::postprocess() { + for (PCursor ic(spanners); ic.ok(); ic++) { + ic->process(); + } for (PCursor ic(its); ic.ok(); ic++){ ic->postprocess(); } diff --git a/pstaff.cc b/src/pstaff.cc similarity index 100% rename from pstaff.cc rename to src/pstaff.cc diff --git a/qlp.cc b/src/qlp.cc similarity index 100% rename from qlp.cc rename to src/qlp.cc diff --git a/qlpsolve.cc b/src/qlpsolve.cc similarity index 100% rename from qlpsolve.cc rename to src/qlpsolve.cc diff --git a/request.cc b/src/request.cc similarity index 86% rename from request.cc rename to src/request.cc index 35a9ae9718..9928f62bed 100644 --- a/request.cc +++ b/src/request.cc @@ -8,7 +8,9 @@ RCONS(Rest_req); RCONS(Rhythmic_req); RCONS(Stem_req); RCONS(Note_req); - +RCONS(Span_req); +RCONS(Slur_req); +RCONS(Beam_req); void Request::print() const @@ -18,13 +20,12 @@ Request::print() const #endif } -Request::Request(Voice_element*v) +Request::Request() { - elt = v; + elt = 0; } -Note_req::Note_req(Voice_element*v) - : Rhythmic_req(v) +Note_req::Note_req() { name = 'c'; octave = 0; @@ -41,8 +42,7 @@ Note_req::height() const return s + octave*7; } -Rhythmic_req::Rhythmic_req(Voice_element*v) - :Request(v) +Rhythmic_req::Rhythmic_req() { balltype = 1; dots = 0; @@ -65,11 +65,6 @@ Note_req::print() const Rhythmic_req::print(); } -Request::Request() -{ - elt = 0; -} - void Rest_req::print() const { @@ -95,3 +90,12 @@ Rhythmic_req::duration() const { return wholes( balltype,dots); } +Beam_req::Beam_req() +{ + nplet = 0; +} + +Span_req::Span_req() +{ + spantype = NOSPAN; +} diff --git a/src/rest.cc b/src/rest.cc new file mode 100644 index 0000000000..e448df37bd --- /dev/null +++ b/src/rest.cc @@ -0,0 +1,47 @@ +#include "rest.hh" +#include "dimen.hh" +#include "debug.hh" +#include "paper.hh" +#include "lookup.hh" +#include "molecule.hh" + + +Rest::Rest(int t, int d) +{ + balltype = t; + dots = d; +} + +void +Rest::print()const +{ + mtor << "Rest "<lookup_->rest(balltype); + + Molecule *m = new Molecule(Atom(s)); + if (dots) { + Symbol d =p->lookup_->dots(dots); + Molecule dm; + dm.add(Atom(d)); + m->add_right(dm); + } + output = m; +} + 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); +} diff --git a/sccol.cc b/src/sccol.cc similarity index 100% rename from sccol.cc rename to src/sccol.cc diff --git a/scommands.cc b/src/scommands.cc similarity index 93% rename from scommands.cc rename to src/scommands.cc index 8f86ff6fad..7b8c8ed9c5 100644 --- a/scommands.cc +++ b/src/scommands.cc @@ -69,6 +69,7 @@ Score_commands::set_breakable(Real when) add_seq(seq); } + bool Score_commands::is_breakable(Real w) { @@ -94,10 +95,10 @@ Score_commands::insert_between(Command victim, PCursor firstc, c++; } last.insert(new Command(victim)); - } + void -Score_commands::add_command_to_break(Command pre, Command mid,Command post) +Score_commands::add_command_to_break(Command pre, Command mid, Command post) { Real w = pre.when; PCursor c ( first(w)), f(c), l(c); @@ -216,6 +217,9 @@ Score_commands::print() const } } +/* + TODO + */ Score_commands* Score_commands::parse(Real l) const { @@ -238,13 +242,14 @@ Score_commands::parse(Real l) const for (PCursor cc(*this); cc.ok() && cc->when <= l; cc++) { assert (cc->code==INTERPRET); if (cc->args[0] == "METER") { - beats_per_meas=cc->args[1].value(); - int one_beat =cc->args[2].value (); + beats_per_meas = cc->args[1].value(); + int one_beat = cc->args[2].value(); measlen = beats_per_meas/Real(one_beat); - nc->process_add(*get_meter_command(wholes,beats_per_meas, one_beat)); + nc->process_add(*get_meter_command(wholes, beats_per_meas, one_beat)); } if (cc->args[0] == "SKIP") { - stoppos = wholes + cc->args[1].value() * measlen + cc->args[2].fvalue(); + stoppos = wholes + cc->args[1].value() * measlen + + cc->args[2].fvalue(); wholes += (measlen-inbar); // skip at least 1 measure barcount++; while (wholes <= stoppos) { diff --git a/score.cc b/src/score.cc similarity index 100% rename from score.cc rename to src/score.cc diff --git a/src/scoreline.cc b/src/scoreline.cc new file mode 100644 index 0000000000..7e40c6a76a --- /dev/null +++ b/src/scoreline.cc @@ -0,0 +1,43 @@ +#include "scoreline.hh" +#include "staffline.hh" +#include "dimen.hh" +#include "spanner.hh" +#include "symbol.hh" +#include "paper.hh" +#include "pcol.hh" +#include "pscore.hh" + + +String +Line_of_score::TeXstring() const +{ + String s("\\vbox{%<- line of score\n"); + for (PCursor sc(staffs); sc.ok(); sc++){ + s += sc->TeXstring(); + if ((sc+1).ok()) + s+= "\\interstaffline\n"; + } + s += "}"; + return s; +} + + +Line_of_score::Line_of_score(svec sv, + const PScore *ps) +{ + score = ps; + for (int i=0; i< sv.sz(); i++) { + PCol *p=(PCol *) sv[i]; + cols.bottom().add(p); + p->line=this; + } + + for (PCursor sc(score->staffs); sc.ok(); sc++) + staffs.bottom().add(new Line_of_staff(this, sc)); +} +/* construct a line with the named columns. Make the line field + in each column point to this + + #sv# isn't really const!! + */ + diff --git a/scores.cc b/src/scores.cc similarity index 100% rename from scores.cc rename to src/scores.cc diff --git a/src/simpleprint.cc b/src/simpleprint.cc new file mode 100644 index 0000000000..395396e22b --- /dev/null +++ b/src/simpleprint.cc @@ -0,0 +1,55 @@ +#include "lookup.hh" +#include "request.hh" +#include "beam.hh" +#include "pscore.hh" +#include "paper.hh" +#include "simplestaff.hh" +#include "molecule.hh" +#include "sccol.hh" +#include "stem.hh" +#include "notehead.hh" +#include "rest.hh" +#include "debug.hh" +#include "bar.hh" +#include "meter.hh" + +Item * +Simple_staff::get_TYPESET_item(Command *com) +{ + Item *s; + if (com -> args[0] == "BAR" ) { + s = new Bar(com->args[1]); + } else if (com->args[0] == "METER") { + svec arg( com->args); + arg.del(0); + s = new Meter(arg); + } else + assert(false); + + return s; +} + +void +Simple_column::typeset_item(Item *i, int breakst) +{ + assert(i); + // ugh + staff_->pscore_->typeset_item(i, score_column->pcol, + staff_->theline,breakst); +} + +void +Simple_staff::set_output(PScore* ps ) +{ + pscore_ = ps; + pscore_->add(theline); +} + + +Rest* +Simple_staff::get_rest(Rest_req*rq) +{ + int b = rq->rhythmic()->balltype; + int d = rq->rhythmic()->dots; + return new Rest(b, d); +} 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); +} + + diff --git a/src/spanner.cc b/src/spanner.cc new file mode 100644 index 0000000000..16c3ff19cb --- /dev/null +++ b/src/spanner.cc @@ -0,0 +1,54 @@ +#include "pstaff.hh" +#include "debug.hh" +#include "pscore.hh" +#include "spanner.hh" +#include "symbol.hh" +#include "molecule.hh" +#include "pcol.hh" + +String +Spanner::TeXstring() const +{ + + assert(output); + return output->TeXstring(); +} + +Spanner::Spanner() +{ + pstaff_=0; + left = right = 0; +} + +void +Spanner::process() +{ +} + +void +Spanner::preprocess() +{ +} + +Interval +Spanner::width()const +{ + return Interval(0,right->hpos - left->hpos); +} + +Paperdef* +Spanner::paper()const +{ + assert(pstaff_); + return pstaff_->pscore_->paper_; +} +void +Spanner::print()const +{ +#ifndef NPRINT + mtor << "Spanner { Output "; + output->print(); + + mtor << "}\n"; +#endif +} diff --git a/staff.cc b/src/staff.cc similarity index 95% rename from staff.cc rename to src/staff.cc index 8b5c0782c5..3a32801b2f 100644 --- a/staff.cc +++ b/src/staff.cc @@ -1,4 +1,5 @@ #include "staff.hh" +#include "swalker.hh" #include "stcol.hh" #include "sccol.hh" #include "debug.hh" @@ -125,11 +126,7 @@ Staff::process() { setup_staffcols(); OK(); - for (PCursor sc(cols); sc.ok(); sc++) { - sc->process_commands(); - sc->process_requests(); - } - grant_requests(); + walk(); } void diff --git a/line.cc b/src/staffline.cc similarity index 64% rename from line.cc rename to src/staffline.cc index 293214dc30..c83e904bc6 100644 --- a/line.cc +++ b/src/staffline.cc @@ -1,4 +1,5 @@ -#include "line.hh" +#include "staffline.hh" +#include "scoreline.hh" #include "dimen.hh" #include "spanner.hh" #include "symbol.hh" @@ -8,8 +9,7 @@ static String make_vbox(Interval i) -{ - +{ String s("\\vbox to "); s += print_dimen(i.length()); s += "{\\vskip "+print_dimen(i.max)+" "; @@ -57,19 +57,22 @@ Line_of_staff::TeXstring() const Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) { - scor=sc; pstaff_=st; +#if 0 + const PCol *linestart = sc->cols.top(); + const PCol *linestop = sc->cols.bottom(); - const PCol *linestart= sc->cols.top(); - const PCol *linestop=sc->cols.bottom(); - for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { const PCol *brokenstart = &MAX(*linestart, *sp->left); const PCol *brokenstop = &MIN(*linestop, *sp->right); +// if (*brokenstop < *brokenstart) + brokenspans.bottom().add(sp->broken_at(0,0)); + } +#endif + for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { - if (*brokenstop < *brokenstart) - brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart)); + brokenspans.bottom().add(sp->broken_at(0,0)); } } @@ -93,45 +96,12 @@ Line_of_staff::height() const // spanners. for (PCursor sc(cc->starters); sc.ok(); sc++) - if (sc->pstaff_ == pstaff_) - assert(false); + if (sc->pstaff_ == pstaff_) { + y.unite(sc->height()); + } } } return y; } -/****************************************************************/ -String -Line_of_score::TeXstring() const -{ - String s("\\vbox{%<- line of score\n"); - for (PCursor sc(staffs); sc.ok(); sc++){ - s += sc->TeXstring(); - if ((sc+1).ok()) - s+= "\\interstaffline\n"; - } - s += "}"; - return s; -} - -/// testing this entry -Line_of_score::Line_of_score(svec sv, - const PScore *ps) -{ - score = ps; - for (int i=0; i< sv.sz(); i++) { - PCol *p=(PCol *) sv[i]; - cols.bottom().add(p); - p->line=this; - } - - for (PCursor sc(score->staffs); sc.ok(); sc++) - staffs.bottom().add(new Line_of_staff(this, sc)); -} -/** construct a line with the named columns. Make the line field - in each column point to this - - #sv# isn't really const!! - */ - diff --git a/stcol.cc b/src/stcol.cc similarity index 100% rename from stcol.cc rename to src/stcol.cc diff --git a/src/stem.cc b/src/stem.cc new file mode 100644 index 0000000000..fdb47f9755 --- /dev/null +++ b/src/stem.cc @@ -0,0 +1,156 @@ +#include "stem.hh" +#include "dimen.hh" +#include "debug.hh" +#include "paper.hh" +#include "notehead.hh" +#include "lookup.hh" +#include "molecule.hh" +#include "pcol.hh" + +const int STEMLEN=7; +static int +ABS(int i) { + return (i < 0)?-i:i; +} + + +Stem::Stem(int c) +{ + minnote = 1000; // invalid values + maxnote = -1000; + bot = top = 0; + flag = 4; + dir =0; + staff_center=c; + stemlen=0; + print_flag=true; + stem_xoffset=0; +} + + +void +Stem::set_stemend(Real se) +{ + // todo: margins + assert((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)); + + top = (dir < 0) ? maxnote : se; + bot = (dir < 0) ? se : minnote; + flag = dir*ABS(flag); +} + +void +Stem::add(Notehead *n) +{ + if (n->balltype == 1) + return; + int p = n->position; + if ( p < minnote) + minnote = p; + if ( p> maxnote) + maxnote = p; +} +void +Stem::print()const +{ + mtor << "Stem minmax=["<< minnote<<","< staff_center) ? -1: 1; +} + +void +Stem::set_default_stemlen() +{ + if (!dir) + set_default_dir(); + + int stafftop = 2*staff_center; + stemlen = STEMLEN + (maxnote - minnote); + + // uhh... how about non 5-line staffs? + if (maxnote < -2 && dir == 1){ + int t = staff_center - staff_center/2; + stemlen = t - minnote +2; + } else if (minnote > stafftop + 2 && dir == -1) { + int t = staff_center + staff_center/2; + stemlen = maxnote -t +2; + } + + assert(stemlen); +} + + +void +Stem::set_default_extents() +{ + assert(minnote<=maxnote); + + if (!stemlen) + set_default_stemlen(); + + set_stemend((dir< 0) ? maxnote-stemlen: minnote +stemlen); + if (dir > 0){ + stem_xoffset = paper()->note_width(); + } +} + +void +Stem::postprocess() +{ + set_default_extents(); + brew_molecole(); +} + +Interval +Stem::width()const +{ + if (!print_flag || ABS(flag) <= 4) + return Interval(0,0); // TODO! + Paperdef*p= paper(); + return p->lookup_->flag(flag).dim.x; +} + +void +Stem::brew_molecole() +{ + assert(pstaff_); + assert(bot!=top); + assert(!output); + + Paperdef *p =paper(); + Parametric_symbol *stem = p->lookup_->stem(); + + Real dy = p->interline()/2; + String y1 =print_dimen( dy * bot); + String y2 = print_dimen(dy * top); + Symbol ss =stem->eval(y1,y2); + delete stem; + + output = new Molecule(Atom(ss)); + + if (print_flag&&ABS(flag) > 4){ + Symbol fl = p->lookup_->flag(flag); + Molecule m(fl); + if (flag < -4){ + output->add_bot(m); + } else if (flag > 4) { + output->add_top(m); + } else + assert(false); + } + + output->translate(Offset(stem_xoffset,0)); + +} + +Real +Stem::hpos()const +{ + return pcol_->hpos + stem_xoffset; +} diff --git a/src/swalker.cc b/src/swalker.cc new file mode 100644 index 0000000000..db48fd1f82 --- /dev/null +++ b/src/swalker.cc @@ -0,0 +1,32 @@ +#include "request.hh" +#include "swalker.hh" +#include "stcol.hh" + +Staff_walker::~Staff_walker() {} + +Staff_walker::Staff_walker(Staff * s, PScore*ps ) + : PCursor (s->cols) +{ + staff_ = s; + pscore_ = ps; + break_status = BREAK_END - BREAK_PRE; +} + +Real +Staff_walker::when() const +{ + return (* (PCursor *) this)->when(); +} + +void +Staff_walker::process() +{ + break_status = BREAK_END - BREAK_PRE; + + for (int i = 0 ; i < (*this)->s_commands.sz(); i++) { + process_command((*this)->s_commands[i]); + } + + process_requests(); +} + diff --git a/symbol.cc b/src/symbol.cc similarity index 100% rename from symbol.cc rename to src/symbol.cc diff --git a/symtable.cc b/src/symtable.cc similarity index 92% rename from symtable.cc rename to src/symtable.cc index e963b64d12..a28d14670c 100644 --- a/symtable.cc +++ b/src/symtable.cc @@ -39,7 +39,9 @@ Symtables::read(Text_db &symini) if (r[0] == "end") break; - assert(r.sz() == 6); + if (r.sz() != 6) + error("Not enough fields in symbol init"); + int i=0; String id=r[i++]; String tex=r[i++]; diff --git a/table.cc b/src/table.cc similarity index 92% rename from table.cc rename to src/table.cc index 58d1c425e1..1f302259e9 100644 --- a/table.cc +++ b/src/table.cc @@ -14,6 +14,7 @@ static Keyword_ent the_key_tab[]={ "bar", BAR, "output", OUTPUT, "cm", CM, + "start", START_T, "pt", PT, "in", IN, "mm", MM, @@ -22,9 +23,11 @@ static Keyword_ent the_key_tab[]={ "meter", METER, "unitspace", UNITSPACE, "skip", SKIP, + "octave", OCTAVECOMMAND, "commands", COMMANDS, "staff", STAFF, "geometric", GEOMETRIC, + "duration", DURATIONCOMMAND, 0,0 } ; diff --git a/template1.cc b/src/template1.cc similarity index 86% rename from template1.cc rename to src/template1.cc index ece4e2ff18..fd2431130e 100644 --- a/template1.cc +++ b/src/template1.cc @@ -1,4 +1,3 @@ -#include "line.hh" #include "plist.hh" #include "pcol.hh" @@ -6,6 +5,8 @@ #include "request.hh" #include "command.hh" #include "spanner.hh" +#include "scoreline.hh" +#include "staffline.hh" #include "list.cc" #include "plist.cc" @@ -13,6 +14,7 @@ #define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a) +L_instantiate(Stem*); PLC_instantiate(Line_of_score); PLC_instantiate(Line_of_staff); PLC_instantiate(Item); diff --git a/template2.cc b/src/template2.cc similarity index 94% rename from template2.cc rename to src/template2.cc index 5e0431c42a..01695c863f 100644 --- a/template2.cc +++ b/src/template2.cc @@ -1,4 +1,4 @@ -#include "line.hh" + #include "symbol.hh" #include "voice.hh" diff --git a/template3.cc b/src/template3.cc similarity index 100% rename from template3.cc rename to src/template3.cc diff --git a/tex.cc b/src/tex.cc similarity index 100% rename from tex.cc rename to src/tex.cc diff --git a/src/texbeam.cc b/src/texbeam.cc new file mode 100644 index 0000000000..e21efba0be --- /dev/null +++ b/src/texbeam.cc @@ -0,0 +1,99 @@ +/* + + Code to generate beams for TeX + + */ + + #include +#include "symbol.hh" +#include "molecule.hh" +#include "tex.hh" +#include "symtable.hh" +#include "dimen.hh" +#include "lookup.hh" + +Symbol +Lookup::beam_element(int sidx, int widx, Real slope) +{ + Symbol bs=(*symtables_)("beamslopes")->lookup("slope"); + + svec args; + args.add(sidx); + args.add(widx); + bs.tex = substitute_args(bs.tex,args); + int w = 2 << widx; + Real width = convert_dimen(w,"pt"); + bs.dim.x = Interval(0,width); + bs.dim.y = Interval(0,width*slope); + return bs; +} + +// ugh.. hard wired tex-code. +static int +slope_index(Real &s) +{ + assert(ABS(s) < 0.45); + int i = int(rint(s * 20.0)); + + s = i/20.0; + if (s>0) + return 6*i +122; + else + return -6 * i+ 188; +} + +Symbol +Lookup::rule_symbol(Real height, Real width) +{ + Symbol bs=(*symtables_)("beamslopes")->lookup("horizontal"); + svec args; + args.add(print_dimen(height)); + args.add(print_dimen(width)); + bs.tex = substitute_args(bs.tex,args); + bs.dim.x = Interval(0,width); + bs.dim.y = Interval(0,height); + return bs; +} + +Symbol +Lookup::beam(Real &slope, Real width) +{ + int sidx = slope_index(slope); + if (!slope) + return rule_symbol(convert_dimen(2,"pt"), width); + + Real w = width; + Real elemwidth = convert_dimen(64,"pt"); + int widx = 5; + + Molecule m; + Real dy=0; + Real minwid =convert_dimen(2,"pt"); + assert(w > minwid); + while (w > minwid) { + while (elemwidth > w) { + widx --; + elemwidth /= 2.0; + } + + Atom a(beam_element(sidx, widx, slope)); + a.translate(Offset(0, dy)); + m.add_right(a); + dy += elemwidth*slope; + w -= elemwidth; + } + + widx = 0; + Atom a(beam_element(sidx, widx, slope)); + a.translate(Offset(width -minwid, (width-minwid) * slope)); + m.add(a); + + Symbol ret; + ret.tex = m.TeXstring(); + ret.dim.y = Interval(0,width*slope); + ret.dim.x = Interval(0,width); + + return ret; +} + + diff --git a/tstream.cc b/src/tstream.cc similarity index 100% rename from tstream.cc rename to src/tstream.cc diff --git a/version.cc b/src/version.cc similarity index 100% rename from version.cc rename to src/version.cc diff --git a/voice.cc b/src/voice.cc similarity index 98% rename from voice.cc rename to src/voice.cc index 379cbae23a..14883e1499 100644 --- a/voice.cc +++ b/src/voice.cc @@ -56,6 +56,7 @@ Voice_element::add(Request*r) assert (!duration); duration = r->duration(); } + r->elt = this; reqs.bottom().add(r); } diff --git a/warn.cc b/src/warn.cc similarity index 100% rename from warn.cc rename to src/warn.cc diff --git a/stem.cc b/stem.cc deleted file mode 100644 index fd6634c6bf..0000000000 --- a/stem.cc +++ /dev/null @@ -1,99 +0,0 @@ -#include "stem.hh" -#include "dimen.hh" -#include "debug.hh" -#include "pstaff.hh" -#include "pscore.hh" -#include "paper.hh" -#include "lookupsyms.hh" -#include "molecule.hh" - -const int STEMLEN=7; - -Stem::Stem(int c) -{ - minnote = maxnote = 0; - bot = top = 0; - flag = 4; - staff_center=c; -} - -void -Stem::print()const -{ - mtor << "Stem minmax=["<< minnote<<","< stafftop + 2) { - top = maxnote; - bot = staff_center + staff_center/2; - flag = -flag; - }else { - Real mean = (minnote+maxnote)/2; - - top = (mean > staff_center) ? maxnote : maxnote+STEMLEN; - bot = (mean > staff_center) ? minnote-STEMLEN : minnote; - flag = (mean > staff_center) ? -flag : flag; - } -} - -void -Stem::postprocess() -{ - calculate(); - brew_molecole(); -} - -Interval -Stem::width()const -{ - if (ABS(flag) <= 4) - return Interval(0,0); // TODO! - Paperdef*p= pstaff_->pscore_->paper_; - return p->lookup_->flag(flag).dim.x; -} - -void -Stem::brew_molecole() -{ - assert(pstaff_); - assert(bot!=top); - assert(!output); - - Paperdef *p = pstaff_->pscore_->paper_; - Parametric_symbol *stem = p->lookup_->stem(); - - Real dy = p->interline()/2; - String y1 =print_dimen( dy * bot); - String y2 = print_dimen(dy * top); - Symbol ss =stem->eval(y1,y2); - delete stem; - - output = new Molecule(Atom(ss)); - - if (ABS(flag) > 4){ - Symbol fl = p->lookup_->flag(flag); - Molecule m(fl); - if (flag < -4){ - output->add_bot(m); - } else if (flag > 4) { - output->add_top(m); - } else - assert(false); - } - - if (flag > 0){ - Real dx = pstaff_->pscore_->paper_->note_width(); // ugh - output->translate(Offset(dx,0)); - } -} diff --git a/suzan.ly b/suzan.ly deleted file mode 100644 index 59eb0c7489..0000000000 --- a/suzan.ly +++ /dev/null @@ -1,8 +0,0 @@ -% testje - -score{ - rhythmstaff { - voice { $ c2 c2 c4. c8 c4 c4 c4 c4 c4 c4 c2 c2$ } - } - commands { meter 2 4 skip 2:0 meter 4 4 skip 2:0} -} diff --git a/symbol.ini b/symbol.ini index ea303b04f1..e1e2f3f2a0 100644 --- a/symbol.ini +++ b/symbol.ini @@ -14,8 +14,8 @@ table balls end table streepjes - toplines \toplines{%} -6pt 6pt 0pt 0pt - botlines \botlines{%} -6pt 6pt 0pt 0pt + toplines \toplines{%} -7pt 7pt 0pt 0pt + botlines \botlines{%} -7pt 7pt 0pt 0pt end table bars @@ -56,9 +56,14 @@ table flags 8 \eigthflag 0pt 5pt 0pt 0pt 16 \sixteenthflag 0pt 5pt 0pt 0pt 32 \thirtysecondflag 0pt 5pt 0pt 0pt - -8 \ieigthflag -5pt 0pt 0pt 0pt - -16 \isixteenthflag -5pt 0pt 0pt 0pt - -32 \ithirtysecondflag -5pt 0pt 0pt 0pt + -8 \deigthflag 0pt 5pt 0pt 0pt + -16 \dsixteenthflag 0pt 5pt 0pt 0pt + -32 \dthirtysecondflag 0pt 5pt 0pt 0pt +end + +table beamslopes + slope \beamslope{%}{%} 0pt 0pt 0pt 0pt + horizontal \rulesym{%}{%} 0pt 0pt 0pt 0pt end end # symboltables \ No newline at end of file -- 2.39.2