From 89e80b41fb745ed7ebc2ba3ee4f183a740f305be Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 12 Feb 1997 10:27:36 +0100 Subject: [PATCH] release: 0.0.30 --- Documentation/CodingStyle.pod | 10 +- Documentation/README.pod | 8 +- Documentation/error.pod | 2 + Documentation/lilyinput.pod | 2 +- Makefile | 7 +- NEWS | 29 ++- Sources.make | 54 +++--- TODO | 31 ++- Variables.make | 21 ++- clearlily | 6 +- configure | 2 +- flower/Makefile | 4 + flower/NEWS | 5 + flower/Variables.make | 3 +- flower/assoc.hh | 8 +- flower/associter.hh | 3 - flower/choleski.hh | 30 ++- flower/compare.hh | 8 +- flower/cursor.hh | 24 +-- flower/cursor.inl | 2 +- flower/dataf.cc | 6 +- flower/dstream.cc | 6 +- flower/dstream.hh | 30 +-- flower/interval.hh | 12 +- flower/lgetopt.hh | 19 +- flower/list.hh | 56 +++--- flower/matrix.hh | 40 ++-- flower/path.cc | 20 +- flower/path.hh | 18 +- flower/pcursor.hh | 10 +- flower/plist.hh | 22 +-- flower/scalar.hh | 2 +- flower/smat.cc | 2 +- flower/string.hh | 52 ++--- flower/stringutil.hh | 34 ++-- flower/textdb.hh | 10 +- flower/textstr.hh | 19 +- flower/tvsmat.hh | 60 +++--- flower/varray.hh | 18 +- flower/vector.hh | 6 +- flower/vsmat.hh | 2 +- genheader | 41 ++-- hdr/beam.hh | 10 +- hdr/break.hh | 2 +- hdr/clef.hh | 11 +- hdr/clefitem.hh | 2 +- hdr/colhpos.hh | 2 +- hdr/command.hh | 36 ++-- hdr/complexcolumn.hh | 35 ++++ hdr/complexstaff.hh | 29 +-- hdr/complexwalker.hh | 22 ++- hdr/dimen.hh | 13 +- hdr/directionalspanner.hh | 2 +- hdr/grouping.hh | 10 +- hdr/headreg.hh | 24 +++ hdr/inputcommands.hh | 6 +- hdr/inputmusic.hh | 61 +++--- hdr/inputscore.hh | 6 +- hdr/inputstaff.hh | 2 +- hdr/item.hh | 21 ++- hdr/key.hh | 2 +- hdr/keyitem.hh | 7 +- hdr/lexer.hh | 2 +- hdr/linepstaff.hh | 11 -- hdr/linespace.hh | 59 +++--- hdr/localkeyitem.hh | 2 +- hdr/localkeyreg.hh | 24 +++ hdr/lookup.hh | 8 +- hdr/lyriccolumn.hh | 4 +- hdr/lyricitem.hh | 2 +- hdr/lyricstaff.hh | 7 +- hdr/lyricwalker.hh | 2 +- hdr/melodicstaff.hh | 29 --- hdr/meter.hh | 2 +- hdr/molecule.hh | 10 +- hdr/notehead.hh | 23 +-- hdr/paper.hh | 17 +- hdr/pcol.hh | 36 ++-- hdr/proto.hh | 10 +- hdr/pscore.hh | 20 +- hdr/pstaff.hh | 6 +- hdr/qlp.hh | 43 +++-- hdr/qlpsolve.hh | 34 ++-- hdr/register.hh | 123 +++--------- hdr/request.hh | 63 ++++--- hdr/rest.hh | 10 +- hdr/rhythmstaff.hh | 26 --- hdr/sccol.hh | 23 +-- hdr/score.hh | 16 +- hdr/scoreline.hh | 2 +- hdr/script.hh | 2 +- hdr/scriptdef.hh | 2 +- hdr/scriptreg.hh | 26 +++ hdr/simplestaff.hh | 77 -------- hdr/simplewalker.hh | 53 ------ hdr/slur.hh | 5 +- hdr/slurreg.hh | 28 +++ hdr/sourcefile.hh | 3 +- hdr/spanner.hh | 40 ++-- hdr/staff.hh | 10 +- hdr/staffcommands.hh | 2 +- hdr/staffelem.hh | 19 +- hdr/staffline.hh | 2 +- hdr/staffsym.hh | 30 +++ hdr/staffwalker.hh | 14 +- hdr/stcol.hh | 14 +- hdr/stem.hh | 26 +-- hdr/stembeamreg.hh | 32 ++++ hdr/tex.hh | 8 +- hdr/textdef.hh | 2 +- hdr/textitem.hh | 2 +- hdr/textreg.hh | 23 +++ hdr/textspanner.hh | 15 +- hdr/timedescription.hh | 2 +- hdr/tstream.hh | 10 +- hdr/voice.hh | 22 +-- hdr/voicegroup.hh | 24 +-- init/table_sixteen.ini | 4 +- input/error.ly | 4 + input/maartje.ly | 2 +- input/scsii-menuetto.ly | 165 +--------------- input/wohltemperirt.ly | 12 +- lilyponddefs.tex | 7 +- src/beam.cc | 26 ++- src/calcideal.cc | 21 +-- src/clef.cc | 37 ++-- src/clefitem.cc | 4 +- src/complexprint.cc | 22 +-- src/complexstaff.cc | 27 ++- src/complexwalker.cc | 75 +++++--- src/dimen.cc | 3 +- src/directionalspanner.cc | 2 +- src/groupregs.cc | 244 ------------------------ src/headreg.cc | 70 +++++++ src/inputcommands.cc | 6 +- src/inputmusic.cc | 10 +- src/inputscore.cc | 5 +- src/inputstaff.cc | 13 +- src/keyitem.cc | 7 +- src/lexer.l | 4 +- src/linepstaff.cc | 27 --- src/linespace.cc | 4 +- src/localkeyitem.cc | 7 +- src/localkeyreg.cc | 58 ++++++ src/lookup.cc | 23 ++- src/lyriccolumn.cc | 25 +-- src/lyricstaff.cc | 15 +- src/lyricwalker.cc | 14 +- src/melodicstaff.cc | 66 ------- src/molecule.cc | 2 +- src/mylexer.cc | 8 +- src/note.cc | 8 +- src/notehead.cc | 1 + src/notename.cc | 2 +- src/paper.cc | 7 +- src/parser.y | 18 +- src/pscore.cc | 30 ++- src/pstaff.cc | 8 +- src/qlp.cc | 2 +- src/qlpsolve.cc | 28 +-- src/register.cc | 64 +++---- src/request.cc | 35 ++-- src/rhythmstaff.cc | 47 ----- src/sccol.cc | 1 + src/score.cc | 18 +- src/scriptdef.cc | 2 +- src/scriptreg.cc | 69 +++++++ src/simpleprint.cc | 110 ----------- src/simplestaff.cc | 85 --------- src/simplewalker.cc | 344 ---------------------------------- src/slur.cc | 20 +- src/slurreg.cc | 91 +++++++++ src/sourcefile.cc | 23 ++- src/spanner.cc | 1 + src/staff.cc | 32 ++-- src/staffline.cc | 11 +- src/staffsym.cc | 46 +++++ src/staffwalker.cc | 8 +- src/stcol.cc | 7 +- src/stembeamreg.cc | 153 +++++++++++++++ src/texbeam.cc | 14 +- src/texslur.cc | 48 ++--- src/textreg.cc | 53 ++++++ src/textspanner.cc | 11 +- src/tstream.cc | 2 +- src/voice.cc | 2 +- src/voicegroup.cc | 70 ++++--- src/voiceregs.cc | 164 +++------------- src/wordwrap.cc | 6 +- 189 files changed, 2108 insertions(+), 2706 deletions(-) create mode 100644 hdr/complexcolumn.hh create mode 100644 hdr/headreg.hh delete mode 100644 hdr/linepstaff.hh create mode 100644 hdr/localkeyreg.hh delete mode 100644 hdr/melodicstaff.hh delete mode 100644 hdr/rhythmstaff.hh create mode 100644 hdr/scriptreg.hh delete mode 100644 hdr/simplestaff.hh delete mode 100644 hdr/simplewalker.hh create mode 100644 hdr/slurreg.hh create mode 100644 hdr/staffsym.hh create mode 100644 hdr/stembeamreg.hh create mode 100644 hdr/textreg.hh create mode 100644 src/headreg.cc delete mode 100644 src/linepstaff.cc create mode 100644 src/localkeyreg.cc delete mode 100644 src/melodicstaff.cc delete mode 100644 src/rhythmstaff.cc create mode 100644 src/scriptreg.cc delete mode 100644 src/simpleprint.cc delete mode 100644 src/simplestaff.cc delete mode 100644 src/simplewalker.cc create mode 100644 src/slurreg.cc create mode 100644 src/staffsym.cc create mode 100644 src/stembeamreg.cc create mode 100644 src/textreg.cc diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 460935f859..2b86193338 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -40,23 +40,23 @@ the C is a Hungarian notation postfix for $C$. =head2 COMMENTS The source is commented in the DOC++ style. Check out doc++ at -F +http://www.zib.de/Visual/software/doc++/index.html /// short description class Class { - /// - Data data_member_; + /// short description /** - .. + long description */ + Data data_member_; /****************/ /// short memo - member(); /** long doco of member() */ + member(); }; /** Class documentation. diff --git a/Documentation/README.pod b/Documentation/README.pod index 973bab25c1..d8f0d1eae7 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -25,7 +25,7 @@ customizable notenames, customizable fontset multiple staffs in one score =item * -multiple stafftypes (melodic, rhythmic) +multiple stafftypes (melodic, rhythmic) [broken from pl28 on] =item * beams, slurs, chords, super/subscripts (accents and text), @@ -43,7 +43,6 @@ a different file. clef changes, meter changes, cadenza-mode, declaring markings in the music, repeat bars - =back =head1 DESIGN CONSIDERATIONS @@ -258,9 +257,8 @@ coding C++ =head1 EXAMPLES -At this time, LilyPond is only suited for Quick & Dirty jobs (the -output quality of multistaff material still is too low). If you're not -discouraged; this is what I type in my xterm: +At this time, LilyPond output looks nice, but is not of production +quality. If you're not discouraged; this is what I type in my xterm: lilypond someinput.ly tex test diff --git a/Documentation/error.pod b/Documentation/error.pod index 1888beaf98..0a73c5b627 100644 --- a/Documentation/error.pod +++ b/Documentation/error.pod @@ -10,6 +10,8 @@ A correctly parsed F does not guarantuee output. A lot (most) of the checking is done B parsing (some checks even are done after the break calc!); I'm sorry. +[outdated] + The parser's job is to construct appropriate objects. It will B detect parse errors. diff --git a/Documentation/lilyinput.pod b/Documentation/lilyinput.pod index 6e08669071..dfdd597948 100644 --- a/Documentation/lilyinput.pod +++ b/Documentation/lilyinput.pod @@ -39,7 +39,7 @@ than in "command" mode, eg, identifier = score { .. } -So you have to signal that to the tokenizer. This is done with +So you have to signal this to the tokenizer. This is done with '$'. '$' is a delimiter, which used by the tokenizer only. The same goes for lyrics, it has a '@' delimiter. diff --git a/Makefile b/Makefile index 10ad8c1642..7af694d132 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) -.PHONY: clean +.PHONY: clean docxx clean: rm -f $(exe) $(DOCDIR)/* core $(obs) $(ALLDEPS) @@ -30,9 +30,8 @@ doc: $(MAKE) -C Documentation doc # doc++ documentation of classes -docpp: $(progdocs) - -mkdir $(DOCDIR) - doc++ -p -I -d $(DOCDIR) $^ +docxx: $(progdocs) + doc++ -p -d $(DOCDIR) $^ $(OBJECTDIR)/%.o: $(CCDIR)/%.cc $(DODEP)\ diff --git a/NEWS b/NEWS index 932246fcb9..0646a2661d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,27 @@ +pl 30 + +Features + - better multivoice spacing + - move rest in multivoice staff + - errors in TeX output now warnings + - progress indicator + - music processing speedup. +Internal + - make spanner for staffsym; scrap Line_pstaff + - scrap simplestaff (Rhythmic_staff temporarily disabled) + - docxx 3.0 format comments + - split register source files + - hardcoded dimensions compile time + - Lookup::tex_hairpin +Bugs + - non G-clef clefs + - script junking (2x) + - empty files + - beam::center (plet position!) + pl 29 - - multiplatform Makefile - - context errors: bugfixes + - multiplatform Makefile (JN) + - context errors: bugfixes (JN) pl 28 @@ -9,8 +30,8 @@ Internal Doc - Request_register Bugfix - - Script.cc : float exception - - Request::Request(Request) copying of definition pointer + - Script.cc : float exception (MB) + - Request::Request(Request) copying of definition pointer (JN) - cleaned dependencies for broken spanners - stupid typo in Staff_elem::post_processing() - init of hpos in PCol::PCol diff --git a/Sources.make b/Sources.make index c40a11e55f..e7e7a22782 100644 --- a/Sources.make +++ b/Sources.make @@ -2,47 +2,55 @@ # sourcefiles to be shipped. Also for dependencies hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\ - colhpos.hh command.hh complexwalker.hh complexstaff.hh\ + colhpos.hh command.hh complexcolumn.hh \ + complexwalker.hh complexstaff.hh\ const.hh debug.hh dimen.hh directionalspanner.hh\ - getcommand.hh glob.hh grouping.hh idealspacing.hh\ + getcommand.hh glob.hh grouping.hh headreg.hh idealspacing.hh\ identifier.hh identparent.hh inputcommand.hh inputcommands.hh\ inputmusic.hh inputscore.hh inputstaff.hh item.hh key.hh keyitem.hh\ - keyword.hh leastsquares.hh lexer.hh linespace.hh linepstaff.hh\ - localkeyitem.hh lookup.hh \ + keyword.hh leastsquares.hh lexer.hh linespace.hh \ + localkeyitem.hh localkeyreg.hh lookup.hh \ lyriccolumn.hh lyricitem.hh lyricstaff.hh lyricwalker.hh\ - main.hh melodicstaff.hh meter.hh misc.hh\ + main.hh meter.hh misc.hh\ molecule.hh moment.hh notehead.hh notename.hh offset.hh paper.hh\ parseconstruct.hh pcol.hh proto.hh pscore.hh pstaff.hh qlp.hh\ - qlpsolve.hh register.hh request.hh rest.hh rhythmstaff.hh\ + qlpsolve.hh register.hh request.hh rest.hh \ sccol.hh score.hh\ - scoreline.hh script.hh scriptdef.hh simplestaff.hh simplewalker.hh\ - slur.hh source.hh sourcefile.hh spanner.hh staff.hh staffcommands.hh\ - staffelem.hh staffline.hh\ + scoreline.hh script.hh scriptdef.hh scriptreg.hh \ + slur.hh slurreg.hh source.hh sourcefile.hh\ + spanner.hh staff.hh staffcommands.hh\ + staffelem.hh staffline.hh staffsym.hh stembeamreg.hh\ stcol.hh stem.hh staffwalker.hh symbol.hh symtable.hh\ - tex.hh textdef.hh\ - textitem.hh textspanner.hh timedescription.hh tstream.hh voice.hh\ + tex.hh textdef.hh \ + textitem.hh textreg.hh textspanner.hh timedescription.hh \ + tstream.hh voice.hh\ voicegroup.hh mycc=bar.cc beam.cc boxes.cc break.cc calcideal.cc clef.cc\ - clefitem.cc colhpos.cc command.cc complexstaff.cc complexwalker.cc \ - complexprint.cc debug.cc dimen.cc\ + clefitem.cc colhpos.cc command.cc\ + complexstaff.cc complexwalker.cc \ + complexprint.cc debug.cc dimen.cc\ directionalspanner.cc\ - getcommands.cc grouping.cc groupregs.cc idealspacing.cc identifier.cc\ + getcommands.cc grouping.cc groupregs.cc headreg.cc\ + idealspacing.cc identifier.cc\ inputcommand.cc inputcommands.cc inputmusic.cc inputscore.cc\ inputstaff.cc item.cc key.cc keyitem.cc keyword.cc\ - leastsquares.cc lexerinit.cc linespace.cc linepstaff.cc\ - localkeyitem.cc lookup.cc\ + leastsquares.cc lexerinit.cc linespace.cc \ + localkeyitem.cc localkeyreg.cc lookup.cc\ lyriccolumn.cc lyricitem.cc lyricstaff.cc lyricwalker.cc\ - main.cc melodicstaff.cc meter.cc\ - misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\ + main.cc meter.cc\ + misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\ paper.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ - register.cc request.cc rest.cc rhythmstaff.cc sccol.cc score.cc\ - scoreline.cc scores.cc script.cc scriptdef.cc simpleprint.cc\ - simplestaff.cc simplewalker.cc slur.cc source.cc sourcefile.cc\ + register.cc request.cc rest.cc sccol.cc score.cc\ + scoreline.cc scores.cc script.cc scriptdef.cc scriptreg.cc \ + slur.cc\ + slurreg.cc source.cc sourcefile.cc\ spanner.cc staff.cc\ - staffcommands.cc staffelem.cc staffline.cc stcol.cc stem.cc\ + staffcommands.cc staffelem.cc staffline.cc staffsym.cc\ + stembeamreg.cc\ + stcol.cc stem.cc\ staffwalker.cc symbol.cc symtable.cc tex.cc texbeam.cc\ - texslur.cc textdef.cc textitem.cc textspanner.cc\ + texslur.cc textdef.cc textitem.cc textreg.cc textspanner.cc\ timedescription.cc tstream.cc voice.cc voiceregs.cc voicegroup.cc\ warn.cc windhoos-suck-suck-suck-thank-you-cygnus.cc wordwrap.cc\ template1.cc template2.cc template3.cc template4.cc\ diff --git a/TODO b/TODO index a931f47d05..44068657a7 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,19 @@ - - ./input/standchen.ly.rej - - ./src/stem.cc.rej - - * scrap simplestaff +This is an assorted collection of stuff that will be done, might be +done, or is an idea that I want to think about BUGS * first clef isn't printed - * accidental placement for other clefs + * key undo + + * key print if SEVERELY LACKING: * grace notes + * dynamics (hairpins) + INPUTLANGUAGE * lose the $ and @ ? @@ -26,12 +26,11 @@ INPUTLANGUAGE SMALLISH PROJECTS + * binsearch for notenames + * stafftypes: voice names/ instrument names. - * make spanner for staffsym - - * Lookup::tex_glissando, Lookup::tex_bracket, - Lookup::tex_cresc, Lookup::tex_decresc (use texbeam.cc as an + * Lookup::tex_glissando, Lookup::tex_bracket, (use texbeam.cc as an example.) * Decent TeX titledefs (\tempo, \metron, etc. ) @@ -64,11 +63,12 @@ DOC * beam generation. - * all errors FUTURE + * warning: beam(): Beam too narrow: beam gen not per stem + * put scripts on barcommands * glissando @@ -95,9 +95,6 @@ IDEAS * itemcolumns - * dependencies: -> implement children more elegantly. Handle - spanner with broken deps. - * use an embedded language: scheme, lisp, S-lang, Perl, ? * y -dims in internote? @@ -113,7 +110,7 @@ IDEAS * Spacing_request for manually adjusting spacing - * Staff_group. + * Staff_group, Score_request_register. * SHIT: meters/bars should be aligned, which is difficult if we get different keychanges in different staffs. @@ -123,3 +120,5 @@ IDEAS * MusixTeX output possible? * PostScript output (esp. Beams, Slurs, etc) + + * caching breakpoints \ No newline at end of file diff --git a/Variables.make b/Variables.make index c53033674c..38280146fd 100644 --- a/Variables.make +++ b/Variables.make @@ -1,8 +1,12 @@ +# -*-make-*- + # version info MAJVER=0 MINVER=0 -PATCHLEVEL=29 +PATCHLEVEL=30 + include Site.make + #### #### USER CONFIGURABLE #### @@ -23,7 +27,8 @@ EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes # ElectricFence is a memory debugger which uses the # VM hardware to trap malloc/free errors. # -#EXTRALIB+=-lefence + +EXTRALIB= #+=-lefence #### #### END USER CONFIGURABLE part. @@ -47,18 +52,13 @@ CXXVER=`$(CXX) --version` # directories TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) + OBJECTDIR=objects HEADERDIR=hdr CCDIR=src INITDIR=init DEPDIR=deps INPUTDIR=input -#vpath %.cc $(CCDIR) -#vpath %.hh $(HEADERDIR) -#vpath %.y $(CCDIR) -#vpath %.l $(CCDIR) -#vpath %.o $(OBJECTDIR) -#vpath %.dep $(DEPDIR) # # @@ -71,11 +71,12 @@ obs=$(addprefix $(OBJECTDIR)/,$(cc:.cc=.o)) ALLDEPS=$(addprefix $(DEPDIR)/,$(cc:.cc=.dep)) STABLEOBS=$(addprefix $(OBJECTDIR)/,$(stablecc:.cc=.o)) HEADERS=$(addprefix $(HEADERDIR)/,$(hdr)) -progdocs=$(HEADERS) $(addprefix $(CCDIR)/, $(mycc)) +progdocs=$(HEADERS) #$(CCSOURCE) + #dist .EXPORT_ALL_VARIABLES: -DOCDIR=docdir +DOCDIR=docxx PACKAGENAME=lilypond DNAME=$(PACKAGENAME)-$(VERSION) diff --git a/clearlily b/clearlily index 40b79c3aaa..983454dad3 100755 --- a/clearlily +++ b/clearlily @@ -1,4 +1,8 @@ #!/bin/sh # unclobber current dir. -rm -v *.aux *.log `grep -li "^% Creator: LilyPond" *.out *.uit` *.orig *~ +rm -vf *.aux *.log `grep -li "^% Creator: LilyPond" *.out` *.orig *~ + +# docxx mess +rm -vf *.class HIER*.html dxxgifs.tex gifs.db icon?.gif logo.gif down.gif \ + aindex.html index.html diff --git a/configure b/configure index 6ecf9b1104..2857ad2aa4 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ PREFIX=${PREFIX:-.} echo using PREFIX=$PREFIX -NEEDFLOWERVER=1.0.25 +NEEDFLOWERVER=1.0.26 flowertar=flower-$NEEDFLOWERVER here=`pwd` cd .. diff --git a/flower/Makefile b/flower/Makefile index 1b8b0013f8..9c69264115 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -17,6 +17,10 @@ realclean: clean fversion.hh: Variables.make make_version make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) "$(CXX) `$(CXXVER)`" > $@ +.PHONY: docxx +docxx: $(hh) $(cc) $(templatecc) $(inl) + -mkdir docxx + doc++ -p -d docxx $(hh) $(cc) $(templatecc) $(inl) dist: -mkdir $(DDIR) diff --git a/flower/NEWS b/flower/NEWS index aac5b758ff..6f4fd129cd 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,9 +1,14 @@ +pl 26 + - docxx 3.0 pl 25 - merge sstack and Array + pl 24 - small fix in vector print + pl 23 - win32 patches (JN) + pl 22 - Array::add -> Array::push \ No newline at end of file diff --git a/flower/Variables.make b/flower/Variables.make index 90d8cc8dc6..0dc6c79705 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,6 +1,7 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=25 +PATCHLEVEL=26 + PACKAGENAME=flower #PROFILEFLAG=-pg diff --git a/flower/assoc.hh b/flower/assoc.hh index 4e0594519f..154a0242a2 100644 --- a/flower/assoc.hh +++ b/flower/assoc.hh @@ -12,11 +12,13 @@ struct Assoc_ent_ { }; /// hungarian: map +/** mindblowingly stupid Associative array implementation + */ template struct Assoc { Array< Assoc_ent_ > arr; - /****************/ + /* ************** */ int find(K key) const { for (int i = 0; i < arr.size(); i++) { @@ -60,7 +62,7 @@ public: int i = find_creat(key); arr[i].val = val; } - /** + /* should create "set" template */ V& operator[](K key) { @@ -71,7 +73,5 @@ public: return arr[find(key)].val; } }; -/** mindblowingly stupid Associative array implementation - */ #endif diff --git a/flower/associter.hh b/flower/associter.hh index bb312b8e9e..34b88df22d 100644 --- a/flower/associter.hh +++ b/flower/associter.hh @@ -35,8 +35,5 @@ struct Assoc_iter { K key() { return assoc_.arr[i].key; } V &val() { return assoc_.arr[i].val; } }; -/* - Iterator - */ #endif diff --git a/flower/choleski.hh b/flower/choleski.hh index c6cb91723b..14cf5e2326 100644 --- a/flower/choleski.hh +++ b/flower/choleski.hh @@ -3,6 +3,13 @@ #include "matrix.hh" +/** + structure for using the LU decomposition of a positive definite . + + #P# is split into + + LD transpose(L) + */ struct Choleski_decomposition { /// lower triangle of Choleski decomposition @@ -11,36 +18,27 @@ struct Choleski_decomposition { /// diagonal Vector D; ///Create decomposition of P - Choleski_decomposition(Matrix P); /** PRE P needs to be symmetric positive definite */ + Choleski_decomposition(Matrix P); Vector solve(Vector rhs) const; - Vector operator * (Vector rhs) const { return solve (rhs); } - /** + /** solve Px = rhs */ - - Matrix inverse() const; - /** +Vector operator * (Vector rhs) const { return solve (rhs); } + /** return the inverse of the matrix P. */ - Matrix original() const; + Matrix inverse() const; /** return P, calc'ed from L and D */ + Matrix original() const; + }; -/** - structure for using the LU decomposition of a positive definite . - - #P# is split into - - LD transpose(L) - */ - - #endif diff --git a/flower/compare.hh b/flower/compare.hh index f0e886e539..30a1998ad3 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -29,6 +29,10 @@ operator op(type t1, type t2)\ #endif /// handy notations for a signed comparison +/** + make the operators{<,<=,==,>=,>} and the MAX and MIN of two. + Please fill a & in the type argument if necessary. + */ #define template_instantiate_compare(type, function, prefix) \ prefix one_operator(type, function, >)\ prefix one_operator(type, function, >=)\ @@ -41,10 +45,6 @@ prefix inline type max(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ \ prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */ - /** - make the operators{<,<=,==,>=,>} and the MAX and MIN of two. - Please fill a & in the type argument if necessary. - */ diff --git a/flower/cursor.hh b/flower/cursor.hh index 1484770688..d8274d2493 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -6,14 +6,22 @@ #include "link.hh" template class List; -/// +/// iterator to List +/** + add and insert extend the list + items are always stored as copies in List, but: + List : copies of String stored + List : copies of String* stored! + + the operations add and insert actually delegate the work to List class. + */ template class Cursor { public: - Cursor( const List& list, Link* pointer = 0 ); /** this isn't true, actually, #list# surely isn't const, but I get tired of the warning messages. */ + Cursor( const List& list, Link* pointer = 0 ); Cursor( const Cursor& cursor ); @@ -49,7 +57,6 @@ class Cursor bool backward(); /// put (copy) after me in List - void add( const T& thing ); /** analogously to editor. ok() interpreted as at end of line. @@ -61,9 +68,9 @@ class Cursor cursor points to same object, cursor.next() is newly added object. */ + void add( const T& thing ); /// put (copy) before me in List - void insert( const T& thing ); /** analogously to editor. ok() interpreted as at begin of line. @@ -76,6 +83,7 @@ class Cursor is newly inserted object. */ + void insert( const T& thing ); /// void backspace(); @@ -90,14 +98,6 @@ private: List& list_; Link* pointer_; }; -/** - add and insert extend the list - items are always stored as copies in List, but: - List : copies of String stored - List : copies of String* stored! - - the operations add and insert actually delegate the work to List class. - */ /* diff --git a/flower/cursor.inl b/flower/cursor.inl index 278d865bff..54d3703e60 100644 --- a/flower/cursor.inl +++ b/flower/cursor.inl @@ -2,7 +2,7 @@ #ifndef CURSOR_INL #define CURSOR_INL #include -//#include "list.hh" + template inline diff --git a/flower/dataf.cc b/flower/dataf.cc index d050e278c5..e3c42ad45f 100644 --- a/flower/dataf.cc +++ b/flower/dataf.cc @@ -79,6 +79,9 @@ Data_file::get_word() } /// get a char. +/** + Only class member who uses text_file::get + */ char Data_file::data_get() { char c = get(); @@ -91,9 +94,6 @@ Data_file::data_get() { return c; } -/** - Only class member who uses text_file::get - */ /// read line, gobble '\n' String Data_file::get_line() diff --git a/flower/dstream.cc b/flower/dstream.cc index 02b218d3cf..b045a0f455 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -58,7 +58,9 @@ Dstream::silence(String s) return false; return (*silent)[s]; } -/// + +/** only output possibility. Delegates all conversion to String class. + */ Dstream & Dstream::operator<<(String s) { @@ -93,8 +95,6 @@ Dstream::operator<<(String s) return *this; } -/** only output possibility. Delegates all conversion to String class. - */ Dstream::Dstream(ostream *r, const char * cfg_nm ) { diff --git a/flower/dstream.hh b/flower/dstream.hh index e38f30128f..0143eb0510 100644 --- a/flower/dstream.hh +++ b/flower/dstream.hh @@ -11,6 +11,20 @@ template struct Assoc; /// debug stream + /** + a class for providing debug output of nested structures, + with indents according to \{\}()[]. + + One can turn on and off specific messages using the Assoc silent. + This can be done automatically: + + #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__) + + DEBUG << "a message\n"; + + Init for the class names which should be silent can be given in a rc file. + + */ class Dstream { ostream *os; @@ -23,29 +37,15 @@ public: bool silence(String); - Dstream(ostream *r, const char * rcfile); /** if rcfile == 0, then do not read any rc file */ + Dstream(ostream *r, const char * rcfile); virtual ~Dstream(); Dstream &identify_as(String s); Dstream &operator << (String s); }; - /** - a class for providing debug output of nested structures, - with indents according to \{\}()[]. - - One can turn on and off specific messages using the Assoc silent. - This can be done automatically: - - #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__) - - DEBUG << "a message\n"; - - Init for the class names which should be silent can be given in a rc file. - - */ #endif diff --git a/flower/interval.hh b/flower/interval.hh index acf437ad0a..9cff84fb3c 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -13,11 +13,15 @@ /// a T interval +/** + this represents the closed interval [left,right]. + No invariants. T must be a totally ordered ring + */ template struct Interval_t { T left, right; - /****************/ + /* ************** */ T center() { return (left + right) / T(2);} void translate(T t) { @@ -43,11 +47,11 @@ struct Interval_t { T max()const { return right;} T min()const{ return left; } T &min(){ return left; } - void unite(Interval_t h); /** PRE *this and h are comparable */ + void unite(Interval_t h); void intersect(Interval_t h); T length() const; @@ -68,10 +72,6 @@ struct Interval_t { String str() const; bool elt_q(T r); }; -/** - this represents the closed interval [left,right]. - No invariants. T must be a totally ordered ring - */ /// partial ordering template diff --git a/flower/lgetopt.hh b/flower/lgetopt.hh index 0ff3e08419..67deb700bc 100644 --- a/flower/lgetopt.hh +++ b/flower/lgetopt.hh @@ -15,15 +15,16 @@ struct long_option_init { }; -/// +/// C++ for version of long_getopt. +/** For processing GNU style command line arguments. No pointer + (return values, arguments) contents are copied. */ class Getopt_long { public: - /// + /** errorcodes: no error, argument expected, no argument expected, + unknown option, illegal argument (eg. int expected). */ enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION, E_ILLEGALARG } ; - /** errorcodes: no error, argument expected, no argument expected, - unknown option, illegal argument (eg. int expected). */ private: @@ -48,12 +49,12 @@ private: void report(Errorcod c); public: /// what to do with errors - void seterror(ostream *os); /** report messages on #*os#, and abort. if #os# is null, then do not report nor abort, just set #error# */ + void seterror(ostream *os); /// argument. Set to 0 if not present char* optarg; @@ -73,18 +74,14 @@ public: Getopt_long(int c, char **v, long_option_init *lo); /// get the next option - long_option_init *operator()(); /** - RETURN: pointer to next option found. + @return pointer to next option found. 0 if error occurred, or next argument is no option. */ + long_option_init *operator()(); char *current_arg(); char * get_next_arg(); Errorcod error; }; -/** - C++ for version of long_getopt. For processing GNU style command line arguments. - No pointer (return values, arguments) contents are copied. - */ #endif diff --git a/flower/list.hh b/flower/list.hh index 4a4aab2f5b..4f3c1aa825 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -6,6 +6,27 @@ template class Cursor; template class Link; /// all-purpose doubly linked list +/** + a doubly linked list; + List can be seen as all items written down on paper, + from top to bottom + + class Cursor is used to extend List + + items are always stored as copies in List, but: + #List# : copies of #String# stored + #List# : copies of #String*# stored! + (do not use, use \Ref{PointerList} ## instead.) + + {\bf note:} + retrieving "invalid" cursors, i.e. + #top()/bottom()# from empty list, #find()# without success, + results in a nonvalid Cursor ( #!ok()# ) + + + INVARIANTEN! +*/ + template class List { @@ -30,8 +51,7 @@ class List void concatenate(List const &s); /// make *this empty - void set_empty(); - /** + /** POST: size == 0 @@ -39,15 +59,14 @@ class List WARNING: contents lost, and not deleted. */ - + void set_empty(); + /// add after after_me void add( const T& thing, Cursor &after_me ); /// put thing before #before_me# void insert( const T& thing, Cursor &before_me ); - - void remove( Cursor me ); - /** Remove link pointed to by me. Destructor of contents called + /** Remove link pointed to by me. Destructor of contents called (nop for pointers) POST @@ -56,34 +75,15 @@ class List WARNING: do not use #me# after calling */ + void remove( Cursor me ); + - /****************/ + /* ************** */ int size_; Link* top_; Link* bottom_; }; -/** - a doubly linked list; - List can be seen as all items written down on paper, - from top to bottom - - class Cursor is used to extend List - - items are always stored as copies in List, but: - #List# : copies of #String# stored - #List# : copies of #String*# stored! - (do not use, use \Ref{PointerList} ## instead.) - - {\bf note:} - retrieving "invalid" cursors, i.e. - #top()/bottom()# from empty list, #find()# without success, - results in a nonvalid Cursor ( #!ok()# ) - - - INVARIANTEN! -*/ - #include "list.inl" #include "cursor.hh" diff --git a/flower/matrix.hh b/flower/matrix.hh index 5283dc71ef..73a9f0487e 100644 --- a/flower/matrix.hh +++ b/flower/matrix.hh @@ -6,6 +6,16 @@ #include "vector.hh" /// a Real matrix +/** This is a class for a nonsquare block of #Real#s. The + implementation of sparse matrices is done in the appropriate #smat# + class. Matrix only does the mathematical actions (adding, + multiplying, etc.) + + + TODO + implement ref counting? */ + + class Matrix { virtual_smat *dat; @@ -15,11 +25,11 @@ public: int rows() const { return dat->rows(); } /// return the size of a matrix - int dim() const; /** - PRE + @pre the matrix needs to be square. */ + int dim() const; // Matrix() { dat = 0; } ~Matrix() { delete dat; } @@ -40,7 +50,6 @@ public: void operator/=(Real a) { (*this) *= 1/a; } /// add a row - void insert_row(Vector v,int k); /** add a row to the matrix before row k @@ -48,25 +57,26 @@ public: v.dim() == cols() 0 <= k <= rows() */ + void insert_row(Vector v,int k); /// - void delete_row(int k) { dat->delete_row(k); } /** delete a row from this matrix. PRE 0 <= k < rows(); */ + void delete_row(int k) { dat->delete_row(k); } void delete_column(int k) { dat->delete_column(k); } - /// - Matrix(int n); + /** square n matrix, initialised to null */ - /// - Matrix(int n, int m); + Matrix(int n); + /** n x m matrix, init to 0 */ + Matrix(int n, int m); Matrix(const Matrix &m); /// dyadic product: v * w.transpose @@ -98,18 +108,18 @@ public: Real norm() const; /// swap - void swap_columns(int c1, int c2); /** PRE 0 <= c1,c2 < cols() */ + void swap_columns(int c1, int c2); /// swap - void swap_rows(int c1, int c2); /** PRE 0 <= c1,c2 < rows() */ + void swap_rows(int c1, int c2); Vector row(int ) const; @@ -119,16 +129,6 @@ public: void print() const; }; -/** This is a class for a nonsquare block of #Real#s. The - implementation of sparse matrices is done in the appropriate #smat# - class. Matrix only does the mathematical actions (adding, - multiplying, etc.) - - - TODO - implement ref counting? */ - - inline Vector operator *(Vector &v, const Matrix& m) { return m.left_multiply(v); } Matrix operator *(const Matrix& m1,const Matrix &m2); diff --git a/flower/path.cc b/flower/path.cc index 2fd7eea3cb..2737d1cd15 100644 --- a/flower/path.cc +++ b/flower/path.cc @@ -8,7 +8,10 @@ #define PATHSEP '/' #endif - +/** + INPUT: path the original full filename + OUTPUT: 4 components of the path. They can be empty +*/ void split_path(String path, String &drive, String &dirs, String &filebase, String &extension) @@ -45,11 +48,6 @@ split_path(String path, filebase = path; } } -/** - INPUT: path the original full filename - OUTPUT: 4 components of the path. They can be empty -*/ - File_path::File_path(String pref) { @@ -58,7 +56,11 @@ File_path::File_path(String pref) } -/// +///find a file +/** + It will search in the current dir, in the construction-arg, and + in any other added path, in this order. + */ String File_path::find(String nm) { @@ -75,7 +77,3 @@ File_path::find(String nm) } return ""; } -/** - It will search in the current dir, in the construction-arg, and - in any other added path, in this order. - */ diff --git a/flower/path.hh b/flower/path.hh index 781e86f970..4a36730dcd 100644 --- a/flower/path.hh +++ b/flower/path.hh @@ -5,6 +5,15 @@ /// searching directory for file. +/** + + Abstraction of PATH variable. An interface for searching input files. + Search a number of dirs for a file. + + Should use kpathsea? + +*/ + class File_path : private Array { public: @@ -18,15 +27,6 @@ public: Array::push; void add(String str) { push(str); } }; -/** - - Abstraction of PATH variable. An interface for searching input files. - Search a number of dirs for a file. - - Should use kpathsea? - -*/ - /// split path into its components void split_path(String path, String &drive, String &dirs, String &filebase, String &extension); diff --git a/flower/pcursor.hh b/flower/pcursor.hh index a6b99c9097..8498aa9e0d 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -10,6 +10,11 @@ /// cursor to go with PointerList +/** + don't create PointerList's. + This cursor is just an interface class for Cursor. It takes care of the + appropriate type casts + */ template struct PCursor : private Cursor { friend class IPointerList; @@ -53,11 +58,6 @@ public: return Cursor::compare(a,b); } }; -/** - 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 f5913c1299..61b51d97e3 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -10,6 +10,11 @@ #include "list.hh" /// Use for list of pointers, e.g. PointerList. +/** + This class does no deletion of the pointers, but it knows how to + copy itself (shallow copy). We could have derived it from List, + but this design saves a lot of code dup; for all PointerLists in the + program only one parent List is instantiated. */ template class PointerList : public List { @@ -24,19 +29,8 @@ class PointerList : public List void concatenate(PointerList const &s) { List::concatenate(s); } PointerList() {} }; -/** - This class does no deletion of the pointers, but it knows how to - copy itself (shallow copy). We could have derived it from List, - but this design saves a lot of code dup; for all PointerLists in the - program only one parent List is instantiated. */ /// pl. which deletes pointers given to it. -template -struct IPointerList : public PointerList { - IPointerList(const IPointerList&) { set_empty(); } - IPointerList() { } - ~IPointerList(); -}; /** NOTE: @@ -48,6 +42,12 @@ struct IPointerList : public PointerList { You have to copy this yourself, or use the macro PointerList__copy */ +template +struct IPointerList : public PointerList { + IPointerList(const IPointerList&) { set_empty(); } + IPointerList() { } + ~IPointerList(); +}; #define IPointerList__copy(T, to, from, op) \ for (PCursor _pc_(from); _pc_.ok(); _pc_++)\ diff --git a/flower/scalar.hh b/flower/scalar.hh index bff21618c6..0213a92f0d 100644 --- a/flower/scalar.hh +++ b/flower/scalar.hh @@ -24,9 +24,9 @@ struct Scalar : public String { operator Real(); operator int(); /// - operator bool() const; /** perl -like string to bool conversion */ + operator bool() const; }; diff --git a/flower/smat.cc b/flower/smat.cc index f2143507b6..d89e3bc285 100644 --- a/flower/smat.cc +++ b/flower/smat.cc @@ -182,7 +182,7 @@ Full_storage::clone() { return new Full_storage(*this); } -/****************************************************************/ + virtual_smat * virtual_smat::get_full(int n, int m) diff --git a/flower/string.hh b/flower/string.hh index 7ed274979d..e58f614699 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -20,6 +20,30 @@ #include "stringutil.hh" /// the smart string class. +/** + + Intuitive string class. provides + + ref counting through #String_handle# + + conversion from bool, int, double, char *, char. + + conversion to int, upcase, downcase + + + printable. + + indexing (pos, posAny, lastPos) + + cutting (left, right, mid) + + concat (+=, +) + + signed comparison (<, >, ==, etc) + + No operator[] is provided, since this would be enormously slow. If needed, + convert to const char *. +*/ class String { protected: @@ -27,8 +51,8 @@ protected: public: /// init to "" - String() { } /** needed because other constructors are provided.*/ + String() { } String(Rational); /// String s = "abc"; String( const char* source ); @@ -95,11 +119,11 @@ public: int lastPos( const char* string ) const; /// index of leftmost c - int pos(char c ) const; /** RETURN: 0 if not found, else index + 1 */ + int pos(char c ) const; int pos(const char* string ) const; int posAny(const char* string ) const; @@ -117,30 +141,6 @@ public: int len() const; }; -/** - - Intuitive string class. provides - - ref counting thru #String_handle# - - conversion from bool, int, double, char *, char. - - conversion to int, upcase, downcase - - - printable. - - indexing (pos, posAny, lastPos) - - cutting (left, right, mid) - - concat (+=, +) - - signed comparison (<, >, ==, etc) - - No operator[] is provided, since this would be enormously slow. If needed, - convert to const char *. -*/ #include "compare.hh" diff --git a/flower/stringutil.hh b/flower/stringutil.hh index d7f7081617..6a7feb126a 100644 --- a/flower/stringutil.hh +++ b/flower/stringutil.hh @@ -8,7 +8,12 @@ const INITIALMAX=8; class String_handle; + /// Internal String struct +/** + the data itself. Handles simple tasks (resizing, resetting) + */ + class StringData { // GNU malloc: storage overhead is 8 bytes anyway. @@ -43,6 +48,10 @@ friend class String_handle; } + /** POST: maxlen >= j. + IN: j, maximum stringlength. + contents thrown away. + */ void setmax(int j) { OKW(); if (j > maxlen) { @@ -54,11 +63,11 @@ friend class String_handle; length = 0; } } + /** POST: maxlen >= j. - IN: j, maximum stringlength. - contents thrown away. - */ - /// + IN: j, maximum stringlength. + contents are kept if it grows. + */ void remax(int j) { OKW(); if (j > maxlen) { @@ -70,10 +79,6 @@ friend class String_handle; // length = strlen(string); } } - /** POST: maxlen >= j. - IN: j, maximum stringlength. - contents are kept if it grows. - */ /// check if writeable. void OKW() { @@ -153,13 +158,13 @@ friend class String_handle; } }; -/** - the data itself. Handles simple tasks (resizing, resetting) - */ -/****************************************************************/ /// ref. counting for strings +/** + handles ref. counting, and provides a very thin + interface using char * + */ class String_handle { StringData* data; @@ -229,11 +234,6 @@ public: void trunc(int j) { copy(); data->trunc(j); } int len() const { return data->length; } }; -/** - handles ref. counting, and provides a very thin - interface using char * - */ - #ifdef NDEBUG #if (NDEBUG == BLONDE) diff --git a/flower/textdb.hh b/flower/textdb.hh index afb04f0725..cdc8898539 100644 --- a/flower/textdb.hh +++ b/flower/textdb.hh @@ -3,8 +3,7 @@ #include "textstr.hh" -/**: do "#" comments, read quote enclosed fields */ - +/** do "#" comments, read quote enclosed fields */ /// a "const" Array. Contents can't be changed. class Text_record : Array { @@ -28,6 +27,9 @@ public: Array::size; }; +/** + add a subrec/fieldsep/record separator + */ /// abstraction for a datafile class Text_db : private Data_file { @@ -50,8 +52,4 @@ public: } }; - -/** - add a subrec/fieldsep/record separator - */ #endif diff --git a/flower/textstr.hh b/flower/textstr.hh index c89f58cf8d..489682effd 100644 --- a/flower/textstr.hh +++ b/flower/textstr.hh @@ -1,3 +1,4 @@ + #ifndef TEXTSTR_HH #define TEXTSTR_HH @@ -7,13 +8,21 @@ #include "varray.hh" /// line counting input stream. +/** + a stream for textfiles. linecounting. Thin interface getchar and + ungetchar. (ungetc is unlimited) + + should protect get and unget against improper use +*/ + + class Text_stream { int line_no; // could just have used streams. FILE *f; - Array pushback; + Array pushback; String name; public: @@ -61,14 +70,6 @@ class Text_stream /// GNU format message. void message(String s); }; -/** - a stream for textfiles. linecounting. Thin interface getchar and - ungetchar. (ungetc is unlimited) - - should protect get and unget against improper use -*/ - - /// read a data file class Data_file : private Text_stream { diff --git a/flower/tvsmat.hh b/flower/tvsmat.hh index 32f981d2e9..847c650b48 100644 --- a/flower/tvsmat.hh +++ b/flower/tvsmat.hh @@ -3,6 +3,17 @@ #include "varray.hh" /// a matrix storage baseclass. +/** base class for interface with matrix storageclasses. There are no + iterators for matrixclasses, since matrices are (like arrays) + explicitly int-indexed. + + Iteration is provided by *_next, *_ok, which update and check both + index variables simultaneously. + + TODO + determine type of product matrix. + +*/ class virtual_smat { @@ -17,11 +28,11 @@ public: virtual int cols() const = 0; /// set the size. contents lost - virtual void set_size(int i, int j) = 0; /** PRE i >=0, j>=0 */ + virtual void set_size(int i, int j) = 0; /// set the size to square dimen. contents lost virtual void set_size(int i) = 0; @@ -29,8 +40,7 @@ public: PRE i>=0 */ - /// set the size to i - virtual void resize(int i, int j) = 0; + /// set the size to i,j /** keep contents. If enlarged contents unspecified @@ -39,18 +49,18 @@ public: i>=0, j>=0 */ + virtual void resize(int i, int j) = 0; /// set the size to square dimen. contents kept - virtual void resize(int i) = 0; /** Keep contents. If enlarged contents are unspecified PRE i>=0 */ + virtual void resize(int i) = 0; /// access an element - virtual Real& elem(int i,int j) = 0; /** access an element. @@ -58,6 +68,7 @@ public: in the 0-part of a sparse matrix. */ + virtual Real& elem(int i,int j) = 0; /// access a element, no modify virtual const Real& elem(int i, int j) const = 0; @@ -67,51 +78,50 @@ public: #endif /// add a row - virtual void insert_row(int k)=0; /** add a row to the matrix before row k. Contents of added row are unspecified 0 <= k <= rows() */ - + virtual void insert_row(int k)=0; + /// delete a row - virtual void delete_row(int k)=0; - /** + /** delete a row from this matrix. PRE 0 <= k < rows(); - */ + */virtual void delete_row(int k)=0; + virtual ~virtual_smat() { } virtual virtual_smat *clone()=0; /// is there a next? - virtual bool mult_ok(int i, int j) const=0; - /** + /** at end of matrix? when doing loop for(i=0; i *get_full(int n, int m); }; -/** base class for interface with matrix storageclasses. There are no - iterators for matrixclasses, since matrices are (like arrays) - explicitly int-indexed. - - Iteration is provided by *_next, *_ok, which update and check both - index variables simultaneously. - - TODO - determine type of product matrix. - -*/ #endif diff --git a/flower/varray.hh b/flower/varray.hh index 229fdf3c45..0daafb84f8 100644 --- a/flower/varray.hh +++ b/flower/varray.hh @@ -16,6 +16,15 @@ inline void arrcpy(T*dest, T*src, int count) { } ///scaleable array/stack template, for T with def ctor. +/** + + This template implements a scaleable vector. With (or without) range + checking. It may be flaky for objects with complicated con- and + destructors. The type T should have a default constructor. It is + best suited for simple types, such as int, double or String + + It uses stack terminology, (push, pop, top), and can be used as a stack. + */ template class Array { protected: @@ -166,14 +175,5 @@ public: return r; } }; -/** - - This template implements a scaleable vector. With (or without) range - checking. It may be flaky for objects with complicated con- and - destructors. The type T should have a default constructor. It is - best suited for simple types, such as int, double or String - - It uses stack terminology, (push, pop, top), and can be used as a stack. - */ #endif diff --git a/flower/vector.hh b/flower/vector.hh index c039d5ce89..266254dbb8 100644 --- a/flower/vector.hh +++ b/flower/vector.hh @@ -10,6 +10,9 @@ class String; void set_matrix_debug(Dstream&ds); /// a row of numbers +/** + a vector. Storage is handled in Array, Vector only does the mathematics. + */ class Vector { Array dat; public: @@ -75,9 +78,6 @@ public: /// set to j-th element of unit-base void set_unit(int j) ; }; -/** - a vector. Storage is handled in Array, Vector only does the mathematics. - */ inline Vector operator+(Vector a, Vector const &b) { diff --git a/flower/vsmat.hh b/flower/vsmat.hh index 3112ae9b25..8765cbfe94 100644 --- a/flower/vsmat.hh +++ b/flower/vsmat.hh @@ -17,12 +17,12 @@ public: virtual int cols() const = 0; /// set the size. contents lost - virtual void set_size(int i, int j) = 0; /** PRE i >=0, j>=0 */ + virtual void set_size(int i, int j) = 0; /// set the size to square dimen. contents lost virtual void set_size(int i) = 0; /** diff --git a/genheader b/genheader index 6e5b278ab3..de9e7bf1e3 100755 --- a/genheader +++ b/genheader @@ -1,22 +1,31 @@ -#!/bin/sh -def=`echo $1 | sed s/\\\./_/ | tr a-z A-Z` +#!/usr/bin/perl -w -cat << HERE -/* - $1 -- part of LilyPond +die "arg needed\n" if (!($#ARGV+1)); +my $fn = $ARGV[0]; +my $hh_q = ($fn =~ /hh$/ ); +my $MAILADRESS=$ENV{MAILADRESS}; +my @pw=(getpwuid($<)); +my $username=$pw[6]; +my $what="implement "; +$what = "declare " if ($hh_q); +my $headstr ="/* + $fn -- $what - (c) 1997 $USERNAME <$MAILADRESS> -*/ + source file of the LilyPond music typesetter -HERE + (c) 1997 $username <$MAILADRESS> +*/\n"; + +my $startdef= $fn; +$startdef =~ s/\./_/; +$startdef =~ tr/a-z/A-Z/; +my $terminatestr="\n"; +if ($hh_q) { + $headstr .= "\n\n#ifndef $startdef\n#define $startdef\n"; + $terminatestr .= "#endif // $startdef\n" +} + +print $headstr, $terminatestr; -if [ $1 != `basename .hh` ] -then -cat < stems; Real slope; Real left_pos; - /// dir: -1 below heads, +1 above heads. + - /****************/ + /* *************** */ const char * name() const; virtual Interval width()const; @@ -41,8 +43,6 @@ private: void solve_slope(); Molecule*brew_molecule_p()const; }; -/** 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/hdr/break.hh b/hdr/break.hh index 9ecb484e5b..7d17470228 100644 --- a/hdr/break.hh +++ b/hdr/break.hh @@ -14,7 +14,7 @@ struct Break_algorithm { PScore &pscore_; Real linelength; - /****************/ + /* *************** */ Break_algorithm(PScore&); diff --git a/hdr/clef.hh b/hdr/clef.hh index 2c56cb497e..7325c542a6 100644 --- a/hdr/clef.hh +++ b/hdr/clef.hh @@ -9,12 +9,15 @@ #include "scalar.hh" #include "varray.hh" -struct Clef { - int c0_pos; - String clef_type; +/// where is c-0 in the staff? +class Clef { + +public: + int c0_position_i_; + String clef_type_str_; Clef(); - void read(Array args); + void set_type(String); }; #endif // CLEF_HH diff --git a/hdr/clefitem.hh b/hdr/clefitem.hh index c07087e073..b7ea93caaa 100644 --- a/hdr/clefitem.hh +++ b/hdr/clefitem.hh @@ -17,7 +17,7 @@ struct Clef_item : Item { bool change; - /****************/ + /* *************** */ Clef_item(); void read(Clef); diff --git a/hdr/colhpos.hh b/hdr/colhpos.hh index d06657485f..5398417ab1 100644 --- a/hdr/colhpos.hh +++ b/hdr/colhpos.hh @@ -16,7 +16,7 @@ struct Col_hpositions { Array config; Real energy; - /****************/ + /* ************** */ void OK()const; Col_hpositions(); diff --git a/hdr/command.hh b/hdr/command.hh index d4dda9411c..2408ac0698 100644 --- a/hdr/command.hh +++ b/hdr/command.hh @@ -5,6 +5,7 @@ #include "varray.hh" #include "scalar.hh" +/// what kind of command? enum Commandcode { NOP, INTERPRET, @@ -13,24 +14,6 @@ enum Commandcode { }; /// set a nonrythmical symbol -struct Command { - Commandcode code; - - /// analogous to argv[] - Array args; - - /// - int priority; - /** in what order relative to other TYPESET commands (eg, bar - should precede meter). Highest priority first. */ - - /****************/ - - Command(); -// Command(Moment w); - bool isbreak()const; - void print() const; -}; /** A nonrhythmical "thing" in a staff is called a "command". @@ -81,5 +64,22 @@ struct Command { */ +struct Command { + Commandcode code; + + /// analogous to argv[] + Array args; + + + /** in what order relative to other TYPESET commands (eg, bar + should precede meter). Highest priority first. */ + int priority; + + /* *************** */ + + Command(); + bool isbreak()const; + void print() const; +}; #endif diff --git a/hdr/complexcolumn.hh b/hdr/complexcolumn.hh new file mode 100644 index 0000000000..50ad5fc8a0 --- /dev/null +++ b/hdr/complexcolumn.hh @@ -0,0 +1,35 @@ +/* + complexcolumn.hh -- declare Complex_column + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef COMPLEXCOLUMN_HH +#define COMPLEXCOLUMN_HH + +/// column of Complex_staff: store one request +struct Complex_column : Staff_column { + + Array first_l_arr_; + Array second_l_arr_; + + Complex_staff* staff_l_; + + /* *************** */ + + Slur_req *find_slur(Voice *); + + void typeset_item(Item *, int=1); + void typeset_item_directional(Item *, int dir, int=1); + Molecule *create_command_mol(Command *com); + + void take_request(Request *rq); + virtual void setup_requests(); + + Complex_column(Score_column*s,Complex_staff*rs); +}; + +#endif // COMPLEXCOLUMN_HH diff --git a/hdr/complexstaff.hh b/hdr/complexstaff.hh index 17d489be96..6c7dbdb18d 100644 --- a/hdr/complexstaff.hh +++ b/hdr/complexstaff.hh @@ -1,5 +1,5 @@ /* - complexstaff.hh -- part of LilyPond + complexstaff.hh -- declare Complex_staff (c) 1996,1997 Han-Wen Nienhuys */ @@ -12,36 +12,15 @@ #include "stcol.hh" #include "staff.hh" #include "staffwalker.hh" - -/// column of Complex_staff: store one request -struct Complex_column : Staff_column { - - Array first_l_arr_; - Array second_l_arr_; - - Complex_staff* staff_l_; - - /****************/ - - Slur_req *find_slur(Voice *); - - void typeset_item(Item *, int=1); - void typeset_item_directional(Item *, int dir, int=1); - Molecule *create_command_mol(Command *com); - - void take_request(Request *rq); - virtual void setup_requests(); - - Complex_column(Score_column*s,Complex_staff*rs); -}; +#include "complexcolumn.hh" /// Complex staff: one voicegroup at a time struct Complex_staff : Staff { /// indirection to the PStaff. - PStaff *theline_l_; + PStaff *pstaff_l_; - /****************/ + /* *************** */ Staff_column*create_col(Score_column*); virtual Item *get_TYPESET_item(Command*); virtual void set_output(PScore *); diff --git a/hdr/complexwalker.hh b/hdr/complexwalker.hh index fcdb84ef96..2ada9fe642 100644 --- a/hdr/complexwalker.hh +++ b/hdr/complexwalker.hh @@ -7,7 +7,6 @@ #ifndef COMPLEXWALKER_HH #define COMPLEXWALKER_HH -// this SUX #include "proto.hh" #include "grouping.hh" #include "voicegroup.hh" @@ -16,6 +15,7 @@ #include "key.hh" #include "clef.hh" #include "register.hh" +#include "localkeyreg.hh" struct Complex_walker: Staff_walker { Local_key local_key_; @@ -32,29 +32,27 @@ struct Complex_walker: Staff_walker { IPointerList voice_reg_list_; IPointerList group_reg_list_; - Assoc voice_group_map_; + Assoc voice_group_map_; Local_key_register local_key_reg_; Array announce_info_arr_; - /****************/ - void do_change_group(const Voice * v, String group_id_str); - - Voice_registers *find_voice_reg(Voice*v_l); + /* *************** */ + Voice_registers *find_voice_reg(Voice*v_l)const; Voice_registers *get_voice_reg(Voice*v_l); /// search and return. return 0 if not found. - Voice_group_registers *find_voice_group(Voice* v_l); + Voice_group_registers *find_voice_group(Voice* v_l)const; /// search. Create if necessary Voice_group_registers *get_voice_group(Voice* v_l); /// search and return. return 0 if not found - Voice_group_registers *find_voice_group(const char* id); + Voice_group_registers *find_voice_group(const char* id)const; /// Create if necessary Voice_group_registers *get_voice_group(const char*); + + Array get_voice_regs(Voice_group_registers *) const; void regs_process_requests(); - void do_announces(); - void try_request(Request*req); void typeset_element(Staff_elem *elem_p); void announce_element(Staff_elem_info); virtual void do_TYPESET_command(Command*); @@ -66,6 +64,10 @@ struct Complex_walker: Staff_walker { Complex_walker(Complex_staff*); Complex_column *col(); Complex_staff *staff(); +private: + void do_change_group( Voice * v, String group_id_str); + void do_announces(); + void try_request(Request*req); }; diff --git a/hdr/dimen.hh b/hdr/dimen.hh index 4ee17ea140..a3f4e8876b 100644 --- a/hdr/dimen.hh +++ b/hdr/dimen.hh @@ -4,9 +4,18 @@ #include "real.hh" #include "string.hh" +const Real INCH_TO_PT=72.0; +const Real CM_TO_PT=INCH_TO_PT/2.54; +const Real MM_TO_PT=CM_TO_PT/10; +const Real PT_TO_PT =1.0; + +#define PT *PT_TO_PT +#define MM *MM_TO_PT +#define CM *CM_TO_PT +#define INCH *INCH_TO_PT + Real parse_dimen(String); -Real convert_dimen(Real, String); String print_dimen(Real); - +Real convert_dimen(Real, String); #endif diff --git a/hdr/directionalspanner.hh b/hdr/directionalspanner.hh index f0e4716432..8868bbfd6d 100644 --- a/hdr/directionalspanner.hh +++ b/hdr/directionalspanner.hh @@ -12,7 +12,7 @@ struct Directional_spanner : Spanner{ /// -1 below heads, +1 above heads. - int dir; + int dir_i_; /// offset of "center" relative to left-column/0-pos of staff virtual Offset center() const=0; diff --git a/hdr/grouping.hh b/hdr/grouping.hh index aea2fd393f..70d95ef55d 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -13,12 +13,13 @@ typedef Interval_t MInterval; -/// data structure which represents rhythmic units +/** data structure which represents rhythmic units this is a tree. It groupes notes according to rules + */ struct Rhythmic_grouping { Array children; MInterval *interval_; - /****************/ + /* *************** */ Array intervals(); MInterval interval()const; @@ -51,9 +52,4 @@ private: void junk(); void copy(Rhythmic_grouping const&); }; -/** - this is a tree. It groupes notes according to rules - - */ - #endif diff --git a/hdr/headreg.hh b/hdr/headreg.hh new file mode 100644 index 0000000000..d5eb6fa5cd --- /dev/null +++ b/hdr/headreg.hh @@ -0,0 +1,24 @@ +/* + headreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef HEADREG_HH +#define HEADREG_HH +#include "register.hh" + +struct Notehead_register : Request_register { + Item* note_p_; + int dir_i_; + /* *************** */ + Notehead_register(Complex_walker*); + virtual bool try_request(Request *req_l) ; + virtual void process_request(); + virtual void do_pre_move_process(); + void set_dir(int); +}; + + +#endif // HEADREG_HH diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh index bd6054f6e9..d40885407a 100644 --- a/hdr/inputcommands.hh +++ b/hdr/inputcommands.hh @@ -16,7 +16,7 @@ struct Commands_at : public IPointerList { Time_description tdescription_; - /****************/ + /* *************** */ Moment when(); void parse(Staff_commands_at*); @@ -30,7 +30,7 @@ struct Commands_at : public IPointerList { struct Input_cursor : public PCursor { - /****************/ + /* *************** */ Input_cursor(PCursor); Moment when()const; void find_moment(Moment w); @@ -42,7 +42,7 @@ struct Input_cursor : public PCursor struct Input_commands : public IPointerList { Input_cursor ptr; - /****************/ + /* *************** */ void find_moment(Moment); void add(Input_command c,Assoc &marks_assoc_r); diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index 7d0dd618ba..0a1d95cfc6 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -16,7 +16,18 @@ struct Voice_list : public PointerList { void translate_time(Moment dt); }; -/// ABC for input structures +/** + + Input_music is anything that can simply be regarded as/converted to + a set of voices "cooperating" or independant. It has some basic + characteristics that real music has too: + + - it is rhythmic (it has a length, and can be translated horizontally) + - a pitch (it can be transposed) + + */ + + struct Input_music { virtual Voice_list convert()const=0; virtual Moment length()const=0; @@ -30,23 +41,12 @@ struct Input_music { virtual Input_music *clone() const = 0; virtual Simple_music *simple() { return 0; } }; -/** - - Input_music is anything that can simply be regarded as/converted to - a set of voices "cooperating" or independant. It has some basic - characteristics that real music has too: - - - it is rhythmic (it has a length, and can be translated horizontally) - - a pitch (it can be transposed) - - */ - /// Simple music consists of one voice struct Simple_music : Input_music { Voice voice_; - /****/ + /* *** */ virtual Simple_music*simple() { return this; } void add(Voice_element*); virtual void set_default_group(String g) { voice_.set_default_group(g); } @@ -63,7 +63,7 @@ struct Simple_music : Input_music { /// Complex_music consists of multiple voices struct Complex_music : Input_music { IPointerList elts; - /****************/ + /* *************** */ virtual void set_default_group(String g); void add(Input_music*); Complex_music(); @@ -73,11 +73,19 @@ struct Complex_music : Input_music { }; -/// multiple stuff after each other + +/** + voice like. + + different music forms which start after each other ( concatenated, + stacked "horizontally ) + + */ + struct Music_voice : Complex_music { - /****************/ + /* *************** */ Moment length()const; virtual void translate_time(Moment dt); virtual Voice_list convert()const; @@ -87,19 +95,18 @@ struct Music_voice : Complex_music { } virtual void print() const ; }; -/** - voice like. - different music forms which start after each other ( concatenated, - stacked "horizontally ) - - */ +/** + Multiple musicstuff stacked on top of each other + chord like : -/// Multiple musicstuff stacked on top of each other + - different music forms which start at the same time ( stacked "vertically" ) + + */ struct Music_general_chord : Complex_music { - /****************/ + /* *************** */ virtual Moment length()const; virtual Voice_list convert()const; @@ -111,12 +118,6 @@ struct Music_general_chord : Complex_music { virtual void print() const ; }; -/** - chord like : - - - different music forms which start at the same time ( stacked "vertically" ) - - */ struct Multi_voice_chord : Music_general_chord { void set_default_group(String); diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index 94ff045814..ef0d9d6a88 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -17,7 +17,7 @@ struct Input_score { IPointerList staffs_; IPointerList commands_; - /****************************************************************/ + /* *************************************************************** */ Input_score(); Input_score(Input_score const&); void add(Array &s); @@ -28,7 +28,5 @@ struct Input_score { void print() const; Score*parse(); }; -/** - - */ + #endif diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh index 647ffaf8a5..c1252ad01d 100644 --- a/hdr/inputstaff.hh +++ b/hdr/inputstaff.hh @@ -20,7 +20,7 @@ struct Input_staff { IPointerList commands_; IPointerList music_; - /****************/ + /* *************** */ void add(Input_music*m); Input_staff(Input_staff const&); diff --git a/hdr/item.hh b/hdr/item.hh index 68f1402c5b..e934f279f7 100644 --- a/hdr/item.hh +++ b/hdr/item.hh @@ -6,24 +6,27 @@ #include "string.hh" #include "staffelem.hh" -/// a horizontally fixed size element of the score +/** + a horizontally fixed size element of the score + + Item is the datastructure for printables whose width is known + before the spacing is calculated + + NB. This doesn't mean an Item has to initialize the output field before + spacing calculation. + +*/ + struct Item : Staff_elem { /// indirection to the column it is in PCol * pcol_l_; - /****************/ + /* *************** */ virtual Item *item() { return this; } Item(); void do_print()const; const char*name()const; }; -/** Item is the datastructure for printables whose width is known - before the spacing is calculated - - NB. This doesn't mean an Item has to initialize the output field before - spacing calculation. - -*/ #endif diff --git a/hdr/key.hh b/hdr/key.hh index a0ea3e833d..fa41082fd8 100644 --- a/hdr/key.hh +++ b/hdr/key.hh @@ -13,7 +13,7 @@ class Key { Array accidentals; - /****************/ + /* *************** */ public: Array read(Array ); diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index 71a7dba2b1..1d1d2e37f0 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -12,7 +12,7 @@ struct Clef; -/// +/// An item which places accidentals at the start of the line struct Keyitem : Item { const char * name() const; Array pitch; @@ -20,7 +20,7 @@ struct Keyitem : Item { int c_position; - /****************/ + /* *************** */ Keyitem(int cposition); void add(int pitch, int acc); @@ -31,8 +31,5 @@ struct Keyitem : Item { Molecule* brew_molecule_p()const; }; -/** - An item which places accidentals at the start of the line - */ #endif // KEYITEM_HH diff --git a/hdr/lexer.hh b/hdr/lexer.hh index 9e5cf1b303..e2909d8879 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -33,7 +33,7 @@ struct My_flex_lexer : yyFlexLexer { Notename_tab * defaulttab; char const* data_ch_c_l_m; int errorlevel_i_; - /****************/ + /* *************** */ int ret_notename(int *p, String text, int octave_mod); char const* here_ch_c_l(); void set(Notename_tab *n); diff --git a/hdr/linepstaff.hh b/hdr/linepstaff.hh deleted file mode 100644 index 3e88f8c915..0000000000 --- a/hdr/linepstaff.hh +++ /dev/null @@ -1,11 +0,0 @@ -#include "pstaff.hh" - -struct Linestaff : PStaff { - - int nolines; - -/****************/ - - void brew_molecule_p(Real width); - Linestaff(int, PScore*); -}; diff --git a/hdr/linespace.hh b/hdr/linespace.hh index e23d334ca6..b9027754ce 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -13,7 +13,7 @@ struct Colinfo { const Real* fixpos; Interval width; - /****************/ + /* *************** */ Colinfo(); void operator=(Colinfo const&); Colinfo(Colinfo const&); @@ -27,7 +27,25 @@ struct Colinfo { }; -/// spacing for one line. +/** the problem, given by the columns (which include constraints) and + intercolumn spacing. The problem is: + + Generate a spacing which + \begin{itemize} + \item + Satisfies spacing constraints (notes can't be printed through each other) + \item + Looks good, ie tries to conform to an ideal spacing as much as possible. + \end{itemize} + This is converted by regarding idealspacing as "springs" attached + to columns. The equilibrium of one spring is the ideal + distance. The columns have a size, this imposes "hard" constraints + on the distances. This transforms the problem into a quadratic + programming problem with linear constraints. + + The quality is given by the total potential energy in the + springs. The lower the energy, the better the configuration. +*/ class Spacing_problem { Array ideals; Array cols; @@ -51,26 +69,28 @@ class Spacing_problem { void make_constraints(Mixed_qp& lp) const; public: - /// solve the spacing problem + /** solve the spacing problem + return the column positions, and the energy (last element) + */ Array solve() const; - /** - return the column positions, and the energy (last element) - */ + /// add a idealspacing to the problem. - void add_ideal(const Idealspacing *i); - /** + + One pair of columns can have no, one or more idealspacings, since they can be "summed" if the columns to which #i# refers are not in this problem, the spacing is ignored. */ + void add_ideal(const Idealspacing *i); /// add a col to the problem - void add_column(const PCol *, bool fixed=false, Real fixpos=0.0); - /** columns have to be added left to right. The column contains + /** columns have to be added left to right. The column contains info on it's minimum width. */ + void add_column(const PCol *, bool fixed=false, Real fixpos=0.0); + bool check_constraints(Vector v) const; @@ -82,23 +102,4 @@ public: }; -/** the problem, given by the columns (which include constraints) and - intercolumn spacing. The problem is: - - Generate a spacing which - \begin{itemize} - \item - Satisfies spacing constraints (notes can't be printed through each other) - \item - Looks good, ie tries to conform to an ideal spacing as much as possible. - \end{itemize} - This is converted by regarding idealspacing as "springs" attached - to columns. The equilibrium of one spring is the ideal - distance. The columns have a size, this imposes "hard" constraints - on the distances. This transforms the problem into a quadratic - programming problem with linear constraints. - - The quality is given by the total potential energy in the - springs. The lower the energy, the better the configuration. -*/ #endif diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index 0da7e06858..492a23f345 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -20,7 +20,7 @@ struct Local_key_item : Item { Array group; int c0_position; // move into walker - /****************/ + /* *************** */ Local_key_item(int c0position); void add(Item*); diff --git a/hdr/localkeyreg.hh b/hdr/localkeyreg.hh new file mode 100644 index 0000000000..742d9cb41e --- /dev/null +++ b/hdr/localkeyreg.hh @@ -0,0 +1,24 @@ +/* + localkeyreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef LOCALKEYREG_HH +#define LOCALKEYREG_HH +#include "register.hh" + +struct Local_key_register : Request_register { + Local_key_item* key_item_p_; + + /* *************** */ + + virtual bool try_request(Request*); + virtual void process_request(); + virtual void acknowledge_element(Staff_elem_info); + virtual void do_pre_move_process(); + Local_key_register(Complex_walker*); +}; + +#endif // LOCALKEYREG_HH diff --git a/hdr/lookup.hh b/hdr/lookup.hh index ac479b8549..540bf664f7 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -11,7 +11,7 @@ struct Lookup { Symtables *symtables_; String texsetting; - /****************/ + /* *************** */ void add(String, Symtable*); Real internote(); @@ -19,14 +19,16 @@ struct Lookup { Symbol linestaff(int n, Real w); Symbol fill(Box b); 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 streepjes(int pos); Symbol meter(Array); Symbol stem(Real y1_pos, Real y2_pos); @@ -44,7 +46,7 @@ struct Lookup { Symbol big_slur(int dy, Real &dx, int dir); Symbol text(String style, String text, int align = 1); Symbol script(String idx); - + Symbol hairpin(Real & width, bool decresc); Lookup(); Lookup(Lookup const &); diff --git a/hdr/lyriccolumn.hh b/hdr/lyriccolumn.hh index 145ff7fc08..118b9f34bd 100644 --- a/hdr/lyriccolumn.hh +++ b/hdr/lyriccolumn.hh @@ -26,10 +26,10 @@ struct Lyric_column : Staff_column { Array winfo_array_; Lyric_staff* lstaff_l_; - void typeset_item(Item *, int=1); + void typeset_item(Item *); virtual void setup_requests(); - Lyric_column(Score_column*s,Lyric_staff*rs); + Lyric_column(Score_column* s,Lyric_staff*rs); }; #endif // LYRICSTAFF_HH diff --git a/hdr/lyricitem.hh b/hdr/lyricitem.hh index 7fda46142e..5dcd90c889 100644 --- a/hdr/lyricitem.hh +++ b/hdr/lyricitem.hh @@ -9,7 +9,7 @@ #include "textitem.hh" struct Lyric_item : Text_item { - /****************/ + /* *************** */ Lyric_item(Lyric_req* lreq_l, int voice_count_i); virtual void do_pre_processing(); }; diff --git a/hdr/lyricstaff.hh b/hdr/lyricstaff.hh index 6959636c60..22fb8958b6 100644 --- a/hdr/lyricstaff.hh +++ b/hdr/lyricstaff.hh @@ -10,14 +10,11 @@ /// (lstaff) struct Lyric_staff : Staff { - PStaff* line_pstaff_p_; + PStaff* pstaff_l_; Staff_column* create_col(Score_column*); - -// virtual Item *get_TYPESET_item(Command*); - virtual void set_output(PScore *); -// virtual Local_key_item* get_local_key_item(); + virtual void set_output(PScore *); void process_commands(PCursor &where); virtual void walk(); diff --git a/hdr/lyricwalker.hh b/hdr/lyricwalker.hh index 870efbb040..fcf0c9186b 100644 --- a/hdr/lyricwalker.hh +++ b/hdr/lyricwalker.hh @@ -16,7 +16,7 @@ struct Lyric_item; // put into proto struct Lyric_walker: Staff_walker { Array litem_l_array_; - /****************/ + /* *************** */ virtual void do_TYPESET_command(Command*); virtual void do_INTERPRET_command(Command*); diff --git a/hdr/melodicstaff.hh b/hdr/melodicstaff.hh deleted file mode 100644 index cec73517d7..0000000000 --- a/hdr/melodicstaff.hh +++ /dev/null @@ -1,29 +0,0 @@ -/* - rhythmstaf.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef MELODICSTAFF_HH -#define MELODICSTAFF_HH - -#include "simplestaff.hh" - -/// five line staff, no multiple voices -struct Melodic_staff : public Simple_staff -{ - - /****************/ - - virtual Rest *get_rest(Rest_req *rq); - virtual void set_output(PScore *); - - virtual Item* get_TYPESET_item(Command*); - virtual Stem * get_stem(Stem_req *rq); - virtual Notehead * get_notehead(Note_req *rq, int bot); - virtual Local_key_item* get_local_key_item(); -}; - -#endif // MELODICSTAFF_HH - - diff --git a/hdr/meter.hh b/hdr/meter.hh index 835b661bae..22a256c93c 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -12,7 +12,7 @@ struct Meter: Item { const char * name() const; Array args; - /****************/ + /* *************** */ Meter(Array args) ; Molecule*brew_molecule_p() const; diff --git a/hdr/molecule.hh b/hdr/molecule.hh index 9f20458fef..084321ce4e 100644 --- a/hdr/molecule.hh +++ b/hdr/molecule.hh @@ -11,7 +11,7 @@ struct Atom { Offset off; Symbol sym; - /****************/ + /* *************** */ void translate(Offset o) { off += o; @@ -26,11 +26,13 @@ struct Atom { String TeXstring() const; }; -/// a group of #Atom#s + +/** a group of individually translated symbols. You can add molecules + to the top, to the right, etc. */ struct Molecule { IPointerList ats; // change to List? - /****************/ + /* *************** */ Molecule() { } Molecule(Atom a) { add(a) ; } @@ -52,6 +54,4 @@ struct Molecule { private: void operator=(const Molecule&); }; -/** a group of individually translated symbols. You can add molecules - to the top, to the right, etc. */ #endif diff --git a/hdr/notehead.hh b/hdr/notehead.hh index 66bed0360e..b3b7d3ad23 100644 --- a/hdr/notehead.hh +++ b/hdr/notehead.hh @@ -8,7 +8,15 @@ #define NOTEHEAD_HH #include "item.hh" -/// ball at the end of the stem +/** + ball at the end of the stem +takes care of: + + * help lines + * proper placing of dots + + */ + struct Notehead : Item { const char * name() const; const char* defined_ch_c_l_m; //sorry, trying to find error in martien.ly @@ -21,24 +29,17 @@ struct Notehead : Item { int balltype; int x_dir; - /****************/ + /* *************** */ void set_rhythmic(Rhythmic_req *); - Notehead(int staff_size); + /** position of top line (5 linestaff: 8) */ - + Notehead(int staff_size); void do_print()const; static int compare(Notehead*&a, Notehead*&b) ; Molecule* brew_molecule_p()const; }; -/** - takes care of: - - * help lines - * proper placing of dots - - */ #endif // NOTEHEAD_HH diff --git a/hdr/paper.hh b/hdr/paper.hh index 6da51df33e..da9ebd12ed 100644 --- a/hdr/paper.hh +++ b/hdr/paper.hh @@ -3,7 +3,15 @@ #include "string.hh" #include "moment.hh" -/// symbols, dimensions and constants + +/** symbols, dimensions and constants + + 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 + */ struct Paperdef { Lookup *lookup_p_; String outfile; @@ -16,7 +24,7 @@ struct Paperdef { /// ideal = geometric_ ^ log2(duration) Real geometric_; - /****************/ + /* *************** */ void reinit(); Paperdef(Lookup*); void set(Lookup*); @@ -30,9 +38,4 @@ struct Paperdef { void print() const; Real duration_to_dist(Moment); }; -/** 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/hdr/pcol.hh b/hdr/pcol.hh index 1d3ff34ca8..0e8ed3e677 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -7,26 +7,34 @@ #include "item.hh" /// stuff grouped vertically. -struct PCol { +/** + This is a class to address items vertically. It contains the data for: + \begin{itemize} + \item + unbroken score + \item + broken score + \item + the linespacing problem + \end{itemize} + */struct PCol { PointerList its; PointerList stoppers, starters; /// prebreak is put before end of line. - PCol *prebreak_p_; /** if broken here, then (*this) column is discarded, and prebreak is put at end of line, owned by Col */ + PCol *prebreak_p_; /// postbreak at beginning of the new line PCol *postbreak_p_; - /** \See{prebreak} - */ - PCol *daddy_l_; /** if this column is pre or postbreak, then this field points to the parent. */ + PCol *daddy_l_; /// if lines are broken then this column is in #line# const Line_of_score *line_l_; @@ -36,7 +44,7 @@ struct PCol { PScore * pscore_l_; - /****************/ + /* *************** */ /// which one (left =0) int rank() const; @@ -53,12 +61,12 @@ struct PCol { PCol(PCol * parent); /// which col comes first? - static int compare(const PCol &c1, const PCol &c2); /** signed compare on columns. return < 0 if c1 < c2. - */ + */static int compare(const PCol &c1, const PCol &c2); + void OK() const; void set_breakable(); @@ -66,17 +74,7 @@ struct PCol { private: PCol(PCol const&){} }; -/** - This is a class to address items vertically. It contains the data for: - \begin{itemize} - \item - unbroken score - \item - broken score - \item - the linespacing problem - \end{itemize} - */ + #include "compare.hh" instantiate_compare(PCol &, PCol::compare); diff --git a/hdr/proto.hh b/hdr/proto.hh index 1ef4d8d9f2..eac46fbeca 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -65,6 +65,7 @@ struct Music_general_chord; struct Music_voice; struct Note_req; struct Notehead; +struct Notehead_register; struct Notename_tab; struct Offset; struct Output; @@ -84,12 +85,14 @@ struct Score; struct Score_column; struct Script_def; struct Script; +struct Script_register; struct Script_req; struct Simple_music; struct Slur; +struct Slur_register; struct Slur_req; -class Source; -class Source_file; +struct Source; +struct Source_file; struct Spacing_req ; struct Span_req; struct Spanner; @@ -101,6 +104,7 @@ struct Staff_commands; struct Staff_commands_at ; struct Staff_elem; struct Staff_elem_info; +struct Staff_symbol; struct Staff_walker; struct Stem; struct Stem_req; @@ -114,7 +118,9 @@ struct Terminate_voice_req; struct Text_item ; struct Text_def; struct Text_gob; +struct Text_register; struct Text_req; + struct Time_description; struct Voice; struct Voice_element; diff --git a/hdr/pscore.hh b/hdr/pscore.hh index 3b47c65e44..f4b3f788d9 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -9,7 +9,10 @@ #include "pstaff.hh" /// all stuff which goes onto paper -struct PScore { +/** notes, signs, symbols in a score can be grouped in two ways: + horizontally (staffwise), and vertically (columns). #PScore# + contains the items, the columns and the staffs. + */struct PScore { Paperdef *paper_l_; /// the columns, ordered left to right @@ -33,7 +36,7 @@ struct PScore { /// broken spanners IPointerList broken_spans; - /****************/ + /* *************** */ /* CONSTRUCTION */ PScore(Paperdef*); @@ -42,8 +45,12 @@ struct PScore { void add(PStaff *); - /// add item - void typeset_item(Item *, PCol *,PStaff*,int=1); + /// add an item + /** + add the item in specified containers. If breakstatus is set + properly, add it to the {pre,post}break of the pcol. + */ + void typeset_item(Item *item_p, PCol *pcol_l,PStaff*pstaf_l,int breakstatus=1); /// add a Spanner void typeset_spanner(Spanner*, PStaff*); @@ -91,8 +98,5 @@ private: /// delete unused columns void clean_cols(); }; -/** notes, signs, symbols in a score can be grouped in two ways: - horizontally (staffwise), and vertically (columns). #PScore# - contains the items, the columns and the staffs. - */ + #endif diff --git a/hdr/pstaff.hh b/hdr/pstaff.hh index 2c79427f78..50a7f0c719 100644 --- a/hdr/pstaff.hh +++ b/hdr/pstaff.hh @@ -8,18 +8,16 @@ /// items grouped horizontally struct PStaff { - Molecule * stafsym_p_; PScore * pscore_l_; PointerList spans; PointerList its; - /****************/ - virtual void brew_molecule_p(Real width)=0; // maybe overkill + /* *************** */ void add(Item*i); PStaff(PScore*); - virtual ~PStaff(); + private: PStaff(PStaff const&); }; diff --git a/hdr/qlp.hh b/hdr/qlp.hh index db5438499d..6e82aa9c40 100644 --- a/hdr/qlp.hh +++ b/hdr/qlp.hh @@ -14,20 +14,19 @@ public: Vector lin; Real const_term; - /// - void assert_solution(Vector sol) const; + /** use a KKT method to assert optimality of sol */ - /// solve the problem using a projected gradient method + void assert_solution(Vector sol) const; + /// solve the problem using a projected gradient method Vector solve(Vector start) const; + /** return the number of variables in the problem */ int dim() const{ return lin.dim(); } - /** return the number of variables in the problem */ - /// - void add_inequality_cons(Vector c, double r); + /** add a constraint @@ -38,14 +37,15 @@ public: c.dim() == dim(); */ - /// - Ineq_constrained_qp(int novars); + void add_inequality_cons(Vector c, double r); + /** set up matrices to go with the problem. */ - - Real eval(Vector v); + Ineq_constrained_qp(int novars); + /** evaluate the quadratic function for input #v# */ + Real eval(Vector v); void eliminate_var(int idx, Real value); void OK()const; @@ -54,6 +54,15 @@ public: }; /// Quadratic programming with mixed linear constraints +/** + problem definition of a quadratic optimisation problem with linear + inequality and equality constraints + + + x^T QUAD x /2 + b^T x +*/ + + class Mixed_qp :public Ineq_constrained_qp { Array eq_cons; Array eq_consrhs; @@ -65,8 +74,7 @@ public: Vector solve(Vector start) const; void add_fixed_var(int i , Real value); - /// - void add_equality_cons(Vector c, double r); + /** add a constraint, @@ -75,15 +83,6 @@ public: PRE c.dim()==dim(); */ - + void add_equality_cons(Vector c, double r); }; -/** - problem definition of a quadratic optimisation problem with linear - inequality and equality constraints - - - x^T QUAD x /2 + b^T x -*/ - - #endif diff --git a/hdr/qlpsolve.hh b/hdr/qlpsolve.hh index b9789bfc4a..aefcc767e7 100644 --- a/hdr/qlpsolve.hh +++ b/hdr/qlpsolve.hh @@ -2,6 +2,18 @@ #include "matrix.hh" +/** + This class represents the set of active (binding) constraints + which can be active while the QLP algorithm is in a feasible + point. The active constraints are numbered. + If the constraints are of the form + + A^T*x >= b + + then the binding constraints are those where the >= is equality. + + */ + class Active_constraints { friend class Inactive_iter; @@ -18,23 +30,23 @@ public: Real rhs(int k) const { return opt->consrhs[k]; } /// drop constraint - void drop (int k); /** drop constraint k from the active set. k is the index of the constraint in #active# */ + void drop (int k); /// add constraint j - void add(int j); /** add constraint j to the active set j is the index of the constraint in #inactive# */ + void add(int j); /// exchange in and out. void exchange(int in, int out) { add(in); drop (out); } - /// + Vector find_active_optimum(Vector g); /// get lagrange multipliers. @@ -48,19 +60,10 @@ public: void OK(); }; -/** - This class represents the set of active (binding) constraints - which can be active while the QLP algorithm is in a feasible - point. The active constraints are numbered. - If the constraints are of the form - - A^T*x >= b - then the binding constraints are those where the >= is equality. - +/** + loop through the inactive constraints. */ - -/// class Inactive_iter { int j; Active_constraints const* ac; @@ -73,6 +76,3 @@ public: Real rhs() const { return ac->rhs(constraint_id()); } bool ok() const { return j < ac->inactive.size(); } }; -/** - loop through the inactive constraints. - */ diff --git a/hdr/register.hh b/hdr/register.hh index e2b5167d8d..0c47e35cd1 100644 --- a/hdr/register.hh +++ b/hdr/register.hh @@ -8,146 +8,77 @@ #define REGISTER_HH #include "proto.hh" #include "varray.hh" +#include "request.hh" /// data container. struct Staff_elem_info { Staff_elem * elem_p_; Request*req_l_; const Voice * voice_l_; - Voice_group_registers * group_regs_l_; - + Voice_group_registers * group_regs_l_; Request_register * origin_reg_l_; - /****/ + /* *** */ Staff_elem_info(Staff_elem*, Request*, Request_register*); Staff_elem_info(); }; /// Hungarian postfix: reg +/** + a struct which processes requests, and creates the Staff_elems + */ struct Request_register { Complex_walker * walk_l_; Array accepted_req_arr_; - /****************/ - + /* *************** */ + /** + Warning: you can't copy a Request_register + */ + Request_register(Request_register const &); Request_register(Complex_walker*); Request_register(); virtual ~Request_register(){} - /// take note of item/spaanner + /** take note of item/spaanner + put item in spanner. Adjust local key; etc. + */ virtual void acknowledge_element(Staff_elem_info){} /** - put item in spanner. Adjust local key; etc. + Announce element to walker + */ + void announce_element(Staff_elem_info); + + /** + invoke walker method to typeset element */ + void typeset_element(Staff_elem*elem_p); - /// - virtual bool try_request(Request *req_l) =0; /** try to fit the request in this register - RETURN - false: request noted, but not taken. + @return + false: not noted, not taken. true: request swallowed. Don't try to put elsewhere (may be we could use C++ exceptions.. :-) */ - + virtual bool try_request(Request *req_l) =0; + /// make items/spanners with the requests you got virtual void process_request()=0; - + Paperdef * paper() const; /// typeset any spanners. Empty accepted_req_arr_ void pre_move_processing(); void post_move_processing(); - + virtual void set_dir(int){} protected: /// virtual, called by pre_move_process() virtual void do_pre_move_process(){} virtual void do_post_move_process(){} }; -/** - a struct which processes requests, and creates the Staff_elems - */ -struct Notehead_register : Request_register { - Item* note_p_; - /****************/ - Notehead_register(Complex_walker*); - virtual bool try_request(Request *req_l) ; - virtual void process_request(); - virtual void do_pre_move_process(); -}; - -struct Slur_register : Request_register { - Array requests_arr_; - Array slur_l_stack_; - Array end_slur_l_arr_; - - /****************/ - ~Slur_register(); - Slur_register(Complex_walker*); - virtual bool try_request(Request*); - virtual void process_request(); - virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); -}; - -struct Stem_beam_register : Request_register { - Stem * stem_p_; - Beam * beam_p_; - Beam_req * beam_req_l_; - Stem_req * stem_req_l_; - Beam_req * start_req_l_; - bool end_beam_b_; - Rhythmic_grouping *current_grouping; - int default_dir_i_; - - /****************/ - Stem_beam_register(Complex_walker*); - ~Stem_beam_register(); - void set_dir(int dir_i_); - virtual bool try_request(Request*); - virtual void process_request(); - virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); - virtual void do_post_move_process(); -}; - -struct Script_register : Request_register { - Script * script_p_; - - /****************/ - void set_dir(int dir_i_); - Script_register(Complex_walker*); - virtual bool try_request(Request*); - virtual void process_request(); - virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); -}; - -struct Text_register : Request_register{ - Text_item * text_p_; - - /****************/ - void set_dir(int dir_i_); - Text_register(Complex_walker*); - virtual bool try_request(Request*); - virtual void process_request(); - virtual void do_pre_move_process(); -}; - - -struct Local_key_register : Request_register { - Local_key_item* key_item_p_; - - /****************/ - - virtual bool try_request(Request*); - virtual void process_request(); - virtual void acknowledge_element(Staff_elem_info); - virtual void do_pre_move_process(); - Local_key_register(Complex_walker*); -}; #endif // REGISTER_HH diff --git a/hdr/request.hh b/hdr/request.hh index 44d42e5301..d07bbd3469 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -7,11 +7,16 @@ #include "moment.hh" /// Hungarian postfix: req +/** + a voice element wants something printed. +see lilygut page + */ + struct Request { Voice_element*elt_l_; char const* defined_ch_c_l_m; - /****************/ + /* *************** */ Request(); Request(Request const&); virtual ~Request(){} @@ -47,11 +52,6 @@ struct Request { protected: virtual void do_print()const ; }; -/** - a voice element wants something printed. -see lilygut page - */ - #define REQUESTMETHODS(T,accessor) \ virtual T * accessor() { return this;}\ @@ -83,7 +83,7 @@ struct Rhythmic_req : virtual Request { int balltype; int dots; Moment plet_factor; - /****************/ + /* *************** */ static int compare(const Rhythmic_req &, const Rhythmic_req &); Moment duration() const; Rhythmic_req(); @@ -95,7 +95,7 @@ struct Spacing_req :virtual Request { Moment next; Real distance; Real strength; - /****************/ + /* *************** */ Spacing_req(); REQUESTMETHODS(Spacing_req, spacing); }; @@ -109,7 +109,7 @@ struct Blank_req : Spacing_req, Rhythmic_req { struct Text_req : virtual Request { int dir_i_; Text_def *tdef_p_; - /****************/ + /* *************** */ Text_req(int d, Text_def*); ~Text_req(); Text_req(Text_req const&); @@ -152,25 +152,29 @@ struct Note_req : Rhythmic_req, virtual Melodic_req { ///Put a rest on the staff. +/** +Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded. +*/ + struct Rest_req : Rhythmic_req { REQUESTMETHODS(Rest_req,rest); }; +/// attach a stem to the noteball /** -Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded. -*/ + Rhythmic_req parent needed to determine if it will fit inside a beam. + */ -/// attach a stem to the noteball struct Stem_req : Rhythmic_req { int dir_i_; Stem_req(int s, int dots); REQUESTMETHODS(Stem_req,stem); }; -/** - Rhythmic_req parent needed to determine if it will fit inside a beam. - */ /// requests to start or stop something. +/** + This type of request typically results in the creation of a #Spanner# +*/ struct Span_req : Request { /// should the spanner start or stop, or is it unwanted? enum { @@ -182,25 +186,22 @@ struct Span_req : Request { Span_req(); }; -/** - This type of request typically results in the creation of a #Spanner# -*/ ///Start / stop a beam at this note. + +/** if #nplet# is set, the staff will try to put an +appropriate number over the beam + */ struct Beam_req : Span_req { int nplet; - /****************/ + /* *************** */ REQUESTMETHODS(Beam_req,beam); Beam_req(); }; -/** if #nplet# is set, the staff will try to put an -appropriate number over the beam - */ - /// a slur struct Slur_req : Span_req { REQUESTMETHODS(Slur_req,slur); @@ -209,32 +210,32 @@ struct Slur_req : Span_req { ///Put a script above or below this ``note'' +/** eg upbow, downbow. Why a request? These symbols may conflict with +slurs and brackets, so this also a request */ struct Script_req : Request { int dir_i_; Script_def *scriptdef_p_; - /****************/ + /* *************** */ static int compare(const Script_req &, const Script_req &); Script_req(int d, Script_def*); REQUESTMETHODS(Script_req,script); ~Script_req(); Script_req(Script_req const&); }; -/** eg upbow, downbow. Why a request? These symbols may conflict with -slurs and brackets, so this also a request */ /// designate this spot with a name. struct Mark_req : Request { String mark_str_; - /****************/ + /* *************** */ Mark_req(String); REQUESTMETHODS(Mark_req,mark); }; struct Staff_command_req : Request { Input_command * com_p_; - /****************/ + /* *************** */ Staff_command_req(Staff_command_req const&); ~Staff_command_req(); Staff_command_req(Input_command*); @@ -280,9 +281,6 @@ struct Subtle_req { }; /// helper in the hierarchy -struct Dynamic:Subtle_req { - -}; /** Each dynamic is bound to one note ( a crescendo spanning multiple notes is thought to be made of two "dynamics": a start and a stop). Dynamic changes can occur in a smaller time than the length of its @@ -295,6 +293,9 @@ struct Dynamic:Subtle_req { Dynamic should have been derived from request, but I don't want to fuss with virtual baseclasses. */ +struct Dynamic:Subtle_req { + +}; /// do a crescendo struct Cresc_req : Span_req, Dynamic { diff --git a/hdr/rest.hh b/hdr/rest.hh index 02c6e0bff6..d03bd0c96f 100644 --- a/hdr/rest.hh +++ b/hdr/rest.hh @@ -8,13 +8,12 @@ #define REST_HH #include "item.hh" -/// ball at the end of the stem struct Rest : Item { int dots; int balltype; - /****************/ + /* *************** */ Rest(int dur,int dots); @@ -22,12 +21,5 @@ struct Rest : Item { const char * name() const; Molecule* brew_molecule_p()const; }; -/** - takes care of: - - * help lines - * proper placing of dots - - */ #endif diff --git a/hdr/rhythmstaff.hh b/hdr/rhythmstaff.hh deleted file mode 100644 index 0508224a3a..0000000000 --- a/hdr/rhythmstaff.hh +++ /dev/null @@ -1,26 +0,0 @@ -/* - rhythmstaf.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef RHYTHMSTAF_HH -#define RHYTHMSTAF_HH - -#include "simplestaff.hh" - -/// all notes on one line -struct Rhythmic_staff : public Simple_staff -{ - - /****************/ - - virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq); - virtual Notehead * get_notehead(Note_req *rq, int b); - virtual void set_output(PScore *); -}; - -#endif // RHYTHMSTAF_HH - - diff --git a/hdr/sccol.hh b/hdr/sccol.hh index 75f1bcd89b..1d2f4022bb 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -11,6 +11,16 @@ #include "moment.hh" +/** + + When typesetting hasn't started on PScore yet, the columns which + contain data have a rhythmical position. Score_column is the type + with a rhythmical time attached to it. The calculation of + idealspacing is done with data in these columns. (notably: the + #durations# field) + + */ + struct Score_column { /// indirection to column @@ -19,10 +29,10 @@ struct Score_column { /// length of notes/rests in this column Array durations; - /// + bool musical_; - /****************/ + /* *************** */ Moment when() { return when_; } Score_column(Moment when); static int compare(Score_column & c1, Score_column &c2); @@ -35,15 +45,6 @@ struct Score_column { private: Moment when_; }; -/** - - When typesetting hasn't started on PScore yet, the columns which - contain data have a rhythmical position. Score_column is the type - with a rhythmical time attached to it. The calculation of - idealspacing is done with data in these columns. (notably: the - #durations# field) - - */ instantiate_compare(Score_column&, Score_column::compare); diff --git a/hdr/score.hh b/hdr/score.hh index 64e2828614..cd5a56c5e7 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -5,6 +5,7 @@ #include "plist.hh" #include "moment.hh" #include "assoc.hh" +#include "string.hh" /// the total music def of one movement struct Score { @@ -20,7 +21,8 @@ struct Score { int errorlevel_i_; Assoc markers_assoc_; - /****************************************************************/ + + /* *************************************************************** */ /// construction Score(Paperdef*); @@ -40,28 +42,26 @@ struct Score { // utils: PCursor create_cols(Moment); + + /// find a column. The cursor is given to try a little efficiency. PCursor find_col(Moment,bool); + /// when does the last *musical* element finish? Moment last() const; private: Score(Score const&){} - /// - void do_cols(); + /** make the pcol_l_ fields of each Score_column point to the correct PCol, remove any unnecessary Score_column's */ + void do_cols(); /// remove unused cols void clean_cols(); /// add #Idealspacings# to #pscore_# void calc_idealspacing(); - /** add the score wide commands (bars, breaks) to each staff so - they can process (typeset) them if needed */ }; -/** - - */ #endif diff --git a/hdr/scoreline.hh b/hdr/scoreline.hh index 3c6ee0de04..f4e1987033 100644 --- a/hdr/scoreline.hh +++ b/hdr/scoreline.hh @@ -19,7 +19,7 @@ Line_of_score { IPointerList staffs; PScore * pscore_l_; // needed to generate staffs - /****************/ + /* *************** */ void process() ; Line_of_score(Array sv, PScore *); diff --git a/hdr/script.hh b/hdr/script.hh index 2a10e7d49e..9c48c75e24 100644 --- a/hdr/script.hh +++ b/hdr/script.hh @@ -19,7 +19,7 @@ struct Script : Item { Stem *stem_l_; Array support; - /****************/ + /* *************** */ const char * name() const; Molecule* brew_molecule_p()const; virtual void do_post_processing(); diff --git a/hdr/scriptdef.hh b/hdr/scriptdef.hh index 423860a895..3c22681d23 100644 --- a/hdr/scriptdef.hh +++ b/hdr/scriptdef.hh @@ -14,7 +14,7 @@ struct Script_def{ bool invertsym; String symidx; - /****************/ + /* *************** */ int compare(Script_def const &); void print() const; Script_def(String, int, int ,bool); diff --git a/hdr/scriptreg.hh b/hdr/scriptreg.hh new file mode 100644 index 0000000000..72953427d5 --- /dev/null +++ b/hdr/scriptreg.hh @@ -0,0 +1,26 @@ +/* + scriptreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef SCRIPTREG_HH +#define SCRIPTREG_HH + +#include "register.hh" + + +struct Script_register : Request_register { + Script * script_p_; + int dir_i_; + /* *************** */ + void set_dir(int dir_i_); + Script_register(Complex_walker*); + virtual bool try_request(Request*); + virtual void process_request(); + virtual void acknowledge_element(Staff_elem_info); + virtual void do_pre_move_process(); +}; + +#endif // SCRIPTREG_HH diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh deleted file mode 100644 index f0ff1679e2..0000000000 --- a/hdr/simplestaff.hh +++ /dev/null @@ -1,77 +0,0 @@ -/* - simplestaff.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef SIMPLESTAFF_HH -#define SIMPLESTAFF_HH - -#include "key.hh" -#include "stcol.hh" -#include "staff.hh" -#include "staffwalker.hh" - -/* - mega-stupido staffs and cols: they do notes one at each moment. - */ - -struct Simple_staff; -struct Note_info { - Rhythmic_req *rq; - Array scripts; - Note_info(); - Note_info(Rhythmic_req*); -}; - -/// column of Simple_staff: store one request -struct Simple_column : Staff_column { - - Array notes; - Array slurs; - Stem_req *stem_; - Moment stem_requester_len; - Beam_req *beam_; - Simple_staff* staff_l_; - Text_req *text_; - - /****************/ - Slur_req * find_slur(Voice *); - void typeset_item(Item *, int=1); - void typeset_item_directional(Item *, int dir, int=1); - - Molecule *create_command_mol(Command *com); - - void take_request(Request *rq); - virtual void setup_requests(); - - Simple_column(Score_column*s,Simple_staff*rs); -}; - - -/// Simple staff: one voicegroup at a time -struct Simple_staff : Staff { - /// indirection to the PStaff. - PStaff *theline_l_; - - /****************/ - Staff_column*create_col(Score_column*); - - virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq)=0; - virtual Notehead *get_notehead(Note_req *rq, int b)=0; - virtual Rest *get_rest(Rest_req *rq); - virtual void set_output(PScore *); - virtual Local_key_item* get_local_key_item(); - - void process_commands( PCursor &where); - virtual void walk(); - - Simple_staff(); -}; - -#endif // SIMPLESTAFF_HH - - - - diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh deleted file mode 100644 index a43844622b..0000000000 --- a/hdr/simplewalker.hh +++ /dev/null @@ -1,53 +0,0 @@ -/* - simplewalker.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef SIMPLEWALKER_HH -#define SIMPLEWALKER_HH - -#include "proto.hh" -#include "grouping.hh" - - -struct Simple_walker: Staff_walker { - Stem *stem_; - Arraynoteheads; - Local_key local_key_; - Key key_; - Array *oldkey_undo; - Array typesetkey; - Beam *beam_; - Local_key_item *local_key_item_; - bool wantkey; // urgh - int processed_bar_priority; - bool processed_key; - bool processed_clef; - Clef clef_; - Rhythmic_grouping default_grouping; - Rhythmic_grouping *current_grouping; - Array pending_slur_reqs; - Array pending_slurs; - - /****************/ - - virtual void do_TYPESET_command(Command*); - virtual void do_INTERPRET_command(Command*); - virtual void process_requests(); - virtual void do_post_move(); - ~Simple_walker(); - Simple_walker(Simple_walker const& c); - void do_note(Note_info); - Simple_walker(Simple_staff*); - Simple_column *col(); - Simple_staff *staff(); - - void do_local_key(Note_req*, Notehead*); - int find_slur(const Voice*v); -}; - - -#endif // SIMPLEWALKER_HH - - diff --git a/hdr/slur.hh b/hdr/slur.hh index c9524ba6f5..c3e6a93c76 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -14,11 +14,10 @@ struct Slur : Directional_spanner { Array encompass; - //int dir; - bool open_left,open_right; + bool open_left, open_right; - /****************/ + /* *************** */ Offset center() const; Slur(); void do_post_processing(); diff --git a/hdr/slurreg.hh b/hdr/slurreg.hh new file mode 100644 index 0000000000..701b60a279 --- /dev/null +++ b/hdr/slurreg.hh @@ -0,0 +1,28 @@ +/* + slurreg.hh -- declare Slur_register + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef SLURREG_HH +#define SLURREG_HH + +#include "register.hh" + +struct Slur_register : Request_register { + Array requests_arr_; + Array slur_l_stack_; + Array end_slur_l_arr_; + int dir_i_; + /* *************** */ + ~Slur_register(); + Slur_register(Complex_walker*); + virtual bool try_request(Request*); + virtual void process_request(); + virtual void acknowledge_element(Staff_elem_info); + virtual void do_pre_move_process(); + virtual void set_dir(int); +}; + +#endif // SLURREG_HH diff --git a/hdr/sourcefile.hh b/hdr/sourcefile.hh index 1e1e2a8692..38a420248b 100644 --- a/hdr/sourcefile.hh +++ b/hdr/sourcefile.hh @@ -9,11 +9,10 @@ class Source_file { public: - /// - Source_file( String &filename_str ); /** RETURN path to opened file. */ + Source_file( String &filename_str ); ~Source_file(); char const* ch_c_l(); String error_str( char const* pos_ch_c_l ); diff --git a/hdr/spanner.hh b/hdr/spanner.hh index 144b110e29..097a592cd6 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -11,11 +11,29 @@ #include "staffelem.hh" /// a symbol which is attached between two columns. +/** A spanner is a symbol which spans across several columns, so its + final appearance can only be calculated after the breaking problem + is solved. + + Examples + + - (de)crescendo + - slur + - beam + - bracket + + + Spanner should know about the items which it should consider: + e.g. slurs should be steep enough to "enclose" all those items. This + is absolutely necessary for beams, since they have to adjust the + length of stems of notes they encompass. + + */ struct Spanner:Staff_elem { PCol *left, *right; - /****************/ + /* *************** */ Spanner(); virtual Interval width()const; @@ -25,29 +43,11 @@ struct Spanner:Staff_elem { virtual Spanner* spanner() { return this; } protected: /// clone a piece of this spanner. - virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0; /** PRE c1 >= start, c2 <= stop */ + virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0; }; -/** A spanner is a symbol which spans across several columns, so its - final appearance can only be calculated after the breaking problem - is solved. - - Examples - - - (de)crescendo - - slur - - beam - - bracket - - - Spanner should know about the items which it should consider: - e.g. slurs should be steep enough to "enclose" all those items. This - is absolutely necessary for beams, since they have to adjust the - length of stems of notes they encompass. - - */ #endif diff --git a/hdr/staff.hh b/hdr/staff.hh index cee6d27a19..6f43293b26 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -16,7 +16,7 @@ struct Staff { PScore *pscore_l_; String define_spot_str_; - /****************************************************************/ + /* *************************************************************** */ void add(PointerList &s); void do_commands(PointerList score_wide, @@ -34,10 +34,10 @@ struct Staff { Paperdef*paper()const; /// interpret all requests and add items to #destination#. - void process(); /** This routines calls virtual functions from Staff, to delegate the interpretation of requests to a derived class of Staff */ + void process(); void setup_staffcols(); @@ -51,13 +51,13 @@ struct Staff { /// remove unused cols void clean_cols() ; - Staff_column * get_col(Moment,bool); + Staff_column *get_col(Moment,bool); // ugh Staff(); - /**************************************************************** + /* VIRTUALS - ****************************************************************/ + */ virtual void set_output(PScore * destination)=0; virtual void walk()=0; diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh index 1a25b9bdb4..1caead811e 100644 --- a/hdr/staffcommands.hh +++ b/hdr/staffcommands.hh @@ -14,7 +14,7 @@ struct Staff_commands_at : public IPointerList { Time_description tdescription_; - /****************/ + /* *************** */ bool is_breakable(); Moment when(); diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh index ba3df695bf..3928c994e9 100644 --- a/hdr/staffelem.hh +++ b/hdr/staffelem.hh @@ -11,6 +11,12 @@ #include "offset.hh" #include "molecule.hh" +/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend + on other Staff_elem's, eg, Beam needs to know and set direction of + Stem. So the Beam has to be calculated *before* Stem. This is + accomplished with the dependencies field of struct Staff_elem. + + */ struct Staff_elem { enum Status { ORPHAN, // not yet added to pstaff @@ -25,7 +31,7 @@ struct Staff_elem { /// the pstaff it is in PStaff *pstaff_l_; - /****************/ + /* *************** */ Staff_elem(Staff_elem const&); String TeXstring () const ; virtual void print() const; @@ -65,21 +71,14 @@ private: /// member: the symbols Molecule *output; // should scrap, and use temp var? - /// - Offset offset_; + /** This is needed, because #output# may still be NULL. */ + Offset offset_; Array dependencies; }; -/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend - on other Staff_elem's, eg, Beam needs to know and set direction of - Stem. So the Beam has to be calculated *before* Stem. This is - accomplished with the dependencies field of struct Staff_elem. - - */ - #define NAME_METHOD(c) const char *c::name()const{ return #c; } struct c #endif // STAFFELEM_HH diff --git a/hdr/staffline.hh b/hdr/staffline.hh index f44754a5d2..9fbe3ec917 100644 --- a/hdr/staffline.hh +++ b/hdr/staffline.hh @@ -20,7 +20,7 @@ struct Line_of_staff { Line_of_score * line_of_score_l_; PStaff *pstaff_l_; - /****************/ + /* *************** */ String TeXstring() const; Line_of_staff(Line_of_score*, PStaff *); diff --git a/hdr/staffsym.hh b/hdr/staffsym.hh new file mode 100644 index 0000000000..294a0218a0 --- /dev/null +++ b/hdr/staffsym.hh @@ -0,0 +1,30 @@ +/* + staffsym.hh -- declare Staff_symbol + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STAFFSYM_HH +#define STAFFSYM_HH +#include "spanner.hh" +/** + This spanner draws the lines of a pstaff. + The bottom line is position 0. + */ +class Staff_symbol : public Spanner +{ +public: + /// this many lines. + int no_lines_i_; + + const char *name()const; + Staff_symbol(int lines); + virtual Molecule* brew_molecule_p() const; + void set_extent(PCol* p1, PCol* p2); + virtual void do_print()const; + virtual Spanner *do_break_at( PCol *c1, PCol *c2) const; +}; +#endif // STAFFSYM_HH diff --git a/hdr/staffwalker.hh b/hdr/staffwalker.hh index efac63e7b0..3b78c29c6b 100644 --- a/hdr/staffwalker.hh +++ b/hdr/staffwalker.hh @@ -10,13 +10,17 @@ #include "staff.hh" +/** + manage run-time info when walking staffcolumns such as: key, + meter, pending beams & slurs + */ struct Staff_walker : public PCursor { Staff * staff_l_; PScore * pscore_l_; int break_status; - /****************/ + /* *************** */ int priority() const; // Command Moment when() const; @@ -26,9 +30,9 @@ struct Staff_walker : public PCursor { void process_command(Command *); void operator++(int); - /**************** + /* *************** VIRTUAL - ****************/ + *************** */ /// every time ++ is called virtual void do_pre_move(){} @@ -39,10 +43,6 @@ struct Staff_walker : public PCursor { private: Staff_walker(Staff_walker const&); }; -/** - manage run-time info when walking staffcolumns such as: key, - meter, pending beams & slurs - */ #endif // STAFFWALKER_HH diff --git a/hdr/stcol.hh b/hdr/stcol.hh index 0984f88022..0ae5244d8a 100644 --- a/hdr/stcol.hh +++ b/hdr/stcol.hh @@ -1,5 +1,5 @@ /* - stcol.hh -- part of LilyPond + stcol.hh -- declare Staff_column (c) 1996,97 Han-Wen Nienhuys */ @@ -23,22 +23,22 @@ struct Staff_column { Time_description *tdescription_; - /****************/ + /* *************** */ - Staff_column(Score_column*s); - bool mus() const; + Staff_column(Score_column*); + bool musical_b() const; Moment when() const; void add(Voice_element*ve); void OK() const; - /**************************************************************** + /* VIRTUAL - ****************************************************************/ + */ virtual void setup_requests()=0; virtual ~Staff_column(); private: - Staff_column(Staff_column const&){} + Staff_column(Staff_column const&); }; diff --git a/hdr/stem.hh b/hdr/stem.hh index e4c3794a8c..962d1f4ba3 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -11,6 +11,16 @@ #include "moment.hh" /// the rule attached to the ball +/** + takes care of: + + \begin{itemize} + \item the rule + \item the flag + \item up/down position. + \end{itemize} + */ + struct Stem : Item { /* /// rhythmical length @@ -29,27 +39,27 @@ struct Stem : Item { int staff_center; // extent of the stem (positions) - Real bot, top; /** fractional, since Beam has to adapt them. */ + Real bot, top; 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 */ + int dir; Real stem_xoffset; Array heads; - /****************/ + /* *************** */ Stem(int center); //, Moment duration); /// ensure that this Stem also encompasses the Notehead #n# @@ -70,14 +80,4 @@ struct Stem : Item { Molecule* brew_molecule_p() const; }; -/** - takes care of: - - \begin{itemize} - \item the rule - \item the flag - \item up/down position. - \end{itemize} - */ - #endif diff --git a/hdr/stembeamreg.hh b/hdr/stembeamreg.hh new file mode 100644 index 0000000000..3d9d6026df --- /dev/null +++ b/hdr/stembeamreg.hh @@ -0,0 +1,32 @@ +/* + stembeamreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STEMBEAMREG_HH +#define STEMBEAMREG_HH +#include "register.hh" + +struct Stem_beam_register : Request_register { + Stem * stem_p_; + Beam * beam_p_; + Beam_req * beam_req_l_; + Stem_req * stem_req_l_; + Beam_req * start_req_l_; + bool end_beam_b_; + Rhythmic_grouping *current_grouping; + int default_dir_i_; + + /* *************** */ + Stem_beam_register(Complex_walker*); + ~Stem_beam_register(); + void set_dir(int dir_i_); + virtual bool try_request(Request*); + virtual void process_request(); + virtual void acknowledge_element(Staff_elem_info); + virtual void do_pre_move_process(); + virtual void do_post_move_process(); +}; +#endif // STEMBEAMREG_HH diff --git a/hdr/tex.hh b/hdr/tex.hh index c33f30e202..baff1c634d 100644 --- a/hdr/tex.hh +++ b/hdr/tex.hh @@ -6,14 +6,14 @@ #include "scalar.hh" /// parameter substitution in TeXstrings -String -substitute_args(String source, Array args); /** - this structure provides a simple macro mechanism: + this function provides a simple macro mechanism: if source == "tex%bla%", then - eval({"X","Y"}) == "texXblaY" + substitute_args(source, {"X","Y"}) == "texXblaY" */ +String +substitute_args(String source, Array args); /// parameter substitution in TeXstrings String diff --git a/hdr/textdef.hh b/hdr/textdef.hh index 4e95c93a6e..8100ed45d8 100644 --- a/hdr/textdef.hh +++ b/hdr/textdef.hh @@ -17,7 +17,7 @@ struct Text_def { char const* defined_ch_c_l_m; - /*****************/ + /* ****************/ virtual ~Text_def() {}; bool compare(const Text_def&); Text_def(); diff --git a/hdr/textitem.hh b/hdr/textitem.hh index c563fc80ca..c7df9069d9 100644 --- a/hdr/textitem.hh +++ b/hdr/textitem.hh @@ -16,7 +16,7 @@ struct Text_item : Item { int dir_i_; Text_def* tdef_l_; - /****************/ + /* ***************/ const char * name() const; virtual void set_default_pos(); Molecule* brew_molecule_p() const; diff --git a/hdr/textreg.hh b/hdr/textreg.hh new file mode 100644 index 0000000000..3dd2172335 --- /dev/null +++ b/hdr/textreg.hh @@ -0,0 +1,23 @@ +/* + textreg.hh -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef TEXTREG_HH +#define TEXTREG_HH +#include "register.hh" + +struct Text_register : Request_register{ + Text_item * text_p_; + int dir_i_; + /* *************** */ + void set_dir(int dir_i); + Text_register(Complex_walker*); + virtual bool try_request(Request*); + virtual void process_request(); + virtual void do_pre_move_process(); +}; + +#endif // TEXTREG_HH diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh index 8bfb9aab6b..40ae5ffa64 100644 --- a/hdr/textspanner.hh +++ b/hdr/textspanner.hh @@ -12,26 +12,25 @@ #include "textdef.hh" /// a spanner which puts texts on top of other spanners. +/** + Use for triplets, eentweetjes, ottava, etc. + */ struct Text_spanner : Spanner { Text_def spec; - Offset tpos; + Offset text_off_; Directional_spanner*support; - /****************/ + /* *************** */ const char * name() const; virtual void do_pre_processing(); virtual void do_post_processing(); - Molecule* brew_molecule_p()const; virtual Interval height() const ; - void do_print() const; + virtual Molecule* brew_molecule_p()const; + virtual void do_print() const; virtual Spanner* do_break_at(PCol*,PCol*)const; Text_spanner(); void set_support(Directional_spanner*); }; -/** - Use for triplets, eentweetjes, ottava, etc. - */ - #endif // TEXTSPANNER_HH diff --git a/hdr/timedescription.hh b/hdr/timedescription.hh index 5fb7749793..4eb5db1194 100644 --- a/hdr/timedescription.hh +++ b/hdr/timedescription.hh @@ -29,7 +29,7 @@ struct Time_description { /// idem int bars; - /****************/ + /* *************** */ void set_cadenza(bool); void OK() const; Time_description(Moment, const Time_description*); diff --git a/hdr/tstream.hh b/hdr/tstream.hh index e75d27a4b3..27ec95cd16 100644 --- a/hdr/tstream.hh +++ b/hdr/tstream.hh @@ -5,6 +5,11 @@ #include "string.hh" /// TeX output +/** + Use this class for writing to a TeX file. + It counts braces to prevent nesting errors, and + it will add a comment sign before each newline. + */ struct Tex_stream { bool outputting_comment; ostream *os; @@ -21,9 +26,4 @@ struct Tex_stream { private: Tex_stream(Tex_stream const&); }; -/** - Use this class for writing to a TeX file. - It counts braces to prevent nesting errors, and - it will add a comment sign before each newline. - */ #endif diff --git a/hdr/voice.hh b/hdr/voice.hh index 03ea55b9ee..20538ae861 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -6,11 +6,18 @@ #include "moment.hh" /// class for horizontal stuff. +/** + + Voice is a ordered row of Voice_elements. It is strictly horizontal: + you cannot have two rhythmic elements running parallel in a Voice + + */ + struct Voice { IPointerList elts; Moment start; - /****************/ + /* *************** */ Moment when(const Voice_element*)const; Moment last() const; Voice(); @@ -19,21 +26,16 @@ struct Voice { void print() const; void set_default_group(String id); }; -/** - - Voice is a ordered row of Voice_elements. It is strictly horizontal: - you cannot have two rhythmic elements running parallel in a Voice - - */ - /// one horizontal bit. +/** Apart from being a container for the requests, Voice_element is nothing + */ struct Voice_element { Moment duration; char const* defined_ch_c_l_m; const Voice *voice_l_; IPointerList reqs; - /****************/ + /* *************** */ void add(Request*); Voice_element(); @@ -41,6 +43,4 @@ struct Voice_element { void print ()const; void set_default_group(String id); }; -/** Apart from being a container for the requests, Voice_element is nothing - */ #endif diff --git a/hdr/voicegroup.hh b/hdr/voicegroup.hh index a6f370ec80..2240433c46 100644 --- a/hdr/voicegroup.hh +++ b/hdr/voicegroup.hh @@ -8,21 +8,21 @@ #define VOICEGROUP_HH #include "proto.hh" -#include "register.hh" -#include "varray.hh" #include "string.hh" struct Voice_registers { - Notehead_register head_reg_; - Slur_register slur_reg_; + Notehead_register *head_reg_; + Slur_register *slur_reg_; Voice *voice_l_; - /****************/ + /* *************** */ + void set_dir(int i); static bool acceptable_request(Request*); void pre_move_processing(); void post_move_processing(); - void announce_element(Staff_elem_info info); + void acknowledge_element(Staff_elem_info info); Voice_registers(Complex_walker*,Voice*); + ~Voice_registers(); bool try_request(Request*); void process_requests(); }; @@ -30,18 +30,20 @@ struct Voice_registers { struct Voice_group_registers { String group_id_str_; - Text_register text_reg_; - Stem_beam_register stem_beam_reg_; - Script_register script_reg_; + Text_register* text_reg_; + Stem_beam_register* stem_beam_reg_; + Script_register *script_reg_; Complex_walker * walk_l_; int dir_i_; - /****************/ + /* *************** */ + void set_dir(int i); static bool acceptable_request(Request*); void pre_move_processing(); void post_move_processing(); - void announce_element(Staff_elem_info info); + void acknowledge_element(Staff_elem_info info); Voice_group_registers(Complex_walker*, String id = ""); + ~Voice_group_registers(); void process_requests(); bool try_request(Request*); }; diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini index e87778753c..7c61810970 100644 --- a/init/table_sixteen.ini +++ b/init/table_sixteen.ini @@ -77,7 +77,7 @@ symboltables { "||" "\finishbar" 0pt 2pt -8pt 8pt ":|" "\repeatbar" -4pt 0pt -8pt 8pt "|:" "\startrepeat" 0pt 4pt -8pt 8pt - ":|:" "\repeatbarstartrepeat" 0pt 8pt -8pt 8pt + ":|:" "\repeatbarstartrepeat" 0pt 16pt -8pt 8pt } @@ -101,6 +101,8 @@ symboltables { "linestaf" "\linestafsym{%}{%}" "stem" "\stem{%}{%}" "fill" "\hbox{}" + "crescendo" "\crescendosym{%}" 0pt 0pt -3pt 3pt + "decrescendo" "\decrescendosym{%}" 0pt 0pt -3pt 3pt } "dots" = table { diff --git a/input/error.ly b/input/error.ly index 9aa92d0710..82e5d190c6 100644 --- a/input/error.ly +++ b/input/error.ly @@ -13,6 +13,7 @@ mwa = music { a b ,c a b c-* a b c& + { a-. b-. } $ } @@ -22,6 +23,9 @@ bla = music { @ } + +include "this-is-hopefully-a-nonexisting-file" + score { staff { lyric music { bla } diff --git a/input/maartje.ly b/input/maartje.ly index aad85a0fc6..0f96005edf 100644 --- a/input/maartje.ly +++ b/input/maartje.ly @@ -65,7 +65,7 @@ score { geometric 1.4 unitspace 3.0 cm } - staff { ritme } +% staff { ritme }%broken for now staff { melody } commands { meter 4* 4 diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index d9b570bf0b..2e7358db48 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -69,7 +69,7 @@ ii_menuetto = music { %%11 % { a4\stemup( f2\stemdown } ) 'd4\stemup % { 'cis4\stemup-. e4\stemdown } - { \music { a4 'd4 'cis4-. } \music { f2 e4 } } | + { \multivoice \music {\stem{1} a4(\stem{1}) 'd4 'cis4-. } \music { \stem{-1} f2 e4 } } | %%12 % { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] | { [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] | @@ -77,7 +77,10 @@ ii_menuetto = music { % { bes2\stemup g4\stemdown } ( ) f4 % { 'c4\stemup e4\stemdown } % { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" | - { \music { bes2 'c4 } \music { g4 f4 e4 } } | + { \multivoice + \music { \stem{1} bes2 'c4 } + \music { \stem{-1} g4(\stem{-1}) f4 e4 }% ugh + } | %%%14 %% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } | { [ a f } g a f ] { 'd4-\upbow e4 `bes4 } | @@ -104,7 +107,7 @@ ii_menuetto = music { %%%21 %% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } | % { 'd4 g2 } 'cis4 { 'd4 f4 } | - { \music { 'd4 'cis4 'd4 } \music { g2 f4 } } | + { \multivoice \music {\stem{1} 'd4(\stem{1} ) 'cis4 'd4 } \music { \stem{-1} g2 f4 } } | %%%22 %% [ { g( cis } )f g e ] { f4 d4 } | { [ g cis } f g e ] { f4 d4 } | @@ -146,160 +149,8 @@ score { symboltables { table_sixteen } width 195mm % unitspace 12mm % this should do, really - unitspace 8mm % to get lily to use only three lines - output "scsii-menuetto.out" - } -} -% scsii-menuetto.ly -% -% Solo Cello Suites -% J. S. Bach -% -% Suite II part v -% Menuetto I -% -% Copyright (c) 1995,1996,1997 Jan Nieuwenhuizen -% -% The purpose of this file is to demonstrate features of LilyPond. -% (there is an accompanying LaTeX file, scsii-menuetto.tex) -% - -% \lefttitle{Menuetto} -% \tempo{Moderato} -% \metron{4=120} -% -% \meter{3/4} -% \key\F % key is F ( f-major ) -% \clef\alto % use alto clef -% \duration8 % default duration is 'eight note -% -% \verb{\nobarnumbers} % issue MusiXTeX command -% \barnumbering0 -% \slope{30} % Fool MusiXTeX into 30 / 10 steeper beam -% \stemlength3 % shorter stemlength -% % because piece is set very tightly -%%1 % double comments are included in .tex file -ii_menuetto = music { - $ - \octave{} - \duration{8} - { a2 f2 d2_"\f" } bes4-. | -%%2 - { [ bes^"1" e c_"2"_"4" } -% (^ ) - a bes-. g-. ] a4-.^"4" | -%%3 -% { d4 `bes4-.\stemup } stemup: 2 voices? - { d4 `bes4-. } g4-. [ f-. e-. ] | -%%4 -% { f `a } (^ e ) d cis-. `b-. `a-. ] -% [ f ( e ) d cis-. `b-. `a-. ] - { [ f `a } e d cis-. `b-. `a-. ] -%%5 - { a2 f2 d2 } bes4-. | % @bes4-. | -%%6 -% { bes( e } ) a - { [ bes e } a bes-. g-. ] - 'c4-. | % ='c4-. | -%%7 - { a4-. f4} -% { 'd4-.-\upbow f4 `bes4\stemdown } - { 'd4-.-\upbow f4 `bes4 } -% { 'e4-.-\downbow g4 `g4\stemdown } | - { 'e4-.-\downbow g4 `g4 } | -%%8 -% { 'cis2.-\upbow e2. `a2.\stemdown } :||: - { 'cis2.-\upbow e2. `a2. } | % :||: -%%9 -% \clef "violin" -% { 'e2 a2_f\stemdown } - { 'e2 a2_"\f" } - [ 'd( 'e16 )'f16 ] | -%%10 -% [ { 'e( g } ) 'd 'cis_{ }_{ }_2 'e - { [ 'e g } 'd 'cis_"2" 'e a( )g ] | -%%11 -% { a4\stemup( f2\stemdown } ) 'd4\stemup -% { 'cis4\stemup-. e4\stemdown } - { \music { a4 'd4 'cis4-. } \music { f2 e4 } } | -%%12 -% { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] | - { [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] | -% %13 -% { bes2\stemup g4\stemdown } ( ) f4 -% { 'c4\stemup e4\stemdown } -% { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" | - { \music { bes2 'c4 } \music { g4 f4 e4 } } | -%%%14 -%% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } | - { [ a f } g a f ] { 'd4-\upbow e4 `bes4 } | -%%%15 -%% { 'c4-\downbow f4 `a4\stemdown } [ bes( )a g a ] | -% { 'c4-\downbow f4 `a4 } [ bes( )a g a ] | -%%%16 - [ f( e )f a-. g-. bes-. ] | -%% \tighten % use one line less -%% \newline % start new line -%% | -%%%17 -%% { a2^0^\tr fis2_3 } bes4 | - { a2^"0" fis2_"3" } bes4 | -%%%18 -%% [ { 'c( es } ) bes 'c a ] fis4^\tr | - { [ 'c es } bes 'c a ] fis4 | -%%%19 -%% { 'd4-\downbow g4 `bes4\stemdown } { 'c4-\upbow g4 c4\stemdown } [ { bes d } a ] | - { 'd4-\downbow g4 `bes4 } { 'c4-\upbow g4 c4 } { [ bes d } a ] | -%%%20 -%% [ { 'c( d `g } bes a ) bes g ( ) bes ] | - { [ 'c d `g } bes a bes g( )bes ] | -%%%21 -%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } | -% { 'd4 g2 } 'cis4 { 'd4 f4 } | - { \music { 'd4 'cis4 'd4 } \music { g2 f4 } } | -%%%22 -%% [ { g( cis } )f g e ] { f4 d4 } | - { [ g cis } f g e ] { f4 d4 } | -%%%23 -%% [ `g g ] { e4.\stemup^\tr `a4.\stemdown } d\stemup-\upbow | - [ `g g ] { e4. `a4. } d-\upbow | -%%%24 -%% { d2.^{fine} `a2. `d2.\stemup_{ }_{ }_{3 mins.}} s4 :|| -%% { \textstyle "italic" d2.^"fine" `a2. \textstyle "roman" `d2._"3 mins."} | % :|| - { d2.^"fine" `a2. `d2._"3 mins."} | % :|| -%% \tighten % use one line less - $ -} - -score { - staff { - melodic - music { ii_menuetto } - commands { - key $bes$ - clef "alto" - skip 8:0 - clef "violin" - skip 5:0 - clef "alto" - skip 12:0 - } - } - commands { - meter 3*4 - skip 8:0 - bar ":|:" -% clef "violin" - skip 5:0 -% \clef "alto" - skip 12:0 - bar ":||" - } - paper { - symboltables { table_sixteen } - width 195mm -% unitspace 12mm % this should do, really - unitspace 8mm % to get lily to use only three lines + unitspace 9mm % to get lily to use only three lines + geometric 1.4 output "scsii-menuetto.out" } } diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index ae48f898cc..aa8120ade8 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -7,7 +7,7 @@ dux = music { $ \duration { \last } - \stem{-1} r8 ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] | + r8-"dux" \stem{-1} ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] | [g 'c16 b] ['c8 'd] [f16 g] as4 [g16 f] | [es 'c b a] [ g f es d] [c8 'es 'd 'c] | [bes a bes 'c] [fis g a fis] | @@ -21,7 +21,7 @@ comes = music { $ r1 r1 \stem{1} \octave {'} - r8 [g16 fis] [g8 c] [es g16 f] [g8 a]| + r8-"comes" [g16 fis] [g8 c] [es g16 f] [g8 a]| [d8 g16 fis] [g8 a] [c16 d] es4 [d16 c] | [`bes8 es16 d] [es8 `g8] [`as f16 es] [f8 `a] | [`bes8 g16 f] [g8 `b] [c8 d16 es] f4( | @@ -32,8 +32,8 @@ $} bassdux = music { $ r1 r1 r1 r1 r1 r1 - \stem{1} \octave { } - r8 [c16 B] [c8 G] [As c16 Bes] [c8 d] | + \octave { } + r8 [c16 B] [c8 G] [As c16 B] [c8 d] | [G c16 B] [c8 d] [F16 G] As4 [G16 F] | $ } @@ -62,7 +62,7 @@ score { meter 4*4 skip 8:0 } - paper { unitspace 2.5cm - geometric 1.1 + paper { %unitspace 2.5cm + %geometric 1.4 } } \ No newline at end of file diff --git a/lilyponddefs.tex b/lilyponddefs.tex index fd0d0ed0ba..586aabb88d 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -71,8 +71,8 @@ } \def\musixcalc{ - \interlinedist=\fontdimen5\musicfnt - \smallspace=.3\interlinedist + \interlinedist=\fontdimen5\musicfnt + \smallspace=.3\interlinedist \interstaffrule=\balkhoog \advance\interstaffrule by-\staffrulethickness \divide\interstaffrule by 4 @@ -245,6 +245,7 @@ \def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}} \def\rulesym#1#2{\vrule height #1 width #2} - +\def\crescendosym#1{\count0=84\advance\count0 by #1} +\def\decrescendosym#1{\count0=116\advance\count0 by #1} \def\settext#1{\textfont #1} \def\setitalic#1{\italicfont #1} diff --git a/src/beam.cc b/src/beam.cc index 02e3d3d94f..f31a15d017 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -21,7 +21,6 @@ struct Stem_info { Real miny; int no_beams; - /////////////// Stem_info(){} Stem_info(const Stem*); @@ -37,7 +36,7 @@ Stem_info::Stem_info(const Stem*s) } -/****************/ +/* *************** */ Offset Beam::center()const @@ -45,7 +44,7 @@ Beam::center()const assert(status >= POSTCALCED); Real w=(paper()->note_width() + width().length())/2.0; - return Offset(w, (left_pos + w* slope)*paper()->interline()); + return Offset(w, (left_pos + w* slope)*paper()->internote()); } @@ -53,7 +52,6 @@ Beam::Beam() { slope = 0; left_pos = 0.0; - dir =0; } void @@ -73,9 +71,9 @@ Beam::set_default_dir() int d = i->get_default_dir(); dirs[(d+1)/2] ++; } - dir = (dirs[0] > dirs[1]) ? -1 : 1; + dir_i_ = (dirs[0] > dirs[1]) ? -1 : 1; for (iter_top(stems,i); i.ok(); i++) { - i->dir = dir; + i->dir = dir_i_; } } @@ -108,12 +106,12 @@ Beam::solve_slope() dy = my -y; } left_pos += dy; - left_pos *= dir; - slope *= dir; + left_pos *= dir_i_; + slope *= dir_i_; // URG Real sl = slope*paper()->internote(); - paper()->lookup_p_->beam(sl, convert_dimen(20,"pt")); + paper()->lookup_p_->beam(sl, 20 PT); slope = sl /paper()->internote(); } @@ -184,7 +182,7 @@ Beam::do_pre_processing() left = (*stems.top()) ->pcol_l_; right = (*stems.bottom())->pcol_l_; assert(stems.size()>1); - if (!dir) + if (!dir_i_) set_default_dir(); } @@ -209,7 +207,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const Real dy=paper()->internote()*2; Real stemdx = paper()->rule_thickness(); Real sl = slope*paper()->internote(); - paper()->lookup_p_->beam(sl, convert_dimen(20,"pt")); + paper()->lookup_p_->beam(sl, 20 PT); Molecule leftbeams; Molecule rightbeams; @@ -223,7 +221,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const a.translate(Offset (-w, -w * sl)); for (int j = 0; j < lhalfs; j++) { Atom b(a); - b.translate(Offset(0, -dir * dy * (lwholebeams+j))); + b.translate(Offset(0, -dir_i_ * dy * (lwholebeams+j))); leftbeams.add( b ); } } @@ -238,7 +236,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const int j = 0; for (; j < rwholebeams; j++) { Atom b(a); - b.translate(Offset(0, -dir * dy * j)); + b.translate(Offset(0, -dir_i_ * dy * j)); rightbeams.add( b ); } w /= 4; @@ -246,7 +244,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const for (; j < rwholebeams + rhalfs; j++) { Atom b(a); - b.translate(Offset(0, -dir * dy * j)); + b.translate(Offset(0, -dir_i_ * dy * j)); rightbeams.add(b ); } diff --git a/src/calcideal.cc b/src/calcideal.cc index 7fcf65d762..7ec06433e9 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -1,15 +1,13 @@ #include "idealspacing.hh" -#include "tstream.hh" #include "score.hh" #include "pscore.hh" -#include "staff.hh" #include "paper.hh" #include "sccol.hh" -#include "debug.hh" +//#include "debug.hh" #include "dimen.hh" -/* +/** this needs A LOT of rethinking. generate springs between columns. @@ -28,18 +26,14 @@ Score::calc_idealspacing() for (int n=0; n < i->durations.size(); n++) { Moment d = i->durations[n]; Real dist = paper_p_->duration_to_dist(d); + Real strength = i->durations[0]/i->durations[n]; + assert(strength <= 1.0); + while (j->when() < d + i->when()) j++; assert( j->when()== d+i->when()); - pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); -#if 0 - if (!j->musical_ && (j+1).ok() - && ) { - j++; - pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist); - } -#endif + pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, strength); } } else if (j.ok()) { @@ -48,8 +42,7 @@ Score::calc_idealspacing() */ Moment d = j->when() - i->when(); - Real dist = (d) ? paper_p_->duration_to_dist(d) : - convert_dimen(2,"pt"); // todo + Real dist = (d) ? paper_p_->duration_to_dist(d) : 2 PT; // todo pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0); } diff --git a/src/clef.cc b/src/clef.cc index d0fcbe09d9..bf7b924159 100644 --- a/src/clef.cc +++ b/src/clef.cc @@ -1,23 +1,32 @@ +/* + clef.cc -- implement Clef + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys , + Mats Bengtsson +*/ + #include "clef.hh" +#include "debug.hh" Clef::Clef() { - clef_type= "violin"; - c0_pos = -2; + set_type("violin"); } -void -Clef::read(Arrayargs) +void +Clef::set_type(String type_str) { - clef_type = args[0]; - if (clef_type == "violin") { - c0_pos=-2; - } else if (clef_type == "alto") { - c0_pos = 4; - } else if (clef_type == "tenor") { - c0_pos = 6; - } else if (clef_type == "bass") { - c0_pos = 10; + clef_type_str_ = type_str; + if (clef_type_str_ == "violin") { + c0_position_i_= -2; + } else if (clef_type_str_ == "alto") { + c0_position_i_= 4; + } else if (clef_type_str_ == "tenor") { + c0_position_i_= 6; + } else if (clef_type_str_ == "bass") { + c0_position_i_= 10; } else - assert(false); + error("unknown clef type `"+clef_type_str_+"\'"); } diff --git a/src/clefitem.cc b/src/clefitem.cc index 2b451a804d..0e0054acd3 100644 --- a/src/clefitem.cc +++ b/src/clefitem.cc @@ -29,7 +29,7 @@ Clef_item::read(String t) void Clef_item::read(Clef k) { - read(k.clef_type); + read(k.clef_type_str_); } Molecule* @@ -40,7 +40,7 @@ Clef_item::brew_molecule_p()const t += "_change"; Symbol s = paper()->lookup_p_->clef(t); Molecule*output = new Molecule(Atom(s)); - output->translate(Offset(0, paper()->interline()/2 * y_off)); + output->translate(Offset(0, paper()->internote() * y_off)); return output; } diff --git a/src/complexprint.cc b/src/complexprint.cc index 372d86db10..ec38b575e1 100644 --- a/src/complexprint.cc +++ b/src/complexprint.cc @@ -6,7 +6,7 @@ #include "complexstaff.hh" #include "sccol.hh" #include "debug.hh" -#include "linepstaff.hh" + #include "clefitem.hh" #include "bar.hh" #include "meter.hh" @@ -38,7 +38,7 @@ Complex_staff::get_TYPESET_item(Command *com) Interval -citemlist_width(const Array &its) +itemlist_width(const Array &its) { Interval iv ; iv.set_empty(); @@ -56,14 +56,14 @@ Complex_column::typeset_item(Item *i, int breakst) assert(i); staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, - staff_l_->theline_l_,breakst); + staff_l_->pstaff_l_,breakst); if (breakst == BREAK_PRE - BREAK_PRE) { Array to_move( - staff_l_->pscore_l_->select_items(staff_l_->theline_l_, + staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_, score_column_l_->pcol_l_->prebreak_p_)); - Interval column_wid = citemlist_width(to_move); + Interval column_wid = itemlist_width(to_move); assert(!column_wid.empty()); for (int j=0; j < to_move.size(); j++) { @@ -84,22 +84,22 @@ Complex_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH! else if (breakst == 2) c = c->postbreak_p_; - Array to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_, + Array to_move(staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_, c)); typeset_item(i, breakst); - Interval column_wid = citemlist_width(to_move); + Interval column_wid = itemlist_width(to_move); if (column_wid.empty()) column_wid = Interval(0,0); i->translate(Offset(column_wid[dir] - i->width()[-dir], 0)); } void -Complex_staff::set_output(PScore* ps ) +Complex_staff::set_output(PScore* pscore_l ) { - theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later. - pscore_l_ = ps; - pscore_l_->add(theline_l_); + pstaff_l_ = new PStaff(pscore_l); // pstaff_l_ is added to pscore later. + pscore_l_ = pscore_l; + pscore_l_->add(pstaff_l_); } diff --git a/src/complexstaff.cc b/src/complexstaff.cc index 7e21bf2252..d5d44362d9 100644 --- a/src/complexstaff.cc +++ b/src/complexstaff.cc @@ -8,19 +8,20 @@ #include "complexstaff.hh" #include "sccol.hh" #include "complexwalker.hh" -#include "main.hh" +#include "score.hh" +#include "pscore.hh" +#include "staffsym.hh" - -Complex_column::Complex_column(Score_column*s, Complex_staff *rs) +Complex_column::Complex_column(Score_column*s, Complex_staff *staff_l) : Staff_column(s) { - staff_l_ = rs; + staff_l_ = staff_l; } Complex_staff::Complex_staff() { - theline_l_ = 0; + pstaff_l_ = 0; } void @@ -57,7 +58,21 @@ void Complex_staff::walk() { for (Complex_walker sc(this); sc.ok(); sc++) { - sc.col()->setup_requests();// TODO + sc.col()->setup_requests(); sc.process(); } + Staff_symbol *span_p = new Staff_symbol(5); + + + Score_column* col_last + =score_l_->find_col(score_l_->last(), false); + Score_column* col_first= + score_l_->find_col(0, false); + col_first->pcol_l_->set_breakable(); + col_last->pcol_l_->set_breakable(); + + span_p->set_extent( col_first->pcol_l_->postbreak_p_, + col_last->pcol_l_->prebreak_p_); + + pscore_l_->typeset_spanner(span_p, pstaff_l_); } diff --git a/src/complexwalker.cc b/src/complexwalker.cc index 378f486a08..ba8253205b 100644 --- a/src/complexwalker.cc +++ b/src/complexwalker.cc @@ -5,26 +5,49 @@ #include "clef.hh" #include "pscore.hh" #include "complexstaff.hh" -#include "sccol.hh" #include "debug.hh" #include "keyitem.hh" #include "clefitem.hh" #include "voicegroup.hh" -#include "register.hh" +#include "localkeyreg.hh" #include "complexwalker.hh" #include "misc.hh" +Rhythmic_grouping +parse_grouping(Array const &a) +{ + Array r; + Array grouplen_arr; + for (int i= 0 ; i < a.size()/2; ) { + r.push(a[i++]); + grouplen_arr.push(Moment(1,(int) a[i++])); + } + Moment here =0; + + Array children; + for (int i=0; i < r.size(); i++) { + + Moment last = here; + here += grouplen_arr[i] * Rational(r[i]); + children.push( + new Rhythmic_grouping(MInterval(last, here), r[i] )); + } + return Rhythmic_grouping(children); +} + void -Complex_walker::do_INTERPRET_command(Command*com) +Complex_walker::do_INTERPRET_command(Command*com_l) { - Array args(com->args); + Array args(com_l->args); args.del(0); - if (com->args[0] == "GROUPING") { + String com = com_l->args[0]; + + if (com == "GROUPING") { default_grouping = parse_grouping(args); - }else if (com->args[0] == "NEWMEASURE") { + }else if (com == "NEWMEASURE") { local_key_.reset(key_); - } else if (com->args[0] == "KEY") { + } else if (com == "KEY") { if (col()->when() > Moment(0)) { assert(!oldkey_undo); @@ -33,10 +56,10 @@ Complex_walker::do_INTERPRET_command(Command*com) typesetkey = key_.read(args); local_key_.reset(key_); - } else if (com->args[0] == "CLEF") { - clef_.read(args); + } else if (com == "CLEF") { + clef_.set_type(args[0]); } else { - WARN << " ignoring INTERPRET command: " << com->args[0]<< "\n"; + WARN << " ignoring INTERPRET command: " << com<< "\n"; } } @@ -101,17 +124,17 @@ Complex_walker::do_announces() for (int i = 0; i < announce_info_arr_.size(); i++){ Staff_elem_info info = announce_info_arr_[i]; for (iter_top(voice_reg_list_,j); j.ok(); j++) { - j->announce_element(info); + j->acknowledge_element(info); } for (iter_top ( group_reg_list_, j); j.ok(); j++) { - j->announce_element(info); + j->acknowledge_element(info); } local_key_reg_.acknowledge_element(info); } } Voice_registers * -Complex_walker::find_voice_reg(Voice*v_l) +Complex_walker::find_voice_reg(Voice*v_l)const { for (iter_top(voice_reg_list_, i); i.ok(); i++) { if (i->voice_l_ == v_l) @@ -133,7 +156,7 @@ Complex_walker::get_voice_reg(Voice*v_l) } Voice_group_registers * -Complex_walker::find_voice_group(Voice* v_l) +Complex_walker::find_voice_group(Voice* v_l)const { if (!voice_group_map_.elt_query(v_l)) return 0; @@ -141,7 +164,7 @@ Complex_walker::find_voice_group(Voice* v_l) } Voice_group_registers * -Complex_walker::find_voice_group(const char *id) +Complex_walker::find_voice_group(const char *id)const { for (iter_top(group_reg_list_, i); i.ok(); i++) if (i->group_id_str_ == id) @@ -176,7 +199,7 @@ Complex_walker::get_voice_group(const char* id) } void -Complex_walker::do_change_group(const Voice * v, String group_id_str) +Complex_walker::do_change_group(Voice * v, String group_id_str) { voice_group_map_[v] = get_voice_group(group_id_str); } @@ -196,12 +219,6 @@ Complex_walker::try_request(Request*req) } else if (Voice_group_registers::acceptable_request(req)){ Voice_group_registers* reg_l = get_voice_group(voice_l); b = reg_l->try_request(req); -#if 0 - if (!b) { - bool please_b = get_voice_group("")->try_request(req); - b |= please_b; - } -#endif } if (!b) @@ -243,13 +260,13 @@ Complex_walker::typeset_element(Staff_elem *elem_p) if (!elem_p) return; if (elem_p->spanner()) - pscore_l_->typeset_spanner(elem_p->spanner(), staff()->theline_l_); + pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_); else col()->typeset_item(elem_p->item()); } Complex_walker::Complex_walker(Complex_staff*s) - : Staff_walker(s, s->theline_l_->pscore_l_), + : Staff_walker(s, s->pstaff_l_->pscore_l_), local_key_reg_(this) { oldkey_undo = 0; @@ -294,3 +311,13 @@ Complex_walker::do_post_move() j->post_move_processing(); local_key_reg_.post_move_processing(); } + +Array +Complex_walker::get_voice_regs(Voice_group_registers* group_regs_l) const + return l_arr; +{ + for (Assoc_iter i(voice_group_map_); i.ok(); i++) { + if (i.val() == group_regs_l) + l_arr.push(find_voice_reg(i.key())); + } +} diff --git a/src/dimen.cc b/src/dimen.cc index eb53756b45..93077bd87b 100644 --- a/src/dimen.cc +++ b/src/dimen.cc @@ -15,7 +15,6 @@ parse_dimen(String dim) return convert_dimen(dim.fvalue(), unit); } -const Real CM_TO_PT=72/2.54; Real convert_dimen(Real quant, String unit) @@ -27,7 +26,7 @@ convert_dimen(Real quant, String unit) if (unit == "mm") return quant*CM_TO_PT/10; if (unit == "in") - return quant * 72; + return quant * INCH_TO_PT; error ("unknown length unit: `" + unit+"'"); } diff --git a/src/directionalspanner.cc b/src/directionalspanner.cc index 49bb67d725..e7ce9c7ddc 100644 --- a/src/directionalspanner.cc +++ b/src/directionalspanner.cc @@ -2,5 +2,5 @@ Directional_spanner::Directional_spanner() { - dir = 0; + dir_i_ = 0; } diff --git a/src/groupregs.cc b/src/groupregs.cc index 9367c92cd5..e69de29bb2 100644 --- a/src/groupregs.cc +++ b/src/groupregs.cc @@ -1,244 +0,0 @@ -#include "script.hh" -#include "request.hh" -#include "beam.hh" -#include "stem.hh" -#include "register.hh" -#include "grouping.hh" -#include "complexwalker.hh" -#include "debug.hh" -#include "complexstaff.hh" -#include "textspanner.hh" -#include "textitem.hh" - -Stem_beam_register::Stem_beam_register(Complex_walker*w) - :Request_register(w) -{ - do_post_move_process(); - current_grouping = 0; - beam_p_ = 0; - set_dir(0); - start_req_l_ = 0; -} - -bool -Stem_beam_register::try_request(Request*req_l) -{ - if ( req_l->beam() ) { - if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START)) - return false; - - if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam())) - return false; - - beam_req_l_ = req_l->beam(); - return true; - } - - if ( req_l->stem() ) { - if (current_grouping && !current_grouping->child_fit_query( - walk_l_->col()->tdescription_->whole_in_measure)) - return false; - - if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem())) - return false; - - stem_req_l_ = req_l->stem(); - return true; - } - return false; -} - -void -Stem_beam_register::process_request() -{ - if (beam_req_l_) { - if (beam_req_l_->spantype == Span_req::STOP) { - end_beam_b_ = true; - start_req_l_ = 0; - } else { - beam_p_ = new Beam; - start_req_l_ = beam_req_l_; -// walk_l_->announce_element(Staff_elem_info(beam_p_, )) - current_grouping = new Rhythmic_grouping; - if (beam_req_l_->nplet) { - Text_spanner* t = new Text_spanner(); - t->set_support(beam_p_); - t->spec.align_i_ = 0; - t->spec.text_str_ = beam_req_l_->nplet; - walk_l_->typeset_element(t); - } - - } - } - - if (stem_req_l_) { - stem_p_ = new Stem(4); - if (current_grouping) - current_grouping->add_child( - walk_l_->col()->tdescription_->whole_in_measure, - stem_req_l_->duration()); - - stem_p_->flag = stem_req_l_->balltype; - - if (beam_p_) { - if (stem_req_l_->balltype<= 4) - warning( "stem doesn't fit in Beam", - stem_req_l_->defined_ch_c_l_m); - else - beam_p_->add(stem_p_); - stem_p_->print_flag = false; - } else { - stem_p_->print_flag = true; - } - - walk_l_->announce_element(Staff_elem_info(stem_p_, - stem_req_l_, this)); - } -} - -void -Stem_beam_register::acknowledge_element(Staff_elem_info info) -{ - if (!stem_p_) - return; - - if (info.elem_p_->name() == String("Notehead") && - stem_req_l_->duration() == info.req_l_->rhythmic()->duration()) - - stem_p_->add((Notehead*)info.elem_p_); -} - -void -Stem_beam_register::do_pre_move_process() -{ - if (stem_p_) { - if (default_dir_i_) - stem_p_->dir = default_dir_i_; - - walk_l_->typeset_element(stem_p_); - stem_p_ = 0; - } - if (beam_p_ && end_beam_b_) { - walk_l_->default_grouping.extend(current_grouping->interval()); - beam_p_->set_grouping(walk_l_->default_grouping, *current_grouping); - walk_l_->typeset_element(beam_p_); - delete current_grouping; - current_grouping = 0; - beam_p_ = 0; - } - end_beam_b_ = false; -} -void -Stem_beam_register::do_post_move_process() -{ - stem_p_ = 0; - beam_req_l_ = 0; - stem_req_l_ = 0; - end_beam_b_ = false; -} - -Stem_beam_register::~Stem_beam_register() -{ - if (beam_p_) - warning("unterminated beam", start_req_l_->defined_ch_c_l_m); -} - -void -Stem_beam_register::set_dir(int i) -{ - default_dir_i_ = i; -} -/****************/ - -Script_register::Script_register(Complex_walker*w) - : Request_register(w) -{ - script_p_ = 0; -} - -bool -Script_register::try_request(Request *r_l) -{ - if (!r_l->script()) - return false ; - - if (accepted_req_arr_.size() - && Script_req::compare( - *accepted_req_arr_[0]->script(), *r_l->script())) - - return false; - - accepted_req_arr_.push(r_l); - - return true; -} -void -Script_register::process_request() -{ - if (accepted_req_arr_.size() ) { - script_p_ = new Script(accepted_req_arr_[0]->script(), 10); - walk_l_->announce_element( - Staff_elem_info(script_p_, accepted_req_arr_[0], this)); - } -} - -void -Script_register::acknowledge_element(Staff_elem_info info) -{ - if (!script_p_) - return; - if (info.elem_p_->name() == String("Stem")) - script_p_->set_stem((Stem*)info.elem_p_); - else if (info.req_l_->rhythmic()) - script_p_->set_support(info.elem_p_->item()); -} - -void -Script_register::do_pre_move_process() -{ - if (script_p_){ - walk_l_->typeset_element(script_p_); - script_p_ = 0; - } -} -/******************/ - - -Text_register::Text_register(Complex_walker*w) - : Request_register(w) -{ - text_p_ = 0; -} - -bool -Text_register::try_request(Request*req_l) -{ - if (!req_l->text()) - return false; - if (accepted_req_arr_.size() && - Text_req::compare(*req_l->text(), *accepted_req_arr_[0]->text())) - - return false; - - accepted_req_arr_.push(req_l); - return true; -} - -void -Text_register::process_request() -{ - - if (accepted_req_arr_.size()) { - text_p_ = new Text_item(accepted_req_arr_[0]->text(), 10); - walk_l_->announce_element(Staff_elem_info(text_p_, - accepted_req_arr_[0], this)); - } -} -void -Text_register::do_pre_move_process() -{ - if (text_p_) { - walk_l_->typeset_element(text_p_); - text_p_ = 0; - } -} diff --git a/src/headreg.cc b/src/headreg.cc new file mode 100644 index 0000000000..ecb24074fd --- /dev/null +++ b/src/headreg.cc @@ -0,0 +1,70 @@ +/* + headreg.cc -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ +#include "rest.hh" +#include "notehead.hh" +#include "headreg.hh" +#include "paper.hh" +#include "complexwalker.hh" + + +Notehead_register::Notehead_register(Complex_walker*w_l) + :Request_register(w_l) +{ + note_p_ = 0; + set_dir(0); +} + +bool +Notehead_register::try_request(Request *req_l) +{ + if (req_l->note() || req_l->rest()) + accepted_req_arr_.push(req_l); + else + return false; + + return true; +} +void +Notehead_register::set_dir(int d) +{ + dir_i_ = d; +} + +void +Notehead_register::process_request() +{ + if (!accepted_req_arr_.size()) + return; + + Request* req_l = accepted_req_arr_.top(); + if (req_l->note()) { + Notehead*n_p = new Notehead(8); // ugh + note_p_ = n_p; + n_p->set_rhythmic(req_l->rhythmic()); + n_p->position = req_l->note()->height() + + walk_l_->clef_.c0_position_i_; + } else { + note_p_ = new Rest ( req_l->rhythmic()->balltype, + req_l->rhythmic()->dots); + if (req_l->rhythmic()->balltype <= 2) + note_p_->translate( + Offset(0, + 6 * paper()->internote())); + } + Staff_elem_info itinf(note_p_,req_l,this); + announce_element(itinf); +} + +void +Notehead_register::do_pre_move_process() +{ + if (note_p_) { + if (dir_i_ && note_p_->name() == String("Rest")) + note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote())); + typeset_element(note_p_); + note_p_ = 0; + } +} diff --git a/src/inputcommands.cc b/src/inputcommands.cc index 0939387375..36e421c7b6 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -82,7 +82,7 @@ Commands_at::parse(Staff_commands_at*s) } } } -/****************/ +/* *************** */ void Input_cursor::find_moment(Moment w) @@ -118,7 +118,7 @@ Input_cursor::find_moment(Moment w) -/****************/ +/* *************** */ void Input_commands::find_moment(Moment m) { @@ -225,7 +225,7 @@ Input_commands::print() const } #endif } -/****************/ +/* *************** */ Moment Input_cursor::when()const diff --git a/src/inputmusic.cc b/src/inputmusic.cc index 4afb6f8556..447d84e41a 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -37,7 +37,7 @@ Simple_music::print() const mtor << "}\n"; } -/****************/ +/* *************** */ void Complex_music::add(Input_music*v) @@ -74,7 +74,7 @@ Complex_music::set_default_group(String g) for (iter_top(elts,i); i.ok(); i++) i->set_default_group(g); } -/****************************************************************/ +/* *************************************************************** */ void Music_voice::print() const @@ -134,7 +134,7 @@ Music_voice::translate_time(Moment t) -/****************/ +/* *************** */ void Music_general_chord::add_elt(Voice_element*v) @@ -180,7 +180,7 @@ Music_general_chord::convert()const return l; } -/****************/ +/* *************** */ void Multi_voice_chord::set_default_group(String g) @@ -193,7 +193,7 @@ Multi_voice_chord::set_default_group(String g) } -/****************/ +/* *************** */ void Voice_list::translate_time(Moment x) diff --git a/src/inputscore.cc b/src/inputscore.cc index ef684047c4..cb9086b1a3 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -26,6 +26,7 @@ Input_score::set(Paperdef*p) delete paper_; paper_ = p; } + Input_score::Input_score(Input_score const&) { assert(false); @@ -53,9 +54,7 @@ Input_score::parse() Input_score::~Input_score() { - // TODO! -//should fix paper/symtabs to allow this deletion. -// delete paper_; + delete paper_; } Input_score::Input_score() diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 27e9a55732..d79aac1021 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -5,12 +5,10 @@ #include "inputstaff.hh" #include "inputcommand.hh" #include "staffcommands.hh" -#include "melodicstaff.hh" -#include "rhythmstaff.hh" -#include "lyricstaff.hh" #include "staff.hh" #include "complexstaff.hh" #include "lexer.hh" +#include "lyricstaff.hh" void Input_staff::add(Array &s) @@ -37,13 +35,16 @@ Staff* Input_staff::parse(Score*score_l) { Staff *p=0; - +#if 0 if (type == "simple") p = new Melodic_staff; - else if (type == "melodic") - p = new Complex_staff; else if (type == "rhythmic") p = new Rhythmic_staff; + else +#endif + + if (type == "melodic") + p = new Complex_staff; else if (type == "lyric") p = new Lyric_staff; else diff --git a/src/keyitem.cc b/src/keyitem.cc index 017570d749..85bf74c620 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -8,7 +8,9 @@ const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ + NAME_METHOD(Keyitem); + Keyitem::Keyitem(int c) { c_position = c; @@ -28,7 +30,8 @@ Keyitem::read(Array s) void Keyitem::read(const Clef& c) { - c_position=(c.c0_pos+70)%7; + int octaves =(abs(c.c0_position_i_) / 7) +1 ; + c_position=(c.c0_position_i_ + 7*octaves)%7; } @@ -48,7 +51,7 @@ Molecule* Keyitem::brew_molecule_p()const { Molecule*output = new Molecule; - Real inter = paper()->interline()/2; + Real inter = paper()->internote(); for (int i =0; i < pitch.size(); i++) { Symbol s= paper()->lookup_p_->accidental(acc[i]); diff --git a/src/lexer.l b/src/lexer.l index 0771cafcde..f0652ac6c7 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -9,6 +9,7 @@ #include "parser.hh" #include "debug.hh" #include "inputscore.hh" +#include "parseconstruct.hh" #include "main.hh" %} @@ -220,7 +221,8 @@ include { [ \t]* { /* eat the whitespace */ } \"[^"]*\"+ { /* got the include file name */ String s (YYText()+1); - s = s.left(s.len()-1); + s = s.left(s.len()-1); + defined_ch_c_l = here_ch_c_l() - String( YYText() ).len() - 1; new_input(s); yy_pop_state(); } diff --git a/src/linepstaff.cc b/src/linepstaff.cc deleted file mode 100644 index ef2c55dfbc..0000000000 --- a/src/linepstaff.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "linepstaff.hh" -#include "molecule.hh" -#include "symbol.hh" -#include "lookup.hh" -#include "dimen.hh" -#include "paper.hh" -#include "pscore.hh" - -Linestaff::Linestaff(int l, PScore *s) - : PStaff(s) -{ - nolines = l; -} - -void -Linestaff::brew_molecule_p(Real width) -{ - Atom a = pscore_l_->paper_l_->lookup_p_->linestaff(nolines,width); - stafsym_p_ = new Molecule(a); -} - - - - - - - diff --git a/src/linespace.cc b/src/linespace.cc index b70e2a26f5..a7bfa1df9b 100644 --- a/src/linespace.cc +++ b/src/linespace.cc @@ -8,7 +8,7 @@ const Real COLFUDGE=1e-3; -//#define COLFUDGE 1e-3 + bool Spacing_problem::contains(const PCol *w) { @@ -239,7 +239,7 @@ Spacing_problem::print() const } -/*****************/ +/* **************** */ void Colinfo::print() const diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc index c61f1b91af..6fa9b1dfe3 100644 --- a/src/localkeyitem.cc +++ b/src/localkeyitem.cc @@ -45,9 +45,10 @@ Local_key_item::brew_molecule_p()const Molecule*octmol = 0; int lastoct = -100; for (int i = 0; i < accs.size(); i++) { + // do one octave if (accs[i].octave != lastoct) { if (octmol){ - Real dy =lastoct*7*paper()->interline()/2; + Real dy =lastoct*7*paper()->internote(); octmol->translate(Offset(0, dy)); output->add(*octmol); delete octmol; @@ -57,14 +58,14 @@ Local_key_item::brew_molecule_p()const lastoct = accs[i].octave; Symbol s =paper()->lookup_p_->accidental(accs[i].acc); Atom a(s); - Real dy = (accs[i].name + c0_position) * paper()->interline()/2; + Real dy = (accs[i].name + c0_position) * paper()->internote(); a.translate(Offset(0,dy)); octmol->add_right(a); } if (octmol){ - Real dy =lastoct*7*paper()->interline()/2; + Real dy =lastoct*7*paper()->internote(); octmol->translate(Offset(0, dy)); output->add(*octmol); delete octmol; diff --git a/src/localkeyreg.cc b/src/localkeyreg.cc new file mode 100644 index 0000000000..bbd4993022 --- /dev/null +++ b/src/localkeyreg.cc @@ -0,0 +1,58 @@ +/* + localkeyreg.cc -- implement Local_key_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "localkeyreg.hh" +#include "localkeyitem.hh" +#include "complexwalker.hh" + +Local_key_register::Local_key_register(Complex_walker*w) + : Request_register(w) +{ + key_item_p_ = 0; +} +bool +Local_key_register::try_request(Request*) + +{ + return false; +} + +void +Local_key_register::process_request() +{ +} +void +Local_key_register::do_pre_move_process() +{ + if (key_item_p_) { + walk_l_->typeset_element(key_item_p_); + key_item_p_ = 0; + } +} +void +Local_key_register::acknowledge_element(Staff_elem_info info) +{ + if (info.req_l_->melodic()) { + Melodic_req * melodic_l_ = info.req_l_->melodic(); + + if( melodic_l_->forceacc || + walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename) + != melodic_l_->accidental) { + Item * support_l_ = info.elem_p_->item(); + + + if (!key_item_p_) { + key_item_p_ = new Local_key_item(walk_l_->clef_.c0_position_i_); + key_item_p_->c0_position = walk_l_->clef_.c0_position_i_; + } + + key_item_p_->add(melodic_l_); + key_item_p_->add(support_l_); + walk_l_->local_key_.oct(melodic_l_->octave) + .set(melodic_l_->notename, melodic_l_->accidental); + } + } +} diff --git a/src/lookup.cc b/src/lookup.cc index be3466e092..96932e0023 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -42,7 +42,7 @@ Lookup::text(String style, String text, int dir) return s; } -/****************/ +/* *************** */ Real Lookup::internote() @@ -137,7 +137,21 @@ Lookup::streepjes(int i) return ret; } - +Symbol +Lookup::hairpin(Real &wid, bool decresc) +{ + int idx = rint(wid / 6 PT); + if(!idx) idx ++; + wid = idx*6 PT; + String idxstr = (decresc)? "decrescendosym" : "crescendosym"; + Symbol ret=(*symtables_)("param")->lookup(idxstr); + + Array a; + a.push(idx); + ret.tex = substitute_args(ret.tex, a); + ret.dim.x = Interval(0,wid); + return ret; +} Symbol Lookup::linestaff(int lines, Real wid) @@ -162,9 +176,8 @@ Symbol Lookup::meter(Array a) { Symbol s; - s.dim.x = Interval( convert_dimen(0,"pt"), - convert_dimen(10,"pt")); - s.dim.y = Interval(0, convert_dimen(20,"pt") ); // todo + s.dim.x = Interval( 0 PT, 10 PT); + s.dim.y = Interval(0, 20 PT); // todo String src = (*symtables_)("param")->lookup("meter").tex; s.tex = substitute_args(src,a); return s; diff --git a/src/lyriccolumn.cc b/src/lyriccolumn.cc index c016957eb6..c54ebc2b39 100644 --- a/src/lyriccolumn.cc +++ b/src/lyriccolumn.cc @@ -9,7 +9,7 @@ #include "pscore.hh" #include "main.hh" -Lyric_column::Lyric_column(Score_column*s, Lyric_staff* lstaff_l) +Lyric_column::Lyric_column(Score_column* s, Lyric_staff* lstaff_l) : Staff_column(s) { lstaff_l_ = lstaff_l; @@ -33,28 +33,11 @@ Lyric_column::setup_requests() } } -Interval itemlist_width(const Array &its); - void -Lyric_column::typeset_item(Item *i, int breakst) -{ - assert(i); - +Lyric_column::typeset_item(Item *i) +{ lstaff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, - lstaff_l_->line_pstaff_p_,breakst); - - if (breakst == BREAK_PRE - BREAK_PRE) { - - Array to_move( - lstaff_l_->pscore_l_->select_items(lstaff_l_->line_pstaff_p_, - score_column_l_->pcol_l_->prebreak_p_)); - Interval column_wid = itemlist_width(to_move); - assert(!column_wid.empty()); - - for (int j=0; j < to_move.size(); j++) { - to_move[j]->translate(Offset(-column_wid.right, 0)); - } - } + lstaff_l_->pstaff_l_); } Word_info::Word_info() diff --git a/src/lyricstaff.cc b/src/lyricstaff.cc index 3afea78a8f..279db7ff87 100644 --- a/src/lyricstaff.cc +++ b/src/lyricstaff.cc @@ -6,16 +6,13 @@ #include "command.hh" #include "lyricstaff.hh" #include "lyriccolumn.hh" -#include "linepstaff.hh" #include "sccol.hh" #include "lyricwalker.hh" #include "pscore.hh" - - Lyric_staff::Lyric_staff() { - line_pstaff_p_ = 0; + pstaff_l_=0; } Staff_column* @@ -25,18 +22,18 @@ Lyric_staff::create_col(Score_column*s) } void -Lyric_staff::set_output(PScore*ps) +Lyric_staff::set_output(PScore*pscore_l) { - line_pstaff_p_ = new Linestaff(0,ps); - pscore_l_ = ps; - pscore_l_->add(line_pstaff_p_); + pstaff_l_ = new PStaff(pscore_l); + pscore_l_ = pscore_l; + pscore_l_->add(pstaff_l_); } void Lyric_staff::walk() { for (Lyric_walker lcols(this); lcols.ok(); lcols++) { - lcols.lcol_l()->setup_requests();// TODO + lcols.lcol_l()->setup_requests(); lcols.process(); } } diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index d28c488b72..160b83ae9e 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -1,17 +1,9 @@ -// -// what about -// #include "flower.hh" -// #include "lily.hh" -// -// or should we first devide lily/src up ? -// HWN: huh? - #include "request.hh" #include "voice.hh" #include "pscore.hh" #include "lyricstaff.hh" #include "lyricwalker.hh" -#include "sccol.hh" +//#include "sccol.hh" #include "debug.hh" #include "lyricitem.hh" @@ -23,13 +15,11 @@ Lyric_walker::do_word(Word_info) void Lyric_walker::do_INTERPRET_command(Command* ) { -// WARN << "command for Lyrics found\n"; } void Lyric_walker::do_TYPESET_command(Command* ) { -// WARN << "command for Lyrics found\n"; } void @@ -44,7 +34,7 @@ Lyric_walker::process_requests() } Lyric_walker::Lyric_walker(Lyric_staff* lstaff_l) - : Staff_walker(lstaff_l, lstaff_l->line_pstaff_p_->pscore_l_) + : Staff_walker(lstaff_l, lstaff_l->pstaff_l_->pscore_l_) { reset(); } diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc deleted file mode 100644 index df760d6a7a..0000000000 --- a/src/melodicstaff.cc +++ /dev/null @@ -1,66 +0,0 @@ -#include "melodicstaff.hh" -#include "keyitem.hh" -#include "stem.hh" -#include "rest.hh" -#include "notehead.hh" -#include "paper.hh" -#include "molecule.hh" -#include "linepstaff.hh" -//#include "rhythmstaff.hh" -#include "sccol.hh" -#include "localkeyitem.hh" -#include "request.hh" - -const int NO_LINES=5; - - -void -Melodic_staff::set_output(PScore*ps) -{ - theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later. - Simple_staff::set_output(ps); -} - - -Notehead* -Melodic_staff::get_notehead(Note_req *rq, int bottom) -{ - Notehead *n =new Notehead((NO_LINES-1)*2); - n->set_rhythmic(rq->rhythmic()); - n->position = rq->note()->height() + bottom; - n->defined_ch_c_l_m = rq->defined_ch_c_l_m; - return n; -} - -Item * -Melodic_staff::get_TYPESET_item(Command*com) -{ - if (com->args[0] == "KEY") { - return new Keyitem(NO_LINES); // urgh. depends on clef. - } else - return Simple_staff::get_TYPESET_item(com); -} - -Stem * -Melodic_staff::get_stem(Stem_req*rq) -{ - Stem * s = new Stem(NO_LINES-1); - s->flag = rq->balltype; - return s; -} - -Rest* -Melodic_staff::get_rest(Rest_req*rq) -{ - Rest*r = Simple_staff::get_rest(rq); - if (rq->balltype <= 2) - r->translate(Offset(0, NO_LINES * paper()->internote())); - return r; -} - -Local_key_item* -Melodic_staff::get_local_key_item() -{ - return new Local_key_item(-2); -} - diff --git a/src/molecule.cc b/src/molecule.cc index 1e09658fee..c52fdc7b32 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -39,7 +39,7 @@ Atom::TeXstring() const return substitute_args(s, a); } -/****************/ +/* *************** */ String Molecule::TeXstring() const diff --git a/src/mylexer.cc b/src/mylexer.cc index 4575fa78d3..de6fcc7238 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -16,24 +16,24 @@ static Keyword_ent the_key_tab[]={ "bar", BAR, "cadenza", CADENZA, "clef", CLEF, - "cm", CM, + "cm", CM_T, "command", COMMAND, "commands", COMMANDS, "duration", DURATIONCOMMAND, "geometric", GEOMETRIC, "goto", GOTO, - "in", IN, + "in", IN_T, "key", KEY, "mark", MARK, "meter", METER, - "mm", MM, + "mm", MM_T, "multivoice", MULTIVOICE, "octave", OCTAVECOMMAND, "output", OUTPUT, "partial", PARTIAL, "paper", PAPER, "plet", PLET, - "pt", PT, + "pt", PT_T, "score", SCORE, "script", SCRIPT, "skip", SKIP, diff --git a/src/note.cc b/src/note.cc index 226b10a601..5c9daee9fd 100644 --- a/src/note.cc +++ b/src/note.cc @@ -1,7 +1,7 @@ /* could use cleanup */ - #include +#include #include "lexer.hh" #include "string.hh" #include "real.hh" @@ -121,7 +121,7 @@ get_note_element(String pitch, int * notename, int * duration ) parse_pitchmod(pitch, i, oct, forceacc); rq->notename =notename[0]; rq->accidental = notename[1]; - rq->octave = oct; + rq->octave = oct + notename[2]; rq->forceacc = forceacc; rq->balltype = dur; rq->dots = dots; @@ -289,7 +289,9 @@ Request* get_script_req(int d , Script_def*def) { Script_req* script_req_p = new Script_req(d, def); - script_req_p->defined_ch_c_l_m = defined_ch_c_l; +// script_req_p->defined_ch_c_l_m = req_defined_ch_c_l; + // all terminal symbols, rather set directly here: + script_req_p->defined_ch_c_l_m = lexer->here_ch_c_l(); return script_req_p; } diff --git a/src/notehead.cc b/src/notehead.cc index fc250288c9..d96b4d0599 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -19,6 +19,7 @@ Notehead::Notehead(int ss) extremal = 0; defined_ch_c_l_m = 0; } + void Notehead::set_rhythmic(Rhythmic_req*r_req_l) { diff --git a/src/notename.cc b/src/notename.cc index f22f44d7b9..e6d62644b2 100644 --- a/src/notename.cc +++ b/src/notename.cc @@ -28,7 +28,7 @@ Notename_tab::set(int l, int s, String n) assert(l < 8 && s <= 2 && s >= -2 && l >=0); notetab[l * 5 + s +2] = n; } -/****************/ +/* *************** */ void My_flex_lexer::set(Notename_tab *n) { diff --git a/src/paper.cc b/src/paper.cc index 09fd19aad4..ec5fde415d 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -20,14 +20,13 @@ Paperdef::duration_to_dist(Moment d) Real Paperdef::rule_thickness()const { - return convert_dimen(0.4, "pt"); + return 0.4 PT; } Paperdef::Paperdef(Lookup *l) { lookup_p_ = l; - - linewidth = convert_dimen(15,"cm"); // in cm for now + linewidth = 15 *CM_TO_PT; // in cm for now whole_width = 8 * note_width(); geometric_ = sqrt(2); } @@ -72,7 +71,7 @@ Paperdef::note_width()const Real Paperdef::standard_height() const { - return convert_dimen(20,"pt"); + return 20 PT; } void diff --git a/src/parser.y b/src/parser.y index 09e4bd310a..71926f60ca 100644 --- a/src/parser.y +++ b/src/parser.y @@ -64,7 +64,7 @@ int fatal_error_i = 0; } %token VOICE STAFF SCORE TITLE BAR OUTPUT MULTIVOICE -%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND +%token CM_T IN_T PT_T MM_T PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND %token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND %token KEY CLEF TABLE VOICES STEM %token PARTIAL MUSIC GROUPING CADENZA @@ -78,7 +78,7 @@ int fatal_error_i = 0; %token STRING %token DOTS INT -%type unit +%type unit %type pitch_list %type open_request_parens close_request_parens %type declaration @@ -517,7 +517,9 @@ mudela_text: ; script_req: - script_dir mudela_script { $$ = get_script_req($1, $2); } + script_dir mudela_script { + $$ = get_script_req($1, $2); + } ; mudela_script: @@ -704,14 +706,14 @@ int_list: { dim: - real unit { $$ = convert_dimen($1,$2); } + real unit { $$ = $1*$2; } ; -unit: CM { $$ = "cm"; } - |IN { $$ = "in"; } - |MM { $$ = "mm"; } - |PT { $$ = "pt"; } +unit: CM_T { $$ = 1 CM; } + |IN_T { $$ = 1 INCH; } + |MM_T { $$ = 1 MM; } + |PT_T { $$ = 1 PT; } ; /* diff --git a/src/pscore.cc b/src/pscore.cc index 728b083f4e..a022f5e087 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -15,16 +15,11 @@ Idealspacing* PScore::get_spacing(PCol*l, PCol*r) { assert(l!=r); - for (iter_top(suz,ic); ic.ok(); ic++) { - if (ic->left == l && ic->right == r){ - return ic; - } - } - - Idealspacing*ip =new Idealspacing(l,r); - suz.bottom().add(ip); - return ip; + Idealspacing*i_p =new Idealspacing(l,r); + suz.bottom().add(i_p); + + return i_p; } @@ -53,11 +48,10 @@ PScore::do_connect(PCol *c1, PCol *c2, Real d, Real h) if (!c1 || !c2 ) return; Idealspacing*s_l=get_spacing(c1,c2); - - if (!s_l->hooke){ - s_l->hooke = h; - s_l->space =d; - } + + + s_l->hooke = h; + s_l->space =d; } void @@ -73,7 +67,7 @@ void PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) { assert(c && i && s); -// assert(!breakstat != 4 || c->breakable() ); + if (breakstat == 0) { typeset_item(i, c->prebreak_p_, s); return; @@ -254,10 +248,10 @@ void PScore::process() { clean_cols(); - *mlog << "Preprocessing" << endl; + *mlog << "Preprocessing ... " <pstaff_l_ = this; diff --git a/src/qlp.cc b/src/qlp.cc index 280f0db4cc..1e3e2f67d4 100644 --- a/src/qlp.cc +++ b/src/qlp.cc @@ -116,7 +116,7 @@ Ineq_constrained_qp::print() const #endif } -/****************/ +/* *************** */ /* eliminate appropriate variables, until we have a Ineq_constrained_qp diff --git a/src/qlpsolve.cc b/src/qlpsolve.cc index dd9c4043a2..ed49c2a02f 100644 --- a/src/qlpsolve.cc +++ b/src/qlpsolve.cc @@ -142,7 +142,7 @@ Active_constraints::find_active_optimum(Vector g) return H*g; } -/****************************************************************/ +/* *************************************************************** */ int min_elt_index(Vector v) @@ -159,6 +159,19 @@ min_elt_index(Vector v) } ///the numerical solving +/** Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) + Prentice Hall. + + Section 13.3 + + This is a "projected gradient" algorithm. Starting from a point x + the next point is found in a direction determined by projecting + the gradient onto the active constraints. (well, not really the + gradient. The optimal solution obeying the active constraints is + tried. This is why H = Q^-1 in initialisation) ) + + + */ Vector Ineq_constrained_qp::solve(Vector start) const { @@ -248,17 +261,4 @@ Ineq_constrained_qp::solve(Vector start) const return x; } -/** Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) - Prentice Hall. - - Section 13.3 - - This is a "projected gradient" algorithm. Starting from a point x - the next point is found in a direction determined by projecting - the gradient onto the active constraints. (well, not really the - gradient. The optimal solution obeying the active constraints is - tried. This is why H = Q^-1 in initialisation) ) - - - */ diff --git a/src/register.cc b/src/register.cc index d9d3e8a41b..7eeeb46ada 100644 --- a/src/register.cc +++ b/src/register.cc @@ -1,9 +1,18 @@ +/* + register.cc -- implement Staff_elem_info, Request_register + + Sourcefile of LilyPond musictypesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "voice.hh" #include "request.hh" #include "register.hh" #include "notehead.hh" #include "complexwalker.hh" #include "localkeyitem.hh" +#include "complexstaff.hh" Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l, Request_register *reg_l) @@ -14,6 +23,7 @@ Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l, group_regs_l_ = 0; origin_reg_l_ = reg_l; } + Staff_elem_info::Staff_elem_info() { elem_p_ = 0; @@ -23,7 +33,8 @@ Staff_elem_info::Staff_elem_info() origin_reg_l_ = 0; req_l_ = 0; } -/****************/ + +/* *************** */ Request_register::Request_register() { @@ -47,54 +58,25 @@ Request_register::post_move_processing() do_post_move_process(); } - -/****************/ - -Local_key_register::Local_key_register(Complex_walker*w) - : Request_register(w) +Request_register::Request_register(Request_register const&) { - key_item_p_ = 0; -} -bool -Local_key_register::try_request(Request*) - -{ - return false; + assert(false); } void -Local_key_register::process_request() +Request_register::announce_element(Staff_elem_info i) { + walk_l_->announce_element(i); } + void -Local_key_register::do_pre_move_process() +Request_register::typeset_element(Staff_elem*p) { - if (key_item_p_) { - walk_l_->typeset_element(key_item_p_); - key_item_p_ = 0; - } + walk_l_->typeset_element(p); } -void -Local_key_register::acknowledge_element(Staff_elem_info info) -{ - if (info.req_l_->melodic()) { - Melodic_req * melodic_l_ = info.req_l_->melodic(); - - if( melodic_l_->forceacc || - walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename) - != melodic_l_->accidental) { - Item * support_l_ = info.elem_p_->item(); - - if (!key_item_p_) { - key_item_p_ = new Local_key_item(walk_l_->clef_.c0_pos); - key_item_p_->c0_position = walk_l_->clef_.c0_pos; - } - - key_item_p_->add(melodic_l_); - key_item_p_->add(support_l_); - walk_l_->local_key_.oct(melodic_l_->octave) - .set(melodic_l_->notename, melodic_l_->accidental); - } - } +Paperdef* +Request_register::paper()const +{ + return walk_l_->staff()->paper(); } diff --git a/src/request.cc b/src/request.cc index 0a5c8dc3d8..951a509bc4 100644 --- a/src/request.cc +++ b/src/request.cc @@ -19,7 +19,7 @@ Stem_req::Stem_req(int s, int d) dir_i_ = 0; } -/****************/ +/* *************** */ void Barcheck_req::do_print() const { @@ -28,7 +28,7 @@ Barcheck_req::do_print() const #endif } -/****************/ +/* *************** */ void Request::print() const @@ -65,7 +65,7 @@ Request::Request(Request const&src) elt_l_ = 0; defined_ch_c_l_m = src.defined_ch_c_l_m; } -/****************/ +/* *************** */ Spacing_req::Spacing_req() { next = 0; @@ -82,7 +82,7 @@ Blank_req::do_print()const { Spacing_req::do_print(); } -/****************/ +/* *************** */ Melodic_req::Melodic_req() { notename = 0; @@ -103,11 +103,11 @@ Melodic_req::height() const return notename + octave*7; } -/****************/ +/* *************** */ int Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2) { - return r1.duration() - r2.duration(); + return sign(r1.duration() - r2.duration()); } Rhythmic_req::Rhythmic_req(int b, int d) { @@ -139,7 +139,7 @@ Moment Rhythmic_req::duration() const { return wholes(balltype,dots)*plet_factor; } -/****************/ +/* *************** */ Lyric_req::Lyric_req(Text_def* def_p) :Text_req(0, def_p) @@ -154,30 +154,30 @@ Lyric_req::do_print() const Rhythmic_req::do_print(); Text_req::do_print(); } -/****************/ +/* *************** */ void Note_req::do_print() const { Melodic_req::do_print(); Rhythmic_req::do_print(); } -/****************/ +/* *************** */ void Rest_req::do_print() const { Rhythmic_req::do_print(); } -/****************/ +/* *************** */ Beam_req::Beam_req() { nplet = 0; } void Beam_req::do_print()const{} -/****************/ +/* *************** */ void Slur_req::do_print()const{} -/****************/ +/* *************** */ int Span_req:: compare(const Span_req &r1, const Span_req &r2) { @@ -188,7 +188,7 @@ Span_req::Span_req() { spantype = NOSPAN; } -/****************/ +/* *************** */ void Group_feature_req::do_print() const { @@ -207,7 +207,7 @@ void Terminate_voice_req::do_print()const { } -/****************/ +/* *************** */ Script_req::Script_req(int d , Script_def*def) { dir_i_ = d; @@ -222,6 +222,7 @@ Script_req::compare(const Script_req &d1, const Script_req &d2) } Script_req::Script_req(Script_req const &s) + : Request( s ) { dir_i_ = s.dir_i_; scriptdef_p_ = new Script_def(*s.scriptdef_p_); @@ -239,7 +240,7 @@ Script_req::~Script_req() { delete scriptdef_p_; } -/****************/ +/* *************** */ int Text_req:: compare(const Text_req &r1, const Text_req &r2) { @@ -274,7 +275,7 @@ Text_req::do_print() const -/****************/ +/* *************** */ Mark_req::Mark_req(String s) { @@ -288,7 +289,7 @@ Mark_req::do_print()const mtor<< " `" << mark_str_ << "\'\n"; #endif } -/****************/ +/* *************** */ Staff_command_req::Staff_command_req(Input_command * p) { com_p_ = p; diff --git a/src/rhythmstaff.cc b/src/rhythmstaff.cc deleted file mode 100644 index 519ea18cfa..0000000000 --- a/src/rhythmstaff.cc +++ /dev/null @@ -1,47 +0,0 @@ -#include "molecule.hh" -#include "score.hh" -#include "request.hh" -#include "notehead.hh" -#include "stem.hh" -#include "linepstaff.hh" -#include "rhythmstaff.hh" -#include "paper.hh" -#include "sccol.hh" -#include "rest.hh" - -void -Rhythmic_staff::set_output(PScore*ps) -{ - theline_l_ = new Linestaff(1,ps); - Simple_staff::set_output(ps); -} - -Item * -Rhythmic_staff::get_TYPESET_item(Command *com) -{ - if (com->args[0] == "KEY" || com->args[0] == "CLEF"|| - com->args[0] == "CURRENTCLEF") - return 0; - Item *i = Simple_staff::get_TYPESET_item(com); - if (!i) return 0; - i->translate(Offset(0, - -score_l_->paper_p_->standard_height()/2)); - return i; -} - -Notehead* -Rhythmic_staff::get_notehead(Note_req *rq, int) -{ - Notehead *n =new Notehead(1); - n->set_rhythmic(rq->rhythmic()); - n->position = 0; - return n; -} - -Stem * -Rhythmic_staff::get_stem(Stem_req*rq) -{ - Stem * s = new Stem(0); - s->flag = rq->balltype; - return s; -} diff --git a/src/sccol.cc b/src/sccol.cc index 14c52796de..2d826094da 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -54,6 +54,7 @@ Score_column::preprocess() void Score_column::add_duration(Moment d) { + assert(d); for (int i = 0; i< durations.size(); i++) { if (d == durations[i]) return ; diff --git a/src/score.cc b/src/score.cc index 0f697655b2..ab9a9d9a93 100644 --- a/src/score.cc +++ b/src/score.cc @@ -12,17 +12,18 @@ void Score::process() { - *mlog << "\nProcessing music" << endl; + *mlog << "\nProcessing music ..." << flush; assert (paper_p_); if (last() == Moment(0)) { warning("Need to have music in a score.", defined_ch_c_l_); } + // distribute commands to disciples pscore_p_ = new PScore(paper_p_); for (iter_top(staffs_,i); i.ok(); i++) { - i->truncate_cols(last()); i->set_output(pscore_p_); + i->truncate_cols(last()); i->process(); } @@ -34,6 +35,7 @@ Score::process() // debugging OK(); + *mlog << endl; pscore_p_->process(); } @@ -88,9 +90,10 @@ Score::create_cols(Moment w) } PCursor -Score::find_col(Moment w,bool mus) -{ - iter_top(cols_,i); +Score::find_col(Moment w, bool mus) +{ iter_top( cols_,i); + + for (; i.ok(); i++) { if (i->when() == w && i->musical_ == mus) return i; @@ -112,6 +115,7 @@ Score::do_cols() } clean_cols(); // can't move clean_cols() farther up. } + Moment Score::last() const { @@ -157,10 +161,10 @@ Score::print() const #endif } -Score::Score(Paperdef*p) +Score::Score(Paperdef*paper_p) { pscore_p_=0; - paper_p_ = p; // ?? safe? + paper_p_ = paper_p; errorlevel_i_ = 0; defined_ch_c_l_ = 0; } diff --git a/src/scriptdef.cc b/src/scriptdef.cc index 1e11de72c2..508ae6a24b 100644 --- a/src/scriptdef.cc +++ b/src/scriptdef.cc @@ -17,7 +17,7 @@ Script_def::print() const int Script_def::compare(Script_def const & c) { - return (symidx == c.symidx && + return !(symidx == c.symidx && stemdir == c.stemdir&& staffdir == c.staffdir&& invertsym == c.invertsym); diff --git a/src/scriptreg.cc b/src/scriptreg.cc new file mode 100644 index 0000000000..88375db8fe --- /dev/null +++ b/src/scriptreg.cc @@ -0,0 +1,69 @@ +/* + scriptreg.cc -- implement Script_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "scriptreg.hh" +#include "script.hh" +#include "request.hh" +#include "complexwalker.hh" + +Script_register::Script_register(Complex_walker*w) + : Request_register(w) +{ + script_p_ = 0; +} + +bool +Script_register::try_request(Request *r_l) +{ + if (!r_l->script()) + return false ; + + if (accepted_req_arr_.size() + && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script())) + + return false; + + accepted_req_arr_.push(r_l); + + return true; +} + +void +Script_register::process_request() +{ + if (accepted_req_arr_.size() ) { + script_p_ = new Script(accepted_req_arr_[0]->script(), 10); + announce_element( + Staff_elem_info(script_p_, accepted_req_arr_[0], this)); + } +} + +void +Script_register::acknowledge_element(Staff_elem_info info) +{ + if (!script_p_) + return; + if (info.elem_p_->name() == String("Stem")) + script_p_->set_stem((Stem*)info.elem_p_); + else if (info.req_l_->rhythmic()) + script_p_->set_support(info.elem_p_->item()); +} + +void +Script_register::do_pre_move_process() +{ + if (script_p_){ + script_p_->dir = dir_i_; + typeset_element(script_p_); + script_p_ = 0; + } +} + +void +Script_register::set_dir(int i) +{ + dir_i_ = i; +} diff --git a/src/simpleprint.cc b/src/simpleprint.cc deleted file mode 100644 index 7ded4a9c90..0000000000 --- a/src/simpleprint.cc +++ /dev/null @@ -1,110 +0,0 @@ -#include "clefitem.hh" -#include "request.hh" -#include "pscore.hh" -#include "paper.hh" -#include "simplestaff.hh" -#include "sccol.hh" -#include "rest.hh" -#include "debug.hh" -#include "bar.hh" -#include "meter.hh" - -Item * -Simple_staff::get_TYPESET_item(Command *com) -{ - Item *s=0; - Array arg( com->args); - String type =arg[0]; - arg.del(0); - if (type == "BAR" ) { - s = new Bar(com->args[1]); - } else if (type == "METER") { - s = new Meter(arg); - } else if (type == "CLEF" || type == "CURRENTCLEF") { - Clef_item * c = new Clef_item; - s = c; - c->change = (type == "CLEF"); - }else{ - WARN << "ignoring TYPESET command for " << type << '\n'; - } - return s; -} - - -Interval -itemlist_width(const Array &its) -{ - Interval iv ; - iv.set_empty(); - - for (int j =0; j < its.size(); j++){ - iv.unite (its[j]->width()); - - } - return iv; -} - -void -Simple_column::typeset_item(Item *i, int breakst) -{ - assert(i); - - staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, - staff_l_->theline_l_,breakst); - - if (breakst == BREAK_PRE - BREAK_PRE) { - - Array to_move( - staff_l_->pscore_l_->select_items(staff_l_->theline_l_, - score_column_l_->pcol_l_->prebreak_p_)); - Interval column_wid = itemlist_width(to_move); - assert(!column_wid.empty()); - - for (int j=0; j < to_move.size(); j++) { - to_move[j]->translate(Offset(-column_wid.right, 0)); - } - } -} - -void -Simple_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH! -{ - assert(i); - PCol * c=score_column_l_->pcol_l_; - if (breakst == 0) - c = c->prebreak_p_; - else if (breakst == 2) - c = c->postbreak_p_; - - Array to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_, - c)); - typeset_item(i, breakst); - - Interval column_wid = itemlist_width(to_move); - if (column_wid.empty()) - column_wid = Interval(0,0); - i->translate(Offset(column_wid[dir] - i->width()[-dir], 0)); -} - -void -Simple_staff::set_output(PScore* ps ) -{ - pscore_l_ = ps; - pscore_l_->add(theline_l_); -} - - -Rest* -Simple_staff::get_rest(Rest_req*rq) -{ - int b = rq->rhythmic()->balltype; - int d = rq->rhythmic()->dots; - return new Rest(b, d); -} - -Local_key_item* -Simple_staff::get_local_key_item() -{ - return 0; -} - diff --git a/src/simplestaff.cc b/src/simplestaff.cc deleted file mode 100644 index 4f7b5bd2e2..0000000000 --- a/src/simplestaff.cc +++ /dev/null @@ -1,85 +0,0 @@ -#include "request.hh" -#include "voice.hh" -#include "staffwalker.hh" -#include "debug.hh" -#include "clef.hh" -#include "staff.hh" -#include "command.hh" -#include "simplestaff.hh" -#include "sccol.hh" -#include "simplewalker.hh" - - - -Simple_column::Simple_column(Score_column*s, Simple_staff *rs) - : Staff_column(s) -{ - stem_requester_len = 0; - stem_ = 0; - staff_l_ = rs; - beam_ = 0; - text_=0; - -} - -Simple_staff::Simple_staff() -{ - theline_l_ = 0; -} - - - -void -Simple_column::setup_requests() -{ - for (int i = 0 ; i < v_elts.size(); i ++) - for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { - Request *rq= j; - if (rq->barcheck()) { - if (tdescription_->whole_in_measure) { - warning( "Barcheck failed", rq->defined_ch_c_l_m ); - } - } - if (rq->rhythmic()){ - notes.push(rq->rhythmic()); - } - if (rq->script()) { - notes.top().scripts.push(rq->script()); - } - if (rq->stem()) { - stem_ = rq->stem(); - stem_requester_len = v_elts[i]->duration; - } - if (rq->text()) { - text_ = rq->text(); - } - if (rq->beam()) { - beam_ = rq->beam(); - } - if (rq->slur()) { - slurs.push(rq->slur()); - } - } -} - -Staff_column* -Simple_staff::create_col(Score_column*s) -{ - return new Simple_column(s,this); -} - -void -Simple_staff::walk() -{ - for (Simple_walker sc(this); sc.ok(); sc++) { - sc.col()->setup_requests();// TODO - sc.process(); - } -} -Note_info::Note_info() -{ - rq =0; -} -Note_info::Note_info(Rhythmic_req*r) { - rq = r; -} diff --git a/src/simplewalker.cc b/src/simplewalker.cc deleted file mode 100644 index f99d9f5213..0000000000 --- a/src/simplewalker.cc +++ /dev/null @@ -1,344 +0,0 @@ -/* - UGR!! CHAOS RULEZ - */ -#include "textspanner.hh" -#include "script.hh" -#include "request.hh" -#include "voice.hh" -#include "clef.hh" -#include "beam.hh" -#include "pscore.hh" -#include "simplestaff.hh" -#include "simplewalker.hh" -#include "sccol.hh" -#include "stem.hh" -#include "notehead.hh" -#include "rest.hh" -#include "debug.hh" -#include "keyitem.hh" -#include "clefitem.hh" -#include "slur.hh" -#include "localkeyitem.hh" -#include "textitem.hh" -#include "misc.hh" - -Rhythmic_grouping -parse_grouping(Array const &a) -{ - Array r; - Array grouplen_arr; - for (int i= 0 ; i < a.size()/2; ) { - r.push(a[i++]); - grouplen_arr.push(Moment(1,(int) a[i++])); - } - Moment here =0; - - Array children; - for (int i=0; i < r.size(); i++) { - - Moment last = here; - here += grouplen_arr[i] * Rational(r[i]); - children.push( - new Rhythmic_grouping(MInterval(last, here), r[i] )); - } - return Rhythmic_grouping(children); -} - - - -void -Simple_walker::do_INTERPRET_command(Command*com) -{ - Array args(com->args); - args.del(0); - if (com->args[0] == "GROUPING") { - default_grouping = parse_grouping(args); - }else if (com->args[0] == "NEWMEASURE") { - local_key_.reset(key_); - - } else if (com->args[0] == "KEY") { - - if (col()->when() > Moment(0)) { - assert(!oldkey_undo); - oldkey_undo = new Array( key_.oldkey_undo(args)); - } - - typesetkey = key_.read(args); - local_key_.reset(key_); - } else if (com->args[0] == "CLEF") { - clef_.read(args); - } else { - WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n'; - } -} - -void -Simple_walker::do_TYPESET_command(Command*com) -{ - /* ignore these commands if non-default versions have been - processed. */ - if (com->args[0] == "CURRENTKEY") - if (processed_key) - return; - else - com->args[0] = "KEY"; // urgh - - if (com->args[0] == "CURRENTCLEF") { - if (processed_clef) - return; - } - if (com->args[0] == "BAR") { - - if (processed_bar_priority > com->priority) - return; - else - processed_bar_priority = com->priority; - } - - Item* i = staff()->get_TYPESET_item(com); - if (!i) - return; - - if (com->args[0] == "KEY") { - ((Keyitem*) i)->read(clef_); - if (oldkey_undo) { - ((Keyitem*) i)->read(*oldkey_undo); - delete oldkey_undo; - oldkey_undo = 0; - } - processed_key = true; - - ((Keyitem*) i)->read(typesetkey); // ugh - } - - if (com->args[0] == "CLEF"||com->args[0] == "CURRENTCLEF") { - processed_clef =true; - Clef_item*c=(Clef_item*)i; - c->read(clef_); - c->change = (break_status != BREAK_POST - BREAK_PRE); - } - col()->typeset_item_directional(i, 1, break_status); -} - -void -Simple_walker::do_local_key(Note_req*n,Notehead* head_p) -{ - if ( local_key_.oct(n->octave).acc(n->notename) != n->accidental) { - if (!local_key_item_) { - local_key_item_ = staff()->get_local_key_item(); - local_key_item_->c0_position = clef_.c0_pos; - } - local_key_item_->add(head_p); - local_key_item_->add(n->octave, n->notename, n->accidental); - local_key_.oct(n->octave).set(n->notename, n->accidental); - } -} - -void -Simple_walker::do_note(Note_info n) -{ - Simple_column*c = col(); - Simple_staff *s = staff(); - Item*rhythmic=0; - if (n.rq->note()) { - Note_req * req = n.rq->note() ; - const Voice *v = req->elt_l_->voice_l_; - - Notehead*n = s->get_notehead(req, clef_.c0_pos); - rhythmic=n; - if (stem_) - stem_->add(n); - - if (current_grouping) { - current_grouping->add_child( - c->tdescription_->whole_in_measure, req->duration()); - } - noteheads.push(n); - int sidx =find_slur(v); - if (sidx >= 0) { - pending_slurs[sidx]->add(n); - } - - if (wantkey) - do_local_key(req,n); - } else if (n.rq->rest()) { - rhythmic = s->get_rest(n.rq->rest()); - c->typeset_item(rhythmic); - } - for (int i= 0; i < n.scripts.size(); i ++) { - Script * s_p =new Script(n.scripts[i], 10); - s_p->set_support(rhythmic); - s_p->set_stem(stem_); - c->typeset_item(s_p); // UGR - } -} - -void -Simple_walker::process_requests() -{ - Simple_column*c = col(); - Simple_staff *s = staff(); - - if (c->beam_ && c->beam_->spantype == Span_req::START) { - if (beam_) - error("Too many beams (t = " +String(c->when())+")"); - beam_ = new Beam; - assert(!current_grouping); - current_grouping = new Rhythmic_grouping; - } - - for (int i=0; i < c->slurs.size(); i++) { - Slur_req*sl = c->slurs[i]; - - if (sl->spantype == Span_req::START) { - if (find_slur(sl->elt_l_->voice_l_)>=0) - error( "Too many slurs in voice", sl->defined_ch_c_l_m ); - pending_slur_reqs.push(sl); - pending_slurs.push(new Slur); - } - } - - if (c->text_) { - c->typeset_item(new Text_item(c->text_, 10)); // UGR - } - - if (c->stem_) { - stem_ = s->get_stem(c->stem_->stem()); - } - - for (int i = 0; i < c->notes.size(); i ++) { - do_note(c->notes[i]); - } - - if (beam_) { - if (!stem_) - WARN <<"beamed note should have a stem (t = " - <when())<<")\n"; - else - beam_->add(stem_); - - - } - if (stem_) { - c->typeset_item(stem_); - /* needed, otherwise placement of - local_key fucks up */ - } - - if (c->beam_&& c->beam_->spantype == Span_req::STOP) { - if (!beam_) { - error( "No beam to end", c->beam_->defined_ch_c_l_m ); - } - default_grouping.extend(current_grouping->interval()); - beam_->set_grouping(default_grouping, *current_grouping); - pscore_l_->typeset_spanner(beam_, s->theline_l_); - - if (c->beam_->nplet) { - Text_spanner* t = new Text_spanner; - t->set_support(beam_); - t->spec.align_i_ = 0; - t->spec.text_str_ = c->beam_->nplet; - pscore_l_->typeset_spanner(t, s->theline_l_); - } - - beam_ = 0; - delete current_grouping; - current_grouping =0; - } - for (int i = 0; i < noteheads.size(); i++) { - c->typeset_item(noteheads[i]); - } - noteheads.set_size(0); - - if (local_key_item_) { - c->typeset_item(local_key_item_); - local_key_item_ = 0; - } - if (stem_) { - stem_ = 0; - } - for (int i=0; i < c->slurs.size(); i++) { - Slur_req *sl = c->slurs[i]; - - if (sl->spantype == Span_req::STOP) { - int idx = find_slur(sl->elt_l_->voice_l_); - if (idx < 0) - error( "can't find slur end", sl->defined_ch_c_l_m ); - - pscore_l_->typeset_spanner(pending_slurs[idx], - s->theline_l_); - pending_slurs.del(idx); - pending_slur_reqs.del(idx); - } - } - -} -Simple_walker::Simple_walker(Simple_walker const&) - : Staff_walker(0, 0) -{ - assert(false); -} - -Simple_walker::~Simple_walker() -{ - if (pending_slurs.size()) - WARN << "destructing " << pending_slurs.size() << " Pending slurs "; - if (beam_) - WARN << "destructing Beam\n"; - if (local_key_item_) - WARN<<"destructing Local_key_item\n"; - if (stem_) - WARN<< "destructing Stem\n"; - delete local_key_item_; - delete stem_; - delete beam_; - -} - -Simple_walker::Simple_walker(Simple_staff*s) - : Staff_walker(s, s->theline_l_->pscore_l_) -{ - stem_ = 0; - beam_ =0; - oldkey_undo = 0; - current_grouping = 0; - Local_key_item * i = s->get_local_key_item(); - wantkey =i; - delete i; - local_key_item_ = 0; - do_post_move(); -} - - - -Simple_staff* -Simple_walker::staff() -{ - return (Simple_staff*) staff_l_; -} - -Simple_column* -Simple_walker::col() -{ - return (Simple_column*) *(*this); -} - -void -Simple_walker::do_post_move() -{ - processed_clef =false; - processed_key = false; - processed_bar_priority = 0; -} - -int -Simple_walker::find_slur(const Voice *v) -{ - for (int i=0; i < pending_slur_reqs.size(); i++) { - if (pending_slur_reqs[i]->elt_l_->voice_l_== v) - return i; - } - return -1; -} - - diff --git a/src/slur.cc b/src/slur.cc index 5b7f99d16e..856ca99035 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -12,10 +12,11 @@ #include "molecule.hh" #include "debug.hh" #include "boxes.hh" + NAME_METHOD(Slur); + Slur::Slur() { - dir = 0; open_right=open_left=false; } @@ -50,9 +51,9 @@ Slur::set_default_dir() /* should consult stems */ Real meanpos = sumpos/Real(encompass.size()); if (meanpos < 5) // todo - dir = -1; + dir_i_ = -1; else - dir = 1; + dir_i_ = 1; } void @@ -85,7 +86,8 @@ Slur::do_break_at(PCol*l, PCol*r) const void Slur::do_post_processing() { - set_default_dir(); + if (!dir_i_) + set_default_dir(); } Molecule* @@ -104,12 +106,12 @@ Slur::brew_molecule_p() const Notehead *rnote_p =encompass.top(); int lpos_i = lnote_p->position; int rpos_i = rnote_p->position; - Offset left_off(lnote_p->x_dir, lpos_i + 2*dir); - Offset right_off(lnote_p->x_dir, rpos_i + 2*dir); + Offset left_off(lnote_p->x_dir, lpos_i + 2*dir_i_); + Offset right_off(lnote_p->x_dir, rpos_i + 2*dir_i_); if (!lnote_p->extremal) - left_off += Offset(0.5, -dir); + left_off += Offset(0.5, -dir_i_); if (!rnote_p->extremal) - right_off+= Offset(-0.5, -dir); + right_off+= Offset(-0.5, -dir_i_); int dy = int(right_off.y - left_off.y); @@ -120,7 +122,7 @@ Slur::brew_molecule_p() const w+= (right_off.x - left_off.x) * nw_f ; Real round_w = w; // slur lookup rounds the slurwidth . - Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir); + Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir_i_); Real error = w-round_w; diff --git a/src/slurreg.cc b/src/slurreg.cc new file mode 100644 index 0000000000..05a7564490 --- /dev/null +++ b/src/slurreg.cc @@ -0,0 +1,91 @@ +/* + slurreg.cc -- implement Slur_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "complexwalker.hh" +#include "slurreg.hh" +#include "slur.hh" +#include "debug.hh" +void +Slur_register::set_dir(int i) +{ + dir_i_ = i; +} + +Slur_register::Slur_register(Complex_walker* w) + : Request_register(w) +{ + set_dir(0); +} + +bool +Slur_register::try_request(Request *req_l) +{ + if(!req_l->slur()) + return false; + + accepted_req_arr_.push(req_l); + return true; +} + +void +Slur_register::acknowledge_element(Staff_elem_info info) +{ + if (info.elem_p_->name() == String("Notehead")) { + Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh + for (int i = 0; i < slur_l_stack_.size(); i++) + slur_l_stack_[i]->add(head_p ); + for (int i = 0; i < end_slur_l_arr_.size(); i++) + end_slur_l_arr_[i]->add(head_p); + } +} +/* + abracadabra + */ +void +Slur_register::process_request() +{ + Array start_slur_l_arr_; + for (int i=0; i< accepted_req_arr_.size(); i++) { + Slur_req* slur_req_l = accepted_req_arr_[i]->slur(); + // end slur: move the slur to other array + if (slur_req_l->spantype == Span_req::STOP) { + if (slur_l_stack_.empty()) + warning("can't find slur to end", + slur_req_l->defined_ch_c_l_m); + else { + end_slur_l_arr_.push(slur_l_stack_.pop()); + requests_arr_.pop(); + } + } else if (slur_req_l->spantype == Span_req::START) { + // push a new slur onto stack. + //(use temp. array to wait for all slur STOPs) + Slur * s_p =new Slur; + requests_arr_.push(slur_req_l); + start_slur_l_arr_.push(s_p); + announce_element(Staff_elem_info(s_p, slur_req_l, this)); + } + } + for (int i=0; i < start_slur_l_arr_.size(); i++) + slur_l_stack_.push(start_slur_l_arr_[i]); +} + +void +Slur_register::do_pre_move_process() +{ + for (int i = 0; i < end_slur_l_arr_.size(); i++) { + if (dir_i_) + end_slur_l_arr_[i]->dir_i_ = dir_i_; + typeset_element(end_slur_l_arr_[i]); + } + end_slur_l_arr_.set_size(0); +} + +Slur_register::~Slur_register() +{ + for (int i=0; i < requests_arr_.size(); i++) { + warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m); + } +} diff --git a/src/sourcefile.cc b/src/sourcefile.cc index 1fe2aa3d53..ac164fd94a 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -17,6 +17,9 @@ #include "string.hh" #include "proto.hh" #include "plist.hh" +#include "lexer.hh" +#include "debug.hh" +#include "parseconstruct.hh" #include "main.hh" // find_file #include "sourcefile.hh" @@ -143,12 +146,13 @@ Source_file::line_i( char const* pos_ch_c_l ) void Source_file::map() { + if ( fildes_i_m == -1 ) + return; + data_caddr_m = (caddr_t)mmap( (void*)0, size_off_m, PROT_READ, MAP_SHARED, fildes_i_m, 0 ); - if ( (int)data_caddr_m == -1 ) { - cerr << "lilypond: can't map: " << name_str_m << ": " << strerror( errno ) << endl; - assert( 0 ); - } + if ( (int)data_caddr_m == -1 ) + warning( String( "can't map: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() ); } String @@ -160,12 +164,15 @@ Source_file::name_str() void Source_file::open() { - name_str_m = find_file( name_str_m ); + String name_str = find_file( name_str_m ); + if ( name_str != "" ) + name_str_m = name_str; + fildes_i_m = ::open( name_str_m, O_RDONLY ); - + if ( fildes_i_m == -1 ) { - cerr << "lilypond: can't open: " << name_str_m << ": " << strerror( errno ) << endl; - assert( 0 ); + warning( String( "can't open: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() ); + return; } struct stat file_stat; diff --git a/src/spanner.cc b/src/spanner.cc index ad5b2e2552..15efb59071 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -3,6 +3,7 @@ #include "pcol.hh" NAME_METHOD(Spanner); + void Spanner::do_print()const { diff --git a/src/staff.cc b/src/staff.cc index d6ddda8f3b..be98be9fc2 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -77,18 +77,21 @@ Staff::clean_cols() Staff_column * Staff::get_col(Moment w, bool mus) { - Score_column* sccol_l = score_l_->find_col(w,mus); - - iter_top(cols,i); + iter_top(cols,i); for (; i.ok(); i++) { - - if (*i->score_column_l_ > *sccol_l) // too far + if (i->when() == w) { + if (i->musical_b() == mus) { + assert( score_l_->find_col(w,mus).ptr() == i->score_column_l_); + return i; + } + else if (!mus) + break; + } else if (i->when() > w) break; - if (sccol_l == i->score_column_l_) - return i; } - /* post: *sc > *->score_column_l_ || !i.ok() */ + + Score_column* sccol_l = score_l_->find_col(w,mus); Staff_column* newst = create_col(sccol_l); if (!i.ok()) { @@ -98,6 +101,7 @@ Staff::get_col(Moment w, bool mus) if (mus) { i.insert(newst); + return newst; } @@ -136,18 +140,22 @@ void Staff::setup_staffcols() { for (iter_top(voices,i); i.ok(); i++) { + Moment now = i->start; for (iter_top(i->elts,j); j.ok(); j++) { - - Staff_column *s_l=get_col(now,true); + + Staff_column *s_l= get_col(now, true); + assert(now == s_l->when()); s_l->add(j); now += j->duration; } - } + OK(); set_time_descriptions(); } + + void Staff::set_time_descriptions() { @@ -182,7 +190,7 @@ Staff::OK() const i++; for (; i.ok(); j++,i++) { if ( j->when() == i->when()) - assert(!j->mus() && i->mus()); + assert(!j->musical_b() && i->musical_b()); else assert(j->when () < i->when() ); } diff --git a/src/staffline.cc b/src/staffline.cc index 429874410e..a7fcbbeb01 100644 --- a/src/staffline.cc +++ b/src/staffline.cc @@ -23,14 +23,11 @@ String Line_of_staff::TeXstring() const { String s("%line_of_staff\n"); + s+=make_vbox(height()); // the staff itself: eg lines, accolades s += "\\hbox{"; { - ((PStaff*)pstaff_l_)-> - brew_molecule_p(line_of_score_l_->pscore_l_->paper_l_->linewidth); - - s+=pstaff_l_->stafsym_p_->TeXstring(); iter_top(line_of_score_l_->cols,cc); Real lastpos=cc->hpos; @@ -67,7 +64,6 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) PCol *linestop = sc->cols.bottom(); for (iter_top(pstaff_l_->spans,i); i.ok(); i++) { - PCol *brokenstart = &max(*linestart, *i->left); PCol *brokenstop = &min(*linestop, *i->right); if ( *brokenstart < *brokenstop) { @@ -82,7 +78,8 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) Interval Line_of_staff::height() const { - Interval y = pstaff_l_->stafsym_p_->extent().y; + Interval y(0,0); + iter_top(line_of_score_l_->cols,cc); // all items in the current line & staff. @@ -105,7 +102,9 @@ Line_of_staff::height() const void Line_of_staff::process() { +#if 0 if (!pstaff_l_->stafsym_p_) pstaff_l_->brew_molecule_p(line_of_score_l_->pscore_l_-> paper_l_->linewidth); +#endif } diff --git a/src/staffsym.cc b/src/staffsym.cc new file mode 100644 index 0000000000..2e2d9f3066 --- /dev/null +++ b/src/staffsym.cc @@ -0,0 +1,46 @@ +/* + staffsym.cc -- implement Staff_symbol + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "staffsym.hh" +#include "lookup.hh" +#include "paper.hh" +#include "debug.hh" + +NAME_METHOD(Staff_symbol); + +Staff_symbol::Staff_symbol(int l) +{ + no_lines_i_ = l; +} + +void +Staff_symbol::do_print()const +{ + mtor << "lines: " << no_lines_i_; +} + +Molecule* +Staff_symbol::brew_molecule_p() const +{ + Atom a = paper()->lookup_p_->linestaff(no_lines_i_, width().length()); + return new Molecule(a); +} + +Spanner* +Staff_symbol::do_break_at(PCol*p1, PCol*p2)const +{ + Staff_symbol *span_p=new Staff_symbol(*this); + return span_p; +} + +void +Staff_symbol::set_extent(PCol*p1, PCol*p2) +{ + assert(p1&&p2); + left = p1; + right = p2; +} diff --git a/src/staffwalker.cc b/src/staffwalker.cc index 3bf94ceaba..eac45b5b13 100644 --- a/src/staffwalker.cc +++ b/src/staffwalker.cc @@ -2,6 +2,7 @@ #include "staffwalker.hh" #include "stcol.hh" #include "sccol.hh" +#include "debug.hh" Staff_walker::~Staff_walker() {} Staff_walker::Staff_walker(Staff_walker const &s) @@ -29,7 +30,7 @@ Staff_walker::process() { break_status = BREAK_END - BREAK_PRE; - if (ptr()->mus()) { + if (ptr()->musical_b()) { process_requests(); } else if (ptr()->staff_commands_p_) for (iter_top(*ptr()->staff_commands_p_,i); i.ok(); i++) { @@ -66,6 +67,11 @@ void Staff_walker::operator++(int i) { do_pre_move(); + if (ptr()->musical_b() && ptr()->tdescription_ + && !ptr()->tdescription_->whole_in_measure) { + *mlog << "[" << ptr()->tdescription_->bars<<"]"<< flush; + } PCursor::operator++(i); + do_post_move(); } diff --git a/src/stcol.cc b/src/stcol.cc index 89a572408a..0712409662 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -16,7 +16,7 @@ Staff_column::OK() const } bool -Staff_column::mus() const +Staff_column::musical_b() const { return score_column_l_->musical_; } @@ -38,10 +38,11 @@ Staff_column::add(Voice_element*ve) v_elts.push(ve); } -Staff_column::Staff_column(Score_column *s_l) +Staff_column::Staff_column(Score_column * cur) + { tdescription_ =0; - score_column_l_ = s_l; + score_column_l_=cur; staff_commands_p_ = 0; } diff --git a/src/stembeamreg.cc b/src/stembeamreg.cc new file mode 100644 index 0000000000..506bde3423 --- /dev/null +++ b/src/stembeamreg.cc @@ -0,0 +1,153 @@ +/* + stembeamreg.cc -- part of LilyPond + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "stembeamreg.hh" +#include "beam.hh" +#include "stem.hh" +#include "grouping.hh" +#include "textspanner.hh" +#include "complexwalker.hh" +#include "complexstaff.hh" +#include "debug.hh" + +Stem_beam_register::Stem_beam_register(Complex_walker*w) + :Request_register(w) +{ + do_post_move_process(); + current_grouping = 0; + beam_p_ = 0; + set_dir(0); + start_req_l_ = 0; +} + +bool +Stem_beam_register::try_request(Request*req_l) +{ + if ( req_l->beam() ) { + if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START)) + return false; + + if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam())) + return false; + + beam_req_l_ = req_l->beam(); + return true; + } + + if ( req_l->stem() ) { + if (current_grouping && !current_grouping->child_fit_query( + walk_l_->col()->tdescription_->whole_in_measure)) + return false; + + if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem())) + return false; + + stem_req_l_ = req_l->stem(); + return true; + } + return false; +} + +void +Stem_beam_register::process_request() +{ + if (beam_req_l_) { + if (beam_req_l_->spantype == Span_req::STOP) { + end_beam_b_ = true; + start_req_l_ = 0; + } else { + beam_p_ = new Beam; + start_req_l_ = beam_req_l_; + + current_grouping = new Rhythmic_grouping; + if (beam_req_l_->nplet) { + Text_spanner* t = new Text_spanner(); + t->set_support(beam_p_); + t->spec.align_i_ = 0; + t->spec.text_str_ = beam_req_l_->nplet; + typeset_element(t); + } + + } + } + + if (stem_req_l_) { + stem_p_ = new Stem(4); + if (current_grouping) + current_grouping->add_child( + walk_l_->col()->tdescription_->whole_in_measure, + stem_req_l_->duration()); + + stem_p_->flag = stem_req_l_->balltype; + + if (beam_p_) { + if (stem_req_l_->balltype<= 4) + warning( "stem doesn't fit in Beam", + stem_req_l_->defined_ch_c_l_m); + else + beam_p_->add(stem_p_); + stem_p_->print_flag = false; + } else { + stem_p_->print_flag = true; + } + + announce_element(Staff_elem_info(stem_p_, + stem_req_l_, this)); + } +} + +void +Stem_beam_register::acknowledge_element(Staff_elem_info info) +{ + if (!stem_p_) + return; + + if (info.elem_p_->name() == String("Notehead") && + stem_req_l_->duration() == info.req_l_->rhythmic()->duration()) + + stem_p_->add((Notehead*)info.elem_p_); +} + +void +Stem_beam_register::do_pre_move_process() +{ + if (stem_p_) { + if (default_dir_i_) + stem_p_->dir = default_dir_i_; + + typeset_element(stem_p_); + stem_p_ = 0; + } + if (beam_p_ && end_beam_b_) { + walk_l_->default_grouping.extend(current_grouping->interval()); + beam_p_->set_grouping(walk_l_->default_grouping, *current_grouping); + typeset_element(beam_p_); + delete current_grouping; + current_grouping = 0; + beam_p_ = 0; + } + end_beam_b_ = false; +} +void +Stem_beam_register::do_post_move_process() +{ + stem_p_ = 0; + beam_req_l_ = 0; + stem_req_l_ = 0; + end_beam_b_ = false; +} + +Stem_beam_register::~Stem_beam_register() +{ + if (beam_p_) + warning("unterminated beam", start_req_l_->defined_ch_c_l_m); +} + +void +Stem_beam_register::set_dir(int i) +{ + default_dir_i_ = i; +} diff --git a/src/texbeam.cc b/src/texbeam.cc index a3b38dde9e..c9f3c95481 100644 --- a/src/texbeam.cc +++ b/src/texbeam.cc @@ -23,7 +23,7 @@ Lookup::beam_element(int sidx, int widx, Real slope) args.push(widx); bs.tex = substitute_args(bs.tex,args); int w = 2 << widx; - Real width = convert_dimen(w,"pt"); + Real width = w PT; bs.dim.x = Interval(0,width); bs.dim.y = Interval(0,width*slope); return bs; @@ -34,7 +34,7 @@ static int slope_index(Real &s) { if (abs(s) > 0.5) { - WARN << "beam steeper than 0.5\n"; + WARN << "beam steeper than 0.5 (" << s << ")\n"; s = sign(s) * 0.5; } @@ -65,12 +65,12 @@ Lookup::beam(Real &slope, Real width) { int sidx = slope_index(slope); if (!slope) - return rule_symbol(convert_dimen(2,"pt"), width); - if (width < convert_dimen(2,"pt")) { - WARN<<"Beam too narrow.\n"; - width = convert_dimen(2,"pt"); + return rule_symbol(2 PT, width); + if (width < 2 PT) { + WARN<<"Beam too narrow. (" << print_dimen(width) <<")\n"; + width = 2 PT; } - Real elemwidth = convert_dimen(64,"pt"); + Real elemwidth = 64 PT; int widx = 5; Molecule m; diff --git a/src/texslur.cc b/src/texslur.cc index a3a29db444..71cded9529 100644 --- a/src/texslur.cc +++ b/src/texslur.cc @@ -28,9 +28,11 @@ char direction_char(int y_sign) Symbol Lookup::half_slur_middlepart(Real &dx, int dir) { - if (dx >= convert_dimen(400,"pt")) // todo - error ("halfslur too large"); - int widx = int(floor(dx / 4.0)); + if (dx >= 400 PT) {// todo + WARN<<"halfslur too large" <= convert_dimen(96,"pt")) { - WARN << "Slur half too wide."; - dx = convert_dimen(96,"pt"); + if (dx >= 96 PT) { + WARN << "Slur half too wide." << print_dimen(orig_dx) << " shrinking (ugh)\n"; + dx = 96 PT; } - + widx = int(rint(dx/12.0)); dx = widx*12.0; if (widx) widx --; else { - WARN << "slur too narrow\n"; + WARN << "slur too narrow " << print_dimen(orig_dx)<<"\n"; } Symbol s; @@ -109,36 +112,36 @@ Lookup::half_slur(int dy, Real &dx, int dir, int xpart) Symbol Lookup::slur (int dy , Real &dx, int dir) -{ // ugh. assuming pt here. - assert(dx >=0); +{ + assert(dx >=0 && abs(dir) <= 1); int y_sign = sign(dy); bool large = dy > 16; if (y_sign) { - large |= dx>= convert_dimen(4*16, "pt"); + large |= dx>= 4*16 PT; } else - large |= dx>= convert_dimen(4*54, "pt"); + large |= dx>= 4*54 PT; if (large) { return big_slur(dy, dx, dir); } - + Real orig_dx = dx; int widx = int(floor(dx/4.0)); // slurs better too small.. dx = 4.0 * widx; if (widx) widx --; else { - WARN << "slur too narrow\n"; + WARN << "slur too narrow: " << print_dimen(orig_dx) << "\n"; } int hidx = dy; if (hidx <0) hidx = -hidx; hidx --; - if (hidx > 16) - error("slur to steep"); - + if (hidx > 16) { + WARN<<"slur to steep: " << dy << " shrinking (ugh)\n"; + } Symbol s; s.dim.x = Interval(0,dx); @@ -152,8 +155,11 @@ Lookup::slur (int dy , Real &dx, int dir) if (dir < 0) idx += 128; } else { - if (dx >= convert_dimen(4*54, "pt")) - error("slur too wide"); + if (dx >= 4*54 PT) { + WARN << "slur too wide: " << print_dimen(dx) << + " shrinking (ugh)\n"; + dx = 4*54 PT; + } idx = widx; if (dir < 0) idx += 54; @@ -172,7 +178,7 @@ Lookup::slur (int dy , Real &dx, int dir) Symbol Lookup::big_slur(int dy , Real &dx, int dir) { - assert(dx >= convert_dimen(24,"pt")); + assert(dx >= 24 PT); Real slur_extra =abs(dy) /2.0 + 2; int l_dy = int(Real (dy)/2 + slur_extra*dir); int r_dy = dy - l_dy; diff --git a/src/textreg.cc b/src/textreg.cc new file mode 100644 index 0000000000..309bf6fe98 --- /dev/null +++ b/src/textreg.cc @@ -0,0 +1,53 @@ +/* + textreg.cc -- implement Text_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "textreg.hh" +#include "textitem.hh" + +Text_register::Text_register(Complex_walker*w) + : Request_register(w) +{ + text_p_ = 0; + set_dir(0); +} + +bool +Text_register::try_request(Request*req_l) +{ + if (!req_l->text()) + return false; + if (accepted_req_arr_.size() && + Text_req::compare(*req_l->text(), *accepted_req_arr_[0]->text())) + + return false; + + accepted_req_arr_.push(req_l); + return true; +} + +void +Text_register::process_request() +{ + + if (accepted_req_arr_.size()) { + text_p_ = new Text_item(accepted_req_arr_[0]->text(), 10); + announce_element(Staff_elem_info(text_p_, accepted_req_arr_[0], this)); + } +} +void +Text_register::do_pre_move_process() +{ + if (text_p_) { + text_p_->dir_i_ = dir_i_; + typeset_element(text_p_); + text_p_ = 0; + } +} +void +Text_register::set_dir(int i) +{ + dir_i_ = i; +} diff --git a/src/textspanner.cc b/src/textspanner.cc index 021b81fbbb..b6d90cbef4 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -3,6 +3,7 @@ #include "textspanner.hh" #include "textdef.hh" #include "debug.hh" +#include "paper.hh" NAME_METHOD(Text_spanner); @@ -29,20 +30,20 @@ Text_spanner::do_post_processing() { switch(spec.align_i_) { case 0: - tpos = support->center(); + text_off_ = support->center() + + Offset(0,support->dir_i_ * paper()->internote() * 4); // todo break; default: assert(false); break; - } - - + } } + Molecule* Text_spanner::brew_molecule_p() const { Atom tsym (spec.create_atom(paper())); - tsym.translate(tpos); + tsym.translate(text_off_); Molecule*output = new Molecule; output->add( tsym ); diff --git a/src/tstream.cc b/src/tstream.cc index 05e2e9c93e..d56c58a3c4 100644 --- a/src/tstream.cc +++ b/src/tstream.cc @@ -72,4 +72,4 @@ Tex_stream::operator<<(String s) } -/****************************************************************/ +/* *************************************************************** */ diff --git a/src/voice.cc b/src/voice.cc index 2e7b0b5111..8bccb12d8d 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -49,7 +49,7 @@ Voice::last() const l += i->duration; return l; } -/****************************************************************/ +/* *************************************************************** */ void Voice_element::print() const { diff --git a/src/voicegroup.cc b/src/voicegroup.cc index f3088d73e2..35de10df4f 100644 --- a/src/voicegroup.cc +++ b/src/voicegroup.cc @@ -1,76 +1,94 @@ #include "request.hh" -#include "complexwalker.hh" -#include "complexstaff.hh" #include "voicegroup.hh" #include "register.hh" +#include "textreg.hh" +#include "stembeamreg.hh" +#include "scriptreg.hh" +#include "complexwalker.hh" + static int temp_id_count; Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id) - : text_reg_(w_l), - stem_beam_reg_(w_l), - script_reg_(w_l) { walk_l_ = w_l; + text_reg_=new Text_register(w_l); + stem_beam_reg_= new Stem_beam_register(w_l); + script_reg_ = new Script_register(w_l); if (id=="") id = __FUNCTION__ + String(temp_id_count++); group_id_str_ = id; dir_i_ = 0; } +Voice_group_registers::~Voice_group_registers() +{ + delete text_reg_; + delete stem_beam_reg_; + delete script_reg_; +} void Voice_group_registers::pre_move_processing() { - stem_beam_reg_.pre_move_processing(); - script_reg_.pre_move_processing(); - text_reg_.pre_move_processing(); + stem_beam_reg_->pre_move_processing(); + script_reg_->pre_move_processing(); + text_reg_->pre_move_processing(); } void Voice_group_registers::post_move_processing() { - stem_beam_reg_.post_move_processing(); - text_reg_.post_move_processing(); - script_reg_.post_move_processing(); + stem_beam_reg_->post_move_processing(); + text_reg_->post_move_processing(); + script_reg_->post_move_processing(); } bool Voice_group_registers::try_request(Request*r_l) { if (r_l->groupfeature()) { - dir_i_ = r_l->groupfeature()->stemdir_i_; + set_dir(r_l->groupfeature()->stemdir_i_); return true; } - bool b = stem_beam_reg_.try_request(r_l); + bool b = stem_beam_reg_->try_request(r_l); if (!b) - b|= script_reg_.try_request(r_l); + b|= script_reg_->try_request(r_l); if (!b) - b|= text_reg_.try_request(r_l); + b|= text_reg_->try_request(r_l); return b; } void -Voice_group_registers::announce_element(Staff_elem_info i) +Voice_group_registers::acknowledge_element(Staff_elem_info i) { if (i.group_regs_l_!= this) return; - stem_beam_reg_.acknowledge_element(i); - script_reg_.acknowledge_element(i); - text_reg_.acknowledge_element(i); + stem_beam_reg_->acknowledge_element(i); + script_reg_->acknowledge_element(i); + text_reg_->acknowledge_element(i); } - void -Voice_group_registers::process_requests() +Voice_group_registers::set_dir(int i) { - stem_beam_reg_.process_request(); - if (dir_i_) - stem_beam_reg_.set_dir (dir_i_); + stem_beam_reg_->set_dir(i); + script_reg_->set_dir(i); + text_reg_->set_dir(i); - script_reg_.process_request(); - text_reg_.process_request(); + Array vr_arr (walk_l_->get_voice_regs(this)); + for (int j=0; jset_dir(i); +} +} +void +Voice_group_registers::process_requests() +{ + stem_beam_reg_->process_request(); + script_reg_->process_request(); + text_reg_->process_request(); } diff --git a/src/voiceregs.cc b/src/voiceregs.cc index fa95ae9e18..f7d63bd76f 100644 --- a/src/voiceregs.cc +++ b/src/voiceregs.cc @@ -1,56 +1,56 @@ -#include "rest.hh" -#include "notehead.hh" -#include "paper.hh" -#include "debug.hh" -#include "slur.hh" #include "request.hh" -#include "complexwalker.hh" -#include "complexstaff.hh" #include "voicegroup.hh" #include "register.hh" +#include "slurreg.hh" +#include "headreg.hh" Voice_registers::Voice_registers(Complex_walker*c_l, Voice *v_p) - : head_reg_(c_l), slur_reg_(c_l) { voice_l_ = v_p; + head_reg_ = new Notehead_register(c_l); + slur_reg_ = new Slur_register(c_l); +} +Voice_registers::~Voice_registers() +{ + delete head_reg_; + delete slur_reg_; } - bool Voice_registers::try_request(Request * r_l) { - bool b = head_reg_.try_request(r_l); + bool b = head_reg_->try_request(r_l); if (!b) - b = slur_reg_.try_request(r_l); + b = slur_reg_->try_request(r_l); return b; } void -Voice_registers::announce_element(Staff_elem_info i) +Voice_registers::acknowledge_element(Staff_elem_info i) { if (i.voice_l_ != voice_l_) return; - if (i.origin_reg_l_ != &slur_reg_) - slur_reg_.acknowledge_element(i); + if (i.origin_reg_l_ != slur_reg_) + slur_reg_->acknowledge_element(i); } void Voice_registers::pre_move_processing() { - head_reg_.pre_move_processing(); - slur_reg_.pre_move_processing(); + head_reg_->pre_move_processing(); + slur_reg_->pre_move_processing(); } void Voice_registers::post_move_processing() { - head_reg_.post_move_processing(); - slur_reg_.post_move_processing(); + head_reg_->post_move_processing(); + slur_reg_->post_move_processing(); } void Voice_registers::process_requests() { - head_reg_.process_request(); - slur_reg_.process_request(); + head_reg_->process_request(); + slur_reg_->process_request(); } bool @@ -59,128 +59,10 @@ Voice_registers::acceptable_request(Request*r) return (r->rest() || r->note() || r->slur()); } -/****************/ - -Notehead_register::Notehead_register(Complex_walker*w_l) - :Request_register(w_l) -{ - note_p_ = 0; -} - -bool -Notehead_register::try_request(Request *req_l) -{ - if (req_l->note() || req_l->rest()) - accepted_req_arr_.push(req_l); - else - return false; - - return true; -} - -void -Notehead_register::process_request() -{ - if (!accepted_req_arr_.size()) - return; - - Request* req_l = accepted_req_arr_.top(); - if (req_l->note()) { - Notehead*n_p = new Notehead(8); // ugh - note_p_ = n_p; - n_p->set_rhythmic(req_l->rhythmic()); - n_p->position = req_l->note()->height() + -2; - } else { - note_p_ = new Rest ( req_l->rhythmic()->balltype, - req_l->rhythmic()->dots); - if (req_l->rhythmic()->balltype <= 2) - note_p_->translate( - Offset(0, - 6 * walk_l_->staff()->paper()->internote())); - } - Staff_elem_info itinf(note_p_,req_l,this); - walk_l_->announce_element(itinf); -} - -void -Notehead_register::do_pre_move_process() -{ - if (note_p_) { - walk_l_->typeset_element(note_p_); - note_p_ = 0; - } -} - -/****************/ - -Slur_register::Slur_register(Complex_walker* w) - : Request_register(w) -{ -} - -bool -Slur_register::try_request(Request *req_l) -{ - if(!req_l->slur()) - return false; - - accepted_req_arr_.push(req_l); - return true; -} void -Slur_register::acknowledge_element(Staff_elem_info info) -{ - if (info.elem_p_->name() == String("Notehead")) { - Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh - for (int i = 0; i < slur_l_stack_.size(); i++) - slur_l_stack_[i]->add(head_p ); - for (int i = 0; i < end_slur_l_arr_.size(); i++) - end_slur_l_arr_[i]->add(head_p); - } -} -/* - abracadabra - */ -void -Slur_register::process_request() -{ - Array start_slur_l_arr_; - for (int i=0; i< accepted_req_arr_.size(); i++) { - Slur_req* slur_req_l = accepted_req_arr_[i]->slur(); - // end slur: move the slur to other array - if (slur_req_l->spantype == Span_req::STOP) { - if (slur_l_stack_.empty()) - warning("can't find slur to end", - slur_req_l->defined_ch_c_l_m); - else { - end_slur_l_arr_.push(slur_l_stack_.pop()); - requests_arr_.pop(); - } - } else if (slur_req_l->spantype == Span_req::START) { - // push a new slur onto stack. - //(use temp. array to wait for all slur STOPs) - Slur * s_p =new Slur; - requests_arr_.push(slur_req_l); - start_slur_l_arr_.push(s_p); - walk_l_->announce_element(Staff_elem_info(s_p, slur_req_l, this)); - } - } - for (int i=0; i < start_slur_l_arr_.size(); i++) - slur_l_stack_.push(start_slur_l_arr_[i]); -} - -void -Slur_register::do_pre_move_process() -{ - for (int i = 0; i < end_slur_l_arr_.size(); i++) - walk_l_->typeset_element(end_slur_l_arr_[i]); - end_slur_l_arr_.set_size(0); -} - -Slur_register::~Slur_register() +Voice_registers::set_dir(int i) { - for (int i=0; i < requests_arr_.size(); i++) { - warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m); - } + head_reg_->set_dir(i); + slur_reg_->set_dir(i); } diff --git a/src/wordwrap.cc b/src/wordwrap.cc index 469d2d1d29..90d4d542dc 100644 --- a/src/wordwrap.cc +++ b/src/wordwrap.cc @@ -2,13 +2,12 @@ #include "pscore.hh" #include "debug.hh" -/* el stupido. This should be done more accurately: +/** el stupido. This should be done more accurately: It would be nice to have a Dynamic Programming type of algorithm similar to TeX's */ - Array Word_wrap::solve() { @@ -64,7 +63,8 @@ Word_wrap::solve() curcol ++; break_idx_i++; } - mtor << "Adding cols~, next breakpoint " << break_idx_i << '\n'; + + *mlog << "[" <