From 47c90cd333d91fce969d1933fc8222ab9d23246c Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 18 Feb 1997 11:49:50 +0100 Subject: [PATCH] release: 0.0.32 --- .dstreamrc | 2 +- ANNOUNCE | 115 +++++++++++++ Documentation/CodingStyle.pod | 221 +++++++++++++++++++++++-- Documentation/Makefile | 4 +- Documentation/README.pod | 53 +++--- Documentation/error.pod | 20 +-- Documentation/index.pod | 76 +++++++++ Documentation/lilygut.pod | 74 ++------- Documentation/lilyinput.pod | 3 +- Documentation/make_website | 12 +- Generate.make | 2 +- Makefile | 4 +- NEWS | 28 ++++ README | 13 +- Sources.make | 57 ++++--- TODO | 52 ++++-- Variables.make | 13 +- configure | 3 +- flower/Makefile | 1 - flower/NEWS | 3 + flower/Sources.make | 23 +-- flower/Variables.make | 2 +- flower/assoc.hh | 4 +- flower/choleski.hh | 16 +- flower/compare.hh | 3 +- flower/cursor.hh | 13 +- flower/dataf.cc | 3 +- flower/dstream.hh | 6 +- flower/findcurs.hh | 12 -- flower/findcurs.inl | 37 ----- flower/handle.hh | 1 + flower/interval.hh | 13 +- flower/iterate.hh | 14 ++ flower/lgetopt.hh | 12 +- flower/list.hh | 14 +- flower/list.tcc | 22 +-- flower/matrix.hh | 20 +-- flower/path.cc | 7 +- flower/path.hh | 3 +- flower/pcursor.hh | 10 +- flower/plist.hh | 13 +- flower/scalar.hh | 4 +- flower/string.cc | 5 +- flower/string.hh | 9 +- flower/stringutil.hh | 10 +- flower/textdb.hh | 8 +- flower/textstr.hh | 3 +- flower/tsmat.hh | 92 ----------- flower/tsmat.tcc | 151 ----------------- flower/tvsmat.hh | 140 ---------------- flower/unionfind.hh | 20 +-- flower/varray.hh | 16 +- flower/vector.hh | 3 +- flower/vsmat.hh | 86 +++++----- hdr/bar.hh | 4 +- hdr/barreg.hh | 30 ++++ hdr/beam.hh | 7 +- hdr/boxes.hh | 4 +- hdr/clef.hh | 23 --- hdr/clefitem.hh | 9 +- hdr/clefreg.hh | 29 ++++ hdr/command.hh | 85 ---------- hdr/commandrequest.hh | 117 +++++++++++++ hdr/complexcolumn.hh | 15 +- hdr/complexstaff.hh | 7 +- hdr/complexwalker.hh | 82 ++++++---- hdr/getcommand.hh | 18 -- hdr/grouping.hh | 5 + hdr/inputcommand.hh | 35 ---- hdr/inputcommands.hh | 59 ------- hdr/inputmusic.hh | 5 +- hdr/inputscore.hh | 22 ++- hdr/inputstaff.hh | 14 +- hdr/key.hh | 8 +- hdr/keyitem.hh | 14 +- hdr/keyreg.hh | 33 ++++ hdr/leastsquares.hh | 4 + hdr/lexer.hh | 4 +- hdr/linespace.hh | 13 +- hdr/localkeyitem.hh | 4 +- hdr/localkeyreg.hh | 5 +- hdr/lyriccolumn.hh | 17 +- hdr/lyricstaff.hh | 20 +-- hdr/lyricwalker.hh | 9 +- hdr/meter.hh | 5 +- hdr/meterreg.hh | 28 ++++ hdr/misc.hh | 4 +- hdr/musicalrequest.hh | 185 +++++++++++++++++++++ hdr/parseconstruct.hh | 8 +- hdr/pcol.hh | 17 +- hdr/proto.hh | 38 +++-- hdr/pscore.hh | 16 +- hdr/qlp.hh | 7 +- hdr/qlpsolve.hh | 8 +- hdr/register.hh | 79 +++++---- hdr/reqtodo.hh | 83 ++++++++++ hdr/request.hh | 299 +++------------------------------- hdr/sccol.hh | 18 +- hdr/score.hh | 23 ++- hdr/scorewalker.hh | 36 ++++ hdr/source.hh | 2 +- hdr/sourcefile.hh | 12 +- hdr/spanner.hh | 8 +- hdr/staff.hh | 60 +++---- hdr/staffcommands.hh | 32 ---- hdr/staffeleminfo.hh | 28 ++++ hdr/staffwalker.hh | 29 ++-- hdr/stcol.hh | 33 ++-- hdr/stem.hh | 19 +-- hdr/tex.hh | 3 +- hdr/textdef.hh | 2 +- hdr/textspanner.hh | 6 +- hdr/timedescription.hh | 14 +- hdr/tstream.hh | 4 +- hdr/voice.hh | 9 +- init/table_sixteen.ini | 12 +- input/Makefile | 2 +- input/cadenza.ly | 23 ++- input/coriolan-alto.ly | 15 +- input/error.ly | 7 +- input/kortjakje.ly | 11 +- input/maartje.ly | 22 +-- input/martien.ly | 76 ++------- input/mlalt.ly | 1 + input/mlcello.ly | 2 +- input/mlvio1.ly | 1 + input/mlvio2.ly | 2 +- input/pavane.ly | 25 ++- input/rhythm.ly | 60 +++++++ input/scales.ly | 12 +- input/scsii-menuetto.ly | 31 ++-- input/standchen.ly | 22 +-- input/twinkle.ly | 10 +- input/wohltemperirt.ly | 33 ++-- src/bar.cc | 9 +- src/barreg.cc | 83 ++++++++++ src/beam.cc | 9 +- src/break.cc | 6 +- src/calcideal.cc | 2 +- src/clef.cc | 32 ---- src/clefitem.cc | 12 +- src/clefreg.cc | 95 +++++++++++ src/command.cc | 31 ---- src/commandrequest.cc | 141 ++++++++++++++++ src/complexcolumn.cc | 102 ++++++++++++ src/complexprint.cc | 105 ------------ src/complexstaff.cc | 88 ++++------ src/complexwalker.cc | 239 ++++++++++++++------------- src/getcommands.cc | 65 -------- src/grouping.cc | 34 +++- src/headreg.cc | 4 +- src/inputcommand.cc | 181 -------------------- src/inputcommands.cc | 238 --------------------------- src/inputmusic.cc | 2 +- src/inputscore.cc | 57 ++++--- src/inputstaff.cc | 58 +++---- src/key.cc | 49 +----- src/keyitem.cc | 32 ++-- src/keyreg.cc | 90 ++++++++++ src/lexerinit.cc | 4 +- src/localkeyitem.cc | 15 +- src/localkeyreg.cc | 25 +-- src/lookup.cc | 2 +- src/lyriccolumn.cc | 34 +--- src/lyricitem.cc | 4 +- src/lyricstaff.cc | 17 +- src/lyricwalker.cc | 44 ++--- src/meter.cc | 2 +- src/meterreg.cc | 63 +++++++ src/misc.cc | 20 ++- src/mylexer.cc | 14 +- src/note.cc | 124 +++++--------- src/notehead.cc | 2 +- src/parser.y | 231 ++++++++++---------------- src/pcol.cc | 8 +- src/pscore.cc | 2 +- src/qlp.cc | 19 ++- src/qlpsolve.cc | 11 +- src/register.cc | 17 +- src/request.cc | 98 +++-------- src/sccol.cc | 22 ++- src/score.cc | 73 +++++---- src/scorewalker.cc | 109 +++++++++++++ src/script.cc | 2 +- src/scriptreg.cc | 2 +- src/slurreg.cc | 7 +- src/source.cc | 4 +- src/sourcefile.cc | 74 ++++----- src/staff.cc | 175 +++++--------------- src/staffcommands.cc | 208 ----------------------- src/staffelem.cc | 5 +- src/staffwalker.cc | 111 ++++++++----- src/stcol.cc | 63 ++++--- src/stem.cc | 4 +- src/stembeamreg.cc | 16 +- src/template1.cc | 3 +- src/template2.cc | 4 +- src/template3.cc | 10 +- src/textdef.cc | 2 +- src/textitem.cc | 2 +- src/textreg.cc | 1 + src/timedescription.cc | 78 ++++----- src/voice.cc | 61 ++----- src/voiceelt.cc | 65 ++++++++ src/voicegroup.cc | 13 +- src/voiceregs.cc | 2 +- src/warn.cc | 2 +- src/wordwrap.cc | 3 +- 208 files changed, 3535 insertions(+), 3840 deletions(-) create mode 100644 ANNOUNCE create mode 100644 Documentation/index.pod delete mode 100644 flower/findcurs.hh delete mode 100644 flower/findcurs.inl delete mode 100644 flower/tsmat.hh delete mode 100644 flower/tsmat.tcc delete mode 100644 flower/tvsmat.hh create mode 100644 hdr/barreg.hh delete mode 100644 hdr/clef.hh create mode 100644 hdr/clefreg.hh delete mode 100644 hdr/command.hh create mode 100644 hdr/commandrequest.hh delete mode 100644 hdr/getcommand.hh delete mode 100644 hdr/inputcommand.hh delete mode 100644 hdr/inputcommands.hh create mode 100644 hdr/keyreg.hh create mode 100644 hdr/meterreg.hh create mode 100644 hdr/musicalrequest.hh create mode 100644 hdr/reqtodo.hh create mode 100644 hdr/scorewalker.hh delete mode 100644 hdr/staffcommands.hh create mode 100644 hdr/staffeleminfo.hh create mode 100644 input/rhythm.ly create mode 100644 src/barreg.cc delete mode 100644 src/clef.cc create mode 100644 src/clefreg.cc delete mode 100644 src/command.cc create mode 100644 src/commandrequest.cc create mode 100644 src/complexcolumn.cc delete mode 100644 src/complexprint.cc delete mode 100644 src/getcommands.cc delete mode 100644 src/inputcommand.cc delete mode 100644 src/inputcommands.cc create mode 100644 src/keyreg.cc create mode 100644 src/meterreg.cc create mode 100644 src/scorewalker.cc delete mode 100644 src/staffcommands.cc create mode 100644 src/voiceelt.cc diff --git a/.dstreamrc b/.dstreamrc index 5c98922777..b4d6029922 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -38,7 +38,7 @@ Input_cursor 1 Commands_at 1 Input_command 1 Time_description 1 -Melodic_req 1 +Melodic_req 0 Stem_req 0 Group_change_req 1 Script_req 1 diff --git a/ANNOUNCE b/ANNOUNCE new file mode 100644 index 0000000000..56579bf36b --- /dev/null +++ b/ANNOUNCE @@ -0,0 +1,115 @@ + +CALL FOR HACKERS: LilyPond, the Music Typesetter + +[Sorry if this is a bit off-topic; I want to announce this software to +small crowd, because it is still test-stage] + +Hi net! + +this is to announce the availability of the first public release +(v0.1) of my music typesetter. + +WHAT IS LILYPOND + +Technically it is a preprocessor which generates TeX +(or LaTeX) output which contains information to typeset a musical +score. Practically it is a typesetter, which only uses TeX as an +output medium. (this is handy because there exist music fonts for TeX) + +HOW DOES IT WORK + +The input is a script file (example appended) which is read. The +script file is a "music definition", ie, you type the melody as if it +is read out loud + +LilyPond interprets this melody and generates appropriate output items +(balls, stems, beams), and calculates where they should be put. Then +it outputs a TeX file. Warning: this said calculations is *slow* (a full +page of music typically takes 1 minute on my 486/66) + +WHY IS THIS A TEST VERSION + +There a lot of advanced features (grace notes, piano staffs) which are +VapourFeatures (tm). We're not sure about the language. It may change; +having a large user base is a burden then. + +WHY A CALL FOR HACKERS + +Currently, the development has three people. I'd this project to have +more people working on it (there is a lot of work to be done) I think +this program is pretty original, so join in if you anything about +music and computers! + +As an aside, I really like the anarchist approach of linux development. + +WHAT HAS TO BE DONE + +LilyPond is written in Gnu C++, and it is (imo) written very cleanly +(Lots of classes, lots of comments, small files/small functions) and +with extensions in mind. + + - Coding. For this time, there won't any biggish (global) +source hackings. There are a lot of small projects which could use +some work. + + - Some TeX hacking. I know little about TeX + + - Documentation. I don't have time for this + +I WANT MORE INFO! + +You can download it at: + + ftp://pcnov095.win.tue.nl/pub/lilypond + +or visit the incredibly lousy webpage at: + + http://www.stack.nl/~hanwen/lilypond/index.html + + +EXAMPLE INPUT + + % twinkle twinkle little star + melody = music { + $\clef\violin + c c | g g | a a | g g | + f f | e e | d d8.( e16 | )c2 | + + g g | f f | e e | d d | + g g | f f | e( e8. f16 | e )d | + + c c | g g | a a | g g | + f f | e e | d d8.( e16 | )c2 + $ + } + + text2 = music { + @ + \textstyle "roman" + When the bla- zing sun is gone,2 + When he no- thing shines up- on,2 + Then you show your lit- tle light,2 + Twin- kle, twin- kle, all the night.2 + Twin- kle, twin- kle, lit- tle star,2 + How I won- der what you are!2 + @ + } + + english_staf = staff { + lyric + music { text2 } + } + + score { + staff { melodic music { melody } } + staff { english_staf } + paper { + unitspace 2.5cm + } + commands { + meter {2 * 4} + skip 24*2 + bar "||" + } + } + diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index 2b86193338..fdbab0668b 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -34,7 +34,7 @@ in emacs: Class::member() Type Class::member_type_ -the C is a Hungarian notation postfix for $C$. +the C is a Hungarian notation postfix for $C$. See below =head2 COMMENTS @@ -42,25 +42,26 @@ the C is a Hungarian notation postfix for $C$. The source is commented in the DOC++ style. Check out doc++ at http://www.zib.de/Visual/software/doc++/index.html - /// short description + /** + short description. + Long class documentation. + */ class Class { - /// short description - /** - long description + /** short description. + long description */ Data data_member_; - /****************/ - /// short memo + /** - long doco of member() + short memo. long doco of member() */ member(); + + /// memo only + boring_member(); }; - /** - Class documentation. - */ Unfortunately most of the code isn't really documented that good. @@ -87,13 +88,207 @@ Standard methods: /// print *this (and substructures) to debugging log void print() const - /// add some data to *this; - add( .. ) /** + protected member. Usually invoked by non-virtual A_virtual_func() + */ + virtual do_A_virtual_func() + + /**add some data to *this. Presence of these methods usually imply that it is not feasible to this via a constructor */ + add( .. ) /// replace some data of *this set( .. ) +=head1 HUNGARIAN NOTATION NAMING CONVENTION + +Proposed is a naming convention derived from the so-called I. + +=head2 Hungarian + +The Hungarian Notation was conceived by +or at least got its name from, +the hungarian programmer x. +It is a naming convention with the aim +to make code more readable (for fellow programmers) +and more accessible for programmers +that are new to a project. + +The essence of the Hungarian Notation +is that every identifier has a part +which identifies its type +(for functions this is the result type). +This is particularly useful in object oriented programming, +where a particular object implies a specific interface +(a set of member functions, perhaps some redefined operators), +and for accounting heap allocated memory pointers and links. + +=head2 Advantages + +Another fun quote from Microsoft Secrets: + + + The Hungarian naming convention gives developers the ability + to read other people's code relatively easily, with a minmum + number of comments in the source code. Jon De Vann estimated + that only about 1 percent of all lines in the Excel product + code consist of comments, but the code is still very + understandable due to the use of Hungarian: "if you look at + our source code, you also notice very few comments. Hungarian + gives us the ability to go in and read code..." + + +Wow! If you use Hungarian you don't have to document your software! +Just think of the hours I have wasted documenting while this "silver bullet" +existed. I feel so stupid and ashamed! + +=head2 Disadvantages + +=over 5 + +=item * +more keystrokes (disk space!) + +=item * +it looks silly C + +=item * +it looks like code from micro suckers + +=item * +(which) might scare away some (otherwise good?) +progammers, or make you a paria in the free +software community + +=item * +it has ambiguities + +=item * +not very useful if not used consistently + +=item * +usefullness in I +(but how many classes is very large?) +remains an issue. + +=back + + + +=head2 Proposal + +=over 5 + +=item * +learn about cut and paste / use emacs or vi +or lean to type using ten fingers + +=item * +Use emacs dabbrev-expand, with dabbrev-case-fold-search set to nil. + +=item * +use no, or pick less silly, abbrvs. + +=item * +use non-ambiguous postfixes C +=back + +Macros, Cs and Cs are all uppercase, +with the parts of the names separated by underscores. + +=head2 Types + +=over 5 + +=item C +bool + +=item C +bit + +=item C +char + +=item C +float + +=item C +signed integer + +=item C +string class + +=item C +Zero terminated c string + +=item C +unsigned integer + +=back + +=head2 User defined types + + + /** Slur blah. blah. + (slur) + */ + class Slur {}; + Slur* slur_p = new Slur; + +=head2 Modifiers + +The following types modify the meaning of the prefix. +These are precede the prefixes: + +=over 5 + +=item C +array + +=item C +user built array. + +=item C +const + +=item C +temporary pointer to object (link) + +=item C

