#include "beam.hh"
+#include "misc.hh"
#include "debug.hh"
#include "symbol.hh"
#include "molecule.hh"
sc->dir = dir;
}
}
+
/*
should use minimum energy formulation (cf linespacing)
*/
solve_slope();
}
+
void
Beam::process()
{
calculate();
+
+ for (PCursor<Stem*> i(stems); i.ok(); i++)
+ i->beams_left = i->beams_right = intlog2(ABS(i->flag)) - 2;
+
+ stems.top()->beams_left = 0;
+ stems.bottom()->beams_right = 0;
+
brew_molecule();
set_stemlens();
}
return Interval( (*me->stems.top()) ->hpos(),
(*me->stems.bottom()) ->hpos() );
}
+/*
+ beams to go with one stem.
+ */
+Molecule
+Beam::stem_beams(Stem *here, Stem *next, Stem *prev)
+{
+ assert( !next || next->hpos() > here->hpos() );
+ assert( !prev || prev->hpos() < here->hpos() );
+ Real dy=paper()->internote()*2;
+ Real stemdx = paper()->rule_thickness();
+ Real sl = slope*paper()->internote();
+ Molecule leftbeams;
+ Molecule rightbeams;
+
+ /* half beams extending to the left. */
+ if (prev) {
+ int lhalfs= lhalfs = here->beams_left - prev->beams_right ;
+ int lwholebeams= here->beams_left <? prev->beams_right ;
+ Real w = (here->hpos() - prev->hpos())/4;
+ Atom a = paper()->lookup_->beam(sl, w);
+ a.translate(Offset (-w, -w * sl));
+ for (int j = 0; j < lhalfs; j++) {
+ Atom b(a);
+ b.translate(Offset(0, -dir * dy * (lwholebeams+j)));
+ leftbeams.add( b );
+ }
+ }
+
+ if (next){
+ int rhalfs = here->beams_right - next->beams_left;
+ int rwholebeams = here->beams_right <? next->beams_left; // g++
+
+ Real w = next->hpos() - here->hpos();
+ Atom a = paper()->lookup_->beam(sl, w + stemdx);
+
+ int j = 0;
+ for (; j < rwholebeams; j++) {
+ Atom b(a);
+ b.translate(Offset(0, -dir * dy * j));
+ rightbeams.add( b );
+ }
+ w /= 4;
+ a = paper()->lookup_->beam(sl, w);
+
+ for (; j < rwholebeams + rhalfs; j++) {
+ Atom b(a);
+ b.translate(Offset(0, -dir * dy * j));
+ rightbeams.add(b );
+ }
+
+ }
+ leftbeams.add(rightbeams);
+ return leftbeams;
+}
+
void
Beam::brew_molecule()
assert(left->line == right->line);
Real inter=paper()->internote();
Real sl = slope*inter;
- Real w = width().length() + paper()->rule_thickness();
- Symbol s = paper()->lookup_->beam(sl,w);
+
+ output = new Molecule;
slope = sl / inter;
+ Real x0 = stems.top()->hpos();
- Atom a(s);
-
- Real dx = width().min -left->hpos;
- a.translate(Offset(dx,left_pos*inter));
- output = new Molecule(a);
+ for (PCursor<Stem*> i(stems); i.ok(); i++) {
+ PCursor<Stem*> p(i-1);
+ PCursor<Stem*> n(i+1);
+ Stem * prev = p.ok() ? p.ptr() : 0;
+ Stem * next = n.ok() ? n.ptr() : 0;
+
+ Molecule sb = stem_beams(i, next, prev);
+ Real x = i->hpos()-x0;
+ sb.translate(Offset(x, (x * slope + left_pos)* inter));
+ output->add(sb);
+ }
+ output->translate(Offset(x0 - left->hpos,0));
}
void
Beam::print()const
{
- mtor << "Beam, slope " <<slope << "left ypos " << left_pos<<'\n';
+#ifndef NPRINT
+ mtor << "{ slope " <<slope << "left ypos " << left_pos;
+ Spanner::print();
+ mtor << "}\n";
+#endif
}
%{ // -*-Fundamental-*-
#include <iostream.h>
+#include "lookup.hh"
#include "lexer.hh"
#include "paper.hh"
#endif
svec<Request*> pre_reqs, post_reqs;
+
+Paperdef*default_paper();
%}
-%union {
+%union {
+ Request * request;
Real real;
Input_command *command;
Identifier *id;
String *string;
const char *consstr;
Paperdef *paper;
- Request* request;
Horizontal_music *horizontal;
Vertical_music *vertical;
Music_general_chord *chord;
svec<String> * strvec;
svec<Input_command*> *commandvec;
- Voice_list *voicelist;
- Input_staff *staff;
- Input_score *score;
+ svec<int> *intvec;
+
+ Input_staff *staff;
+ Input_score *score;
+ Symtables * symtables;
+ Symtable * symtable;
+ Symbol * symbol;
+ Lookup*lookup;
+ Interval *interval;
+ Box *box;
}
%token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT
%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
%token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES
-%token PARTIAL RHYTHMIC MELODIC MUSIC
+%token PARTIAL RHYTHMIC MELODIC MUSIC GROUPING
+
+%token END SYMBOLTABLES TEXID TABLE
%token <id> IDENTIFIER
%token <string> NEWIDENTIFIER
%token <string> STRING
%token <i> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
-
%type <consstr> unit
%type <id> declaration
%type <score> score_block score_body
%type <staff> staff_block staff_init staff_body
%type <i> int
+%type <intvec> int_list
%type <commandvec> score_commands_block score_commands_body
%type <commandvec> staff_commands_block staff_commands_body
%type <request> post_request pre_request
%type <horizontal> horizontal_music
%type <mvoice> music_voice_body music_voice
+%type <interval> dinterval
+%type <box> box
+%type <symtable> symtable symtable_body
+%type <lookup> symtables symtables_body
+%type <symbol> symboldef
+
%%
}
| mudela add_declaration { }
;
+
/*
DECLARATIONS
*/
$$ = new M_chord_id(*$1, $3);
delete $1;
}
+ | NEWIDENTIFIER '=' symtables {
+ $$ = new Lookup_id(*$1, $3);
+ delete $1;
+ }
;
/*
SCORE
*/
-score_block: SCORE '{' score_body '}' { $$ = $3; }
+score_block: SCORE '{' score_body '}' { $$ = $3;
+ if (!$$->paper_)
+ $$->paper_ = default_paper();
+ }
;
score_body: { $$ = new Input_score; }
| PARTIAL REAL {
$$ = get_partial_command($2);
}
+ | GROUPING int_list {
+ $$ = get_grouping_command(*$2);
+ delete $2;
+ }
;
-
+
+
/*
PAPER
;
paper_body:
- /* empty */ { $$ = new Paperdef; }
+ /* empty */ {
+ $$ = default_paper();
+ }
| paper_body WIDTH dim { $$->linewidth = $3;}
| paper_body OUTPUT STRING { $$->outfile = *$3;
delete $3;
}
+ | paper_body symtables { $$->set($2); }
| paper_body UNITSPACE dim { $$->whole_width = $3; }
| paper_body GEOMETRIC REAL { $$->geometric_ = $3; }
;
+
/*
STAFFs
*/
staff_block:
- STAFF '{' staff_body '}' { $$ = $3; }
+ STAFF '{' staff_body '}' { $$ = $3; }
;
staff_init:
- IDENTIFIER { $$ = new Input_staff(*$1->staff()); }
+ IDENTIFIER { $$ = $1->staff(true); }
| RHYTHMIC {
$$ = new Input_staff("rhythmic");
}
}
;
-
+int_list:
+ /* */ {
+ $$ = new svec<int>;
+ }
+ | int {
+ $$->add($1);
+ }
+ ;
dim:
REAL unit { $$ = convert_dimen($1,$2); }
VIOLIN { $$ = new String("violin"); }
| BASS { $$ = new String("bass"); }
;
+/*
+ symbol tables
+*/
+symtables:
+ SYMBOLTABLES '{' symtables_body '}' { $$ = $3; }
+ ;
+
+symtables_body:
+ {
+ $$ = new Lookup;
+ }
+ | IDENTIFIER {
+ $$ = new Lookup(*$1->lookup(true));
+ }
+ | symtables_body TEXID STRING {
+ $$->texsetting = *$3;
+ delete $3;
+ }
+ | symtables_body STRING '=' symtable {
+ $$->add(*$2, $4);
+ delete $2;
+ }
+ ;
+
+symtable:
+ TABLE '{' symtable_body '}' { $$ = $3; }
+ ;
+
+symtable_body:
+ { $$ = new Symtable; }
+ | symtable_body STRING symboldef {
+ $$->add(*$2, *$3);
+ delete $2;
+ delete $3;
+ }
+ ;
+
+symboldef:
+ STRING box {
+ $$ = new Symbol(*$1, *$2);
+ delete $1;
+ delete $2;
+ }
+ ;
+
+box:
+ dinterval dinterval {
+ $$ = new Box(*$1, *$2);
+ delete $1;
+ delete $2;
+ }
+ ;
+
+dinterval: dim dim {
+ $$ = new Interval($1, $2);
+ }
+ ;
+
%%
void
*mlog << "Parsing ... ";
#ifdef YYDEBUG
- yydebug = !monitor.silence("Parser") & check_debug;
+ yydebug = !monitor.silence("Parser") && check_debug;
#endif
+ new_input("symbol.ini");
+ yyparse();
new_input(s);
yyparse();
+
delete_identifiers();
kill_lexer();
*mlog << "\n";
}
+Paperdef*
+default_paper()
+{
+ return new Paperdef(
+ lookup_identifier("default_table")->lookup(true));
+}
-
-
-
-symboltables
-# index TeXstring, xmin xmax ymin ymax
-
-# be careful with editing this:
-# the "index" entry is hardwired into lilypond.
-
-table clefs
- violin \violinclef 0pt 16pt -12.5pt 22.5pt
- bass \bassclef 0pt 16pt 0pt 20pt
- viola \violaclef 0pt 16pt 0pt 20pt
- violin_change \cviolinclef 0pt 16pt -12.5pt 22.5pt
- bass_change \cbassclef 0pt 16pt 0pt 20pt
- viola_change \cviolaclef 0pt 16pt 0pt 20pt
-end
-
-table balls
- 1 \wholeball 0pt 7.5pt -2.5pt 2.5pt
- 2 \halfball 0pt 6pt -2.5pt 2.5pt
- 4 \quartball 0pt 6pt -2.5pt 2.5pt
-end
-
-table slur
- whole \slurchar%{%} 0pt 0pt 0pt 0pt
- half \hslurchar%{%} 0pt 0pt 0pt 0pt
-end
-table accidentals
- -2 \flatflat 0pt 10.2pt -2.5pt 7.5pt
- -1 \flat 0pt 6pt -2.5pt 7.5pt
- 0 \natural 0pt 6pt -7.5pt 7.5pt
- 1 \sharp 0pt 6pt -7.5pt 7.5pt
- 2 \sharpsharp 0pt 6pt -2.5pt 7.5pt
-end
-
-table streepjes
- toplines \toplines{%} -3pt 9pt 0pt 0pt
- botlines \botlines{%} -3pt 9pt 0pt 0pt
-end
-
-table bars
- empty \emptybar 0pt 0pt 0pt 0pt
- | \maatstreep 0pt 5pt -12pt 12pt
- || \finishbar 0pt 2pt -12pt 12pt
-end
-
-table rests
- 1 \wholerest -5pt 1pt -1pt 1pt
- 2 \halfrest -5pt 1pt -1pt 1pt
- 4 \quartrest -5pt 2pt -5pt 5pt
- 8 \eighthrest 0pt 5pt 0pt 8pt
- 16 \sixteenthrest 0pt 6pt 0pt 12pt
- 32 \thirtysecondrest 0pt 6pt 0pt 16pt
-end
-
-table meters
- C \fourfourmeter 0pt 10pt -5pt 5pt
- C2 \allabreve 0pt 10pt -5pt 5pt
-end
-
-# dims ignored for this table
-table param
- meter \generalmeter{%}{%} -3pt 10pt -5pt 5pt
- linestaf \linestafsym{%}{%} 0pt 0pt 0pt 0pt
- stem \stem{%}{%} 0pt 0pt 0pt 0pt
-end
-
-table dots
- 1 \lsingledot 0pt 8pt -1pt 1pt
- 2 \ldoubledot 0pt 12pt -1pt 1pt
- 3 \ltripledot 0pt 16pt -1pt 1pt
-end
-
-table flags
- 8 \eigthflag 0pt 5pt 0pt 0pt
- 16 \sixteenthflag 0pt 5pt 0pt 0pt
- 32 \thirtysecondflag 0pt 5pt 0pt 0pt
- -8 \deigthflag 0pt 5pt 0pt 0pt
- -16 \dsixteenthflag 0pt 5pt 0pt 0pt
- -32 \dthirtysecondflag 0pt 5pt 0pt 0pt
-end
-
-table beamslopes
- slope \beamslope{%}{%} 0pt 0pt 0pt 0pt
- horizontal \rulesym{%}{%} 0pt 0pt 0pt 0pt
-end
-
-end # symboltables
\ No newline at end of file
+%
+% spacing info for LilyPond. Do not edit this. It has a lot of hard-wired stringconstants
+%
+%
+
+table_sixteen = symboltables {
+
+ texid "\musixsixteendefs"
+
+
+ % index TeXstring, xmin xmax ymin ymax
+
+
+ "clefs" = table {
+ "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt
+ "bass" "\bassclef" 0pt 16pt 0pt 20pt
+ "viola" "\violaclef" 0pt 16pt 0pt 20pt
+ "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt
+ "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt
+ "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt
+ }
+
+ "balls" = table {
+ "1" "\wholeball" 0pt 6pt -2 pt 2pt
+ "2" "\halfball" 0pt 5pt -2 pt 2pt
+ "4" "\quartball" 0pt 5pt -2 pt 2pt
+ }
+
+ "slur" = table {
+ "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt
+ "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt
+ }
+ "accidentals" = table {
+ "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt
+ "-1" "\flat" 0pt 6pt -2.5pt 7.5pt
+ "0" "\natural" 0pt 6pt -7.5pt 7.5pt
+ "1" "\sharp" 0pt 6pt -7.5pt 7.5pt
+ "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt
+ }
+
+ "streepjes" = table {
+ "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt
+ "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt
+ }
+
+ "bars" = table {
+ "empty" "\emptybar" 0pt 0pt 0pt 0pt
+ "|" "\maatstreep" 0pt 5pt -12pt 12pt
+ "||" "\finishbar" 0pt 2pt -12pt 12pt
+ }
+
+ "rests" = table {
+ "1" "\wholerest" -5pt 1pt -1pt 1pt
+ "2" "\halfrest" -5pt 1pt -1pt 1pt
+ "4" "\quartrest" -5pt 2pt -5pt 5pt
+ "8" "\eighthrest" 0pt 5pt 0pt 8pt
+ "16" "\sixteenthrest" 0pt 6pt 0pt 12pt
+ "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt
+ }
+
+ "meters" = table {
+ "C" "\fourfourmeter" 0pt 10pt -5pt 5pt
+ "C2" "\allabreve" 0pt 10pt -5pt 5pt
+ }
+
+ % dims ignored for this table
+ "param" = table {
+ "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt
+ "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt
+ "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt
+ }
+
+ "dots" = table {
+ "1" "\lsingledot" 0pt 8pt -1pt 1pt
+ "2" "\ldoubledot" 0pt 12pt -1pt 1pt
+ "3" "\ltripledot" 0pt 16pt -1pt 1pt
+ }
+
+ "flags" = table {
+ "8" "\eigthflag" 0pt 5pt 0pt 0pt
+ "16" "\sixteenthflag" 0pt 5pt 0pt 0pt
+ "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt
+ "-8" "\deigthflag" 0pt 5pt 0pt 0pt
+ "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt
+ "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt
+ }
+
+ "beamslopes" = table {
+ "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt
+ "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt
+ }
+
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+table_twenty = symboltables {
+
+ texid "\musixtwentydefs"
+
+
+ % index TeXstring, xmin xmax ymin ymax
+ % be careful with editing this:
+ % the "index" entry is hardwired into lilypond.
+
+ "clefs" = table {
+ "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt
+ "bass" "\bassclef" 0pt 16pt 0pt 20pt
+ "viola" "\violaclef" 0pt 16pt 0pt 20pt
+ "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt
+ "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt
+ "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt
+ }
+
+ "balls" = table {
+ "1" "\wholeball" 0pt 7.5pt -2.5pt 2.5pt
+ "2" "\halfball" 0pt 6pt -2.5pt 2.5pt
+ "4" "\quartball" 0pt 6pt -2.5pt 2.5pt
+ }
+
+ "slur" = table {
+ "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt
+ "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt
+ }
+ "accidentals" = table {
+ "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt
+ "-1" "\flat" 0pt 6pt -2.5pt 7.5pt
+ "0" "\natural" 0pt 6pt -7.5pt 7.5pt
+ "1" "\sharp" 0pt 6pt -7.5pt 7.5pt
+ "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt
+ }
+
+ "streepjes" = table {
+ "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt
+ "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt
+ }
+
+ "bars" = table {
+ "empty" "\emptybar" 0pt 0pt 0pt 0pt
+ "|" "\maatstreep" 0pt 5pt -12pt 12pt
+ "||" "\finishbar" 0pt 2pt -12pt 12pt
+ }
+
+ "rests" = table {
+ "1" "\wholerest" -5pt 1pt -1pt 1pt
+ "2" "\halfrest" -5pt 1pt -1pt 1pt
+ "4" "\quartrest" -5pt 2pt -5pt 5pt
+ "8" "\eighthrest" 0pt 5pt 0pt 8pt
+ "16" "\sixteenthrest" 0pt 6pt 0pt 12pt
+ "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt
+ }
+
+ "meters" = table {
+ "C" "\fourfourmeter" 0pt 10pt -5pt 5pt
+ "C2" "\allabreve" 0pt 10pt -5pt 5pt
+ }
+
+ % dims ignored for this table
+ "param" = table {
+ "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt
+ "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt
+ "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt
+ }
+
+ "dots" = table {
+ "1" "\lsingledot" 0pt 8pt -1pt 1pt
+ "2" "\ldoubledot" 0pt 12pt -1pt 1pt
+ "3" "\ltripledot" 0pt 16pt -1pt 1pt
+ }
+
+ "flags" = table {
+ "8" "\eigthflag" 0pt 5pt 0pt 0pt
+ "16" "\sixteenthflag" 0pt 5pt 0pt 0pt
+ "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt
+ "-8" "\deigthflag" 0pt 5pt 0pt 0pt
+ "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt
+ "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt
+ }
+
+ "beamslopes" = table {
+ "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt
+ "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt
+ }
+
+}
+
+default_table = symboltables { table_sixteen }
\ No newline at end of file