From f2ef27e5cd198f8b057328bb53f01b95d536e837 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:27:43 +0000 Subject: [PATCH] lilypond-0.0.22 --- Documentation/lilygut.pod | 35 ++++++++++++++++++++--------------- hdr/proto.hh | 1 + hdr/request.hh | 21 +++++++++++++++++---- hdr/timedescription.hh | 7 +++++++ src/parser.y | 39 ++++++++++++++++++++++++++------------- src/simplestaff.cc | 8 +++++++- 6 files changed, 78 insertions(+), 33 deletions(-) diff --git a/Documentation/lilygut.pod b/Documentation/lilygut.pod index 295ed2844c..20d5f0364b 100644 --- a/Documentation/lilygut.pod +++ b/Documentation/lilygut.pod @@ -5,7 +5,8 @@ LilyGuts - doco to the internals of LilyPond =head1 DESCRIPTION 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 +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 @@ -67,48 +68,53 @@ 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 +After C made up her mind, 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 +=item C + +Checks during music processing if start of this voice element +coincides with the start of a measure. Handy to check if you left out +some voice elts. + +=item C 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 +is also for the C to decide. The C can decide on positioning based on ottava commands and the appropriate clef. -=item Rest_req +=item C Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded. -=item Span_req +=item C This type of request typically results in the creation of a C -=item Beam_req +=item C 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 +=item C -Each dynamic is bound to one note ( a crescendo spanning multiple +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 +note, therefore fore each C request carries a time, measured from the start of its note. -This subfield would come in handy, if mpp96 was adapted for midi +This subfield would come in handy, if LilyPond was adapted for midi support. =back @@ -145,7 +151,7 @@ This table decribes the proper order for the different commands: =head1 BREAKING -[Source files: command.hh, scommands.cc] +[Source files: F, F] BREAKING, PREBREAK POSTBREAK, etc. @@ -226,7 +232,7 @@ 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 +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 @@ -283,7 +289,6 @@ signifies a "list of". (This is not complete) [partly by Mark Basinski ] - Herbert Chlapik, W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In diff --git a/hdr/proto.hh b/hdr/proto.hh index b11ca6c59f..ac215970fe 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -15,6 +15,7 @@ struct Absdynamic_req; struct Accidental; struct Atom; +struct Barcheck_req; struct Beam; struct Beam_req; struct Box; diff --git a/hdr/request.hh b/hdr/request.hh index 43b31d75cc..a6ae0fbc88 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -8,14 +8,20 @@ /// a voice element wants something printed struct Request { - Voice_element*elt; // indirection. + Voice_element*elt_l_; /****************/ Request(); + Request(Request const&); virtual ~Request(){} virtual void print()const ; + virtual Moment duration() const { return 0.0; } + virtual Request* clone() const =0; + + /* accessors for children */ + virtual Barcheck_req *barcheck() { return 0; } virtual Note_req *note() {return 0;} virtual Script_req *script() {return 0;} virtual Stem_req *stem() {return 0;} @@ -26,14 +32,17 @@ struct Request { virtual Slur_req *slur() { 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; }; /** see lilygut page */ +struct Barcheck_req : Request { + virtual Barcheck_req *barcheck() { return this; } + void print ()const; + Request*clone() const; +}; /// a request with a duration struct Rhythmic_req : virtual Request { @@ -107,6 +116,7 @@ struct Span_req : Request { NOSPAN, START, STOP } spantype ; + virtual void print() const; Span_req*span() { return this; } Span_req(); virtual Request*clone()const; @@ -132,6 +142,7 @@ appropriate number over the beam /// a slur struct Slur_req : Span_req { + virtual Request*clone()const; virtual Slur_req*slur() { return this; } }; @@ -148,6 +159,7 @@ struct Script_req : Request { Request *clone()const; Script_req(int d, Script_def*); ~Script_req(); + Script_req(Script_req const&); }; /** eg upbow, downbow. Why a request? These symbols may conflict with slurs and brackets, so this also a request */ @@ -162,7 +174,8 @@ struct Text_req : Request { virtual void print() const; Request *clone()const; Text_req(int d, Text_def*); - ~Text_req(); + ~Text_req(); + Text_req(Text_req const&); }; diff --git a/hdr/timedescription.hh b/hdr/timedescription.hh index 2cdbc8de23..2194ee0a16 100644 --- a/hdr/timedescription.hh +++ b/hdr/timedescription.hh @@ -26,11 +26,18 @@ struct Time_description { /****************/ void OK() const; Time_description(Rational, const Time_description*); + String str()const; void print() const; void setpartial(Rational p); Rational barleft(); void set_meter(int,int); + static int compare (Time_description&, Time_description&); }; +#include "compare.hh" + + +instantiate_compare(Time_description&,Time_description::compare); + #endif // Time_description_HH diff --git a/src/parser.y b/src/parser.y index 3ef8d182ff..a2603284b3 100644 --- a/src/parser.y +++ b/src/parser.y @@ -2,7 +2,6 @@ #include #include "lookup.hh" - #include "misc.hh" #include "lexer.hh" #include "paper.hh" @@ -19,7 +18,7 @@ #define YYDEBUG 1 #endif -svec pre_reqs, post_reqs; +Array pre_reqs, post_reqs; Paperdef*default_paper(); %} @@ -42,9 +41,9 @@ Paperdef*default_paper(); char c; int ii[10]; - svec * strvec; - svec *commandvec; - svec *intvec; + Array * strvec; + Array *commandvec; + Array *intvec; Input_staff *staff; Input_score *score; @@ -72,11 +71,11 @@ Paperdef*default_paper(); %token NOTENAME %token REAL %token STRING -%token OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS + %token DOTS INT %type unit %type pitch_list - +%type open_request_parens close_request_parens %type declaration %type declarable_identifier %type paper_block paper_body @@ -204,7 +203,7 @@ score_commands_block: COMMANDS '{' score_commands_body '}' { $$ =$3;} ; -score_commands_body: { $$ = new svec; } +score_commands_body: { $$ = new Array; } | score_commands_body score_command { $$->add($2); } @@ -215,7 +214,7 @@ staff_commands_block: COMMANDS '{' staff_commands_body '}' { ; staff_commands_body: - /* empty */ { $$ = new svec; } + /* empty */ { $$ = new Array; } | staff_commands_body staff_command { $$->add($2); } @@ -246,6 +245,10 @@ skipcommand: score_command: skipcommand + | BAR STRING { + $$ = get_bar_command(*$2); + delete $2; + } | METER int int { $$ = get_meterchange_command($2, $3); } @@ -377,10 +380,20 @@ post_requests: ; post_request: - CLOSE_REQUEST_PARENS { $$ = get_request($1); } + close_request_parens { $$ = get_request($1); } | script_req | textscript_req ; +close_request_parens: + '(' { $$='('; } + |']' { $$ = ']' } + ; + +open_request_parens: + '|' {$$='|'} + |')' {$$=')'} + |'[' {$$='['} + ; script_definition: SCRIPT '{' script_body '}' { $$ = $3; } @@ -434,7 +447,7 @@ pre_requests: ; pre_request: - OPEN_REQUEST_PARENS { $$ = get_request($1); } + open_request_parens { $$ = get_request($1); } ; @@ -489,7 +502,7 @@ voice_elt: UTILITIES */ pitch_list: { - $$ = new svec; + $$ = new Array; } | pitch_list NOTENAME { $$->add($2[0]); @@ -508,7 +521,7 @@ int: int_list: /* */ { - $$ = new svec; + $$ = new Array; } | int_list int { $$->add($2); diff --git a/src/simplestaff.cc b/src/simplestaff.cc index 636b6691de..f0087ebd3f 100644 --- a/src/simplestaff.cc +++ b/src/simplestaff.cc @@ -39,9 +39,15 @@ Scalar void Simple_column::process_requests() { - for (int i = 0 ; i < v_elts.sz(); i ++) + for (int i = 0 ; i < v_elts.size(); i ++) for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) { Request *rq= j; + if (rq->barcheck()) { + if (tdescription_->whole_in_measure) { + error("Barcheck failed, " + tdescription_->str()); + } + } + if (rq->rhythmic()){ notes.add(rq->rhythmic()); } -- 2.39.5