From 1ff9a8dbb150839392b2a3a3bf33a90db2db5464 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 4 Jan 1997 00:13:32 +0100 Subject: [PATCH] release: 0.0.21 --- .dstreamrc | 20 ++--- Documentation/README.pod | 48 +++++++----- Documentation/lilygut.pod | 84 +++++++++++++++++++- Makefile | 2 +- NEWS | 7 ++ README | 4 +- Sources.make | 10 ++- Variables.make | 4 +- cadenza.ly | 25 +++--- dimen.tex | 52 ++++++------- flower/Variables.make | 2 +- flower/assoc.hh | 1 + hdr/accidental.hh | 2 +- hdr/bar.hh | 3 +- hdr/beam.hh | 16 ++-- hdr/break.hh | 54 +++++++++++++ hdr/clefitem.hh | 4 +- hdr/grouping.hh | 1 + hdr/idealspacing.hh | 30 ++++++++ hdr/identifier.hh | 3 +- hdr/identparent.hh | 22 +++--- hdr/item.hh | 35 +-------- hdr/keyitem.hh | 11 ++- hdr/lexer.hh | 2 +- hdr/linespace.hh | 20 +++-- hdr/localkeyitem.hh | 13 ++-- hdr/lookup.hh | 2 +- hdr/meter.hh | 3 +- hdr/molecule.hh | 3 +- hdr/notehead.hh | 6 +- hdr/parseconstruct.hh | 7 +- hdr/pcol.hh | 17 ---- hdr/proto.hh | 6 +- hdr/pscore.hh | 21 ++--- hdr/request.hh | 145 ++++++++++++++++++---------------- hdr/rest.hh | 6 +- hdr/script.hh | 37 +++++++++ hdr/scriptdef.hh | 24 ++++++ hdr/simplestaff.hh | 10 ++- hdr/simplewalker.hh | 10 +-- hdr/slur.hh | 13 ++-- hdr/spanner.hh | 36 +++------ hdr/staffelem.hh | 68 ++++++++++++++++ hdr/stem.hh | 13 ++-- hdr/textdef.hh | 24 ++++++ hdr/textitem.hh | 30 ++++++++ hdr/textspanner.hh | 16 ++-- init/Makefile | 2 +- init/dutch.ini | 7 ++ init/script.ini | 14 ++++ init/table_sixteen.ini | 23 +++++- init/table_twenty.ini | 7 +- lilyponddefs.tex | 148 ++++++++++++++++++++--------------- maartje.ly | 10 +-- pavane.ly | 97 +++++++++++++++++------ src/bar.cc | 8 +- src/beam.cc | 82 ++++++++++---------- src/break.cc | 151 +++++++++++++++--------------------- src/calcideal.cc | 5 +- src/clefitem.cc | 7 +- src/grouping.cc | 40 ++++++---- src/idealspacing.cc | 1 + src/identifier.cc | 5 +- src/inputcommands.cc | 8 +- src/inputmusic.cc | 21 +++-- src/inputscore.cc | 4 +- src/inputstaff.cc | 14 ++-- src/item.cc | 69 ++--------------- src/keyitem.cc | 15 ++-- src/lexer.l | 12 ++- src/lexerinit.cc | 2 +- src/linespace.cc | 58 ++++++++++---- src/localkeyitem.cc | 19 ++--- src/lookup.cc | 14 +++- src/meter.cc | 6 +- src/molecule.cc | 11 ++- src/mylexer.cc | 3 + src/note.cc | 79 ++++++++++++++++++- src/notehead.cc | 23 ++---- src/parser.y | 76 ++++++++++++++++-- src/pcol.cc | 5 +- src/pscore.cc | 158 +++++++++++++++++++------------------- src/request.cc | 64 +++++++++++++-- src/rest.cc | 14 +--- src/score.cc | 22 +++--- src/scoreline.cc | 6 +- src/script.cc | 95 +++++++++++++++++++++++ src/scriptdef.cc | 16 ++++ src/simpleprint.cc | 2 +- src/simplestaff.cc | 24 ++++-- src/simplewalker.cc | 55 ++++++++----- src/slur.cc | 68 ++++++++-------- src/spanner.cc | 55 ++++--------- src/staff.cc | 20 ++--- src/staffcommands.cc | 71 ++++++++--------- src/staffelem.cc | 138 +++++++++++++++++++++++++++++++++ src/staffline.cc | 46 ++++++----- src/stem.cc | 35 ++++----- src/swalker.cc | 2 +- src/template1.cc | 4 +- src/template2.cc | 2 +- src/template3.cc | 4 +- src/template4.cc | 4 +- src/template5.cc | 3 +- src/textdef.cc | 24 ++++++ src/textitem.cc | 40 ++++++++++ src/textspanner.cc | 41 +++++----- src/voice.cc | 6 +- src/wordwrap.cc | 71 +++++++++++++++++ symbol.ini | 12 +-- 110 files changed, 2059 insertions(+), 1061 deletions(-) create mode 100644 hdr/break.hh create mode 100644 hdr/idealspacing.hh create mode 100644 hdr/script.hh create mode 100644 hdr/scriptdef.hh create mode 100644 hdr/staffelem.hh create mode 100644 hdr/textdef.hh create mode 100644 hdr/textitem.hh create mode 100644 init/script.ini create mode 100644 src/script.cc create mode 100644 src/scriptdef.cc create mode 100644 src/staffelem.cc create mode 100644 src/textdef.cc create mode 100644 src/textitem.cc create mode 100644 src/wordwrap.cc diff --git a/.dstreamrc b/.dstreamrc index 0fb28ce927..8a79bb8f83 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,12 +1,12 @@ # class name silence? -My_flex_lexer 0 +My_flex_lexer 1 yyFlexLexer 1 PCol 1 Score_column 1 Ineq_constrained_qp 1 -Spacing_problem 1 -Colinfo 1 +Spacing_problem 0 +Colinfo 0 Mixed_qp 1 PScore 1 Idealspacing 1 @@ -25,14 +25,14 @@ Note_req 1 Rhythmic_req 1 Rest_req 1 delete_identifiers 1 -Command 0 -Staff_commands 0 -Stem 0 -Staff 0 -Score 0 -Voice 0 +Command 1 +Staff_commands 1 +Stem 1 +Staff 1 +Score 1 +Voice 1 Voice_element 1 Input_cursor 1 Commands_at 1 Input_command 1 -Moment 0 \ No newline at end of file +Time_description 1 \ No newline at end of file diff --git a/Documentation/README.pod b/Documentation/README.pod index f7226fa03c..6ced7dae17 100644 --- a/Documentation/README.pod +++ b/Documentation/README.pod @@ -13,16 +13,16 @@ F<.ly>'s) into TeX input. =head1 OPTIONS -=item B<-d,--debug> +=item B<-d,--debug>, debugging -=item B<-w,--warranty> +=item B<-w,--warranty>, warranty -=item B<-o,--output> +=item B<-o,--output>, default output file -=item B<-h,--help> +=item B<-h,--help>, help =head1 LICENSE @@ -45,8 +45,9 @@ Compilation: =item - bison/yacc -=item - The "flower" library, which should be available from the - same source you got this from. +=item - The "flower" library, +which should be available from the +same source you got this from. =item - perl @@ -56,9 +57,9 @@ Operation: =over 5 -=item - TeX +=item TeX -=item - the MusixTeX fonts +=item the MusixTeX fonts =back @@ -78,11 +79,21 @@ Do: why G++ >= 2.7? LilyPond & flower lib uses: - builtin bool - typeof - operator ? - the new for-scope - class Rational (libg++) +=over 5 + +=item builtin bool + +=item typeof + +=item operator ? + +=item the new for-scope + +=item class Rational (libg++) + +=item named return values + +=back =head1 AUTHOR @@ -146,7 +157,8 @@ F =head1 FILES -F The initialisation file with symbol tables etc. +F The initialisation file with symbol tables etc. It +includes files from the directory F. =head1 HOW DOES IT WORK @@ -155,11 +167,9 @@ F The initialisation file with symbol tables etc. 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 +the subdir F contains some more-in-depth matter on LilyPond - http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html +The source is commented in the DOC++ style. Check out doc++ at +F =back diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index 5707dcfef9..295ed2844c 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -4,7 +4,8 @@ LilyGuts - doco to the internals of LilyPond =head1 DESCRIPTION -This page documents some aspects of the internals of LilyPond +This page documents some aspects of the internals of LilyPond. Some of +this stuff comes from e-mail I wrote, some from e-mail others wrote, some are large comments taken away from the headers =head1 OVERVIEW @@ -39,8 +40,82 @@ Very simple, just walk all Line_of_* and follow the links over there =back +=head1 REQUESTS + +[see F] + +Any Voice_element can do a number of requests. A request is done +to the C which contains the C. The staff decides +whether to to honor the request, ignore it, or merge it with other +requests. Merging of requests is preferably done with other +requests done by members of the same voicegroups (beams, brackets, stems) + +Please refer to the documentation of the Child classes of +C for explanation of each request type. + +The result of a request will be an C or a C, which +will be put on a C. Note that the C and the original +C need not have anything in common. For example, the +``double'' piano Staff could interpret commands which juggle +melodies across the left and right hand, and may put the result in +two five-line PStaffs (maybe with extra PStaffs to carry the dynamic +signs and any lyric. + +The class C should be thought as a container for the +Cs, and an interpreter for Cs and Cs. +Different staffs can produce different outputs; a melodious voice +which is put into a percussion-Staff, will be typeset as the rythm of +that voice. + +After C made up her mind (Would C be a smart +name? How about C :-), the resultant items and +spanners are put on the PScore, and pointers to these items are +stored in the C. This construction enables the +beams/stems to look up the balls it has to connect to. + +=over 5 + +=item Note_req + +Staff has to decide if the ball should be hanging left or right. This +influences the horizontal dimensions of a column, and this is why +request processing should be done before horizontal spacing. + +Other voices' frivolities may cause the need for accidentals, so this +is also for the Staff to decide. The Staff can decide on positioning +based on ottava commands and the appropriate clef. + +=item Rest_req + +Why a request? It might be a good idea to not typeset the rest, if the +paper is too crowded. + +=item Span_req + +This type of request typically results in the creation of a C + +=item Beam_req + +Staff has to combine this request with the stem_request, since the +number of flags that a stem wants to carry will determine the +number of beams. + +=item Dynamic + +Each dynamic is bound to one note ( a crescendo spanning multiple +notes is thought to be made of two "dynamics": a start and a stop). +Dynamic changes can occur in a smaller time than the length of its +note, therefore fore each Dynamic request carries a time, measured +from the start of its note. + +This subfield would come in handy, if mpp96 was adapted for midi +support. + +=back + =head1 COMMANDS + This table decribes the proper order for the different commands: @@ -206,6 +281,9 @@ signifies a "list of". (This is not complete) =head2 References +[partly by Mark Basinski ] + + Herbert Chlapik, W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In @@ -213,12 +291,12 @@ W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In 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] diff --git a/Makefile b/Makefile index cb118a3ea2..5044425dcd 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ $(CCDIR)/parser.cc: parser.y fi ) mv $(CCDIR)/parser.tab.c $@ -parser.hh: parser.cc +$(parsheadnew): $(CCDIR)/parser.cc version.o: $(obs) version.hh diff --git a/NEWS b/NEWS index 27be7f4bd2..def00e3b86 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +pl 21: + - Move breaking stuff into a separate class Break_algorithm + - dependencies for Staff_elem's + - scripts + - texts + - nplets (triplets!) + pl 20: - Rational for time measurement - updated doco to .pod diff --git a/README b/README index 94d352fc50..9b08b5b1e3 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ -Please refer to the directory Documentation/. +Please refer to the directory Documentation/, Documentation/README.* -To generate the pretty-printed docs, do a: +To generate the pretty-printed docs, do this: make doc diff --git a/Sources.make b/Sources.make index a04e3dd03c..f274a9ebcd 100644 --- a/Sources.make +++ b/Sources.make @@ -18,8 +18,9 @@ hdr= qlp.hh linespace.hh qlpsolve.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 offset.hh - + inputcommand.hh grouping.hh moment.hh offset.hh\ + staffelem.hh idealspacing.hh break.hh\ + scriptdef.hh script.hh textdef.hh textitem.hh mycc= qlp.cc qlpsolve.cc leastsquares.cc\ inputcommands.cc inputmusic.cc \ @@ -40,10 +41,11 @@ mycc= qlp.cc qlpsolve.cc leastsquares.cc\ notehead.cc stem.cc \ rest.cc bar.cc meter.cc keyitem.cc localkeyitem.cc clefitem.cc\ swalker.cc scoreline.cc\ - simplewalker.cc\ + simplewalker.cc scriptdef.cc script.cc\ texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\ idealspacing.cc grouping.cc identifier.cc\ - lexerinit.cc mylexer.cc\ + lexerinit.cc mylexer.cc textdef.cc textitem.cc\ + staffelem.cc wordwrap.cc\ template1.cc template2.cc template3.cc template4.cc\ template5.cc\ version.cc diff --git a/Variables.make b/Variables.make index ac306c7832..cd4a663b6e 100644 --- a/Variables.make +++ b/Variables.make @@ -37,12 +37,12 @@ endif # version info MAJVER=0 MINVER=0 -PATCHLEVEL=20 +PATCHLEVEL=21 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) CXXVER=`$(CXX) --version` #flower version -NEEDEFLOWERVER=1.0.16 +NEEDEFLOWERVER=1.0.17 # directories TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) diff --git a/cadenza.ly b/cadenza.ly index 0ed66019c0..b61616cf02 100644 --- a/cadenza.ly +++ b/cadenza.ly @@ -4,27 +4,30 @@ cad = music { $ \duration { 8} - 'c4. g8 ['e()'d 'c b] - [b()c] g c [c e g 'c] + \textstyle "italic" + 'c4._"f" g8 + \textstyle "roman" + ['e^"accel" ()'d 'c b] + [b()'c] g-\fermata c [c_"rubato" e g 'c] \octave{'} - e4. e [g ()f e d] + e4. e [g ()f_"rit" e d] \duration{16} dis4()e4 r8 [c d] [e f g gis] \duration{4} - a `f()`e g - f `d()`cis e + a-> `f()`e g + f-> `d()`cis e \duration{8} - d4 r8 `a [`b cis] + d4^\fermata r8 `a [`b cis] \duration{16} [d cis d e] f4()[f e d c] `b4 - \octave{} ['c8 b8] % triplet! + \octave{} \plet{2/3} ['d8 'c8 a8] \plet{1/1} % triplet! g2 [g c e g] ['c e g 'c]\octave{'} - [e `g c e] g4 %()% BUG! - [g8.( e g8. )e] + [e `g c e] g4^\fermata %()% BUG! + [g8.(_"a tempo" e g8. )e] a4. g8 [f8 e8 d8 c8] - `g2 d2 + `g2 d2^"tr" c4 $} score { @@ -32,4 +35,4 @@ score { music { cad } } commands { meter 4 4 skip 13:0 } -} \ No newline at end of file +} diff --git a/dimen.tex b/dimen.tex index f1c9bad686..b8a062179a 100644 --- a/dimen.tex +++ b/dimen.tex @@ -1,6 +1,6 @@ \font\musicfnt=musix20 -\font\slurfont=xslhu20 -\def\thefont{\musicfnt} +\font\slurfont=xslu16 +\def\thefont{\slurfont} \def\mb#1{{\thefont\char#1}} @@ -8,42 +8,42 @@ \newdimen\inc \newdimen\here \def\hruler#1{% - \wid=#1pt - \inc=\wid - \divide\inc by #1 - \divide\wid by 2 - \here=-\wid - \loop\ifdim\here<\wid\advance\here by\inc - \hbox to0pt{\kern\here\vrule width0.05pt height 2pt\hss}% - \repeat% + \wid=#1pt + \inc=\wid + \divide\inc by #1 + \divide\wid by 2 + \here=-\wid + \loop\ifdim\here<\wid\advance\here by\inc + \hbox to0pt{\kern\here\vrule width0.05pt height 2pt\hss}% + \repeat% } \def\vruler#1{% - \wid=#1pt - \inc=\wid - \divide\inc by #1 - \divide\wid by 2 - \here=-\wid - \loop\ifdim\here<\wid\advance\here by\inc - \vbox to0pt{\vskip\here\vrule width2pt height 0.05pt\vss}% - \repeat% + \wid=#1pt + \inc=\wid + \divide\inc by #1 + \divide\wid by 2 + \here=-\wid + \loop\ifdim\here<\wid\advance\here by\inc + \vbox to0pt{\vskip\here\vrule width2pt height 0.05pt\vss}% + \repeat% } \def\twhrul{\hbox to 0pt{\hbox{\hruler{20}\vrule - width0.1pt height 3ptdepth 1pt}}} + width0.1pt height 3ptdepth 1pt}}} \def\twvrul{\hbox{\vbox to 20pt{\vruler{20}\vrule - width3pt height 0.1pt}}} + width3pt height 0.1pt}}} \def\doitem#1{ - #1 % - %\twvrul%doesn't work - \hbox to 50pt{\qquad\twhrul\mb{#1}\hss}\setbox0=\hbox{\mb{#1}} width \the\wd0\ depth \the\dp0 \ height \the\ht0} + #1 % + %\twvrul%doesn't work + \hbox to 50pt{\qquad\twhrul\mb{#1}\hss}\setbox0=\hbox{\mb{#1}} width \the\wd0\ depth \the\dp0 \ height \the\ht0} \newcount\n \def\charn{\n=-1 - \loop\ifnum\n<255\advance\n by1 - \doitem{\number\n}\endgraf\repeat} + \loop\ifnum\n<255\advance\n by1 + \doitem{\number\n}\endgraf\repeat} - \charn + \charn \bye \ No newline at end of file diff --git a/flower/Variables.make b/flower/Variables.make index 8bf3820ffc..0c389c10ef 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=20 +PATCHLEVEL=21 PACKAGENAME=flower #PROFILEFLAG=-pg diff --git a/flower/assoc.hh b/flower/assoc.hh index d17b10a70b..c21c4fc6bc 100644 --- a/flower/assoc.hh +++ b/flower/assoc.hh @@ -11,6 +11,7 @@ struct Assoc_ent_ { V val; }; +/// hungarian: map template struct Assoc { Array< Assoc_ent_ > arr; diff --git a/hdr/accidental.hh b/hdr/accidental.hh index ba341a30df..8c601863ae 100644 --- a/hdr/accidental.hh +++ b/hdr/accidental.hh @@ -15,7 +15,7 @@ struct Accidental : Item { Accidental(int type, int position); void print()const; private: - void brew_molecole(); + void brew_molecule(); }; #endif // ACCIDENTAL_HH diff --git a/hdr/bar.hh b/hdr/bar.hh index 187fadfe78..634940121e 100644 --- a/hdr/bar.hh +++ b/hdr/bar.hh @@ -12,7 +12,8 @@ struct Bar: Item { String type; Bar(String type); - void preprocess(); + + Molecule*brew_molecule()const; }; #endif // BAR_HH diff --git a/hdr/beam.hh b/hdr/beam.hh index e376f00978..2fd78100c3 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -24,22 +24,24 @@ struct Beam: public Directional_spanner { virtual Interval width()const; Offset center() const; - Spanner *broken_at(PCol *, PCol *) const; + Spanner *do_break_at(PCol *, PCol *) const; Beam(); void add(Stem*); - void process(); - void calculate(); + + void set_default_dir(); - void preprocess(); - Interval height()const; + void do_pre_processing(); + void do_post_processing(); + void print() const; void set_grouping(Rhythmic_grouping def, Rhythmic_grouping current); void set_stemlens(); ~Beam(); + private: - Molecule stem_beams(Stem *here, Stem *next, Stem *prev); + Molecule stem_beams(Stem *here, Stem *next, Stem *prev)const; void solve_slope(); - void brew_molecule(); + Molecule*brew_molecule()const; }; /** Beam adjusts the stems its owns to make sure that they reach the beam and that point in the correct direction */ diff --git a/hdr/break.hh b/hdr/break.hh new file mode 100644 index 0000000000..4c0f6b33b6 --- /dev/null +++ b/hdr/break.hh @@ -0,0 +1,54 @@ +/* + break.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef BREAK_HH +#define BREAK_HH +#include "vray.hh" +#include "proto.hh" +typedef svec Line_of_cols; + +struct Col_configuration { + Line_of_cols cols; + svec config; + Real energy; + + /****************/ + void OK()const; + void setsol(svec); + Col_configuration() ; + void add( PCol*c); + void print() const; +}; + +struct Break_algorithm { + PScore &pscore_; + Real linelength; + + /****************/ + + Break_algorithm(PScore&); + /// check if the spacing/breaking problem is well-stated + void problem_OK()const; + /// search all pcols which are breakable. + svec find_breaks() const; + + /// helper: solve for the columns in #curline#. + svec solve_line(Line_of_cols) const; + + + /// does curline fit on the paper? + bool feasible(Line_of_cols)const; + + virtual svec solve()=0; +}; + +/// wordwrap type algorithm: move to next line if current is optimal. +struct Word_wrap : Break_algorithm { + virtual svec solve(); + Word_wrap(PScore&); +}; +#endif // BREAK_HH + diff --git a/hdr/clefitem.hh b/hdr/clefitem.hh index f54d49306a..525aa0aeb0 100644 --- a/hdr/clefitem.hh +++ b/hdr/clefitem.hh @@ -16,10 +16,12 @@ struct Clef_item : Item { bool change; + /****************/ + Clef_item(); void read(Clef); void read(String); - void preprocess(); + Molecule* brew_molecule()const; }; #endif // CLEFITEM_HH diff --git a/hdr/grouping.hh b/hdr/grouping.hh index d1c9bac139..9541123b9e 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -45,6 +45,7 @@ struct Rhythmic_grouping { svec generate_beams(svec, int&); private: + void init(); void junk(); void copy(Rhythmic_grouping const&); }; diff --git a/hdr/idealspacing.hh b/hdr/idealspacing.hh new file mode 100644 index 0000000000..801818e7a3 --- /dev/null +++ b/hdr/idealspacing.hh @@ -0,0 +1,30 @@ +/* + idealspacing.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef IDEALSPACING_HH +#define IDEALSPACING_HH +#include "proto.hh" + +/// ideal spacing between two columns +struct Idealspacing { + + /// the ideal distance + Real space; + + /// Hooke's constant: how strong are the "springs" attached to columns + Real hooke; + + /// the two columns + const PCol *left, *right; + + void print()const; + void OK() const ; + Idealspacing(const PCol *left,const PCol *right); +}; + + +#endif // IDEALSPACING_HH + diff --git a/hdr/identifier.hh b/hdr/identifier.hh index da4bfb6b7b..f634e216dc 100644 --- a/hdr/identifier.hh +++ b/hdr/identifier.hh @@ -13,6 +13,7 @@ #include "inputmusic.hh" #include "notename.hh" #include "lookup.hh" +#include "scriptdef.hh" #define make_id_class(Idclass, Class, accessor) \ struct Idclass : Identifier {\ @@ -28,7 +29,7 @@ struct Idclass : Identifier {\ }\ - +make_id_class(Script_id, Script_def, script); make_id_class(Lookup_id, Lookup, lookup); make_id_class(Symtables_id, Symtables, symtables); make_id_class(Staff_id, Input_staff, staff); diff --git a/hdr/identparent.hh b/hdr/identparent.hh index addfd26e0b..653158da4d 100644 --- a/hdr/identparent.hh +++ b/hdr/identparent.hh @@ -9,23 +9,25 @@ #include "proto.hh" #include "string.hh" +#define IDACCESSOR( Input_staff, staff)\ + virtual Input_staff * staff(bool = false) { error(#Input_staff); return 0; } -struct Identifier -{ +struct Identifier { void *data; String name; Identifier(String n) : name(n) { } virtual ~Identifier() {} virtual const char*classname() { return "new Identifier"; } - void error(); - virtual Input_staff * staff(bool = false) { error(); return 0; } - virtual Input_music *music(bool = false) { error(); return 0; } - virtual Music_voice *mvoice(bool = false) { error(); return 0; } - virtual Symtables *symtables(bool = false) { error(); return 0; } - virtual Music_general_chord *mchord(bool = false) { error(); return 0; } - virtual Lookup*lookup(bool = false) { error(); return 0; } - virtual Notename_tab*notename_tab(bool = false) { error(); return 0; } + void error(String); + IDACCESSOR(Input_staff, staff) + IDACCESSOR(Input_music, music) + IDACCESSOR(Music_voice, mvoice) + IDACCESSOR(Script_def, script) + IDACCESSOR(Symtables, symtables) + IDACCESSOR(Music_general_chord, mchord) + IDACCESSOR(Lookup,lookup) + IDACCESSOR(Notename_tab, notename_tab) }; #endif // IDENTPARENT_HH diff --git a/hdr/item.hh b/hdr/item.hh index 33b60831c1..516a7b8f9e 100644 --- a/hdr/item.hh +++ b/hdr/item.hh @@ -4,45 +4,18 @@ #include "glob.hh" #include "boxes.hh" #include "string.hh" - +#include "staffelem.hh" + + /// a horizontally fixed size element of the score -struct Item { +struct Item : Staff_elem { /// indirection to the column it is in PCol * pcol_; - /// indirection to the pstaff it is in - PStaff *pstaff_; - - /// member: the symbols - Molecule *output; - - /// - Offset offset_; - /** - This is needed, because #output# may still be - NULL. - */ /****************/ - - void translate(Offset); - - /// do calculations after determining horizontal spacing - virtual void postprocess(); - - /// do calculations before determining horizontal spacing - virtual void preprocess(); - /** - This is executed directly after the item is added to the - PScore - */ - virtual Interval width() const; - virtual Interval height() const; - String TeXstring () const ; Item(); void print()const; - virtual ~Item(); - Paperdef *paper() const; }; /** Item is the datastructure for printables whose width is known before the spacing is calculated diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index ba49475ce4..ffd0abeb9d 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -9,19 +9,26 @@ #include "item.hh" #include "vray.hh" + +/// struct Keyitem : Item { svec pitch; svec acc; int c_position; + /****************/ Keyitem(int cposition); void add(int pitch, int acc); void read(svec k); + void preprocess(); -private: - void brew_molecole(); + Molecule* brew_molecule()const; }; +/** + An item which places accidentals at the start of the line + */ + #endif // KEYITEM_HH diff --git a/hdr/lexer.hh b/hdr/lexer.hh index 239b7bbe0b..767a12c95e 100644 --- a/hdr/lexer.hh +++ b/hdr/lexer.hh @@ -33,7 +33,7 @@ struct My_flex_lexer : yyFlexLexer { /****************/ void set(Notename_tab *n); - int lookup_keyword(String); + int lookup_keyword(String); void lookup_notename(int &large, int &small, String s); void LexerError(const char *); Identifier*lookup_identifier(String s); diff --git a/hdr/linespace.hh b/hdr/linespace.hh index 8a8742142c..75f4b9fb74 100644 --- a/hdr/linespace.hh +++ b/hdr/linespace.hh @@ -4,18 +4,26 @@ #include "glob.hh" #include "plist.hh" #include "vray.hh" -#include "pcol.hh" -#include "matrix.hh" +#include "vector.hh" +#include "interval.hh" /// helper struct for #Spacing_problem# struct Colinfo { const PCol *pcol_; - bool fixed; - Real fixpos; + const Real* fixpos; + Interval width; + + /****************/ Colinfo(); + void operator=(Colinfo const&); + Colinfo(Colinfo const&); + ~Colinfo(); + Colinfo(const PCol*,const Real*); void print() const; - Real minright() const { return pcol_->width().right; } - Real minleft() const { return -pcol_->width().left; } + bool fixed() const { return fixpos;} + Real fixed_position()const { return *fixpos; } + Real minright() const { return width.right; } + Real minleft() const { return -width.left; } }; diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index cc786e8e7f..05a468b973 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -16,19 +16,16 @@ struct Local_acc { struct Local_key_item : Item { svec accs; - - int c0_position; + svec group; + int c0_position; // move into walker /****************/ Local_key_item(int c0position); - void add(int oct, int pitch, int acc); - - void preprocess(); - -private: - void brew_molecole(); + void add(int oct, int pitch, int acc, Notehead*); + void do_pre_processing(); + Molecule* brew_molecule()const; }; #endif // LOCALKEYITEM_HH diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 5f3a3e7860..5fa14d57a8 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -43,7 +43,7 @@ struct Lookup { 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); - + Symbol script(String idx); Lookup(); diff --git a/hdr/meter.hh b/hdr/meter.hh index a9db9c100a..33838c1525 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -11,9 +11,10 @@ struct Meter: Item { svec args; + /****************/ Meter(svec args) ; - void preprocess(); + Molecule*brew_molecule() const; }; #endif // METER_HH diff --git a/hdr/molecule.hh b/hdr/molecule.hh index b5df9ee383..7419e203de 100644 --- a/hdr/molecule.hh +++ b/hdr/molecule.hh @@ -3,7 +3,6 @@ #include "plist.hh" #include "boxes.hh" -#include "item.hh" #include "symbol.hh" /// a symbol which can be translated, and freely copied @@ -28,7 +27,7 @@ struct Atom { /// a group of #Atom#s struct Molecule { - IPointerList ats; + IPointerList ats; // change to List? /****************/ diff --git a/hdr/notehead.hh b/hdr/notehead.hh index 317d74cc3e..be0a345283 100644 --- a/hdr/notehead.hh +++ b/hdr/notehead.hh @@ -21,17 +21,15 @@ struct Notehead : public Item /****************/ - void preprocess(); Notehead(int staff_size); /** position of top line (5 linestaff: 8) */ - + void print()const; static int compare(Notehead*&a, Notehead*&b) ; -private: - void brew_molecole(); + Molecule* brew_molecule()const; }; /** takes care of: diff --git a/hdr/parseconstruct.hh b/hdr/parseconstruct.hh index f0d8a4ba38..dea0d0cd95 100644 --- a/hdr/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -11,13 +11,18 @@ void set_default_duration(int *); void get_default_duration(int *); void set_default_octave(String); +void set_plet(int,int); Staff * get_new_rhythmstaff(); Voice_element * get_note_element(String,int * ,int *); Voice_element* get_rest_element(String,int *); Staff * get_new_melodicstaff(); void add_requests( Voice_element*v, svec&req); Request* get_request(char); - +void set_text_style(String); +Script_def* get_scriptdef(char); +Text_def*get_text(String s); +Request*get_script_req(int d , Script_def*def); +Request*get_text_req(int d , Text_def*def); #endif // PARSECONSTRUCT_HH diff --git a/hdr/pcol.hh b/hdr/pcol.hh index 1f3e15df3f..7da7c02cb2 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -79,21 +79,4 @@ struct PCol { instantiate_compare(const PCol &, PCol::compare); -/// ideal spacing between two columns -struct Idealspacing { - - /// the ideal distance - Real space; - - /// Hooke's constant: how strong are the "springs" attached to columns - Real hooke; - - /// the two columns - const PCol *left, *right; - - void print()const; - void OK() const ; - Idealspacing(const PCol *left,const PCol *right); -}; - #endif diff --git a/hdr/proto.hh b/hdr/proto.hh index c20d981f15..b11ca6c59f 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -65,6 +65,7 @@ struct Slur_req; struct Span_req; struct Spanner; struct Staff; +struct Col_configuration; struct Staff_column; struct Stem; struct Stem_req; @@ -95,5 +96,8 @@ struct Rhythmic_grouping; struct Staff_commands_at ; struct Commands_at ; struct Time_description; - +struct Script_def; +struct Text_def; +struct Text_req; +struct Melodic_req; #endif // PROTO_HH diff --git a/hdr/pscore.hh b/hdr/pscore.hh index 33741e9263..8ad259412e 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -3,7 +3,7 @@ #ifndef PSCORE_HH #define PSCORE_HH - +#include "break.hh" #include "vray.hh" #include "pcol.hh" #include "pstaff.hh" @@ -54,16 +54,11 @@ struct PScore { /// after calc_breaking void postprocess(); - /// search all pcols which are breakable. - svec< PCol *> find_breaks() const; - /// add a line to the broken stuff. Positions given in #config# - void add_line(svec< PCol *> curline, svec config); - - /// helper: solve for the columns in #curline#. - svec solve_line(svec curline) const; + void set_breaking(svec< Col_configuration> ); void add(PStaff *); + /// add item void typeset_item(Item *, PCol *,PStaff*,int=1); @@ -88,19 +83,13 @@ struct PScore { /// delete unused columns void clean_cols(); - - /// check if the spacing/breaking problem is well-stated - void problem_OK() const; - /// invarinants void OK()const; + PScore(Paperdef*); void print() const; - /// does curline fit on the paper? - bool feasible(svec curline) const; - - /// which is first (left, higher) + /// which is first (left, higher) int compare_pcols( PCol*, PCol*)const; }; /** notes, signs, symbols in a score can be grouped in two ways: diff --git a/hdr/request.hh b/hdr/request.hh index 279947a21c..43b31d75cc 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -13,55 +13,33 @@ struct Request { /****************/ Request(); + virtual ~Request(){} virtual void print()const ; virtual Note_req *note() {return 0;} + virtual Script_req *script() {return 0;} virtual Stem_req *stem() {return 0;} + virtual Text_req*text() { return 0; } virtual Rest_req *rest() {return 0;} virtual Span_req *span() {return 0;} virtual Beam_req *beam() { return 0 ; } virtual Slur_req *slur() { return 0 ; } - virtual Rhythmic_req*rhythmic() { return 0;} + virtual Rhythmic_req*rhythmic() { return 0; } + virtual Melodic_req *melodic() { return 0; } virtual Moment duration() const { return 0.0; } virtual Request* clone() const =0; }; /** - Any Voice_element can do a number of requests. A request is done - to the #Staff# which contains the #Voice_element#. The staff decides - whether to to honor the request, ignore it, or merge it with other - requests. Merging of requests is preferably done with other - requests done by members of the same voicegroups (beams, brackets, stems) - - Please refer to the documentation of the Child classes of - #Request# for explanation of each request type. - - The result of a request will be an #Item# or a #Spanner#, which - will be put on a #PStaff#. Note that the #PStaff# and the original - #Staff# need not have anything in common. For example, the - ``double'' piano Staff could interpret commands which juggle - melodies across the left and right hand, and may put the result in - two five-line PStaffs (maybe with extra PStaffs to carry the dynamic - signs and any lyric. - - The class #Staff# should be thought as a container for the - #Voice#s, and an interpreter for #Request#s and #Command#s. - Different staffs can produce different outputs; a melodious voice - which is put into a percussion-Staff, will be typeset as the rythm of - that voice. - - After #Staff# made up her mind (Would #Staff# be a smart - name? How about #struct Susan {}# :-), the resultant items and - spanners are put on the PScore, and pointers to these items are - stored in the #Voice_element#. This construction enables the - beams/stems to look up the balls it has to connect to. */ +see lilygut page + */ /// a request with a duration -struct Rhythmic_req : Request { +struct Rhythmic_req : virtual Request { int balltype; int dots; - + Moment plet_factor; /****************/ Moment duration() const; @@ -71,30 +49,32 @@ struct Rhythmic_req : Request { Request*clone() const; }; -/// Put a note of specified type, height, and with accidental on the staff. -struct Note_req : Rhythmic_req { - char name; + +struct Melodic_req :virtual Request +{ + /// 0 is c + int name; int octave; int accidental; bool forceacc; - - /****************/ // return height from central c (in halflines) int height()const; - Note_req(); + Melodic_req(); + Melodic_req*melodic() { return this;} + virtual void print() const; + Request*clone() const; +}; + +/// Put a note of specified type, height, and with accidental on the staff. +struct Note_req : Rhythmic_req, virtual Melodic_req { + Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); } + Note_req*note() { return this;} virtual void print() const; Request*clone() const; }; /** -Staff has to decide if the ball should be hanging left or right. This -influences the horizontal dimensions of a column, and this is why -request processing should be done before horizontal spacing. - -Other voices' frivolities may cause the need for accidentals, so this -is also for the Staff to decide. The Staff can decide on positioning -based on ottava commands and the appropriate clef. */ @@ -146,11 +126,8 @@ struct Beam_req : Span_req { virtual Beam_req * beam() { return this; } virtual Request*clone()const; }; -/** Staff will have to combine this with the stem_request, since the - number of flags that a stem wants to carry will determine the - number of beams. if #nplet# is set, the staff will try to put an - appropriate number over the beam - +/** if #nplet# is set, the staff will try to put an +appropriate number over the beam */ /// a slur @@ -160,25 +137,42 @@ struct Slur_req : Span_req { }; -#if 0 +///Put a script above or below this ``note'' +struct Script_req : Request { + int dir; + Script_def *scriptdef; -///Put a lyric above or below (?) this staff. -struct Lyric_req : Request { - String text; + /****************/ + Script_req*script() { return this; } + virtual void print() const; + Request *clone()const; + Script_req(int d, Script_def*); + ~Script_req(); }; +/** eg upbow, downbow. Why a request? These symbols may conflict with +slurs and brackets, so this also a request */ -///Put a script above or below this ``note'' -struct Script_req : Request { - int orientation; - Symbol sym; +///Put a text above or below (?) this staff. +struct Text_req : Request { + int dir; + Text_def *spec; + /****************/ + Text_req*text() { return this; } + virtual void print() const; + Request *clone()const; + Text_req(int d, Text_def*); + ~Text_req(); }; -/** -eg upbow, downbow. Why a request? These symbols may conflict with slurs and brackets, so this -also a request -*/ +#if 0 + +///Put a lyric above or below (?) this staff. +struct Lyric_req : Request { + String text; +}; + ///Draw a (Guitar) chord above or below this ``note'' @@ -199,17 +193,22 @@ enum Loudness { ///Start / stop a slur or a bracket. struct Bracket_req : Span_req { - int nplet; + int nplet; // print a number over the beam. }; + /** Start/stop a bracket at this note. if #nplet# is set, the staff will try to put an appropriate number over the bracket */ -/// helper in the hierarchy -struct Dynamic { +struct Subtle_request { Moment subtime; }; + +/// helper in the hierarchy +struct Dynamic:Subtle_request { + +}; /** Each dynamic is bound to one note ( a crescendo spanning multiple notes is thought to be made of two "dynamics": a start and a stop). Dynamic changes can occur in a smaller time than the length of its @@ -234,7 +233,23 @@ struct Decresc_req : Span_req, Dynamic { /// do a dynamic like "fff" or "mp" struct Absdynamic_req : Request, Dynamic { - Loudness loudness; + Loudness loudness; +}; + +struct Grace_req : Subtle_request { + +}; + +struct Grace_turn_req : Grace_turn { + +}; + +struct Grace_note : Melodic_req { + +}; + +struct Grace_notes { + }; #endif #endif diff --git a/hdr/rest.hh b/hdr/rest.hh index c5d0d7f995..2280611be8 100644 --- a/hdr/rest.hh +++ b/hdr/rest.hh @@ -16,11 +16,11 @@ struct Rest : public Item /****************/ - void preprocess(); + Rest(int dur,int dots); void print()const; -private: - void brew_molecole(); + + Molecule* brew_molecule()const; }; /** takes care of: diff --git a/hdr/script.hh b/hdr/script.hh new file mode 100644 index 0000000000..08d7a64f18 --- /dev/null +++ b/hdr/script.hh @@ -0,0 +1,37 @@ +/* + script.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SCRIPT_HH +#define SCRIPT_HH + +#include "scriptdef.hh" +#include "item.hh" + +struct Script : Item{ + int dir; + int symdir; + int pos; + int staffsize; + Script_def*specs; + Stem * stem_; + Item * support; + + /****************/ + + void set_symdir(); + void set_default_dir(); + void set_default_pos(); + + Molecule* brew_molecule()const; + virtual void do_post_processing(); + virtual void do_pre_processing(); + Script(Script_req*, Item*,int,Stem*p=0); + virtual Interval width() const; +}; + + +#endif // SCRIPT_HH + diff --git a/hdr/scriptdef.hh b/hdr/scriptdef.hh new file mode 100644 index 0000000000..ea5793e21c --- /dev/null +++ b/hdr/scriptdef.hh @@ -0,0 +1,24 @@ +/* + scriptdef.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SCRIPTDEF_HH +#define SCRIPTDEF_HH +#include "string.hh" +struct Script_def{ + int stemdir; + int staffdir; + + bool invertsym; + String symidx; + + /****************/ + void print() const; + Script_def(String, int, int ,bool); +}; + + +#endif // SCRIPTDEF_HH + diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh index d05179b1ba..34e48b0d23 100644 --- a/hdr/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -17,17 +17,23 @@ */ struct Simple_staff; +struct Note_info { + Rhythmic_req *rq; + svec scripts; + Note_info(); + Note_info(Rhythmic_req*); +}; /// column of Simple_staff: store one request struct Simple_column : Staff_column { - svec notes; + svec notes; svec slurs; Stem_req *stem_; Moment stem_requester_len; Beam_req *beam_; Simple_staff* staff_; - + Text_req *text_; /****************/ Slur_req * find_slur(Voice *); diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh index 261394c206..635b9fbbcc 100644 --- a/hdr/simplewalker.hh +++ b/hdr/simplewalker.hh @@ -25,13 +25,9 @@ struct Simple_walker: Staff_walker { Clef clef_; Rhythmic_grouping default_grouping; Rhythmic_grouping *current_grouping; -// Real inbar; // whuh? - svec pending_slur_reqs; svec pending_slurs; - - - + /****************/ virtual void do_TYPESET_command(Command*); @@ -39,12 +35,12 @@ struct Simple_walker: Staff_walker { virtual void process_requests(); virtual void reset(); - void do_note(Rhythmic_req*); + void do_note(Note_info); Simple_walker(Simple_staff*); Simple_column *col(); Simple_staff *staff(); - void do_local_key(Note_req*n); + void do_local_key(Note_req*, Notehead*); int find_slur(const Voice*v); }; diff --git a/hdr/slur.hh b/hdr/slur.hh index df144a88ee..cf8c2261ab 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -20,16 +20,17 @@ struct Slur : Directional_spanner { /****************/ Offset center() const; - void calculate(); - void print()const; - void preprocess(); + Slur(); + void print() const; + void do_post_processing(); + void do_pre_processing(); void add(Notehead*); void set_default_dir(); - Interval height() const; - Spanner* broken_at( PCol*, PCol*) const; + + Spanner* do_break_at( PCol*, PCol*) const; void process(); private: - void brew_molecule(); +Molecule*brew_molecule()const; }; #endif // SLUR_HH diff --git a/hdr/spanner.hh b/hdr/spanner.hh index 86d63527ae..fd646a4b91 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -8,46 +8,32 @@ #define SPANNER_HH #include "proto.hh" -#include "interval.hh" +#include "staffelem.hh" /// a symbol which is attached between two columns. -struct Spanner { +struct Spanner:Staff_elem { PCol *left, *right; - PStaff * pstaff_; - Molecule *output ; + /****************/ - - String TeXstring () const ; + Spanner(); - Paperdef *paper() const; - virtual ~Spanner(); - virtual Interval height()const=0; - /** - PRE: - processed - */ - /// 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(); - + virtual Interval width()const; + void print()const; + Spanner *broken_at(PCol *c1, PCol *c2) const; +protected: /// clone a piece of this spanner. - virtual Spanner *broken_at( PCol *c1, PCol *c2) const=0; + virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0; /** PRE c1 >= start, c2 <= stop */ - virtual void print() const; }; /** - A spanner is a symbol whose appearance can only be calculated after the breaking problem is solved. + A spanner is a symbol whose final appearance can only be calculated + after the breaking problem is solved. Examples diff --git a/hdr/staffelem.hh b/hdr/staffelem.hh new file mode 100644 index 0000000000..a12addbfac --- /dev/null +++ b/hdr/staffelem.hh @@ -0,0 +1,68 @@ +/* + staffelem.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef STAFFELEM_HH +#define STAFFELEM_HH +#include "vray.hh" +#include "proto.hh" +#include "offset.hh" +#include "molecule.hh" + +struct Staff_elem { + enum Status { + ORPHAN, // not yet added to pstaff + VIRGIN, // added to pstaff + PRECALCED, // calcs before spacing done + POSTCALCED, // after spacing calcs done + OUTPUT, // molecule has been output + } status; + bool calc_children; + svec dependencies; + + /// indirection to the pstaff it is in + PStaff *pstaff_; + + /****************/ + + String TeXstring () const ; + virtual void print() const; + virtual Interval width() const; + virtual Interval height() const; + Paperdef *paper() const; + virtual ~Staff_elem(); + Staff_elem(); + + void translate(Offset); + void add_processing(); + void pre_processing(); + void post_processing(); + void molecule_processing(); + +protected: + /// generate the molecule + virtual Molecule* brew_molecule()const=0; + ///executed directly after the item is added to the PScore + virtual void do_add_processing(); + /// do calculations before determining horizontal spacing + virtual void do_pre_processing(); + + /// do calculations after determining horizontal spacing + virtual void do_post_processing(); + +private: + /// member: the symbols + Molecule *output; // should scrap, and use temp var? + + /// + Offset offset_; + /** + This is needed, because #output# may still be + NULL. + */ +}; + +#endif // STAFFELEM_HH + diff --git a/hdr/stem.hh b/hdr/stem.hh index 768b614118..ad2856b0f2 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -49,9 +49,11 @@ struct Stem : public Item { svec heads; /****************/ - + Stem(int center, Moment duration); + /// ensure that this Stem also encompasses the Notehead #n# void add(Notehead*n); + Real hpos()const; void print() const; void set_stemend(Real); @@ -59,14 +61,13 @@ struct Stem : public Item { void set_default_stemlen(); void set_default_extents(); void set_noteheads(); - void postprocess(); - void preprocess(); - Stem(int center, Moment duration); + + + void do_pre_processing(); Interval width() const; -private: - void brew_molecole(); + Molecule* brew_molecule() const; }; /** takes care of: diff --git a/hdr/textdef.hh b/hdr/textdef.hh new file mode 100644 index 0000000000..784420c44b --- /dev/null +++ b/hdr/textdef.hh @@ -0,0 +1,24 @@ +/* + textdef.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef TEXTDEF_HH +#define TEXTDEF_HH + +#include "string.hh" + +struct Text_def { + int align; + String text; + String style; + + /*****************/ + + Text_def(); + void print()const; + Atom create(Paperdef*)const; +}; +#endif // TEXTDEF_HH + diff --git a/hdr/textitem.hh b/hdr/textitem.hh new file mode 100644 index 0000000000..1d37be3286 --- /dev/null +++ b/hdr/textitem.hh @@ -0,0 +1,30 @@ +/* + text.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef TEXT_ITEM_HH +#define TEXT_ITEM_HH + +#include "textdef.hh" +#include "item.hh" + +struct Text_item : Item{ + int pos; + int staffsize; + int dir; + Text_def*specs; + + /****************/ + + void set_default_pos(); + Molecule* brew_molecule()const; + void do_pre_processing(); + + Text_item(Text_req*,int); +}; + + +#endif // TEXT_HH + diff --git a/hdr/textspanner.hh b/hdr/textspanner.hh index 6a0aa3e761..1e9d06d543 100644 --- a/hdr/textspanner.hh +++ b/hdr/textspanner.hh @@ -9,18 +9,20 @@ #include "string.hh" #include "directionalspanner.hh" +#include "textdef.hh" /// a spanner which puts texts on top of other spanners. struct Text_spanner : Spanner { - int align; - String text; - String style; + Text_def spec; + Offset tpos; Directional_spanner*support; /****************/ - virtual void process(); - virtual void preprocess(); - virtual Interval height() const; - virtual Spanner* broken_at(PCol*,PCol*)const; + virtual void do_pre_processing(); + virtual void do_post_processing(); + Molecule* brew_molecule()const; + virtual Interval height() const ; + void print() const; + virtual Spanner* do_break_at(PCol*,PCol*)const; Text_spanner(Directional_spanner*); }; /** diff --git a/init/Makefile b/init/Makefile index 9e9b75f0f9..b9d962d1ed 100644 --- a/init/Makefile +++ b/init/Makefile @@ -1,5 +1,5 @@ DFILES=dutch.ini table_sixteen.ini table_twenty.ini\ - english.ini + english.ini script.ini dist: ln Makefile $(DFILES) $(DDIR)/$(INITDIR) diff --git a/init/dutch.ini b/init/dutch.ini index d573656deb..6502ec4452 100644 --- a/init/dutch.ini +++ b/init/dutch.ini @@ -1,3 +1,8 @@ +% +% 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 @@ -9,3 +14,5 @@ notenames { "beses" 6 -2 "bes" 6 -1 "b" 6 0 "bis" 6 1 "bisis" 6 2 } + +notenames { dutch_names } \ No newline at end of file diff --git a/init/script.ini b/init/script.ini new file mode 100644 index 0000000000..6ac23c92c5 --- /dev/null +++ b/init/script.ini @@ -0,0 +1,14 @@ + +% name = script { +% indexstring same_dir_as_stem above_below_staff symbol_can_beinverted } +% + +fermata = script { "fermata" 1 0 1 } +stopped = script { "stopped" 0 1 0 } +accent = script { "accent" -1 0 0 } +staccato = script { "staccato" -1 0 0 } +staccatissimo = script { "staccatissimo" 1 0 1 } +portato = script { "portato" -1 0 0 } +marcato = script { "marcato" -1 0 1 } +upbow = script { "upbow" 0 1 0 } +downbow = script { "downbow" 0 1 0 } diff --git a/init/table_sixteen.ini b/init/table_sixteen.ini index 8b506b8224..2b719ecd88 100644 --- a/init/table_sixteen.ini +++ b/init/table_sixteen.ini @@ -1,3 +1,8 @@ +% +% spacing info for LilyPond. Do not edit this. +% It has a lot of hard-wired stringconstants +% + table_sixteen= symboltables { @@ -5,10 +10,23 @@ symboltables { % index TeXstring, xmin xmax ymin ymax + "scripts" = table { + "fermata" "\fermata" 0pt 0pt 0pt 11.25pt + "-fermata" "\ifermata" 0pt 0pt -11.25pt 0pt + "portato" "\portato" 0pt 0pt 0pt 0pt + "accent" "\maccent" -1pt 8pt 0pt 0pt + "marcato" "\marcato" 0pt 0pt 0pt 11.25pt + "-marcato" "\imarcato" 0pt 0pt -11.25pt 0pt + "staccato" "\staccato" 0pt 0pt 0pt 5pt + "staccatissimo" "\staccatissimo" 0pt 0pt 0pt 7.5pt + "istaccatissimo" "\staccatissimo" 0pt 0pt -7.5pt 0pt + "upbow" "\upbow" -1pt 6pt 0pt 5pt + "downbow" "\downbow" 0pt 5pt 0pt 7.5pt + } "style" = table { - "roman" "\settext{%}" 0pt 0pt 0pt 0pt - "italic" "\setitalic{%}" 0pt 0pt 0pt 0pt + "roman" "\settext{%}" 0pt 0pt 0pt 8pt + "italic" "\setitalic{%}" 0pt 0pt 0pt 8pt } "align" = table { "-1" "\leftalign{%}" 0pt 0pt 0pt 0pt @@ -97,3 +115,4 @@ symboltables { } } +default_table = symboltables { table_sixteen } \ No newline at end of file diff --git a/init/table_twenty.ini b/init/table_twenty.ini index 1b49eab1dd..780e0b2e86 100644 --- a/init/table_twenty.ini +++ b/init/table_twenty.ini @@ -1,5 +1,7 @@ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% spacing info for LilyPond. Do not edit this. +% It has a lot of hard-wired stringconstants +% table_twenty = symboltables { @@ -101,3 +103,4 @@ table_twenty = symboltables { } } +default_table = symboltables { table_twenty } \ No newline at end of file diff --git a/lilyponddefs.tex b/lilyponddefs.tex index da2c971f2f..24df3eedaa 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -6,55 +6,59 @@ %% musix defs \parindent=0pt \newdimen\interlinedist - \newcount\n - \newdimen\balkhoog - \newdimen\notewidth - \newdimen\notewidthhalf - \newdimen\notewidthdouble - \newdimen\staffrulethickness - \newdimen\interstaffrule - + \newcount\n + \newdimen\balkhoog + \newdimen\notewidth + \newdimen\notewidthhalf + \newdimen\notewidthdouble + \newdimen\staffrulethickness + \newdimen\interstaffrule +\newdimen\balkhalf \def\musixtwentydefs{ - \font\textfont=cmr10 - \font\slurufont=xslu20 - \font\slurdfont=xsld20 - \font\slurhfont=xslz20 - \font\hslurufont=xslhu20 - \font\hslurdfont=xslhd20 - \font\hslurhfont=xslhz20 - \font\musicfnt=musix20 - \font\italicfont=cmti10 - \balkhoog=20pt - \notewidth=6pt - \staffrulethickness=0.4pt - - \musixcalc + \font\textfont=cmr10 + \font\meterfont=cmbx12 + \font\slurufont=xslu20 + \font\slurdfont=xsld20 + \font\slurhfont=xslz20 + \font\hslurufont=xslhu20 + \font\hslurdfont=xslhd20 + \font\hslurhfont=xslhz20 + \font\musicfnt=musix20 + \font\italicfont=cmti10 + \balkhoog=20pt + \notewidth=6pt + \staffrulethickness=0.4pt + + \musixcalc } \def\musixsixteendefs{ - \font\textfont=cmr8 - \font\italicfont=cmti8 - \font\slurufont=xslu16 - \font\slurdfont=xsld16 - \font\slurhfont=xslz20 % sigh - \font\hslurufont=xslhu16 - \font\hslurdfont=xslhd16 - \font\hslurhfont=xslhz20 - \font\musicfnt=musix16 - \balkhoog=16pt - \staffrulethickness=0.4pt - \notewidth=5pt - \musixcalc + \font\textfont=cmr8 + \font\meterfont=cmbx12 + \font\italicfont=cmti8 + \font\slurufont=xslu16 + \font\slurdfont=xsld16 + \font\slurhfont=xslz20 % sigh + \font\hslurufont=xslhu16 + \font\hslurdfont=xslhd16 + \font\hslurhfont=xslhz20 + \font\musicfnt=musix16 + \balkhoog=16pt + \staffrulethickness=0.4pt + \notewidth=5pt + \musixcalc } \def\musixcalc{ - \interstaffrule=\balkhoog - \advance\interstaffrule by-\staffrulethickness - \divide\interstaffrule by 4 - \advance\interstaffrule by -\staffrulethickness - \notewidthhalf=\notewidth - \notewidthdouble=\notewidth - \divide \notewidthhalf by 2 - \multiply \notewidthdouble by 2 + \interstaffrule=\balkhoog + \advance\interstaffrule by-\staffrulethickness + \divide\interstaffrule by 4 + \advance\interstaffrule by -\staffrulethickness + \notewidthhalf=\notewidth + \notewidthdouble=\notewidth + \divide \notewidthhalf by 2 + \multiply \notewidthdouble by 2 + \balkhalf=\balkhoog + \divide \balkhalf by 2 } @@ -101,17 +105,19 @@ \def\maatstreep{\vrule height\balkhoog} \def\finishbar{\vrule height\balkhoog width 1pt} -\def\generalmeter#1#2{\vbox to 0pt{\vss\textfont\hbox{#1}\hbox{#2}}} +\def\generalmeter#1#2{\botalign{\vbox to\balkhalf{\vss \meterfont#1}% + \nointerlineskip + \vbox to \balkhalf{\vss\meterfont #2}}} \def\lineseparator{\vbox{\mussepline\vskip -5pt\mussepline}} \def\beauty{% - \par\vskip 10pt plus 30pt minus 10pt\par - \hskip -5pt\lineseparator - \par\vskip 10pt plus 30pt minus 10pt\par + \par\vskip 10pt plus 30pt minus 10pt\par + \hskip -5pt\lineseparator + \par\vskip 10pt plus 30pt minus 10pt\par } \def\interstaffline{% - \vskip 10pt + \vskip 10pt } \def\ugly{\nointerlineskip\par \vskip 40pt\par\vbox{\leftalign{\vrule width30pt height1pt}}\par\vskip 40pt @@ -121,25 +127,22 @@ \def\lines#1#2{% \vbox{\kern-\interstaffrule - \n=0\nointerlineskip% - \loop\ifnum\n<#1\advance\n by1% - \kern\interstaffrule - \hrule height \staffrulethickness width#2 - \repeat - }} + \n=0\nointerlineskip% + \loop\ifnum\n<#1\advance\n by1% + \kern\interstaffrule + \hrule height \staffrulethickness width#2 + \repeat + }} \def\toplines#1{ % why space needed here? - \vbox to 0pt{\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}\vss}} + \topalign{\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}}} \def\botlines#1{ % idem ditto - \vbox to 0pt{\vss\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}}} + \botalign{\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}}} % % a staffsymbol with #1 lines, width #2 % bottom at baseline -\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}} +\def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}}}} \def\eigthflag{\topalign{\ueigthflag}} \def\sixteenthflag{\topalign{\usixteenthflag}} @@ -154,12 +157,28 @@ \def\ldoubledot{\kern-\notewidth\doubledot} \def\ltripledot{\kern-\notewidth\tripledot} - +\mdef\maccent{30} +\mdef\fermata{80} +\mdef\ifermata{81} +\mdef\iaccent{31} +\mdef\msxmarcato{20} +\def\marcato{\botalign{\msxmarcato}} +\mdef\msximarcato{21} +\def\imarcato{\topalign{\msximarcato}} +\mdef\staccato{24} +\mdef\istaccato{25} +\mdef\staccatissimo{16} +\mdef\istaccatissimo{17} +\mdef\spicato{28} +\mdef\ispicato{29} +\mdef\upbow{22} +\mdef\downbow{23} +\mdef\portato{26} \def\stem#1#2{\vrule height#2 depth-#1} \def\placebox#1#2#3{% - \vbox to 0pt{\vss\hbox{\raise #1\leftalign{\kern #2{}#3}}}% + \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}% } @@ -169,5 +188,10 @@ \def\settext#1{\textfont #1} \def\setitalic#1{\italicfont #1} +\def\vcenter#1{\vbox to 0pt{\vss #1\vss}} + +\def\topalign#1{\vbox to 0pt{#1\vss}} +\def\botalign#1{\vbox to 0pt{\vss #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 d0ca0dfb75..28d1d78040 100644 --- a/maartje.ly +++ b/maartje.ly @@ -29,11 +29,11 @@ c8 \duration {4} { - \music { c () `bes c} - \music { 'fis ()'gisis fis } - \music { d () d dis } - \music { a () bes eis } - \music { fis () g gis } + \music { c () `bes [c8 c8] } + \music { 'fis ()'gisis fis8 fis8 } + \music { d () d dis8 dis8 } + \music { a () bes eis8 eis8 } + \music { fis () g gis8 gis8 } } { c4 'c4 } diff --git a/pavane.ly b/pavane.ly index fd66d490cd..96fb1da3da 100644 --- a/pavane.ly +++ b/pavane.ly @@ -12,33 +12,80 @@ staff {melodic \duration { 8} % 1 - d2( [)d e cis `b] `a4 [`b cis] [cis `b] `b4 - fis2( [)fis g e d] cis4 [d e(] [)e fis d cis] - `b4 [cis d(] [)d e cis `b] cis2 r2 - r4 fis2 fis4 fis2()[fis e a fis] - fis4 e4 d4 e4 `b2()[`b `a( d cis] + d2( [)d e cis `b] + `a4 [`b cis] [cis `b] `b4 + fis2( [)fis g e d] + cis4 [d e(] [)e fis d cis] + `b4 [cis d(] [)d e cis `b] + cis2 r2^"c\'edez" + r4 fis2 fis4 + fis2^"en mesure" ()[fis e a fis] + fis4-- e4-- d4-- e4-- + `b2()[`b^"un peu retenu" `a( d cis] % 11 - )`b [`fis `a `b] cis4 `b4 `fis2 r2 - cis4 d4()[d cis d e] + )`b [`fis^"en \'elargissant"-- `a-- `b--] cis4-- `b4-- + `fis2 r2 + cis4^"1er mouvement" d4^"tr\`es lontain" ()[d cis d e] \octave { } - a4 gis2. - a4 b4()[b a b 'cis] fis4 e4 cis2 - e4 fis4 () [fis e fis gis] cis4 `b4()`b8 r8 r4 + a4 gis2. + a4 b4()[b a b 'cis] + fis4 e4 cis2 + e4 fis4 () [fis e fis gis] + cis4 `b4()`b8 r8 r4^"tr\`es soutenu" - r4 r4 'cis4 'd4 () ['d 'cis 'd 'e] - a4 gis2. a4 b4()[b a b 'cis] - fis4 e4 cis2 e4 fis4()[fis e fis gis] - cis4 `b4()`b8 r8 r4 r1 - r2 r4 r4 + r4 r4 %2/4 meter + + 'cis4_"ppp" 'd4 () ['d 'cis 'd 'e] + a4 gis2. + a4 b4()[b a b 'cis] + fis4 e4 cis2 + e4_"pp" fis4()[fis e fis gis] + cis4_"mf" `b4()`b8 r8 r4^"un peu plus lent" + r1 + r2 r4 r4%^\fermata %% cut 'n paste. \octave { ' } - d2( [)d e cis `b] `a4 [`b cis] [cis `b] `b4 - fis2( [)fis g e d] cis4 [d e(] [)e fis d cis] - `b4 [cis d(] [)d e cis `b] cis2 r2 - r4 fis2 fis4 fis2()[fis e a fis] - fis4 e4 d4 e4 `b2() [`b `a d cis] - `b [`fis `a `b] cis4 `b4 `fis2 r2 - $} + d2^"Reprenez le mouvement"( [)d e cis `b] + `a4 [`b cis] [cis `b] `b4 + fis2( [)fis g e d] + cis4 [d e(] [)e fis d cis] + `b4 [cis d(] [)d e cis `b] + cis2 r2^"c\'edez" + r4 fis2 fis4 + fis2^"en mesure"()[fis e a fis] + fis4-- e4-- d4-- e4-- + `b2() [`b `a-. d-. cis-.] + `b-. [`fis^"large" `a `b] cis4 `b4 `fis2 r2 + r1 + \duration {8} + r2 [c-.( e-. c-. )`a-. ] + \plet {2/3}\octave{} + [c e a ] \plet{1/1} b4-> () [b c-- e-- a--] + b4. b8()g2 + r1 + r2 + [f a f d] + \plet {2/3} + [f a 'c] \plet{1/1} 'e4-^ () ['e f-> a-> 'c->] + e4._"sf" e8()c4 r4 + r1 + r4 r4-\fermata + \octave { ' } + d2( [)d e cis `b] + `a4 [`b cis] [cis `b] `b4 + fis2( [)fis g e d] + cis4 [d e(] [)e fis d cis] + `b4 [cis d(] [)d e cis `b] + cis2 r2^"c\'edez" + r4 fis2 fis4 + fis2()[fis e a fis] + fis4-- e4-- d4-- e4-- + \octave{ } + b2()[b a 'd 'cis] + b [fis a b ] 'cis4 b4 + fis2 r2 + r1-\fermata + $} commands { key $fis cis $ } @@ -58,6 +105,10 @@ score { meter 2 4 skip 1:0 meter 4 4 - skip 20:0 + skip 29:0 + meter 2 4 + skip 1:0 + meter 4 4 + skip 13:0 } } \ No newline at end of file diff --git a/src/bar.cc b/src/bar.cc index bb66f2b777..01807f123e 100644 --- a/src/bar.cc +++ b/src/bar.cc @@ -9,10 +9,12 @@ Bar::Bar( String t) { type = t; } -void -Bar::preprocess() +Molecule* +Bar::brew_molecule()const { Symbol s = paper()->lookup_->bar(type); - output = new Molecule(Atom(s)); +Molecule* output = new Molecule(Atom(s)); +return output; + } diff --git a/src/beam.cc b/src/beam.cc index 85d5cc4812..5edf3ce7eb 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -37,8 +37,11 @@ Stem_info::Stem_info(const Stem*s) Offset Beam::center()const { - if(!dir) - ((Beam*)this)->calculate(); + assert(status >= POSTCALCED); + if (calc_children){ // URGGGG!!! + Beam*me_p = (Beam*)this; + me_p->do_post_processing(); + } Real w=width().length()/2; return Offset(w, (left_pos + w* slope)*paper()->interline()); @@ -57,6 +60,7 @@ void Beam::add(Stem*s) { stems.bottom().add(s); + s->dependencies.add(this); s->print_flag = false; } @@ -65,13 +69,13 @@ Beam::set_default_dir() { int dirs[2]; dirs[0]=0; dirs[1] =0; - for (PCursor sc(stems); sc.ok(); sc++) { - sc->set_default_dir(); - dirs[(sc->dir+1)/2] ++; + for (iter_top(stems,i); i.ok(); i++) { + i->set_default_dir(); + dirs[(i->dir+1)/2] ++; } dir = (dirs[0] > dirs[1]) ? -1 : 1; - for (PCursor sc(stems); sc.ok(); sc++) { - sc->dir = dir; + for (iter_top(stems,i); i.ok(); i++) { + i->dir = dir; } } @@ -82,10 +86,10 @@ void Beam::solve_slope() { svec sinfo; - for (PCursorsc(stems); sc.ok(); sc++) { - sc->set_default_extents(); - Stem_info i(sc); - sinfo.add(i); + for (iter_top(stems,i); i.ok(); i++) { + i->set_default_extents(); + Stem_info info(i); + sinfo.add(info); } Real leftx = sinfo[0].x; Least_squares l; @@ -106,13 +110,17 @@ Beam::solve_slope() left_pos += dy; left_pos *= dir; slope *= dir; - + + // URG + Real sl = slope*paper()->internote(); + paper()->lookup_->beam(sl, convert_dimen(20,"pt")); + slope = sl /paper()->internote(); } void Beam::set_stemlens() { - PCursor s(stems); + iter_top(stems,s); Real x0 = s->hpos(); for (; s.ok() ; s++) { Real x = s->hpos()-x0; @@ -120,22 +128,11 @@ Beam::set_stemlens() } } -void -Beam::calculate() -{ - assert(stems.size()>1); - if (!dir) - set_default_dir(); - - solve_slope(); -} void -Beam::process() +Beam::do_post_processing() { - calculate(); - - brew_molecule(); + solve_slope(); set_stemlens(); } @@ -150,7 +147,7 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) group = new Rhythmic_grouping(cur); svec b; { - PCursor s(stems); + iter_top(stems,s); svec flags; for (; s.ok(); s++) { int f = intlog2(abs(s->flag))-2; @@ -164,7 +161,7 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) assert(stems.size() == b.sz()/2); } - PCursor s(stems); + iter_top(stems,s); for (int i=0; i < b.sz() && s.ok(); i+=2, s++) { s->beams_left = b[i]; s->beams_right = b[i+1]; @@ -174,24 +171,23 @@ Beam::set_grouping(Rhythmic_grouping def, Rhythmic_grouping cur) // todo. Spanner * -Beam::broken_at( PCol *, PCol *) const +Beam::do_break_at( PCol *, PCol *) const { return new Beam(*this); } void -Beam::preprocess() +Beam::do_pre_processing() { left = (*stems.top()) ->pcol_; right = (*stems.bottom())->pcol_; -} + assert(stems.size()>1); + if (!dir) + set_default_dir(); -Interval -Beam::height() const -{ - return output->extent().y; } + Interval Beam::width() const { @@ -204,7 +200,7 @@ Beam::width() const beams to go with one stem. */ Molecule -Beam::stem_beams(Stem *here, Stem *next, Stem *prev) +Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const { assert( !next || next->hpos() > here->hpos() ); assert( !prev || prev->hpos() < here->hpos() ); @@ -212,7 +208,7 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev) Real stemdx = paper()->rule_thickness(); Real sl = slope*paper()->internote(); paper()->lookup_->beam(sl, convert_dimen(20,"pt")); - slope = sl /paper()->internote(); + Molecule leftbeams; Molecule rightbeams; @@ -258,15 +254,15 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev) } -void -Beam::brew_molecule() +Molecule* +Beam::brew_molecule() const return out; { assert(left->line == right->line); Real inter=paper()->internote(); - output = new Molecule; + out = new Molecule; Real x0 = stems.top()->hpos(); - for (PCursor i(stems); i.ok(); i++) { + for (iter_top(stems,i); i.ok(); i++) { PCursor p(i-1); PCursor n(i+1); Stem * prev = p.ok() ? p.ptr() : 0; @@ -275,9 +271,9 @@ Beam::brew_molecule() Molecule sb = stem_beams(i, next, prev); Real x = i->hpos()-x0; sb.translate(Offset(x, (x * slope + left_pos)* inter)); - output->add(sb); + out->add(sb); } - output->translate(Offset(x0 - left->hpos,0)); + out->translate(Offset(x0 - left->hpos,0)); } void diff --git a/src/break.cc b/src/break.cc index ff86e848af..e27abd9b84 100644 --- a/src/break.cc +++ b/src/break.cc @@ -2,134 +2,109 @@ do calculations for breaking problem */ +#include "break.hh" #include "paper.hh" #include "linespace.hh" #include "debug.hh" #include "scoreline.hh" #include "pscore.hh" + +/* + return all breakable columns + */ +svec +Break_algorithm::find_breaks() const +{ + svec retval; + for (iter_top(pscore_.cols,c); c.ok(); c++) + if (c->breakable()) + + + retval.add(c); + + return retval; +} + // construct an appropriate Spacing_problem and solve it. svec -PScore::solve_line(svec< PCol *> curline) const +Break_algorithm::solve_line(Line_of_cols curline) const { Spacing_problem sp; sp.add_column(curline[0], true, 0.0); for (int i=1; i< curline.sz()-1; i++) sp.add_column(curline[i]); - sp.add_column(curline.last(), true, paper_->linewidth); + sp.add_column(curline.last(), true, linelength); // misschien moeven uit Spacing_problem? - for (PCursor i(suz); i.ok(); i++) { + for (iter_top(pscore_.suz,i); i.ok(); i++) { sp.add_ideal(i); } svec the_sol=sp.solve(); return the_sol; } +Break_algorithm::Break_algorithm(PScore&s) + :pscore_(s) +{ + linelength = s.paper_->linewidth; +} + bool -PScore::feasible(svec< PCol *> curline) const +Break_algorithm::feasible(Line_of_cols curline) const { Real l =0; for (int i=0; i < curline.sz(); i++) l +=curline[i]->width().length(); - return l < paper_->linewidth; + return l < linelength; } void -PScore::problem_OK() const +Break_algorithm::problem_OK() const { - if (!cols.size()) - error("PScore::problem_OK(): Score does not have any columns"); - PCursor start(cols); - PCursor end (((PScore*)this)->cols.bottom()); + if (!pscore_.cols.size()) + error("Score does not have any columns"); +#ifndef NDEBUG + iter_top(pscore_.cols,start); + PCursor end (pscore_.cols.bottom()); assert(start->breakable()); assert(end->breakable()); +#endif } -struct Col_configuration { - svec< PCol*> line; - svec config; - Real energy; - - Col_configuration() { - energy = INFTY; - } - void add( PCol*c) { line.add(c);} - void setsol(svec sol) { - config = sol; - energy = config.last(); - config.pop(); - } - void print() const { -#ifndef NPRINT - mtor << "energy : " << energy << '\n'; - mtor << "line of " << config.sz() << " cols\n"; -#endif - } -}; +/****************/ -/// wordwrap type algorithm -/* el stupido. This should be done more accurately: +Col_configuration::Col_configuration() +{ + energy = INFTY; +} - It would be nice to have a Dynamic Programming type of algorithm - similar to TeX's - - */ +void +Col_configuration::add( PCol*c) +{ + cols.add(c); +} void -PScore::calc_breaking() +Col_configuration::setsol(svec sol) { - OK(); - problem_OK(); - PCursor curcol(cols); - - svec breakpoints(find_breaks()); - assert(breakpoints.sz()>=2); - for (int i=0 ; i < breakpoints.sz() -1; ) { - Col_configuration minimum; - Col_configuration current; - - // do another line - PCol *post = breakpoints[i]->postbreak; - current.add( post); - curcol++; // skip the breakable. - i++; - - while (i < breakpoints.sz()) { - - // add another measure. - while (breakpoints[i] != curcol.ptr()){ - - current.add(curcol); - curcol++; - } - current.add(breakpoints[i]->prebreak ); - if (!feasible(current.line)) { - if (!minimum.line.sz()) - error("sorry, this measure is too long"); - break; - } - current.setsol(solve_line(current.line)); - current.print(); - - if (current.energy < minimum.energy) { - minimum = current; - } else { // we're one col too far. - i--; - while (curcol.ptr() != breakpoints[i]) - curcol --; - - break; - } - - current.line.last()=breakpoints[i]; - curcol ++; - i++; - } - mtor << "Adding line, next breakpoint " << i << '\n'; - add_line(minimum.line, minimum.config); - } + config = sol; + energy = config.last(); + config.pop(); } +void +Col_configuration::print() const +{ +#ifndef NPRINT + mtor << "energy : " << energy << '\n'; + mtor << "line of " << config.sz() << " cols\n"; +#endif +} +void +Col_configuration::OK()const +{ + assert(config.sz() == cols.sz()); +} diff --git a/src/calcideal.cc b/src/calcideal.cc index faf88d6ead..77cef180ef 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -1,3 +1,4 @@ +#include "idealspacing.hh" #include "tstream.hh" #include "score.hh" #include "pscore.hh" @@ -37,11 +38,11 @@ Score::connect(PCol* c1, PCol *c2, Real d, Real h) void Score::calc_idealspacing() { - PCursor i(cols_); + iter_top(cols_,i); for (; i.ok(); i++) { assert(i->used()); - PCursor j (i+1); + PCursor j(i+1); if (i->musical) { assert(j.ok()); for (int n=0; n < i->durations.sz(); n++) { diff --git a/src/clefitem.cc b/src/clefitem.cc index 3e10f88867..4289c64374 100644 --- a/src/clefitem.cc +++ b/src/clefitem.cc @@ -25,14 +25,15 @@ Clef_item::read(Clef k) read(k.clef_type); } -void -Clef_item::preprocess() +Molecule* +Clef_item::brew_molecule()const { String t = type; if (change) t += "_change"; Symbol s = paper()->lookup_->clef(t); - output = new Molecule(Atom(s)); + Molecule*output = new Molecule(Atom(s)); output->translate(Offset(0, paper()->interline()/2 * y_off)); + return output; } diff --git a/src/grouping.cc b/src/grouping.cc index 3252178849..c7d38dbdae 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -2,6 +2,13 @@ #include "grouping.hh" #include "interval.hh" +void +Rhythmic_grouping::init() +{ + interval_ = 0; + children.set_size(0); +} + void Rhythmic_grouping::OK()const { @@ -65,19 +72,6 @@ Rhythmic_grouping::intervals() } return r; } - -Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n) -{ - if (n == 1 || !n) { - interval_ = new MInterval(t); - return; - } - 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(MInterval t) { @@ -143,6 +137,21 @@ Rhythmic_grouping::split(svec splitpoints) children = ch; } + +Rhythmic_grouping::Rhythmic_grouping(MInterval t, int n) +{ + init(); + if (n == 1 || !n) { + interval_ = new MInterval(t); + return; + } + 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 )); +} + + Rhythmic_grouping::Rhythmic_grouping(svec r) :children(r) { @@ -152,6 +161,7 @@ Rhythmic_grouping::Rhythmic_grouping(svec r) Rhythmic_grouping::~Rhythmic_grouping() { junk(); + } void @@ -171,6 +181,7 @@ Rhythmic_grouping::operator=(Rhythmic_grouping const &s) Rhythmic_grouping::Rhythmic_grouping(Rhythmic_grouping const&s) { + init(); copy(s); } @@ -178,10 +189,9 @@ void Rhythmic_grouping::junk() { delete interval_; - interval_ = 0; for (int i=0; i < children.sz(); i++) delete children[i]; - children.set_size(0); + init(); } void diff --git a/src/idealspacing.cc b/src/idealspacing.cc index c6b84931f6..3ceaff1e6d 100644 --- a/src/idealspacing.cc +++ b/src/idealspacing.cc @@ -1,3 +1,4 @@ +#include "idealspacing.hh" #include "pcol.hh" #include "pscore.hh" #include "pstaff.hh" diff --git a/src/identifier.cc b/src/identifier.cc index 6241768694..d55c3fc4e4 100644 --- a/src/identifier.cc +++ b/src/identifier.cc @@ -5,8 +5,9 @@ #include "debug.hh" void -Identifier::error() +Identifier::error(String expect) { String e("Wrong identifier type: "); - ::error(e + classname()); + e += String(classname()) + "(expected " + expect + ")"; + ::error(e); } diff --git a/src/inputcommands.cc b/src/inputcommands.cc index e1d4046561..64e8fa9598 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -11,7 +11,7 @@ Commands_at::print() const #ifndef NPRINT mtor << "Commands_at {"; tdescription_.print(); - for (PCursor cc(*this); cc.ok(); cc++) + for (iter_top(*this,cc); cc.ok(); cc++) cc->print(); mtor << "}\n"; #endif @@ -69,7 +69,7 @@ void Commands_at::parse(Staff_commands_at*s) { s->tdescription_ = tdescription_; - for (PCursor cc(*this); cc.ok(); cc++) { + for (iter_top(*this,cc); cc.ok(); cc++) { if (cc->args.sz() && cc->args[0] !="") { Command c = **cc; s->add(c); @@ -175,7 +175,7 @@ Input_commands::parse() const print(); Staff_commands*nc = new Staff_commands; - for (PCursor i(*this); i.ok(); i++) { + for (iter_top(*this,i); i.ok(); i++) { Staff_commands_at* s= nc->find(i->when()); if (!s){ @@ -200,7 +200,7 @@ void Input_commands::print() const { #ifndef NPRINT - for (PCursor cc(*this); cc.ok() ; cc++) { + for (iter_top(*this,cc); cc.ok() ; cc++) { cc->print(); } #endif diff --git a/src/inputmusic.cc b/src/inputmusic.cc index b007562d1c..80f0a258a7 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -47,14 +47,14 @@ Complex_music::add(Input_music*v) void Complex_music::print() const { - for (PCursor i(elts); i.ok(); i++) + for (iter_top(elts,i); i.ok(); i++) i->print(); } void Complex_music::concatenate(Complex_music*h) { - for (PCursor i(h->elts); i.ok(); i++) + for (iter_top(h->elts,i); i.ok(); i++) add(i->clone()); } @@ -64,7 +64,7 @@ Complex_music::Complex_music() Complex_music::Complex_music(Complex_music const&s) { - for (PCursor i(s.elts); i.ok(); i++) + for (iter_top(s.elts,i); i.ok(); i++) add(i->clone()); } @@ -98,7 +98,7 @@ Music_voice::length() { Moment l = 0.0; - for (PCursor i(elts); i.ok(); i++) + for (iter_top(elts,i); i.ok(); i++) l += i->length(); return l; } @@ -110,13 +110,12 @@ Music_voice::convert() Voice_list l; Moment here = 0.0; - for (PCursor i(elts); i.ok(); i++) { + for (iter_top(elts,i); i.ok(); i++) { Moment len = i->length(); Voice_list k(i->convert()); k.translate_time(here); l.concatenate(k); - here +=len; - + here +=len; } return l; } @@ -150,7 +149,7 @@ Music_general_chord::print() const void Music_general_chord::translate_time(Moment t) { - for (PCursor i(elts); i.ok(); i++) + for (iter_top(elts,i); i.ok(); i++) i->translate_time(t); } @@ -159,7 +158,7 @@ Music_general_chord::length() { Moment l =0.0; - for (PCursor i(elts); i.ok(); i++) + for (iter_top(elts,i); i.ok(); i++) l = l >? i->length(); return l; } @@ -168,7 +167,7 @@ Voice_list Music_general_chord::convert() { Voice_list l; - for (PCursor i(elts); i.ok(); i++) { + for (iter_top(elts,i); i.ok(); i++) { Voice_list k(i->convert()); l.concatenate(k); } @@ -181,7 +180,7 @@ Music_general_chord::convert() void Voice_list::translate_time(Moment x) { - for (PCursor i(*this); i.ok(); i++) + for (iter_top(*this,i); i.ok(); i++) i->start += x; } diff --git a/src/inputscore.cc b/src/inputscore.cc index 5043354f0c..8bbe7e266e 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -32,7 +32,7 @@ Input_score::parse() Paperdef* p=new Paperdef(*paper_); Score *s = new Score(p); - for (PCursor i(staffs_); i.ok(); i++) { + for (iter_top(staffs_,i); i.ok(); i++) { Staff* staf=i->parse(commands_); s->add(staf); } @@ -54,7 +54,7 @@ void Input_score::print()const { mtor << "Input_score {\n"; - for (PCursor i(staffs_); i.ok(); i++) { + for (iter_top(staffs_,i); i.ok(); i++) { i->print(); } mtor << "}\n"; diff --git a/src/inputstaff.cc b/src/inputstaff.cc index 4a38d38bc1..97622a9dab 100644 --- a/src/inputstaff.cc +++ b/src/inputstaff.cc @@ -39,15 +39,15 @@ Input_staff::parse(PointerList score_wide) else if (type == "rhythmic") p = new Rhythmic_staff; - for (PCursor i(music_); i.ok(); i++) { + for (iter_top(music_,i); i.ok(); i++) { Voice_list vl = i->convert(); p->add(vl); } Input_commands commands; - for (PCursor i(score_wide); i.ok(); i++) + for (iter_top(score_wide,i); i.ok(); i++) commands.add(**i); - for (PCursor i(commands_); i.ok(); i++) + for (iter_top(commands_,i); i.ok(); i++) commands.add(**i); p->staff_commands_ = commands.parse(); @@ -57,9 +57,9 @@ Input_staff::parse(PointerList score_wide) Input_staff::Input_staff(Input_staff&s) { - for (PCursor i(s.commands_); i.ok(); i++) + for (iter_top(s.commands_,i); i.ok(); i++) commands_.bottom().add(new Input_command(**i)); - for (PCursor i(s.music_); i.ok(); i++) + for (iter_top(s.music_,i); i.ok(); i++) add(i); type = s.type; @@ -70,9 +70,9 @@ Input_staff::print() const { #ifndef NPRINT mtor << "Input_staff {\n"; - for (PCursor i(commands_); i.ok(); i++) + for (iter_top(commands_,i); i.ok(); i++) i->print(); - for (PCursor i(music_); i.ok(); i++) + for (iter_top(music_,i); i.ok(); i++) i->print(); mtor << "}\n"; #endif diff --git a/src/item.cc b/src/item.cc index ba71539d30..64dcc1e1f4 100644 --- a/src/item.cc +++ b/src/item.cc @@ -1,77 +1,18 @@ -#include "pstaff.hh" -#include "pscore.hh" -#include "symbol.hh" -#include "molecule.hh" -#include "pcol.hh" - -void -Item::translate(Offset O) -{ - offset_ += O; -} - -void -Item::postprocess() -{ - // default: do nothing -} - - -void -Item::preprocess() -{ - // default: do nothing -} - -String -Item::TeXstring() const -{ - Item * me = (Item*) this; - output->translate(offset_); // ugh? - me ->offset_ = Offset(0,0); // URRGGH! - return output->TeXstring(); -} - -Interval -Item::width() const -{ - Interval i =output->extent().x ; - if (!i.empty()) // float exception on DEC Alpha - i+=offset_.x; - return i; -} - -Interval -Item::height() const -{ - Interval i =output->extent().y; - return i+=offset_.y; -} - -Item::~Item() -{ - delete output; -} +#include "debug.hh" +#include "item.hh" Item::Item() { pcol_ = 0; - output = 0; - pstaff_ = 0; } + void Item::print() const { #ifndef NPRINT - if (output) - output->print(); + mtor << "item " ; + Staff_elem::print(); #endif -} -Paperdef* -Item::paper() const -{ - assert(pstaff_); - return pstaff_->pscore_->paper_; } diff --git a/src/keyitem.cc b/src/keyitem.cc index 26ad1745e3..3499149352 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -21,6 +21,7 @@ Keyitem::read(svec s) add(note, acc); } } + void Keyitem::add(int p, int a) { @@ -28,16 +29,11 @@ Keyitem::add(int p, int a) acc.add(a); } -void -Keyitem::preprocess() -{ - brew_molecole(); -} -void -Keyitem::brew_molecole() +Molecule* +Keyitem::brew_molecule()const { - output = new Molecule; + Molecule*output = new Molecule; Real inter = paper()->interline()/2; for (int i =0; i < pitch.sz(); i++) { @@ -50,5 +46,6 @@ Keyitem::brew_molecole() Molecule m(paper()->lookup_->fill(Box( Interval(0, paper()->note_width()), Interval(0,0)))); - output->add_right(m); + output->add_right(m); + return output; } diff --git a/src/lexer.l b/src/lexer.l index 4968c89de6..22bda7c92e 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -97,8 +97,6 @@ DOTS \.+ } \| { } -[:space:]+ { -} [%#].*\n { } @@ -120,7 +118,16 @@ DOTS \.+ yylval.c = YYText()[0]; return CLOSE_REQUEST_PARENS; } +\"[^\"]*\" { + String s (YYText()+1); + s = s.left(s.len()-1); + yylval.string = new String(s); + return STRING; +} +[/.^>_-] { + return yylval.c = YYText()[0]; +} . { String s("lexer error: illegal character found: " + String(YYText())); yyerror(s); @@ -133,6 +140,7 @@ DOTS \.+ yylval.string = new String (YYText()); } \" { + mtor << "quoted string\n"; BEGIN(INITIAL); return STRING; } diff --git a/src/lexerinit.cc b/src/lexerinit.cc index 3bc0d31aed..b401071f3a 100644 --- a/src/lexerinit.cc +++ b/src/lexerinit.cc @@ -47,7 +47,7 @@ Input_file::Input_file(String s) is = new ifstream( s ); if ( ! *is) { - String e("cant open " + s); + String e("can\'t open `" + s+"\'"); error(e); } cout << "["< #include "linespace.hh" +#include "pcol.hh" #include "debug.hh" #include "qlp.hh" #include "unionfind.hh" +#include "idealspacing.hh" const Real COLFUDGE=1e-3; + //#define COLFUDGE 1e-3 bool Spacing_problem::contains(const PCol *w) @@ -38,7 +41,7 @@ Spacing_problem::OK() const connected.connect(l,r); } for (int i = 0; i < cols.sz(); i++) - if (cols[i].fixed) + if (cols[i].fixed()) fixed.add(i); for (int i = 0; i < cols.sz(); i++) { bool c=false; @@ -56,7 +59,7 @@ Spacing_problem::check_constraints(Vector v) const // mtor << "checking solution " << v << '\n'; for (int i=0; i < dim; i++) { - if (cols[i].fixed&& abs(cols[i].fixpos - v(i)) > COLFUDGE) { + if (cols[i].fixed()&& abs(cols[i].fixed_position() - v(i)) > COLFUDGE) { return false; } if (!i) @@ -101,8 +104,8 @@ Spacing_problem::try_initial_solution() const int dim=cols.sz(); Vector initsol(dim); for (int i=0; i < dim; i++) { - if (cols[i].fixed) { - initsol(i)=cols[i].fixpos; + if (cols[i].fixed()) { + initsol(i)=cols[i].fixed_position(); } else { Real mindist=cols[i-1].minright() +cols[i].minleft(); @@ -124,6 +127,7 @@ Spacing_problem::find_initial_solution() const assert(check_constraints(v)); return v; } + // generate the matrices void Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const @@ -155,13 +159,12 @@ Spacing_problem::make_constraints(Mixed_qp& lp) const int dim=cols.sz(); for (int j=0; j < dim; j++) { Colinfo *c=&(cols[j]); - if (c->fixed) { - lp.add_fixed_var(j,c->fixpos); + if (c->fixed()) { + lp.add_fixed_var(j,c->fixed_position()); } if (j > 0){ Vector c1(dim); - c1(j)=1.0 ; c1(j-1)=-1.0 ; lp.add_inequality_cons(c1, cols[j-1].minright() + @@ -199,11 +202,7 @@ Spacing_problem::solve() const void Spacing_problem::add_column(const PCol *col, bool fixed, Real fixpos) { - Colinfo c; - c.fixed=fixed; - c.fixpos=fixpos; - assert(col); - c.pcol_=col; + Colinfo c(col,(fixed)? &fixpos : 0); cols.add(c); } @@ -246,21 +245,50 @@ Spacing_problem::print() const } +/*****************/ + void Colinfo::print() const { #ifndef NPRINT mtor << "column { "; - if (fixed) - mtor << "fixed at " << fixpos<<", "; + if (fixed()) + mtor << "fixed at " << fixed_position()<<", "; assert(pcol_); mtor << "[" << minleft() << ", " << minright() << "]"; mtor <<"}\n"; #endif } +Colinfo::Colinfo(Colinfo const&c) +{ + fixpos = (c.fixpos)?new Real(*c.fixpos):0; + pcol_ = c.pcol_; + width = c.width; +} + +Colinfo::Colinfo(const PCol*col_p, const Real*fixed_r_p ) +{ + fixpos = (fixed_r_p)? new Real(*fixed_r_p) : 0; + pcol_ = col_p; + width = pcol_->width(); +} + +Colinfo::~Colinfo() +{ + delete fixpos; +} + Colinfo::Colinfo() { - fixed=false; pcol_=0; + fixpos = 0; +} +void +Colinfo::operator=(Colinfo const&c ) +{ + delete fixpos; + fixpos = (c.fixpos)?new Real(*c.fixpos):0; + pcol_ = c.pcol_; + width = c.width; } diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc index a7de5ae695..42bb268df0 100644 --- a/src/localkeyitem.cc +++ b/src/localkeyitem.cc @@ -3,34 +3,34 @@ #include "scalar.hh" #include "lookup.hh" #include "paper.hh" - +#include "notehead.hh" Local_key_item::Local_key_item(int i) { c0_position = i; } void -Local_key_item::add (int o, int p , int a) +Local_key_item::add (int o, int p , int a,Notehead*head_p) { Local_acc l; l.octave = o; l.name = p; l.acc = a; accs.add(l); + group.add(head_p); + dependencies.add(head_p); } void -Local_key_item::preprocess() +Local_key_item::do_pre_processing() { - brew_molecole(); + accs.sort(Local_acc::compare); } - -void -Local_key_item::brew_molecole() +Molecule* +Local_key_item::brew_molecule()const { - accs.sort(Local_acc::compare); - output = new Molecule; + Molecule* output = new Molecule; Molecule*octmol = 0; int lastoct = -100; for (int i = 0; i < accs.sz(); i++) { @@ -58,6 +58,7 @@ Local_key_item::brew_molecole() output->add(*octmol); delete octmol; } + return output; } int diff --git a/src/lookup.cc b/src/lookup.cc index d7a3f721e9..9c8def52cf 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -33,11 +33,13 @@ 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); + a.add(text); + Symbol tsym = (*symtables_)("style")->lookup(style); + a[0] = substitute_args(tsym.tex,a); + Symbol s = (*symtables_)("align")->lookup(dir); s.tex = substitute_args(s.tex,a); + s.dim.y = tsym.dim.y; return s; } @@ -84,6 +86,12 @@ Lookup::bar(String s) return (*symtables_)("bars")->lookup(s); } +Symbol +Lookup::script(String s) +{ + return (*symtables_)("scripts")->lookup(s); +} + Symbol Lookup::clef(String s) { diff --git a/src/meter.cc b/src/meter.cc index 14b242e5c6..dc3cb40f3e 100644 --- a/src/meter.cc +++ b/src/meter.cc @@ -9,10 +9,10 @@ Meter::Meter(sveca) { } -void -Meter::preprocess() +Molecule* +Meter::brew_molecule()const { Symbol s = paper()->lookup_->meter(args); - output = new Molecule(Atom(s)); +return new Molecule(Atom(s)); } diff --git a/src/molecule.cc b/src/molecule.cc index 68b8791c18..6b9db4cac3 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -1,4 +1,3 @@ -#include "glob.hh" #include "vray.hh" #include "interval.hh" #include "dimen.hh" @@ -46,7 +45,7 @@ String Molecule::TeXstring() const { String s; - for(PCursor c(ats); c.ok(); c++) + for(iter_top(ats,c); c.ok(); c++) s+=c->TeXstring(); return s; } @@ -55,7 +54,7 @@ Box Molecule::extent() const { Box b; - for(PCursor c(ats); c.ok(); c++) + for(iter_top(ats,c); c.ok(); c++) b.unite(c->extent()); return b; } @@ -63,14 +62,14 @@ Molecule::extent() const void Molecule::translate(Offset o) { - for (PCursor c(ats); c.ok(); c++) + for (iter_top(ats,c); c.ok(); c++) c->translate(o); } void Molecule::add(const Molecule &m) { - for (PCursor c(m.ats); c.ok(); c++) { + for (iter_top(m.ats,c); c.ok(); c++) { add(**c); } } @@ -142,6 +141,6 @@ Molecule::Molecule(const Molecule&s) void Molecule::print() const { - for (PCursor c(ats); c.ok(); c++) + for (iter_top(ats,c); c.ok(); c++) c->print(); } diff --git a/src/mylexer.cc b/src/mylexer.cc index 699a46d9fa..53763a6ab2 100644 --- a/src/mylexer.cc +++ b/src/mylexer.cc @@ -27,9 +27,11 @@ static Keyword_ent the_key_tab[]={ "output", OUTPUT, "partial", PARTIAL, "paper", PAPER, + "plet", PLET, "pt", PT, "rhythmic", RHYTHMIC, "score", SCORE, + "script", SCRIPT, "skip", SKIP, "staff", STAFF, "start", START_T, @@ -37,6 +39,7 @@ static Keyword_ent the_key_tab[]={ "symboltables", SYMBOLTABLES, "notenames", NOTENAMES, "texid", TEXID, + "textstyle", TEXTSTYLE, "chord", CHORD, "multi", MULTI, "unitspace", UNITSPACE, diff --git a/src/note.cc b/src/note.cc index cac44829ad..30ded730d4 100644 --- a/src/note.cc +++ b/src/note.cc @@ -1,14 +1,41 @@ #include - +#include "lexer.hh" #include "string.hh" #include "real.hh" #include "debug.hh" #include "request.hh" #include "voice.hh" #include "notename.hh" +#include "identparent.hh" #include "vray.hh" +#include "textdef.hh" int default_duration = 4, default_dots=0, default_octave=0; +int default_plet_type = 1, default_plet_dur = 1; +String textstyle="roman"; // in lexer? + +/* triplet is '2/3' */ +void set_plet(int num,int den) +{ + assert(num >0&& den>0); + default_plet_dur = num; + default_plet_type = den; +} + +Text_def* +get_text(String s) return t; +{ + t= new Text_def; + t->text= s; + t->style = textstyle; + return t; +} + +void +set_text_style(String s) +{ + textstyle = s; +} void parse_octave (const char *a, int &j, int &oct) @@ -71,7 +98,7 @@ get_note_element(String pitch, int * notename, int * duration ) rq->forceacc = forceacc; rq->balltype = dur; rq->dots = dots; - + rq->plet_factor = Moment(default_plet_dur, default_plet_type); rq->print(); v->add(rq); @@ -85,7 +112,7 @@ get_rest_element(String, int * duration ) Voice_element*v = new Voice_element; Rest_req * rq = new Rest_req; - + rq->plet_factor = Moment(default_plet_dur, default_plet_type); rq->balltype = duration[0]; rq->dots = duration[1]; rq->print(); @@ -124,7 +151,12 @@ get_request(char c) switch (c) { case '[': case ']': - ret = new Beam_req; + { + Beam_req*b = new Beam_req; + if (default_plet_type != 1) + b->nplet = default_plet_type; + ret = b; + } break; case ')': @@ -161,3 +193,42 @@ add_requests(Voice_element *v, svec &req) } req.set_size(0); } + +Script_def* +get_scriptdef(char c) +{ + String s; + switch (c) { + case '^' : s = "marcato"; + break; + case '+' : s = "stopped"; + break; + case '-' : s = "portato"; + break; + case '|': s = "staccatissimo"; + break; + case 'o' : s = ""; + break; + case '>' : s = "accent"; + break; + case 'v' : s = ""; + break; + case '.' : s = "staccato"; + break; + } + return lexer->lookup_identifier(s)->script(1); +} + +Request* +get_script_req(int d , Script_def*def) +{ + return new Script_req(d, def); +} + + +Request* +get_text_req(int d , Text_def*def) +{ + return new Text_req(d, def); +} + diff --git a/src/notehead.cc b/src/notehead.cc index 203c592830..5db7386600 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -1,5 +1,4 @@ #include "misc.hh" - #include "notehead.hh" #include "dimen.hh" #include "debug.hh" @@ -27,11 +26,6 @@ Notehead::print()const #endif } -void -Notehead::preprocess() -{ - brew_molecole(); -} int Notehead::compare(Notehead*&a, Notehead*&b) @@ -39,27 +33,24 @@ Notehead::compare(Notehead*&a, Notehead*&b) return a->position - b->position; } -void -Notehead::brew_molecole() +Molecule* +Notehead::brew_molecule() const return out; { - assert(pstaff_); - assert(!output); - Paperdef *p = paper(); Real dy = p->internote(); Symbol s = p->lookup_->ball(balltype); - output = new Molecule(Atom(s)); + out = new Molecule(Atom(s)); if (dots) { Symbol d = p->lookup_->dots(dots); Molecule dm; dm.add(Atom(d)); if (!(position %2)) dm.translate(Offset(0,dy)); - output->add_right(dm); + out->add_right(dm); } - output->translate(Offset(x_dir * p->note_width(),0)); + out->translate(Offset(x_dir * p->note_width(),0)); bool streepjes = (position<-1)||(position > staff_size+1); if (streepjes) { int dir = sign(position); @@ -69,10 +60,10 @@ Notehead::brew_molecole() sm.add(Atom(str)); if (position % 2) sm.translate(Offset(0,-dy* dir)); - output->add(sm); + out->add(sm); } - output->translate(Offset(0,dy*position)); + out->translate(Offset(0,dy*position)); } diff --git a/src/parser.y b/src/parser.y index 402bc95f74..3ef8d182ff 100644 --- a/src/parser.y +++ b/src/parser.y @@ -6,9 +6,7 @@ #include "misc.hh" #include "lexer.hh" #include "paper.hh" -#include "inputstaff.hh" #include "inputscore.hh" -#include "inputmusic.hh" #include "main.hh" #include "keyword.hh" #include "inputcommand.hh" @@ -57,6 +55,8 @@ Paperdef*default_paper(); Interval *interval; Box *box; Notename_tab *notename_tab; + Script_def * script; + Text_def * textdef; } %token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT @@ -64,7 +64,7 @@ Paperdef*default_paper(); %token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND %token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES %token PARTIAL RHYTHMIC MELODIC MUSIC GROUPING -%token END SYMBOLTABLES TEXID TABLE NOTENAMES +%token END SYMBOLTABLES TEXID TABLE NOTENAMES SCRIPT TEXTSTYLE PLET %token IDENTIFIER %token NEWIDENTIFIER @@ -91,7 +91,7 @@ Paperdef*default_paper(); %type int_list %type score_commands_block score_commands_body %type staff_commands_block staff_commands_body -%type post_request pre_request +%type post_request pre_request %type clef_id pitchmod %type music %type music_chord music_chord_body @@ -104,6 +104,11 @@ Paperdef*default_paper(); %type symtables symtables_body %type symboldef %type notename_tab notename_tab_body +%type script_dir +%type