+pointer to newed object + +=item C +reference + +=back + +=over 5 + +=item C +Variable loop: an integer + +=item C +Temporary variable: an unsigned integer + +=item C +Variable Test: a character + +=item C +Variable first_name: a String class object + +=item C +Variable first_name: a C array + +=item C +Variable Loop: an C that you must delete + +=item C +Variable Loop: an C that you must not delete + +=back + + + diff --git a/Documentation/Makefile b/Documentation/Makefile index c025773895..f8211b708c 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,9 +1,9 @@ PODS=README.pod CodingStyle.pod lilygut.pod lilyinput.pod error.pod\ - faq.pod + faq.pod index.pod TXTS=$(PODS:.pod=.txt) MANS=$(PODS:.pod=.1) HTMLS=$(PODS:.pod=.html) -DISTFILES=$(PODS) Makefile lelie_logo.png make_website #lelieblond.gif +DISTFILES=$(PODS) Makefile lelie_logo.png make_website default: diff --git a/Documentation/README.pod b/Documentation/README.pod index d8f0d1eae7..87e2b65fbe 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -22,7 +22,7 @@ ASCII script input, with identifiers (for music reuse), customizable notenames, customizable fontset =item * -multiple staffs in one score +Multiple staffs in one score. Each staff can have a different meters. =item * multiple stafftypes (melodic, rhythmic) [broken from pl28 on] @@ -33,15 +33,14 @@ triplets, general n-plet (triplet, quadruplets, etc.), lyrics =item * multiple voices within one staff; beams optionally shared -between voices. +between voices. (well, more than 2 voices won't look pretty) =item * multiple scores within one input file. Each score is output to a different file. =item * -clef changes, meter changes, cadenza-mode, declaring markings -in the music, repeat bars +clef changes, meter changes, cadenza-mode, key changes, repeat bars =back @@ -96,7 +95,7 @@ LilyPond does not display notes directly, nor will it be rehacked to be used interactively. LilyPond writes output to a file. It will not be extended to play music, or to recognize music. -We're thinking about adding MIDI output, though +It will output MIDI, though (at some stage) =item * LilyPond is intended to run on Unix platforms, but it should @@ -112,8 +111,6 @@ broken systems. =back - - =head1 OPTIONS =over 5 @@ -124,7 +121,9 @@ add F to the search path for input files. =item B<-d,--debug>, -debugging. LilyPond will read the file F<.dstreamrc>, which tells for what functions to produce copious debugging output. +Turn debugging info. LilyPond will read the file F<.dstreamrc>, which +tells for what functions and classes may produce copious debugging +output. =item B<-w,--warranty>, @@ -138,9 +137,9 @@ Set the default output file to F. Show a summary of usage -=item B<--init, -i> +=item B<-i,--init=>F -set init file (default: symbol.ini) +set init file (default: F) =item B<--include, -I> add to file search path. @@ -163,11 +162,13 @@ Compilation: =over 5 =item * - Unix. Any decent Linux distribution is fine. LilyPond is known to run -on Linux, AIX, Digital Unix and Solaris +Unix. LilyPond is known to run on Linux, AIX, Digital Unix and +Solaris (if you have the Cygnus WIN32 port of the GNU utils, it will +even work in Lose NT/95) =item * -GNU C++ v2.7 or better, with libg++. Version 2.7.2 or better recommended. +GNU C++ v2.7 or better, with libg++ installed. Version 2.7.2 +or better recommended. I doubt if it will compile with AT&T CC. =item * GNU make. @@ -176,7 +177,7 @@ GNU make. flex (2.5.1 or better) =item * -Bison or YACC. +Bison. =item * The "Flower" library, which should be available from the same @@ -192,6 +193,10 @@ LilyPond does use a lot of resources. For operation you need the following: =over 5 +=item * +a fast computer (well; full page of music typically takes 1 +minute on my 486/66, using the DEBUG compile) + =item * TeX @@ -266,10 +271,20 @@ quality. If you're not discouraged; this is what I type in my xterm: This is what the output looks like over here: - hw:~/musix/spacer$ lilypond input/maartje.ly - LilyPond 0.0.27/FlowerLib 1.0.23. Compile: Feb 5 1997, 00:28:13 (g++ 2.7.2) - Parsing ... [./init//symbol.ini[./init/dutch.ini][./init/script.ini][./init/table_sixteen.ini]][./input/maartje.ly] - Processing music ... Preprocessing ... Calculating ... Postprocessing ... + LilyPond 0.0.pre32-3/FlowerLib 1.0.27. Compile: Feb 18 1997, 11:21:57 (g++ 2.7.2) + Parsing ... [./init//symbol.ini[./init//dutch.ini][./init//script.ini][./init//table_sixteen.ini]][./input/wohltemperirt.ly] + Setting up music ...Processing music ............ + Preprocessing ... + Calculating column positions ... [3][6][9] + Postprocessing ... + warning: slope_index(): beam steeper than 0.5 (-0.555556) + warning: slope_index(): beam steeper than 0.5 (-0.588346) + warning: slope_index(): beam steeper than 0.5 (-0.523166) + warning: slope_index(): beam steeper than 0.5 (0.571915) + warning: slope_index(): beam steeper than 0.5 (-0.555556) + warning: slope_index(): beam steeper than 0.5 (-0.588346) + warning: slope_index(): beam steeper than 0.5 (-0.523166) + warning: slope_index(): beam steeper than 0.5 (0.571915) output to lelie.out... hw:~/musix/spacer$ tex test @@ -329,7 +344,7 @@ among others: lilygut, lilyinput, error, faq, =head1 REMARKS LilyPond has no connection with the music package RoseGarden, other -than the names being similar. +than the names being similar :-) =head1 HISTORY diff --git a/Documentation/error.pod b/Documentation/error.pod index 0a73c5b627..e6ae1a689c 100644 --- a/Documentation/error.pod +++ b/Documentation/error.pod @@ -10,22 +10,4 @@ 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. - - can't find slur to end - -Eg. with: - - {d g ( } ) g8 - -The {} part generates two one-note Cs, the C another, which -is translated to start right after the chord. Slurs are contained -within voices. LilyPond can't find a slur which started in this -C's voice. (what should C<{ d( g ( } )g8 )g8 }> look like? Use - - { \music { d } \music { g()g8 } } - - +[yep.. has to be written..] diff --git a/Documentation/index.pod b/Documentation/index.pod new file mode 100644 index 0000000000..06364733d4 --- /dev/null +++ b/Documentation/index.pod @@ -0,0 +1,76 @@ +=head1 NAME + +LilyPond -- the Webpage + +=head1 DESCRIPTION + +Excuse me for this poor page. I don't really have time for doing this.. + +[and yes, i write webpages in POD :-] + +=head1 DOCUMENTATION + +=item * + +README + + +=item * + +internal structures. + + +=item * + +notes on the input format + + +=item * + +FAQ + + +=item * + +errors + + +=item * + +The lilypond logo (in PNG format) + + + +=item * + +An example inputfile: from Bach's WTK: c-minor fugue + + +=item * + +A Gif file of the example + + +=item * + +PS output + + diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index 5633ee211a..e348b644d0 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -8,6 +8,10 @@ This page documents some aspects of the internals of LilyPond. Some of this stuff comes from e-mail I wrote, some from e-mail others wrote, some are large comments taken away from the headers +You should use doc++ to take a peek at the sources. + +[have to do more doco; see TODO] + =head1 OVERVIEW LilyPond is a "5-pass" system: @@ -170,6 +174,10 @@ registers. There are a few groups: =item * Staff wide, contains Local_key_register + Bar_register + Key_register + Meter_register + Clef_register =item * Voice group, contains @@ -186,36 +194,6 @@ Voice, contains =item 1 -=head1 COMMANDS - - -This table decribes the proper order for the different commands: - - -=head2 interpret - - which priority - ======================== - - key 200 - clef 190 - meter 180 - bar 170 - -=head2 typeset - - which priority - ======================== - - bar 100 - clef 90 - currentclef 80 - key 70 - currentkey 60 - meter 40 - - - =head1 BREAKING [Source files: F, F] @@ -317,39 +295,6 @@ concept of pre- and post-breaks. minimum distance to other columns, to prevent symbols from running into symbols of other columns.) -=head1 POINTERS - -This describes the ownership of certain classes in LilyPond. + -signifies a "list of". (This is not complete) - - Score: - Paperdef - Staff+ - Score_commands - Score_columns+ - PScore - - Staff: - Voice - Staff_column+ - Command+ - - - Voice: - Voice_element - - Voice_element: - Request+ - - - PScore: - PStaff+ - PCol+ - Idealspacing+ - Item+ - Spanner+ - Spanner+ (broken) - =head1 SEE ALSO =head2 References @@ -401,7 +346,8 @@ Muziek'' afstudeerscriptie Bestuurlijke informatica, no 45327, Erasmus universiteit Rotterdam, 1991. (``An automated system for printing music'' Master's Thesis Management and Computer Science.) -C. Roemer, The Art of Music Copying. Roerick music co., Sherman Oaks (CA), 1973. +C. Roemer, The Art of Music Copying. Roerick music co., Sherman Oaks +(CA), 1973. Rosecrans, Glen. Music Notation Primer. New York: Passantino, 1979. diff --git a/Documentation/lilyinput.pod b/Documentation/lilyinput.pod index dfdd597948..b7d4888006 100644 --- a/Documentation/lilyinput.pod +++ b/Documentation/lilyinput.pod @@ -4,7 +4,8 @@ LilyInput - LilyPond input format =head1 DESCRIPTION -This page documents the the LilyPond input format, mudela. +This page globally documents the the LilyPond input format, mudela. +To get a better impression, please study some examples. =head2 Overview diff --git a/Documentation/make_website b/Documentation/make_website index d241527ff1..4b1a9aaf4a 100755 --- a/Documentation/make_website +++ b/Documentation/make_website @@ -25,9 +25,13 @@ foreach $a (<*.html>) foreach $a (@examples) { $texfile="test"; - system "cd ..; lilypond input/$a; tex $texfile; dvips $texfile;"; - system "mv ../$texfile.ps $a.ps"; - system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif" + system "cd ..; lilypond input/$a; tex $texfile;"; + system "dvips -o $texfile.ps $texfile;"; + system "mv ../$texfile.ps $a.ps;". + "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif" } -system "tar cfz website.tgz *.html *.gif *.png *.ps " +system "mkdir docxx; make -C.. docxx; ln ../docxx/* ./docxx/;" + +system "tar cf website.tar *.html *.gif *.png *.ps docxx/;" . +"gzip -9 website.tar;" diff --git a/Generate.make b/Generate.make index 08d53ba78c..701c6d79b0 100644 --- a/Generate.make +++ b/Generate.make @@ -7,7 +7,7 @@ parsheadnew=$(HEADERDIR)/parser.hh $(CCDIR)/parser.cc: $(CCDIR)/parser.y $(BISON) -d $< (if diff $(parsheadorig) $(parsheadnew)>/dev/null; then \ - echo leaving $(parsheadnew); \ + echo Ignoring $(parsheadorig); \ else \ mv $(parsheadorig) $(parsheadnew); \ fi ) diff --git a/Makefile b/Makefile index 7af694d132..f34bcbc4ca 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ include Variables.make $(exe): $(obs) $(STRIPDEBUG) $(STABLEOBS) - $(CXX) -o $@ $^ $(LOADLIBES) + $(LINKER) -o $@ $^ $(LOADLIBES) .PHONY: clean docxx @@ -31,7 +31,7 @@ doc: # doc++ documentation of classes docxx: $(progdocs) - doc++ -p -d $(DOCDIR) $^ + doc++ -kp -d $(DOCDIR) $^ $(OBJECTDIR)/%.o: $(CCDIR)/%.cc $(DODEP)\ diff --git a/NEWS b/NEWS index 1899d8f4c7..34f241725c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,31 @@ +pl 32 + - multiple meters, see rhythm.ly + + +pl 32-2 + - skip syntax/Skip_req + - command carnage + - score_wide_music: commands in staff now override commands in score. +Internal: + - Key_register + - Bar_register + - Meter_register + - meters now kept in baseclass Staff_walker + - Score_walker (to ease MIDI output) +Doc: + - Hungarian doco added to CodingStyle + +pl 32-1 + - music processing speedup + - website added to doco + - clef must *inside* music + - fixed spurious "beam too narrow" messages. +Internal + - merge musical / non-musical staff_column + - musical/ non-musical requests + - Clef_register + - split up request.hh, Musical_req vs. Nonmusical_req + pl 31 Examples diff --git a/README b/README index 414facda00..8c2b831b5a 100644 --- a/README +++ b/README @@ -1,3 +1,11 @@ +IMPORTANT: if you have downloaded a + + *.pre* + +version, then this is version is *not* meant for producing nice output +(but to keep your patchsets up to date) + +==================== Please refer to the directory Documentation/, Documentation/README.* To generate the pretty-printed docs, do this: @@ -16,4 +24,7 @@ criticism, comments, bugreports, patches, etc. Please send e-mail to hanwen@stack.urc.tue.nl -Have fun! \ No newline at end of file +Have fun! + +====================== + diff --git a/Sources.make b/Sources.make index dad8bf2734..ffb0f96cd5 100644 --- a/Sources.make +++ b/Sources.make @@ -1,65 +1,68 @@ # -*- Makefile-*- -# sourcefiles to be shipped. Also for dependencies +# sourcefiles to be shipped. Also used for dependencies -hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\ - colhpos.hh command.hh complexcolumn.hh \ +hdr= bar.hh barreg.hh beam.hh boxes.hh break.hh clefreg.hh clefitem.hh\ + colhpos.hh commandrequest.hh complexcolumn.hh \ complexwalker.hh complexstaff.hh\ const.hh debug.hh dimen.hh directionalspanner.hh\ - getcommand.hh glob.hh grouping.hh headreg.hh idealspacing.hh\ - identifier.hh identparent.hh inputcommand.hh inputcommands.hh\ + glob.hh grouping.hh headreg.hh idealspacing.hh\ + identifier.hh identparent.hh \ inputmusic.hh inputscore.hh inputstaff.hh item.hh key.hh keyitem.hh\ + keyreg.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 meter.hh misc.hh\ - molecule.hh moment.hh notehead.hh notename.hh offset.hh paperdef.hh\ + main.hh meter.hh meterreg.hh misc.hh\ + molecule.hh moment.hh musicalrequest.hh\ + notehead.hh notename.hh offset.hh paperdef.hh\ parseconstruct.hh pcol.hh proto.hh pscore.hh pstaff.hh qlp.hh\ - qlpsolve.hh register.hh request.hh rest.hh \ + qlpsolve.hh register.hh reqtodo.hh request.hh rest.hh \ sccol.hh score.hh\ - scoreline.hh script.hh scriptdef.hh scriptreg.hh \ + scoreline.hh scorewalker.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\ + spanner.hh staff.hh\ + staffelem.hh staffeleminfo.hh staffline.hh staffsym.hh stembeamreg.hh\ stcol.hh stem.hh staffwalker.hh symbol.hh symtable.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\ +mycc=bar.cc barreg.cc beam.cc boxes.cc break.cc calcideal.cc clefreg.cc\ + clefitem.cc colhpos.cc commandrequest.cc\ + complexcolumn.cc complexstaff.cc complexwalker.cc \ + debug.cc dimen.cc\ directionalspanner.cc\ - getcommands.cc grouping.cc groupregs.cc headreg.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\ + inputmusic.cc inputscore.cc\ + inputstaff.cc item.cc key.cc keyitem.cc \ + keyreg.cc keyword.cc\ leastsquares.cc lexerinit.cc linespace.cc \ localkeyitem.cc localkeyreg.cc lookup.cc\ lyriccolumn.cc lyricitem.cc lyricstaff.cc lyricwalker.cc\ - main.cc meter.cc\ + main.cc meter.cc meterreg.cc\ misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\ paperdef.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\ register.cc request.cc rest.cc sccol.cc score.cc\ - scoreline.cc scores.cc script.cc scriptdef.cc scriptreg.cc \ - slur.cc\ + scoreline.cc scores.cc scorewalker.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 staffsym.cc\ - stembeamreg.cc\ - stcol.cc stem.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 textreg.cc textspanner.cc\ - timedescription.cc tstream.cc voice.cc voiceregs.cc voicegroup.cc\ + timedescription.cc tstream.cc voice.cc voiceelt.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\ template5.cc template6.cc version.cc # a bit of a hack to keep exec size under control. -stablecc=request.cc bar.cc boxes.cc break.cc clef.cc getcommands.cc grouping.cc\ +stablecc=request.cc bar.cc boxes.cc break.cc \ item.cc keyword.cc leastsquares.cc \ - linepstaff.cc linespace.cc lookup.cc molecule.cc meter.cc\ + lookup.cc molecule.cc meter.cc\ paperdef.cc parser.cc lexer.cc pstaff.cc qlp.cc qlpsolve.cc\ template1.cc template2.cc template3.cc template4.cc\ template5.cc template6.cc version.cc tstream.cc tex.cc\ diff --git a/TODO b/TODO index ab8df44987..1803ad21c3 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,29 @@ + +before 0.1 + + * martien.ly, standchen.ly + + * pushgroup, popgroup. + + * basic dynamics + + * triplet notation + + * midi output + + * decent TeX page layout + + * < .. > vs. { .. } + 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 - * key undo - * key print if + * key print if clef change. + + * $cis ( | ) cis$ SEVERELY LACKING: @@ -24,11 +41,15 @@ INPUTLANGUAGE * rest name configurable + * '*' vs. '/' + SMALLISH PROJECTS + * bar numbers + * read from mmap directly: study yy_scan_buffer - * binsearch for notenames + * binsearch/hash for notenames * stafftypes: voice names/ instrument names. @@ -56,10 +77,9 @@ SMALLISH PROJECTS * fix linking: `Warning: size of symbol' -BIGGISH PROJECT + * collision Request_register. - * merge musical & non-musical column. Scrap Commands in favour - of Requests, and do multiparallel meters + * LilyPond .rpm and .deb DOC @@ -69,11 +89,13 @@ DOC * a decent webpage + * a test suite + FUTURE - * warning: beam(): Beam too narrow: beam gen not per stem + * Register_container baseclass - * put scripts on barcommands + * put scripts on bars * glissando @@ -85,7 +107,7 @@ FUTURE * Implement all requests - * merge key{item} & localkey{item} + * merge key{item} & localkey{item}? * QLP for beams? @@ -93,6 +115,10 @@ FUTURE * eentje/tweetje + * piano staff + + * abbreviations a4*8 + IDEAS * enter Requests directly @@ -108,8 +134,6 @@ IDEAS * merge Atom and Symbol? - * merge Command/Input_command. - * merge common code of Item, Atom/Molecule * Spacing_request for manually adjusting spacing @@ -125,4 +149,6 @@ IDEAS * PostScript output (esp. Beams, Slurs, etc) - * caching breakpoints + * caching breakpoints + + * use exceptions? \ No newline at end of file diff --git a/Variables.make b/Variables.make index 6d2ad10580..6c75665757 100644 --- a/Variables.make +++ b/Variables.make @@ -1,9 +1,9 @@ -# -*-make-*- +# -*-Makefile-*- # version info MAJVER=0 MINVER=0 -PATCHLEVEL=31 +PATCHLEVEL=32 @@ -66,12 +66,13 @@ include Sources.make gencc=parser.cc lexer.cc cc=$(mycc) $(gencc) +MY_CCSOURCE=$(addprefix $(CCDIR)/, $(mycc)) CCSOURCE=$(addprefix $(CCDIR)/, $(cc)) obs=$(addprefix $(OBJECTDIR)/,$(cc:.cc=.o)) ALLDEPS=$(addprefix $(DEPDIR)/,$(cc:.cc=.dep)) STABLEOBS=$(addprefix $(OBJECTDIR)/,$(stablecc:.cc=.o)) HEADERS=$(addprefix $(HEADERDIR)/,$(hdr)) -progdocs=$(HEADERS) #$(CCSOURCE) +progdocs=$(HEADERS) $(MY_CCSOURCE) #dist .EXPORT_ALL_VARIABLES: @@ -86,7 +87,7 @@ othersrc=lexer.l parser.y SCRIPTS=make_version make_patch genheader clearlily MAKFILES=Makefile Variables.make Sources.make Initial.make Generate.make \ configure -OFILES=COPYING README NEWS TODO +OFILES=COPYING README NEWS TODO ANNOUNCE IFILES= titledefs.tex lilyponddefs.tex \ ltest.tex test.tex .dstreamrc dimen.tex DFILES=$(MAKFILES) $(OFILES) $(IFILES) $(SCRIPTS) @@ -107,6 +108,8 @@ SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR) $(INITDIR) $(DEPDIR) \ depfile=deps/$(subst .o,.dep,$(notdir $@)) DODEP=rm -f $(depfile); DEPENDENCIES_OUTPUT="$(depfile) $(OBJECTDIR)/$(notdir $@)" -STRIPDEBUG=true # replace to do stripping of certain objects +STRIPDEBUG=true #replace to do stripping of certain objects +LINKER=$(CXX) + include Site.make \ No newline at end of file diff --git a/configure b/configure index 2857ad2aa4..b1b21e0631 100755 --- a/configure +++ b/configure @@ -3,7 +3,7 @@ PREFIX=${PREFIX:-.} echo using PREFIX=$PREFIX -NEEDFLOWERVER=1.0.26 +NEEDFLOWERVER=1.0.27 flowertar=flower-$NEEDFLOWERVER here=`pwd` cd .. @@ -29,3 +29,4 @@ cd $here echo '#define LIBDIR "'$PREFIX'/"'> hdr/config.hh touch Site.make make -f Initial.make + diff --git a/flower/Makefile b/flower/Makefile index 9c69264115..611691fae6 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -19,7 +19,6 @@ fversion.hh: Variables.make make_version .PHONY: docxx docxx: $(hh) $(cc) $(templatecc) $(inl) - -mkdir docxx doc++ -p -d docxx $(hh) $(cc) $(templatecc) $(inl) dist: diff --git a/flower/NEWS b/flower/NEWS index 6f4fd129cd..b89a032048 100644 --- a/flower/NEWS +++ b/flower/NEWS @@ -1,3 +1,6 @@ +pl 27 + - (temporarily?) removed findcursor* t*mat* + pl 26 - docxx 3.0 diff --git a/flower/Sources.make b/flower/Sources.make index 1e4fb2bc02..23d5164f0a 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,18 +1,13 @@ -cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ - smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ - matdebug.cc scalar.cc path.cc +cc=choleski.cc dataf.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\ +path.cc scalar.cc smat.cc string.cc textdb.cc unionfind.cc vector.cc -templatecc=cursor.tcc list.tcc tsmat.tcc plist.tcc interval.tcc\ +templatecc=cursor.tcc list.tcc plist.tcc interval.tcc\ pcursor.tcc -inl=findcurs.inl link.inl list.inl cursor.inl plist.inl -hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \ - string.hh stringutil.hh varray.hh textdb.hh textstr.hh assoc.hh\ - findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\ - smat.hh vsmat.hh vector.hh real.hh choleski.hh\ - tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\ - interval.hh scalar.hh rational.hh iterate.hh\ - path.hh - - +inl=link.inl list.inl cursor.inl plist.inl +hh=assoc.hh associter.hh choleski.hh compare.hh cursor.hh dstream.hh\ +fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh link.hh list.hh\ +matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\ +smat.hh string.hh stringutil.hh textdb.hh textstr.hh unionfind.hh\ +varray.hh vector.hh vsmat.hh diff --git a/flower/Variables.make b/flower/Variables.make index 0dc6c79705..6d0cec88bd 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=26 +PATCHLEVEL=27 PACKAGENAME=flower diff --git a/flower/assoc.hh b/flower/assoc.hh index 154a0242a2..07afb8a27c 100644 --- a/flower/assoc.hh +++ b/flower/assoc.hh @@ -11,8 +11,8 @@ struct Assoc_ent_ { V val; }; -/// hungarian: map -/** mindblowingly stupid Associative array implementation + +/** mindblowingly stupid Associative array implementation.Hungarian: map */ template struct Assoc { diff --git a/flower/choleski.hh b/flower/choleski.hh index 14cf5e2326..f5e9fb4f5a 100644 --- a/flower/choleski.hh +++ b/flower/choleski.hh @@ -4,7 +4,8 @@ #include "matrix.hh" /** - structure for using the LU decomposition of a positive definite . + Choleski decomposition of a matrix + structure for using the LU decomposition of a positive definite matrix. #P# is split into @@ -17,22 +18,23 @@ struct Choleski_decomposition { /// diagonal Vector D; - ///Create decomposition of P - /** + + /** Create decomposition of P. PRE P needs to be symmetric positive definite */ Choleski_decomposition(Matrix P); - Vector solve(Vector rhs) const; - /** + + /** solve Px = rhs */ -Vector operator * (Vector rhs) const { return solve (rhs); } + Vector solve(Vector rhs) const; + + Vector operator * (Vector rhs) const { return solve (rhs); } /** return the inverse of the matrix P. */ - Matrix inverse() const; /** return P, calc'ed from L and D diff --git a/flower/compare.hh b/flower/compare.hh index 30a1998ad3..203ba014e7 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -28,8 +28,7 @@ operator op(type t1, type t2)\ #define gpp_minmax(type, prefix) #endif -/// handy notations for a signed comparison -/** +/** 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. */ diff --git a/flower/cursor.hh b/flower/cursor.hh index d8274d2493..0ea99037f9 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -6,8 +6,7 @@ #include "link.hh" template class List; -/// iterator to List -/** +/** iterator to List. add and insert extend the list items are always stored as copies in List, but: List : copies of String stored @@ -19,8 +18,8 @@ template class Cursor { public: - /** this isn't true, actually, #list# surely isn't const, but I get - tired of the warning messages. */ + /** create cursor, set at top. The const part 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 ); @@ -56,8 +55,7 @@ class Cursor /// -- items left? bool backward(); - /// put (copy) after me in List - /** + /** put (copy) after me in List. analogously to editor. ok() interpreted as at end of line. @@ -70,8 +68,7 @@ class Cursor */ void add( const T& thing ); - /// put (copy) before me in List - /** + /** put (copy) before me in List. analogously to editor. ok() interpreted as at begin of line. diff --git a/flower/dataf.cc b/flower/dataf.cc index e3c42ad45f..29b366c860 100644 --- a/flower/dataf.cc +++ b/flower/dataf.cc @@ -78,8 +78,7 @@ Data_file::get_word() return s; } -/// get a char. -/** +/** get a char Only class member who uses text_file::get */ char diff --git a/flower/dstream.hh b/flower/dstream.hh index 0143eb0510..801b166774 100644 --- a/flower/dstream.hh +++ b/flower/dstream.hh @@ -1,4 +1,3 @@ -// debug_stream #ifndef DSTREAM_HH #define DSTREAM_HH @@ -10,8 +9,7 @@ const char eol= '\n'; template struct Assoc; -/// debug stream - /** +/** debug stream. a class for providing debug output of nested structures, with indents according to \{\}()[]. @@ -38,7 +36,7 @@ public: bool silence(String); /** - if rcfile == 0, then do not read any rc file + if rcfile == 0, then do not read any rc file. */ Dstream(ostream *r, const char * rcfile); diff --git a/flower/findcurs.hh b/flower/findcurs.hh deleted file mode 100644 index e46b64dcd9..0000000000 --- a/flower/findcurs.hh +++ /dev/null @@ -1,12 +0,0 @@ -template -class FindCursor : public Cursor -{ -public: - FindCursor( List& list, Link* pointer = 0 ); - FindCursor( const Cursor& cursor ); - - Cursor operator =( const Cursor& c ); - FindCursor find( const T& thing ); -}; - -#include "findcurs.inl" diff --git a/flower/findcurs.inl b/flower/findcurs.inl deleted file mode 100644 index 593d4aae10..0000000000 --- a/flower/findcurs.inl +++ /dev/null @@ -1,37 +0,0 @@ -template -inline -FindCursor::FindCursor( List& list, Link* pointer ) : - Cursor( list, pointer ) -{ -} - -template -inline -FindCursor::FindCursor( const Cursor& cursor ) : - Cursor( cursor ) -{ -} - -template -Cursor -FindCursor::operator =( const Cursor& c ) -{ - ( (Cursor&)*this ) = c; - return *this; -} - -template -inline FindCursor -FindCursor::find( const T& thing ) -{ - Cursor c( *this ); - while( c.forward() ) - { - T& look = *c; - if ( U::equal( look, thing ) ) - return c; - c++; - } - - return FindCursor( *this ); // cursor is not .ok() -} diff --git a/flower/handle.hh b/flower/handle.hh index 921dc6031c..63c17ef1d2 100644 --- a/flower/handle.hh +++ b/flower/handle.hh @@ -1,5 +1,6 @@ #ifndef HANDLE_HH #define HANDLE_HH + /// reference counting handle template class Handle { diff --git a/flower/interval.hh b/flower/interval.hh index 9cff84fb3c..aae16381db 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -12,8 +12,7 @@ #include "real.hh" -/// a T interval -/** +/** a T interval. this represents the closed interval [left,right]. No invariants. T must be a totally ordered ring */ @@ -73,16 +72,16 @@ struct Interval_t { bool elt_q(T r); }; -/// partial ordering -template -int Interval__compare(const Interval_t&,Interval_t const&); + /** inclusion ordering. Crash if not comparable. */ +template +int Interval__compare(const Interval_t&,Interval_t const&); -/**************************************************************** +/* INLINE - ****************************************************************/ + */ #include "compare.hh" diff --git a/flower/iterate.hh b/flower/iterate.hh index 33dbb16a4c..1e924f0790 100644 --- a/flower/iterate.hh +++ b/flower/iterate.hh @@ -1,3 +1,16 @@ +/* + iterate.hh -- define some list macros + + source file of the flowerlib + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef ITERATE_HH +#define ITERATE_HH + + #define iterator(set) typeof((set).top()) #define iterator_bot(set) typeof((set).bottom()) @@ -6,3 +19,4 @@ #define iter_top(set,var) iterator(set) var(set) #define iter_bot(set,var) iterator(set) var(set.bottom()) +#endif // ITERATE_HH diff --git a/flower/lgetopt.hh b/flower/lgetopt.hh index 67deb700bc..31fb2c55eb 100644 --- a/flower/lgetopt.hh +++ b/flower/lgetopt.hh @@ -15,9 +15,9 @@ 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. */ +/** 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, @@ -48,8 +48,7 @@ private: /// report an error and abort void report(Errorcod c); public: - /// what to do with errors - /** + /** what to do with errors. report messages on #*os#, and abort. if #os# is null, then do not report nor abort, just set #error# */ @@ -73,8 +72,7 @@ public: /// construct: pass arguments and option info. Getopt_long(int c, char **v, long_option_init *lo); - /// get the next option - /** + /** get the next option. @return pointer to next option found. 0 if error occurred, or next argument is no option. */ diff --git a/flower/list.hh b/flower/list.hh index 4f3c1aa825..ec59fbff07 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -5,9 +5,8 @@ class ostream; template class Cursor; template class Link; -/// all-purpose doubly linked list -/** - a doubly linked list; +/** all-purpose doubly linked list. + List can be seen as all items written down on paper, from top to bottom @@ -39,7 +38,7 @@ class List int size() const; - Cursor bottom() const; // const sucks.. + Cursor bottom() const; // const sucks. Cursor top() const; void OK() const; // check list @@ -50,8 +49,7 @@ class List void concatenate(List const &s); - /// make *this empty - /** + /** make *this empty. POST: size == 0 @@ -61,12 +59,12 @@ class List */ 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 ); - /** Remove link pointed to by me. Destructor of contents called + + /** Remove link pointed to by me. Destructor of contents called (nop for pointers) POST diff --git a/flower/list.tcc b/flower/list.tcc index 37ded81bbe..16e12a31f1 100644 --- a/flower/list.tcc +++ b/flower/list.tcc @@ -43,6 +43,18 @@ List::~List() c.del(); } +/** + + add after after_me. + + Procedure: + \begin{itemize} + \item if #after_me# is #ok()#, add after #after_me#, else + \item if list !empty simply add to bottom, else + \item list is empty: create first \Ref{Link} and initialize + #bottom_# and #top_#. + \end{itemize} +*/ template void List::add( const T& thing, Cursor &after_me ) @@ -62,16 +74,6 @@ List::add( const T& thing, Cursor &after_me ) size_++; } -/** - - Procedure: - \begin{itemize} - \item if #after_me# is #ok()#, add after #after_me#, else - \item if list !empty simply add to bottom, else - \item list is empty: create first \Ref{Link} and initialize - #bottom_# and #top_#. - \end{itemize} -*/ template void diff --git a/flower/matrix.hh b/flower/matrix.hh index 73a9f0487e..a633d6657a 100644 --- a/flower/matrix.hh +++ b/flower/matrix.hh @@ -5,8 +5,7 @@ #include "vsmat.hh" #include "vector.hh" -/// a Real matrix -/** This is a class for a nonsquare block of #Real#s. The +/** 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.) @@ -24,9 +23,8 @@ public: int cols() const { return dat->cols(); } int rows() const { return dat->rows(); } - /// return the size of a matrix - /** - @pre + /** return the size of a matrix. + PRE the matrix needs to be square. */ int dim() const; @@ -49,8 +47,7 @@ public: void operator*=(Real a); void operator/=(Real a) { (*this) *= 1/a; } - /// add a row - /** + /** add a row. add a row to the matrix before row k PRE @@ -58,8 +55,7 @@ public: 0 <= k <= rows() */ void insert_row(Vector v,int k); - /// - /** + /** . delete a row from this matrix. PRE @@ -107,15 +103,13 @@ public: Matrix transposed() const ; Real norm() const; - /// swap - /** + /** swap. PRE 0 <= c1,c2 < cols() */ void swap_columns(int c1, int c2); - /// swap - /** + /** swap. PRE 0 <= c1,c2 < rows() */ diff --git a/flower/path.cc b/flower/path.cc index 2737d1cd15..3dc38366f2 100644 --- a/flower/path.cc +++ b/flower/path.cc @@ -9,8 +9,8 @@ #endif /** - INPUT: path the original full filename - OUTPUT: 4 components of the path. They can be empty + @param path the original full filename + @return 4 components of the path. They can be empty */ void split_path(String path, @@ -56,8 +56,7 @@ File_path::File_path(String pref) } -///find a file -/** +/** find a file. 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 4a36730dcd..bc4d9f3776 100644 --- a/flower/path.hh +++ b/flower/path.hh @@ -4,8 +4,7 @@ #include "varray.hh" -/// searching directory for file. -/** +/** searching directory for file. Abstraction of PATH variable. An interface for searching input files. Search a number of dirs for a file. diff --git a/flower/pcursor.hh b/flower/pcursor.hh index 8498aa9e0d..1215270e3b 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -1,4 +1,3 @@ - /* pcursor.hh -- part of flowerlib @@ -8,15 +7,16 @@ #ifndef PCURSOR_HH #define PCURSOR_HH +#include "plist.hh" +#include "cursor.hh" -/// cursor to go with PointerList -/** +/** 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 { +class PCursor : private Cursor { friend class IPointerList; /// delete contents @@ -45,7 +45,7 @@ public: PCursor operator +( int no) const {return Cursor::operator+(no);} PCursor(const PointerList & l) : Cursor (l) {} PCursor( const Cursor& cursor ) : Cursor(cursor) { } - void* vptr() const { return * ((Cursor &) *this); } + void* vptr() const { return *((Cursor &) *this); } // should return T& ? T ptr() const { return (T) vptr(); } diff --git a/flower/plist.hh b/flower/plist.hh index 61b51d97e3..426b861c02 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -9,12 +9,15 @@ #include "list.hh" -/// Use for list of pointers, e.g. PointerList. /** + A list of pointers. + + 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. */ + program only one parent List is instantiated. + */ template class PointerList : public List { @@ -30,8 +33,7 @@ class PointerList : public List PointerList() {} }; -/// pl. which deletes pointers given to it. -/** +/** PointerList which deletes pointers given to it. NOTE: The copy constructor doesn't do what you'd want: @@ -43,7 +45,8 @@ class PointerList : public List */ template -struct IPointerList : public PointerList { +class IPointerList : public PointerList { +public: IPointerList(const IPointerList&) { set_empty(); } IPointerList() { } ~IPointerList(); diff --git a/flower/scalar.hh b/flower/scalar.hh index 0213a92f0d..5cdfa427da 100644 --- a/flower/scalar.hh +++ b/flower/scalar.hh @@ -23,8 +23,8 @@ struct Scalar : public String { bool isnum(); operator Real(); operator int(); - /// - /** perl -like string to bool conversion + + /** perl -like string to bool conversion. */ operator bool() const; diff --git a/flower/string.cc b/flower/string.cc index eb5822cf32..9c7f2d0801 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -1,11 +1,12 @@ -/**************************************************************************** +/* PROJECT: FlowerSoft C++ library FILE : string.cc Rehacked by HWN 3/nov/95 removed String & introduced Class String_handle ---*/ + +*/ #include #include diff --git a/flower/string.hh b/flower/string.hh index e58f614699..420d5f959d 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -19,8 +19,7 @@ #include "stringutil.hh" -/// the smart string class. -/** +/** the smart string class. Intuitive string class. provides @@ -50,8 +49,7 @@ protected: String_handle data; // should derive String from String_handle? public: - /// init to "" - /** needed because other constructors are provided.*/ + /** init to "". needed because other constructors are provided.*/ String() { } String(Rational); /// String s = "abc"; @@ -118,8 +116,7 @@ public: /// index of rightmost element of string int lastPos( const char* string ) const; - /// index of leftmost c - /** + /** index of leftmost c. RETURN: 0 if not found, else index + 1 */ diff --git a/flower/stringutil.hh b/flower/stringutil.hh index 6a7feb126a..2f62caee3d 100644 --- a/flower/stringutil.hh +++ b/flower/stringutil.hh @@ -9,8 +9,7 @@ const INITIALMAX=8; class String_handle; -/// Internal String struct -/** +/** Internal String struct. the data itself. Handles simple tasks (resizing, resetting) */ @@ -145,8 +144,8 @@ friend class String_handle; length = j; } - /** not really safe. Can alter length without StringData knowing it. - */ + /** access a char. not really safe. Can alter length without + *StringData knowing it. */ char &operator [](int j) { assert(j >= 0 && j <= length); return string[j] ; @@ -160,8 +159,7 @@ friend class String_handle; -/// ref. counting for strings -/** +/** ref. counting for strings. handles ref. counting, and provides a very thin interface using char * */ diff --git a/flower/textdb.hh b/flower/textdb.hh index cdc8898539..3586c0d180 100644 --- a/flower/textdb.hh +++ b/flower/textdb.hh @@ -3,8 +3,8 @@ #include "textstr.hh" -/** do "#" comments, read quote enclosed fields */ -/// a "const" Array. Contents can't be changed. +/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ + class Text_record : Array { int line_no; @@ -27,10 +27,10 @@ public: Array::size; }; -/** +/** abstraction for a datafile. add a subrec/fieldsep/record separator */ -/// abstraction for a datafile + class Text_db : private Data_file { void gobble_leading_white(); diff --git a/flower/textstr.hh b/flower/textstr.hh index 489682effd..2d648d4c19 100644 --- a/flower/textstr.hh +++ b/flower/textstr.hh @@ -7,8 +7,7 @@ #include "string.hh" #include "varray.hh" -/// line counting input stream. -/** +/** line counting input stream. a stream for textfiles. linecounting. Thin interface getchar and ungetchar. (ungetc is unlimited) diff --git a/flower/tsmat.hh b/flower/tsmat.hh deleted file mode 100644 index e8dac44e6e..0000000000 --- a/flower/tsmat.hh +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SMAT_HH -#define SMAT_HH -#include "varray.hh" -#include "vsmat.hh" - -/// simplest matrix storage. refer to its baseclass for the doco. -template -class Full_storage : public virtual_smat -{ - /// height, width - int h,w; - /// maxima. - int maxh, maxw; - - /// the storage - T** els; - void - init() { - els=0; - h=w=maxh=maxw=0; - - } - - bool valid(int i, int j) const { - return (i>=0 && i < h) - && (j < w && j >=0); - } - - - void resize_rows(int); - void resize_cols(int); - -public: - virtual int rows() const { - return h; - } - virtual int cols() const { - return w; - } - - - virtual void set_size(int i, int j) - { - resize(i,j); //this could be more efficient. - } - - virtual void set_size(int i) { - set_size(i,i); - } - virtual void resize(int i, int j); - virtual void resize(int i) { - resize(i,i); - } - - virtual T& elem(int i,int j) { - assert(valid(i,j)); - return els[i][j]; - } - virtual const T& elem(int i, int j) const { - assert(valid(i,j)); - return els[i][j]; - } - virtual Array row(int i) const; - virtual Array column(int j) const; - - Full_storage() { - init(); - } - Full_storage(int i, int j) { - init(); - set_size(i,j); - } - Full_storage(int i) { - init(); - set_size(i); - } - void OK() const; - void operator=(Full_storage const &); - - virtual void insert_row(int k); - virtual void delete_row(int k); - - - ~Full_storage(); - virtual bool mult_ok(int i, int j)const; - virtual void mult_next(int &i, int &j) const ; - virtual bool trans_ok(int i, int j) const; - virtual void trans_next(int &i, int &j) const; - -}; - -#endif diff --git a/flower/tsmat.tcc b/flower/tsmat.tcc deleted file mode 100644 index 0e5407ae70..0000000000 --- a/flower/tsmat.tcc +++ /dev/null @@ -1,151 +0,0 @@ -#include "smat.hh" - -template -void -Full_storage::operator=(Full_storage const &fs) -{ - resize(fs.h, fs.w); - for (int i=0; i -void -Full_storage::OK() const -{ - assert(maxh >= h && maxw >= w); - assert(h >= 0 && w >= 0); -} -template -void -Full_storage::resize_cols(int newh) -{ - if (newh <= maxh) { - h=newh; - return; - } - - T** newa=new T*[newh]; - int j=0; - for (; j < h; j++) - newa[j] = els[j]; - for (; j < newh; j++) - newa[j] = new T[w]; - delete[] els; - els=newa; - maxh = newh; -} - -template -void -Full_storage::resize_rows(int neww) -{ - if (neww <= maxw) { - w=neww; - return; - } - for (int i=0; i < h ; i++) { - T* newa=new T[neww]; - for (int k=0; k < w; k++) - newa[k] = els[i][k]; - - delete[] els[i]; - els[i] = newa; - maxw = neww; - } -} - -template -Full_storage::~Full_storage() { - for (int i=0; i < maxh; i++) - delete [] els[i]; - delete[] els; -} - -template -void -Full_storage::resize(int i, int j) -{ - resize_cols(i); - resize_rows(j); -} - -template -void -Full_storage::set_size(int i, int j) -{ - resize(i,j) -} - -template -bool -Full_storage::mult_ok(int i, int j) const -{ - return valid(i,j); -} - -template -bool -Full_storage::trans_ok(int i, int j) const -{ - return valid(i,j); -} - - -template -void -Full_storage::trans_next(int &i, int &j) const -{ - assert(trans_ok(i,j)); - i++; - if (i >= h) { - i=0; - j ++; - } -} - -template -void -Full_storage::mult_next(int &i, int &j) const -{ - assert(mult_ok(i,j)); - j++; - if (j >= w) { - j=0; - i++; - } -} - -template -void -Full_storage::delete_row(int k) -{ - assert(0 <= k k ; i++) - for (int j=0; j < w; j++) - els[i-1][j]=els[i][j]; -} - -template -void -Full_storage::insert_row(int k) -{ - assert(0 <= k <=h); - resize_cols(h+1); - for (int i=h-1; i > k ; i++) - for (int j=0; j -virtual_smat * -virtual_smat::get_full(int n, int m) -{ - return new Full_storage(n,m); -} -#include "real.hh" - -template Full_storage; diff --git a/flower/tvsmat.hh b/flower/tvsmat.hh deleted file mode 100644 index 847c650b48..0000000000 --- a/flower/tvsmat.hh +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef VSMAT_HH -#define VSMAT_HH -#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 { - - -public: - /// check invariants - virtual void OK() const=0; - - /// height of matrix - virtual int rows() const = 0; - - /// width of matrix - virtual int cols() const = 0; - - /// set the size. contents lost - /** - 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; - /** - PRE - i>=0 - */ - /// set the size to i,j - /** - - keep contents. If enlarged contents unspecified - - PRE - i>=0, j>=0 - - */ - virtual void resize(int i, int j) = 0; - - /// set the size to square dimen. contents kept - /** - Keep contents. If enlarged contents are unspecified - - PRE - i>=0 - */ - virtual void resize(int i) = 0; - - /// access an element - /** - access an element. - - Generate an errormessage, if this happens - 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; - -#if 1 - virtual Array row(int i) const = 0; - virtual Array column(int j) const = 0; -#endif - - /// add a row - /** - 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 - /** - 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? - /** - at end of matrix? when doing loop - - for(i=0; i *get_full(int n, int m); - -}; - - -#endif diff --git a/flower/unionfind.hh b/flower/unionfind.hh index 523321ff5f..fbaa51e731 100644 --- a/flower/unionfind.hh +++ b/flower/unionfind.hh @@ -2,7 +2,16 @@ #define UNIONFIND_HH #include "varray.hh" -/// which points of a graph are connected? +/* + which points of a graph are connected?. + Union find, a standard algorithm: + + Union_find represents an undirected graph of N points. You can + connect two points using #connect()#. #find(i)# finds a uniquely + determined representant of the equivalence class of points + connected to #i#. + + */ struct Union_find { void connect(int i, int j); int find(int i); @@ -13,13 +22,4 @@ private: Array classes; }; -/* - Union find, a standard algorithm: - - Union_find represents an undirected graph of N points. You can - connect two points using #connect()#. #find(i)# finds a uniquely - determined representant of the equivalence class of points - connected to #i#. - - */ #endif diff --git a/flower/varray.hh b/flower/varray.hh index 0daafb84f8..d2c2f55321 100644 --- a/flower/varray.hh +++ b/flower/varray.hh @@ -15,9 +15,9 @@ inline void arrcpy(T*dest, T*src, int count) { *dest++ = *src++; } -///scaleable array/stack template, for T with def ctor. -/** +/** + 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 @@ -52,8 +52,9 @@ public: assert(max >= size_ && size_ >=0); if (max) assert(thearray); } - /// report the size_. See {setsize_} - + /** report the size_. + @see {setsize_} + */ int size() const { return size_; } /// POST: size() == 0 @@ -61,13 +62,14 @@ public: Array() { thearray = 0; max =0; size_ =0; } - /// set the size_ to #s# + + /** set the size_ to #s#. + POST: size() == s. + Warning: contents are unspecified */ void set_size(int s) { if (s >= max) remax(s); size_ = s; } - /** POST: size() == s. - Warning: contents are unspecified */ ~Array() { delete[] thearray; } diff --git a/flower/vector.hh b/flower/vector.hh index 266254dbb8..4d91397cc6 100644 --- a/flower/vector.hh +++ b/flower/vector.hh @@ -9,8 +9,7 @@ class Dstream; class String; void set_matrix_debug(Dstream&ds); -/// a row of numbers -/** +/** a row of numbers. a vector. Storage is handled in Array, Vector only does the mathematics. */ class Vector { diff --git a/flower/vsmat.hh b/flower/vsmat.hh index 8765cbfe94..283b1e567b 100644 --- a/flower/vsmat.hh +++ b/flower/vsmat.hh @@ -2,7 +2,17 @@ #define VSMAT_HH #include "varray.hh" #include "real.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 { @@ -15,23 +25,20 @@ public: /// width of matrix virtual int cols() const = 0; - - /// set the size. contents lost - /** + + + /** set the size. contents lost. 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; - /** + + /**set the size to square dimen. contents lost PRE i>=0 */ - /// set the size to i - virtual void resize(int i, int j) = 0; - /** + virtual void set_size(int i) = 0; + /**set the size to i. keep contents. If enlarged contents unspecified @@ -39,25 +46,27 @@ public: i>=0, j>=0 */ - - /// set the size to square dimen. contents kept - virtual void resize(int i) = 0; - /** + virtual void resize(int i, int j) = 0; + + /** + set the size to square dimen. contents kept 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. Generate an errormessage, if this happens 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; @@ -66,53 +75,54 @@ public: virtual Array column(int j) const = 0; #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 void delete_column(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 + at end of matrix?. when doing loop for(i=0; i +*/ + + +#ifndef BARREG_HH +#define BARREG_HH +#include "register.hh" + +/** + generate bars. Either user ("|:"), or default (new measure) + */ +class Bar_register : public Request_register { + void split_bar(Bar *& pre, Bar * no, Bar * &post); +public: + Bar_req * bar_req_l_; + Bar * bar_p_; + + virtual bool try_request(Request *req_l); + virtual void process_request(); + virtual void do_pre_move_process(); + virtual void do_post_move_process(); + Bar_register(Complex_walker*); +}; + +#endif // BARREG_HH diff --git a/hdr/beam.hh b/hdr/beam.hh index 68f5087f45..eb8020c53a 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -11,11 +11,14 @@ #include "plist.hh" /** a beam connects multiple stems Beam adjusts the stems its owns to -make sure that they reach the beam and that point in the correct -direction */ + make sure that they reach the beam and that point in the correct + direction */ struct Beam: public Directional_spanner { PointerList stems; + /// the slope of the beam in posns / point (dimension) Real slope; + + /// position of leftmost end of beam Real left_pos; diff --git a/hdr/boxes.hh b/hdr/boxes.hh index d817dc42e8..22a2eec3a5 100644 --- a/hdr/boxes.hh +++ b/hdr/boxes.hh @@ -9,14 +9,16 @@ #include "real.hh" #include "interval.hh" #include "offset.hh" + /// a square subset of Real^2 struct Box { Interval x, y; - + void translate(Offset o) { x.translate(o.x); y.translate(o.y); } + /// smallest box enclosing #b# void unite(Box b) { x.unite(b.x); y.unite(b.y); diff --git a/hdr/clef.hh b/hdr/clef.hh deleted file mode 100644 index 7325c542a6..0000000000 --- a/hdr/clef.hh +++ /dev/null @@ -1,23 +0,0 @@ -/* - clef.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef CLEF_HH -#define CLEF_HH -#include "scalar.hh" -#include "varray.hh" - -/// where is c-0 in the staff? -class Clef { - -public: - int c0_position_i_; - String clef_type_str_; - - Clef(); - void set_type(String); -}; -#endif // CLEF_HH - diff --git a/hdr/clefitem.hh b/hdr/clefitem.hh index b7ea93caaa..2e67a7d094 100644 --- a/hdr/clefitem.hh +++ b/hdr/clefitem.hh @@ -1,6 +1,6 @@ /* - clefitem.hh -- part of LilyPond + clefitem.hh -- declare Clef_item (c) 1996,97 Han-Wen Nienhuys */ @@ -11,16 +11,17 @@ struct Clef_item : Item { - const char * name() const; String type; int y_off; + + /// is this a change clef (smaller size)? bool change; /* *************** */ - + const char * name() const; Clef_item(); - void read(Clef); + void read(Clef_register const&); void read(String); Molecule* brew_molecule_p()const; }; diff --git a/hdr/clefreg.hh b/hdr/clefreg.hh new file mode 100644 index 0000000000..ff9e5903a7 --- /dev/null +++ b/hdr/clefreg.hh @@ -0,0 +1,29 @@ +/* + clef.hh -- part of LilyPond + + (c) 1996,97 Han-Wen Nienhuys +*/ + +#ifndef CLEF_HH +#define CLEF_HH +#include "scalar.hh" +#include "varray.hh" +#include "register.hh" + +/// where is c-0 in the staff? +class Clef_register : public Request_register { + Clef_item *clef_p_; +public: + int c0_position_i_; + String clef_type_str_; + + /* ************** */ + virtual void process_request(); + virtual void do_pre_move_process(); + virtual bool try_request(Nonmusical_req*); + Clef_register(Complex_walker*); + void read_req(Clef_change_req*); + bool set_type(String); +}; +#endif // CLEF_HH + diff --git a/hdr/command.hh b/hdr/command.hh deleted file mode 100644 index 2408ac0698..0000000000 --- a/hdr/command.hh +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef COMMAND_HH -#define COMMAND_HH - -#include "glob.hh" -#include "varray.hh" -#include "scalar.hh" - -/// what kind of command? -enum Commandcode { - NOP, - INTERPRET, - TYPESET, - BREAK_PRE,BREAK_MIDDLE, BREAK_POST, BREAK_END -}; - -/// set a nonrythmical symbol - -/** - A nonrhythmical "thing" in a staff is called a "command". - Commands have these properties: - - \begin{itemize} - \item They are \bf{not} rhythmical, i.e. they do not have a duration - \item They have a staff-wide impact, i.e. a command cannot be targeted at - only one voice in the staff: two voices sharing a staff can't have - different clefs - \item Commands are ordered, that is, when from musical point of view the - commands happen simultaneously, the order in which Staff receives the - commands can still make a difference in the output - \item Some commands are actually score wide, so Score has to issue these - commands to the Staff, eg. BREAK commands - \end{itemize} - - At this moment we have three classes of commands: - \begin{description} - INTERPRET commands are not grouped. - \item[TYPESET] These commands instruct the Staff to - typeset symbols on the output, eg meter/clef/key changes - \item[INTERPRET] These commands do not produce output, instead, - they change the interpretation of other commands or requests. - example: shift output vertically, set the key. - \item[BREAK_XXX] These commands group TYPESET commands in - prebreak and postbreak commands. See Documentation/breaking - - Staff can insert additional commands in a sequence of BREAK_XXX - commands, eg. key change commands - - \end{description} - - These commands are generated by Score, since they have to be the - same for the whole score. - - - \begin{description} - \item[BREAK_PRE] - \item[BREAK_MIDDLE] - \item[BREAK_POST] - \item[BREAK_END] - \item[TYPESET] METER,BAR - \end{description} - - - Commands can be freely copied, they do not have virtual methods. - - */ - -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/commandrequest.hh b/hdr/commandrequest.hh new file mode 100644 index 0000000000..e5419da759 --- /dev/null +++ b/hdr/commandrequest.hh @@ -0,0 +1,117 @@ +/* + commandrequest.hh -- declare Non musical requests + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef COMMANDREQUEST_HH +#define COMMANDREQUEST_HH + +#include "request.hh" +#include "varray.hh" + +/** + Request assumed to be "happening" before the musical requests + */ +struct Nonmusical_req : virtual Request { + REQUESTMETHODS(Nonmusical_req, nonmus); + + virtual Measure_grouping_req * measuregrouping() { return 0; } + virtual Clef_change_req * clefchange() { return 0; } + virtual Key_change_req * keychange() { return 0; } + virtual Partial_measure_req * partial() { return 0; } + virtual Meter_change_req * meterchange() { return 0; } + virtual Bar_req *bar() { return 0; } + virtual Cadenza_req *cadenza() { return 0; } + virtual Timing_req*timing() { return 0; } +}; + + +/** Baseclass for meter/partial req. It has to be handled by + Staff_{walker,column} baseclass. */ +struct Timing_req : Nonmusical_req { + REQUESTMETHODS(Timing_req, timing); +}; + + +struct Partial_measure_req : Timing_req { + Moment duration_; + + Partial_measure_req(Moment); + REQUESTMETHODS(Partial_measure_req, partial); +}; + +/** + todo: allow C meter + */ +struct Meter_change_req : Timing_req { + int beats_i_, one_beat_i_; + + Meter_change_req(); + void set(int,int); + REQUESTMETHODS(Meter_change_req, meterchange); +}; + +/// toggle Cadenza mode +struct Cadenza_req : Timing_req { + /// turn on? + bool on_b; + Cadenza_req(bool); + REQUESTMETHODS(Cadenza_req,cadenza); +}; + +/// check if we're at start of a measure. +struct Barcheck_req : Timing_req { + + REQUESTMETHODS(Barcheck_req,barcheck); +}; + +struct Measure_grouping_req: Timing_req { + Array beat_i_arr_; + Array elt_length_arr_; + + REQUESTMETHODS(Measure_grouping_req, measuregrouping); +}; + +struct Group_change_req : Nonmusical_req { + String newgroup_str_; + REQUESTMETHODS(Group_change_req, groupchange); +}; + +/** draw a (repeat)-bar. This something different than #Barcheck_req#, + the latter should only happen at the start of a measure. */ +struct Bar_req : Nonmusical_req { + String type; + Bar_req(String); + REQUESTMETHODS(Bar_req,bar); +}; +struct Terminate_voice_req : Nonmusical_req { + REQUESTMETHODS(Terminate_voice_req,terminate); +}; + +struct Group_feature_req : Nonmusical_req { + int stemdir_i_; + Group_feature_req(); + REQUESTMETHODS(Group_feature_req, groupfeature); +}; + + +struct Key_change_req : Nonmusical_req { + Array melodic_p_arr_; + + Key_change_req(); + Key_change_req(Key_change_req const&); + ~Key_change_req(); + REQUESTMETHODS(Key_change_req, keychange); +}; + +struct Clef_change_req : Nonmusical_req { + String clef_str_; + Clef_change_req(String); + REQUESTMETHODS(Clef_change_req, clefchange); +}; + +#endif // COMMANDREQUEST_HH diff --git a/hdr/complexcolumn.hh b/hdr/complexcolumn.hh index 50ad5fc8a0..4065954b64 100644 --- a/hdr/complexcolumn.hh +++ b/hdr/complexcolumn.hh @@ -10,6 +10,8 @@ #ifndef COMPLEXCOLUMN_HH #define COMPLEXCOLUMN_HH +#include "stcol.hh" + /// column of Complex_staff: store one request struct Complex_column : Staff_column { @@ -22,14 +24,13 @@ struct Complex_column : Staff_column { 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(); + void typeset_musical_item(Item *); + void typeset_breakable_items(Array &pre_p_arr, + Array &nobreak_p_arr, + Array &post_p_arr); + virtual void setup_one_request(Request*); - Complex_column(Score_column*s,Complex_staff*rs); + Complex_column(Complex_staff*rs); }; #endif // COMPLEXCOLUMN_HH diff --git a/hdr/complexstaff.hh b/hdr/complexstaff.hh index 6c7dbdb18d..5a605d475e 100644 --- a/hdr/complexstaff.hh +++ b/hdr/complexstaff.hh @@ -21,12 +21,9 @@ struct Complex_staff : Staff { PStaff *pstaff_l_; /* *************** */ - Staff_column*create_col(Score_column*); - virtual Item *get_TYPESET_item(Command*); + Staff_column*create_col(); virtual void set_output(PScore *); - void process_commands( PCursor &where); - virtual void walk(); - + virtual Staff_walker *get_walker_p(); Complex_staff(); }; diff --git a/hdr/complexwalker.hh b/hdr/complexwalker.hh index a4ba27b03b..d8444c7c9e 100644 --- a/hdr/complexwalker.hh +++ b/hdr/complexwalker.hh @@ -1,5 +1,5 @@ /* - complexwalker.hh -- part of LilyPond + complexwalker.hh -- declare Complex_walker (c) 1996,97 Han-Wen Nienhuys */ @@ -8,70 +8,92 @@ #define COMPLEXWALKER_HH #include "proto.hh" -#include "grouping.hh" #include "voicegroup.hh" #include "assoc.hh" #include "staffwalker.hh" -#include "key.hh" -#include "clef.hh" -#include "register.hh" -#include "localkeyreg.hh" - +#include "staffeleminfo.hh" +#include "plist.hh" /** - A staff walker which uses registers to what to print + A staff walker which uses registers to decide what to print */ -struct Complex_walker: Staff_walker { - Local_key local_key_; - Key key_; - Array *oldkey_undo; - Array typesetkey; - - int processed_bar_priority; - bool processed_key; - bool processed_clef; - Clef clef_; - Rhythmic_grouping default_grouping; - +class Complex_walker: public Staff_walker { + bool try_command_request(Nonmusical_req *req_l); + void do_change_group( Voice * v, String group_id_str); + void do_announces(); + void try_request(Request*req); + int c0_position_i_; + Array prebreak_item_p_arr_; + Array nobreak_item_p_arr_; + Array postbreak_item_p_arr_; + +public: + IPointerList voice_reg_list_; IPointerList group_reg_list_; Assoc voice_group_map_; - Local_key_register local_key_reg_; + Clef_register *clef_reg_p_; + Local_key_register *local_key_reg_p_; + Key_register *key_reg_p_; + Bar_register *bar_reg_p_; + Meter_register *meter_reg_p_; + Array announce_info_arr_; /* *************** */ + 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. + /** search for voice_group containing #v_l# + + @return + pointer if found, 0 if not found. + */ 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 + /** search for voice_group named #id# + + @return + pointer if found, 0 if not found. + */ Voice_group_registers *find_voice_group(const char* id)const; - /// Create if necessary + + /** + search for voice_group named #id#, create if necessary + */ Voice_group_registers *get_voice_group(const char*); Array get_voice_regs(Voice_group_registers *) const; void regs_process_requests(); + void typeset_breakable_item(Item * pre_p , + Item * nobreak_p, Item * post_p); void typeset_element(Staff_elem *elem_p); void announce_element(Staff_elem_info); - virtual void do_TYPESET_command(Command*); - virtual void do_INTERPRET_command(Command*); virtual void process_requests(); virtual void do_post_move(); virtual void do_pre_move(); - + /** + @return the position of central c. + */ + int c0_position_i() const; + + /** + set the position of central c. + @param the new position + */ + void set_c0_position(int j); Complex_walker(Complex_staff*); + ~Complex_walker(); + 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/getcommand.hh b/hdr/getcommand.hh deleted file mode 100644 index 77123e85dc..0000000000 --- a/hdr/getcommand.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* - getcommand.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef GETCOMMAND_HH -#define GETCOMMAND_HH -#include "proto.hh" - - -Command* get_meter_command(int,int); -Command get_defaultbar_command(); - -void split_bar_command(Command &pre_com, Command &no_break_com, Command &post_com,String s); - - -#endif // GETCOMMAND_HH diff --git a/hdr/grouping.hh b/hdr/grouping.hh index 70d95ef55d..72d2960f82 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -52,4 +52,9 @@ private: void junk(); void copy(Rhythmic_grouping const&); }; + + +Rhythmic_grouping parse_grouping(Array beat_i_arr, Array elt_length_arr); + + #endif diff --git a/hdr/inputcommand.hh b/hdr/inputcommand.hh deleted file mode 100644 index 8437454d9a..0000000000 --- a/hdr/inputcommand.hh +++ /dev/null @@ -1,35 +0,0 @@ -/* - inputcommand.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef INPUTCOMMAND_HH -#define INPUTCOMMAND_HH -#include "proto.hh" -#include "scalar.hh" -#include "varray.hh" -#include "moment.hh" -/// command without time assoced -struct Input_command { - /// analogous to argv[] - Array args; - void print()const; - Input_command(); - - operator Command(); -}; -Input_command*get_cadenza_toggle(int i); -Input_command *get_meterchange_command( int,int); -Input_command *get_key_interpret_command(Array); -Input_command *get_clef_interpret_command(String w); -Input_command *get_reset_command(); -Input_command *get_partial_command(Moment u); -Input_command *get_skip_command(int,Moment); -Input_command *get_grouping_command(Array); -Input_command *get_bar_command(String); -Input_command *get_newmeasure_command(); -Input_command *get_goto_command(String); -Array get_default_grouping(int count, int onenote); -#endif // INPUTCOMMAND_HH - diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh deleted file mode 100644 index 94d94c4202..0000000000 --- a/hdr/inputcommands.hh +++ /dev/null @@ -1,59 +0,0 @@ -/* - inputcommands.hh -- part of LilyPond - - (c) 1996,97 Han-Wen Nienhuys -*/ - -#ifndef INPUTCOMMANDS_HH -#define INPUTCOMMANDS_HH - -#include "proto.hh" -#include "plist.hh" -#include "real.hh" -#include "timedescription.hh" - -struct Commands_at : public IPointerList { - Time_description tdescription_; - - /* *************** */ - - Moment when(); - void parse(Staff_commands_at*); - void print() const; - Moment barleft(); - void add(Input_command*); - void setpartial(Moment); - Commands_at(const Commands_at&); - Commands_at(Moment, Commands_at*prev); -}; - -struct Input_cursor : public PCursor -{ - /* *************** */ - Input_cursor(PCursor); - Moment when()const; - void find_moment(Moment w); - void prev() { operator --(0); } - void next() { operator ++(0); } -}; - -/// the list of commands in Score -struct Input_commands : public IPointerList { - Input_cursor ptr; - - /* *************** */ - - void find_moment(Moment); - void add(Input_command c,Assoc &marks_assoc_r); - void do_skip(int bars, Moment wholes); - - Input_commands(); - Input_commands(Input_commands const&); - - void reset(); - void print()const; - void parse(Staff *) const; -}; - -#endif // INPUTCOMMANDS_HH - diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index 0a1d95cfc6..13e8f4a365 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -18,6 +18,7 @@ struct Voice_list : public PointerList { /** + A set voices. 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: @@ -26,8 +27,6 @@ struct Voice_list : public PointerList { - a pitch (it can be transposed) */ - - struct Input_music { virtual Voice_list convert()const=0; virtual Moment length()const=0; @@ -75,7 +74,7 @@ struct Complex_music : Input_music { /** - voice like. + A voice like list of music. different music forms which start after each other ( concatenated, stacked "horizontally ) diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index ef0d9d6a88..024c6d132c 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -1,5 +1,15 @@ -#ifndef ISCORE_HH -#define ISCORE_HH +/* + inputscore.hh -- declare + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef INPUTSCORE_HH +#define INPUTSCORE_HH + #include "varray.hh" #include "proto.hh" #include "plist.hh" @@ -13,20 +23,22 @@ struct Input_score { int errorlevel_i_; /// paper_, staffs_ and commands_ form the problem definition. - Paperdef *paper_; + Paperdef *paper_p_; IPointerList staffs_; - IPointerList commands_; + + Input_music * score_wide_music_p_; /* *************************************************************** */ Input_score(); Input_score(Input_score const&); - void add(Array &s); + void add(Input_staff*); ~Input_score(); /// construction void set(Paperdef*); void print() const; Score*parse(); + void set(Input_music*); }; #endif diff --git a/hdr/inputstaff.hh b/hdr/inputstaff.hh index cc9f823885..f72cac8ba1 100644 --- a/hdr/inputstaff.hh +++ b/hdr/inputstaff.hh @@ -1,5 +1,5 @@ /* - inputstaff.hh -- part of LilyPond + inputstaff.hh -- declare Input_staff (c) 1996,97 Han-Wen Nienhuys */ @@ -14,19 +14,19 @@ struct Input_staff { - const char * defined_ch_c_l_; String type; - IPointerList commands_; + IPointerList music_; - + Input_music * score_wide_music_p_; + /* *************** */ - + ~Input_staff(); void add(Input_music*m); Input_staff(Input_staff const&); Input_staff(String); - void add(Array &s); - Staff* parse(Score*); + void set_score_wide(Input_music*m); + Staff* parse(Score*, Input_music *score_wide); void print() const; }; diff --git a/hdr/key.hh b/hdr/key.hh index 7a755244a8..3d58629d5d 100644 --- a/hdr/key.hh +++ b/hdr/key.hh @@ -12,17 +12,15 @@ /// administration of current key class Key { - Array accidentals; + Array accidental_i_arr_; /* *************** */ public: - Array read(Array ); - Array oldkey_undo(Array); - + Key(); void set(int i, int acc); - int acc(int i) { return accidentals[i]; } + int acc(int i)const { return accidental_i_arr_[i]; } }; /// administration of accidentals diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index b882c9551a..86dae4d9fc 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -10,25 +10,21 @@ #include "item.hh" #include "varray.hh" -struct Clef; /// An item which places accidentals at the start of the line -struct Keyitem : Item { - const char * name() const; +struct Key_item : Item { Array pitch; Array acc; int c_position; /* *************** */ - - Keyitem(int cposition); + const char * name() const; + Key_item(int cposition); void add(int pitch, int acc); - void read(Array k); - void read(const Clef& c); - + void read(const Key_register&); + void set_c_position(int); void preprocess(); - Molecule* brew_molecule_p()const; }; diff --git a/hdr/keyreg.hh b/hdr/keyreg.hh new file mode 100644 index 0000000000..cf1923134d --- /dev/null +++ b/hdr/keyreg.hh @@ -0,0 +1,33 @@ +/* + keyreg.hh -- declare Key_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef KEYREG_HH +#define KEYREG_HH + +#include "register.hh" +#include "key.hh" + +struct Key_register : Request_register { + Key key_; + Key_change_req * keyreq_l_; + Key_item * kit_p_; + Array accidental_idx_arr_; + bool default_key_b_; + + virtual bool try_request(Request *req_l); + virtual void process_request(); + virtual void do_pre_move_process(); + virtual void do_post_move_process(); + Key_register(Complex_walker*); +private: + + void read_req(Key_change_req * r); +}; + +#endif // KEYREG_HH diff --git a/hdr/leastsquares.hh b/hdr/leastsquares.hh index b9a9241d0d..35b1e1d34b 100644 --- a/hdr/leastsquares.hh +++ b/hdr/leastsquares.hh @@ -9,6 +9,10 @@ #include "varray.hh" #include "offset.hh" + +/** + Least squares minimisation in 2 variables. + */ struct Least_squares { Array input; void minimise(Real &coef, Real &offset); diff --git a/hdr/lexer.hh b/hdr/lexer.hh index e2909d8879..8f1e67123e 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -14,7 +14,7 @@ void set_lexer(); struct Input_file { istream* is; - char const* defined_ch_c_l_m; + char const* defined_ch_c_l_; Source_file* sourcefile_l_; int line; String name; @@ -31,7 +31,7 @@ struct My_flex_lexer : yyFlexLexer { Assoc *the_id_tab; Keyword_table * keytable; Notename_tab * defaulttab; - char const* data_ch_c_l_m; + char const* data_ch_c_l_; int errorlevel_i_; /* *************** */ int ret_notename(int *p, String text, int octave_mod); diff --git a/hdr/linespace.hh b/hdr/linespace.hh index b9027754ce..1479d1e936 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -70,13 +70,15 @@ class Spacing_problem { public: /** solve the spacing problem - return the column positions, and the energy (last element) - */ + + @return the column positions, and the energy (last element) + + */ Array solve() const; - /// add a idealspacing to the problem. + /** - + add a idealspacing to the problem. One pair of columns can have no, one or more idealspacings, since they can be "summed" if the columns to which #i# refers are @@ -85,8 +87,7 @@ public: void add_ideal(const Idealspacing *i); - /// add a col to the problem - /** columns have to be added left to right. The column contains + /** add a col to the problem. 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); diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index 492a23f345..e9640023d4 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -17,8 +17,8 @@ struct Local_acc { struct Local_key_item : Item { const char * name() const; Array accs; - Array group; - int c0_position; // move into walker + Array support_items_; + int c0_position; /* *************** */ diff --git a/hdr/localkeyreg.hh b/hdr/localkeyreg.hh index 742d9cb41e..48a9b5cbd2 100644 --- a/hdr/localkeyreg.hh +++ b/hdr/localkeyreg.hh @@ -8,14 +8,13 @@ #ifndef LOCALKEYREG_HH #define LOCALKEYREG_HH #include "register.hh" +#include "key.hh" struct Local_key_register : Request_register { + Local_key local_key_; 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*); diff --git a/hdr/lyriccolumn.hh b/hdr/lyriccolumn.hh index 118b9f34bd..a7202e593d 100644 --- a/hdr/lyriccolumn.hh +++ b/hdr/lyriccolumn.hh @@ -1,5 +1,5 @@ // -// lyriccolumn.hh -- part of LilyPond +// lyriccolumn.hh -- declare Lyric_column // // copyright 1997 Jan Nieuwenhuizen @@ -11,25 +11,16 @@ #include "stcol.hh" #include "staff.hh" -struct Lyric_staff; - -/// (winfo) -struct Word_info { - Lyric_req* lreq_l_; - Word_info(); - Word_info(Lyric_req* lreq_l); -}; - /// (lcol) struct Lyric_column : Staff_column { - Array winfo_array_; + Array lreq_l_array_; Lyric_staff* lstaff_l_; void typeset_item(Item *); - virtual void setup_requests(); + virtual void setup_one_request(Request*); - Lyric_column(Score_column* s,Lyric_staff*rs); + Lyric_column(Lyric_staff*rs); }; #endif // LYRICSTAFF_HH diff --git a/hdr/lyricstaff.hh b/hdr/lyricstaff.hh index 22fb8958b6..31cc62caaa 100644 --- a/hdr/lyricstaff.hh +++ b/hdr/lyricstaff.hh @@ -1,23 +1,23 @@ -// -// lyricstaff.hh -- part of LilyPond -// -// copyright 1997 Jan Nieuwenhuizen +/* + lyricstaff.hh -- part of LilyPond + + copyright 1997 Jan Nieuwenhuizen + */ #ifndef LYRICSTAFF_HH #define LYRICSTAFF_HH #include "staff.hh" -/// (lstaff) +/** + Hungarian prefix lstaff + */ struct Lyric_staff : Staff { PStaff* pstaff_l_; - Staff_column* create_col(Score_column*); - + Staff_column* create_col(); virtual void set_output(PScore *); - void process_commands(PCursor &where); - virtual void walk(); - + virtual Staff_walker *get_walker_p(); Lyric_staff(); }; diff --git a/hdr/lyricwalker.hh b/hdr/lyricwalker.hh index fcf0c9186b..5f413f2ab9 100644 --- a/hdr/lyricwalker.hh +++ b/hdr/lyricwalker.hh @@ -1,5 +1,5 @@ /* - simplewalker.hh -- part of LilyPond + lyricwalker.hh -- declare Lyric_walker (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen */ @@ -12,18 +12,13 @@ #include "staffwalker.hh" #include "lyriccolumn.hh" -struct Lyric_item; // put into proto +/// a simple walker which collects words, and then print them, first on top struct Lyric_walker: Staff_walker { Array litem_l_array_; /* *************** */ - - virtual void do_TYPESET_command(Command*); - virtual void do_INTERPRET_command(Command*); virtual void process_requests(); - virtual void reset(); - void do_word(Word_info); Lyric_walker(Lyric_staff* lstaff_l); Lyric_column* lcol_l(); Lyric_staff* lstaff_l(); diff --git a/hdr/meter.hh b/hdr/meter.hh index 22a256c93c..7de58e7c64 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -1,5 +1,5 @@ /* - meter.hh -- part of LilyPond + meter.hh -- declare Meter (c) 1996,97 Han-Wen Nienhuys */ @@ -8,11 +8,12 @@ #define METER_HH #include "item.hh" #include "varray.hh" +#include "scalar.hh" struct Meter: Item { - const char * name() const; Array args; /* *************** */ + const char * name() const; Meter(Array args) ; Molecule*brew_molecule_p() const; diff --git a/hdr/meterreg.hh b/hdr/meterreg.hh new file mode 100644 index 0000000000..f14e2ecb9e --- /dev/null +++ b/hdr/meterreg.hh @@ -0,0 +1,28 @@ +/* + meterreg.hh -- declare Meter_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef METERREG_HH +#define METERREG_HH +#include "register.hh" + +/** + generate meters. + */ +class Meter_register : public Request_register { +public: + Meter_change_req * meter_req_l_; + Meter * meter_p_; + + virtual bool try_request(Request *req_l); + virtual void process_request(); + virtual void do_pre_move_process(); + virtual void do_post_move_process(); + Meter_register(Complex_walker*); +}; +#endif // METERREG_HH diff --git a/hdr/misc.hh b/hdr/misc.hh index ae288151a2..00b742076e 100644 --- a/hdr/misc.hh +++ b/hdr/misc.hh @@ -5,10 +5,9 @@ #include "real.hh" #include "moment.hh" #include "scalar.hh" +#include "grouping.hh" Moment wholes(int dur, int dots); - -Rhythmic_grouping parse_grouping(const Array &a); double log_2(double x) ; int intlog2(int d); inline int @@ -22,5 +21,6 @@ sign(int i) { else return 0; } +Interval itemlist_width(const Array &its); #endif diff --git a/hdr/musicalrequest.hh b/hdr/musicalrequest.hh new file mode 100644 index 0000000000..2a864eb9ef --- /dev/null +++ b/hdr/musicalrequest.hh @@ -0,0 +1,185 @@ +/* + musicalrequests.hh -- declare Musical requests + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef MUSICALREQUESTS_HH +#define MUSICALREQUESTS_HH + +#include "request.hh" + + +/** + A request which is coupled to a #Voice_element# with nonzero duration. + Base class only + */ +struct Musical_req : virtual Request { + virtual Skip_req* skip() { return 0; } + REQUESTMETHODS(Musical_req, musical); +}; + + +struct Skip_req : Musical_req { + Moment duration_; + + virtual Moment duration() const; + REQUESTMETHODS(Skip_req, skip); +}; +/** a request with a duration. + This request is used only a base class. + */ +struct Rhythmic_req : virtual Musical_req { + int balltype; + int dots; + Moment plet_factor; + /* *************** */ + static int compare(const Rhythmic_req &, const Rhythmic_req &); + virtual Moment duration() const; + Rhythmic_req(); + Rhythmic_req(int,int); + REQUESTMETHODS(Rhythmic_req, rhythmic); +}; + +struct Spacing_req :virtual Request { + Moment next; + Real distance; + Real strength; + /* *************** */ + Spacing_req(); + REQUESTMETHODS(Spacing_req, spacing); +}; + +struct Blank_req : Spacing_req, Rhythmic_req { + REQUESTMETHODS(Spacing_req, spacing); + +}; + +/// Put a text above or below (?) this staff. +struct Text_req : virtual Musical_req { + /// preferred position (above/below) + int dir_i_; + /// the characteristics of the text + Text_def *tdef_p_; + /* *************** */ + Text_req(int d, Text_def*); + ~Text_req(); + Text_req(Text_req const&); + static int compare(const Text_req&,const Text_req&); + REQUESTMETHODS(Text_req,text); +}; + +/** Put a text in lyric_staff + @see Lyric_staff + */ +struct Lyric_req : public Rhythmic_req, Text_req { + Lyric_req(Text_def* t_p); + REQUESTMETHODS(Lyric_req, lreq_l); +}; + +/// request which has some kind of pitch +struct Melodic_req :virtual Musical_req +{ + /// 0 is c, 6 is b + int notename_i_; + /// 0 is central c + int octave_i_; + + /// 0 natural, 1 sharp, etc + int accidental_i_; + + /// force/supress printing of accidental. + bool forceacc_b_; + + /// return height from central c (in halflines) + int height()const; + Melodic_req(); + + REQUESTMETHODS(Melodic_req,melodic); +}; + +/// Put a note of specified type, height, and with accidental on the staff. +struct Note_req : Rhythmic_req, virtual Melodic_req { + + + Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); } + REQUESTMETHODS(Note_req, note); + }; + +/** +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. +*/ +class Rest_req : public Rhythmic_req { +public: + REQUESTMETHODS(Rest_req,rest); +}; + +/** + attach a stem to the noteball. + Rhythmic_req parent needed to determine if it will fit inside a beam. + */ +struct Stem_req : Rhythmic_req { + /// preferred direction for the stem + int dir_i_; + Stem_req(int s, int dots); + REQUESTMETHODS(Stem_req,stem); +}; + +/** + Requests to start or stop something. + This type of request typically results in the creation of a #Spanner# +*/ +struct Span_req : Musical_req { + /// should the spanner start or stop, or is it unwanted? + enum { + NOSPAN, START, STOP + } spantype ; + static int compare(const Span_req &r1, const Span_req &r2); + REQUESTMETHODS(Span_req,span); + + Span_req(); + +}; + + +/** 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(); +}; + +/// a slur +struct Slur_req : Span_req { + REQUESTMETHODS(Slur_req,slur); + +}; + + +/**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 : Musical_req { + 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&); +}; + + + + +#endif // MUSICALREQUESTS_HH diff --git a/hdr/parseconstruct.hh b/hdr/parseconstruct.hh index 78d4f84861..5ee82774c0 100644 --- a/hdr/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -11,7 +11,6 @@ extern char const* defined_ch_c_l; extern char const* req_defined_ch_c_l; -Voice_element*get_mark_element(String); void set_default_duration(int *); void last_duration(int n); void set_duration_mode(String s); @@ -28,11 +27,12 @@ Script_def* get_scriptdef(char); Text_def*get_text(String s); Request*get_script_req(int d , Script_def*def); Request*get_text_req(int d , Text_def*def); -Voice_element*get_command_element(Input_command*); -Voice_element* get_barcheck_element(); -Voice_element* get_stemdir_element(int); +Request* get_stemdir_req(int); + +Request*get_grouping_req(Array i_arr); + #endif // PARSECONSTRUCT_HH diff --git a/hdr/pcol.hh b/hdr/pcol.hh index 0e8ed3e677..21fdb698d9 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -6,8 +6,9 @@ #include "plist.hh" #include "item.hh" -/// stuff grouped vertically. + /** + stuff grouped vertically. This is a class to address items vertically. It contains the data for: \begin{itemize} \item @@ -17,13 +18,15 @@ \item the linespacing problem \end{itemize} - */struct PCol { + */ + +struct PCol { PointerList its; PointerList stoppers, starters; - /// prebreak is put before end of line. - /** + + /** prebreak is put before end of line. if broken here, then (*this) column is discarded, and prebreak is put at end of line, owned by Col */ @@ -54,17 +57,17 @@ void add(Item *i); /// Can this be broken? true eg. for bars. - bool breakable()const; + bool breakable_b()const; Interval width() const; ~PCol(); PCol(PCol * parent); - /// which col comes first? /** + which col comes first?. signed compare on columns. - return < 0 if c1 < c2. + @return < 0 if c1 < c2. */static int compare(const PCol &c1, const PCol &c2); diff --git a/hdr/proto.hh b/hdr/proto.hh index eac46fbeca..5610e4f54b 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -1,4 +1,3 @@ - /* proto.hh -- part of LilyPond @@ -14,55 +13,64 @@ struct Absdynamic_req; struct Accidental; struct Atom; +struct Bar; +struct Bar_register; struct Barcheck_req; +struct Bar_req; struct Beam; struct Beam_req; struct Box; struct Bracket_req; -struct CNote_info; +struct Cadenza_req; struct Chord; -struct Clef; +struct Clef_change_req; +struct Clef_register; struct Clef_item; struct Col_hpositions; struct Colinfo; -struct Command; -struct Commands_at ; struct Complex_column; struct Complex_music; struct Complex_staff; struct Complex_walker; struct Cresc_req; struct Decresc_req; +struct Durational_req; struct Dynamic; struct Group_change_req; struct Group_feature_req; struct Idealspacing; struct Identifier; -struct Input_command; -struct Input_commands; struct Input_file; struct Input_music; struct Input_score; struct Input_staff; struct Item; struct Key; -struct Keyitem; +struct Key_register; +struct Key_change_req; +struct Key_item; struct Keyword; struct Keyword_table; struct Line_of_score; struct Line_of_staff; struct Linestaff; struct Local_key; +struct Local_key_register; struct Local_key_item; struct Lookup; +struct Lyric_item; struct Lyric_req; -struct Lyric_req; -struct Mark_req; struct Melodic_req; +struct Measure_grouping_req; +struct Meter_change_req; +struct Meter; +struct Meter_register; struct Mixed_qp; struct Molecule; +struct Musical_req; struct Music_general_chord; struct Music_voice; +struct Nonmusical_req; struct Note_req; struct Notehead; struct Notehead_register; @@ -73,21 +81,24 @@ struct PCol; struct PScore; struct PStaff; struct Paperdef; -struct Parametric_symbol; +struct Partial_measure_req; struct Rational; struct Request; struct Request_register; struct Rest; struct Rest_req; struct Rhythmic_grouping; +struct Rhythmic_grouping_req; struct Rhythmic_req; struct Score; struct Score_column; +struct Score_walker; struct Script_def; struct Script; struct Script_register; struct Script_req; struct Simple_music; +struct Skip_req; struct Slur; struct Slur_register; struct Slur_req; @@ -99,9 +110,6 @@ struct Spanner; struct Blank_req; struct Staff; struct Staff_column; -struct Staff_command_req; -struct Staff_commands; -struct Staff_commands_at ; struct Staff_elem; struct Staff_elem_info; struct Staff_symbol; @@ -120,7 +128,7 @@ struct Text_def; struct Text_gob; struct Text_register; struct Text_req; - +struct Timing_req; struct Time_description; struct Voice; struct Voice_element; diff --git a/hdr/pscore.hh b/hdr/pscore.hh index f4b3f788d9..f1f8dbbc96 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -8,11 +8,13 @@ #include "pcol.hh" #include "pstaff.hh" -/// all stuff which goes onto paper -/** notes, signs, symbols in a score can be grouped in two ways: + +/** all stuff which goes onto paper. 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 { + */ + +struct PScore { Paperdef *paper_l_; /// the columns, ordered left to right @@ -45,8 +47,8 @@ void add(PStaff *); - /// add an item - /** + + /** add an item. add the item in specified containers. If breakstatus is set properly, add it to the {pre,post}break of the pcol. */ @@ -62,7 +64,9 @@ /* INSPECTION */ Array select_items(PStaff*, PCol*); - /// return argument as a cursor. + /** + @return argument as a cursor of the list + */ PCursor find_col(const PCol *)const; /* MAIN ROUTINES */ diff --git a/hdr/qlp.hh b/hdr/qlp.hh index 7bc667b956..ccfba72bb8 100644 --- a/hdr/qlp.hh +++ b/hdr/qlp.hh @@ -30,7 +30,9 @@ public: /// solve the problem using a projected gradient method Vector solve(Vector start) const; - /** return the number of variables in the problem */ + /** + @return the number of variables in the problem + */ int dim() const{ return lin.dim(); } @@ -61,8 +63,9 @@ public: }; -/// Quadratic programming with mixed linear constraints + /** + Quadratic programming with mixed linear constraints. problem definition of a quadratic optimisation problem with linear inequality and equality constraints diff --git a/hdr/qlpsolve.hh b/hdr/qlpsolve.hh index 811556c362..7c9b8da341 100644 --- a/hdr/qlpsolve.hh +++ b/hdr/qlpsolve.hh @@ -40,15 +40,15 @@ public: Vector vec(int k) const { return opt->cons[k]; } Real rhs(int k) const { return opt->consrhs[k]; } - /// drop constraint - /** drop constraint k from the active set. k is the index of the + + /** drop constraint. drop constraint k from the active set. k is the index of the constraint in #active# */ void drop (int k); - /// add constraint j - /** + + /** add constraint j. add constraint j to the active set j is the index of the constraint in #inactive# */ diff --git a/hdr/register.hh b/hdr/register.hh index 0c47e35cd1..922d874644 100644 --- a/hdr/register.hh +++ b/hdr/register.hh @@ -6,77 +6,88 @@ #ifndef REGISTER_HH #define REGISTER_HH + #include "proto.hh" #include "varray.hh" #include "request.hh" +#include "staffeleminfo.hh" -/// data container. -struct Staff_elem_info { - Staff_elem * elem_p_; - Request*req_l_; - const Voice * voice_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 + a struct which processes requests, and creates the #Staff_elem#s. + Hungarian postfix: reg */ -struct Request_register { +class Request_register { +public: Complex_walker * walk_l_; Array accepted_req_arr_; - /* *************** */ /** - Warning: you can't copy a Request_register + 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 - put item in spanner. Adjust local key; etc. - */ - virtual void acknowledge_element(Staff_elem_info){} /** - Announce element to walker - */ - void announce_element(Staff_elem_info); + take note of item/spanner + put item in spanner. Adjust local key; etc. - /** - invoke walker method to typeset element + Default: ignore the info */ - void typeset_element(Staff_elem*elem_p); - + virtual void acknowledge_element(Staff_elem_info){} + /** try to fit the request in this register @return false: not noted, not taken. - true: request swallowed. Don't try to put elsewhere + true: request swallowed. Don't try to put the request elsewhere. (may be we could use C++ exceptions.. :-) + + #Request_register::try_request# always returns false */ - virtual bool try_request(Request *req_l) =0; + virtual bool try_request(Request *req_l); /// make items/spanners with the requests you got - virtual void process_request()=0; - Paperdef * paper() const; - /// typeset any spanners. Empty accepted_req_arr_ + virtual void process_request(){} + + /// typeset any spanners. Empty #accepted_req_arr_# void pre_move_processing(); + /// reset any appropriate data. void post_move_processing(); + virtual void set_dir(int){} protected: - /// virtual, called by pre_move_process() + /// utility + Paperdef * paper() const; + + + /** + invoke walker method to typeset element + */ + void typeset_element(Staff_elem*elem_p); + + + /** + typeset a "command" item. + If the column is not breakable, #pre_p# and #post_p# are junked + */ + void typeset_breakable_item(Item * pre_p , Item * nobreak_p, Item * post_p); + /** virtual, called by #pre_move_processing()# + #Request_register::do_pre_move_process()# defaults to NOP + */ virtual void do_pre_move_process(){} + /** virtual, called by #post_move_processing#, + #Request_register::do_post_move_process()# defaults to NOP */ virtual void do_post_move_process(){} + /** + Announce element to walker. Utility + */ + void announce_element(Staff_elem_info); }; diff --git a/hdr/reqtodo.hh b/hdr/reqtodo.hh new file mode 100644 index 0000000000..eaed606453 --- /dev/null +++ b/hdr/reqtodo.hh @@ -0,0 +1,83 @@ +#if 0 + + + +/**Draw a (Guitar) chord above or below this ``note''. +Why a request? +Because everything else is done in requests. +*/ +struct Chord : Request { + // don't know how this looks. +}; + + +/// for absolute dynamics +enum Loudness { + FFF, FF, F, MF, MP, P, PP, PPP +} ; + + +/** +Start/stop a bracket at this note. if #nplet# is set, the staff will +try to put an appropriate number over the bracket +*/ +struct Bracket_req : Span_req { + int nplet; // print a number over the beam. +}; + +struct Subtle_req { + Moment subtime; +}; + + +/** helper in the hierarchy. 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 note, therefore fore each + Dynamic request carries a time, measured from the start of its + note. + + This subfield would come in handy, if mpp96 was adapted for midi + support. + + 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 { + +}; + +/// do a decrescendo +struct Decresc_req : Span_req, Dynamic { + +}; + +/// do a dynamic like "fff" or "mp" +struct Absdynamic_req : Request, Dynamic { + Loudness loudness; +}; + +struct Grace_req : Subtle_req { + +}; + +struct Grace_turn_req : Grace_turn { + +}; + +struct Grace_note : Melodic_req { + +}; + +struct Grace_notes { + +}; + +struct Glissando_req : Span_req { + +}; +#endif diff --git a/hdr/request.hh b/hdr/request.hh index b533a3fbb5..56fc3e4ea5 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -1,20 +1,27 @@ -// LilyPond's second egg of columbus! +/* + request.hh -- declare Request baseclasses. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #ifndef REQUEST_HH #define REQUEST_HH +// LilyPond's second egg of columbus! #include "glob.hh" #include "string.hh" #include "moment.hh" -/// Hungarian postfix: req /** a voice element wants something printed. -see lilygut page + Hungarian postfix: req + @see lilygut manpage */ - struct Request { Voice_element*elt_l_; - char const* defined_ch_c_l_m; + char const* defined_ch_c_l_; /* *************** */ Request(); @@ -22,7 +29,7 @@ struct Request { virtual ~Request(){} virtual const char * name() const { return "Request";} - virtual Request* clone() const =0; + virtual Request* clone() const { return new Request(*this); } void print()const ; virtual Moment duration() const { return 0; } @@ -31,24 +38,24 @@ struct Request { maybe checkout RTTI */ virtual Barcheck_req *barcheck() { return 0; } - virtual Note_req *note() {return 0;} - virtual Script_req *script() {return 0;} - virtual Stem_req *stem() {return 0;} + virtual Note_req *note() { return 0;} + virtual Script_req *script() { return 0;} + virtual Stem_req *stem() { return 0;} virtual Text_req*text() { return 0; } - virtual Rest_req *rest() {return 0;} - virtual Span_req *span() {return 0;} + virtual Rest_req *rest() { return 0; } + virtual Span_req *span() { return 0; } virtual Beam_req *beam() { return 0 ; } virtual Slur_req *slur() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0; } virtual Lyric_req* lreq_l() { return 0; } virtual Melodic_req *melodic() { return 0; } - virtual Mark_req * mark() { return 0; } - virtual Staff_command_req* command() { return 0;} virtual Terminate_voice_req *terminate() {return 0;} virtual Group_change_req * groupchange() { return 0;} virtual Group_feature_req * groupfeature() { return 0; } virtual Spacing_req * spacing() { return 0; } virtual Blank_req * blank() { return 0; } + virtual Musical_req *musical() { return 0; } + virtual Nonmusical_req * nonmus() { return 0; } protected: virtual void do_print()const ; }; @@ -58,271 +65,5 @@ virtual T * accessor() { return this;}\ virtual const char* name() const { return #T; }\ virtual Request *clone() const { return new T(*this); } \ virtual void do_print() const - -struct Barcheck_req : Request { - REQUESTMETHODS(Barcheck_req,barcheck); -}; - -struct Terminate_voice_req : Request { - REQUESTMETHODS(Terminate_voice_req,terminate); -}; - -struct Group_feature_req : Request { - int stemdir_i_; - Group_feature_req(); - REQUESTMETHODS(Group_feature_req, groupfeature); -}; - -struct Group_change_req : Request { - String newgroup_str_; - REQUESTMETHODS(Group_change_req, groupchange); -}; - -/// a request with a duration -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(); - Rhythmic_req(int,int); - REQUESTMETHODS(Rhythmic_req, rhythmic); -}; - -struct Spacing_req :virtual Request { - Moment next; - Real distance; - Real strength; - /* *************** */ - Spacing_req(); - REQUESTMETHODS(Spacing_req, spacing); -}; - -struct Blank_req : Spacing_req, Rhythmic_req { - REQUESTMETHODS(Spacing_req, spacing); - -}; - -///Put a text above or below (?) this staff. -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&); - static int compare(const Text_req&,const Text_req&); - REQUESTMETHODS(Text_req,text); -}; - - -struct Lyric_req : public Rhythmic_req, Text_req { - - Lyric_req(Text_def* t_p); - REQUESTMETHODS(Lyric_req, lreq_l); -}; - -/// request which has some kind of pitch -struct Melodic_req :virtual Request -{ - /// 0 is c - int notename; - int octave; - int accidental; - bool forceacc; - - // return height from central c (in halflines) - int height()const; - Melodic_req(); - - REQUESTMETHODS(Melodic_req,melodic); -}; - -/// Put a note of specified type, height, and with accidental on the staff. -struct Note_req : Rhythmic_req, virtual Melodic_req { - - - Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); } - REQUESTMETHODS(Note_req, note); - }; -/** -*/ - - -///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 -/** - Rhythmic_req parent needed to determine if it will fit inside a beam. - */ - -struct Stem_req : Rhythmic_req { - int dir_i_; - Stem_req(int s, int dots); - REQUESTMETHODS(Stem_req,stem); -}; - -/// 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 { - NOSPAN, START, STOP - } spantype ; - static int compare(const Span_req &r1, const Span_req &r2); - REQUESTMETHODS(Span_req,span); - - Span_req(); - -}; - - -///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(); -}; - -/// a slur -struct Slur_req : Span_req { - REQUESTMETHODS(Slur_req,slur); - -}; - - -///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&); -}; - - -/// 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*); - REQUESTMETHODS(Staff_command_req,command); -}; - -#if 0 - - -///Draw a (Guitar) chord above or below this ``note'' -/** -Why a request? -Because everything else is done in requests. -*/ -struct Chord : Request { - // don't know how this looks. -}; - -/// for absolute dynamics -enum Loudness { - FFF, FF, F, MF, MP, P, PP, PPP -} ; - - -///Start / stop a slur or a bracket. -/** -Start/stop a bracket at this note. if #nplet# is set, the staff will -try to put an appropriate number over the bracket -*/ -struct Bracket_req : Span_req { - int nplet; // print a number over the beam. -}; - -struct Subtle_req { - Moment subtime; -}; - -/// helper in the hierarchy -/** 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 - note, therefore fore each Dynamic request carries a time, measured - from the start of its note. - - This subfield would come in handy, if mpp96 was adapted for midi - support. - - 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 { - -}; - -/// do a decrescendo -struct Decresc_req : Span_req, Dynamic { - -}; - -/// do a dynamic like "fff" or "mp" -struct Absdynamic_req : Request, Dynamic { - Loudness loudness; -}; - -struct Grace_req : Subtle_req { - -}; - -struct Grace_turn_req : Grace_turn { - -}; - -struct Grace_note : Melodic_req { - -}; - -struct Grace_notes { - -}; - -struct Glissando_req : Span_req { - -}; -#endif #endif diff --git a/hdr/sccol.hh b/hdr/sccol.hh index 1d2f4022bb..8237822219 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -21,29 +21,33 @@ */ -struct Score_column { +class Score_column { + friend class Score; + friend class Score_walker; + bool musical_b_; + Moment when_; + void set_breakable(); +public: /// indirection to column PCol * pcol_l_; /// 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); void add_duration(Moment ); void preprocess(); - void set_breakable(); + bool breakable_b(); + bool musical_b() { return musical_b_; } bool used(); void print() const; -private: - Moment when_; + }; instantiate_compare(Score_column&, Score_column::compare); diff --git a/hdr/score.hh b/hdr/score.hh index cd5a56c5e7..f48ad356df 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -1,5 +1,15 @@ +/* + score.hh -- declare Score + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + #ifndef SCORE_HH #define SCORE_HH + #include "varray.hh" #include "proto.hh" #include "plist.hh" @@ -20,8 +30,6 @@ struct Score { const char *defined_ch_c_l_; int errorlevel_i_; - Assoc markers_assoc_; - /* *************************************************************** */ /// construction @@ -29,7 +37,6 @@ struct Score { ~Score(); void add(Staff*); - void add_marks(Array, Array); /// do everything except outputting to file void process(); @@ -40,16 +47,18 @@ struct Score { void OK() const; void print() const; - // utils: - PCursor create_cols(Moment); - - /// find a column. The cursor is given to try a little efficiency. + /// find a column. PCursor find_col(Moment,bool); /// when does the last *musical* element finish? Moment last() const; private: + void setup_music(); + void process_music(); + // utils: + PCursor create_cols(Moment); + Score(Score const&){} /** diff --git a/hdr/scorewalker.hh b/hdr/scorewalker.hh new file mode 100644 index 0000000000..0bfc991374 --- /dev/null +++ b/hdr/scorewalker.hh @@ -0,0 +1,36 @@ +/* + scorewalker.hh -- declare Score_walker + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef SCOREWALKER_HH +#define SCOREWALKER_HH +#include "pcursor.hh" +#include "proto.hh" +#include "varray.hh" + + +/** + walk through the score_columns, and while doing so, walk all staffs in a score. + */ +class Score_walker : public PCursor +{ + /// walkers for the individual staves. + Array walker_p_arr_; + Array disallow_break_walk_l_arr; + int disallow_break_count_; + void reinit(); +public: + void allow_break(Staff_walker*w); + Score_walker(Score*); + ~Score_walker(); + Moment when(); + void operator++(int); + /// process staff walkers. + void process(); +}; +#endif // SCOREWALKER_HH diff --git a/hdr/source.hh b/hdr/source.hh index b9d00f4650..063905baaa 100644 --- a/hdr/source.hh +++ b/hdr/source.hh @@ -16,7 +16,7 @@ public: Source_file* sourcefile_l( char const* ch_c_l ); private: - IPointerList sourcefile_p_iplist_m; + IPointerList sourcefile_p_iplist_; }; #endif // SOURCE_HH // diff --git a/hdr/sourcefile.hh b/hdr/sourcefile.hh index f92631dbe0..a52e76f66a 100644 --- a/hdr/sourcefile.hh +++ b/hdr/sourcefile.hh @@ -11,7 +11,7 @@ class Source_file { public: /** - RETURN path to opened file. + @return path to opened file. */ Source_file( String &filename_str ); ~Source_file(); @@ -29,11 +29,11 @@ private: void open(); void unmap(); - istream* istream_p_m; - int fildes_i_m; - String name_str_m; - off_t size_off_m; - caddr_t data_caddr_m; + istream* istream_p_; + int fildes_i_; + String name_str_; + off_t size_off_; + caddr_t data_caddr_; }; #endif // SOURCE_FILE_HH // diff --git a/hdr/spanner.hh b/hdr/spanner.hh index 097a592cd6..878d48d6e0 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -10,8 +10,8 @@ #include "proto.hh" #include "staffelem.hh" -/// a symbol which is attached between two columns. -/** A spanner is a symbol which spans across several columns, so its + +/** 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. @@ -42,9 +42,9 @@ struct Spanner:Staff_elem { Spanner *broken_at(PCol *c1, PCol *c2) const; virtual Spanner* spanner() { return this; } protected: - /// clone a piece of this spanner. + /** - + clone a piece of this spanner. PRE c1 >= start, c2 <= stop */ diff --git a/hdr/staff.hh b/hdr/staff.hh index 6f43293b26..4c507c4b5b 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -1,45 +1,41 @@ +/* + staff.hh -- declare Staff + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #ifndef STAFF_HH #define STAFF_HH -#include "staffcommands.hh" - +#include "plist.hh" +#include "proto.hh" +#include "moment.hh" /// base class for a collection of voices. -struct Staff { +class Staff { + Staff_column *get_col(Moment, PCursor * last= 0); + Staff(const Staff&src); + /// synchronous horizontal stuff - IPointerList voices; + IPointerList voice_list_; + +public: /// runtime field IPointerList cols; Score *score_l_; PScore *pscore_l_; - String define_spot_str_; /* *************************************************************** */ - void add(PointerList &s); - void do_commands(PointerList score_wide, - PointerList staff_wide); + void add(const PointerList &s); - void get_marks(Array&, Array&); - - /// throw away cols later the #l# - void truncate_cols(Moment l); - - Staff(const Staff&src); void add_voice(Voice *v); - void add_staff_column(Staff_column *sp); - Paperdef*paper()const; - - /// interpret all requests and add items to #destination#. - /** - This routines calls virtual functions from Staff, to delegate the - interpretation of requests to a derived class of Staff */ - void process(); - void setup_staffcols(); void OK() const; @@ -50,22 +46,12 @@ struct Staff { /// remove unused cols void clean_cols() ; - - Staff_column *get_col(Moment,bool); // ugh - Staff(); - - /* - VIRTUALS - */ - + virtual void set_output(PScore * destination)=0; - virtual void walk()=0; - virtual Staff_column * create_col(Score_column * )=0; + virtual Staff_walker *get_walker_p()=0; virtual ~Staff() { } -private: - void set_time_descriptions(); +protected: + virtual Staff_column * create_col()=0; }; #endif - - diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh deleted file mode 100644 index 1caead811e..0000000000 --- a/hdr/staffcommands.hh +++ /dev/null @@ -1,32 +0,0 @@ -/* - lilypond, (c) 1996,97 Han-Wen Nienhuys -*/ -#ifndef SCORECOMMANDS_HH -#define SCORECOMMANDS_HH - -#include "proto.hh" -#include "command.hh" -#include "varray.hh" -#include "plist.hh" -#include "timedescription.hh" - - -struct Staff_commands_at : public IPointerList { - Time_description tdescription_; - - /* *************** */ - - bool is_breakable(); - Moment when(); - Staff_commands_at(Time_description); - void set_breakable(); - void add_command_to_break(Command pre, Command mid,Command post); - void print() const; - void OK() const; - void insert_between(Command victim, PCursor firstc, - PCursor last); - void add(Command c); -}; - -#endif - diff --git a/hdr/staffeleminfo.hh b/hdr/staffeleminfo.hh new file mode 100644 index 0000000000..b8af8aeb22 --- /dev/null +++ b/hdr/staffeleminfo.hh @@ -0,0 +1,28 @@ +/* + staffeleminfo.hh -- declare Staff_elem_info + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef STAFFELEMINFO_HH +#define STAFFELEMINFO_HH + +#include "proto.hh" + +/// data container. +struct Staff_elem_info { + Staff_elem * elem_p_; + Request*req_l_; + const Voice * voice_l_; + Voice_group_registers * group_regs_l_; + Request_register * origin_reg_l_; + + /* *** */ + Staff_elem_info(Staff_elem*, Request*, Request_register*); + Staff_elem_info(); +}; + +#endif // STAFFELEMINFO_HH diff --git a/hdr/staffwalker.hh b/hdr/staffwalker.hh index 3b78c29c6b..aed371ef32 100644 --- a/hdr/staffwalker.hh +++ b/hdr/staffwalker.hh @@ -1,14 +1,15 @@ - /* - staffwalker.hh -- part of LilyPond - + staffwalker.hh -- declare Staff_walker + (c) 1996,97 Han-Wen Nienhuys */ #ifndef STAFFWALKER_HH #define STAFFWALKER_HH -#include "staff.hh" +#include "proto.hh" +#include "timedescription.hh" +#include "pcursor.hh" /** manage run-time info when walking staffcolumns such as: key, @@ -17,30 +18,28 @@ struct Staff_walker : public PCursor { Staff * staff_l_; PScore * pscore_l_; - - int break_status; + Score_walker *score_walk_l_; + Time_description time_; + Rhythmic_grouping *default_grouping; /* *************** */ - int priority() const; // Command Moment when() const; virtual ~Staff_walker(); Staff_walker(Staff*, PScore*); void process() ; - void process_command(Command *); - void operator++(int); - /* *************** - VIRTUAL - *************** */ + void operator++(int); + void allow_break(); - /// every time ++ is called +protected: + /// every time before ++ is called virtual void do_pre_move(){} + /// every time after ++ is called virtual void do_post_move(){} virtual void process_requests()=0; - virtual void do_TYPESET_command(Command*)=0; - virtual void do_INTERPRET_command(Command*)=0 ; private: + void process_timing_reqs(); Staff_walker(Staff_walker const&); }; diff --git a/hdr/stcol.hh b/hdr/stcol.hh index 0ae5244d8a..613dffb758 100644 --- a/hdr/stcol.hh +++ b/hdr/stcol.hh @@ -11,34 +11,27 @@ #include "moment.hh" /// store simultaneous requests -struct Staff_column { - - Score_column *score_column_l_; - - /// fields to collect data vertically. - Array v_elts; - - /// idem - Staff_commands_at *staff_commands_p_; +class Staff_column { + Staff_column(Staff_column const&); +public: + /// fields to collect timing data vertically. + Array timing_req_l_arr_; + Score_column *musical_column_l_, *command_column_l_; - Time_description *tdescription_; - /* *************** */ - Staff_column(Score_column*); - bool musical_b() const; + Staff_column(); + Moment when() const; + void set_cols(Score_column *c1, Score_column *c2); void add(Voice_element*ve); void OK() const; - /* - VIRTUAL - */ + virtual ~Staff_column(); - virtual void setup_requests()=0; - virtual ~Staff_column(); -private: - Staff_column(Staff_column const&); +protected: + virtual void setup_one_request(Request*)=0; + }; diff --git a/hdr/stem.hh b/hdr/stem.hh index 962d1f4ba3..ccc02a6b59 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -1,5 +1,5 @@ /* - stem.hh -- + stem.hh -- declare Stem (c) 1996,97 Han-Wen Nienhuys */ @@ -10,8 +10,8 @@ #include "varray.hh" #include "moment.hh" -/// the rule attached to the ball -/** + +/**the rule attached to the ball. takes care of: \begin{itemize} @@ -22,11 +22,7 @@ */ struct Stem : Item { -/* - /// rhythmical length - Moment note_length; - */ - // heads the stem encompasses (positions) + /// heads that the stem encompasses (positions) int minnote, maxnote; /// false if in beam @@ -38,8 +34,8 @@ struct Stem : Item { /// needed for determining direction/length int staff_center; - // extent of the stem (positions) - /** + + /**extent of the stem (positions). fractional, since Beam has to adapt them. */ @@ -49,8 +45,9 @@ struct Stem : Item { /// flagtype? 4 none, 8 8th flag, 0 = beam. int flag; - ///geen gedonder, jij gaat onder + /** + geen gedonder, jij gaat onder. -1 stem points down, +1: stem points up */ diff --git a/hdr/tex.hh b/hdr/tex.hh index baff1c634d..af45ba7d27 100644 --- a/hdr/tex.hh +++ b/hdr/tex.hh @@ -5,8 +5,7 @@ #include "boxes.hh" #include "scalar.hh" -/// parameter substitution in TeXstrings -/** +/** parameter substitution in TeXstrings. this function provides a simple macro mechanism: if source == "tex%bla%", then diff --git a/hdr/textdef.hh b/hdr/textdef.hh index 8100ed45d8..da0055281d 100644 --- a/hdr/textdef.hh +++ b/hdr/textdef.hh @@ -14,7 +14,7 @@ struct Text_def { int align_i_; String text_str_; String style_str_; - char const* defined_ch_c_l_m; + char const* defined_ch_c_l_; /* ****************/ diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh index 40ae5ffa64..586d25a5d8 100644 --- a/hdr/textspanner.hh +++ b/hdr/textspanner.hh @@ -11,10 +11,8 @@ #include "directionalspanner.hh" #include "textdef.hh" -/// a spanner which puts texts on top of other spanners. -/** - Use for triplets, eentweetjes, ottava, etc. - */ +/** a spanner which puts texts on top of other spanners. Use for + triplets, eentweetjes, ottava, etc. */ struct Text_spanner : Spanner { Text_def spec; Offset text_off_; diff --git a/hdr/timedescription.hh b/hdr/timedescription.hh index 4eb5db1194..7e366ec4c2 100644 --- a/hdr/timedescription.hh +++ b/hdr/timedescription.hh @@ -7,32 +7,32 @@ #ifndef tdes_HH #define tdes_HH -#include "real.hh" #include "moment.hh" /// full info on where we are struct Time_description { - Moment when; + Moment when_; /// if true, no bars needed, no reduction of whole_in_measure bool cadenza_b_; /// current measure info - Moment whole_per_measure; + Moment whole_per_measure_; /// where am i - Moment whole_in_measure; + Moment whole_in_measure_; /// how long is one beat? - Moment one_beat; + Moment one_beat_; /// idem - int bars; + int bars_i_; /* *************** */ void set_cadenza(bool); void OK() const; - Time_description(Moment, const Time_description*); + Time_description(); + void add(Moment dt); String str()const; void print() const; void setpartial(Moment p); diff --git a/hdr/tstream.hh b/hdr/tstream.hh index 27ec95cd16..4d5805c556 100644 --- a/hdr/tstream.hh +++ b/hdr/tstream.hh @@ -4,8 +4,8 @@ #include #include "string.hh" -/// TeX output -/** + +/** 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. diff --git a/hdr/voice.hh b/hdr/voice.hh index 20538ae861..4d282ddea1 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -5,8 +5,7 @@ #include "plist.hh" #include "moment.hh" -/// class for horizontal stuff. -/** +/** 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 @@ -26,12 +25,12 @@ struct Voice { void print() const; void set_default_group(String id); }; -/// one horizontal bit. -/** Apart from being a container for the requests, Voice_element is nothing + +/** 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; + char const* defined_ch_c_l_; const Voice *voice_l_; IPointerList reqs; diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini index 7c61810970..689f935b0f 100644 --- a/init/table_sixteen.ini +++ b/init/table_sixteen.ini @@ -72,11 +72,11 @@ symboltables { } "bars" = table { - "empty" "\emptybar" 0pt 0pt 0pt 0pt - "|" "\maatstreep" 0pt 5pt -8pt 8pt - "||" "\finishbar" 0pt 2pt -8pt 8pt - ":|" "\repeatbar" -4pt 0pt -8pt 8pt - "|:" "\startrepeat" 0pt 4pt -8pt 8pt + "empty" "\emptybar" 0pt 0pt 0pt 0pt + "|" "\maatstreep" 0pt 0.4pt -8pt 8pt + "||" "\finishbar" 0pt 2pt -8pt 8pt + ":|" "\repeatbar" -4pt 0pt -8pt 8pt + "|:" "\startrepeat" 0pt 4pt -8pt 8pt ":|:" "\repeatbarstartrepeat" 0pt 16pt -8pt 8pt } @@ -97,7 +97,7 @@ symboltables { % dims ignored for this table "param" = table { - "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt + "meter" "\generalmeter{%}{%}" 0pt 10pt -5pt 5pt "linestaf" "\linestafsym{%}{%}" "stem" "\stem{%}{%}" "fill" "\hbox{}" diff --git a/input/Makefile b/input/Makefile index c9888dd680..885dcf19a9 100644 --- a/input/Makefile +++ b/input/Makefile @@ -4,7 +4,7 @@ DISTFILES=Makefile kortjakje.ly pavane.ly maartje.ly\ cadenza.ly scales.ly standchen.ly twinkle.ly\ wohltemperirt.ly error.ly\ martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\ - coriolan-alto.ly\ + coriolan-alto.ly rhythm.ly \ standchen.tex pavane.tex scsii-menuetto.tex scsii-menuetto.ly\ martien.tex diff --git a/input/cadenza.ly b/input/cadenza.ly index 3f32d19de3..6773143fea 100644 --- a/input/cadenza.ly +++ b/input/cadenza.ly @@ -7,53 +7,50 @@ cad = music { $ \duration { 8} \textstyle "italic" - \command { \clef \violin } + \clef \violin 'c4._"f" g8 \textstyle "roman" ['e^"accel" ()'d 'c b] [b()'c] g-\fermata - \command { \bar \empty } + \bar \empty c [c_"rubato" e g 'c] \octave{'} e4. e [g ()f_"rit" e d] \duration{16} dis4()e4 - \command { \bar \empty } + \bar \empty r8 [c d] [e f g gis] \duration{4} a-> `f()`e g f-> `d()`cis e \duration{8} d4^\fermata - \command { \bar \empty } + \bar \empty r8 `a [`b cis] \duration{16} [d cis d e] f4()[f e d c] `b4 - \octave{} \plet{2/3} ['d8 'c8 a8] - \plet{1/1} + \octave{} \plet{2/3} ['d8 'c8 a8] \plet{1/1} g2 - \command { \bar \empty } + \bar \empty [g c e g] ['c e g 'c]\octave{'} [e `g c e] g4^\fermata %()% BUG! - \command { \bar \empty } + \bar \empty [g8.(_"a tempo" e g8. )e] a4. g8 [f8 e8 d8 c8] `g2 d2^"tr" c4 $} - score { +score { staff { melodic music { cad } - } commands { - meter 4*4 - cadenza 1 - grouping 1*4 + cadenza $1$ + grouping{1*4} } } diff --git a/input/coriolan-alto.ly b/input/coriolan-alto.ly index 959c4d79a3..683141814d 100644 --- a/input/coriolan-alto.ly +++ b/input/coriolan-alto.ly @@ -14,7 +14,9 @@ alto = music { $ \duration{ 8 } - + \key {$bes es as$} + + } \clef "alto" % these are chords (i.e. non-divisi) % that-s why i-d rather type chords, % but how to type slurs? @@ -68,15 +70,10 @@ alto = music { } score { - staff { melodic music { alto } - commands { - clef "alto" - key $c es as$ % c ??? - } - } + staff { melodic music { alto }} + commands { - meter 4*4 - skip 5:0 + meter {4*4} grouping {4*4} } paper { unitspace 14mm diff --git a/input/error.ly b/input/error.ly index 9cc6311697..922f9ebefd 100644 --- a/input/error.ly +++ b/input/error.ly @@ -1,8 +1,7 @@ mwa = music { $ -% [ a8 a8 a8 a8 a8 ] % assertion fail -% [ a8 a8 a8 ] % assertion fail -% [ a8 ] % assertion fail + [ a8 a8 a8 a8 a8 ] % + [ a8 ] % a ) b ] c % warning & % ok; error a b ) ] % ok; error @@ -37,6 +36,6 @@ score { melodic music { mwa } } commands { - meter 3*4 + meter {3*4} } } diff --git a/input/kortjakje.ly b/input/kortjakje.ly index ba78402109..6da101c266 100644 --- a/input/kortjakje.ly +++ b/input/kortjakje.ly @@ -11,6 +11,7 @@ melodie = music { $ % switch Lilypond in note-mode + \clef\violin \octave {} % set the default octave % the default note duratino is 4 %%% theme @@ -32,7 +33,7 @@ $} % more of this. begeleiding = -$ +$ \clef "bass" % bass-clef \music { % as you can see, the $ sign obliges % you to precede keyword by a backslash: \ \octave { ` } % default octave: 1 below the first octave. @@ -53,16 +54,12 @@ $ bstaf = staff { melodic music { begeleiding } % use the declared music - commands { % commands with Staff-wide impact. - clef "bass" % bass-clef - } } % another one vstaf = staff { melodic music { melodie } - commands { clef "violin" } % default clef is violin clef } @@ -74,9 +71,7 @@ score { unitspace 2.5cm % a whole note takes 2.5 cm ideally. } commands { - meter 2* 4 % a 2/4 meter. - skip 33:0 % skip 32 measures, and generate the bars -% meter 6 8 % another meter + meter {2* 4} % a 2/4 meter. } } diff --git a/input/maartje.ly b/input/maartje.ly index 0f96005edf..9a79cf47c3 100644 --- a/input/maartje.ly +++ b/input/maartje.ly @@ -26,7 +26,7 @@ melody= staff { melodic music{$ - c8 + c8\key{fis cis gis} |r4 r4 r4 r4 |'cis2.. r8 | r4 r8 r16 r32 r32 @@ -45,19 +45,11 @@ staff { |''fis2 | a8 b8 'c8 'd8 |''c8 ```c8 c4 |c4 c4 |c4 \duration{ 16 } `b `a `g `f \duration{ 4} - + \clef\bass |c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c $} - commands { - skip 3:0 - key $ fis cis gis $ - skip 2:0 - key - skip 5:0 - clef bass - } } score { @@ -68,13 +60,13 @@ score { % staff { ritme }%broken for now staff { melody } commands { - meter 4* 4 + meter {4* 4} partial 8 - skip 1:2 + skip 3*2 bar ":|:" - skip 2:0 - meter 2* 4 - skip 19:0 + skip 2*1 + meter {2*4} + } } diff --git a/input/martien.ly b/input/martien.ly index b299340b3a..cf40cc9788 100644 --- a/input/martien.ly +++ b/input/martien.ly @@ -1,3 +1,6 @@ +%%%%%%%%% HAS TO BE ADJUSTED to pl32 + + % martien.ly % % Viola Quartet @@ -23,83 +26,30 @@ score { staff { melodic music { alto } - commands { -% meter 2*4 - clef "alto" - key $fis$ - skip 56:0 - key $bes es as$ - skip 8:0 -% meter 6*8 - skip 8:0 -% meter 2*4 - skip 16:0 - key $fis$ - } } staff { melodic music { violin1 } - commands { -% meter 2*4 - clef "violin" - key $fis$ - skip 56:0 - key $bes es as$ - skip 8:0 -% meter 6*8 - skip 8:0 -% meter 2*4 - skip 16:0 - key $fis$ - } } staff { melodic music { violin2 } - commands { -% meter 2*4 - clef "violin" - key $fis$ - skip 56:0 - key $bes es as$ - skip 8:0 -% meter 6*8 - skip 8:0 -% meter 2*4 - skip 16:0 - key $fis$ - } } staff { melodic music { cello } - commands { -% meter 2*4 - clef "bass" - key $fis$ - skip 56:0 - key $bes es as$ - skip 8:0 -% meter 6*8 - skip 8:0 -% meter 2*4 - skip 16:0 - key $fis$ - } } commands { - meter 2*4 - skip 56:0 - bar "||" - skip 8:0 - meter 6*8 - bar "||" - skip 8:0 - meter 2*4 - bar "||" - skip 16:0 - bar "||" + meter {2*4} + key $fis$ + skip 56*2 + key $bes es as$ + skip 8*2 + meter {6*8} + skip 48*8 + meter {2*4} + skip 16*2 + key $fis$ } paper { % unitspace 16mm diff --git a/input/mlalt.ly b/input/mlalt.ly index 9058f25dd2..51f7de8742 100644 --- a/input/mlalt.ly +++ b/input/mlalt.ly @@ -14,6 +14,7 @@ alto = music { $ \duration{16} + \clef\alto \octave{} %1 [ `b8. `a ] [ `g8 `b c ] | diff --git a/input/mlcello.ly b/input/mlcello.ly index 5795bb44c1..cdc0b43348 100644 --- a/input/mlcello.ly +++ b/input/mlcello.ly @@ -13,7 +13,7 @@ % cello = music { $ - \octave{`} +\clef"bass" \octave{`} \duration{4} %%1 g `g | diff --git a/input/mlvio1.ly b/input/mlvio1.ly index 7ea613f53c..a6f2b049f4 100644 --- a/input/mlvio1.ly +++ b/input/mlvio1.ly @@ -13,6 +13,7 @@ % violin1 = music { $ +\clef "violin" \octave{} \duration{4} %1 diff --git a/input/mlvio2.ly b/input/mlvio2.ly index 0a9df42f3f..ad6deb44a4 100644 --- a/input/mlvio2.ly +++ b/input/mlvio2.ly @@ -13,7 +13,7 @@ % violin2 = music { $ - \octave{} +\clef "violin" \octave{} \duration{4} %1 d2 | diff --git a/input/pavane.ly b/input/pavane.ly index e3b1e50e06..4f0b3b8812 100644 --- a/input/pavane.ly +++ b/input/pavane.ly @@ -15,6 +15,7 @@ staff { melodic music{ $ \octave { ' } + \key{ fis cis } \duration { 8 } % 1 @@ -39,8 +40,8 @@ staff { e4( fis4 () [fis e fis gis] | cis4 `b4())`b8 r8 r4^"tr\`es soutenu" | - \command { \meter 2 *4 } r4 r4 | - \command { \meter 4 *4 } + \meter {2 *4} r4 r4 | + \meter {4 *4} 'cis4_"\dyn ppp"( 'd4 () ['d 'cis 'd 'e] | a4 )gis2. | a4 (b4()[b a b 'cis] | @@ -76,8 +77,9 @@ staff { | [f a 'c] \plet{1/1} 'e4-^ () ['e f-> a-> 'c->] | 'e4._"sf" 'e8()'c4 r4 | r1 | - \command { \meter 2 *4 } r4 r4-\fermata - \command { \meter 4 *4 } + \meter {2 *4} + r4 r4-\fermata + \meter {4 *4} \octave { ' } |d2(( [)d e cis `b] | @@ -94,10 +96,7 @@ staff { )b [fis a b ] 'cis4 b4 | fis2 r2 | r1-\fermata - $} - commands { - key $fis cis $ - } + $} } score { staff { @@ -110,14 +109,12 @@ score { width 12cm } commands { - meter 4 *4 - skip 18:0 - skip 1:0 - skip 20:0 + meter {4 *4} + skip 39*1 bar "|:" - skip 10:0 + skip 10*1 bar ":|" - skip 13:0 + skip 13*1 bar "||" } } \ No newline at end of file diff --git a/input/rhythm.ly b/input/rhythm.ly new file mode 100644 index 0000000000..c74c9d8dcd --- /dev/null +++ b/input/rhythm.ly @@ -0,0 +1,60 @@ +% +% I've got rhythm! +% +% add any impressive examples here, please + +ritme = staff { + melodic + + music { $ + c8 | + + [a8() a8. a8 a16 a16 a16] c4. | % watch the beams! + r32 r32 r16 r8 r4 r2 | + \meter{ 5*16} + + % divide measure in 5 equal parts. Usually it 2+3 or 3+2 + \grouping { 5*16 } + [c8 c16 c8 ] | % watch THIS! + \plet{5/4} [c16 c16 c16 c16]\plet{1/1} | + \meter{ 2*8} + c4 | + c4 c4 c4 c4 + \meter {4*4} + c1 c1 c1 + +% [c16 c16 c16 c16 ] | +% [c16 c16 c16 c16 c16 ] | +% [c16 c16 c16 c16 c16 ] | + + $ } + + commands { % override "commands" section of Score. + partial 1*8 + meter{ 4*4} + } +} +another = staff { + melodic + music { $ + c1 c1 c1 c4 c4 c4 c4 {\meter 4*4} c1 c1 c1 + $ } +} + +yanother = staff { + melodic + music { $ + c1 c1 c1 c4 c4 c4 c4 c1 c1 c1 + $ } +} + +score { + staff{ritme} + staff { another } + staff { yanother } + commands { meter {4*4 }} + paper { + unitspace 2cm + geometric 1.3 + } +} \ No newline at end of file diff --git a/input/scales.ly b/input/scales.ly index 97d8dd89cb..fba2c9ff4d 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -41,9 +41,8 @@ c1 |['c b a g][f e d c] $} - commands { - } } + score { staff { blah @@ -54,11 +53,8 @@ score { geometric 1.4 } commands { - meter 6*8 - skip 6:0 - meter 4*4 - skip 2:0 - skip 11:0 - + meter {6*8} + skip 36*8 + meter {4*4} } } diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index 2e7358db48..00fde25284 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -28,7 +28,8 @@ % % because piece is set very tightly %%1 % double comments are included in .tex file ii_menuetto = music { - $ + $\clef"alto" + \key {bes} \octave{} \duration{8} { a2 f2 d2_"\f" } bes4-. | @@ -59,7 +60,7 @@ ii_menuetto = music { % { 'cis2.-\upbow e2. `a2.\stemdown } :||: { 'cis2.-\upbow e2. `a2. } | % :||: %%9 -% \clef "violin" + \clef "violin" % { 'e2 a2_f\stemdown } { 'e2 a2_"\f" } [ 'd( 'e16 )'f16 ] | @@ -76,7 +77,8 @@ ii_menuetto = music { % %13 % { bes2\stemup g4\stemdown } ( ) f4 % { 'c4\stemup e4\stemdown } -% { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" | +% { bes2 g4 } f4 { 'c4 e4 } | + \clef "alto"% { \multivoice \music { \stem{1} bes2 'c4 } \music { \stem{-1} g4(\stem{-1}) f4 e4 }% ugh @@ -125,24 +127,15 @@ ii_menuetto = music { 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 + meter {3 * 4} + skip {24 * 4}% 8 measures bar ":|:" -% clef "violin" - skip 5:0 -% \clef "alto" - skip 12:0 + + skip {15 * 4} % 5 meas. + + skip {36*4} bar ":||" } paper { @@ -153,4 +146,4 @@ score { geometric 1.4 output "scsii-menuetto.out" } -} +o} diff --git a/input/standchen.ly b/input/standchen.ly index 279cd513be..edc487c9b0 100644 --- a/input/standchen.ly +++ b/input/standchen.ly @@ -35,7 +35,7 @@ %#%% %#%\duration8 %%1 -melodie = music { $ +melodie = music { $ \clef\violin \duration{ 8 } r_"\pp" { [ d `a-| } f-| { d `a-| } f-| { d `a-| ] } | %%2 @@ -194,7 +194,8 @@ melodie = music { $ $ } begeleiding = music { $ - \duration{2} +\clef\bass +\duration{2} `d r4 %%2 ``bes r4 @@ -472,26 +473,19 @@ score { staff { melodic music { melodie } - commands { - key $bes$ - clef "violin" - } } staff { melodic music { begeleiding } - commands { - key $bes$ - clef "bass" - } } commands { - meter 3*4 - skip 4:0 + meter { 3*4 } + key $bes$ + skip 12*4 bar ":|" - skip 32:0 + skip 96*4 bar ":|" - skip 22:0 + skip 66*4 bar "||" } paper { diff --git a/input/twinkle.ly b/input/twinkle.ly index 80b8be6eee..9b081c43fa 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -5,7 +5,7 @@ % Copyright: none melodie = music { - $ + $\clef\violin c c | g g | a a | g g | f f | e e | d d8.( e16 | )c2 | % :| @@ -19,7 +19,7 @@ melodie = music { } begeleiding = music { - $ + $\clef \bass \octave{`} c 'c | 'e 'c | 'f 'c | 'e 'c | 'd b | 'c a | f g | c2 | @@ -106,13 +106,11 @@ text3 = music { mstaf = staff { melodic music { melodie } - commands { clef "violin" } } bass_staf = staff { melodic music { begeleiding } - commands { clef "bass" } } @@ -151,8 +149,8 @@ score { unitspace 2.5cm } commands { - meter 2 * 4 - skip 24:0 + meter {2 * 4} + skip 24*2 bar "||" } } diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index 53187772f9..c4c0f2455e 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -6,14 +6,17 @@ % dux = music { $ - \duration { \last } - r8-"dux" \stem{-1} ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] | + \clef \violin + \duration { \last } + \stem{-1} + + r8-"dux" ['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] | g4 r16 [c d es] [f g as8(] [)as16 d es f ]| [g a bes8(] [)bes16 es f g ] [as g f es] [d8 'c16 b]| - 'c4 r4 r8 ['f 'es 'd] | + 'c4 r4 r8 ['f 'es 'd] r8 [as g f] [g f16 es] [f8 d] | $} @@ -23,47 +26,37 @@ comes = music { $ \octave {'} 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 es16 d] [es8 `g8] [`as f16 es] [f8 `a] [`bes8 g16 f] [g8 `b] [c8 d16 es] f4( | - [) f8 es16 d] [c16 `bes `as `g] [`f8 as g f] | + [) f8 es16 d] [c16 `bes `as `g] [`f8 as g f] [es d es f] [`b c d `b] | $} bassdux = music { $ + \clef \bass r1 r r r r r \octave { } r8 [c16 B] [c8 G] [As c16 B] [c8 d] | [G c16 B] [c8 d] [F16 G] As4 [G16 F] | $ } -% will make it look even uglier basstaf = staff { melodic music { bassdux } - commands { - clef bass - key $bes es as$ - } } score { staff { melodic - % every "music {} " in a staff has its own "voicegroup" music { dux } music { comes } - commands { - key $bes es as$ - } } staff { basstaf } - commands { - meter 4*4 - skip 8:0 - } - paper { %unitspace 2.5cm - %geometric 1.4 + commands { + meter {4*4} + grouping {2*2} + key {$bes es as$} } } diff --git a/src/bar.cc b/src/bar.cc index 4f26d25310..ad64e016a6 100644 --- a/src/bar.cc +++ b/src/bar.cc @@ -3,6 +3,7 @@ #include "molecule.hh" #include "paperdef.hh" #include "lookup.hh" +#include "debug.hh" NAME_METHOD(Bar); @@ -11,11 +12,17 @@ Bar::Bar( String t) type = t; } +void +Bar::do_print()const +{ + mtor << type; +} + Molecule* Bar::brew_molecule_p()const { Symbol s = paper()->lookup_p_->bar(type); - Molecule* output = new Molecule(Atom(s)); + Molecule*output = new Molecule(Atom(s)); return output; } diff --git a/src/barreg.cc b/src/barreg.cc new file mode 100644 index 0000000000..03b49497b7 --- /dev/null +++ b/src/barreg.cc @@ -0,0 +1,83 @@ +/* + barreg.cc -- implement Bar_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "barreg.hh" +#include "bar.hh" +#include "commandrequest.hh" +#include "complexwalker.hh" +#include "complexcolumn.hh" +#include "sccol.hh" + + +Bar_register::Bar_register(Complex_walker*w) + : Request_register(w) +{ + do_post_move_process(); +} + +bool +Bar_register::try_request(Request*r_l) +{ + if (!r_l->nonmus()->bar()) + return false; + + assert(!bar_req_l_); + bar_req_l_ = r_l->nonmus()->bar(); + + return true; +} + +void +Bar_register::process_request() +{ + + if (bar_req_l_ ) { + bar_p_ = new Bar(bar_req_l_->type); + } else if (!walk_l_->time_.whole_in_measure_) { + bar_p_ = new Bar("|"); + } + + if (bar_p_){ + walk_l_->allow_break(); + announce_element(Staff_elem_info(bar_p_, bar_req_l_, this) ); + } +} + +void +Bar_register::split_bar(Bar *& pre, Bar * no, Bar * &post) +{ + String s= no->type; + if (s == ":|:") { + pre = new Bar(":|"); + post = new Bar("|:"); + }else if (s=="|:") { + post = new Bar(s); + } else { + pre = new Bar(*no); + } +} + +void +Bar_register::do_pre_move_process() +{ + if (bar_p_) { + Bar * post_p =0; + Bar * pre_p =0; + split_bar(pre_p, bar_p_, post_p); + + typeset_breakable_item(pre_p, bar_p_, post_p); + bar_p_ =0; + } +} + +void +Bar_register::do_post_move_process() +{ + bar_req_l_ = 0; + bar_p_ =0; +} diff --git a/src/beam.cc b/src/beam.cc index 44d51e0af9..1b0fa2baa3 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -217,7 +217,10 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const int lhalfs= lhalfs = here->beams_left - prev->beams_right ; int lwholebeams= here->beams_left beams_right ; Real w = (here->hpos() - prev->hpos())/4; - Atom a = paper()->lookup_p_->beam(sl, w); + Symbol dummy; + Atom a(dummy); + if (lhalfs) // generates warnings if not + a = paper()->lookup_p_->beam(sl, w); a.translate(Offset (-w, -w * sl)); for (int j = 0; j < lhalfs; j++) { Atom b(a); @@ -239,8 +242,10 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const b.translate(Offset(0, -dir_i_ * dy * j)); rightbeams.add( b ); } + w /= 4; - a = paper()->lookup_p_->beam(sl, w); + if (rhalfs) + a = paper()->lookup_p_->beam(sl, w); for (; j < rwholebeams + rhalfs; j++) { Atom b(a); diff --git a/src/break.cc b/src/break.cc index 576bf4c67a..6128fdd097 100644 --- a/src/break.cc +++ b/src/break.cc @@ -17,7 +17,7 @@ Break_algorithm::find_breaks() const { Line_of_cols retval; for (iter_top(pscore_.cols,c); c.ok(); c++) - if (c->breakable()) + if (c->breakable_b()) retval.push(c); assert(retval.top() == pscore_.cols.bottom().ptr()); return retval; @@ -71,7 +71,7 @@ Break_algorithm::problem_OK() const iter_top(pscore_.cols,start); PCursor end (pscore_.cols.bottom()); - assert(start->breakable()); - assert(end->breakable()); + assert(start->breakable_b()); + assert(end->breakable_b()); #endif } diff --git a/src/calcideal.cc b/src/calcideal.cc index 79db657588..a656482e7d 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -20,7 +20,7 @@ Score::calc_idealspacing() for (; i.ok(); i++) { assert(i->used()); PCursor j(i+1); - if (i->musical_) { + if (i->musical_b()) { assert(j.ok()); for (int n=0; n < i->durations.size(); n++) { Moment d = i->durations[n]; diff --git a/src/clef.cc b/src/clef.cc deleted file mode 100644 index bf7b924159..0000000000 --- a/src/clef.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - 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() -{ - set_type("violin"); -} - -void -Clef::set_type(String type_str) -{ - 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 - error("unknown clef type `"+clef_type_str_+"\'"); -} diff --git a/src/clefitem.cc b/src/clefitem.cc index 30703026da..037aab69b8 100644 --- a/src/clefitem.cc +++ b/src/clefitem.cc @@ -1,9 +1,17 @@ +/* + clefitem.cc -- implement Clef_item + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "clefitem.hh" #include "string.hh" #include "molecule.hh" #include "paperdef.hh" #include "lookup.hh" -#include "clef.hh" +#include "clefreg.hh" NAME_METHOD(Clef_item); @@ -27,7 +35,7 @@ Clef_item::read(String t) y_off = 6; } void -Clef_item::read(Clef k) +Clef_item::read(Clef_register const &k) { read(k.clef_type_str_); } diff --git a/src/clefreg.cc b/src/clefreg.cc new file mode 100644 index 0000000000..81c87e953a --- /dev/null +++ b/src/clefreg.cc @@ -0,0 +1,95 @@ +/* + clef.cc -- implement Clef_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys , + Mats Bengtsson +*/ + +#include "clefreg.hh" +#include "clefitem.hh" +#include "debug.hh" +#include "commandrequest.hh" +#include "timedescription.hh" +#include "complexwalker.hh" +#include "stcol.hh" + +Clef_register::Clef_register(Complex_walker*w) + : Request_register(w) +{ + clef_p_ = 0; + + set_type("violin"); +} +bool +Clef_register::set_type(String s) +{ + clef_type_str_ = s; + 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 + return false; + walk_l_->set_c0_position(c0_position_i_); + return true; +} + +void +Clef_register::read_req(Clef_change_req*c_l) +{ + if (!set_type(c_l->clef_str_)) + error("unknown clef type ", c_l->defined_ch_c_l_); +} + +bool +Clef_register::try_request(Nonmusical_req* r_l) +{ + if (!r_l->clefchange()) + return false; + + accepted_req_arr_.push(r_l); + // do it now! Others have to read c0_pos. + read_req(r_l->clefchange()); + return true; +} + +void +Clef_register::process_request() +{ + const Time_description *time_l = &walk_l_->time_; + if (!accepted_req_arr_.size() && + (!time_l->whole_in_measure_|| !time_l->when_)) { + + clef_p_ = new Clef_item; + clef_p_->change = false; + } else if (accepted_req_arr_.size()) { + clef_p_ = new Clef_item; + clef_p_->change = true; + } + if (clef_p_) { + clef_p_->read(*this); +// announce_element(Staff_elem_info(clef_p_, +// accepted_req_arr_[0], this)); + } +} + +void +Clef_register::do_pre_move_process() +{ + if (!clef_p_) + return; + if (clef_p_->change) { + typeset_breakable_item(new Clef_item(*clef_p_), + clef_p_, new Clef_item(*clef_p_) ); + } else { + typeset_breakable_item(0, 0, clef_p_); + } + clef_p_ = 0; +} + diff --git a/src/command.cc b/src/command.cc deleted file mode 100644 index 7ddebc6f82..0000000000 --- a/src/command.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "string.hh" -#include "debug.hh" -#include "command.hh" - -bool -Command::isbreak()const -{ - return (code >= BREAK_PRE && code <= BREAK_END); -} - -Command::Command() -{ - code = NOP; - priority=0; -} - -void -Command::print() const -{ -#ifndef NPRINT - mtor << "Command " << "code " << code << " prio " << priority; - if ( isbreak()) - mtor << "(break separator)"; - if (args.size()) { - mtor<< " args: "; - for (int i = 0; i +*/ + +#include "commandrequest.hh" +#include "debug.hh" +#include "musicalrequest.hh" + + +void +Cadenza_req::do_print()const +{ + mtor << on_b; +} + +void +Bar_req::do_print() const +{ + mtor << type; +} + +Partial_measure_req::Partial_measure_req(Moment m) +{ + duration_ =m; +} +/* *************** */ +Cadenza_req::Cadenza_req(bool b) +{ + on_b =b; +} +/* *************** */ + +Meter_change_req::Meter_change_req() +{ + beats_i_ = 0; + one_beat_i_ =0; +} +void +Meter_change_req::set(int b,int o) +{ + beats_i_=b; + one_beat_i_=o; +} + +void +Timing_req::do_print()const{} + +void +Nonmusical_req::do_print()const{} +/* *************** */ +void +Barcheck_req::do_print() const{} + +Bar_req::Bar_req(String s) +{ + type = s; +} +/* *************** */ +void +Clef_change_req::do_print() const +{ + mtor << clef_str_ ; +} + +Clef_change_req::Clef_change_req(String s) +{ + clef_str_ = s; +} +/* *************** */ +void +Group_feature_req::do_print() const +{ + mtor << "stemdir " << stemdir_i_; +} + +Group_feature_req::Group_feature_req() +{ + stemdir_i_ = 0; +} + +void +Group_change_req::do_print()const +{ + mtor << "id : " << newgroup_str_; +} +/* *************** */ +void +Terminate_voice_req::do_print()const +{ +} + +/* *************** */ +void +Partial_measure_req::do_print() const +{ + mtor << duration_; +} + +void +Meter_change_req::do_print() const +{ + mtor << beats_i_ << "*" << one_beat_i_; +} + +/* *************** */ + +void +Measure_grouping_req::do_print() const +{ + for (int i=0; i < elt_length_arr_.size(); i++) { + mtor << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" "; + } +} +/* *************** */ +void +Key_change_req::do_print() const +{ + for (int i=0; i < melodic_p_arr_.size(); i++) { + melodic_p_arr_[i]->print(); + } +} + +Key_change_req::Key_change_req() +{ +} +Key_change_req::Key_change_req(Key_change_req const&c) +{ + for (int i=0; i < c.melodic_p_arr_.size(); i++) { + melodic_p_arr_.push( c.melodic_p_arr_[i]->clone()->melodic() ); + } +} + +Key_change_req::~Key_change_req() +{ + for (int i=0; i < melodic_p_arr_.size(); i++) + delete melodic_p_arr_[i]; +} diff --git a/src/complexcolumn.cc b/src/complexcolumn.cc new file mode 100644 index 0000000000..22e695016a --- /dev/null +++ b/src/complexcolumn.cc @@ -0,0 +1,102 @@ +/* + complexcolumn.cc -- implement Complex_column + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "voice.hh" +#include "debug.hh" +#include "complexcolumn.hh" +#include "pscore.hh" +#include "request.hh" +#include "pscore.hh" +#include "sccol.hh" +#include "complexstaff.hh" +#include "misc.hh" + +void +Complex_column::typeset_musical_item(Item *i) +{ + assert(i); + Score_column * sccol_l = musical_column_l_; + staff_l_->pscore_l_->typeset_item(i, sccol_l->pcol_l_, + staff_l_->pstaff_l_); +} + +Complex_column::Complex_column(Complex_staff *staff_l) +{ + staff_l_ = staff_l; +} + +void +Complex_column::setup_one_request(Request * j) +{ + if (j->nonmus()) // ugh + first_l_arr_.push(j); + else if (j->musical()) + second_l_arr_.push(j); +} + +/** + align items in #item_l_arr#, return the width. + */ +Interval +align_items(Array item_l_arr) +{ + Interval wid(0,0); + for (int i =0; i < item_l_arr.size(); i++) { + Interval item_width= item_l_arr[i]->width(); + item_l_arr[i]->translate(Offset( wid.right - item_width.left ,0)); + wid.unite(item_width); + } + return wid; +} + +void +translate_items(Real x, Array item_l_arr) +{ + for (int i =0; i < item_l_arr.size(); i++) + item_l_arr[i]->translate(Offset(x, 0)); +} +/* + UGR + This still sux + */ +void +Complex_column::typeset_breakable_items(Array &pre_p_arr, + Array &nobreak_p_arr, + Array &post_p_arr) +{ + PCol * c= command_column_l_->pcol_l_; + PScore *ps_l=staff_l_->pscore_l_; + if (!c->breakable_b()) { + for (int i =0; i < pre_p_arr.size(); i++) + delete pre_p_arr[i]; + pre_p_arr.set_size(0); + for (int i =0; i < post_p_arr.size(); i++) + delete post_p_arr[i]; + post_p_arr.set_size(0); + } + + + for (int i =0; i < pre_p_arr.size(); i++) { + ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0); + } + for (int i =0; i < nobreak_p_arr.size(); i++) { + ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1); + } + for (int i =0; i < post_p_arr.size(); i++) { + ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2); + } + + Interval pre_wid= align_items(pre_p_arr); + translate_items( -pre_wid.right, pre_p_arr); + align_items(nobreak_p_arr); + Interval post_wid =align_items(post_p_arr); + translate_items (-post_wid.left , post_p_arr); + + pre_p_arr.set_size(0); + post_p_arr.set_size(0); + nobreak_p_arr.set_size(0); +} diff --git a/src/complexprint.cc b/src/complexprint.cc deleted file mode 100644 index 6abe7659d2..0000000000 --- a/src/complexprint.cc +++ /dev/null @@ -1,105 +0,0 @@ -#include "keyitem.hh" - -#include "request.hh" -#include "pscore.hh" -#include "paperdef.hh" -#include "complexstaff.hh" -#include "sccol.hh" -#include "debug.hh" - -#include "clefitem.hh" -#include "bar.hh" -#include "meter.hh" -const NO_LINES = 5; - -Item * -Complex_staff::get_TYPESET_item(Command *com) -{ - Item *s=0; - Array arg( com->args); - String type =arg[0]; - arg.del(0); - if (com->args[0] == "KEY") { - return new Keyitem(NO_LINES); // urgh. depends on clef. - } else 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 -Complex_column::typeset_item(Item *i, int breakst) -{ - assert(i); - - staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, - staff_l_->pstaff_l_,breakst); - - if (breakst == BREAK_PRE - BREAK_PRE) { - - Array to_move( - staff_l_->pscore_l_->select_items(staff_l_->pstaff_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)); - } - } -} -/* - UGGGG - */ -void -Complex_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_->pstaff_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 -Complex_staff::set_output(PScore* pscore_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 d5d44362d9..3ecf9fdb89 100644 --- a/src/complexstaff.cc +++ b/src/complexstaff.cc @@ -1,78 +1,56 @@ -#include "request.hh" -#include "voice.hh" -#include "staffwalker.hh" #include "debug.hh" -#include "clef.hh" -#include "staff.hh" -#include "command.hh" #include "complexstaff.hh" -#include "sccol.hh" #include "complexwalker.hh" +#include "complexcolumn.hh" #include "score.hh" #include "pscore.hh" #include "staffsym.hh" +#include "pscore.hh" +#include "bar.hh" +#include "meter.hh" +#include "sccol.hh" +#include "commandrequest.hh" +const NO_LINES = 5; -Complex_column::Complex_column(Score_column*s, Complex_staff *staff_l) - : Staff_column(s) -{ - staff_l_ = staff_l; -} - -Complex_staff::Complex_staff() -{ - pstaff_l_ = 0; -} - +/** Aside from putting fields right, this generates the staff symbol. + */ void -Complex_column::setup_requests() +Complex_staff::set_output(PScore* pscore_l ) { - for (int i = 0 ; i < v_elts.size(); i ++) - for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { + pstaff_l_ = new PStaff(pscore_l); + pscore_l_ = pscore_l; + pscore_l_->add(pstaff_l_); - if (j->barcheck()) { - if (tdescription_->whole_in_measure) { - warning( "Barcheck failed", j->defined_ch_c_l_m ); -// staff_l_->the_line_->pscore_l_->heu errorlevel_i_ |= 1; - } - continue; - } - if (j->mark()) - continue; - if (j->command()) - continue; - if (j->groupchange()) // ugh - first_l_arr_.push(j); - else - second_l_arr_.push(j); - } -} -Staff_column* -Complex_staff::create_col(Score_column*s) -{ - return new Complex_column(s,this); -} - -void -Complex_staff::walk() -{ - for (Complex_walker sc(this); sc.ok(); sc++) { - 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_, + span_p->set_extent(col_first->pcol_l_->postbreak_p_, col_last->pcol_l_->prebreak_p_); pscore_l_->typeset_spanner(span_p, pstaff_l_); } + +Complex_staff::Complex_staff() +{ + pstaff_l_ = 0; +} + +Staff_column* +Complex_staff::create_col() +{ + return new Complex_column(this); +} + +Staff_walker * +Complex_staff::get_walker_p() +{ + return new Complex_walker(this); +} diff --git a/src/complexwalker.cc b/src/complexwalker.cc index ba8253205b..c6478fbb23 100644 --- a/src/complexwalker.cc +++ b/src/complexwalker.cc @@ -1,115 +1,28 @@ +/* + complexwalker.cc -- implement Complex_walker + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "associter.hh" #include "script.hh" -#include "request.hh" +#include "musicalrequest.hh" #include "voice.hh" -#include "clef.hh" #include "pscore.hh" #include "complexstaff.hh" #include "debug.hh" -#include "keyitem.hh" -#include "clefitem.hh" #include "voicegroup.hh" -#include "localkeyreg.hh" #include "complexwalker.hh" #include "misc.hh" +#include "commandrequest.hh" +#include "clefreg.hh" +#include "localkeyreg.hh" +#include "keyreg.hh" +#include "meterreg.hh" +#include "barreg.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_l) -{ - Array args(com_l->args); - args.del(0); - String com = com_l->args[0]; - - if (com == "GROUPING") { - default_grouping = parse_grouping(args); - }else if (com == "NEWMEASURE") { - local_key_.reset(key_); - - } else if (com == "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 == "CLEF") { - clef_.set_type(args[0]); - } else { - WARN << " ignoring INTERPRET command: " << com<< "\n"; - } -} - -void -Complex_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 Complex_walker::announce_element(Staff_elem_info info) @@ -121,15 +34,24 @@ Complex_walker::announce_element(Staff_elem_info info) void Complex_walker::do_announces() { + Request dummy_req; for (int i = 0; i < announce_info_arr_.size(); i++){ Staff_elem_info info = announce_info_arr_[i]; + if (!info.req_l_) + info.req_l_ = &dummy_req; + for (iter_top(voice_reg_list_,j); j.ok(); j++) { j->acknowledge_element(info); } for (iter_top ( group_reg_list_, j); j.ok(); j++) { j->acknowledge_element(info); } - local_key_reg_.acknowledge_element(info); + bar_reg_p_->acknowledge_element(info); + clef_reg_p_->acknowledge_element(info); + key_reg_p_->acknowledge_element(info); + meter_reg_p_->acknowledge_element(info); + + local_key_reg_p_->acknowledge_element(info); } } @@ -204,15 +126,37 @@ Complex_walker::do_change_group(Voice * v, String group_id_str) voice_group_map_[v] = get_voice_group(group_id_str); } +bool +Complex_walker::try_command_request(Nonmusical_req *req_l) +{ + bool b=false; + Voice *voice_l = (Voice*)req_l->elt_l_->voice_l_; // ugh + if (req_l->groupchange()){ + do_change_group(voice_l, req_l->groupchange()->newgroup_str_); + b|= true; + } else if(req_l->groupfeature()) { + Voice_group_registers* reg_l = get_voice_group(voice_l); + b |= reg_l->try_request(req_l); + } else { + if (!b) + b |= bar_reg_p_->try_request(req_l); + b |= clef_reg_p_->try_request(req_l); + if (!b) + b |= key_reg_p_->try_request(req_l); + if (!b) + b |= meter_reg_p_->try_request(req_l); + } + return b; +} + void Complex_walker::try_request(Request*req) { bool b=false; - Voice *voice_l = req->elt_l_->voice_l_; + Voice *voice_l = (Voice*)req->elt_l_->voice_l_; // ahh. This sux - if (req->groupchange()) { - do_change_group(voice_l, req->groupchange()->newgroup_str_); - b = true; + if (req->nonmus()) { + b = try_command_request(req->nonmus()); } else if (Voice_registers::acceptable_request(req)) { Voice_registers *vregs_l = get_voice_reg(voice_l); b = vregs_l->try_request(req); @@ -222,7 +166,8 @@ Complex_walker::try_request(Request*req) } if (!b) - warning("junking request: " + String(req->name()), req->defined_ch_c_l_m); + warning("junking request: " + String(req->name()), + req->defined_ch_c_l_); } void @@ -251,7 +196,12 @@ Complex_walker::regs_process_requests() for (iter_top(group_reg_list_, j); j.ok(); j++) j->process_requests(); - local_key_reg_.process_request(); + + bar_reg_p_->process_request(); + clef_reg_p_->process_request(); + key_reg_p_->process_request(); + meter_reg_p_->process_request(); + local_key_reg_p_->process_request(); } void @@ -262,17 +212,43 @@ Complex_walker::typeset_element(Staff_elem *elem_p) if (elem_p->spanner()) pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_); else - col()->typeset_item(elem_p->item()); + col()->typeset_musical_item(elem_p->item()); } Complex_walker::Complex_walker(Complex_staff*s) - : Staff_walker(s, s->pstaff_l_->pscore_l_), - local_key_reg_(this) + : Staff_walker(s, s->pstaff_l_->pscore_l_) { - oldkey_undo = 0; + local_key_reg_p_= new Local_key_register(this); + clef_reg_p_= new Clef_register(this); + key_reg_p_ = new Key_register(this); + bar_reg_p_ = new Bar_register(this); + meter_reg_p_ = new Meter_register(this); + do_post_move(); } + +Complex_walker::~Complex_walker() +{ + delete local_key_reg_p_; + delete clef_reg_p_; + delete meter_reg_p_; + delete bar_reg_p_; + delete key_reg_p_; +} + +int +Complex_walker::c0_position_i()const +{ + return c0_position_i_; +} + +void +Complex_walker::set_c0_position(int p) +{ + c0_position_i_ =p; +} + Complex_staff* Complex_walker::staff() { @@ -293,31 +269,54 @@ Complex_walker::do_pre_move() } for (iter_top (group_reg_list_, j); j.ok(); j++) j->pre_move_processing(); - local_key_reg_.pre_move_processing(); + local_key_reg_p_->pre_move_processing(); + bar_reg_p_->pre_move_processing(); + clef_reg_p_->pre_move_processing(); + key_reg_p_->pre_move_processing(); + meter_reg_p_->pre_move_processing(); + + col()->typeset_breakable_items(prebreak_item_p_arr_, + nobreak_item_p_arr_, + postbreak_item_p_arr_); } void Complex_walker::do_post_move() { - processed_clef = false; - processed_key = false; - processed_bar_priority = 0; - for (iter_top(voice_reg_list_,i); i.ok(); i++) { i->post_move_processing(); } announce_info_arr_.set_size(0); for (iter_top (group_reg_list_, j); j.ok(); j++) j->post_move_processing(); - local_key_reg_.post_move_processing(); + + local_key_reg_p_->post_move_processing(); + bar_reg_p_->post_move_processing(); + clef_reg_p_->post_move_processing(); + key_reg_p_->post_move_processing(); + meter_reg_p_->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++) { + for (Assoc_iter i(voice_group_map_); + i.ok(); i++) { if (i.val() == group_regs_l) l_arr.push(find_voice_reg(i.key())); } } + +void +Complex_walker::typeset_breakable_item(Item * pre_p , Item * nobreak_p, + Item * post_p) +{ + if (pre_p) + prebreak_item_p_arr_.push(pre_p); + if (nobreak_p) + nobreak_item_p_arr_.push(nobreak_p); + if (post_p) + postbreak_item_p_arr_.push(post_p); +} diff --git a/src/getcommands.cc b/src/getcommands.cc deleted file mode 100644 index 61a3f59f62..0000000000 --- a/src/getcommands.cc +++ /dev/null @@ -1,65 +0,0 @@ -#include "string.hh" -#include "inputcommand.hh" -#include "parseconstruct.hh" -#include "command.hh" - -Command* -get_key_typeset_command(Arraywhich) -{ - Command*c = new Command; - c->code = TYPESET; - c->args = which; - String k("KEY"); - c->args.insert(k,0 ); - c->priority = 70; - return c; -} - -Command * -get_meter_command(int n, int m) -{ - Command*c = new Command; - - c->code = TYPESET; - c->args.push( "METER"); - c->args.push( n ); - c->args.push( m ); - c->priority = 40; - return c; -} - -Command -get_defaultbar_command() -{ - Command c; - c.code = TYPESET; - c.args.push("BAR"); - c.args.push("default"); - return c; -} - -void -split_bar_command(Command &pre_com, Command &no_break_com, Command &post_com, - String s) -{ - Command c; - c.code = TYPESET; - c.priority = (s=="default") ? 100: 110; - c.args.push("BAR"); - if(s=="default") - s = "|"; - - if (s == ":|:") { - no_break_com=post_com=pre_com = c; - - pre_com.args.push( ":|"); - no_break_com.args.push( s); - post_com.args.push( "|:"); - }else if (s=="|:") { - c.args.push(s); - no_break_com=post_com=c; - } else { - c.args.push(s); - pre_com= no_break_com= c; - } -} diff --git a/src/grouping.cc b/src/grouping.cc index 8c7e0e5d5b..6c2e6760c8 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -1,3 +1,11 @@ +/* + grouping.cc -- implement Rhythmic_grouping + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "debug.hh" #include "grouping.hh" #include "interval.hh" @@ -74,6 +82,7 @@ Rhythmic_grouping::intervals() } return r; } + void Rhythmic_grouping::intersect(MInterval t) { @@ -100,7 +109,11 @@ Rhythmic_grouping::intersect(MInterval t) } -/* I really should be documenting what is happening here, but I find +/** + Put our children in branches of #this#. + The min and max time intervals coincide with elements of #splitpoints# + + I really should be documenting what is happening here, but I find that difficult, since I don't really understand what's going on here. */ @@ -248,7 +261,6 @@ min_elt(Array v) Array Rhythmic_grouping::generate_beams(Array flags, int &flagidx) { - assert (!interval_) ; Array< Array > children_beams; @@ -318,3 +330,21 @@ Rhythmic_grouping::extend(MInterval m) assert(m.right <= interval().right); OK(); } + +Rhythmic_grouping +parse_grouping(Array beat_i_arr, Array elt_length_arr) +{ + Moment here =0; + assert(beat_i_arr.size() == elt_length_arr.size()); + + Array children; + for (int i=0; i < beat_i_arr.size(); i++) { + Moment last = here; + here += elt_length_arr[i] * Moment(beat_i_arr[i]); + children.push( + new Rhythmic_grouping(MInterval(last, here), + beat_i_arr[i] )); + } + return Rhythmic_grouping(children); +} + diff --git a/src/headreg.cc b/src/headreg.cc index 94ad2291e1..c41037c513 100644 --- a/src/headreg.cc +++ b/src/headreg.cc @@ -8,7 +8,7 @@ #include "headreg.hh" #include "paperdef.hh" #include "complexwalker.hh" - +#include "musicalrequest.hh" Notehead_register::Notehead_register(Complex_walker*w_l) :Request_register(w_l) @@ -45,7 +45,7 @@ Notehead_register::process_request() note_p_ = n_p; n_p->set_rhythmic(req_l->rhythmic()); n_p->position = req_l->note()->height() + - walk_l_->clef_.c0_position_i_; + walk_l_->c0_position_i(); } else { note_p_ = new Rest ( req_l->rhythmic()->balltype, req_l->rhythmic()->dots); diff --git a/src/inputcommand.cc b/src/inputcommand.cc deleted file mode 100644 index aab0ea4a8b..0000000000 --- a/src/inputcommand.cc +++ /dev/null @@ -1,181 +0,0 @@ -#include "inputcommand.hh" -#include "debug.hh" -#include "command.hh" - -Input_command::Input_command() -{ -} - - -Input_command::operator Command() -{ - Command c; - if (!args.size()) - return c; - - c.code = INTERPRET; - String s = args[0]; - - int p=0; - if (s == "KEY") - p = 200; - else if (s=="CLEF") - p = 190; - else if (s == "METER") - p = 180; - else if (s == "BAR") - p = 170; - else if (s == "GROUPING") - p = 160; - - c.priority = p; - c.args = args; - - return c; -} - - -Input_command* -get_partial_command(Moment u) -{ - Input_command*c = new Input_command; - c->args.push("PARTIAL"); - c->args.push(u); - return c; -} - -Input_command* -get_goto_command(String s) -{ - Input_command*c = new Input_command; - c->args.push("GOTO"); - c->args.push(s); - return c; -} - -Input_command* -get_cadenza_toggle(int i) -{ - - Input_command*c = new Input_command; - c->args.push("CADENZA"); - c->args.push(i); - return c; -} -Input_command* -get_grouping_command(Arraya ) -{ - Input_command*c = new Input_command; - c->args.push("GROUPING"); - for (int i=0; i < a.size(); i ++) - c->args.push(a[i]); - - return c; -} - -Input_command* -get_key_interpret_command(Arraya ) -{ - Input_command*c = new Input_command; - c->args.push("KEY"); - for (int i=0; i < a.size(); i ++) { - c->args.push(a[i]); - } - return c; -} - -Input_command* -get_reset_command() -{ - Input_command*c = new Input_command; - c->args.push("RESET"); - return c; -} - -Input_command * -get_meterchange_command(int n, int m) -{ - Input_command*c = new Input_command; - - c->args.push( "METER"); - c->args.push( n ); - c->args.push( m ); - - return c; -} - -Input_command * -get_newmeasure_command() -{ - Input_command*c = new Input_command; - c->args.push( "NEWMEASURE"); - return c; -} - -Input_command * -get_skip_command(int n, Moment m) -{ - Input_command*c = new Input_command; - - c->args.push( "SKIP"); - c->args.push( n ); - c->args.push( m ); - - return c; -} - - -void -Input_command::print()const -{ -#ifndef NPRINT - mtor << "{ "; - if (args.size()) { - mtor<< " args: "; - for (int i = 0; iargs.push("CLEF"); - c->args.push(w); - return c; -} - -Input_command* -get_bar_command(String w) -{ - Input_command*c = new Input_command; - c->args.push("BAR"); - c->args.push(w); - return c; -} - -Array -get_default_grouping(int count, int one_beat_note) -{ - Array s; - if (!(count % 3 )) { - for (int i=0; i < count/3; i++) { - s.push(3); - s.push(one_beat_note); - } - } else if (!(count %2)) { - for (int i=0; i < count/2; i++) { - s.push(2); - s.push(one_beat_note); - } - - }else { - s.push(2); - s.push(one_beat_note); - s.concat(get_default_grouping(count-2, one_beat_note)); - } - return s; -} diff --git a/src/inputcommands.cc b/src/inputcommands.cc deleted file mode 100644 index 36e421c7b6..0000000000 --- a/src/inputcommands.cc +++ /dev/null @@ -1,238 +0,0 @@ -#include "inputcommands.hh" -#include "inputcommand.hh" -#include "debug.hh" -#include "staffcommands.hh" -#include "getcommand.hh" -#include "command.hh" -#include "stcol.hh" -#include "staff.hh" -#include "assoc.hh" -#include "lexer.hh" - -void -Commands_at::print() const -{ -#ifndef NPRINT - mtor << "Commands_at {"; - tdescription_.print(); - for (iter_top(*this,cc); cc.ok(); cc++) - cc->print(); - mtor << "}\n"; -#endif -} - -Moment -Commands_at::when() -{ - return tdescription_.when; -} - -Commands_at::Commands_at(Moment dt, Commands_at* prev) - : tdescription_(dt, (prev)? &prev->tdescription_ : 0) -{ - if (prev && !tdescription_.whole_in_measure) { - bottom().add(get_newmeasure_command()); - } -} - -void -Commands_at::add(Input_command *i) -{ - bottom().add(i); - - // should check for other meterchanges here. - if (i->args[0] == "METER") { - int l = i->args[1]; - int o = i->args[2]; - tdescription_.set_meter(l,o); - bottom().add(get_grouping_command( get_default_grouping(l,o))); - } -} - -Commands_at::Commands_at(Commands_at const&src) : - tdescription_(src.tdescription_) -{ - IPointerList &me(*this); - const IPointerList &that(src); - - PL_copy(me, that); -} - -void -Commands_at::setpartial(Moment p) -{ - tdescription_.setpartial(p); -} - -Moment -Commands_at::barleft() -{ - return tdescription_.barleft(); -} - -void -Commands_at::parse(Staff_commands_at*s) -{ - s->tdescription_ = tdescription_; - for (iter_top(*this,cc); cc.ok(); cc++) { - if (cc->args.size() && cc->args[0] !="") { - Command c = **cc; - s->add(c); - - } - } -} -/* *************** */ - -void -Input_cursor::find_moment(Moment w) -{ - Moment last = when(); - while (1) { - if (! ok() ) { - *this = list().bottom(); - - Moment dt = (w - when()); - if ( !ptr()->tdescription_.cadenza_b_ ) - dt = dt barleft(); - - Commands_at * c = new Commands_at(dt, *this); - assert(c->when() <= w); - add(c); - } else if (when() == w ) { - return ; - } else if (when() > w ) - break; - - - last = when(); - next(); - } - - prev(); - Moment dt = (w - when()); - Commands_at * c = new Commands_at(dt, *this); - add(c); - next(); -} - - - -/* *************** */ -void -Input_commands::find_moment(Moment m) -{ - ptr.find_moment(m); -} - -Input_commands::Input_commands(Input_commands const&src) - : ptr(src.ptr) -{ - IPointerList &me(*this); - const IPointerList &that(src); - - PL_copy(me, that); -} - -Input_commands::Input_commands() - : ptr (bottom()) -{ - Commands_at * p = new Commands_at(0,0); - bottom().add(p); - ptr = bottom(); -} - -void -Input_commands::do_skip(int bars, Moment wholes) -{ - while (bars > 0) { - Moment b = ptr->barleft(); - ptr.find_moment(ptr->when() + b); - bars --; - } - if (wholes) { - ptr.find_moment(ptr->when() + wholes); - } -} - - -void -Input_commands::add(Input_command c, Assoc &marks_assoc_r) -{ - String s(c.args[0]); - if (s == "CADENZA") { - ptr->tdescription_.set_cadenza((int)c.args[1]); - } if (s == "PARTIAL") { - ptr->setpartial(c.args[1]); - } else if (s == "GROUPING") { - Input_command *ic = new Input_command(c); - ic->args.insert(ptr->tdescription_.one_beat, 1); - ptr->add(ic); - } else if (s == "METER") { - int beats_per_meas = c.args[1]; - int one_beat = c.args[2]; - Input_command *ch = get_meterchange_command(beats_per_meas, one_beat); - ptr->add(ch); - } else if (s == "SKIP") { - int bars = c.args[1] ; - Moment wholes= c.args[2]; - do_skip(bars, wholes); - } else if (s == "RESET") { - ptr= top(); - } else if (s=="GOTO") { - ptr = top(); - String m(c.args[1]); - if (!marks_assoc_r.elt_query(m)) { - warning( "Unknown marker: `" +m + "\'", 0 ); - return; - } - - ptr.find_moment(marks_assoc_r[m]); - } else { - Input_command *ic = new Input_command(c); - ptr->add(ic); - } - -} - -void -Input_commands::parse(Staff * staff_l) const -{ - print(); - for (iter_top(*this,i); i.ok(); i++) { - - Staff_column* col_l = staff_l->get_col(i->when(), false); - if (!col_l->staff_commands_p_) - col_l->staff_commands_p_ = new Staff_commands_at(i->tdescription_); - - Staff_commands_at * com_l = col_l->staff_commands_p_; - - if (!i->when()) { /* all pieces should start with a breakable. */ - com_l->set_breakable(); - } - - i->parse(com_l); - } -} - - -void -Input_commands::print() const -{ -#ifndef NPRINT - for (iter_top(*this,cc); cc.ok() ; cc++) { - cc->print(); - } -#endif -} -/* *************** */ - -Moment -Input_cursor::when()const -{ - return (*this)->when(); -} -Input_cursor::Input_cursor(PCursorc) - : PCursor(c) -{ -} diff --git a/src/inputmusic.cc b/src/inputmusic.cc index 447d84e41a..05918a1a5f 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -1,7 +1,7 @@ #include "debug.hh" #include "inputmusic.hh" #include "voice.hh" -#include "request.hh" +#include "musicalrequest.hh" void Simple_music::add(Voice_element*v) diff --git a/src/inputscore.cc b/src/inputscore.cc index 764c8e8509..a8a653982c 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -1,18 +1,19 @@ +/* + inputscore.cc -- implement Input_score + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "debug.hh" -#include "inputcommand.hh" #include "inputscore.hh" #include "inputstaff.hh" +#include "inputmusic.hh" #include "score.hh" #include "paperdef.hh" #include "staff.hh" -void -Input_score::add(Array &s) -{ - commands_.bottom().add(get_reset_command()); - for (int i=0; i < s.size(); i++) - commands_.bottom().add(s[i]); -} void Input_score::add(Input_staff*s) @@ -23,51 +24,61 @@ Input_score::add(Input_staff*s) void Input_score::set(Paperdef*p) { - delete paper_; - paper_ = p; + delete paper_p_; + paper_p_ = p; } -Input_score::Input_score(Input_score const&) +Input_score::Input_score(Input_score const&s) { - assert(false); + paper_p_ = (s.paper_p_)? new Paperdef(*s.paper_p_) :0; + defined_ch_c_l_ = s.defined_ch_c_l_; + errorlevel_i_ = s.errorlevel_i_; + score_wide_music_p_ = (s.score_wide_music_p_) ? + s.score_wide_music_p_->clone():0; } Score* Input_score::parse() { - Paperdef* paper_p=new Paperdef(*paper_); + Paperdef* paper_p=new Paperdef(*paper_p_); Score *s_p = new Score(paper_p); s_p->defined_ch_c_l_= defined_ch_c_l_; s_p->errorlevel_i_ = errorlevel_i_; - Array parsed_staffs; + for (iter_top(staffs_,i); i.ok(); i++) { - Staff* staf_p=i->parse(s_p); - parsed_staffs.push(staf_p); + Staff* staf_p=i->parse(s_p, score_wide_music_p_); s_p->add(staf_p); } - int j = 0; - for (iter_top(staffs_,i); i.ok(); i++,j++) { - parsed_staffs[j]->do_commands(commands_, i->commands_); - } + return s_p; } +void +Input_score::set(Input_music *m_p) +{ + delete score_wide_music_p_; + score_wide_music_p_ =m_p; +} + + Input_score::~Input_score() { - delete paper_; + delete paper_p_; + delete score_wide_music_p_; } Input_score::Input_score() { + score_wide_music_p_ =0; defined_ch_c_l_=0; - paper_= 0; + paper_p_= 0; errorlevel_i_ = 0; } void Input_score::print()const { - #ifndef NPRINT +#ifndef NPRINT mtor << "Input_score {\n"; for (iter_top(staffs_,i); i.ok(); i++) { i->print(); diff --git a/src/inputstaff.cc b/src/inputstaff.cc index d79aac1021..116624574c 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -1,26 +1,16 @@ -#include "getcommand.hh" #include "debug.hh" #include "score.hh" #include "inputmusic.hh" #include "inputstaff.hh" -#include "inputcommand.hh" -#include "staffcommands.hh" #include "staff.hh" #include "complexstaff.hh" #include "lexer.hh" #include "lyricstaff.hh" -void -Input_staff::add(Array &s) -{ - commands_.bottom().add(get_reset_command()); - for (int i=0; i < s.size(); i++) - commands_.bottom().add(s[i]); - s.set_size(0); -} Input_staff::Input_staff(String s) { + score_wide_music_p_ =0; type= s; defined_ch_c_l_ = 0; } @@ -32,51 +22,36 @@ Input_staff::add(Input_music*m) } Staff* -Input_staff::parse(Score*score_l) +Input_staff::parse(Score*score_l, Input_music *default_score_wide) { Staff *p=0; -#if 0 - if (type == "simple") - p = new Melodic_staff; - else if (type == "rhythmic") - p = new Rhythmic_staff; - else -#endif - - if (type == "melodic") + if (type == "melodic") p = new Complex_staff; else if (type == "lyric") p = new Lyric_staff; else - error( "Unknown staff-type `" + type +"\'", 0 ); + error( "Unknown staff-type `" + type +"\'", defined_ch_c_l_); p->score_l_ = score_l; - p->define_spot_str_ = ""; // todo for (iter_top(music_,i); i.ok(); i++) { Voice_list vl = i->convert(); p->add(vl); } - - { - Array mark_arr; - Array moment_arr; - p->get_marks(mark_arr, moment_arr); - score_l->add_marks(mark_arr, moment_arr); - } - + Voice_list vl = (score_wide_music_p_) ? score_wide_music_p_->convert() + : default_score_wide->convert(); + p->add(vl); return p; } Input_staff::Input_staff(Input_staff const&s) -{ - - for (iter_top(s.commands_,i); i.ok(); i++) - commands_.bottom().add(new Input_command(**i)); +{ for (iter_top(s.music_,i); i.ok(); i++) add(i->clone()); defined_ch_c_l_ = s.defined_ch_c_l_; type = s.type; + score_wide_music_p_ = (s.score_wide_music_p_) ? + s.score_wide_music_p_->clone() : 0; } void @@ -84,10 +59,19 @@ Input_staff::print() const { #ifndef NPRINT mtor << "Input_staff {\n"; - for (iter_top(commands_,i); i.ok(); i++) - i->print(); for (iter_top(music_,i); i.ok(); i++) i->print(); mtor << "}\n"; #endif } +void +Input_staff::set_score_wide(Input_music *m_p) +{ + delete score_wide_music_p_; + score_wide_music_p_ = m_p; +} + +Input_staff::~Input_staff() +{ + delete score_wide_music_p_; +} diff --git a/src/key.cc b/src/key.cc index 232ce9a94f..7e23464ccf 100644 --- a/src/key.cc +++ b/src/key.cc @@ -1,13 +1,13 @@ #include "key.hh" -const int OCTAVES=14; +const int OCTAVES=14; // ugh.. const int ZEROOCTAVE=7; Key::Key() { - accidentals.set_size(7); + accidental_i_arr_.set_size(7); for (int i= 0; i < 7 ; i++) - accidentals[i] = 0; + accidental_i_arr_[i] = 0; } Local_key::Local_key() @@ -25,7 +25,7 @@ void Key::set(int i, int a) { assert(a > -3 && a < 3); - accidentals[i]=a; + accidental_i_arr_[i]=a; } @@ -36,44 +36,3 @@ Local_key::reset(Key k) octaves[i] = k; } -Array -Key::read(Array s) -{ - Array newkey; - for (int j = 0; j < 7; j++) - accidentals[j] = 0; - - for (int i=0; i < s.size(); ) { - int large = s[i++]; - int small = s[i++]; - accidentals[large]=small; - - newkey.push(large); - newkey.push(small); - } - return newkey; -} - -Array -Key::oldkey_undo(Arrays) -{ - Array oldkey; - Array newkey; - newkey.set_size(7); - for (int i=0; i < newkey.size(); i++) - newkey[i] = 0; - - for (int i=0; i < s.size(); ) { - int large = s[i++]; - int small = s[i++]; - newkey[large] = small; - } - for (int i=0; i < newkey.size(); i++) - if (accidentals[i] && accidentals[i] != newkey[i]) { - oldkey.push(i); - oldkey.push(0); - } - - - return oldkey; -} diff --git a/src/keyitem.cc b/src/keyitem.cc index 22cf0e6d01..6b465572dd 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -4,43 +4,45 @@ #include "molecule.hh" #include "paperdef.hh" #include "lookup.hh" -#include "clef.hh" +//#include "clefreg.hh" +#include "keyreg.hh" 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); +NAME_METHOD(Key_item); -Keyitem::Keyitem(int c) +Key_item::Key_item(int c) { - c_position = c; + set_c_position(c); } void -Keyitem::read(Array s) +Key_item::read(const Key_register& key_reg_r) { - for (int i = 0 ; i< s.size(); ) { - int note = s[i++]; - int acc = s[i++]; - + const Array &idx_arr =key_reg_r.accidental_idx_arr_; + for (int i = 0 ; i< idx_arr.size(); i++) { + int note = idx_arr[i]; + int acc = key_reg_r.key_.acc(note); + add(note, acc); } } void -Keyitem::read(const Clef& c) +Key_item::set_c_position(int c0) { - int octaves =(abs(c.c0_position_i_) / 7) +1 ; - c_position=(c.c0_position_i_ + 7*octaves)%7; + int octaves =(abs(c0) / 7) +1 ; + c_position=(c0 + 7*octaves)%7; } void -Keyitem::add(int p, int a) +Key_item::add(int p, int a) { if ((a<0 && p>FLAT_TOP_PITCH) || (a>0 && p>SHARP_TOP_PITCH)) { - p=p-7; /* Typeset below c_position */ + p -= 7; /* Typeset below c_position */ } pitch.push(p); acc.push(a); @@ -48,7 +50,7 @@ Keyitem::add(int p, int a) Molecule* -Keyitem::brew_molecule_p()const +Key_item::brew_molecule_p()const { Molecule*output = new Molecule; Real inter = paper()->internote(); diff --git a/src/keyreg.cc b/src/keyreg.cc new file mode 100644 index 0000000000..963ebaf649 --- /dev/null +++ b/src/keyreg.cc @@ -0,0 +1,90 @@ +/* + keyreg.cc -- implement Key_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys + + todo: key undo + + */ + +#include "keyreg.hh" +#include "keyitem.hh" +#include "complexwalker.hh" +#include "commandrequest.hh" +#include "stcol.hh" +#include "localkeyreg.hh" +#include "musicalrequest.hh" + +Key_register::Key_register(Complex_walker*w) + : Request_register(w) +{ + do_post_move_process(); +} + + +bool +Key_register::try_request(Request * req_l) +{ + if (!req_l->nonmus()->keychange()) + return false; + assert(!keyreq_l_); // todo + keyreq_l_ = req_l->nonmus()->keychange(); + read_req(keyreq_l_); + walk_l_->local_key_reg_p_->local_key_.reset(key_); // ugh + return true; +} + +void +Key_register::process_request() +{ + Time_description *time_l = &walk_l_->time_; + + if (!keyreq_l_ && + (!time_l->whole_in_measure_|| !time_l->when_)) { + default_key_b_ = true; + } + + if (default_key_b_ || keyreq_l_) { + kit_p_ = new Key_item(walk_l_->c0_position_i()); + kit_p_->read(*this); + announce_element(Staff_elem_info(kit_p_, keyreq_l_, this)); + } +} + +void +Key_register::do_pre_move_process() +{ + if (kit_p_) { + if (default_key_b_) + typeset_breakable_item(0,0,kit_p_); + else + typeset_breakable_item( + new Key_item(*kit_p_), kit_p_, new Key_item(*kit_p_)); + kit_p_ = 0; + } +} + + + +void +Key_register::read_req(Key_change_req * r) +{ + accidental_idx_arr_.set_size(0); + for (int i = 0; i < r->melodic_p_arr_.size(); i ++) { + int n_i=r->melodic_p_arr_[i]->notename_i_; + key_.set(n_i, r->melodic_p_arr_[i]->accidental_i_); + accidental_idx_arr_.push(n_i); + } +} + +void +Key_register::do_post_move_process() +{ + keyreq_l_ = 0; + default_key_b_ = false; + kit_p_ = 0; + if (!walk_l_->time_.whole_in_measure_) + walk_l_->local_key_reg_p_->local_key_.reset(key_); // ugh +} diff --git a/src/lexerinit.cc b/src/lexerinit.cc index 5840b3c62e..43a1c2c5a6 100644 --- a/src/lexerinit.cc +++ b/src/lexerinit.cc @@ -28,7 +28,7 @@ Input_file::Input_file(String s) String pf(s); if (pf=="") { is = &cin; - defined_ch_c_l_m = 0; + defined_ch_c_l_ = 0; sourcefile_l_ = 0; } else { @@ -36,7 +36,7 @@ Input_file::Input_file(String s) source_global_l->add( sourcefile_p ); sourcefile_l_ = sourcefile_p; is = sourcefile_l_->istream_l(); - defined_ch_c_l_m = sourcefile_l_->ch_c_l(); + defined_ch_c_l_ = sourcefile_l_->ch_c_l(); } cout << "["<octave, m_l->notename, m_l->accidental); + add(m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); } void Local_key_item::add (int o, int p , int a) @@ -71,10 +75,7 @@ Local_key_item::brew_molecule_p()const delete octmol; } - Interval head_width; - for (int i = 0; i < group.size(); i++) { - head_width.unite(group[i]->width()); - } + Interval head_width=itemlist_width(support_items_); output->translate(Offset(-output->extent().x.right + head_width.left ,0)); return output; diff --git a/src/localkeyreg.cc b/src/localkeyreg.cc index bbd4993022..5669109786 100644 --- a/src/localkeyreg.cc +++ b/src/localkeyreg.cc @@ -3,7 +3,7 @@ (c) 1997 Han-Wen Nienhuys */ - +#include "musicalrequest.hh" #include "localkeyreg.hh" #include "localkeyitem.hh" #include "complexwalker.hh" @@ -13,17 +13,7 @@ Local_key_register::Local_key_register(Complex_walker*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() { @@ -38,21 +28,20 @@ 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) { + if( melodic_l_->forceacc_b_ || + local_key_.oct(melodic_l_->octave_i_).acc(melodic_l_->notename_i_) + != melodic_l_->accidental_i_) { 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_ = new Local_key_item(walk_l_->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); + local_key_.oct(melodic_l_->octave_i_) + .set(melodic_l_->notename_i_, melodic_l_->accidental_i_); } } } diff --git a/src/lookup.cc b/src/lookup.cc index 96932e0023..a87454e2d1 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -140,7 +140,7 @@ Lookup::streepjes(int i) Symbol Lookup::hairpin(Real &wid, bool decresc) { - int idx = rint(wid / 6 PT); + int idx = int(rint(wid / 6 PT)); if(!idx) idx ++; wid = idx*6 PT; String idxstr = (decresc)? "decrescendosym" : "crescendosym"; diff --git a/src/lyriccolumn.cc b/src/lyriccolumn.cc index c54ebc2b39..9d5cbe3297 100644 --- a/src/lyriccolumn.cc +++ b/src/lyriccolumn.cc @@ -1,4 +1,4 @@ -#include "request.hh" +#include "musicalrequest.hh" #include "voice.hh" #include "staffwalker.hh" #include "debug.hh" @@ -9,43 +9,21 @@ #include "pscore.hh" #include "main.hh" -Lyric_column::Lyric_column(Score_column* s, Lyric_staff* lstaff_l) - : Staff_column(s) +Lyric_column::Lyric_column(Lyric_staff* lstaff_l) { lstaff_l_ = lstaff_l; } void -Lyric_column::setup_requests() +Lyric_column::setup_one_request(Request*req_l) { - for (int i = 0 ; i < v_elts.size(); i ++) { - for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { - Request* req_l = j; - if (req_l->barcheck()) { - if (tdescription_->whole_in_measure) { - warning( "Barcheck failed ", req_l->defined_ch_c_l_m ); - } - } - if (req_l->lreq_l()) { - winfo_array_.push(req_l->lreq_l()); - } - } - } + if (req_l->lreq_l()) + lreq_l_array_.push(req_l->lreq_l()); } void Lyric_column::typeset_item(Item *i) { - lstaff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_, + lstaff_l_->pscore_l_->typeset_item(i, musical_column_l_->pcol_l_, lstaff_l_->pstaff_l_); -} - -Word_info::Word_info() -{ - lreq_l_ = 0; -} - -Word_info::Word_info(Lyric_req* lreq_l) -{ - lreq_l_ = lreq_l; } diff --git a/src/lyricitem.cc b/src/lyricitem.cc index 5b290d3634..f8ec193be0 100644 --- a/src/lyricitem.cc +++ b/src/lyricitem.cc @@ -1,4 +1,4 @@ -#include "request.hh" +#include "musicalrequest.hh" #include "paperdef.hh" #include "lyricitem.hh" #include "stem.hh" @@ -24,5 +24,5 @@ Lyric_item::do_pre_processing() // test context-error if ( tdef_l_->text_str_.pos( "Gates" ) )// :-) - warning( "foul word", tdef_l_->defined_ch_c_l_m ); + warning( "foul word", tdef_l_->defined_ch_c_l_ ); } diff --git a/src/lyricstaff.cc b/src/lyricstaff.cc index 279db7ff87..6d199970c7 100644 --- a/src/lyricstaff.cc +++ b/src/lyricstaff.cc @@ -1,12 +1,10 @@ -#include "request.hh" +#include "musicalrequest.hh" #include "voice.hh" #include "staffwalker.hh" #include "debug.hh" #include "staff.hh" -#include "command.hh" #include "lyricstaff.hh" #include "lyriccolumn.hh" -#include "sccol.hh" #include "lyricwalker.hh" #include "pscore.hh" @@ -16,9 +14,9 @@ Lyric_staff::Lyric_staff() } Staff_column* -Lyric_staff::create_col(Score_column*s) +Lyric_staff::create_col() { - return new Lyric_column(s,this); + return new Lyric_column(this); } void @@ -29,11 +27,8 @@ Lyric_staff::set_output(PScore*pscore_l) pscore_l_->add(pstaff_l_); } -void -Lyric_staff::walk() +Staff_walker* +Lyric_staff::get_walker_p() { - for (Lyric_walker lcols(this); lcols.ok(); lcols++) { - lcols.lcol_l()->setup_requests(); - lcols.process(); - } + return new Lyric_walker(this); } diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index 160b83ae9e..960c1e76e0 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -1,42 +1,34 @@ -#include "request.hh" +/* + lyricwalker.cc -- implement Lyric_walker + + source file of the LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + +#include "musicalrequest.hh" #include "voice.hh" #include "pscore.hh" #include "lyricstaff.hh" #include "lyricwalker.hh" -//#include "sccol.hh" #include "debug.hh" #include "lyricitem.hh" -void -Lyric_walker::do_word(Word_info) -{ -} - -void -Lyric_walker::do_INTERPRET_command(Command* ) -{ -} - -void -Lyric_walker::do_TYPESET_command(Command* ) -{ -} - void Lyric_walker::process_requests() { - Lyric_column* lcol_l = Lyric_walker::lcol_l(); - - for (int i = 0; i < lcol_l->winfo_array_.size(); i++) { - lcol_l->typeset_item(new Lyric_item(lcol_l->winfo_array_[i].lreq_l_, i)); + allow_break(); + for (int i = 0; i < lcol_l()->lreq_l_array_.size(); i++) { + lcol_l()->typeset_item( + new Lyric_item(lcol_l()->lreq_l_array_[i],i) + ); } - } Lyric_walker::Lyric_walker(Lyric_staff* lstaff_l) : Staff_walker(lstaff_l, lstaff_l->pstaff_l_->pscore_l_) { - reset(); + } @@ -52,9 +44,3 @@ Lyric_walker::lcol_l() { return (Lyric_column*) *(*this); } - -void -Lyric_walker::reset() -{ -} - diff --git a/src/meter.cc b/src/meter.cc index 8c4af23818..4f06b6469e 100644 --- a/src/meter.cc +++ b/src/meter.cc @@ -13,6 +13,6 @@ Molecule* Meter::brew_molecule_p()const { Symbol s = paper()->lookup_p_->meter(args); -return new Molecule(Atom(s)); + return new Molecule(Atom(s)); } diff --git a/src/meterreg.cc b/src/meterreg.cc new file mode 100644 index 0000000000..e7d8b8e973 --- /dev/null +++ b/src/meterreg.cc @@ -0,0 +1,63 @@ +/* + meterreg.cc -- implement Meter_register + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "meterreg.hh" +#include "meter.hh" +#include "commandrequest.hh" + +Meter_register::Meter_register(Complex_walker*w) + : Request_register(w) +{ + do_post_move_process(); +} + +bool +Meter_register::try_request(Request*r_l) +{ + if (!r_l->nonmus()->meterchange()) + return false; + + assert(!meter_req_l_); + meter_req_l_ = r_l->nonmus()->meterchange(); + + return true; +} + +void +Meter_register::process_request() +{ + if (meter_req_l_ ) { + Array args; + args.push(meter_req_l_->beats_i_); + args.push(meter_req_l_->one_beat_i_); + + meter_p_ = new Meter(args); + } + + if (meter_p_) + announce_element(Staff_elem_info(meter_p_, meter_req_l_, this) ); +} + +void +Meter_register::do_pre_move_process() +{ + if (meter_p_) { + Meter * post_p =new Meter(*meter_p_); + Meter * pre_p =new Meter(*meter_p_); + + typeset_breakable_item(pre_p, meter_p_, post_p); + meter_p_ =0; + } +} + +void +Meter_register::do_post_move_process() +{ + meter_req_l_ = 0; + meter_p_ =0; +} diff --git a/src/misc.cc b/src/misc.cc index a8fe2c026d..f89cdec9f1 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -1,16 +1,17 @@ +#include + +#include "item.hh" #include "misc.hh" #include "glob.hh" #include "moment.hh" -#include Moment wholes(int dur, int dots) { if (!dur) - return 0.0; + return 0; - // stupid Intel: doesn't crash if !dur Moment f = Rational(1)/Moment(dur); Moment delta = f; @@ -36,3 +37,16 @@ log_2(double x) { return log(x) /log(2.0); } +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; +} + diff --git a/src/mylexer.cc b/src/mylexer.cc index de6fcc7238..7af820ae44 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -24,7 +24,7 @@ static Keyword_ent the_key_tab[]={ "goto", GOTO, "in", IN_T, "key", KEY, - "mark", MARK, + "meter", METER, "mm", MM_T, "multivoice", MULTIVOICE, @@ -81,7 +81,7 @@ My_flex_lexer::My_flex_lexer() keytable = new Keyword_table(the_key_tab); the_id_tab = new Assoc; defaulttab = 0; - data_ch_c_l_m = 0; + data_ch_c_l_ = 0; errorlevel_i_ = 0; } @@ -103,7 +103,7 @@ My_flex_lexer::lookup_identifier(String s) char const* My_flex_lexer::here_ch_c_l() { - return data_ch_c_l_m ? data_ch_c_l_m + yyin->tellg() : 0; + return data_ch_c_l_ ? data_ch_c_l_ + yyin->tellg() : 0; } void @@ -155,16 +155,16 @@ My_flex_lexer::new_input(String s) if (!include_stack.empty()) { include_stack.top()->line = lineno(); // should this be saved at all? - include_stack.top()->defined_ch_c_l_m = defined_ch_c_l; + include_stack.top()->defined_ch_c_l_ = defined_ch_c_l; } Input_file *newin = new Input_file(s); include_stack.push(newin); switch_streams(newin->is); if ( newin->sourcefile_l_ ) - data_ch_c_l_m = newin->sourcefile_l_->ch_c_l(); + data_ch_c_l_ = newin->sourcefile_l_->ch_c_l(); else - data_ch_c_l_m = 0; + data_ch_c_l_ = 0; yylineno = 1; } @@ -181,7 +181,7 @@ My_flex_lexer::close_input() Input_file *i = include_stack.top(); switch_streams(i->is); yylineno = i->line; - defined_ch_c_l = i->defined_ch_c_l_m; + defined_ch_c_l = i->defined_ch_c_l_; } delete old; return ok; diff --git a/src/note.cc b/src/note.cc index 796090f04d..2a89743e95 100644 --- a/src/note.cc +++ b/src/note.cc @@ -6,7 +6,8 @@ #include "string.hh" #include "real.hh" #include "debug.hh" -#include "request.hh" +#include "musicalrequest.hh" +#include "commandrequest.hh" #include "voice.hh" #include "notename.hh" #include "identparent.hh" @@ -48,7 +49,7 @@ get_text(String s) return t; t= new Text_def; t->text_str_= s; t->style_str_ = textstyle; - t->defined_ch_c_l_m = defined_ch_c_l; + t->defined_ch_c_l_ = defined_ch_c_l; return t; } @@ -74,40 +75,37 @@ parse_octave (const char *a, int &j, int &oct) } void -parse_pitchmod( const char *a, int &j, int &oct, bool & overide_acc) +parse_pitch( const char *a, Melodic_req* mel_l) { + int j=0; + // octave - oct =default_octave; - parse_octave(a,j,oct); - + mel_l->octave_i_ = default_octave; + parse_octave(a,j,mel_l->octave_i_); + // accidental - overide_acc = false; + mel_l->forceacc_b_ = false; - if (a[j] == '!') - { - overide_acc = true; + if (a[j] == '!'){ + mel_l->forceacc_b_ = true; j++; - } - - mtor << "oct " << oct; - mtor << "override: " << overide_acc<<'\n'; + } } - Voice_element * get_note_element(String pitch, int * notename, int * duration ) { Voice_element*v = new Voice_element; - v->defined_ch_c_l_m = defined_ch_c_l; - int i=0; + v->defined_ch_c_l_ = defined_ch_c_l; + int dur = duration[0]; - int dots=duration[1]; + int dots = duration[1]; if (dur >= 2) { Stem_req * stem_req_p = new Stem_req(dur,dots); stem_req_p->plet_factor = Moment(default_plet_dur, default_plet_type); - stem_req_p->defined_ch_c_l_m = defined_ch_c_l; + stem_req_p->defined_ch_c_l_ = defined_ch_c_l; v->add(stem_req_p); } @@ -115,19 +113,15 @@ get_note_element(String pitch, int * notename, int * duration ) defined_ch_c_l = lexer->here_ch_c_l(); Note_req * rq = new Note_req; - - int oct; - bool forceacc; - parse_pitchmod(pitch, i, oct, forceacc); - rq->notename =notename[0]; - rq->accidental = notename[1]; - rq->octave = oct + notename[2]; - rq->forceacc = forceacc; + rq->notename_i_ =notename[0]; + rq->accidental_i_ = notename[1]; + parse_pitch(pitch, rq); + rq->octave_i_ += notename[2]; + rq->balltype = dur; rq->dots = dots; rq->plet_factor = Moment(default_plet_dur, default_plet_type); - rq->defined_ch_c_l_m = defined_ch_c_l; - rq->print(); + rq->defined_ch_c_l_ = defined_ch_c_l; v->add(rq); @@ -138,25 +132,20 @@ Voice_element* get_word_element(Text_def* tdef_p, int* duration) { Voice_element* velt_p = new Voice_element; - velt_p->defined_ch_c_l_m = defined_ch_c_l; + velt_p->defined_ch_c_l_ = defined_ch_c_l; int dur = duration[0]; int dots=duration[1]; - tdef_p->defined_ch_c_l_m = defined_ch_c_l; -#if 0 - char buf[ 21 ]; - strncpy( buf, tdef_p->defined_ch_c_l_m, 20 ); - buf[ 20 ] = 0; - cout << hex << (void*)tdef_p->defined_ch_c_l_m << dec << buf << endl; -#endif + tdef_p->defined_ch_c_l_ = defined_ch_c_l; + Lyric_req* lreq_p = new Lyric_req(tdef_p); lreq_p->balltype = dur; lreq_p->dots = dots; lreq_p->plet_factor = Moment(default_plet_dur, default_plet_type); lreq_p->print(); - lreq_p->defined_ch_c_l_m = defined_ch_c_l; + lreq_p->defined_ch_c_l_ = defined_ch_c_l; velt_p->add(lreq_p); @@ -167,14 +156,14 @@ Voice_element * get_rest_element(String, int * duration ) { Voice_element* velt_p = new Voice_element; - velt_p->defined_ch_c_l_m = defined_ch_c_l; + velt_p->defined_ch_c_l_ = defined_ch_c_l; Rest_req * rest_req_p = new Rest_req; rest_req_p->plet_factor = Moment(default_plet_dur, default_plet_type); rest_req_p->balltype = duration[0]; rest_req_p->dots = duration[1]; rest_req_p->print(); - rest_req_p->defined_ch_c_l_m = defined_ch_c_l; + rest_req_p->defined_ch_c_l_ = defined_ch_c_l; velt_p->add(rest_req_p); @@ -247,7 +236,7 @@ get_request(char c) break; } - req_p->defined_ch_c_l_m = req_defined_ch_c_l; + req_p->defined_ch_c_l_ = req_defined_ch_c_l; return req_p; } @@ -289,8 +278,6 @@ Request* get_script_req(int d , Script_def*def) { Script_req* script_req_p = new Script_req(d, def); - // all terminal symbols, rather set directly here: - script_req_p->defined_ch_c_l_m = lexer->here_ch_c_l(); return script_req_p; } @@ -298,49 +285,24 @@ Request* get_text_req(int d , Text_def*def) { Text_req* text_req_p = new Text_req(d, def); - text_req_p->defined_ch_c_l_m = defined_ch_c_l; return text_req_p; } -Voice_element* -get_mark_element(String s) -{ - Voice_element*v_p = new Voice_element; - v_p->defined_ch_c_l_m = defined_ch_c_l; - Mark_req* mark_req_p = new Mark_req(s); - mark_req_p->defined_ch_c_l_m = defined_ch_c_l; - v_p->add(mark_req_p); - return v_p; -} -Voice_element* -get_command_element(Input_command*com_p) -{ - Voice_element *velt_p = new Voice_element; - velt_p->defined_ch_c_l_m = defined_ch_c_l; - Staff_command_req* scommand_req_p = new Staff_command_req(com_p); - scommand_req_p->defined_ch_c_l_m = defined_ch_c_l; - velt_p->add(scommand_req_p); - return velt_p; -} -Voice_element* -get_barcheck_element() +Request* +get_stemdir_req(int d) { - Voice_element* velt_p = new Voice_element; - velt_p->defined_ch_c_l_m = req_defined_ch_c_l; - Barcheck_req* barcheck_req_p = new Barcheck_req; - barcheck_req_p->defined_ch_c_l_m = req_defined_ch_c_l; - velt_p->add(barcheck_req_p); - return velt_p; + Group_feature_req * gfreq_p = new Group_feature_req; + gfreq_p->stemdir_i_ =d; + return gfreq_p; } -Voice_element* -get_stemdir_element(int d) +Request* +get_grouping_req(Array i_arr) { - Voice_element*v_p = new Voice_element; - v_p->defined_ch_c_l_m = req_defined_ch_c_l; - Group_feature_req * gfreq_p = new Group_feature_req; - gfreq_p->stemdir_i_ =d; - gfreq_p->defined_ch_c_l_m = req_defined_ch_c_l; - v_p->add(gfreq_p); - return v_p; + Measure_grouping_req * mr_p = new Measure_grouping_req; + for (int i=0; i beat_i_arr_.push(i_arr[i++]); + mr_p->elt_length_arr_.push(Moment(1, i_arr[i++])); + } + return mr_p; } diff --git a/src/notehead.cc b/src/notehead.cc index 2eabd2ff73..a0c031c106 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -5,7 +5,7 @@ #include "paperdef.hh" #include "lookup.hh" #include "molecule.hh" -#include "request.hh" +#include "musicalrequest.hh" NAME_METHOD(Notehead); diff --git a/src/parser.y b/src/parser.y index 5a307d847d..6c471fc95f 100644 --- a/src/parser.y +++ b/src/parser.y @@ -8,11 +8,12 @@ #include "inputscore.hh" #include "main.hh" #include "keyword.hh" -#include "inputcommand.hh" #include "debug.hh" #include "parseconstruct.hh" #include "dimen.hh" #include "identifier.hh" +#include "commandrequest.hh" +#include "musicalrequest.hh" #ifndef NDEBUG #define YYDEBUG 1 @@ -31,9 +32,8 @@ int fatal_error_i = 0; %union { Request * request; Real real; - Input_command *command; Identifier *id; - Voice *voice; + Voice *voice; Voice_element *el; String *string; const char *consstr; @@ -47,9 +47,8 @@ int fatal_error_i = 0; Moment *moment; Array * strvec; - Array *commandvec; Array *intvec; - + Array *melreqvec; Input_staff *staff; Input_score *score; Symtables * symtables; @@ -69,7 +68,7 @@ int fatal_error_i = 0; %token KEY CLEF TABLE VOICES STEM %token PARTIAL MUSIC GROUPING CADENZA %token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET -%token MARK GOTO +%token GOTO %token IDENTIFIER %token PITCHMOD DURATION RESTNAME @@ -79,7 +78,7 @@ int fatal_error_i = 0; %token DOTS INT %type unit -%type pitch_list +%type pitch_list %type open_request_parens close_request_parens %type declaration %type declarable_identifier @@ -88,15 +87,13 @@ int fatal_error_i = 0; %type default_duration explicit_duration notemode_duration mudela_duration %type notename %type duration_length -%type voice_elt full_element lyrics_elt -%type score_command staff_command position_command +%type voice_elt full_element lyrics_elt command_elt + %type score_block score_body %type staff_block staff_init staff_body %type int -%type int_list intastint_list -%type score_commands_block score_commands_body -%type staff_commands_block staff_commands_body -%type post_request pre_request +%type intastint_list +%type post_request pre_request command_req %type pitchmod %type music %type music_chord music_chord_body @@ -145,7 +142,7 @@ declarable_identifier: declaration: declarable_identifier '=' staff_block { $$ = new Staff_id(*$1, $3); - delete $1; // this sux + delete $1; } | declarable_identifier '=' music_voice { $$ = new M_voice_id(*$1, $3); @@ -172,7 +169,7 @@ declaration: delete $1; } | declarable_identifier error '}' { -// warning( "parse error", lexer->here_ch_c_l() ); + } ; @@ -195,13 +192,13 @@ notename_tab_body: { /* SCORE */ -score_block: SCORE - { define_spots.push(lexer->here_ch_c_l()); } - '{' score_body '}' { +score_block: + SCORE { define_spots.push(lexer->here_ch_c_l()); } + /*cont*/ '{' score_body '}' { $$ = $4; $$->defined_ch_c_l_ = define_spots.pop(); - if (!$$->paper_) - $$->paper_ = default_paper(); + if (!$$->paper_p_) + $$->paper_p_ = default_paper(); /* handle error levels. */ $$->errorlevel_i_ = lexer->errorlevel_i_; @@ -213,68 +210,15 @@ score_body: { $$ = new Input_score; } | score_body staff_block { $$->add($2); } - | score_body score_commands_block { - $$->add(*$2); - delete $2; + | score_body COMMANDS '{' music_voice_body '}' { + $$->set($4); } | score_body paper_block { $$->set($2); } - ; -/* - COMMANDS -*/ -score_commands_block: - COMMANDS '{' score_commands_body '}' { $$ =$3;} - | COMMANDS '{' error '}' { -// warning( "parse error", lexer->here_ch_c_l() ); - } - ; - -score_commands_body: { $$ = new Array; } - | score_commands_body score_command { - $$->push($2); - } - | score_commands_body position_command { - $$->push($2); - } - ; - -staff_commands_block: COMMANDS '{' staff_commands_body '}' { - $$ = $3; } - ; - -staff_commands_body: - /* empty */ { $$ = new Array; } - | staff_commands_body staff_command { - $$->push($2); - } - | staff_commands_body position_command { - $$->push($2); - } - ; + | score_body error { -staff_command: - KEY pitch_list {/*UGH*/ - $$ = get_key_interpret_command(*$2); - delete $2; - } - | CLEF STRING { - $$ = get_clef_interpret_command(*$2); - delete $2; - } - ; - -position_command: - SKIP int ':' duration_length { - $$ = get_skip_command($2, *$4); - delete $4; - } - | GOTO STRING { - $$ = get_goto_command(*$2); - delete $2; } ; - intastint_list: /* */ { $$ =new Array; } | intastint_list int '*' int { @@ -282,28 +226,6 @@ intastint_list: } ; -score_command: - BAR STRING { - $$ = get_bar_command(*$2); - delete $2; - } - | METER int '*' int { - $$ = get_meterchange_command($2, $4); - } - | PARTIAL duration_length { - $$ = get_partial_command(*$2); - delete $2; - } - | GROUPING intastint_list { - $$ = get_grouping_command(*$2); - delete $2; - } - | CADENZA int { - $$ = get_cadenza_toggle($2); - } - ; - - /* PAPER @@ -326,7 +248,7 @@ paper_body: | paper_body UNITSPACE dim { $$->whole_width = $3; } | paper_body GEOMETRIC REAL { $$->geometric_ = $3; } | paper_body error { -// warning( "parse error", lexer->here_ch_c_l() ); + } ; @@ -353,16 +275,14 @@ staff_init: staff_body: staff_init + | staff_body COMMANDS '{' music_voice_body '}' { + $$->set_score_wide($4); + } | staff_body music { $2->set_default_group( "staff_music" + String($$->music_.size())); $$->add($2); } - | staff_body staff_commands_block { - $$->add(*$2); - delete $2; - } | staff_body error { -// warning( "parse error", lexer->here_ch_c_l() ); } ; @@ -393,7 +313,6 @@ music_voice_body: $$->add($2); } | music_voice_body error { -// warning( "parse error", lexer->here_ch_c_l() ); } ; @@ -411,13 +330,12 @@ music_chord_body: $$->concatenate($2->mchord(true)); } | music_chord_body music { - $$ -> add($2); + $$->add($2); } | music_chord_body full_element { $$ ->add_elt($2); } | music_chord_body error { -// warning( "parse error", lexer->here_ch_c_l() ); } ; @@ -431,40 +349,77 @@ full_element: pre_requests voice_elt post_requests { add_requests($2, post_reqs); $$ = $2; } - | MARK STRING { - $$ = get_mark_element(*$2); + | lyrics_elt + | command_elt + ; + +command_elt: + command_req { + $$ = new Voice_element; + $$->add($1); + $1-> defined_ch_c_l_ = lexer->here_ch_c_l(); + } +/* can't do this, since "| |" has shift/reduce conflict. : + command_elt command_req { .. } +*/ + ; + +command_req: + '|' { + $$ = new Barcheck_req; + } + | BAR STRING { + $$ = new Bar_req(*$2); + delete $2; + } + | METER '{' int '*' int '}' { + Meter_change_req *m = new Meter_change_req; + m->set($3,$5); + $$ = m; + } + | SKIP duration_length { + Skip_req * skip_p = new Skip_req; + skip_p->duration_ = *$2; delete $2; + $$ = skip_p; } - | COMMAND '{' staff_command '}' { $$=get_command_element($3); } - | COMMAND '{' score_command '}' { $$=get_command_element($3); } - | '|' { - req_defined_ch_c_l = lexer->here_ch_c_l(); - $$ = get_barcheck_element(); + | CADENZA int { + $$ = new Cadenza_req($2); + } + | PARTIAL duration_length { + $$ = new Partial_measure_req(*$2); + delete $2; } | STEM '{' int '}' { - req_defined_ch_c_l = lexer->here_ch_c_l(); - $$ = get_stemdir_element($3); + $$ = get_stemdir_req($3); + } + | CLEF STRING { + $$ = new Clef_change_req(*$2); + delete $2; + } + | KEY '{' pitch_list '}' { + Key_change_req *key_p= new Key_change_req; + key_p->melodic_p_arr_ = *$3; + $$ = key_p; + delete $3; + } + | GROUPING '{' intastint_list '}' { + $$ = get_grouping_req(*$3); delete $3; } - | lyrics_elt -/* -+ | pre_requests voice_elt post_requests error '|' { -+ warning( "parse error", lexer->here_ch_c_l() ); -+ } -+ */ ; - + post_requests: { assert(post_reqs.empty()); } | post_requests post_request { + $2->defined_ch_c_l_ = lexer->here_ch_c_l(); post_reqs.push($2); } ; post_request: close_request_parens { - req_defined_ch_c_l = lexer->here_ch_c_l(); $$ = get_request($1); } | script_req @@ -473,22 +428,18 @@ post_request: close_request_parens: '(' { - req_defined_ch_c_l = lexer->here_ch_c_l(); $$='('; } | ']' { - req_defined_ch_c_l = lexer->here_ch_c_l(); $$ = ']'; } ; open_request_parens: ')' { - req_defined_ch_c_l = lexer->here_ch_c_l(); $$=')'; } | '[' { - req_defined_ch_c_l = lexer->here_ch_c_l(); $$='['; } ; @@ -552,6 +503,7 @@ script_dir: pre_requests: | pre_requests pre_request { pre_reqs.push($2); + $2->defined_ch_c_l_ = lexer->here_ch_c_l(); } ; @@ -665,13 +617,15 @@ lyrics_elt: /* UTILITIES -*/ + */ pitch_list: { - $$ = new Array; + $$ = new Array; } | pitch_list NOTENAME { - $$->push($2[0]); - $$->push($2[1]); + Melodic_req *m_p = new Melodic_req; + m_p->notename_i_ = $2[0]; + m_p->accidental_i_ = $2[1]; + $$->push(m_p); } ; @@ -696,14 +650,6 @@ real: ; -int_list: { - $$ = new Array; - } - | int_list int { - $$->push($2); - } - ; - dim: real unit { $$ = $1*$2; } @@ -784,8 +730,6 @@ dinterval: dim dim { void yyerror(const char *s) { -// if ( YYRECOVERING() ) -// return; lexer->LexerError(s); if ( fatal_error_i ) @@ -816,7 +760,8 @@ parse_file(String init, String s) delete lexer; lexer = 0; - assert(define_spots.empty()); + if(!define_spots.empty()) + warning("Braces don't match.",0); } Paperdef* diff --git a/src/pcol.cc b/src/pcol.cc index 54e177f486..5256947ce7 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -37,7 +37,7 @@ PCol::print() const mtor << "rank: " << rank() << '\n'; mtor << "# symbols: " << its.size() ; - if (breakable()){ + if (breakable_b()){ mtor << "\npre,post: "; prebreak_p_->print(); postbreak_p_->print(); @@ -76,7 +76,7 @@ PCol::OK() const void PCol::set_breakable() { - if (breakable()) + if (breakable_b()) return; prebreak_p_ = new PCol(this); @@ -86,7 +86,7 @@ PCol::set_breakable() } bool -PCol::breakable() const +PCol::breakable_b() const { return prebreak_p_||postbreak_p_; } @@ -117,5 +117,5 @@ PCol::add( Item *i) bool PCol::used()const { - return breakable() || its.size(); + return breakable_b() || its.size(); } diff --git a/src/pscore.cc b/src/pscore.cc index 34f0e09c28..c18fe83e01 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -103,7 +103,7 @@ void PScore::add(PCol *p) { p->pscore_l_ = this; - if (p->breakable()){ + if (p->breakable_b()){ p->prebreak_p_->pscore_l_ = this; p->postbreak_p_->pscore_l_ = this; } diff --git a/src/qlp.cc b/src/qlp.cc index 1e3e2f67d4..e6696acf39 100644 --- a/src/qlp.cc +++ b/src/qlp.cc @@ -46,6 +46,14 @@ Ineq_constrained_qp::eval (Vector v) { return v * quad * v + lin * v + const_term; } + +/** + eliminate appropriate variables, until we have a Ineq_constrained_qp + then solve that. + + PRE + cons should be ascending + */ Vector Mixed_qp::solve(Vector start) const { @@ -65,6 +73,8 @@ Mixed_qp::solve(Vector start) const /* assume x(idx) == value, and adjust constraints, lin and quad accordingly + + TODO: add const_term */ void Ineq_constrained_qp::eliminate_var(int idx, Real value) @@ -118,15 +128,6 @@ Ineq_constrained_qp::print() const /* *************** */ -/* - eliminate appropriate variables, until we have a Ineq_constrained_qp - then solve that. - - PRE - cons should be ascending - */ - - Mixed_qp::Mixed_qp(int n) : Ineq_constrained_qp(n) { diff --git a/src/qlpsolve.cc b/src/qlpsolve.cc index ed49c2a02f..5738be2f3b 100644 --- a/src/qlpsolve.cc +++ b/src/qlpsolve.cc @@ -133,7 +133,7 @@ Active_constraints::Active_constraints(Ineq_constrained_qp const *op) H=chol.inverse(); } -/* Find the optimum which is in the planes generated by the active +/** Find the optimum which is in the planes generated by the active constraints. */ Vector @@ -158,8 +158,8 @@ min_elt_index(Vector v) return idx; } -///the numerical solving -/** Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) + +/**the numerical solving. Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) Prentice Hall. Section 13.3 @@ -183,8 +183,9 @@ Ineq_constrained_qp::solve(Vector start) const Vector x(start); Vector gradient=quad*x+lin; - - +// Real fvalue = x*quad*x/2 + lin*x + const_term; +// it's no use. + Vector last_gradient(gradient); int iterations=0; diff --git a/src/register.cc b/src/register.cc index 7eeeb46ada..d58f262295 100644 --- a/src/register.cc +++ b/src/register.cc @@ -7,7 +7,7 @@ */ #include "voice.hh" -#include "request.hh" +#include "musicalrequest.hh" #include "register.hh" #include "notehead.hh" #include "complexwalker.hh" @@ -18,7 +18,7 @@ Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l, Request_register *reg_l) { elem_p_ = s_l; - voice_l_ = r_l->elt_l_->voice_l_; + voice_l_ = (r_l)?r_l->elt_l_->voice_l_:0; req_l_ = r_l; group_regs_l_ = 0; origin_reg_l_ = reg_l; @@ -35,6 +35,11 @@ Staff_elem_info::Staff_elem_info() } /* *************** */ +bool +Request_register::try_request(Request*) +{ + return false; +} Request_register::Request_register() { @@ -80,3 +85,11 @@ Request_register::paper()const { return walk_l_->staff()->paper(); } + +void +Request_register::typeset_breakable_item(Item * pre_p , Item * nobreak_p, + Item * post_p) +{ + walk_l_->typeset_breakable_item(pre_p, nobreak_p,post_p); +} + diff --git a/src/request.cc b/src/request.cc index 951a509bc4..72b8a3544a 100644 --- a/src/request.cc +++ b/src/request.cc @@ -1,11 +1,17 @@ -#include "request.hh" +/* + request.cc -- implement all musical requests. + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "musicalrequest.hh" #include "misc.hh" #include "debug.hh" #include "scriptdef.hh" #include "textdef.hh" -#include "inputcommand.hh" - void Stem_req::do_print() const { @@ -19,20 +25,14 @@ Stem_req::Stem_req(int s, int d) dir_i_ = 0; } -/* *************** */ -void -Barcheck_req::do_print() const -{ -#ifndef NPRINT - -#endif -} +/* ************** */ +void Musical_req::do_print()const{} +void Request::do_print() const{} /* *************** */ void Request::print() const - { mtor << name() << " {"; do_print(); @@ -40,12 +40,6 @@ Request::print() const } -void -Request::do_print() const -{ -#ifndef NPRINT -#endif -} void Span_req::do_print() const @@ -58,12 +52,12 @@ Span_req::do_print() const Request::Request() { elt_l_ = 0; - defined_ch_c_l_m = 0; + defined_ch_c_l_ = 0; } Request::Request(Request const&src) { elt_l_ = 0; - defined_ch_c_l_m = src.defined_ch_c_l_m; + defined_ch_c_l_ = src.defined_ch_c_l_; } /* *************** */ Spacing_req::Spacing_req() @@ -85,22 +79,22 @@ Blank_req::do_print()const /* *************** */ Melodic_req::Melodic_req() { - notename = 0; - octave = 0; - accidental = 0; - forceacc = false; + notename_i_ = 0; + octave_i_ = 0; + accidental_i_ = 0; + forceacc_b_ = false; } void Melodic_req::do_print() const { - mtor << "notename: " << notename << " oct: "<< octave; + mtor << "notename: " << notename_i_ << " oct: "<< octave_i_; } int Melodic_req::height() const { - return notename + octave*7; + return notename_i_ + octave_i_*7; } /* *************** */ @@ -188,25 +182,7 @@ Span_req::Span_req() { spantype = NOSPAN; } -/* *************** */ -void -Group_feature_req::do_print() const -{ - mtor << "stemdir " << stemdir_i_; -} -Group_feature_req::Group_feature_req() -{ - stemdir_i_ = 0; -} -void -Group_change_req::do_print()const -{ - mtor << "id : " << newgroup_str_; -} -void -Terminate_voice_req::do_print()const -{ -} + /* *************** */ Script_req::Script_req(int d , Script_def*def) { @@ -273,39 +249,17 @@ Text_req::do_print() const tdef_p_->print(); } - - /* *************** */ -Mark_req::Mark_req(String s) +Moment +Skip_req::duration() const { - mark_str_ = s; + return duration_; } void -Mark_req::do_print()const -{ -#ifndef NDEBUG - mtor<< " `" << mark_str_ << "\'\n"; -#endif -} -/* *************** */ -Staff_command_req::Staff_command_req(Input_command * p) -{ - com_p_ = p; -} -Staff_command_req::~Staff_command_req() -{ - delete com_p_; -} -Staff_command_req::Staff_command_req(Staff_command_req const&src) -{ - com_p_ = new Input_command(*src.com_p_); -} -void -Staff_command_req::do_print()const +Skip_req::do_print() const { - com_p_->print(); + mtor << "duration: " << duration(); } - diff --git a/src/sccol.cc b/src/sccol.cc index 2d826094da..1722599b21 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -1,3 +1,11 @@ +/* + sccol.cc -- implement Score_column + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "debug.hh" #include "pcol.hh" #include "sccol.hh" @@ -18,7 +26,7 @@ Score_column::Score_column(Moment w) { when_ = w; pcol_l_ = new PCol(0); - musical_ = false; + musical_b_ = false; } bool @@ -30,7 +38,7 @@ void Score_column::print() const { #ifndef NPRINT - mtor << "Score_column { mus "<< musical_ <<" at " << when_<<'\n'; + mtor << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n'; mtor << "durations: ["; for (int i=0; i < durations.size(); i++) mtor << durations[i] << " "; @@ -41,7 +49,7 @@ Score_column::print() const } int -Tdescription_compare(Moment &a , Moment& b) +Moment_compare(Moment &a , Moment& b) { return sign(a-b); } @@ -49,7 +57,7 @@ Tdescription_compare(Moment &a , Moment& b) void Score_column::preprocess() { - durations.sort(Tdescription_compare); + durations.sort(Moment_compare); } void Score_column::add_duration(Moment d) @@ -61,3 +69,9 @@ Score_column::add_duration(Moment d) } durations.push(d); } + +bool +Score_column::breakable_b() +{ + return pcol_l_->breakable_b(); +} diff --git a/src/score.cc b/src/score.cc index 1adcf7dd05..3084f90c90 100644 --- a/src/score.cc +++ b/src/score.cc @@ -1,3 +1,11 @@ +/* + score.cc -- implement Score + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "tstream.hh" #include "score.hh" #include "sccol.hh" @@ -8,27 +16,45 @@ #include "main.hh" #include "source.hh" #include "sourcefile.hh" +#include "scorewalker.hh" void -Score::process() +Score::setup_music() { - *mlog << "\nProcessing music ..." << flush; - - assert (paper_p_); + *mlog << "\nSetting up music ..." << flush; 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_); + find_col(0, false)->set_breakable(); // ugh + find_col(last(), false)->set_breakable(); + + + for (iter_top(staffs_,i); i.ok(); i++) { i->set_output(pscore_p_); - i->truncate_cols(last()); - i->process(); + i->setup_staffcols(); + i->OK(); } +} + +void +Score::process_music() +{ + *mlog << "Processing music ..." << flush; + for (Score_walker w(this); w.ok(); w++) { + w.process(); + } +} + +void +Score::process() +{ + setup_music(); + process_music(); // do this after processing, staffs first have to generate PCols. - find_col(last(), false)->set_breakable(); do_cols(); print(); calc_idealspacing(); @@ -36,7 +62,7 @@ Score::process() // debugging OK(); *mlog << endl; - pscore_p_->process(); + pscore_p_->process(); } /** @@ -59,8 +85,11 @@ Score::clean_cols() } /** + Create columns at time #w#. this sux. We should have Score_column create the appropriate PCol. - Unfortunately, PCols don't know about their position. + Unfortunately, PCols don't know about their position. + + @return cursor pointing to the nonmusical (first) column */ PCursor Score::create_cols(Moment w) @@ -68,8 +97,8 @@ Score::create_cols(Moment w) Score_column* c1 = new Score_column(w); Score_column* c2 = new Score_column(w); - c1->musical_ = false; - c2->musical_ = true; + c1->musical_b_ = false; + c2->musical_b_ = true; iter_top(cols_,i); @@ -94,11 +123,11 @@ Score::create_cols(Moment w) PCursor Score::find_col(Moment w, bool mus) -{ iter_top( cols_,i); - +{ + iter_top( cols_,i); for (; i.ok(); i++) { - if (i->when() == w && i->musical_ == mus) + if (i->when() == w && i->musical_b_ == mus) return i; if (i->when() > w) break; @@ -209,17 +238,3 @@ Score::add(Staff*s) s->score_l_ = this; staffs_.bottom().add(s); } - -void -Score::add_marks(Array s_arr, Array m_arr) -{ - for (int i=0; i < s_arr.size(); i++) { - String mark_str (s_arr[i]); - if (markers_assoc_.elt_query(mark_str) && - m_arr[i] != markers_assoc_[mark_str]) - - error("Conflicting marker: `" + s_arr[i]+ "\'"); - else - markers_assoc_[s_arr[i]] = m_arr[i]; - } -} diff --git a/src/scorewalker.cc b/src/scorewalker.cc new file mode 100644 index 0000000000..760bd29c75 --- /dev/null +++ b/src/scorewalker.cc @@ -0,0 +1,109 @@ +/* + scorewalker.cc -- implement Score_walker + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "debug.hh" +#include "plist.hh" +#include "scorewalker.hh" +#include "score.hh" +#include "staffwalker.hh" +#include "staff.hh" +#include "sccol.hh" + +Score_walker::Score_walker(Score *s) + :PCursor (s->cols_) +{ + for (iter_top(s->staffs_,i); i.ok(); i++) { + Staff_walker* w_p=i->get_walker_p(); + w_p->score_walk_l_ =this; + walker_p_arr_.push(w_p); + } + + if(ok()) { + s->find_col(0, false)->set_breakable(); + s->find_col(s->last(), false)->set_breakable(); + } + reinit(); +} + + +void +Score_walker::reinit() +{ + disallow_break_walk_l_arr = walker_p_arr_; + disallow_break_count_ = disallow_break_walk_l_arr.size(); +} + + +/** Advance the cursor, and all Staff_walkers contained in this. Reset + runtime fields */ +void +Score_walker::operator ++(int ) +{ + Moment last = ptr()->when(); + + PCursor::operator++(0); + if (ok() && ptr()->when() == last) + PCursor::operator++(0); + reinit(); + if (!ok()) + return; + for (int i=0; i< walker_p_arr_.size(); i++) { + if (walker_p_arr_[i]->ok() && + walker_p_arr_[i]->when() < when()) { + + walker_p_arr_[i]->operator++(0); + } + } +} + +/** Allow the command_column to be breakable for one staff. If all + staffs allow, then allow a break here. */ +void +Score_walker::allow_break(Staff_walker*w) +{ + for (int i=0; i < disallow_break_walk_l_arr.size(); i++) { + if (w == disallow_break_walk_l_arr[i]) { + disallow_break_count_ --; + disallow_break_walk_l_arr[i] =0; + + if (!disallow_break_count_) { + PCursor col_cursor = *this; + if (ptr()->musical_b()) + col_cursor --; + col_cursor->set_breakable(); + } + } + } +} + +Moment +Score_walker::when() +{ + return ptr()->when(); +} + +void +Score_walker::process() +{ + for (int i=0; i < walker_p_arr_.size(); i++) { + Staff_walker *w = walker_p_arr_[i]; + if ( w->ok() && w->when() == when() ) { + walker_p_arr_[i]->process(); + } + } + if (when().denominator() == 1) { + *mlog << "." < */ +#include "musicalrequest.hh" #include "complexwalker.hh" #include "slurreg.hh" #include "slur.hh" #include "debug.hh" + + void Slur_register::set_dir(int i) { @@ -54,7 +57,7 @@ Slur_register::process_request() 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); + slur_req_l->defined_ch_c_l_); else { end_slur_l_arr_.push(slur_l_stack_.pop()); requests_arr_.pop(); @@ -86,6 +89,6 @@ Slur_register::do_pre_move_process() Slur_register::~Slur_register() { for (int i=0; i < requests_arr_.size(); i++) { - warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m); + warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_); } } diff --git a/src/source.cc b/src/source.cc index dbdc501a4d..34f1a8808f 100644 --- a/src/source.cc +++ b/src/source.cc @@ -22,13 +22,13 @@ Source::~Source() void Source::add( Source_file* sourcefile_p ) { - sourcefile_p_iplist_m.bottom().add( sourcefile_p ); + sourcefile_p_iplist_.bottom().add( sourcefile_p ); } Source_file* Source::sourcefile_l( char const* ch_c_l ) { - PCursor sourcefile_p_pcur( sourcefile_p_iplist_m.top() ); + PCursor sourcefile_p_pcur( sourcefile_p_iplist_.top() ); for ( ; sourcefile_p_pcur.ok(); sourcefile_p_pcur++ ) if ( sourcefile_p_pcur->in_b( ch_c_l ) ) return *sourcefile_p_pcur; diff --git a/src/sourcefile.cc b/src/sourcefile.cc index ac164fd94a..f10d419b5a 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -26,21 +26,21 @@ Source_file::Source_file( String &filename_str ) { - data_caddr_m = 0; - fildes_i_m = 0; - size_off_m = 0; - name_str_m = filename_str; - istream_p_m = 0; + data_caddr_ = 0; + fildes_i_ = 0; + size_off_ = 0; + name_str_ = filename_str; + istream_p_ = 0; open(); map(); - filename_str = name_str_m; + filename_str = name_str_; } Source_file::~Source_file() { - delete istream_p_m; - istream_p_m = 0; + delete istream_p_; + istream_p_ = 0; unmap(); close(); } @@ -49,15 +49,15 @@ char const* Source_file::ch_c_l() { assert( this ); - return (char const*)data_caddr_m; + return (char const*)data_caddr_; } void Source_file::close() { - if ( fildes_i_m ) { - ::close( fildes_i_m ); - fildes_i_m = 0; + if ( fildes_i_ ) { + ::close( fildes_i_ ); + fildes_i_ = 0; } } @@ -77,7 +77,7 @@ Source_file::error_str( char const* pos_ch_c_l ) } char const* end_ch_c_l = pos_ch_c_l; - while ( end_ch_c_l < data_ch_c_l + size_off_m ) + while ( end_ch_c_l < data_ch_c_l + size_off_ ) if ( *end_ch_c_l++ == '\n' ) { break; } @@ -111,22 +111,22 @@ Source_file::error_str( char const* pos_ch_c_l ) bool Source_file::in_b( char const* pos_ch_c_l ) { - return ( pos_ch_c_l && ( pos_ch_c_l >= ch_c_l() ) && ( pos_ch_c_l < ch_c_l() + size_off_m ) ); + return ( pos_ch_c_l && ( pos_ch_c_l >= ch_c_l() ) && ( pos_ch_c_l < ch_c_l() + size_off_ ) ); } istream* Source_file::istream_l() { - assert( fildes_i_m ); - if ( !istream_p_m ) { - if ( size_off_m ) // can-t this be done without such a hack? - istream_p_m = new istrstream( ch_c_l(), size_off_m ); + assert( fildes_i_ ); + if ( !istream_p_ ) { + if ( size_off_ ) // can-t this be done without such a hack? + istream_p_ = new istrstream( ch_c_l(), size_off_ ); else { - istream_p_m = new istrstream( "", 0 ); - istream_p_m->set(ios::eofbit); + istream_p_ = new istrstream( "", 0 ); + istream_p_->set(ios::eofbit); } } - return istream_p_m; + return istream_p_; } int @@ -146,47 +146,47 @@ Source_file::line_i( char const* pos_ch_c_l ) void Source_file::map() { - if ( fildes_i_m == -1 ) + if ( fildes_i_ == -1 ) return; - data_caddr_m = (caddr_t)mmap( (void*)0, size_off_m, PROT_READ, MAP_SHARED, fildes_i_m, 0 ); + data_caddr_ = (caddr_t)mmap( (void*)0, size_off_, PROT_READ, MAP_SHARED, fildes_i_, 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() ); + if ( (int)data_caddr_ == -1 ) + warning( String( "can't map: " ) + name_str_ + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() ); } String Source_file::name_str() { - return name_str_m; + return name_str_; } void Source_file::open() { - String name_str = find_file( name_str_m ); + String name_str = find_file( name_str_ ); if ( name_str != "" ) - name_str_m = name_str; + name_str_ = name_str; - fildes_i_m = ::open( name_str_m, O_RDONLY ); + fildes_i_ = ::open( name_str_, O_RDONLY ); - if ( fildes_i_m == -1 ) { - warning( String( "can't open: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() ); + if ( fildes_i_ == -1 ) { + warning( String( "can't open: " ) + name_str_ + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() ); return; } struct stat file_stat; - fstat( fildes_i_m, &file_stat ); - size_off_m = file_stat.st_size; + fstat( fildes_i_, &file_stat ); + size_off_ = file_stat.st_size; } void Source_file::unmap() { - if ( data_caddr_m ) { - munmap( data_caddr_m, size_off_m ); - data_caddr_m = 0; - size_off_m = 0; + if ( data_caddr_ ) { + munmap( data_caddr_, size_off_ ); + data_caddr_ = 0; + size_off_ = 0; } } String diff --git a/src/staff.cc b/src/staff.cc index 2e650b008f..a69f625aed 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -4,59 +4,19 @@ #include "staffwalker.hh" #include "stcol.hh" #include "sccol.hh" -#include "staffcommands.hh" -#include "debug.hh" -#include "inputcommands.hh" -#include "inputcommand.hh" -#include "request.hh" - -void -Staff::do_commands(PointerList score_wide, - PointerList staff_wide) -{ - Input_commands commands; - - // bring in commands from voices. - for (iter_top(voices, i); i.ok(); i++) { - Moment here = i->start; - for (iter_top(i->elts, j); j.ok(); j++) { - for (iter_top(j->reqs, k); k.ok(); k++) { - if (k->command()){ - commands.find_moment(here); - commands.add(*k->command()->com_p_, - score_l_->markers_assoc_); - } - } - here += j->duration; - } - } - for (iter_top(score_wide,i); i.ok(); i++) - commands.add(**i, score_l_->markers_assoc_); - for (iter_top(staff_wide,i); i.ok(); i++) - commands.add(**i, score_l_->markers_assoc_); - commands.parse(this); -} +#include "debug.hh" +#include "musicalrequest.hh" +#include "commandrequest.hh" // todo void -Staff::add(PointerList &l) +Staff::add(PointerList const &l) { for (iter_top(l,i); i.ok(); i++) - voices.bottom().add(i); + voice_list_.bottom().add(i); } -void -Staff::truncate_cols(Moment l) -{ - iter_bot(cols, i); - for (; i->when() > l; i=cols.bottom()) { - Staff_column * col_p = i.get(); - assert(col_p->when() > l); - delete col_p; - } -} - -Paperdef* +Paperdef * Staff::paper() const { return score_l_->paper_p_; @@ -67,7 +27,12 @@ Staff::clean_cols() { iter_top(cols,i); for(; i.ok(); ){ - if (!i->score_column_l_->used()) + if (!i->musical_column_l_->used()) + i->musical_column_l_ = 0; + if (!i->command_column_l_->used()) + i->command_column_l_ =0; + + if (!i->command_column_l_&& !i->musical_column_l_) delete i.get(); else i++; @@ -75,109 +40,60 @@ Staff::clean_cols() } Staff_column * -Staff::get_col(Moment w, bool mus) -{ - iter_top(cols,i); +Staff::get_col(Moment w, PCursor *last) +{ + iter_top(cols,i); + if (last && last->ok() && (*last)->when() <= w) + i = *last; + for (; i.ok(); i++) { 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; + if (last) + *last = i; + return i; } else if (i->when() > w) break; } - /* 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()) { - cols.bottom().add(newst); - return cols.bottom(); - } - - if (mus) { - i.insert(newst); - - return newst; - } + PCursor sccols(score_l_->find_col(w, false)); + Staff_column* stcol_p = create_col(); + Score_column* comcol_l = sccols++; + stcol_p->set_cols(comcol_l, sccols); - // making a fix at 2:30 am, with several beers drunk. - // but it works :-) - if ((i-1).ok()&& (i-1)->when() == newst->when()) { + if (!i.ok()) { + cols.bottom().add( stcol_p); + i = cols.bottom(); + } else { + i.insert(stcol_p); i--; } - - i.insert(newst); - - return newst; + if (last) + *last = i; + return i; } -void -Staff::get_marks(Array&s_arr, Array&m_arr) -{ - for (iter_top(voices,i); i.ok(); i++) { - Moment now = i->start; - for (iter_top(i->elts,j); j.ok(); j++) { - for (iter_top(j->reqs, k); k.ok(); k++) { - if (k->mark()) { // ugh. 4 levels - s_arr.push(k->mark()->mark_str_); - m_arr.push(now); - } - } - now += j->duration; - } - } -} -/* - put all stuff grouped vertically in the Staff_cols +/** + put all stuff grouped vertically in the Staff_cols. + Do the preprarations for walking the cols. not virtual */ void Staff::setup_staffcols() { - for (iter_top(voices,i); i.ok(); i++) { - + for (iter_top(voice_list_,i); i.ok(); i++) { + PCursor last(cols); 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, &last); assert(now == s_l->when()); s_l->add(j); now += j->duration; } - get_col(now, false); - } - OK(); - set_time_descriptions(); -} - - - -void -Staff::set_time_descriptions() -{ - Time_description t(0,0); - for (iter_top(cols,i); i.ok(); i++) { - if (i->staff_commands_p_) - t = i->staff_commands_p_->tdescription_; - else if (i->tdescription_) - t = *i->tdescription_; - if(!i->tdescription_) { - i->tdescription_ = new Time_description(i->when() - t.when ,&t); - } +// get_col(now,last); } - -} -void -Staff::process() -{ - setup_staffcols(); OK(); - walk(); } void @@ -185,15 +101,12 @@ Staff::OK() const { #ifndef NDEBUG cols.OK(); - voices.OK(); + voice_list_.OK(); iter_top(cols, i); iter_top(cols, j); i++; for (; i.ok(); j++,i++) { - if ( j->when() == i->when()) - assert(!j->musical_b() && i->musical_b()); - else - assert(j->when () < i->when() ); + assert(j->when () < i->when() ); } assert(score_l_); #endif @@ -204,7 +117,7 @@ Moment Staff::last() const { Moment l = 0.0; - for (iter_top(voices,i); i.ok(); i++) { + for (iter_top(voice_list_,i); i.ok(); i++) { l = l >? i->last(); } return l; @@ -216,7 +129,7 @@ Staff::print() const { #ifndef NPRINT mtor << "Staff {\n"; - for (iter_top(voices,i); i.ok(); i++) { + for (iter_top(voice_list_,i); i.ok(); i++) { i->print(); } mtor <<"}\n"; diff --git a/src/staffcommands.cc b/src/staffcommands.cc deleted file mode 100644 index 517e7d1dd7..0000000000 --- a/src/staffcommands.cc +++ /dev/null @@ -1,208 +0,0 @@ -#include "staffcommands.hh" -#include "debug.hh" -#include "parseconstruct.hh" -#include "getcommand.hh" - -Moment -Staff_commands_at::when() -{ - return tdescription_.when; -} - -void -Staff_commands_at::print() const -{ -#ifndef NPRINT - iter_top(*this,i); - mtor << "Commands at: " ; - tdescription_.print(); - - for (; i.ok(); i++) - i->print(); -#endif -} -void -Staff_commands_at::OK()const -{ -#ifndef NDEBUG - iter_top(*this,i); - for (; i.ok() && (i+1).ok(); i++) - if (!i->isbreak() && !(i+1)->isbreak()) - assert(i->priority >= (i+1)->priority); -#endif -} - -Staff_commands_at::Staff_commands_at(Time_description m) - :tdescription_(m) -{ - -} - -bool -Staff_commands_at::is_breakable() -{ - iter_top(*this,i); - for (; i.ok(); i++) { - if (i->isbreak()) - return true; - } - return false; -} - -void -Staff_commands_at::set_breakable() -{ - if (is_breakable()) return; - - Command k; - k.code = BREAK_PRE; - bottom().add(new Command(k)); - k.code = BREAK_MIDDLE; - bottom().add(new Command(k)); - k.code = BREAK_POST; - bottom().add(new Command(k)); - k.code = BREAK_END; - bottom().add(new Command(k)); -} - -void -Staff_commands_at::insert_between(Command victim, PCursor firstc, - PCursor last) -{ - PCursor c(firstc+1); -// assert(firstc < last&&last.ok()); - assert(firstc->code < last->code && last.ok()); - -// while (c < last) { - while (c->code < last->code ) { - if (c->priority <= victim.priority) { - c.insert(new Command(victim)); - return; - } - c++; - } - last.insert(new Command(victim)); -} - -void -Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post) -{ - assert(is_breakable()); - iter_top(*this,c), f(c), l(c); - - while (!c->isbreak()) - c++; - f = c++; - while (!c->isbreak()) - c++; - l = c++; - - insert_between(pre, f, l); - f = l; - while (!c->isbreak()) - c++; - l = c++; - insert_between(mid, f, l); - f = l; - while (!c->isbreak()) - c++; - l = c++; - assert(l.ok() && l->code == BREAK_END); - - insert_between(post, f, l); -} - - -/* - should move this stuff into inputlanguage. - */ -void -Staff_commands_at::add(Command c) -{ - bool encapsulate =false; - Command pre; - Command mid; - Command post; - - if (c.code == INTERPRET) - { // UGH - Command typeset; // kut met peren - typeset.code = TYPESET; - typeset.args = c.args; - if (c.args[0] == "NEWMEASURE") { - add(get_defaultbar_command()); - } else if (c.args[0] == "BAR") { - add(typeset); - c.code= NOP; // no INTERPRET (BAR) commands - } else if (c.args[0] == "KEY") { - typeset.priority = 70; - add(typeset); - } else if (c.args[0] == "CLEF") { - typeset.priority = 90; - add(typeset); - } else if (c.args[0] == "METER") { - typeset.priority = 40; - add(typeset); - return; - } - } - - // kut en peer - if (c.code == TYPESET) { - encapsulate = is_breakable(); - if (c.args[0] == "BAR") { - set_breakable(); - encapsulate = true; - split_bar_command(pre,mid,post, c.args[1]); - - { /* every line a currentkey. */ - Command kc; - kc.code =TYPESET; - kc.args.push( "CURRENTKEY"); - kc.priority = 60; - add(kc); - } - { /* every line a currentclef. */ - Command kc; - kc.code =TYPESET; - kc.args.push( "CURRENTCLEF"); - kc.priority = 80; - add(kc); - } - } - if (is_breakable()) { - if (c.args[0] == "METER") { - mid = c; - pre = c; - post =c; - }else if( c.args[0] == "KEY") { - - mid = c; - pre = c; - post = c; - }else if (c.args[0] == "CURRENTKEY" ){ - post = c; - - }else - if (c.args[0] == "CURRENTCLEF" ){ - post = c; - - }else if (c.args[0] == "CLEF") { - - post = c; - pre = c; - mid = c; - } - } - } - - if (encapsulate) - add_command_to_break(pre, mid, post); - else { - if (c.priority>0) - top().insert(new Command(c)); - else - bottom().add(new Command(c)); - } -} - diff --git a/src/staffelem.cc b/src/staffelem.cc index 341b54e32b..1b5e592762 100644 --- a/src/staffelem.cc +++ b/src/staffelem.cc @@ -23,7 +23,10 @@ Staff_elem::Staff_elem(Staff_elem const&s) pstaff_l_ = s.pstaff_l_; offset_ = Offset(0,0); } - +/** + TODO: + If deleted, then remove dependants depency! + */ Staff_elem::~Staff_elem() { delete output; diff --git a/src/staffwalker.cc b/src/staffwalker.cc index eac45b5b13..d93243255d 100644 --- a/src/staffwalker.cc +++ b/src/staffwalker.cc @@ -1,10 +1,28 @@ -#include "request.hh" +/* + staffwalker.cc -- implement Staff_walker + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "grouping.hh" +#include "staff.hh" +#include "musicalrequest.hh" #include "staffwalker.hh" #include "stcol.hh" #include "sccol.hh" #include "debug.hh" +#include "timedescription.hh" +#include "commandrequest.hh" +#include "grouping.hh" +#include "scorewalker.hh" + +Staff_walker::~Staff_walker() +{ + do_pre_move(); +} -Staff_walker::~Staff_walker() {} Staff_walker::Staff_walker(Staff_walker const &s) :PCursor (s) { @@ -16,62 +34,73 @@ Staff_walker::Staff_walker(Staff * s, PScore*ps ) { staff_l_ = s; pscore_l_ = ps; - break_status = BREAK_END - BREAK_PRE; + default_grouping = new Rhythmic_grouping(MInterval(0, 1), 4); // should be in tdes. TODO + score_walk_l_ = 0; } Moment Staff_walker::when() const { - return (* (PCursor *) this)->when(); -} - -void -Staff_walker::process() -{ - break_status = BREAK_END - BREAK_PRE; - - if (ptr()->musical_b()) { - process_requests(); - } else if (ptr()->staff_commands_p_) - for (iter_top(*ptr()->staff_commands_p_,i); i.ok(); i++) { - process_command(i); - } + return ptr()->when(); } void -Staff_walker::process_command(Command*com) +Staff_walker::process_timing_reqs() { - switch (com->code){ - case BREAK_PRE: - case BREAK_MIDDLE: - case BREAK_POST: - case BREAK_END: - (*this)->score_column_l_->set_breakable(); - break_status = com->code- BREAK_PRE; - break; - case INTERPRET: - do_INTERPRET_command(com); - break; - - case TYPESET: - do_TYPESET_command(com); - break; - - default : - break; + for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) { + Timing_req * tr_l = ptr()->timing_req_l_arr_[i]; + if (tr_l->meterchange()) { + int b_i=tr_l->meterchange()->beats_i_; + int o_i = tr_l->meterchange()->one_beat_i_; + time_.set_meter(b_i, o_i); + + *default_grouping = Rhythmic_grouping( + MInterval(0,Moment(b_i, o_i)), b_i); + } + } + + for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) { + Timing_req * tr_l = ptr()->timing_req_l_arr_[i]; + if (tr_l->partial()) { + time_.setpartial(tr_l->partial()->duration_); + } else if (tr_l->barcheck() && time_.whole_in_measure_) { + warning( "Barcheck failed", tr_l->defined_ch_c_l_ ); + } else if (tr_l->cadenza()) { + time_.set_cadenza(tr_l->cadenza()->on_b); + } else if (tr_l->measuregrouping()) { + *default_grouping = parse_grouping( + tr_l->measuregrouping()->beat_i_arr_, + tr_l->measuregrouping()->elt_length_arr_); + } } + time_.OK(); } void Staff_walker::operator++(int i) { + Moment last = when(); + do_pre_move(); - if (ptr()->musical_b() && ptr()->tdescription_ - && !ptr()->tdescription_->whole_in_measure) { - *mlog << "[" << ptr()->tdescription_->bars<<"]"<< flush; - } PCursor::operator++(i); - + if (ok() ) { + Moment delta_t = when() - last; + assert(delta_t >0); + time_.add( delta_t ); + } do_post_move(); } + +void +Staff_walker::process() +{ + process_timing_reqs(); + process_requests(); +} +void +Staff_walker::allow_break() +{ + score_walk_l_->allow_break(this); +} + diff --git a/src/stcol.cc b/src/stcol.cc index 0712409662..f3498db0e1 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -1,52 +1,69 @@ +/* + stcol.cc -- implement Staff_column + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "voice.hh" #include "timedescription.hh" #include "sccol.hh" -#include "staffcommands.hh" #include "stcol.hh" +#include "commandrequest.hh" +#include "musicalrequest.hh" void Staff_column::OK() const { #ifndef NDEBUG - if (tdescription_) { - assert(tdescription_->when == when()); - assert(*tdescription_ == staff_commands_p_->tdescription_); - } + assert (command_column_l_->when() == musical_column_l_->when()); #endif } -bool -Staff_column::musical_b() const -{ - return score_column_l_->musical_; -} - Moment Staff_column::when() const { - return score_column_l_->when(); + return (command_column_l_)? + command_column_l_->when(): + musical_column_l_->when(); } void Staff_column::add(Voice_element*ve) { - Moment d= ve->duration; - if (d){ - score_column_l_->add_duration(d); + for (iter_top(ve->reqs,j); j.ok(); j++) { + if (j->nonmus()) { + if (j->nonmus()->timing()) { + timing_req_l_arr_.push(j->nonmus()->timing()); + } + if (!j->barcheck() && !j->nonmus()->measuregrouping()) + setup_one_request(j); // no need to bother children + } else { + if (j->rhythmic()) { + musical_column_l_->add_duration(j->rhythmic()->duration()); + } + setup_one_request(j); + } } - - v_elts.push(ve); } -Staff_column::Staff_column(Score_column * cur) - +Staff_column::Staff_column() { - tdescription_ =0; - score_column_l_=cur; - staff_commands_p_ = 0; + musical_column_l_ = 0; + command_column_l_ = 0; } + + + Staff_column::~Staff_column() { - delete tdescription_; +} + +void +Staff_column::set_cols(Score_column*c1, Score_column*c2) +{ + command_column_l_ = c1; + musical_column_l_ = c2; } diff --git a/src/stem.cc b/src/stem.cc index 2a1f99e21a..b11386afec 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -10,9 +10,9 @@ const int STEMLEN=7; NAME_METHOD(Stem); + Stem::Stem(int c) //, Moment len) { -// note_length = len; beams_left = 0; beams_right = 0; minnote = 1000; // invalid values @@ -188,7 +188,7 @@ Stem::brew_molecule_p()const return out; Real Stem::hpos()const { - return pcol_l_->hpos + stem_xoffset; + return pcol_l_->hpos + stem_xoffset; // hmm. + offset_.x; } diff --git a/src/stembeamreg.cc b/src/stembeamreg.cc index 506bde3423..504ba6854f 100644 --- a/src/stembeamreg.cc +++ b/src/stembeamreg.cc @@ -4,6 +4,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "musicalrequest.hh" #include "stembeamreg.hh" #include "beam.hh" #include "stem.hh" @@ -12,7 +13,7 @@ #include "complexwalker.hh" #include "complexstaff.hh" #include "debug.hh" - +#include "grouping.hh" Stem_beam_register::Stem_beam_register(Complex_walker*w) :Request_register(w) { @@ -39,7 +40,7 @@ Stem_beam_register::try_request(Request*req_l) if ( req_l->stem() ) { if (current_grouping && !current_grouping->child_fit_query( - walk_l_->col()->tdescription_->whole_in_measure)) + walk_l_->time_.whole_in_measure_)) return false; if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem())) @@ -68,6 +69,7 @@ Stem_beam_register::process_request() t->set_support(beam_p_); t->spec.align_i_ = 0; t->spec.text_str_ = beam_req_l_->nplet; + t->spec.style_str_="italic"; typeset_element(t); } @@ -78,7 +80,7 @@ Stem_beam_register::process_request() stem_p_ = new Stem(4); if (current_grouping) current_grouping->add_child( - walk_l_->col()->tdescription_->whole_in_measure, + walk_l_->time_.whole_in_measure_, stem_req_l_->duration()); stem_p_->flag = stem_req_l_->balltype; @@ -86,7 +88,7 @@ Stem_beam_register::process_request() if (beam_p_) { if (stem_req_l_->balltype<= 4) warning( "stem doesn't fit in Beam", - stem_req_l_->defined_ch_c_l_m); + stem_req_l_->defined_ch_c_l_); else beam_p_->add(stem_p_); stem_p_->print_flag = false; @@ -122,8 +124,8 @@ Stem_beam_register::do_pre_move_process() 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_->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; @@ -143,7 +145,7 @@ Stem_beam_register::do_post_move_process() Stem_beam_register::~Stem_beam_register() { if (beam_p_) - warning("unterminated beam", start_req_l_->defined_ch_c_l_m); + warning("unterminated beam", start_req_l_->defined_ch_c_l_); } void diff --git a/src/template1.cc b/src/template1.cc index 128dd06258..283a488b1a 100644 --- a/src/template1.cc +++ b/src/template1.cc @@ -2,8 +2,7 @@ #include "plist.hh" #include "pcol.hh" #include "item.hh" -#include "request.hh" -#include "command.hh" +#include "musicalrequest.hh" #include "spanner.hh" #include "scoreline.hh" #include "staffline.hh" diff --git a/src/template2.cc b/src/template2.cc index 06b3a167c4..29d4b1eaf3 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -1,12 +1,10 @@ - #include "symbol.hh" #include "voice.hh" -#include "request.hh" +#include "musicalrequest.hh" #include "staff.hh" #include "sccol.hh" #include "stcol.hh" #include "spanner.hh" - #include "plist.tcc" #include "pcursor.tcc" diff --git a/src/template3.cc b/src/template3.cc index bc7e4885a3..185c185076 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -1,23 +1,15 @@ #include "request.hh" -#include "command.hh" #include "inputscore.hh" #include "inputstaff.hh" #include "inputmusic.hh" -#include "inputcommand.hh" -#include "inputcommands.hh" #include "molecule.hh" -#include "staffcommands.hh" #include "sourcefile.hh" - #include "plist.tcc" #include "pcursor.tcc" + IPL_instantiate(Atom); -IPL_instantiate(Command); IPL_instantiate(Atom); -IPL_instantiate(Input_command); -IPL_instantiate(Commands_at); -IPL_instantiate(Staff_commands_at); IPL_instantiate(Input_staff); IPL_instantiate(Input_music); IPL_instantiate(Source_file); diff --git a/src/textdef.cc b/src/textdef.cc index 09fb2257a1..d4e9824d1b 100644 --- a/src/textdef.cc +++ b/src/textdef.cc @@ -8,7 +8,7 @@ Text_def::Text_def() { align_i_ = 1; // right style_str_ = "roman"; - defined_ch_c_l_m = 0; + defined_ch_c_l_ = 0; } bool Text_def::compare(const Text_def&def) diff --git a/src/textitem.cc b/src/textitem.cc index c9ead7ce03..110e95e3bf 100644 --- a/src/textitem.cc +++ b/src/textitem.cc @@ -1,4 +1,4 @@ -#include "request.hh" +#include "musicalrequest.hh" #include "paperdef.hh" #include "textitem.hh" #include "stem.hh" diff --git a/src/textreg.cc b/src/textreg.cc index 309bf6fe98..7e6d59e2cb 100644 --- a/src/textreg.cc +++ b/src/textreg.cc @@ -4,6 +4,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "musicalrequest.hh" #include "textreg.hh" #include "textitem.hh" diff --git a/src/timedescription.cc b/src/timedescription.cc index 5026656c2b..c9c3d52860 100644 --- a/src/timedescription.cc +++ b/src/timedescription.cc @@ -8,10 +8,10 @@ Time_description::str()const if (cadenza_b_) s+=String( " (cadenza) "); s+= "at "; - s+=when; - s+="\nmeter " + String(whole_per_measure/one_beat) +":" + - String(Rational(Rational(1)/one_beat)); - s+= "\nposition "+String( bars) + ":"+ whole_in_measure +"\n}\n"; + s+=when_; + s+="\nmeter " + String(whole_per_measure_/one_beat_) +":" + + String(Rational(Rational(1)/one_beat_)); + s+= "\nposition "+String( bars_i_) + ":"+ whole_in_measure_ +"\n}\n"; return s; } @@ -25,9 +25,9 @@ Time_description::OK() const { #ifdef NDEBUG if (!cadenza_b_) - assert(whole_in_measure < whole_per_measure); - assert(0 <= whole_in_measure); - assert(one_beat); + assert(whole_in_measure_ < whole_per_measure_); + assert(0 <= whole_in_measure_); + assert(one_beat_); #endif } @@ -35,33 +35,33 @@ void Time_description::set_cadenza(bool b) { if (cadenza_b_ && !b) { - if (whole_in_measure) { - bars ++; - whole_in_measure = 0; + if (whole_in_measure_) { + bars_i_ ++; + whole_in_measure_ = 0; } } cadenza_b_ = b ; } -Time_description::Time_description(Moment dt, Time_description const *prev) +Time_description::Time_description() { - if (prev) { - assert(dt >= Rational(0)); - *this = *prev; - when += dt; - whole_in_measure += dt; + whole_per_measure_ = 1; + whole_in_measure_ =0; + one_beat_ = Moment(1,4); + when_ = 0; + bars_i_ = 0; + cadenza_b_ = false; +} +void +Time_description::add(Moment dt) +{ + assert(dt >= Rational(0)); + when_ += dt; + whole_in_measure_ += dt; - while ( !cadenza_b_ && whole_in_measure >= whole_per_measure ) { - whole_in_measure -= whole_per_measure; - bars ++; - } - } else { // default 4/4 - whole_per_measure = 1; - whole_in_measure =0; - one_beat = Moment(1,4); - when = 0.0; - bars = 0; - cadenza_b_ = false; + while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_ ) { + whole_in_measure_ -= whole_per_measure_; + bars_i_ ++; } } @@ -69,39 +69,39 @@ void Time_description::set_meter(int l, int o) { assert(o); - one_beat = Rational(1)/Moment(o); - whole_per_measure = Moment(l) * one_beat; - if(whole_in_measure) + one_beat_ = Rational(1)/Moment(o); + whole_per_measure_ = Moment(l) * one_beat_; + if(whole_in_measure_) error_t("Meterchange should be at start of measure", *this); } void Time_description::setpartial(Moment p) { - if (when) + if (when_) error_t ("Partial measure only allowed at beginning.", *this); - if (p whole_per_measure) + if (p whole_per_measure_) error_t ("Partial measure has incorrect size", *this); - whole_in_measure = whole_per_measure - p; + whole_in_measure_ = whole_per_measure_ - p; } Moment Time_description::barleft() { assert(!cadenza_b_); - return whole_per_measure-whole_in_measure; + return whole_per_measure_-whole_in_measure_; } int Time_description::compare(Time_description &t1, Time_description&t2) { - int i = sign(t1.when-t2.when); + int i = sign(t1.when_-t2.when_); if (!i) { - assert(t1.bars==t2.bars); - assert(t1.one_beat == t2.one_beat); - assert(t1.whole_in_measure == t2.whole_in_measure); - assert(t1.whole_per_measure == t2.whole_per_measure); + assert(t1.bars_i_==t2.bars_i_); + assert(t1.one_beat_ == t2.one_beat_); + assert(t1.whole_in_measure_ == t2.whole_in_measure_); + assert(t1.whole_per_measure_ == t2.whole_per_measure_); } return i; diff --git a/src/voice.cc b/src/voice.cc index 8bccb12d8d..3dd4becf21 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -1,6 +1,15 @@ +/* + voice.cc -- implement Voice + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + #include "debug.hh" #include "voice.hh" -#include "request.hh" +#include "musicalrequest.hh" +#include "commandrequest.hh" void Voice::set_default_group(String s) @@ -49,54 +58,4 @@ Voice::last() const l += i->duration; return l; } -/* *************************************************************** */ -void -Voice_element::print() const -{ -#ifndef NPRINT - mtor << "voice_element { dur :"<< duration <<"\n"; - for (iter_top(reqs,rc); rc.ok(); rc++) { - rc->print(); - } - mtor << "}\n"; -#endif -} -void -Voice_element::add(Request*r) -{ - if (r->rhythmic()) { - assert (!duration || duration == r->duration()); - duration = r->duration(); - } - - r->elt_l_ = this; - reqs.bottom().add(r); -} - - -Voice_element::Voice_element() -{ - voice_l_ = 0; - duration = 0; - defined_ch_c_l_m = 0; -} -Voice_element::Voice_element(Voice_element const&src) -{ - defined_ch_c_l_m = src.defined_ch_c_l_m; - // are you sure? They can be modified after copying. - voice_l_=0; - for (iter_top(src.reqs, i); i.ok(); i++) - add(i->clone()); - -} -void -Voice_element::set_default_group(String s) -{ - for (iter_top(reqs, i); i.ok(); i++) - if (i->groupchange()) - return ; - Group_change_req *greq = new Group_change_req; - greq->newgroup_str_ = s; - add(greq); -} diff --git a/src/voiceelt.cc b/src/voiceelt.cc new file mode 100644 index 0000000000..72ba0a77d5 --- /dev/null +++ b/src/voiceelt.cc @@ -0,0 +1,65 @@ +/* + voiceelt.cc -- implement Voice_element + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "debug.hh" +#include "voice.hh" +#include "musicalrequest.hh" +#include "commandrequest.hh" + + +void +Voice_element::print() const +{ +#ifndef NPRINT + mtor << "voice_element { dur :"<< duration <<"\n"; + for (iter_top(reqs,rc); rc.ok(); rc++) { + rc->print(); + } + mtor << "}\n"; +#endif +} + +void +Voice_element::add(Request*r) +{ + if (r->duration()) { + assert (!duration || duration == r->duration()); + duration = r->duration(); + } + + r->elt_l_ = this; + reqs.bottom().add(r); +} + + +Voice_element::Voice_element() +{ + voice_l_ = 0; + duration = 0; + defined_ch_c_l_ = 0; +} + +Voice_element::Voice_element(Voice_element const&src) +{ + defined_ch_c_l_ = src.defined_ch_c_l_; + + voice_l_=0; + for (iter_top(src.reqs, i); i.ok(); i++) + add(i->clone()); + +} +void +Voice_element::set_default_group(String s) +{ + for (iter_top(reqs, i); i.ok(); i++) + if (i->groupchange()) + return ; + Group_change_req *greq = new Group_change_req; + greq->newgroup_str_ = s; + add(greq); +} diff --git a/src/voicegroup.cc b/src/voicegroup.cc index 35de10df4f..4f622c9384 100644 --- a/src/voicegroup.cc +++ b/src/voicegroup.cc @@ -1,11 +1,19 @@ -#include "request.hh" +/* + voicegroup.cc -- implement Voice_group_registers + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "musicalrequest.hh" #include "voicegroup.hh" #include "register.hh" #include "textreg.hh" #include "stembeamreg.hh" #include "scriptreg.hh" #include "complexwalker.hh" - +#include "commandrequest.hh" static int temp_id_count; @@ -27,6 +35,7 @@ Voice_group_registers::~Voice_group_registers() delete stem_beam_reg_; delete script_reg_; } + void Voice_group_registers::pre_move_processing() { diff --git a/src/voiceregs.cc b/src/voiceregs.cc index f7d63bd76f..4eba8c55f7 100644 --- a/src/voiceregs.cc +++ b/src/voiceregs.cc @@ -1,4 +1,4 @@ -#include "request.hh" +#include "musicalrequest.hh" #include "voicegroup.hh" #include "register.hh" #include "slurreg.hh" diff --git a/src/warn.cc b/src/warn.cc index a7d9ba18be..46d779e10f 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -40,7 +40,7 @@ error_t(const String& s, const Moment& r) void error_t(const String& s, Time_description const &t_tdes) { - String e=s+ " (at t=" + String(t_tdes.bars) + ": " + String(t_tdes.whole_in_measure) + ")\n"; + String e=s+ " (at t=" + String(t_tdes.bars_i_) + ": " + String(t_tdes.whole_in_measure_) + ")\n"; error(e); } diff --git a/src/wordwrap.cc b/src/wordwrap.cc index 90d4d542dc..f217a63b08 100644 --- a/src/wordwrap.cc +++ b/src/wordwrap.cc @@ -40,7 +40,8 @@ Word_wrap::solve() // try to solve if (!feasible(current.cols)) { if (!minimum.cols.size()) - error("sorry, this measure is too long"); + error("sorry, this measure is too long, breakpoint: " + + String(break_idx_i) ); current.energy = INFTY; // make sure we go back } else { current = solve_line(current.cols); -- 2.39.5