From 6e632214ccd61a566fdaa42659bd63aff6b5d070 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 23 Dec 1996 11:29:38 +0100 Subject: [PATCH] release: 0.0.20 --- .dstreamrc | 2 +- .../{CodingStyle => CodingStyle.pod} | 68 +++-- Documentation/Makefile | 23 +- Documentation/README.pod | 165 +++++++++++ Documentation/algorithms | 98 ------- Documentation/breaking | 38 --- Documentation/commands | 24 -- Documentation/design | 26 -- Documentation/lilygut.pod | 260 ++++++++++++++++++ Documentation/{inputformat => lilyinput.pod} | 38 ++- Documentation/literature | 76 ----- Documentation/pointers | 31 --- Documentation/slurfont | 43 --- Makefile | 7 +- NEWS | 6 + README | 117 +------- Sources.make | 21 +- Variables.make | 12 +- cadenza.ly | 35 +++ flower/Sources.make | 3 +- flower/Variables.make | 2 +- flower/dstream.cc | 2 +- flower/interval.tcc | 23 +- flower/path.cc | 81 ++++++ flower/path.hh | 32 +++ flower/pcursor.hh | 4 +- flower/plist.hh | 10 +- flower/plist.tcc | 2 +- flower/scalar.cc | 4 +- flower/scalar.hh | 2 +- flower/smat.cc | 4 +- flower/sstack.hh | 2 +- hdr/beam.hh | 10 +- hdr/boxes.hh | 32 +-- hdr/command.hh | 3 +- hdr/directionalspanner.hh | 25 ++ hdr/grouping.hh | 18 +- hdr/inputcommand.hh | 8 +- hdr/inputcommands.hh | 25 +- hdr/inputmusic.hh | 19 +- hdr/leastsquares.hh | 2 +- hdr/linespace.hh | 4 +- hdr/lookup.hh | 3 +- hdr/melodicstaff.hh | 2 +- hdr/misc.hh | 12 +- hdr/moment.hh | 29 +- hdr/offset.hh | 38 +++ hdr/paper.hh | 3 +- hdr/proto.hh | 4 +- hdr/request.hh | 7 +- hdr/rhythmstaff.hh | 2 +- hdr/sccol.hh | 19 +- hdr/score.hh | 8 +- hdr/simplestaff.hh | 4 +- hdr/simplewalker.hh | 2 +- hdr/slur.hh | 9 +- hdr/spanner.hh | 11 +- hdr/staff.hh | 6 +- hdr/staffcommands.hh | 14 +- hdr/stcol.hh | 5 +- hdr/stem.hh | 5 +- hdr/swalker.hh | 2 +- hdr/textspanner.hh | 31 +++ hdr/timedescription.hh | 36 +++ hdr/voice.hh | 9 +- init/Makefile | 5 + init/dutch.ini | 11 + init/english.ini | 13 + init/table_sixteen.ini | 99 +++++++ init/table_twenty.ini | 103 +++++++ lilyponddefs.tex | 16 +- maartje.ly | 6 +- src/beam.cc | 16 +- src/boxes.cc | 8 - src/calcideal.cc | 6 +- src/directionalspanner.cc | 6 + src/grouping.cc | 60 ++-- src/inputcommand.cc | 15 +- src/inputcommands.cc | 49 ++-- src/inputmusic.cc | 22 +- src/lexer.l | 11 + src/linespace.cc | 2 +- src/lookup.cc | 13 + src/melodicstaff.cc | 2 +- src/misc.cc | 7 +- src/molecule.cc | 8 +- src/mylexer.cc | 1 + src/notehead.cc | 4 +- src/paper.cc | 2 +- src/parser.y | 2 +- src/pcol.cc | 2 +- src/pscore.cc | 2 +- src/qlpsolve.cc | 4 +- src/request.cc | 2 +- src/rhythmstaff.cc | 2 +- src/sccol.cc | 23 +- src/score.cc | 10 +- src/simpleprint.cc | 15 +- src/simplewalker.cc | 17 +- src/slur.cc | 18 ++ src/spanner.cc | 5 +- src/staff.cc | 28 +- src/staffcommands.cc | 32 ++- src/staffline.cc | 6 +- src/stcol.cc | 14 +- src/stem.cc | 10 +- src/swalker.cc | 2 +- src/template5.cc | 8 + src/texbeam.cc | 4 +- src/texslur.cc | 12 +- src/textspanner.cc | 57 ++++ src/{moment.cc => timedescription.cc} | 26 +- src/voice.cc | 4 +- symbol.ini | 205 +------------- 114 files changed, 1559 insertions(+), 1104 deletions(-) rename Documentation/{CodingStyle => CodingStyle.pod} (59%) create mode 100644 Documentation/README.pod delete mode 100644 Documentation/algorithms delete mode 100644 Documentation/breaking delete mode 100644 Documentation/commands delete mode 100644 Documentation/design create mode 100644 Documentation/lilygut.pod rename Documentation/{inputformat => lilyinput.pod} (59%) delete mode 100644 Documentation/literature delete mode 100644 Documentation/pointers delete mode 100644 Documentation/slurfont create mode 100644 cadenza.ly create mode 100644 flower/path.cc create mode 100644 flower/path.hh create mode 100644 hdr/directionalspanner.hh create mode 100644 hdr/offset.hh create mode 100644 hdr/textspanner.hh create mode 100644 hdr/timedescription.hh create mode 100644 init/Makefile create mode 100644 init/dutch.ini create mode 100644 init/english.ini create mode 100644 init/table_sixteen.ini create mode 100644 init/table_twenty.ini create mode 100644 src/directionalspanner.cc create mode 100644 src/template5.cc create mode 100644 src/textspanner.cc rename src/{moment.cc => timedescription.cc} (59%) diff --git a/.dstreamrc b/.dstreamrc index 1d35c0489b..0fb28ce927 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,6 +1,6 @@ # class name silence? -My_flex_lexer 1 +My_flex_lexer 0 yyFlexLexer 1 PCol 1 Score_column 1 diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle.pod similarity index 59% rename from Documentation/CodingStyle rename to Documentation/CodingStyle.pod index 0669c2094a..a0ffcaf4ea 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle.pod @@ -1,29 +1,37 @@ --*-text-*- +=head1 NAME + +CodingStyle - standards while programming for LilyPond + +=head1 DESCRIPTION + +Please use these standards while doing programming for LilyPond + -CODING STANDARDS: Functions and methods do not return errorcodes, but use assert for checking status. -INDENTATION, in emacs: +=head2 INDENTATION +in emacs: -(add-hook 'c-mode-hook - '(lambda ()(setq c-basic-offset 4))) + (add-hook 'c-mode-hook + '(lambda ()(setq c-basic-offset 4))) -(add-hook 'c++-mode-hook - '(lambda() (c-set-style "Stroustrup") - ) - ) + (add-hook 'c++-mode-hook + '(lambda() (c-set-style "Stroustrup") + ) + ) -CLASSES and TYPES: + +=head2 CLASSES and TYPES: This_is_a_class AClass_name (for Abbreviation_class_name) -DATA MEMBERS +=head2 DATA MEMBERS Class::member @@ -33,43 +41,43 @@ if the member's name resembles its type, then I use Class::fubular_ -COMMENTS +=head2 COMMENTS -/// short description -class Class { - /// - Data data_member_; - /** - .. - */ + /// short description + class Class { + /// + Data data_member_; + /** + .. + */ - /****************/ + /****************/ - /// short memo - member(); + /// short memo + member(); + /** + long doco of member() + */ + }; /** - long doco of member() + Class documentation. */ -}; -/** - Class documentation. -*/ Unfortunately most of the code isn't really documented that good. -CLASSNAMES (2) +=head2 CLASSNAMES (2) A lot of classes in LilyPond start with 'P', this is to distinguish certain parts of LilyPond: the P stands for Printer, and the P-classes are supposed to be more lowlevel than the others. Example: - Staff uses PStaff, PScore and PCol to do the typesetting of +Staff uses PStaff, PScore and PCol to do the typesetting of symbols. Staff is the "brains" for PStaff NB: in PCursor (which is part of the library) P stands for PointerCursor -MEMBERS(2) +=head2 MEMBERS(2) Standard methods: diff --git a/Documentation/Makefile b/Documentation/Makefile index 7aa470764b..5eb21d58ce 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,6 +1,23 @@ +PODS=README.pod CodingStyle.pod lilygut.pod lilyinput.pod +TXTS=$(PODS:.pod=.txt) +MANS=$(PODS:.pod=.1) +DOCFILES=$(PODS) Makefile -DOCFILES=commands CodingStyle algorithms Makefile breaking\ - slurfont pointers design literature inputformat + +default: + $(MAKE) -C .. doc + +doc: $(TXTS) dist: - ln $(DOCFILES) $(DDIR)/Documentation/ \ No newline at end of file + ln $(DOCFILES) $(DDIR)/Documentation/ +clean: + rm -f $(TXTS) $(MANS) + +%.txt: %.1 + groff -man -Tascii $< > $@ + +%.1: %.pod + pod2man --center="LilyPond documentation" --section="0"\ + --release="LilyPond $(MAJVER).$(MINVER).$(PATCHLEVEL)" $< > $@ + diff --git a/Documentation/README.pod b/Documentation/README.pod new file mode 100644 index 0000000000..f7226fa03c --- /dev/null +++ b/Documentation/README.pod @@ -0,0 +1,165 @@ +=head1 NAME + +Lilypond - a music typesetter + +=head1 SYNOPSIS + + lilypond [options] [inputfiles] + +=head1 DESCRIPTION + +LilyPond typesets music. It translates script files (mudela files or +F<.ly>'s) into TeX input. + +=head1 OPTIONS + +=item B<-d,--debug> +debugging + +=item B<-w,--warranty> +warranty + +=item B<-o,--output> +default output file + +=item B<-h,--help> +help + +=head1 LICENSE + +GNU GPL. See file COPYING + +=head1 PREREQUISITES + +Compilation: + +=over 5 + +=item - Unix (any decent Linux distribution is fine) + +=item - GNU C++ v2.7 or better (with libg++ ) + +=item - GNU make. + +=item - flex (2.5.1 or better) + +=item - bison/yacc + +=item - The "flower" library, which should be available from the + same source you got this from. + +=item - perl + +=back + +Operation: + +=over 5 + +=item - TeX + +=item - the MusixTeX fonts + +=back + +The Makefile uses perl for trivial operations, and you could tinker +with it to use sed or awk. + +=head1 COMPILING + +Do: + + tar zxf flower-1.11.9.tar.gz + mv flower-1.11.9 flower + cd flower; make; cd .. + tar zxf lilypond-1.2.13.tar.gz + cd lilypond-1.2.13 + make + +why G++ >= 2.7? LilyPond & flower lib uses: + + builtin bool + typeof + operator ? + the new for-scope + class Rational (libg++) + +=head1 AUTHOR + +Han-Wen Nienhuys , + +=head1 EXAMPLES + +At this time, LilyPond is only suited for Quick & Dirty jobs (the +output quality still is too low). If you're not discouraged; this is +what I type in my xterm: + + lilypond someinput.ly + tex test + xdvi test& + +This is what the output looks like over here: + + hw:~/musix/spacer$ lilypond maartje.ly + LilyPond 0.0.17/FlowerLib 1.0.14. Compile: Dec 17 1996, 11:33:54 (g++ 2.7.2) + Parsing ... [symbol.ini][maartje.ly] + Processing ... Calculating ... Postprocessing ... + output to lelie.uit... + + hw:~/musix/spacer$ tex test + This is TeX, Version 3.14159 (C version 6.1) + (test.tex + Hyphenation patterns for english, dutch, loaded. + (lilyponddefs.tex) (lelie.uit) [1] [2] ) + Output written on test.dvi (2 pages, 8072 bytes). + Transcript written on test.log. + + hw:~/musix/spacer$ xdvi test& + [1] 1468 + +Check out kortjakje.ly, it has some comments + + +=head1 PROBLEMS + +If LilyPond bombs out, then please recompile using B<-g>, and send a gdb +stacktrace of the crash. It also helps if you can print the values of the objects. So if you trace is + + (gdb) backtrace 12 + #0 Interval::operator+= (this=0x11fffec60..) + at ../flower/interval.hh:50 + #1 0x12005195c in Item::width (this=0x14008a680) at src/item.cc:39 + #2 0x12008fdbc in itemlist_width (its=0x11fffed58 .. + : + : + +Than it would help if you send a dump of the Interval and the Item +(use: 'print *this' or use LilyPond print() methods). + +This is a beta version of LilyPond. Please send your helpful comments +and patches to me, + +LilyPond is updated very frequently, the latest version is always available at: + +F + + +=head1 FILES + +F The initialisation file with symbol tables etc. + +=head1 HOW DOES IT WORK + +=over 5 + +Use The Source, Luke. If you don't know C++, you can try editing +the file F<.dstreamrc> for copious debugging output. (use B<-d>) + +the subdir Documentation/ contains some more-in-depth matter on LilyPond + +The source is commented in the DOC++ style. +Check out doc++ at + + http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html + +=back diff --git a/Documentation/algorithms b/Documentation/algorithms deleted file mode 100644 index f422332e41..0000000000 --- a/Documentation/algorithms +++ /dev/null @@ -1,98 +0,0 @@ -Date: Tue, 5 Nov 1996 00:01:32 +0100 -From: Werner Icking -To: hanwen@stack.urc.tue.nl -Cc: dsimons@logicon.com -Subject: Re: font sizes. - -> Date: Mon, 4 Nov 1996 22:37:54 +0100 (MET) -> From: Han-Wen Nienhuys -> > -> >There were different schemes when music was typeset by hand. If I remember -> >right Harder uses another scheme that Gomberg. Both scheme may be used -> -> Who are Harder and Gomberg? Do you have references? - -Both are mentioned in the master thesis by Steinbach & Schofer who -invented M(u)TeX, the grandmother of all M...TeXs. The Musiclibrary -in Bonn has the harder (printed in 1948?) and there are not many books -I liked more to own. - -The master thesis should be available at the CTAN archives under MuTeX -or MTEX maybe subdirectory DIPL (for Diplom). I have the TEX-source -and I may pack it to ftp.gmd.de if you are interested and can't find it -on CTAN. -================================================================ - -[breaking lines] -> ->Incidentally, I use a different approach in PMX, starting with the ->total number of systems for the piece instead of assuming a starting ->physical value for \elemskip. That's equivalent to setting the ->physical length of the whole piece if laid out in one long line. ->Knowing the total amount of scalable and fixed space I compute a ->starting physical value for \elemskip. I use that to get how many ->bars go in the first line. Then I force a line break there, remove ->those bars and their scalable and fixed space from the accounting, and ->start over with the second line, etc. - - -Since you are getting into technical details, I will show mine too: I -think my way is the most elegant algorithm i've seen so far. Some -terminology: I call a vertical group of symbols (notes) which start at -the same time a "column". Each line of a score has notes in it, -grouped in columns. The difference in starting time between those -columns makes it possible to determine ideal distances between those -columns. - -Example: - - time -----> - - col1 col2 col3 col4 - - -voice1 1 1 - -voice2 2 2 2 2 - - -(1 is a whole note, 2 a half note.) - -time_difference (col1 , col2) = 0.5 wholes, -time_difference (col1 , col3) = 1 wholes, -time_difference (col2 , col3) = 0.5 wholes, -etc. - -these differences are translated into ideal distances (these translations -have been the subject of discussion in this thread). - - distance (col1,col2) = 10 pt - distance (col1,col3) = 14.1 pt - distance (col2,col3) = 10 pt - etc. - -as you can see, these distance are conflicting. So instead of -satisfying all those ideals simultaneously, a compromise is sought. - -This is Columbus' egg: LilyPond attaches "springs" to each -column-pair. each spring has an equilibrium-position which is equal to -the above mentioned distance, so - - spring (col1, col2) and spring(col2,col3) try to push column 1 -and 3 away (to a distance of 20pt) from each other, whereas the spring -between col 1 and col 3 tries to pull those two together (to a -distance of 14.1 pt). The net result of this pushing and pulling is an -equilibrium situation (the pushing cancels the pulling), which can be -calculated as the solution of Quadratic program: it is the solution -with minimum potential energy, for you physicists out there. - -This algorithm for doing one line, gives a "badness" parameter for -each line (the potential energy). Now one can use TeX's algorithm for -making paragraphs (using this new version of "badness"): one should -try to minimise the overall badness of a paragraph. LilyPond also uses the -concept of pre- and post-breaks. - -(actually, it is a bit more complicated: each column also has a -minimum distance to other columns, to prevent symbols from running -into symbols of other columns.) - diff --git a/Documentation/breaking b/Documentation/breaking deleted file mode 100644 index ea1ada7e10..0000000000 --- a/Documentation/breaking +++ /dev/null @@ -1,38 +0,0 @@ -[Source files: command.hh, scommands.cc] - -BREAKING, PREBREAK POSTBREAK, etc. - -So what's the deal with PREBREAK and POSTBREAK and all this -stuff? - -Let's take text as an example. In German some compound -words change their spelling if they are broken: "backen" becomes -"bak-ken". TeX has a mechanism to deal with this, you would define -the spelling of "backen" in TeX in this way - - \discretionary{bak-}{ken}{backen} - -These 3 arguments are called "prebreak", "postbreak" and "nobreak" -text. - -The same problem exists when typesetting music. If a line of music is -broken, the next line usually gets a clef. So in TeX terms, the clef -is a postbreak. The same thing happens with meter signs: Normally the -meter follows the bar. If a line is broken at that bar, the bar along -with the meter stays on the "last" line, but the next line also gets a -meter sign after the clef. Using the previous notation, - - \discretionary{bar meter}{clef meter}{ bar meter } - -In Lilypond, we have the same concepts (and the same -terminology). Each (nonrhythmic) symbol is typeset using a Command -(code: TYPESET). At a breakpoint, TYPESET commands can be grouped -using separators (in lower case): - - BREAK_PRE, typeset(bar), typeset(meter), - BREAK_MID, typeset(bar), typeset(meter), - BREAK_POST, typeset(clef), typeset(meter), BREAK_END - -The BREAK command sequence is terminated with BREAK_END, so other -commands (like INTERPRET) may follow this sequence. - diff --git a/Documentation/commands b/Documentation/commands deleted file mode 100644 index 00d5856c67..0000000000 --- a/Documentation/commands +++ /dev/null @@ -1,24 +0,0 @@ -This table decribes the proper order for the different commands: - - -interpret - which priority - ======================== - - key 200 - clef 190 - meter 180 - bar 170 - -typeset - - which priority - ======================== - - bar 100 - clef 90 - currentclef 80 - key 70 - currentkey 60 - meter 40 - \ No newline at end of file diff --git a/Documentation/design b/Documentation/design deleted file mode 100644 index e1a317a29e..0000000000 --- a/Documentation/design +++ /dev/null @@ -1,26 +0,0 @@ -LilyPond is a "5-pass" system: - -1. Parsing: - -No difficult algorithms. Associated datastructures have prefix Input -(eg Input_score, Input_command) - -2. Processing: - -Requests are processed and granted. In this step data-structures for -3. are created and filled with data: PScore, PCol, PStaff - -3. Calculation: - -This step uses structures which have names starting with 'P'. -linebreaks and horizontal positions of PCols are determined. Line_of_* -generated. - -4. Postprocesing: - -Some items and all spanners need computation after the PCol positions -are determined. - -5. Output - -Very simple, just walk all Line_of_* and follow the links over there \ No newline at end of file diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod new file mode 100644 index 0000000000..5707dcfef9 --- /dev/null +++ b/Documentation/lilygut.pod @@ -0,0 +1,260 @@ +=head1 NAME + +LilyGuts - doco to the internals of LilyPond + +=head1 DESCRIPTION + +This page documents some aspects of the internals of LilyPond + +=head1 OVERVIEW + +LilyPond is a "5-pass" system: + +=over 5 + +=item 1. Parsing: + +No difficult algorithms. Associated datastructures have prefix Input +(eg Input_score, Input_command) + +=item 2. Processing: + +Requests are processed and granted. In this step data-structures for +3. are created and filled with data: PScore, PCol, PStaff + +=item 3. Calculation: + +This step uses structures which have names starting with 'P'. +linebreaks and horizontal positions of PCols are determined. Line_of_* +generated. + +=item 4. Postprocesing: + +Some items and all spanners need computation after the PCol positions +are determined. + +=item 5. Output + +Very simple, just walk all Line_of_* and follow the links over there + +=back + +=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: command.hh, scommands.cc] + +BREAKING, PREBREAK POSTBREAK, etc. + +So what's the deal with PREBREAK and POSTBREAK and all this +stuff? + +Let's take text as an example. In German some compound +words change their spelling if they are broken: "backen" becomes +"bak-ken". TeX has a mechanism to deal with this, you would define +the spelling of "backen" in TeX in this way + + \discretionary{bak-}{ken}{backen} + +These 3 arguments are called "prebreak", "postbreak" and "nobreak" +text. + +The same problem exists when typesetting music. If a line of music is +broken, the next line usually gets a clef. So in TeX terms, the clef +is a postbreak. The same thing happens with meter signs: Normally the +meter follows the bar. If a line is broken at that bar, the bar along +with the meter stays on the "last" line, but the next line also gets a +meter sign after the clef. Using the previous notation, + + \discretionary{bar meter}{clef meter}{ bar meter } + +In Lilypond, we have the same concepts (and the same +terminology). Each (nonrhythmic) symbol is typeset using a Command +(code: TYPESET). At a breakpoint, TYPESET commands can be grouped +using separators (in lower case): + + BREAK_PRE, typeset(bar), typeset(meter), + BREAK_MID, typeset(bar), typeset(meter), + BREAK_POST, typeset(clef), typeset(meter), BREAK_END + +The BREAK command sequence is terminated with BREAK_END, so other +commands (like INTERPRET) may follow this sequence. + +=head1 SPACING + +I think my way is the most elegant algorithm i've seen so far. Some +terminology: I call a vertical group of symbols (notes) which start at +the same time a "column". Each line of a score has notes in it, +grouped in columns. The difference in starting time between those +columns makes it possible to determine ideal distances between those +columns. + +Example: + + time -----> + + col1 col2 col3 col4 + + + voice1 1 1 + + voice2 2 2 2 2 + + + (1 is a whole note, 2 a half note.) + + time_difference (col1 , col2) = 0.5 wholes, + time_difference (col1 , col3) = 1 wholes, + time_difference (col2 , col3) = 0.5 wholes, + etc. + +these differences are translated into ideal distances (these translations +have been the subject of discussion in this thread). + + distance (col1,col2) = 10 pt + distance (col1,col3) = 14.1 pt + distance (col2,col3) = 10 pt + etc. + +as you can see, these distance are conflicting. So instead of +satisfying all those ideals simultaneously, a compromise is sought. + +This is Columbus' egg: LilyPond attaches "springs" to each +column-pair. each spring has an equilibrium-position which is equal to +the above mentioned distance, so + + spring (col1, col2) and spring(col2,col3) try to push column 1 +and 3 away (to a distance of 20pt) from each other, whereas the spring +between col 1 and col 3 tries to pull those two together (to a +distance of 14.1 pt). The net result of this pushing and pulling is an +equilibrium situation (the pushing cancels the pulling), which can be +calculated as the solution of Quadratic program: it is the solution +with minimum potential energy, for you physicists out there. + +This algorithm for doing one line, gives a "badness" parameter for +each line (the potential energy). Now one can use TeX's algorithm for +making paragraphs (using this new version of "badness"): one should +try to minimise the overall badness of a paragraph. LilyPond also uses the +concept of pre- and post-breaks. + +(actually, it is a bit more complicated: each column also has a +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 + +Herbert Chlapik, + +W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In +``Document Manipulation and Typography'', J.C. van Vliet (ed) 1988. + +Ross, Ted. ``Teach yourself the art of music engraving and processing'' +(3rd edition). Hansen House, Miami Beach, FL. + + Hansen House + 1820 West Ave. + Miami, FL 33139 + (305) 532-5461 + +[This is about *engraving* i.e. professional music typesetting, and includes +some good spacing tables] + +Read, Gardner. ``Modern Rhythmic Notation.'' Indiana University Press, 1978. + +Read, Gardner. ``Music Notation'' (2nd edition). Taplinger Publishing, +New York. + +[This is as close to the ``standard'' reference work for music notation issues +as one is likely to get.] + + +=head2 Further reading + +(of varying usefulness): + +Donato, Anthony. Preparing Music Manuscript. Englewood Cliffs: +Prentice-Hall, 1963. + +Donemus. "Uitgeven van muziek". Donemus Amsterdam, 1900 + +Heussenstamm, George. The Norton Manual of Music Notation. New York: +Norton, 1987. + +Karkoshka, Erdhard. Notation in New Music. Trans. Ruth Koenig. New York: +Praeger Publishers, 1972. Out of print. + +Roelofs, Ren\'e. ``Een Geautomatiseerd Systeem voor het Afdrukken van +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. + +Rosecrans, Glen. Music Notation Primer. New York: Passantino, 1979. + +Stone, Kurt. Music Notation in the Twentieth Century. New York: Norton, 1980. + + diff --git a/Documentation/inputformat b/Documentation/lilyinput.pod similarity index 59% rename from Documentation/inputformat rename to Documentation/lilyinput.pod index d82c02b2e5..99c58aaee2 100644 --- a/Documentation/inputformat +++ b/Documentation/lilyinput.pod @@ -1,3 +1,13 @@ +=head1 NAME + +LilyInput - LilyPond input format + +=head1 DESCRIPTION + +This page documents the the LilyPond input format, mudela. + +=head2 Overview + General format of a construct: BLOCKNAME { } @@ -28,34 +38,40 @@ than in "command" mode, eg, So you have to signal that to the tokenizer. This is done with '$'. '$' is a delimiter, which used by the tokenizer only. -* musicmode: The brace still is used to group grammatical groups. -* musicmode: "word" are preceded by a '\' (backslash) +=item * +musicmode: The brace still is used to group grammatical groups. + +=item * +musicmode: "word" are preceded by a '\' (backslash) This means you can write some stuff in a zillion ways: -1. $\var = \blockname { ... } $ +=item 1. + $\var = \blockname { ... } $ -2. var = blockname { $ ... $ } +=item 2. + var = blockname { $ ... $ } -3. var = $ $ $\blockname { ... $ } +=item 3. + var = $ $ $\blockname { ... $ } -COMMENTS +=head2 Comments -not really crystallized; you can use '#' or '%' as line comment +Not really crystallized; you can use '#' or '%' as line comment -OTHER +=head2 other A correctly parsed .ly does not guarantuee output. A lot (most) of the -checking is done *after* parsing (some checks even are done after the +checking is done B parsing (some checks even are done after the break calc!); I'm sorry. The parser's job is to construct appropriate objects. It will *only* detect parse errors. LilyPond first reads 'symbol.ini', which contains declarations crucial -to proper operation of LilyPond (symbol tables, note names) +to proper operation of LilyPond (symbol tables, note names). This language looks a lot like Rayce's which in turn owes a lot to the POVRay raytracer. Now, I know, musictypesetting and Raytracing do not necessarily require the same input format, but I was just to lazy to -make up a new/better input format. Suggestions welcome. +make up a new and/or better input format. Suggestions welcome. diff --git a/Documentation/literature b/Documentation/literature deleted file mode 100644 index 0085806013..0000000000 --- a/Documentation/literature +++ /dev/null @@ -1,76 +0,0 @@ -\chapter{References \& Further reading} - -Herbert Chlapik, - -Ren\'e Roelofs, ``Een Geautomatiseerd Systeem voor het Afdrukken van -Muziek'' afstudeerscriptie Bestuurlijke informatica, no 45327, Erasmus -universiteit Rotterdam, 1991. (``An automated system for printing -music'' Master's Thesis Management and Computer Science.) - -G. Read, ``Modern Rhythmic Notation.'' Indiana University Press, 1978. - -C. Roemer, The Art of Music Copying. Roerick music co., Sherman Oaks (CA), 1973. - -Donemus, Uitgeven van muziek. Donemus Amsterdam, 1900 - -W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In -``Document Manipulation and Typography'',J.C. van Vliet (ed) 1988. - -\begin{verbatim} -Date: Thu, 03 Aug 1995 22:55:48 -0700 -From: Mark Basinski -To: Han-Wen Nienhuys -Newsgroups: comp.music, comp.text.tex -Subject: Re: [WANTED] references on typesetting music - -(A copy of this message has also been posted to the following newsgroups: -comp.music, comp.text.tex) - -In article <3vqr50$den@turtle.stack.urc.tue.nl>, hanwen@stack.urc.tue.nl -(Han-Wen Nienhuys) wrote: - -> I am currently typesetting music with a preprocessor to the TeX package -> MusiXTeX, and I want to enhance this preprocessor with an some sort of -> algorithm to do spacing. Currently the output looks nice, but there are some -> flaws in the spacing when I combine accidentals, slurs, triplets and strange -> pitchjumps and so on. Therefore I am interested in all literature on -> typesetting music. The FAQS for comp.music did not have any references. -> -Probably the best 2 reference books are: - -1) ``Teach yourself the art of music engraving and processing'' by Ted Ross -(3rd edition), published by Hansen House, Miami Beach, FL. - -Hansen House -1820 West Ave. -Miami, FL 33139 -(305) 532-5461 - -This is about *engraving* i.e. professional music typesetting, and includes -some good spacing tables - -2) ``Music Notation'' by Gardner Read (2nd edition), published by Taplinger -Publishing, New York. - -This is as close to the ``standard'' reference work for music notation issues -as one is likely to get. - -Some others (of varying usefulness): - -Donato, Anthony. Preparing Music Manuscript. Englewood Cliffs: -Prentice-Hall, 1963. - -Heussenstamm, George. The Norton Manual of Music Notation. New York: -Norton, 1987. - -Karkoshka, Erdhard. Notation in New Music. Trans. Ruth Koenig. New York: -Praeger Publishers, 1972. Out of print. - -Roemer, Clinton. The Art of Music Copying. Roerick Music. Sherman Oaks, 1973. - -Rosecrans, Glen. Music Notation Primer. New York: Passantino, 1979. - -Stone, Kurt. Music Notation in the Twentieth Century. New York: Norton, 1980. - -\end{verbatim} - diff --git a/Documentation/pointers b/Documentation/pointers deleted file mode 100644 index 45e2479d3f..0000000000 --- a/Documentation/pointers +++ /dev/null @@ -1,31 +0,0 @@ -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) - diff --git a/Documentation/slurfont b/Documentation/slurfont deleted file mode 100644 index fda65e193a..0000000000 --- a/Documentation/slurfont +++ /dev/null @@ -1,43 +0,0 @@ -How are slur fonts organised? - -xhslu20: see xslhu20 - -xslhu20: half slurs, pointing up - right - width in steps of 12pt (12pt-96pt) - height in 16 steps - left - idem - -xslhd20: half slurs, pointing down, idem - -xslu20: whole slurs, ascending - pointing up - height (dy) in 8 steps - width in 16 steps of 4pt (8 pt - 64pt) - pointing down - height (dy) in 8 steps - width in steps of 4pt (8 pt - 64pt) - -xsld20: whole slurs, descending - pointing up - height (dy) in 8 steps - width in steps of 4pt (8 pt - 60pt) - pointing down - height (dy) in 8 steps - width in steps of 4pt (8 pt - 60pt) - - -xslhz: middlepieces for half-slurs - pointing up - width in 100 steps of 4 pt (4 pt to 400pt) - pointing down - idem - -xslz: horizontal slurs - pointing up - width in 54 steps of 4pt - pointing down - idem - -xtie: same as xslhz. diff --git a/Makefile b/Makefile index d0bdffd022..cb118a3ea2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ include Variables.make .SUFFIXES: -.SUFFIXES: .cc .o .hh .y .l +.SUFFIXES: .cc .o .hh .y .l .pod .txt .1 $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) @@ -18,7 +18,10 @@ distclean: clean all: kompijl doc # doc++ documentation of classes -doc: $(progdocs) +doc: + $(MAKE) -C Documentation doc + +docpp: $(progdocs) -mkdir $(DOCDIR) doc++ -p -I -d $(DOCDIR) $^ diff --git a/NEWS b/NEWS index ab7f8437f6..27be7f4bd2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +pl 20: + - Rational for time measurement + - updated doco to .pod + - directionalspanner/textspanner + - include files + pl 19: - struct Moment - grouping code: LilyPond can set advanced multibeams. diff --git a/README b/README index c936c13e29..94d352fc50 100644 --- a/README +++ b/README @@ -1,116 +1,7 @@ --*-text-*- +Please refer to the directory Documentation/. -last update: 96/17/12, 0.0.17 +To generate the pretty-printed docs, do a: -LICENSE + make doc -See file COPYING - -INTRODUCTION - -This is a beta version of LilyPond (a music typesetter). Please send -your helpful comments and patches to me, - - hanwen@stack.nl - -LilyPond is updated very frequently, the latest version is always available at: - - ftp://pcnov095.win.tue.nl/pub/lilypond - -PREREQUISITES - -Compilation: - - - Unix (any decent Linux distribution is fine) - - GNU C++ v2.7 or better - - GNU make. - - flex (2.5.1 or better) - - bison/yacc - - The "flower" library, which should be available from the - same source you got this from. - - perl - -Operation: - - - TeX - - the MusixTeX fonts - -The Makefile uses perl for trivial operations, and you could tinker -with it to use sed or awk. - -COMPILING - -Do: - - tar zxf flower-1.11.9.tar.gz - mv flower-1.11.9 flower - cd flower; make; cd .. - tar zxf lilypond-1.2.13.tar.gz - cd lilypond-1.2.13 - make - -why G++ >= 2.7? LilyPond & flower lib uses: - - builtin bool - typeof - operator ? - new for-scope - -USING - -At this time, LilyPond is only suited for Quick & Dirty jobs (the -output quality still is too low). If you're not discouraged; this is -what I type in my xterm: - - lilypond someinput.ly - tex test - xdvi test& - -This is what the output looks like over here: - - hw:~/musix/spacer$ lilypond maartje.ly - LilyPond 0.0.17/FlowerLib 1.0.14. Compile: Dec 17 1996, 11:33:54 (g++ 2.7.2) - Parsing ... [symbol.ini][maartje.ly] - Processing ... Calculating ... Postprocessing ... - output to lelie.uit... - - hw:~/musix/spacer$ tex test - This is TeX, Version 3.14159 (C version 6.1) - (test.tex - Hyphenation patterns for english, dutch, loaded. - (lilyponddefs.tex) (lelie.uit) [1] [2] ) - Output written on test.dvi (2 pages, 8072 bytes). - Transcript written on test.log. - - hw:~/musix/spacer$ xdvi test& - [1] 1468 - -Check out kortjakje.ly, it has some comments - - -PROBLEMS - -If LilyPond bombs out, then please recompile using -g, and send a gdb -stacktrace of the crash. It also helps if you can print the values of the objects. So if you trace is - -(gdb) backtrace 12 -#0 Interval::operator+= (this=0x11fffec60, r=-1.7976931348623157e+308) - at ../flower/interval.hh:50 -#1 0x12005195c in Item::width (this=0x14008a680) at src/item.cc:39 -#2 0x12008fdbc in itemlist_width (its=0x11fffed58) at src/simpleprint.cc:40 - : - : - -Than it would help if you send a dump of the Interval and the Item (use: 'print *this' or use LilyPond print() methods) - -HOW DOES IT WORK - -* Use The Source, Luke. If you don't know C++, you can try editing -.dstreamrc for copious debugging output. (use -d) - -* the subdir Documentation/ contains some more-in-depth matter on LilyPond - -* The source is commented in the DOC++ style. -Check out doc++ at - - http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html +in the top-level dir \ No newline at end of file diff --git a/Sources.make b/Sources.make index 53977c778b..a04e3dd03c 100644 --- a/Sources.make +++ b/Sources.make @@ -9,20 +9,22 @@ hdr= qlp.hh linespace.hh qlpsolve.hh\ parseconstruct.hh debug.hh globvars.hh keyword.hh\ misc.hh score.hh notename.hh lexer.hh symtable.hh\ symbol.hh main.hh dimen.hh paper.hh lookup.hh\ + spanner.hh beam.hh directionalspanner.hh slur.hh textspanner.hh\ sccol.hh stcol.hh staffcommands.hh melodicstaff.hh\ - identifier.hh simplestaff.hh spanner.hh stem.hh\ - notehead.hh leastsquares.hh beam.hh rest.hh\ + identifier.hh simplestaff.hh stem.hh\ + notehead.hh leastsquares.hh rest.hh\ swalker.hh bar.hh meter.hh accidental.hh\ key.hh keyitem.hh localkeyitem.hh simplewalker.hh\ - clef.hh clefitem.hh slur.hh inputcommands.hh\ - getcommand.hh inputmusic.hh \ + clef.hh clefitem.hh inputcommands.hh\ + getcommand.hh inputmusic.hh timedescription.hh\ inputscore.hh inputstaff.hh identparent.hh\ - inputcommand.hh grouping.hh moment.hh + inputcommand.hh grouping.hh moment.hh offset.hh + mycc= qlp.cc qlpsolve.cc leastsquares.cc\ inputcommands.cc inputmusic.cc \ - inputscore.cc inputstaff.cc\ - moment.cc\ + inputscore.cc inputstaff.cc inputcommand.cc\ + timedescription.cc\ break.cc linespace.cc molecule.cc staffline.cc\ pscore.cc tex.cc item.cc pcol.cc staff.cc \ rhythmstaff.cc score.cc note.cc main.cc misc.cc\ @@ -34,15 +36,16 @@ mycc= qlp.cc qlpsolve.cc leastsquares.cc\ dimen.cc paper.cc lookup.cc staffcommands.cc\ sccol.cc stcol.cc getcommands.cc simplestaff.cc\ melodicstaff.cc simpleprint.cc\ - spanner.cc \ + spanner.cc textspanner.cc directionalspanner.cc \ notehead.cc stem.cc \ rest.cc bar.cc meter.cc keyitem.cc localkeyitem.cc clefitem.cc\ swalker.cc scoreline.cc\ simplewalker.cc\ texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\ - idealspacing.cc inputcommand.cc grouping.cc identifier.cc\ + idealspacing.cc grouping.cc identifier.cc\ lexerinit.cc mylexer.cc\ template1.cc template2.cc template3.cc template4.cc\ + template5.cc\ version.cc diff --git a/Variables.make b/Variables.make index 32bffdfc97..ac306c7832 100644 --- a/Variables.make +++ b/Variables.make @@ -5,14 +5,14 @@ #PROFILEFLAG=-pg OPTIFLAG=-DNDEBUG -DNPRINT -O2 DEBUGFLAG=-g + # turn off -pipe if linker doesn't support it EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes -# -Woverloaded-virtual # # -lefence = ElectricFence. # -# ElectricFence is memory debugger which uses the +# ElectricFence is a memory debugger which uses the # VM hardware to trap malloc/free errors. # #EXTRALIB+=-lefence @@ -37,7 +37,7 @@ endif # version info MAJVER=0 MINVER=0 -PATCHLEVEL=19 +PATCHLEVEL=20 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) CXXVER=`$(CXX) --version` @@ -49,7 +49,7 @@ TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) OBJECTDIR=objects HEADERDIR=hdr CCDIR=src - +INITDIR=init vpath %.cc $(CCDIR) vpath %.hh $(HEADERDIR) vpath %.y $(CCDIR) @@ -77,7 +77,7 @@ DNAME=$(PACKAGENAME)-$(VERSION) othersrc=lexer.l parser.y SCRIPTS=make_version make_patch genheader IFILES=dimen.tex symbol.ini kortjakje.ly pavane.ly maartje.ly\ - lilyponddefs.tex test.tex .dstreamrc + lilyponddefs.tex test.tex .dstreamrc cadenza.ly OFILES=Makefile Variables.make Sources.make COPYING README NEWS DFILES=$(OFILES) $(IFILES) $(SCRIPTS) @@ -91,4 +91,4 @@ BISON=bison exe=$(PACKAGENAME) OUTPUT_OPTION=$< -o $@ DDIR=$(TOPDIR)/$(DNAME) -SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR) +SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR) $(INITDIR) diff --git a/cadenza.ly b/cadenza.ly new file mode 100644 index 0000000000..0ed66019c0 --- /dev/null +++ b/cadenza.ly @@ -0,0 +1,35 @@ +% +% Cadenza to Mozart Horn/3 +% + +cad = music { $ + \duration { 8} + 'c4. g8 ['e()'d 'c b] + [b()c] g c [c e g 'c] + \octave{'} + e4. e [g ()f e d] + + \duration{16} + dis4()e4 r8 [c d] [e f g gis] + \duration{4} + a `f()`e g + f `d()`cis e + \duration{8} + d4 r8 `a [`b cis] + \duration{16} + [d cis d e] + f4()[f e d c] `b4 + \octave{} ['c8 b8] % triplet! + g2 [g c e g] ['c e g 'c]\octave{'} + [e `g c e] g4 %()% BUG! + [g8.( e g8. )e] + a4. g8 [f8 e8 d8 c8] + `g2 d2 + c4 $} + +score { + staff { melodic + music { cad } + } + commands { meter 4 4 skip 13:0 } +} \ No newline at end of file diff --git a/flower/Sources.make b/flower/Sources.make index eae2acaf4d..c0097bdcf8 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,7 +1,7 @@ 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 + matdebug.cc scalar.cc path.cc templatecc=cursor.tcc list.tcc tsmat.tcc plist.tcc interval.tcc\ pcursor.tcc @@ -13,5 +13,6 @@ hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.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 sstack.hh rational.hh iterate.hh\ + path.hh diff --git a/flower/Variables.make b/flower/Variables.make index c1801c14c4..8bf3820ffc 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=19 +PATCHLEVEL=20 PACKAGENAME=flower #PROFILEFLAG=-pg diff --git a/flower/dstream.cc b/flower/dstream.cc index fc50506195..44e2057059 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -118,7 +118,7 @@ Dstream::Dstream(ostream *r, const char * cfg_nm ) r.message("not enough fields in Dstream init."); continue; } - (*silent)[r[0]] = Scalar(r[1]).to_bool(); + (*silent)[r[0]] = bool(Scalar(r[1])); } } diff --git a/flower/interval.tcc b/flower/interval.tcc index 46b4fc7e16..0a1a027acd 100644 --- a/flower/interval.tcc +++ b/flower/interval.tcc @@ -4,10 +4,9 @@ #include "string.hh" - template int -Interval__compare(const Interval_t&a,Interval_t const&b) +_Interval__compare(const Interval_t&a,Interval_t const&b) { if (a.left == b.left && a.right == b.right) return 0; @@ -18,16 +17,30 @@ Interval__compare(const Interval_t&a,Interval_t const&b) if (a.left >= b.left && a.right <= b.right) return -1; - assert(false); // not comparable + return -2; +} + - return 0; +template +int +Interval__compare(const Interval_t&a,Interval_t const&b) +{ + int i = _Interval__compare(a,b); + if (i < -1) + assert(false); + return i; } +#ifdef AIX +const Real INFTY = 1e8; // ARGh. AIX sucks +#else const Real INFTY = HUGE; +#endif template void -Interval_t::set_empty() { +Interval_t::set_empty() +{ left = INFTY; right = -INFTY; } diff --git a/flower/path.cc b/flower/path.cc new file mode 100644 index 0000000000..2fd7eea3cb --- /dev/null +++ b/flower/path.cc @@ -0,0 +1,81 @@ +/* + path.cc - manipulation of paths and filenames. +*/ +#include +#include "path.hh" + +#ifndef PATHSEP +#define PATHSEP '/' +#endif + + +void +split_path(String path, + String &drive, String &dirs, String &filebase, String &extension) +{ + // peel off components, one by one. + int di = path.pos(':'); + if (di) + { + drive = path.left(di); + path = path.right(path.len() - di); + } + else + drive = ""; + + di = path.lastPos(PATHSEP); + if (di) + { + dirs = path.left(di); + path = path.right(path.len()-di); + } + else + dirs = ""; + + di = path.lastPos('.'); + if (di) + { + di --; // don't forget '.' + filebase = path.left(di); + extension =path.right(path.len()-di); + } + else + { + extension = ""; + filebase = path; + } +} +/** + INPUT: path the original full filename + OUTPUT: 4 components of the path. They can be empty +*/ + + +File_path::File_path(String pref) +{ + add("."); + add(pref); +} + + +/// +String +File_path::find(String nm) +{ + for (int i=0; i < size(); i++) { + String path = (*this)[i]; + path+= "/"+nm; + + + FILE *f = fopen(path, "r"); // ugh! + if (f) { + fclose(f); + return path; + } + } + return ""; +} +/** + It will search in the current dir, in the construction-arg, and + in any other added path, in this order. + */ diff --git a/flower/path.hh b/flower/path.hh new file mode 100644 index 0000000000..fceaeed647 --- /dev/null +++ b/flower/path.hh @@ -0,0 +1,32 @@ +#ifndef PATH_HH +#define PATH_HH +#include "string.hh" +#include "varray.hh" + + +/// searching directory for file. +class File_path : private Array +{ +public: + /// locate a file in the search path + String find(String nm); + + /// construct using prefix. Normally argv[0]. + File_path(String); + + /// add to end of path. + Array:: add; +}; +/** + + Abstraction of PATH variable. An interface for searching input files. + Search a number of dirs for a file. + + Should use kpathsea? + +*/ + +/// split path into its components +void split_path(String path, String &drive, String &dirs, String &filebase, String &extension); + +#endif diff --git a/flower/pcursor.hh b/flower/pcursor.hh index 383a450a1a..a6b99c9097 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -18,8 +18,8 @@ struct PCursor : private Cursor { void junk(); public: Cursor::ok; - void del() { junk(); Cursor::del(); } - void backspace() { junk(); Cursor::backspace(); } + Cursor::del; + Cursor::backspace; T get() { T p = ptr(); Cursor::del(); diff --git a/flower/plist.hh b/flower/plist.hh index 0aedfba60b..f5913c1299 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -24,7 +24,8 @@ class PointerList : public List void concatenate(PointerList const &s) { List::concatenate(s); } PointerList() {} }; -/** This class does no deletion of the pointers, but it knows how to +/** + 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. */ @@ -47,6 +48,7 @@ struct IPointerList : public PointerList { You have to copy this yourself, or use the macro PointerList__copy */ + #define IPointerList__copy(T, to, from, op) \ for (PCursor _pc_(from); _pc_.ok(); _pc_++)\ to.bottom().add(_pc_->op)\ @@ -57,8 +59,10 @@ template void PL_copy(IPointerList &dst,IPointerList const&src); -#define PL_instantiate(a) template class PointerList -#define IPL_instantiate(a) PL_instantiate(a); template class IPointerList +#define PL_instantiate(a) template class PointerList; \ + template class PCursor; +#define IPL_instantiate(a) PL_instantiate(a); \ + template class IPointerList #include "plist.inl" diff --git a/flower/plist.tcc b/flower/plist.tcc index 69986035d2..1dea8cefc1 100644 --- a/flower/plist.tcc +++ b/flower/plist.tcc @@ -5,7 +5,7 @@ IPointerList::~IPointerList() { PCursor c( *this ); while (c.ok()) { - c.del(); + delete c.get(); } } diff --git a/flower/scalar.cc b/flower/scalar.cc index f981bc101f..d8e6f9e74b 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -43,8 +43,8 @@ Scalar::operator int() return value(); } -bool -Scalar::to_bool() const + +Scalar::operator bool() const { if (!len()) return false; diff --git a/flower/scalar.hh b/flower/scalar.hh index 67ae85beda..bff21618c6 100644 --- a/flower/scalar.hh +++ b/flower/scalar.hh @@ -24,7 +24,7 @@ struct Scalar : public String { operator Real(); operator int(); /// - bool to_bool() const; + operator bool() const; /** perl -like string to bool conversion */ diff --git a/flower/smat.cc b/flower/smat.cc index c2177d4c99..9c3b8e2a97 100644 --- a/flower/smat.cc +++ b/flower/smat.cc @@ -14,7 +14,7 @@ Full_storage::operator=(Full_storage const &fs) void Full_storage::OK() const { - #ifndef NDEBUG +#ifndef NDEBUG // static Real dummy; assert(maxh >= h && maxw >= w); assert(h >= 0 && w >= 0); @@ -29,7 +29,7 @@ Full_storage::OK() const } #endif } - #endif +#endif } void Full_storage::resize_cols(int newh) diff --git a/flower/sstack.hh b/flower/sstack.hh index fb4d68c3a5..11c39a0f41 100644 --- a/flower/sstack.hh +++ b/flower/sstack.hh @@ -12,7 +12,7 @@ /// A simple stack based on Array. template struct sstack : Array { - T top() { return last(); } + T top()const { return last(); } T pop() { assert(!empty()); T l = last(); diff --git a/hdr/beam.hh b/hdr/beam.hh index 0032b67e17..e376f00978 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -7,23 +7,23 @@ #ifndef BEAM_HH #define BEAM_HH #include "proto.hh" -#include "spanner.hh" +#include "directionalspanner.hh" #include "plist.hh" /// a beam connects multiple stems -struct Beam: public Spanner { +struct Beam: public Directional_spanner { PointerList stems; Real slope; Real left_pos; - /// -1 below heads, +1 above heads. - int dir; + /// dir: -1 below heads, +1 above heads. + Rhythmic_grouping *group; /****************/ virtual Interval width()const; - + Offset center() const; Spanner *broken_at(PCol *, PCol *) const; Beam(); void add(Stem*); diff --git a/hdr/boxes.hh b/hdr/boxes.hh index 5bc2cb2e73..d817dc42e8 100644 --- a/hdr/boxes.hh +++ b/hdr/boxes.hh @@ -8,35 +8,8 @@ #include "fproto.hh" #include "real.hh" #include "interval.hh" - - -/// 2d vector -struct Offset { - Real x,y; - - Offset operator+(Offset o)const { - Offset r(*this); - r+=o; - return r; - } - - Offset operator+=(Offset o) { - x+=o.x; - y+=o.y; - return *this; - } - Offset(Real ix , Real iy) { - x=ix; - y=iy; - } - Offset() { - x=0.0; - y=0.0; - } -}; - - -/// a 4-tuple of #Real#s +#include "offset.hh" +/// a square subset of Real^2 struct Box { Interval x, y; @@ -48,7 +21,6 @@ struct Box { x.unite(b.x); y.unite(b.y); } - Box(svec &); Box(); Box(Interval ix, Interval iy); }; diff --git a/hdr/command.hh b/hdr/command.hh index 26e47ffa1f..43d016bbee 100644 --- a/hdr/command.hh +++ b/hdr/command.hh @@ -16,7 +16,6 @@ enum Commandcode { struct Command { Commandcode code; -// Real when; /// analogous to argv[] svec args; @@ -28,7 +27,7 @@ struct Command { /****************/ Command(); -// Command(Real w); +// Command(Moment w); bool isbreak()const; void print() const; }; diff --git a/hdr/directionalspanner.hh b/hdr/directionalspanner.hh new file mode 100644 index 0000000000..3c734b3474 --- /dev/null +++ b/hdr/directionalspanner.hh @@ -0,0 +1,25 @@ +/* + directionalspanner.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef DIRECTIONALSPANNER_HH +#define DIRECTIONALSPANNER_HH + +#include "spanner.hh" + +struct Directional_spanner : Spanner{ + + /// -1 below heads, +1 above heads. + int dir; + + /// offset of "center" relative to left-column/0-pos of staff + virtual Offset center() const=0; + virtual void set_default_dir()=0; + Directional_spanner(); + +}; + +#endif // DIRECTIONALSPANNER_HH + diff --git a/hdr/grouping.hh b/hdr/grouping.hh index da1ddd2ce3..d1c9bac139 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -7,34 +7,36 @@ #ifndef GROUPING_HH #define GROUPING_HH +#include "moment.hh" #include "interval.hh" #include "vray.hh" +typedef Interval_t MInterval; /// data structure which represents rhythmic units struct Rhythmic_grouping { svec children; - Interval *interval_; + MInterval *interval_; /****************/ - svec intervals(); - Interval interval()const; - Real length() const; - void intersect(Interval); + svec intervals(); + MInterval interval()const; + Moment length() const; + void intersect(MInterval); void operator=(Rhythmic_grouping const&); Rhythmic_grouping(Rhythmic_grouping const&); - Rhythmic_grouping(Interval, int n=1); + Rhythmic_grouping(MInterval, int n=1); Rhythmic_grouping(); Rhythmic_grouping(svec); ~Rhythmic_grouping(); - void add_child(Real start, Real len); + void add_child(Moment start, Moment len); void split(Rhythmic_grouping r); - void split(svec); + void split(svec); void split(int n); void print() const; diff --git a/hdr/inputcommand.hh b/hdr/inputcommand.hh index fff2f1a1f3..639b6542e1 100644 --- a/hdr/inputcommand.hh +++ b/hdr/inputcommand.hh @@ -9,13 +9,14 @@ #include "proto.hh" #include "scalar.hh" #include "vray.hh" +#include "moment.hh" struct Input_command { /// analogous to argv[] svec args; void print()const; Input_command(); - Input_command(Real); + operator Command(); }; @@ -23,9 +24,8 @@ Input_command* get_meterchange_command( int,int); Input_command* get_key_interpret_command(svec); Input_command* get_clef_interpret_command(String w); Input_command *get_reset_command(); -Input_command *get_partial_command(Real u); -Input_command *get_skip_command(int,Real); -Input_command *get_grouping_command(Real,svec); +Input_command *get_partial_command(Moment u); +Input_command *get_skip_command(int,Moment); Input_command *get_grouping_command(svec); Input_command *get_bar_command( ); diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh index 527986e6ea..e2c487f204 100644 --- a/hdr/inputcommands.hh +++ b/hdr/inputcommands.hh @@ -11,29 +11,29 @@ #include "proto.hh" #include "plist.hh" #include "real.hh" -#include "moment.hh" +#include "timedescription.hh" struct Commands_at : public IPointerList { - Moment moment_; + Time_description tdescription_; /****************/ - Real when(); + Moment when(); void parse(Staff_commands_at*); void print() const; - Real barleft(); + Moment barleft(); void add(Input_command*); - void setpartial(Real); + void setpartial(Moment); Commands_at(const Commands_at&); - Commands_at(Real, Commands_at*prev); + Commands_at(Moment, Commands_at*prev); }; struct Input_cursor : public PCursor { /****************/ Input_cursor(PCursor); - Real when()const; - void find_moment(Real w); + Moment when()const; + void find_moment(Moment w); void prev() { operator --(0); } void next() { operator ++(0); } }; @@ -44,9 +44,9 @@ struct Input_commands : public IPointerList { /****************/ - void find_moment(Real); + void find_moment(Moment); void add(Input_command c); - void do_skip(int bars, Real wholes); + void do_skip(int bars, Moment wholes); Input_commands(); Input_commands(Input_commands const&); @@ -56,10 +56,5 @@ struct Input_commands : public IPointerList { Staff_commands *parse() const; }; - - -void -interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, - Real& whole_per_measure); #endif // INPUTCOMMANDS_HH diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index d3286135f8..5b6da2968a 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -10,16 +10,17 @@ #include "plist.hh" #include "proto.hh" #include "voice.hh" +#include "moment.hh" struct Voice_list : public PointerList { - void translate_time(Real dt); + void translate_time(Moment dt); }; /// ABC for input structures struct Input_music { virtual Voice_list convert()=0; - virtual Real length()=0; - virtual void translate_time(Real dt)=0; + virtual Moment length()=0; + virtual void translate_time(Moment dt)=0; virtual ~Input_music(){} virtual void print() const =0; // virtual void transpose(...) const =0; @@ -47,9 +48,9 @@ struct Simple_music : Input_music { /****/ virtual Simple_music*simple() { return this; } void add(Voice_element*); - virtual Real length(); + virtual Moment length(); virtual Voice_list convert(); - virtual void translate_time(Real dt); + virtual void translate_time(Moment dt); virtual void print() const; virtual Input_music *clone() const { return new Simple_music(*this); @@ -74,8 +75,8 @@ struct Music_voice : Complex_music { /****************/ - Real length(); - virtual void translate_time(Real dt); + Moment length(); + virtual void translate_time(Moment dt); virtual Voice_list convert(); void add_elt(Voice_element*); virtual Input_music *clone() const { @@ -97,9 +98,9 @@ struct Music_general_chord : Complex_music { /****************/ - virtual Real length(); + virtual Moment length(); virtual Voice_list convert(); - virtual void translate_time(Real dt); + virtual void translate_time(Moment dt); void add_elt(Voice_element*); virtual Input_music *clone() const { return new Music_general_chord(*this); diff --git a/hdr/leastsquares.hh b/hdr/leastsquares.hh index 71586d8d5c..105efd0aa7 100644 --- a/hdr/leastsquares.hh +++ b/hdr/leastsquares.hh @@ -7,7 +7,7 @@ #ifndef LEASTSQUARE_HH #define LEASTSQUARE_HH #include "vray.hh" -#include "boxes.hh" +#include "offset.hh" struct Least_squares { svec input; diff --git a/hdr/linespace.hh b/hdr/linespace.hh index 54704508e6..8a8742142c 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -14,8 +14,8 @@ struct Colinfo { Real fixpos; Colinfo(); void print() const; - Real minright() const { return pcol_->width().max; } - Real minleft() const { return -pcol_->width().min; } + Real minright() const { return pcol_->width().right; } + Real minleft() const { return -pcol_->width().left; } }; diff --git a/hdr/lookup.hh b/hdr/lookup.hh index ecb55bd03c..5f3a3e7860 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -42,7 +42,8 @@ struct Lookup { Symbol half_slur(int dy, Real &dx, int dir, int xpart); Symbol half_slur_middlepart(Real &dx, int dir); Symbol big_slur(int dy, Real &dx, int dir); - + Symbol text(String style, String text, int align = 1); + Lookup(); diff --git a/hdr/melodicstaff.hh b/hdr/melodicstaff.hh index 45785e4c02..db7dd88b83 100644 --- a/hdr/melodicstaff.hh +++ b/hdr/melodicstaff.hh @@ -19,7 +19,7 @@ struct Melodic_staff : public Simple_staff virtual void set_output(PScore *); virtual Item* get_TYPESET_item(Command*); - virtual Stem * get_stem(Stem_req *rq,Real); + virtual Stem * get_stem(Stem_req *rq,Moment); virtual Notehead * get_notehead(Note_req *rq, int bot); virtual Local_key_item* get_local_key_item(); }; diff --git a/hdr/misc.hh b/hdr/misc.hh index 376f048c0e..fa87876748 100644 --- a/hdr/misc.hh +++ b/hdr/misc.hh @@ -2,16 +2,22 @@ #define MISC_HH #include "real.hh" +#include "moment.hh" -Real wholes(int dur, int dots); +Moment wholes(int dur, int dots); double log_2(double x) ; int intlog2(int d); inline int -ABS(int i) -{ +abs(int i){ return (i < 0)?-i:i; } +inline int +sign(int i) { + if (i<0) return -1; + else if (i) return 1; + else return 0; +} #endif diff --git a/hdr/moment.hh b/hdr/moment.hh index 83910b1a31..3327741384 100644 --- a/hdr/moment.hh +++ b/hdr/moment.hh @@ -1,36 +1,13 @@ /* - moment.hh -- part of LilyPond - (c) 1996 Han-Wen Nienhuys */ #ifndef MOMENT_HH #define MOMENT_HH -#include "real.hh" - - -struct Moment { - Real when; - /// current measure info - Real whole_per_measure; - - /// where am i - Real whole_in_measure; - - /// how long is one beat? - Real one_beat; +#include "rational.hh" - /// idem - int bars; - /****************/ - void OK() const; - Moment(Real, const Moment*); - void print() const; - void setpartial(Real p); - Real barleft(); - void set_meter(int,int); -}; +typedef Rational Moment; -#endif // MOMENT_HH +#endif // diff --git a/hdr/offset.hh b/hdr/offset.hh new file mode 100644 index 0000000000..b1867007fa --- /dev/null +++ b/hdr/offset.hh @@ -0,0 +1,38 @@ +/* + offset.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef OFFSET_HH +#define OFFSET_HH +#include "real.hh" + +/// 2d vector +struct Offset { + Real x,y; + + Offset operator+(Offset o)const { + Offset r(*this); + r+=o; + return r; + } + + Offset operator+=(Offset o) { + x+=o.x; + y+=o.y; + return *this; + } + Offset(Real ix , Real iy) { + x=ix; + y=iy; + } + Offset() { + x=0.0; + y=0.0; + } +}; + +#endif // OFFSET_HH + + diff --git a/hdr/paper.hh b/hdr/paper.hh index b03d1f7621..34c6ce3e20 100644 --- a/hdr/paper.hh +++ b/hdr/paper.hh @@ -1,6 +1,7 @@ #include "proto.hh" #include "real.hh" #include "string.hh" +#include "moment.hh" /// symbols, dimensions and constants struct Paperdef { @@ -26,7 +27,7 @@ struct Paperdef { Real standard_height()const; Real note_width() const; void print() const; - Real duration_to_dist(Real); + Real duration_to_dist(Moment); }; /** This struct takes care of all kinds of symbols, dimensions and constants. Most of them are related to the point-size of the fonts, diff --git a/hdr/proto.hh b/hdr/proto.hh index 217b2f7f58..c20d981f15 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -30,7 +30,6 @@ struct Dynamic; struct Idealspacing; struct Identifier; struct Input_commands; -struct Interval; struct Item; struct Key; struct Keyitem; @@ -95,5 +94,6 @@ struct Keyword_table; struct Rhythmic_grouping; struct Staff_commands_at ; struct Commands_at ; -struct Moment; +struct Time_description; + #endif // PROTO_HH diff --git a/hdr/request.hh b/hdr/request.hh index d8ee21ccc7..279947a21c 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -4,6 +4,7 @@ #include "glob.hh" #include "string.hh" +#include "moment.hh" /// a voice element wants something printed struct Request { @@ -21,7 +22,7 @@ struct Request { virtual Beam_req *beam() { return 0 ; } virtual Slur_req *slur() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0;} - virtual Real duration() const { return 0.0; } + virtual Moment duration() const { return 0.0; } virtual Request* clone() const =0; }; @@ -63,7 +64,7 @@ struct Rhythmic_req : Request { /****************/ - Real duration() const; + Moment duration() const; Rhythmic_req(); Rhythmic_req*rhythmic() { return this;} void print ()const; @@ -207,7 +208,7 @@ try to put an appropriate number over the bracket /// helper in the hierarchy struct Dynamic { - Real subtime; + Moment subtime; }; /** 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). diff --git a/hdr/rhythmstaff.hh b/hdr/rhythmstaff.hh index 8591e3c1a0..978594dcd3 100644 --- a/hdr/rhythmstaff.hh +++ b/hdr/rhythmstaff.hh @@ -16,7 +16,7 @@ struct Rhythmic_staff : public Simple_staff /****************/ virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq,Real); + virtual Stem *get_stem(Stem_req *rq,Moment); virtual Notehead * get_notehead(Note_req *rq, int b); virtual void set_output(PScore *); }; diff --git a/hdr/sccol.hh b/hdr/sccol.hh index b61a02682f..8c1d82b3ae 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -6,8 +6,9 @@ #ifndef SCCOL_HH #define SCCOL_HH -#include "pcol.hh" +#include "proto.hh" #include "vray.hh" +#include "moment.hh" struct Score_column { @@ -16,24 +17,20 @@ struct Score_column { PCol * pcol_; /// length of notes/rests in this column - svec durations; + svec durations; - Real when; + Moment when; /// bool musical; /****************/ - Score_column(Real when); - static int compare(Score_column & c1, Score_column &c2) { - return sgn(c1.when - c2.when); - } - void add_duration(Real ); + Score_column(Moment when); + static int compare(Score_column & c1, Score_column &c2); + void add_duration(Moment ); void preprocess(); - void set_breakable() { - pcol_->set_breakable(); - } + void set_breakable(); bool used(); void print() const; }; diff --git a/hdr/score.hh b/hdr/score.hh index fbcfde1fc0..5363b475cb 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -3,7 +3,7 @@ #include "vray.hh" #include "proto.hh" #include "plist.hh" - +#include "moment.hh" /// the total music def of one movement struct Score { @@ -25,12 +25,12 @@ struct Score { void OK() const; - PCursor find_col(Real,bool); + PCursor find_col(Moment,bool); void process(); void output(String fn); - PCursor create_cols(Real); + PCursor create_cols(Moment); void print() const; - Real last() const; + Moment last() const; private: void do_pcols(); diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh index faf1002d53..d05179b1ba 100644 --- a/hdr/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -24,7 +24,7 @@ struct Simple_column : Staff_column { svec notes; svec slurs; Stem_req *stem_; - Real stem_requester_len; + Moment stem_requester_len; Beam_req *beam_; Simple_staff* staff_; @@ -52,7 +52,7 @@ struct Simple_staff : Staff { Staff_column*create_col(Score_column*); virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq, Real)=0; + virtual Stem *get_stem(Stem_req *rq, Moment)=0; virtual Notehead *get_notehead(Note_req *rq, int b)=0; virtual Rest *get_rest(Rest_req *rq); virtual void set_output(PScore *); diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh index 6394bc79db..261394c206 100644 --- a/hdr/simplewalker.hh +++ b/hdr/simplewalker.hh @@ -25,7 +25,7 @@ struct Simple_walker: Staff_walker { Clef clef_; Rhythmic_grouping default_grouping; Rhythmic_grouping *current_grouping; - Real inbar; +// Real inbar; // whuh? svec pending_slur_reqs; svec pending_slurs; diff --git a/hdr/slur.hh b/hdr/slur.hh index 10b5884571..df144a88ee 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -7,19 +7,20 @@ #ifndef SLUR_HH #define SLUR_HH -#include "spanner.hh" +#include "directionalspanner.hh" #include "fproto.hh" #include "vray.hh" -struct Slur : Spanner { +struct Slur : Directional_spanner { svec encompass; - int dir; + //int dir; bool open_left,open_right; /****************/ - + Offset center() const; + void calculate(); void print()const; void preprocess(); void add(Notehead*); diff --git a/hdr/spanner.hh b/hdr/spanner.hh index cfaca3dec9..86d63527ae 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -6,7 +6,9 @@ #ifndef SPANNER_HH #define SPANNER_HH + #include "proto.hh" +#include "interval.hh" /// a symbol which is attached between two columns. struct Spanner { @@ -18,14 +20,19 @@ struct Spanner { String TeXstring () const ; Spanner(); - Paperdef*paper() const; + Paperdef *paper() const; virtual ~Spanner(); virtual Interval height()const=0; /** PRE: processed */ - virtual Interval width()const; + /// do calcs + virtual void calculate(); + /** + It is safe to call calculate multiple times on one object + */ + virtual Interval width()const; virtual void process(); virtual void preprocess(); diff --git a/hdr/staff.hh b/hdr/staff.hh index 9f1ba1f498..5414fc3f8b 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -21,7 +21,7 @@ struct Staff { /****************************************************************/ void add(PointerList &s); - void process_commands(Real l); + void process_commands(Moment l); Staff(const Staff&src); void add_voice(Voice *v); @@ -37,9 +37,9 @@ struct Staff { void OK() const; void print() const; - Real last() const; + Moment last() const; void clean_cols() ; - Staff_column * get_col(Real,bool); + Staff_column * get_col(Moment,bool); Staff(); diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh index 2fb564eb62..633b73285c 100644 --- a/hdr/staffcommands.hh +++ b/hdr/staffcommands.hh @@ -8,17 +8,17 @@ #include "command.hh" #include "vray.hh" #include "plist.hh" -#include "moment.hh" +#include "timedescription.hh" struct Staff_commands_at : public IPointerList { - Moment moment_; + Time_description tdescription_; /****************/ bool is_breakable(); - Real when(); - Staff_commands_at(Moment); + Moment when(); + Staff_commands_at(Time_description); void set_breakable(); void add_command_to_break(Command pre, Command mid,Command post); void print() const; @@ -31,12 +31,12 @@ struct Staff_commands_at : public IPointerList { /// the list of commands in Score struct Staff_commands : public IPointerList { - Staff_commands_at*find(Real); + Staff_commands_at*find(Moment); void add(Staff_commands_at*); - void clean(Real last); + void clean(Moment last); void OK() const; void print() const; - Real last() const; + Moment last() const; }; /** the list of commands in Score. Put in a separate class, since it otherwise clutters the methods of Score. diff --git a/hdr/stcol.hh b/hdr/stcol.hh index 823e9e9126..9e7501edc7 100644 --- a/hdr/stcol.hh +++ b/hdr/stcol.hh @@ -8,6 +8,7 @@ #define STCOL_HH #include "proto.hh" #include "vray.hh" +#include "moment.hh" /// store simultaneous requests struct Staff_column { @@ -20,13 +21,13 @@ struct Staff_column { /// idem Staff_commands_at *s_commands; - Moment *moment_; + Time_description *tdescription_; /****************/ Staff_column(Score_column*s); bool mus() const; - Real when() const; + Moment when() const; void add(Voice_element*ve); /**************************************************************** diff --git a/hdr/stem.hh b/hdr/stem.hh index ff64a3af91..768b614118 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -8,11 +8,12 @@ #define STEM_HH #include "item.hh" #include "vray.hh" +#include "moment.hh" /// the rule attached to the ball struct Stem : public Item { /// rhythmical length - Real note_length; + Moment note_length; // heads the stem encompasses (positions) int minnote, maxnote; @@ -60,7 +61,7 @@ struct Stem : public Item { void set_noteheads(); void postprocess(); void preprocess(); - Stem(int center, Real duration); + Stem(int center, Moment duration); Interval width() const; private: diff --git a/hdr/swalker.hh b/hdr/swalker.hh index da132dd9d6..0d66a55fb4 100644 --- a/hdr/swalker.hh +++ b/hdr/swalker.hh @@ -19,7 +19,7 @@ struct Staff_walker : public PCursor { /****************/ int priority() const; // Command - Real when() const; + Moment when() const; virtual ~Staff_walker(); Staff_walker(Staff*, PScore*); void process() ; diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh new file mode 100644 index 0000000000..6a0aa3e761 --- /dev/null +++ b/hdr/textspanner.hh @@ -0,0 +1,31 @@ +/* + textspanner.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef TEXTSPANNER_HH +#define TEXTSPANNER_HH + +#include "string.hh" +#include "directionalspanner.hh" + +/// a spanner which puts texts on top of other spanners. +struct Text_spanner : Spanner { + int align; + String text; + String style; + Directional_spanner*support; + /****************/ + virtual void process(); + virtual void preprocess(); + virtual Interval height() const; + virtual Spanner* broken_at(PCol*,PCol*)const; + Text_spanner(Directional_spanner*); +}; +/** + Use for triplets, eentweetjes, ottava, etc. + */ + +#endif // TEXTSPANNER_HH + diff --git a/hdr/timedescription.hh b/hdr/timedescription.hh new file mode 100644 index 0000000000..2cdbc8de23 --- /dev/null +++ b/hdr/timedescription.hh @@ -0,0 +1,36 @@ +/* + moment.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef tdes_HH +#define tdes_HH + +#include "real.hh" +#include "moment.hh" + +struct Time_description { + Rational when; + /// current measure info + Rational whole_per_measure; + + /// where am i + Rational whole_in_measure; + + /// how long is one beat? + Rational one_beat; + + /// idem + int bars; + /****************/ + void OK() const; + Time_description(Rational, const Time_description*); + void print() const; + void setpartial(Rational p); + Rational barleft(); + void set_meter(int,int); +}; + +#endif // Time_description_HH + diff --git a/hdr/voice.hh b/hdr/voice.hh index c716c650dc..f63f905a0d 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -3,15 +3,16 @@ #include "proto.hh" #include "plist.hh" +#include "moment.hh" /// class for horizontal stuff. struct Voice { IPointerList elts; - Real start; + Moment start; /****************/ - Real when(const Voice_element*)const; - Real last() const; + Moment when(const Voice_element*)const; + Moment last() const; Voice(); Voice(Voice const&); void add(Voice_element*); @@ -30,7 +31,7 @@ struct Voicegroup { /// one horizontal bit. struct Voice_element { - Real duration; + Moment duration; const Voicegroup *group; const Voice *voice_; IPointerList reqs; diff --git a/init/Makefile b/init/Makefile new file mode 100644 index 0000000000..9e9b75f0f9 --- /dev/null +++ b/init/Makefile @@ -0,0 +1,5 @@ +DFILES=dutch.ini table_sixteen.ini table_twenty.ini\ + english.ini + +dist: + ln Makefile $(DFILES) $(DDIR)/$(INITDIR) diff --git a/init/dutch.ini b/init/dutch.ini new file mode 100644 index 0000000000..d573656deb --- /dev/null +++ b/init/dutch.ini @@ -0,0 +1,11 @@ +dutch_names = +notenames { + "ceses" 0 -2 "ces" 0 -1 "c" 0 0 "cis" 0 1 "cisis" 0 2 + "deses" 1 -2 "des" 1 -1 "d" 1 0 "dis" 1 1 "disis" 1 2 + "eses" 2 -2 "es" 2 -1 "e" 2 0 "eis" 2 1 "eisis" 2 2 + "feses" 3 -2 "fes" 3 -1 "f" 3 0 "fis" 3 1 "fisis" 3 2 + "geses" 4 -2 "ges" 4 -1 "g" 4 0 "gis" 4 1 "gisis" 4 2 + "ases" 5 -2 "as" 5 -1 "a" 5 0 "ais" 5 1 "aisis" 5 2 + "beses" 6 -2 "bes" 6 -1 "b" 6 0 "bis" 6 1 "bisis" 6 2 +} + diff --git a/init/english.ini b/init/english.ini new file mode 100644 index 0000000000..d876d29c6f --- /dev/null +++ b/init/english.ini @@ -0,0 +1,13 @@ + +% +% f = flat, s = sharp. +% +english_names = notenames { + "cff" 0 -2 "cf" 0 -1 "c" 0 0 "cs" 0 1 "css" 0 2 + "dff" 1 -2 "df" 1 -1 "d" 1 0 "ds" 1 1 "dss" 1 2 + "eff" 2 -2 "ef" 2 -1 "e" 2 0 "es" 2 1 "ess" 2 2 + "fff" 3 -2 "ff" 3 -1 "f" 3 0 "fs" 3 1 "fss" 3 2 + "gff" 4 -2 "gf" 4 -1 "g" 4 0 "gs" 4 1 "gss" 4 2 + "aff" 5 -2 "af" 5 -1 "a" 5 0 "as" 5 1 "ass" 5 2 + "bff" 6 -2 "bf" 6 -1 "b" 6 0 "bs" 6 1 "bss" 6 2 +} diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini new file mode 100644 index 0000000000..8b506b8224 --- /dev/null +++ b/init/table_sixteen.ini @@ -0,0 +1,99 @@ +table_sixteen= +symboltables { + + texid "\musixsixteendefs" + + % index TeXstring, xmin xmax ymin ymax + + + "style" = table { + "roman" "\settext{%}" 0pt 0pt 0pt 0pt + "italic" "\setitalic{%}" 0pt 0pt 0pt 0pt + } + "align" = table { + "-1" "\leftalign{%}" 0pt 0pt 0pt 0pt + "0" "\centeralign{%}" 0pt 0pt 0pt 0pt + "1" "\rightalign{%}" 0pt 0pt 0pt 0pt + } + + "clefs" = table { + "violin" "\violinclef" 0pt 12.8pt -10pt 18pt + "bass" "\bassclef" 0pt 11.2pt 0pt 16pt + "viola" "\violaclef" 0pt 12.8pt 0pt 16pt + "violin_change" "\cviolinclef" 0pt 11.2pt -12pt 12pt + "bass_change" "\cbassclef" 0pt 12.8pt 0pt 16pt + "viola_change" "\cviolaclef" 0pt 11.2pt 0pt 16pt + } + + "balls" = table { + "1" "\wholeball" 0pt 6pt -2 pt 2pt + "2" "\halfball" 0pt 5pt -2 pt 2pt + "4" "\quartball" 0pt 5pt -2 pt 2pt + } + + "slur" = table { + "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt + "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt + } + "accidentals" = table { + "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt + "-1" "\flat" 0pt 6pt -2.5pt 7.5pt + "0" "\natural" 0pt 6pt -7.5pt 7.5pt + "1" "\sharp" 0pt 6pt -7.5pt 7.5pt + "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + } + + "streepjes" = table { + "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt + "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + } + + "bars" = table { + "empty" "\emptybar" 0pt 0pt 0pt 0pt + "|" "\maatstreep" 0pt 5pt -12pt 12pt + "||" "\finishbar" 0pt 2pt -12pt 12pt + } + + "rests" = table { + "1" "\wholerest" -5pt 1pt -1pt 1pt + "2" "\halfrest" -5pt 1pt -1pt 1pt + "4" "\quartrest" -5pt 2pt -5pt 5pt + "8" "\eighthrest" 0pt 5pt 0pt 8pt + "16" "\sixteenthrest" 0pt 6pt 0pt 12pt + "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + } + + "meters" = table { + "C" "\fourfourmeter" 0pt 10pt -5pt 5pt + "C2" "\allabreve" 0pt 10pt -5pt 5pt + } + + % dims ignored for this table + "param" = table { + "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt + "linestaf" "\linestafsym{%}{%}" + "stem" "\stem{%}{%}" + "fill" "\hbox{}" + } + + "dots" = table { + "1" "\lsingledot" 0pt 2pt -1pt 1pt + "2" "\ldoubledot" 0pt 5pt -1pt 1pt + "3" "\ltripledot" 0pt 8pt -1pt 1pt + } + + "flags" = table { + "8" "\eigthflag" 0pt 4pt 0pt 0pt + "16" "\sixteenthflag" 0pt 4pt 0pt 0pt + "32" "\thirtysecondflag" 0pt 4pt 0pt 0pt + "-8" "\deigthflag" 0pt 4pt 0pt 0pt + "-16" "\dsixteenthflag" 0pt 4pt 0pt 0pt + "-32" "\dthirtysecondflag" 0pt 4pt 0pt 0pt + } + + "beamslopes" = table { + "slope" "\beamslope{%}{%}" + "horizontal" "\rulesym{%}{%}" + } + +} diff --git a/init/table_twenty.ini b/init/table_twenty.ini new file mode 100644 index 0000000000..1b49eab1dd --- /dev/null +++ b/init/table_twenty.ini @@ -0,0 +1,103 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +table_twenty = symboltables { + + texid "\musixtwentydefs" + + "style" = table { + "roman" "\settext{%}" 0pt 0pt 0pt 0pt + "italic" "\setitalic{%}" 0pt 0pt 0pt 0pt + } + "align" = table { + "-1" "\leftalign{%}" 0pt 0pt 0pt 0pt + "0" "\centeralign{%}" 0pt 0pt 0pt 0pt + "1" "\rightalign{%}" 0pt 0pt 0pt 0pt + } + + + % index TeXstring, xmin xmax ymin ymax + % be careful with editing this: + % the "index" entry is hardwired into lilypond. + + "clefs" = table { + "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt + "bass" "\bassclef" 0pt 16pt 0pt 20pt + "viola" "\violaclef" 0pt 16pt 0pt 20pt + "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt + "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt + "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt + } + + "balls" = table { + "1" "\wholeball" 0pt 7.5pt -2.5pt 2.5pt + "2" "\halfball" 0pt 6pt -2.5pt 2.5pt + "4" "\quartball" 0pt 6pt -2.5pt 2.5pt + } + + "slur" = table { + "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt + "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt + } + "accidentals" = table { + "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt + "-1" "\flat" 0pt 6pt -2.5pt 7.5pt + "0" "\natural" 0pt 6pt -7.5pt 7.5pt + "1" "\sharp" 0pt 6pt -7.5pt 7.5pt + "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + } + + "streepjes" = table { + "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt + "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + } + + "bars" = table { + "empty" "\emptybar" 0pt 0pt 0pt 0pt + "|" "\maatstreep" 0pt 5pt -12pt 12pt + "||" "\finishbar" 0pt 2pt -12pt 12pt + } + + "rests" = table { + "1" "\wholerest" -5pt 1pt -1pt 1pt + "2" "\halfrest" -5pt 1pt -1pt 1pt + "4" "\quartrest" -5pt 2pt -5pt 5pt + "8" "\eighthrest" 0pt 5pt 0pt 8pt + "16" "\sixteenthrest" 0pt 6pt 0pt 12pt + "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + } + + "meters" = table { + "C" "\fourfourmeter" 0pt 10pt -5pt 5pt + "C2" "\allabreve" 0pt 10pt -5pt 5pt + } + + % dims ignored for this table + "param" = table { + "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt + "linestaf" "\linestafsym{%}{%}" + "stem" "\stem{%}{%}" + "fill" "\hbox{}" + } + + "dots" = table { + "1" "\lsingledot" 0pt 8pt -1pt 1pt + "2" "\ldoubledot" 0pt 12pt -1pt 1pt + "3" "\ltripledot" 0pt 16pt -1pt 1pt + } + + "flags" = table { + "8" "\eigthflag" 0pt 5pt 0pt 0pt + "16" "\sixteenthflag" 0pt 5pt 0pt 0pt + "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt + "-8" "\deigthflag" 0pt 5pt 0pt 0pt + "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt + "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt + } + + "beamslopes" = table { + "slope" "\beamslope{%}{%}" + "horizontal" "\rulesym{%}{%}" + } + +} diff --git a/lilyponddefs.tex b/lilyponddefs.tex index 0c70462bc0..da2c971f2f 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -23,6 +23,7 @@ \font\hslurdfont=xslhd20 \font\hslurhfont=xslhz20 \font\musicfnt=musix20 + \font\italicfont=cmti10 \balkhoog=20pt \notewidth=6pt \staffrulethickness=0.4pt @@ -31,6 +32,7 @@ } \def\musixsixteendefs{ \font\textfont=cmr8 + \font\italicfont=cmti8 \font\slurufont=xslu16 \font\slurdfont=xsld16 \font\slurhfont=xslz20 % sigh @@ -112,7 +114,7 @@ \vskip 10pt } \def\ugly{\nointerlineskip\par -\vskip 40pt\par\vbox{\hbox to 0pt{\vrule width30pt height1pt\hss}}\par\vskip 40pt +\vskip 40pt\par\vbox{\leftalign{\vrule width30pt height1pt}}\par\vskip 40pt } \def\interscoreline{\beauty} @@ -134,7 +136,7 @@ % % a staffsymbol with #1 lines, width #2 % bottom at baseline -\def\linestafsym#1#2{\hbox to 0pt{\vbox to 0pt{\vss\lines{#1}{#2}}\hss}} +\def\linestafsym#1#2{\leftalign{\vbox to 0pt{\vss\lines{#1}{#2}}}} \def\vcenter#1{\vbox to 0pt{\vss #1\vss}} \def\topalign#1{\vbox to 0pt{#1\vss}} @@ -157,9 +159,15 @@ \def\stem#1#2{\vrule height#2 depth-#1} \def\placebox#1#2#3{% - \vbox to 0pt{\vss\hbox{\raise #1\hbox to 0pt{\kern #2{}#3\hss}}}% + \vbox to 0pt{\vss\hbox{\raise #1\leftalign{\kern #2{}#3}}}% } \def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}} -\def\rulesym#1#2{\vrule height #1 width #2} \ No newline at end of file +\def\rulesym#1#2{\vrule height #1 width #2} + +\def\settext#1{\textfont #1} +\def\setitalic#1{\italicfont #1} + +\def\centeralign#1{\hbox to 0pt{\hss#1\hss}} +\def\leftalign#1{\hbox to 0pt{#1\hss}} diff --git a/maartje.ly b/maartje.ly index 2ce1ab655a..d0ca0dfb75 100644 --- a/maartje.ly +++ b/maartje.ly @@ -1,9 +1,9 @@ ritme = staff {rhythmic music {$ c8 - [a8 a8. a8 a16 a16 a16] c4. + [a8() a8. a8 a16 a16 a16] c4. - %[c8( )'a8 c8 c8] + %[c8( )'a8() c8 c8]% BUG! c2 c2 [fis16 'dis16( fis16 'dis16 ][fis16) 'dis16 fis16 'dis16] @@ -61,11 +61,9 @@ score { paper { geometric 1.4 unitspace 3.0 cm -% symboltables { table_sixteen} } staff { ritme } staff { melody } -% staff { melody } commands { meter 4 4 partial 8 diff --git a/src/beam.cc b/src/beam.cc index 9cb43f5731..85d5cc4812 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -27,13 +27,23 @@ Stem_info::Stem_info(const Stem*s) { x = s->hpos(); int dir = s->dir; - idealy = MAX(dir*s->top, dir*s->bot); - miny = MAX(dir*s->minnote, dir*s-> maxnote); + idealy = max(dir*s->top, dir*s->bot); + miny = max(dir*s->minnote, dir*s-> maxnote); assert(miny <= idealy); no_beams = s->flag; } /****************/ +Offset +Beam::center()const +{ + if(!dir) + ((Beam*)this)->calculate(); + Real w=width().length()/2; + return Offset(w, + (left_pos + w* slope)*paper()->interline()); +} + Beam::Beam() { @@ -143,7 +153,7 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) PCursor s(stems); svec flags; for (; s.ok(); s++) { - int f = intlog2(ABS(s->flag))-2; + int f = intlog2(abs(s->flag))-2; assert(f>0); flags.add(f); } diff --git a/src/boxes.cc b/src/boxes.cc index b280e45f92..d6564663a1 100644 --- a/src/boxes.cc +++ b/src/boxes.cc @@ -2,14 +2,6 @@ #include "const.hh" #include "vray.hh" -Box::Box(svec &s) -{ - assert(s.sz() == 4); - x.min = s[0]; - x.max = s[1]; - y.min = s[2]; - y.max = s[3]; -} Box::Box() { diff --git a/src/calcideal.cc b/src/calcideal.cc index 9db9472113..faf88d6ead 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -45,12 +45,12 @@ Score::calc_idealspacing() if (i->musical) { assert(j.ok()); for (int n=0; n < i->durations.sz(); n++) { - Real d = i->durations[n]; + Moment d = i->durations[n]; Real dist = paper_->duration_to_dist(d); while (j->when < d + i->when) j++; - assert( distance(j->when, d+i->when) < 1e-8); + assert( j->when== d+i->when); connect(i->pcol_, j->pcol_, dist); if (!j->musical && (j+1).ok() @@ -65,7 +65,7 @@ Score::calc_idealspacing() the last col is breakable, and therefore in use */ - Real d = j->when - i->when; + Moment d = j->when - i->when; Real dist = (d) ? paper_->duration_to_dist(d) : convert_dimen(2,"pt"); // todo diff --git a/src/directionalspanner.cc b/src/directionalspanner.cc new file mode 100644 index 0000000000..49bb67d725 --- /dev/null +++ b/src/directionalspanner.cc @@ -0,0 +1,6 @@ +#include "directionalspanner.hh" + +Directional_spanner::Directional_spanner() +{ + dir = 0; +} diff --git a/src/grouping.cc b/src/grouping.cc index 4c77034bd1..3252178849 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -10,26 +10,26 @@ Rhythmic_grouping::OK()const for (int i= 0; i < children.sz(); i++) { children[i]->OK(); if (i>0) - assert(children[i-1]->interval().max == - children[i]->interval().min); + assert(children[i-1]->interval().right == + children[i]->interval().left); } } -Real +Moment Rhythmic_grouping::length() const { return interval().length(); } -Interval +MInterval Rhythmic_grouping::interval()const { if (interval_) return *interval_; else return - Interval(children[0]->interval().min, - children.last()->interval().max); + MInterval(children[0]->interval().left, + children.last()->interval().right); } void @@ -50,14 +50,14 @@ Rhythmic_grouping::split(Rhythmic_grouping r) } -svec +svec Rhythmic_grouping::intervals() { - svec r; + svec r; if (interval_ || children.sz() == 1) { - Interval i(interval()); - Interval r1(i), r2(i); - r1.max = r2.min = i.center(); + MInterval i(interval()); + MInterval r1(i), r2(i); + r1.right = r2.left = i.center(); r.add(r1); r.add(r2); } else { for (int i=0; i < children.sz(); i++) @@ -66,20 +66,20 @@ Rhythmic_grouping::intervals() return r; } -Rhythmic_grouping::Rhythmic_grouping(Interval t, int n) +Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n) { if (n == 1 || !n) { - interval_ = new Interval(t); + interval_ = new MInterval(t); return; } - Real dt = t.length()/n; - Interval basic = Interval(t.min, t.min+dt); + Moment dt = t.length()/n; + MInterval basic = MInterval(t.left, t.left+dt); for (int i= 0; i < n; i++) children.add(new Rhythmic_grouping( dt*i + basic )); } void -Rhythmic_grouping::intersect(Interval t) +Rhythmic_grouping::intersect(MInterval t) { if (interval_) { interval_->intersect(t); @@ -87,8 +87,8 @@ Rhythmic_grouping::intersect(Interval t) } for (int i=0; i < children.sz(); i++) { - Interval inter = intersection(t, children[i]->interval()); - if (inter.empty() || inter.length() < 1e-8) { + MInterval inter = intersection(t, children[i]->interval()); + if (inter.empty() || inter.length() <= 0) { delete children[i]; children[i] =0; } else { @@ -105,7 +105,7 @@ Rhythmic_grouping::intersect(Interval t) } void -Rhythmic_grouping::split(svec splitpoints) +Rhythmic_grouping::split(svec splitpoints) { //check on splitpoints.. int j = 0, i=0, starti = 0, startj = 0; @@ -115,11 +115,11 @@ Rhythmic_grouping::split(svec splitpoints) if ( i >= children.sz() || j >= splitpoints.sz()) break; - assert( distance( - children[starti]->interval().min, splitpoints[startj].min)<1e-8); - if (children[i]->interval().max < splitpoints[j].max - 1e-8) { + assert( + children[starti]->interval().left== splitpoints[startj].left); + if (children[i]->interval().right < splitpoints[j].right) { i ++; - } else if (children[i]->interval().max > splitpoints[j].max + 1e-8) { + } else if (children[i]->interval().right > splitpoints[j].right ) { j ++; } else { @@ -157,7 +157,7 @@ Rhythmic_grouping::~Rhythmic_grouping() void Rhythmic_grouping::copy(Rhythmic_grouping const&s) { - interval_ = (s.interval_)? new Interval(*s.interval_) : 0; + interval_ = (s.interval_)? new MInterval(*s.interval_) : 0; for (int i=0; i < s.children.sz(); i++) children.add(new Rhythmic_grouping(*s.children[i])); } @@ -199,20 +199,20 @@ Rhythmic_grouping::print()const } void -Rhythmic_grouping::add_child(Real start, Real len) +Rhythmic_grouping::add_child(Moment start, Moment len) { - Real stop = start+len; + Moment stop = start+len; for (int i=0; i < children.sz(); i ++) { - Interval j=children[i]->interval(); - if (distance (j.min, start)<1e-8 && distance (j.max, stop)<1e-8) { + MInterval j=children[i]->interval(); + if (j.left == start && j.right==stop) { return; } } if (children.sz()) - assert ( distance(children.last()->interval().max , start) < 1e-8); + assert ( children.last()->interval().right== start); - children.add(new Rhythmic_grouping(Interval(start, stop))); + children.add(new Rhythmic_grouping(MInterval(start, stop))); } Rhythmic_grouping::Rhythmic_grouping() diff --git a/src/inputcommand.cc b/src/inputcommand.cc index e38eb87217..fda5ceefcf 100644 --- a/src/inputcommand.cc +++ b/src/inputcommand.cc @@ -6,9 +6,6 @@ Input_command::Input_command() { } -Input_command::Input_command(Real ) -{ -} Input_command::operator Command() { @@ -39,7 +36,7 @@ Input_command::operator Command() Input_command* -get_partial_command(Real u) +get_partial_command(Moment u) { Input_command*c = new Input_command; c->args.add("PARTIAL"); @@ -47,14 +44,6 @@ get_partial_command(Real u) return c; } -Input_command* -get_grouping_command(Real r,sveca ) -{ - Input_command*c = get_grouping_command(a); - c->args.insert(r,1); - return c; -} - Input_command* get_grouping_command(sveca ) { @@ -109,7 +98,7 @@ get_bar_command() } Input_command * -get_skip_command(int n, Real m) +get_skip_command(int n, Moment m) { Input_command*c = new Input_command; diff --git a/src/inputcommands.cc b/src/inputcommands.cc index 59d8eeaae7..e1d4046561 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -10,21 +10,21 @@ Commands_at::print() const { #ifndef NPRINT mtor << "Commands_at {"; - moment_.print(); + tdescription_.print(); for (PCursor cc(*this); cc.ok(); cc++) cc->print(); mtor << "}\n"; #endif } -Real +Moment Commands_at::when() { - return moment_.when; + return tdescription_.when; } -Commands_at::Commands_at(Real dt, Commands_at* prev) - : moment_(dt, (prev)? &prev->moment_ : 0) +Commands_at::Commands_at(Moment dt, Commands_at* prev) + : tdescription_(dt, (prev)? &prev->tdescription_ : 0) { - if (prev&& !moment_.whole_in_measure) { + if (prev&& !tdescription_.whole_in_measure) { bottom().add(get_bar_command()); } } @@ -38,15 +38,14 @@ Commands_at::add(Input_command *i) if (i->args[0] == "METER") { int l = i->args[1]; int o = i->args[2]; - moment_.set_meter(l,o); - bottom().add(get_grouping_command( moment_.one_beat, - get_default_grouping(l))); + tdescription_.set_meter(l,o); + bottom().add(get_grouping_command( get_default_grouping(l))); } } Commands_at::Commands_at(Commands_at const&src) : - moment_(src.moment_) + tdescription_(src.tdescription_) { IPointerList &me(*this); const IPointerList &that(src); @@ -55,21 +54,21 @@ Commands_at::Commands_at(Commands_at const&src) : } void -Commands_at::setpartial(Real p) +Commands_at::setpartial(Moment p) { - moment_.setpartial(p); + tdescription_.setpartial(p); } -Real +Moment Commands_at::barleft() { - return moment_.barleft(); + return tdescription_.barleft(); } void Commands_at::parse(Staff_commands_at*s) { - s->moment_ = moment_; + s->tdescription_ = tdescription_; for (PCursor cc(*this); cc.ok(); cc++) { if (cc->args.sz() && cc->args[0] !="") { Command c = **cc; @@ -81,13 +80,13 @@ Commands_at::parse(Staff_commands_at*s) /****************/ void -Input_cursor::find_moment(Real w) +Input_cursor::find_moment(Moment w) { - Real last = when(); + Moment last = when(); while (1) { if (! ok() ) { *this = list().bottom(); - Real dt = (w - when()) barleft(); + Moment dt = (w - when()) barleft(); Commands_at * c = new Commands_at(dt, *this); assert(c->when() <= w); @@ -103,7 +102,7 @@ Input_cursor::find_moment(Real w) } prev(); - Real dt = (w - when()); + Moment dt = (w - when()); Commands_at * c = new Commands_at(dt, *this); add(c); next(); @@ -130,10 +129,10 @@ Input_commands::Input_commands() } void -Input_commands::do_skip(int bars, Real wholes) +Input_commands::do_skip(int bars, Moment wholes) { while (bars > 0) { - Real b = ptr->barleft(); + Moment b = ptr->barleft(); ptr.find_moment(ptr->when() + b); bars --; } @@ -150,7 +149,7 @@ Input_commands::add(Input_command c) ptr->setpartial(c.args[1]); } else if (c.args[0] == "GROUPING") { Input_command *ic = new Input_command(c); - ic->args.insert(ptr->moment_.one_beat, 1); + ic->args.insert(ptr->tdescription_.one_beat, 1); ptr->add(ic); } else if (c.args[0] == "METER") { int beats_per_meas = c.args[1]; @@ -159,7 +158,7 @@ Input_commands::add(Input_command c) ptr->add(ch); } else if (c.args[0] == "SKIP") { int bars = c.args[1] ; - Real wholes= c.args[2]; + Moment wholes= c.args[2]; do_skip(bars, wholes); } else if (c.args[0] == "RESET") { ptr= top(); @@ -180,7 +179,7 @@ Input_commands::parse() const Staff_commands_at* s= nc->find(i->when()); if (!s){ - s = new Staff_commands_at(i->moment_); + s = new Staff_commands_at(i->tdescription_); nc->add(s); } if (!i->when()) { /* all pieces should start with a breakable. */ @@ -208,7 +207,7 @@ Input_commands::print() const } /****************/ -Real +Moment Input_cursor::when()const { return (*this)->when(); diff --git a/src/inputmusic.cc b/src/inputmusic.cc index db2e3c57d5..b007562d1c 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -8,13 +8,13 @@ Simple_music::add(Voice_element*v) voice_.add(v); } -Real +Moment Simple_music::length() { return voice_.last(); } void -Simple_music::translate_time(Real t) +Simple_music::translate_time(Moment t) { voice_.start += t; } @@ -93,10 +93,10 @@ Music_voice::add_elt(Voice_element*v) s->add(v); } -Real +Moment Music_voice::length() { - Real l = 0.0; + Moment l = 0.0; for (PCursor i(elts); i.ok(); i++) l += i->length(); @@ -108,10 +108,10 @@ Voice_list Music_voice::convert() { Voice_list l; - Real here = 0.0; + Moment here = 0.0; for (PCursor i(elts); i.ok(); i++) { - Real len = i->length(); + Moment len = i->length(); Voice_list k(i->convert()); k.translate_time(here); l.concatenate(k); @@ -122,7 +122,7 @@ Music_voice::convert() } void -Music_voice::translate_time(Real t) +Music_voice::translate_time(Moment t) { elts.bottom()->translate_time(t); } @@ -148,16 +148,16 @@ Music_general_chord::print() const } void -Music_general_chord::translate_time(Real t) +Music_general_chord::translate_time(Moment t) { for (PCursor i(elts); i.ok(); i++) i->translate_time(t); } -Real +Moment Music_general_chord::length() { - Real l =0.0; + Moment l =0.0; for (PCursor i(elts); i.ok(); i++) l = l >? i->length(); @@ -179,7 +179,7 @@ Music_general_chord::convert() /****************/ void -Voice_list::translate_time(Real x) +Voice_list::translate_time(Moment x) { for (PCursor i(*this); i.ok(); i++) i->start += x; diff --git a/src/lexer.l b/src/lexer.l index 0b17abac66..4968c89de6 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -144,6 +144,17 @@ DOTS \.+ yyterminate(); // can't move this, since it actually rets a YY_NULL } + +include { BEGIN(incl); } +[ \t]* { /* eat the whitespace */ } +\"[^"]*\"+ { /* got the include file name */ + String s (YYText()+1); + s = s.left(s.len()-1); + new_input(s); + BEGIN(INITIAL); +} + + {WORD} { mtor << "word: " << YYText()< COLFUDGE) { + if (cols[i].fixed&& abs(cols[i].fixpos - v(i)) > COLFUDGE) { return false; } if (!i) diff --git a/src/lookup.cc b/src/lookup.cc index baa037b970..d7a3f721e9 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -28,6 +28,19 @@ Lookup::add(String s, Symtable*p) symtables_->add(s, p); } +Symbol +Lookup::text( String style, String text , int dir) +{ + svec a; + + a.add((*symtables_)("style")->lookup(style).tex); + Symbol s = (*symtables_)("align")->lookup(dir); + a[0] = substitute_args( text,a); + + s.tex = substitute_args(s.tex,a); + return s; +} + /****************/ Real diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc index 493e67f05e..b20e3a6bf2 100644 --- a/src/melodicstaff.cc +++ b/src/melodicstaff.cc @@ -45,7 +45,7 @@ Melodic_staff::get_TYPESET_item(Command*com) } Stem * -Melodic_staff::get_stem(Stem_req*rq, Real dur) +Melodic_staff::get_stem(Stem_req*rq, Moment dur) { Stem * s = new Stem(NO_LINES-1, dur); s->flag = rq->stem_number; diff --git a/src/misc.cc b/src/misc.cc index ff99029ec7..5618f8ae2a 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -1,17 +1,18 @@ #include "misc.hh" #include "glob.hh" +#include "moment.hh" #include -Real +Moment wholes(int dur, int dots) { if (!dur) return 0.0; // stupid Intel: doesn't crash if !dur - Real f = 1.0/Real(dur); - Real delta = f; + Moment f = 1/Moment(dur); + Moment delta = f; while (dots--) { delta /= 2.0; diff --git a/src/molecule.cc b/src/molecule.cc index fb72eb6bf0..68b8791c18 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -82,7 +82,7 @@ Molecule::add_right(const Molecule &m) add(m); return; } - Real xof=extent().x.max - m.extent().x.min; + Real xof=extent().x.right - m.extent().x.left; Molecule toadd(m); toadd.translate(Offset(xof, 0.0)); add(toadd); @@ -95,7 +95,7 @@ Molecule::add_left(const Molecule &m) add(m); return; } - Real xof=extent().x.min - m.extent().x.max; + Real xof=extent().x.left - m.extent().x.right; Molecule toadd(m); toadd.translate(Offset(xof, 0.0)); add(toadd); @@ -109,7 +109,7 @@ Molecule::add_top(const Molecule &m) add(m); return; } - Real yof=extent().y.max - m.extent().y.min; + Real yof=extent().y.right - m.extent().y.left; Molecule toadd(m); toadd.translate(Offset(0,yof)); add(toadd); @@ -122,7 +122,7 @@ Molecule::add_bottom(const Molecule &m) add(m); return; } - Real yof=extent().y.min- m.extent().y.max; + Real yof=extent().y.left- m.extent().y.right; Molecule toadd(m); toadd.translate(Offset(0,yof)); add(toadd); diff --git a/src/mylexer.cc b/src/mylexer.cc index 0a912e3389..699a46d9fa 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -1,3 +1,4 @@ +#include "interval.hh" #include "identparent.hh" #include "associter.hh" #include "lexer.hh" diff --git a/src/notehead.cc b/src/notehead.cc index 88cb621181..203c592830 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -1,3 +1,5 @@ +#include "misc.hh" + #include "notehead.hh" #include "dimen.hh" #include "debug.hh" @@ -60,7 +62,7 @@ Notehead::brew_molecole() output->translate(Offset(x_dir * p->note_width(),0)); bool streepjes = (position<-1)||(position > staff_size+1); if (streepjes) { - int dir = sgn(position); + int dir = sign(position); int s =(position<-1) ? -((-position)/2): (position-staff_size)/2; Symbol str = p->lookup_->streepjes(s); Molecule sm; diff --git a/src/paper.cc b/src/paper.cc index 2879d90c91..82b8583876 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -12,7 +12,7 @@ const Real PHI = (1+sqrt(5))/2; // see Roelofs, p. 57 Real -Paperdef::duration_to_dist(Real d) +Paperdef::duration_to_dist(Moment d) { return whole_width * pow(geometric_, log_2(d)); } diff --git a/src/parser.y b/src/parser.y index bc38c27e14..402bc95f74 100644 --- a/src/parser.y +++ b/src/parser.y @@ -437,7 +437,7 @@ pitch_list: { int: REAL { $$ = int($1); - if (ABS($1-Real(int($$))) > 1e-8) + if ( distance($1,Real(int($$)) ) > 1e-8) error("expecting integer number"); } | INT diff --git a/src/pcol.cc b/src/pcol.cc index 951be6fa5f..7dc4c22c5a 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -43,7 +43,7 @@ PCol::print() const } else if (daddy) { mtor<<'\n' << ((this == daddy->prebreak) ? "prebreak" : "postbreak"); } - mtor << "extent: " << width().min << ", " << width().max << "\n"; + mtor << "extent: " << width().str() << "\n"; mtor << "}\n"; #endif } diff --git a/src/pscore.cc b/src/pscore.cc index a34d86b0ba..c808ecc3fe 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -59,7 +59,7 @@ PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) svec col_its (select_items(s, c)); for (int j =0; j < col_its.sz(); j++) col_its[j]->translate(Offset(-iv.length(),0)); - i->translate (Offset(-iv.max, 0)); + i->translate (Offset(-iv.right, 0)); } } diff --git a/src/qlpsolve.cc b/src/qlpsolve.cc index 21af7cdcb0..88b703bbbb 100644 --- a/src/qlpsolve.cc +++ b/src/qlpsolve.cc @@ -68,7 +68,7 @@ Active_constraints::add(int k) Vector Ha = H*a; Real aHa = a*Ha; Vector addrow(Ha.dim()); - if (ABS(aHa) > EPS) { + if (abs(aHa) > EPS) { /* a != 0, so if Ha = O(EPS), then Ha * aH / aHa = O(EPS^2/EPS) @@ -203,7 +203,7 @@ Ineq_constrained_qp::solve(Vector start) const } } Real unbounded_alfa = 1.0; - Real optimal_step = MIN(minalf, unbounded_alfa); + Real optimal_step = min(minalf, unbounded_alfa); Vector deltax=direction * optimal_step; x += deltax; diff --git a/src/request.cc b/src/request.cc index 7821ba240c..2645d5dc90 100644 --- a/src/request.cc +++ b/src/request.cc @@ -71,7 +71,7 @@ Rest_req::print() const } -Real +Moment Rhythmic_req::duration() const { return wholes( balltype,dots); } diff --git a/src/rhythmstaff.cc b/src/rhythmstaff.cc index a446bd33ec..9142986abc 100644 --- a/src/rhythmstaff.cc +++ b/src/rhythmstaff.cc @@ -43,7 +43,7 @@ Rhythmic_staff::get_notehead(Note_req *rq, int) } Stem * -Rhythmic_staff::get_stem(Stem_req*rq, Real l) +Rhythmic_staff::get_stem(Stem_req*rq, Moment l) { Stem * s = new Stem(0,l); s->flag = rq->stem_number; diff --git a/src/sccol.cc b/src/sccol.cc index be242059af..ec8784a9bd 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -1,7 +1,18 @@ -#include "sccol.hh" #include "debug.hh" +#include "pcol.hh" +#include "sccol.hh" + +int +Score_column::compare(Score_column & c1, Score_column &c2) +{ + return sign(c1.when - c2.when); +} -Score_column::Score_column(Real w) +void +Score_column::set_breakable() { + pcol_->set_breakable(); +} +Score_column::Score_column(Moment w) { when = w; pcol_ = new PCol(0); @@ -28,18 +39,18 @@ Score_column::print() const } int -Real_compare(Real &a , Real& b) +Tdescription_compare(Moment &a , Moment& b) { - return sgn(a-b); + return sign(a-b); } void Score_column::preprocess() { - durations.sort(Real_compare); + durations.sort(Tdescription_compare); } void -Score_column::add_duration(Real d) +Score_column::add_duration(Moment d) { for (int i = 0; i< durations.sz(); i++) { if (d == durations[i]) diff --git a/src/score.cc b/src/score.cc index 5a65809c5a..1593f7be16 100644 --- a/src/score.cc +++ b/src/score.cc @@ -68,7 +68,7 @@ Score::clean_cols() */ // todo PCursor -Score::create_cols(Real w) +Score::create_cols(Moment w) { Score_column* c1 = new Score_column(w); Score_column* c2 = new Score_column(w); @@ -98,7 +98,7 @@ Score::create_cols(Real w) } PCursor -Score::find_col(Real w,bool mus) +Score::find_col(Moment w,bool mus) { PCursor i(cols_); for (; i.ok(); i++) { @@ -121,12 +121,12 @@ Score::do_pcols() pscore_->add(i->pcol_); } } -Real +Moment Score::last() const { - Real l = 0; + Moment l = 0; for (PCursor i(staffs_); i.ok(); i++) { - l = MAX(l, i->last()); + l = l>? i->last(); } return l; } diff --git a/src/simpleprint.cc b/src/simpleprint.cc index 833afe2108..4c0aa4b15c 100644 --- a/src/simpleprint.cc +++ b/src/simpleprint.cc @@ -26,7 +26,6 @@ Simple_staff::get_TYPESET_item(Command *com) c->change = (type == "CLEF"); }else{ WARN << "ignoring TYPESET command for " << type << '\n'; - } return s; } @@ -35,9 +34,13 @@ Simple_staff::get_TYPESET_item(Command *com) Interval itemlist_width(const svec &its) { - Interval iv; - for (int j =0; j < its.sz(); j++) - iv.unite(its[j]->width()); + Interval iv ; + iv.set_empty(); + + for (int j =0; j < its.sz(); j++){ + iv.unite (its[j]->width()); + + } return iv; } @@ -58,7 +61,7 @@ Simple_column::typeset_item(Item *i, int breakst) assert(!column_wid.empty()); for (int j=0; j < to_move.sz(); j++) { - to_move[j]->translate(Offset(-column_wid.max, 0)); + to_move[j]->translate(Offset(-column_wid.right, 0)); } } } @@ -102,6 +105,6 @@ Simple_staff::get_rest(Rest_req*rq) Local_key_item* Simple_staff::get_local_key_item() { - return 0; + return 0; } diff --git a/src/simplewalker.cc b/src/simplewalker.cc index 9f5f0033f2..458e071c9a 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -21,22 +21,21 @@ #include "localkeyitem.hh" Rhythmic_grouping -parse_grouping(svec a) +parse_grouping(svec a, Moment one_beat) { - Real one_beat =a[0]; - a.del(0); + svec r; for (int i= 0 ; i < a.sz(); i++) r.add(a[i]); - Real here =0.0; + Moment here =0.0; svec children; for (int i=0; i < r.sz(); i++) { - Real last = here; + Moment last = here; here += one_beat * r[i]; children.add( - new Rhythmic_grouping(Interval(last, here), r[i] ) + new Rhythmic_grouping(MInterval(last, here), r[i] ) ); } return Rhythmic_grouping(children); @@ -48,7 +47,7 @@ Simple_walker::do_INTERPRET_command(Command*com) svec args(com->args); args.del(0); if (com->args[0] == "GROUPING") { - default_grouping = parse_grouping(args); + default_grouping = parse_grouping(args, col()->tdescription_->one_beat); }else if (com->args[0] == "BAR") { local_key_.reset(key_); @@ -136,7 +135,7 @@ Simple_walker::do_note(Rhythmic_req*rq) stem_->add(n); if (current_grouping) { current_grouping->add_child( - c->moment_->whole_in_measure, rq->duration()); + c->tdescription_->whole_in_measure, rq->duration()); } noteheads.add(n); int sidx =find_slur(v); @@ -170,7 +169,7 @@ Simple_walker::process_requests() if (sl->spantype == Span_req::START) { if (find_slur(sl->elt->voice_ )>=0) - error("Too many slurs in voice"); + error_t("Too many slurs in voice", col()->when()); pending_slur_reqs.add(sl); pending_slurs.add(new Slur); } diff --git a/src/slur.cc b/src/slur.cc index f795dc8284..b16aae1f0a 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -7,6 +7,24 @@ #include "molecule.hh" #include "debug.hh" #include "boxes.hh" +void +Slur::calculate() +{ + set_default_dir(); +} + +Offset +Slur::center() const +{ + int pos1 = encompass.last()->position; + int pos2 = encompass[0]->position; + + int dy = pos1-pos2; + + Real w = width().length(); + + return Offset(w/2,dy * paper()->internote()); +} void Slur::add(Notehead*n) diff --git a/src/spanner.cc b/src/spanner.cc index a550227ea6..9a8c1dc36f 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -5,7 +5,10 @@ #include "symbol.hh" #include "molecule.hh" #include "pcol.hh" - +void +Spanner::calculate() +{ +} String Spanner::TeXstring() const { diff --git a/src/staff.cc b/src/staff.cc index 03e22a0398..ef0ff53e58 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -15,7 +15,7 @@ Staff::add(PointerList &l) } void -Staff::process_commands(Real l) +Staff::process_commands(Moment l) { if (staff_commands_) staff_commands_->clean(l); @@ -40,7 +40,7 @@ Staff::clean_cols() } Staff_column * -Staff::get_col(Real w, bool mus) +Staff::get_col(Moment w, bool mus) { Score_column* sc = score_->find_col(w,mus); assert(sc->when == w); @@ -89,7 +89,7 @@ void Staff::setup_staffcols() { for (PCursor i(voices); i.ok(); i++) { - Real now = i->start; + Moment now = i->start; for (PCursor ve(i->elts); ve.ok(); ve++) { Staff_column *sc=get_col(now,true); @@ -99,22 +99,22 @@ Staff::setup_staffcols() } for (PCursor cc(*staff_commands_); cc.ok(); cc++) { - Staff_column *sc=get_col(cc->moment_.when,false); + Staff_column *sc=get_col(cc->tdescription_.when,false); sc->s_commands = cc; - sc->moment_ = new Moment(cc->moment_); + sc->tdescription_ = new Time_description(cc->tdescription_); } PCursor cc(*staff_commands_); for (PCursor i(cols); i.ok(); i++) { while ((cc+1).ok() && (cc+1)->when() < i->when()) cc++; - - if(!i->moment_) { - if (cc->moment_.when == i->when()) - i->moment_ = new Moment(cc->moment_); + + if(!i->tdescription_) { + if (cc->tdescription_.when == i->when()) + i->tdescription_ = new Time_description(cc->tdescription_); else - i->moment_ = new Moment( - i->when() - cc->when() ,&cc->moment_); + i->tdescription_ = new Time_description( + i->when() - cc->when() ,&cc->tdescription_); } } } @@ -138,12 +138,12 @@ Staff::OK() const } -Real +Moment Staff::last() const { - Real l = 0.0; + Moment l = 0.0; for (PCursor i(voices); i.ok(); i++) { - l = MAX(l, i->last()); + l = l >? i->last(); } return l; } diff --git a/src/staffcommands.cc b/src/staffcommands.cc index a0bb71f84c..8a2e945e77 100644 --- a/src/staffcommands.cc +++ b/src/staffcommands.cc @@ -2,10 +2,10 @@ #include "debug.hh" #include "parseconstruct.hh" -Real +Moment Staff_commands_at::when() { - return moment_.when; + return tdescription_.when; } void Staff_commands_at::print() const @@ -13,7 +13,7 @@ Staff_commands_at::print() const #ifndef NPRINT PCursor i (*this); mtor << "Commands at: " ; - moment_.print(); + tdescription_.print(); for (; i.ok(); i++) i->print(); @@ -28,8 +28,8 @@ Staff_commands_at::OK()const assert(i->priority >= (i+1)->priority); } -Staff_commands_at::Staff_commands_at(Moment m) - :moment_(m) +Staff_commands_at::Staff_commands_at(Time_description m) + :tdescription_(m) { } @@ -105,7 +105,11 @@ Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post) insert_between(post, f, l); } - + + +/* + should move this stuff into inputlanguage. + */ void Staff_commands_at::add(Command c) { @@ -207,7 +211,7 @@ Staff_commands::OK() const { #ifndef NDEBUG for (PCursor i(*this); i.ok() && (i+1).ok(); i++) { - assert(i->moment_.when <= (i+1)->moment_.when); + assert(i->tdescription_.when <= (i+1)->tdescription_.when); i->OK(); } #endif @@ -224,13 +228,13 @@ Staff_commands::print() const } Staff_commands_at* -Staff_commands::find(Real w) +Staff_commands::find(Moment w) { PCursor i(bottom()); for (; i.ok() ; i--) { - if (i->moment_.when == w) + if (i->tdescription_.when == w) return i; - if (i->moment_.when < w) + if (i->tdescription_.when < w) break; } return 0; @@ -241,7 +245,7 @@ Staff_commands::add(Staff_commands_at*p) { PCursor i(bottom()); for (; i.ok() ; i--) { - if (i->moment_.when < p->moment_.when) + if (i->tdescription_.when < p->tdescription_.when) break; } if (!i.ok()) @@ -253,16 +257,16 @@ Staff_commands::add(Staff_commands_at*p) } void -Staff_commands::clean(Real l) +Staff_commands::clean(Moment l) { PCursor i(bottom()); - for (; i->moment_.when > l; i=bottom()) { + for (; i->tdescription_.when > l; i=bottom()) { remove(i); } Staff_commands_at*p = find(l); if (!p) { - p = new Staff_commands_at(Moment(l - i->when(), &i->moment_)); + p = new Staff_commands_at(Time_description(l - i->when(), &i->tdescription_)); add(p); } if (!p->is_breakable()) { diff --git a/src/staffline.cc b/src/staffline.cc index afb8085b1a..c3e33fff06 100644 --- a/src/staffline.cc +++ b/src/staffline.cc @@ -13,7 +13,7 @@ make_vbox(Interval i) { String s("\\vbox to "); s += print_dimen(i.length()); - s += "{\\vskip "+print_dimen(i.max)+" "; + s += "{\\vskip "+print_dimen(i.right)+" "; return s; } @@ -68,8 +68,8 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { - PCol *brokenstart = &MAX(*linestart, *sp->left); - PCol *brokenstop = &MIN(*linestop, *sp->right); + PCol *brokenstart = &max(*linestart, *sp->left); + PCol *brokenstop = &min(*linestop, *sp->right); if ( *brokenstart < *brokenstop) { line_of_score_->pscore_-> // higghl add_broken(sp->broken_at(brokenstart,brokenstop)); diff --git a/src/stcol.cc b/src/stcol.cc index d4ba8cec33..9ed22dfe47 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -1,7 +1,7 @@ -#include "stcol.hh" -#include "sccol.hh" #include "voice.hh" -#include "moment.hh" +#include "timedescription.hh" +#include "sccol.hh" +#include "stcol.hh" bool Staff_column::mus() const @@ -9,7 +9,7 @@ Staff_column::mus() const return score_column->musical; } -Real +Moment Staff_column::when() const { return score_column->when; @@ -18,7 +18,7 @@ Staff_column::when() const void Staff_column::add(Voice_element*ve) { - Real d= ve->duration; + Moment d= ve->duration; if (d){ score_column->add_duration(d); } @@ -30,10 +30,10 @@ Staff_column::Staff_column(Score_column*s) { score_column = s; s_commands = 0; - moment_ = 0; + tdescription_ = 0; } Staff_column::~Staff_column() { - delete moment_; + delete tdescription_; } diff --git a/src/stem.cc b/src/stem.cc index 03b91b9316..496425e10f 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -10,7 +10,7 @@ const int STEMLEN=7; -Stem::Stem(int c, Real len) +Stem::Stem(int c, Moment len) { note_length = len; beams_left = 0; @@ -48,7 +48,7 @@ Stem::set_stemend(Real se) top = (dir < 0) ? maxnote : se; bot = (dir < 0) ? se : minnote; - flag = dir*ABS(flag); + flag = dir*abs(flag); } void @@ -116,7 +116,7 @@ Stem::set_noteheads() int parity=0; int lastpos = heads[0]->position; for (int i=1; i < heads.sz(); i ++) { - if (ABS(lastpos- heads[i]->position) == 1) { + if (abs(lastpos- heads[i]->position) == 1) { if (parity) heads[i]->x_dir = (stem_xoffset>0) ? 1:-1; parity = !parity; @@ -138,7 +138,7 @@ Stem::postprocess() Interval Stem::width()const { - if (!print_flag || ABS(flag) <= 4) + if (!print_flag || abs(flag) <= 4) return Interval(0,0); // TODO! Paperdef*p= paper(); Interval r(p->lookup_->flag(flag).dim.x); @@ -161,7 +161,7 @@ Stem::brew_molecole() output = new Molecule(Atom(ss)); - if (print_flag&&ABS(flag) > 4){ + if (print_flag&&abs(flag) > 4){ Symbol fl = p->lookup_->flag(flag); Molecule m(fl); if (flag < -4){ diff --git a/src/swalker.cc b/src/swalker.cc index 98d58324c3..130543dd97 100644 --- a/src/swalker.cc +++ b/src/swalker.cc @@ -13,7 +13,7 @@ Staff_walker::Staff_walker(Staff * s, PScore*ps ) break_status = BREAK_END - BREAK_PRE; } -Real +Moment Staff_walker::when() const { return (* (PCursor *) this)->when(); diff --git a/src/template5.cc b/src/template5.cc new file mode 100644 index 0000000000..2d278a4fce --- /dev/null +++ b/src/template5.cc @@ -0,0 +1,8 @@ +#include "proto.hh" +#include "string.hh" +#include "moment.hh" +#include "real.hh" +#include "interval.cc" + +Interval__instantiate(Real); +Interval__instantiate(Rational); diff --git a/src/texbeam.cc b/src/texbeam.cc index 5c082be669..713bc1f473 100644 --- a/src/texbeam.cc +++ b/src/texbeam.cc @@ -33,9 +33,9 @@ Lookup::beam_element(int sidx, int widx, Real slope) static int slope_index(Real &s) { - if (ABS(s) > 0.5) { + if (abs(s) > 0.5) { WARN << "beam steeper than 0.5"; - s = sgn(s) * 0.5; + s = sign(s) * 0.5; } int i = int(rint(s * 20.0)); diff --git a/src/texslur.cc b/src/texslur.cc index eab9822940..a58a2cf94c 100644 --- a/src/texslur.cc +++ b/src/texslur.cc @@ -1,5 +1,5 @@ #include - +#include "misc.hh" #include "lookup.hh" #include "molecule.hh" #include "dimen.hh" @@ -39,7 +39,7 @@ Lookup::half_slur_middlepart(Real &dx, int dir) Symbol s; - s.dim.y = Interval(MIN(0,0), MAX(0,0)); + s.dim.y = Interval(min(0,0), max(0,0)); s.dim.x = Interval(0,dx); String f = String("\\hslurchar"); @@ -81,7 +81,7 @@ Lookup::half_slur(int dy, Real &dx, int dir, int xpart) Symbol s; s.dim.x = Interval(0,dx); - s.dim.y = Interval(MIN(0,dy), MAX(0,dy)); + s.dim.y = Interval(min(0,dy), max(0,dy)); String f = String("\\hslurchar"); @@ -111,7 +111,7 @@ Symbol Lookup::slur (int dy , Real &dx, int dir) { // ugh. assuming pt here. assert(dx >=0); - int y_sign = sgn(dy); + int y_sign = sign(dy); bool large = dy > 16; @@ -142,7 +142,7 @@ Lookup::slur (int dy , Real &dx, int dir) Symbol s; s.dim.x = Interval(0,dx); - s.dim.y = Interval(MIN(0,dy), MAX(0,dy)); + s.dim.y = Interval(min(0,dy), max(0,dy)); String f = String("\\slurchar") + direction_char(y_sign); @@ -173,7 +173,7 @@ Symbol Lookup::big_slur(int dy , Real &dx, int dir) { assert(dx >= convert_dimen(24,"pt")); - Real slur_extra =ABS(dy) /2.0 + 2; + Real slur_extra =abs(dy) /2.0 + 2; int l_dy = int(Real (dy)/2 + slur_extra*dir); int r_dy = dy - l_dy; diff --git a/src/textspanner.cc b/src/textspanner.cc new file mode 100644 index 0000000000..e33efbb9b3 --- /dev/null +++ b/src/textspanner.cc @@ -0,0 +1,57 @@ +#include "paper.hh" +#include "molecule.hh" +#include "lookup.hh" +#include "boxes.hh" +#include "textspanner.hh" + +Text_spanner::Text_spanner(Directional_spanner*d) +{ + support = d; + align = 0; + style = "roman"; +} + +void +Text_spanner::process() +{ + Offset tpos; + + switch(align) { + case 0: + tpos = support->center(); + break; + default: + assert(false); + break; + } + + Paperdef *pap_p = paper(); + + Atom tsym (pap_p->lookup_->text(style, text, -align)); + tsym.translate(tpos); + output = new Molecule; + output->add( tsym ); +} + +void +Text_spanner::preprocess() +{ + right = support->right; + left = support->left; + assert(left && right); +} + +Interval +Text_spanner::height()const +{ + return output->extent().y; +} + +Spanner* +Text_spanner::broken_at(PCol*c1, PCol*c2)const +{ + Text_spanner *n=new Text_spanner(*this); + n->left = c1; + n->right = c2; + return n; +} diff --git a/src/moment.cc b/src/timedescription.cc similarity index 59% rename from src/moment.cc rename to src/timedescription.cc index 19f8571335..459c15a06d 100644 --- a/src/moment.cc +++ b/src/timedescription.cc @@ -1,20 +1,20 @@ -#include "moment.hh" +#include "timedescription.hh" #include "debug.hh" void -Moment::print() const +Time_description::print() const { - mtor << " at "<0); @@ -35,15 +35,15 @@ Moment::Moment(Real dt, Moment const *prev) } void -Moment::set_meter(int l, int o) +Time_description::set_meter(int l, int o) { assert(o); - one_beat = 1/Real(o); - whole_per_measure = Real(l) * one_beat; + one_beat = 1/Moment(o); + whole_per_measure = Moment(l) * one_beat; } void -Moment::setpartial(Real p) +Time_description::setpartial(Moment p) { if (when) error_t ("Partial measure only allowed at beginning.", when); @@ -51,8 +51,8 @@ Moment::setpartial(Real p) error_t ("Partial measure has incorrect size", when); whole_in_measure = whole_per_measure - p; } -Real -Moment::barleft() +Moment +Time_description::barleft() { return whole_per_measure-whole_in_measure; } diff --git a/src/voice.cc b/src/voice.cc index 8a1c136d04..2f2bbaec53 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -30,10 +30,10 @@ Voice::print() const #endif } -Real +Moment Voice::last() const { - Real l =start; + Moment l =start; for (PCursor vec(elts); vec.ok(); vec++) l += vec->duration; return l; diff --git a/symbol.ini b/symbol.ini index ed7b4f23be..fd28f9ea0f 100644 --- a/symbol.ini +++ b/symbol.ini @@ -3,214 +3,13 @@ % It has a lot of hard-wired stringconstants % -table_sixteen = symboltables { - - texid "\musixsixteendefs" +include "init/dutch.ini" +include "init/table_sixteen.ini" - % index TeXstring, xmin xmax ymin ymax - - - "clefs" = table { - "violin" "\violinclef" 0pt 12.8pt -10pt 18pt - "bass" "\bassclef" 0pt 11.2pt 0pt 16pt - "viola" "\violaclef" 0pt 12.8pt 0pt 16pt - "violin_change" "\cviolinclef" 0pt 11.2pt -12pt 12pt - "bass_change" "\cbassclef" 0pt 12.8pt 0pt 16pt - "viola_change" "\cviolaclef" 0pt 11.2pt 0pt 16pt - } - - "balls" = table { - "1" "\wholeball" 0pt 6pt -2 pt 2pt - "2" "\halfball" 0pt 5pt -2 pt 2pt - "4" "\quartball" 0pt 5pt -2 pt 2pt - } - - "slur" = table { - "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt - "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt - } - "accidentals" = table { - "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt - "-1" "\flat" 0pt 6pt -2.5pt 7.5pt - "0" "\natural" 0pt 6pt -7.5pt 7.5pt - "1" "\sharp" 0pt 6pt -7.5pt 7.5pt - "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt - } - - "streepjes" = table { - "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt - "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt - } - - "bars" = table { - "empty" "\emptybar" 0pt 0pt 0pt 0pt - "|" "\maatstreep" 0pt 5pt -12pt 12pt - "||" "\finishbar" 0pt 2pt -12pt 12pt - } - - "rests" = table { - "1" "\wholerest" -5pt 1pt -1pt 1pt - "2" "\halfrest" -5pt 1pt -1pt 1pt - "4" "\quartrest" -5pt 2pt -5pt 5pt - "8" "\eighthrest" 0pt 5pt 0pt 8pt - "16" "\sixteenthrest" 0pt 6pt 0pt 12pt - "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt - } - - "meters" = table { - "C" "\fourfourmeter" 0pt 10pt -5pt 5pt - "C2" "\allabreve" 0pt 10pt -5pt 5pt - } - - % dims ignored for this table - "param" = table { - "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt - "linestaf" "\linestafsym{%}{%}" - "stem" "\stem{%}{%}" - "fill" "\hbox{}" - } - - "dots" = table { - "1" "\lsingledot" 0pt 2pt -1pt 1pt - "2" "\ldoubledot" 0pt 5pt -1pt 1pt - "3" "\ltripledot" 0pt 8pt -1pt 1pt - } - - "flags" = table { - "8" "\eigthflag" 0pt 4pt 0pt 0pt - "16" "\sixteenthflag" 0pt 4pt 0pt 0pt - "32" "\thirtysecondflag" 0pt 4pt 0pt 0pt - "-8" "\deigthflag" 0pt 4pt 0pt 0pt - "-16" "\dsixteenthflag" 0pt 4pt 0pt 0pt - "-32" "\dthirtysecondflag" 0pt 4pt 0pt 0pt - } - - "beamslopes" = table { - "slope" "\beamslope{%}{%}" - "horizontal" "\rulesym{%}{%}" - } - -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -table_twenty = symboltables { - - texid "\musixtwentydefs" - - - % index TeXstring, xmin xmax ymin ymax - % be careful with editing this: - % the "index" entry is hardwired into lilypond. - - "clefs" = table { - "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt - "bass" "\bassclef" 0pt 16pt 0pt 20pt - "viola" "\violaclef" 0pt 16pt 0pt 20pt - "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt - "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt - "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt - } - - "balls" = table { - "1" "\wholeball" 0pt 7.5pt -2.5pt 2.5pt - "2" "\halfball" 0pt 6pt -2.5pt 2.5pt - "4" "\quartball" 0pt 6pt -2.5pt 2.5pt - } - - "slur" = table { - "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt - "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt - } - "accidentals" = table { - "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt - "-1" "\flat" 0pt 6pt -2.5pt 7.5pt - "0" "\natural" 0pt 6pt -7.5pt 7.5pt - "1" "\sharp" 0pt 6pt -7.5pt 7.5pt - "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt - } - - "streepjes" = table { - "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt - "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt - } - - "bars" = table { - "empty" "\emptybar" 0pt 0pt 0pt 0pt - "|" "\maatstreep" 0pt 5pt -12pt 12pt - "||" "\finishbar" 0pt 2pt -12pt 12pt - } - - "rests" = table { - "1" "\wholerest" -5pt 1pt -1pt 1pt - "2" "\halfrest" -5pt 1pt -1pt 1pt - "4" "\quartrest" -5pt 2pt -5pt 5pt - "8" "\eighthrest" 0pt 5pt 0pt 8pt - "16" "\sixteenthrest" 0pt 6pt 0pt 12pt - "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt - } - - "meters" = table { - "C" "\fourfourmeter" 0pt 10pt -5pt 5pt - "C2" "\allabreve" 0pt 10pt -5pt 5pt - } - - % dims ignored for this table - "param" = table { - "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt - "linestaf" "\linestafsym{%}{%}" - "stem" "\stem{%}{%}" - "fill" "\hbox{}" - } - - "dots" = table { - "1" "\lsingledot" 0pt 8pt -1pt 1pt - "2" "\ldoubledot" 0pt 12pt -1pt 1pt - "3" "\ltripledot" 0pt 16pt -1pt 1pt - } - - "flags" = table { - "8" "\eigthflag" 0pt 5pt 0pt 0pt - "16" "\sixteenthflag" 0pt 5pt 0pt 0pt - "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt - "-8" "\deigthflag" 0pt 5pt 0pt 0pt - "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt - "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt - } - - "beamslopes" = table { - "slope" "\beamslope{%}{%}" - "horizontal" "\rulesym{%}{%}" - } - -} % % common dutch names for notes. "es" means flat, "is" means sharp % -dutch_names = notenames { - "ceses" 0 -2 "ces" 0 -1 "c" 0 0 "cis" 0 1 "cisis" 0 2 - "deses" 1 -2 "des" 1 -1 "d" 1 0 "dis" 1 1 "disis" 1 2 - "eses" 2 -2 "es" 2 -1 "e" 2 0 "eis" 2 1 "eisis" 2 2 - "feses" 3 -2 "fes" 3 -1 "f" 3 0 "fis" 3 1 "fisis" 3 2 - "geses" 4 -2 "ges" 4 -1 "g" 4 0 "gis" 4 1 "gisis" 4 2 - "ases" 5 -2 "as" 5 -1 "a" 5 0 "ais" 5 1 "aisis" 5 2 - "beses" 6 -2 "bes" 6 -1 "b" 6 0 "bis" 6 1 "bisis" 6 2 -} - -% -% f = flat, s = sharp. -% -english_names = notenames { - "cff" 0 -2 "cf" 0 -1 "c" 0 0 "cs" 0 1 "css" 0 2 - "dff" 1 -2 "df" 1 -1 "d" 1 0 "ds" 1 1 "dss" 1 2 - "eff" 2 -2 "ef" 2 -1 "e" 2 0 "es" 2 1 "ess" 2 2 - "fff" 3 -2 "ff" 3 -1 "f" 3 0 "fs" 3 1 "fss" 3 2 - "gff" 4 -2 "gf" 4 -1 "g" 4 0 "gs" 4 1 "gss" 4 2 - "aff" 5 -2 "af" 5 -1 "a" 5 0 "as" 5 1 "ass" 5 2 - "bff" 6 -2 "bf" 6 -1 "b" 6 0 "bs" 6 1 "bss" 6 2 -} - default_table = symboltables { table_sixteen } notenames { dutch_names } -- 2.39.5