From 13e79c0250d34b6bdfbafbc551ef64e8b59b2991 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 18 Aug 1997 03:31:07 +0200 Subject: [PATCH] release: 0.1.9 --- .dstreamrc | 5 +- AUTHORS.text | 2 +- BUGS | 7 + Documentation/CodingStyle.pod | 22 +- Documentation/faq.pod | 6 +- INSTALL.text | 12 +- NEWS | 25 +- TODO | 260 ++++++------ VERSION | 4 +- flower/choleski.cc | 135 ++++--- flower/data-file.cc | 46 +-- flower/diagonal-storage.cc | 108 ++--- flower/directed-graph.cc | 62 +-- flower/dstream.cc | 103 ++--- flower/flower-debug.cc | 8 +- flower/flower-version.cc | 6 +- flower/full-storage.cc | 114 +++--- flower/include/cursor.icc | 60 +-- flower/include/cursor.tcc | 70 ++-- flower/include/full-storage.icc | 38 +- flower/include/interval.tcc | 54 +-- flower/include/link.icc | 58 +-- flower/include/list.icc | 17 +- flower/include/list.tcc | 53 +-- flower/include/pcursor.tcc | 8 +- flower/include/plist.icc | 3 +- flower/include/plist.tcc | 11 +- flower/include/pointer.tcc | 34 +- flower/include/string-data.icc | 112 +++--- flower/include/string-handle.icc | 59 +-- flower/interval.cc | 2 +- flower/lgetopt.cc | 202 +++++----- flower/libc-extension.cc | 36 +- flower/matrix-debug.cc | 33 +- flower/matrix-storage.cc | 77 ++-- flower/matrix.cc | 191 ++++----- flower/path.cc | 48 +-- flower/rational.cc | 4 +- flower/scalar.cc | 39 +- flower/string-convert.cc | 185 ++++----- flower/string.cc | 209 +++++----- flower/stringtest.cc | 137 +++---- flower/text-db.cc | 19 +- flower/text-stream.cc | 15 +- flower/unionfind.cc | 24 +- flower/vector.cc | 14 +- init/paper16.ly | 13 +- init/symbol.ly | 5 + init/table16.ly | 35 +- input/cadenza.ly | 23 +- input/gallina.ly | 70 ++-- input/gallina.tex | 24 ++ input/header.ly | 29 +- input/kortjakje.ly | 19 +- input/rhythm.ly | 2 - input/s.ly | 43 -- input/scales.ly | 17 +- input/scsii-menuetto.ly | 28 +- input/standchen.ly | 24 +- input/toccata-fuga-E.ly | 23 +- input/twinkle-pop.ly | 24 +- input/twinkle.ly | 32 +- input/wohltemperirt.ly | 21 +- lib/duration-convert.cc | 111 ++++-- lib/duration.cc | 62 +-- lib/file-storage.cc | 15 +- lib/includable-lexer.cc | 16 +- lib/include/duration-convert.hh | 8 +- lib/include/duration.hh | 52 +-- lib/include/plet.hh | 27 ++ lib/input.cc | 10 +- lib/plet.cc | 29 ++ lib/simple-file-storage.cc | 5 +- lib/source-file.cc | 20 +- lib/source.cc | 5 +- lily/VERSION | 2 +- lily/atom.cc | 32 +- lily/audio-column.cc | 16 +- lily/audio-item.cc | 22 +- lily/audio-score.cc | 78 ++-- lily/audio-staff.cc | 10 +- lily/axis-group-item.cc | 27 +- lily/axis-group-spanner.cc | 73 ++-- lily/axis-group.cc | 35 +- lily/axis.cc | 2 +- lily/bar-column-grav.cc | 31 +- lily/bar-column.cc | 13 +- lily/bar-grav.cc | 39 +- lily/bar-number-grav.cc | 12 +- lily/bar.cc | 43 +- lily/beam.cc | 259 ++++++------ lily/bow.cc | 50 +-- lily/boxes.cc | 4 +- lily/break-align-item.cc | 4 +- lily/break.cc | 113 +++--- lily/clef-grav.cc | 79 ++-- lily/clef-item.cc | 37 +- lily/col-info.cc | 22 +- lily/colhpos.cc | 30 +- lily/collision-grav.cc | 12 +- lily/collision.cc | 121 +++--- lily/command-request.cc | 88 +++-- lily/crescendo.cc | 43 +- lily/debug.cc | 26 +- lily/dimen.cc | 27 +- lily/directional-spanner.cc | 6 +- lily/dynamic-grav.cc | 82 ++-- lily/elem-group-item.cc | 2 +- lily/elem-group.cc | 30 +- lily/engraver-group.cc | 191 +++++---- lily/engraver.cc | 61 +-- lily/general-script-def.cc | 24 +- lily/global-gravs.cc | 50 +-- lily/global-performers.cc | 26 +- lily/global-translator.cc | 24 +- lily/gourlay-breaking.cc | 224 ++++++----- lily/grouping.cc | 232 ++++++----- lily/head-column.cc | 33 +- lily/head-grav.cc | 42 +- lily/horizontal-align-item.cc | 75 ++-- lily/horizontal-group-item.cc | 2 +- lily/idealspacing.cc | 16 +- lily/identifier.cc | 38 +- lily/include/header.hh | 21 + lily/include/identifier.hh | 2 + lily/include/lily-proto.hh | 1 + lily/include/my-lily-lexer.hh | 1 + lily/include/paper-def.hh | 5 +- lily/include/score.hh | 1 + lily/include/spring-spacer.hh | 82 ++-- lily/ineq-constrained-qp.cc | 164 ++++---- lily/input-translator.cc | 72 ++-- lily/item.cc | 59 +-- lily/key-grav.cc | 55 +-- lily/key-item.cc | 45 ++- lily/key-performer.cc | 18 +- lily/key.cc | 18 +- lily/keyword.cc | 71 ++-- lily/leastsquares.cc | 29 +- lily/lexer.l | 66 +++- lily/lexerinit.cc | 2 +- lily/lily-version.cc | 6 +- lily/line-group-grav.cc | 18 +- lily/line-spacer.cc | 4 +- lily/local-key-grav.cc | 58 +-- lily/local-key-item.cc | 68 ++-- lily/lookup.cc | 215 +++++----- lily/lyric-grav.cc | 20 +- lily/lyric-performer.cc | 16 +- lily/main.cc | 108 ++--- lily/meter-grav.cc | 77 ++-- lily/meter-performer.cc | 18 +- lily/meter.cc | 8 +- lily/midi-def.cc | 40 +- lily/midi-item.cc | 637 +++++++++++++++--------------- lily/midi-stream.cc | 38 +- lily/midi-walker.cc | 63 +-- lily/misc.cc | 22 +- lily/molecule.cc | 71 ++-- lily/music-iterator.cc | 213 +++++----- lily/music-list.cc | 43 +- lily/music.cc | 18 +- lily/musical-request.cc | 192 ++++----- lily/my-lily-lexer.cc | 154 ++++---- lily/my-lily-parser.cc | 230 +++++------ lily/note-column-grav.cc | 74 ++-- lily/note-column.cc | 21 +- lily/note-performer.cc | 25 +- lily/note.cc | 58 +-- lily/notehead.cc | 101 ++--- lily/notename-table.cc | 8 +- lily/p-col.cc | 99 ++--- lily/p-score.cc | 239 +++++------ lily/paper-def.cc | 108 +++-- lily/parser.y | 99 ++++- lily/performer-group-performer.cc | 88 +++-- lily/performer.cc | 26 +- lily/qlp.cc | 63 +-- lily/qlpsolve.cc | 124 +++--- lily/request.cc | 12 +- lily/rest-collision-grav.cc | 19 +- lily/rest-collision.cc | 121 +++--- lily/rest-column.cc | 2 +- lily/score-align-grav.cc | 21 +- lily/score-align-gravs.cc | 8 +- lily/score-column.cc | 41 +- lily/score-elem-info.cc | 8 +- lily/score-elem.cc | 378 +++++++++--------- lily/score-grav.cc | 154 ++++---- lily/score-halign-grav.cc | 16 +- lily/score-performer.cc | 27 +- lily/score.cc | 170 ++++---- lily/scoreline.cc | 83 ++-- lily/scores.cc | 23 +- lily/script-column.cc | 66 ++-- lily/script-def.cc | 48 +-- lily/script-grav.cc | 27 +- lily/script.cc | 62 +-- lily/slur-grav.cc | 46 ++- lily/slur.cc | 57 +-- lily/span-bar-grav.cc | 28 +- lily/span-bar.cc | 66 ++-- lily/span-score-bar-grav.cc | 4 +- lily/span-score-bar.cc | 15 +- lily/spanner-elem-group.cc | 6 +- lily/spanner.cc | 86 ++-- lily/spring-spacer.cc | 481 ++++++++++++---------- lily/staff-info.cc | 22 +- lily/staff-performer.cc | 26 +- lily/staff-side.cc | 74 ++-- lily/staff-sym-grav.cc | 16 +- lily/staff-sym.cc | 20 +- lily/stem-beam-grav.cc | 236 +++++------ lily/stem.cc | 198 +++++----- lily/super-elem.cc | 21 +- lily/swallow-grav.cc | 2 +- lily/symbol.cc | 10 +- lily/symtable.cc | 23 +- lily/template5.cc | 4 +- lily/tex-beam.cc | 102 ++--- lily/tex-slur.cc | 242 ++++++------ lily/tex-stream.cc | 54 +-- lily/tex.cc | 30 +- lily/text-def.cc | 24 +- lily/text-grav.cc | 29 +- lily/text-item.cc | 26 +- lily/text-spanner.cc | 46 +-- lily/tie-grav.cc | 60 +-- lily/tie.cc | 57 +-- lily/time-description.cc | 84 ++-- lily/timing-grav.cc | 6 +- lily/translator.cc | 4 +- lily/version.cc | 6 +- lily/vertical-align-elem.cc | 26 +- lily/vertical-align-grav.cc | 19 +- lily/voice-group-gravs.cc | 15 +- lily/warn.cc | 10 +- lily/word-wrap.cc | 60 +-- make/lilypond.lsm | 8 +- make/lilypond.spec | 6 +- mi2mu/main.cc | 131 +++--- mi2mu/mi2mu-version.cc | 6 +- mi2mu/mudela-column.cc | 8 +- mi2mu/mudela-item.cc | 194 +++++---- mi2mu/mudela-score.cc | 129 +++--- mi2mu/mudela-staff.cc | 280 ++++++------- mi2mu/mudela-stream.cc | 91 +++-- mi2mu/mudela-voice.cc | 35 +- mi2mu/my-midi-lexer.cc | 41 +- mi2mu/my-midi-parser.cc | 172 ++++---- mi2mu/version.cc | 2 +- tex/taupindefs.tex | 2 + 252 files changed, 8053 insertions(+), 6898 deletions(-) create mode 100644 input/gallina.tex delete mode 100644 input/s.ly create mode 100644 lib/include/plet.hh create mode 100644 lib/plet.cc create mode 100644 lily/include/header.hh diff --git a/.dstreamrc b/.dstreamrc index b4b3248203..211edb54f5 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -77,8 +77,9 @@ Staff_commands 0 Stem 0 Stem 0 Stem_req 0 -Symtable 0 -Symtables 0 +Symtable 1 +Symtables 1 + Text_def 0 Text_req 0 Time_description 0 diff --git a/AUTHORS.text b/AUTHORS.text index a035909c09..e8e36bb310 100644 --- a/AUTHORS.text +++ b/AUTHORS.text @@ -61,6 +61,6 @@ CCCCOOOONNNNTTTTRRRRIIIIBBBBUUUUTTTTOOOORRRRSS -12/Aug/97 LilyPond 0.1.7 1 +12/Aug/97 LilyPond 0.1.9 1 diff --git a/BUGS b/BUGS index c5f7e685f6..31bb2b7211 100644 --- a/BUGS +++ b/BUGS @@ -45,3 +45,10 @@ bc=\melodic{ } } *************************** + + \score { < + \melodic { \id "Staff" ""; c'4 g'4 } + \lyric { \id "Lyric" ""; hello4 bye4 < a chord > } + \lyric { \id "Lyric" ""; bye4 hello4 } + \melodic { \id "Staff" ""; c'4 g'4 } + > } diff --git a/Documentation/CodingStyle.pod b/Documentation/CodingStyle.pod index db238815e6..cddf90b58e 100644 --- a/Documentation/CodingStyle.pod +++ b/Documentation/CodingStyle.pod @@ -179,10 +179,28 @@ Standard methods: Presence of these methods usually imply that it is not feasible to this via a constructor */ - add( .. ) + add (..) /// replace some data of *this - set( .. ) + set (..) + +=head2 Constructor + +Every class should have a default constructor. + +Don't use non-default constructors if this can be avoided: + + Foo f(1) + +is less readable than + + Foo f; + f.x = 1 + +or + Foo f(Foo_convert::int_to_foo (1)) + + =head1 HUNGARIAN NOTATION NAMING CONVENTION diff --git a/Documentation/faq.pod b/Documentation/faq.pod index 9d58aaec2f..2a505782f0 100644 --- a/Documentation/faq.pod +++ b/Documentation/faq.pod @@ -11,9 +11,9 @@ Some questions that have been answered before. Q: I get all kinds of errors while compiling parser.cc A: LilyPond uses features of bison version 1.25. Please confirm that -you are using a version 1.25 or better. Don't forget to do "make -clean" after installing it. Don't forget to remove the stale -bison.simple as well. +you are using a version 1.25 or better, that is B bison +B<1.25>. Don't forget to do "make clean" after installing it. Don't +forget to remove the stale F as well. If the problem persists, then please mail me. diff --git a/INSTALL.text b/INSTALL.text index a91ed8b4ef..bbbec823a1 100644 --- a/INSTALL.text +++ b/INSTALL.text @@ -61,7 +61,7 @@ RRRRUUUUNNNNNNNNIIIINNNNGGGG -8/Aug/97 LilyPond 0.1.7 1 +8/Aug/97 LilyPond 0.1.9 1 @@ -127,7 +127,7 @@ CCCCOOOONNNNFFFFIIIIGGGGUUUURRRRIIIINNNNGGGG a -8/Aug/97 LilyPond 0.1.7 2 +8/Aug/97 LilyPond 0.1.9 2 @@ -193,7 +193,7 @@ INSTALL(1) LilyPond documentation INSTALL(1) -8/Aug/97 LilyPond 0.1.7 3 +8/Aug/97 LilyPond 0.1.9 3 @@ -259,7 +259,7 @@ IIIINNNNSSSSTTTTAAAALLLLLLLLIIIINNNNGGGG -8/Aug/97 LilyPond 0.1.7 4 +8/Aug/97 LilyPond 0.1.9 4 @@ -325,7 +325,7 @@ RRRREEEEDDDDHHHHAAAATTTT LLLLIIIINNNNUUUUXXXX -8/Aug/97 LilyPond 0.1.7 5 +8/Aug/97 LilyPond 0.1.9 5 @@ -391,6 +391,6 @@ AAAAUUUUTTTTHHHHOOOORRRRSSSS -8/Aug/97 LilyPond 0.1.7 6 +8/Aug/97 LilyPond 0.1.9 6 diff --git a/NEWS b/NEWS index 24972f4326..6c757d5207 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,19 @@ +pl 9 + - declare rhythic_request + - preliminary support for real \mudelaheaders + - context-sensitive arithmetic spacing. Looks alot better + - silly GNU braces. + - JCN fixes for pl 8 + - bf: midi instrument + - Vocabs from GMP-I + +pl 8.mb: + - use log of duration-name +******* +aug 15 pl 8 + - gif -> xpm - bf: Whoops! Open eyes now, when finding shortest note in spring-spacer. Fixes spacing problems. @@ -9,14 +23,14 @@ spring-spacer. Fixes spacing problems. - Identifier doesn't store its name. Much cleaner now. - bf: Rest_collision_engraver now always announces - bf: announce Staff_sym only once - - rewrite of mi2mu (JCN) - -******** -aug 14 pl 0.1.7.jcn1 - complete redo mid/back-end of mi2mu - bf: do not create/play empty Audio-{text,instrument} events + +******** +aug 14 + pl 7 - Audio_element as base for Audio_item and Audio_staff. fixes midi-lyric segfault @@ -77,9 +91,6 @@ Interface via File_storage. (Now using Simple_file_storage) - mudela: parse tempo requests, \midi{ \tempo 4= 60;} ****** -pl 0.1.3.jcn1 - - mi2mu: simplification +bf lily_stream: indentation and wordwrap - - mi2mu: bf: blunt: non-alpha(num) chars from identifiers aug 8 pl 3 - don't crash if no Clef_engraver. diff --git a/TODO b/TODO index d53e6e6b69..8b8b9c403d 100644 --- a/TODO +++ b/TODO @@ -6,76 +6,6 @@ done, or is an idea that I want to think about Most of the items are marked in the code as well, with full explanation. grep for TODO and ugh/ugr - * Generate TeX titles from MudelaHeader - - * integrate midi-elts from mi2mu and lily - - * virtualise PCols to make encapsulated spacing problems - - * Doc Mutopia (Music To The People) - - * context in spring-spacer. - - * don't count bars which are not on first beat. - - * generate stuff in out/default, out/sun5-irix etc iso out/ - and out-sun5/ - - * derive lily_stream, Dstream, texstream from ostream? - - * check libtool, automake - - * have make dist produce tarball in out/ directory. - - * write a faster Spring_spacer ( without matrices if possible ) - - * A decent scalar type - - * relate energybound to linelen unitspace fontsize etc. - - * naming of Voice_group/Voice - - * benchmark band_matrices. - - * versioning stuff (cvt mudela, mudela, etc.) - - * get rid of gif files. - - * dots into separate item. - - * use String iso Text_def for lyrics. - - * use position 0 for center of staff iso bottom. - - * Klavarskribo? - - * return status on exit - - * lyrics in chords still fuck up. - - * rewire acknowledge_element() logic with a process_acknowledged() - - * Global type registration. - - My_class * p = create_object( My_class ) - Type t = get_type ( *p ); - if ( t <= get_type( q )) - .. - - * progress when creating MIDI elts. - - * pushgroup/popgroup - - * whole head on ledger line - - * piano staff - - * update 20 pt table - - * decent TeX page layout - - * a tutorial - 3RD PARTY BUGS: * ICE: spring-spacer::calcideal() @@ -96,19 +26,47 @@ grep for TODO and ugh/ugr * (where are the) gcc compile warnings on linux -LILY BUGS +PROJECTS - \score { < - \melodic { \id "Staff" ""; c'4 g'4 } - \lyric { \id "Lyric" ""; hello4 bye4 < a chord > } - \lyric { \id "Lyric" ""; bye4 hello4 } - \melodic { \id "Staff" ""; c'4 g'4 } - > } + * Spring_spacer: + - write a faster Spring_spacer ( without matrices if possible ) + - relate energybound to linelen unitspace fontsize etc. + -used fixed fp -PROJECTS + * \header + - Generate TeX titles from \header: + + title = XXX + -> \def\title{XXXX} + - revise lexer mode + - write perl script for handling it * emacs-mode for mudela + * Makefile stuff: + - have make dist produce tarball in out/ directory. + - Use Automake + - shared lib on Solaris too. + - check libtool, automake + + - generate stuff in out/default, out/sun5-irix etc iso out/ + and out-sun5/ + + * chords + - guitar chords + - chord names + - basso continuo + - Syntax/parser + - MIDI output? + - typesetting + + * integrate midi-elts from mi2mu and lily + + * Debug logs: + - derive lily_stream, Dstream, texstream from ostream? + - indentable stream as baseclass for TeX stream, lily stream, Dstream. + - use dstream feature in mi2mu + * input converters - NIFF? - ABC? @@ -139,6 +97,8 @@ PROJECTS - quiet/ignore-version options - logfile output + * piano staff + * elaborate Staff_side baseclass: - scripts - text @@ -153,6 +113,12 @@ PROJECTS - PostScript output (esp. Beams, Slurs, etc) - Move PScore, Items, Spanners etc. into libmutype.a + + * Documentation + - Doc Mutopia (Music To The People) + - Doc (C) stuff of sheet music + - a tutorial + * separate Score_elem settings in user-settable (properties .. ) and non-user-settable part. Maybe use something like X-resources: "Staff=oboe*dir: 0", "Staff=*.Voice_group=solo*dir: 1" @@ -173,7 +139,7 @@ PROJECTS - beams over bars - * Redo font support + * Redo font - rename mf fonts to avoid conflicts with musixtex - use own fonts/update musixtex fonts/find older (c)-less fonts - hack up mf sources for decent spacing info (and then @@ -181,6 +147,11 @@ PROJECTS - use MF to generate rules. - rewrite : make a metafont iso font + * Font support: + - update 20 pt table + - mixed fontsizes + + * lines: - Ledger lines, should be separate item: Ledger_lines, Ledger_lines - set different line sizes / thicknesses @@ -216,13 +187,15 @@ PROJECTS - specify number of lines - set linelength per line + * Rhythmic staff. + SEVERELY LACKING: * SPEED! * multibar rests - * barnumbers, markers + * markers * abbreviations c4=16 @@ -235,8 +208,6 @@ INPUTLANGUAGE * 4 ? - * should have \require{package.ly} to read req'd packages. - * Viola mode? @c c g e g @@ -255,71 +226,64 @@ INPUTLANGUAGE * configure pitch_byte - * figured bass? - * rest name configurable * Raw request syntax -PROJECTS - - * Do RTTI i.s.o. static_name(), name() and request-junk. SMALLISH PROJECTS + * progress when creating MIDI elts. + * A range for context errors (eg. mark both { and }. ) - * lyric in staff (sharpsharp in staff, text below) + * merge Atom and Symbol - * fix Egler definitions ( see tex/eglerdefs.tex ) + * lyric in staff (sharpsharp in staff, text below) * replace Score_elem member access by get()/set() methods, to enable future embedded code. - * --fast/--draft: leave out constraints - * write Dynamic_line (to group dynamics horizontally) * write Rest_collision * use Real for y positions. - * shared lib on Solaris too. - - * cleanup lily-proto.hh and proto.hh - * half-sharps, half-flats * adaptive accidental spacing. * unix style paths for LILYINCLUDE env - * indentable stream as baseclass for TeX stream, lily stream, Dstream. - * handle EOF graciously in error messages. * caching Item/spanner dimensions. * centered whole rest - * use dstream feature in mi2mu - * qtor, btor, mtor-> tor( QUIET_ver ), tor( DEBUG_ver ), etc. - use tors feature in lily (?) - * declare symtab - * declare notenametab? * midi esp.: use I32 iso int where 32 bits are needed (or assumed...) * parshape + * Flower types: + - A decent scalar type + - String hash + - Pointer hash + + * binsearch/hash for identifiers * stafftypes: voice names/ instrument names. - * Decent TeX titledefs (\tempo, \metron, etc. ) + * TeX stuff: + - Decent TeX titledefs (\tempo, \metron, etc. ) + - decent TeX page layout * lily \tempo @@ -327,40 +291,34 @@ SMALLISH PROJECTS * textspanner: center position - * script-spacing * Brackets - * use (char *) iso. String for communication between lexer and - parser. + * Scricts: + - stack scripts in chords: + % fingering: footing: + < a-4 c-2 g-1 > < c-\ltoe e-\lheel > + - script-spacing + - slur parts as a script + - stackparameterised scripts for fingering and footing: - * configure idealspacing: arithmetic spacing + % toe to bheel four to five + % ^_u 4_5 + % - + % --|x-- --|x-- + % --|--- --|--- + % --|--- --|--- + (where "to" is a tiny bow) DOC - * Score_elem structure. - * all errors - * config of TeX macros - - * a test suite - * hacking-HOWTO FUTURE * auxilliary file for caching info. - * Reg_configure_request - - * slur parts as a script - - * mixed fontsizes - - * put scripts on bars - - * guitar chord - * Text_crescendo * clean solution for staffsize in items. @@ -371,8 +329,6 @@ FUTURE IDEAS - * derive PCol from Score_elem? More in Score_elems? Spacing? - * scoping in Lexer: do general id- assignments in mudela. ID '=' EXPR; @@ -390,10 +346,6 @@ IDEAS * y -dims in internote? Staff-space? X-dimensions? - * merge Atom and Symbol? - - * merge common code of Item, Atom/Molecule - * Spacing_request for manually adjusting spacing * caching breakpoints @@ -404,23 +356,45 @@ IDEAS * used fixedpoint arithmetic for min. energy. - * default convert mudela-file.ly -> mudela-file.tex - - rename {standchen,scsii-menuetto,...}.tex + * move towards incremental algorithms. - * stack scripts in chords: - % fingering: footing: - < a-4 c-2 g-1 > < c-\ltoe e-\lheel > + * design meta-language like TeX and Metafont - * stackparameterised scripts for fingering and footing: + * Global type registration. - % toe to bheel four to five - % ^_u 4_5 - % - - % --|x-- --|x-- - % --|--- --|--- - % --|--- --|--- - (where "to" is a tiny bow) + My_class * p = create_object( My_class ) + Type t = get_type ( *p ); + if ( t <= get_type( q )) + .. - * move towards incremental algorithms. + + * virtualise PCols to make encapsulated spacing problems + + * don't count bars which are not on first beat. + + * naming of Voice_group/Voice + + * benchmark band_matrices. + + * versioning stuff (cvt mudela, mudela, etc.) + + * a real convert-mudela + + * dots into separate item. + + * use String iso Text_def for lyrics. + + * use position 0 for center of staff iso bottom. + + * Klavarskribo? + + * return status on exit + + * lyrics in chords still fuck up. + + * rewire acknowledge_element() logic with a process_acknowledged() + + * pushgroup/popgroup + + * whole head on ledger line - * design meta-language like TeX and Metafont diff --git a/VERSION b/VERSION index 3248c2e3ff..b5229ae0eb 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ TOPLEVEL_MAJOR_VERSION = 0 TOPLEVEL_MINOR_VERSION = 1 -TOPLEVEL_PATCH_LEVEL = 8 +TOPLEVEL_PATCH_LEVEL = 9 # use to send patches, always empty for released version: -TOPLEVEL_MY_PATCH_LEVEL = .jcn1 +TOPLEVEL_MY_PATCH_LEVEL = diff --git a/flower/choleski.cc b/flower/choleski.cc index eae3c49cea..4a98301af3 100644 --- a/flower/choleski.cc +++ b/flower/choleski.cc @@ -15,26 +15,28 @@ const Real EPS = 1e-7; // so sue me. Hard coded void Choleski_decomposition::full_matrix_solve (Vector &out, Vector const &rhs)const { - int n= rhs.dim(); - assert (n == L.dim()); - Vector y; - y.set_dim (n); - out.set_dim (n); - - // forward substitution - for (int i=0; i < n; i++) { + int n= rhs.dim(); + assert (n == L.dim()); + Vector y; + y.set_dim (n); + out.set_dim (n); + + // forward substitution + for (int i=0; i < n; i++) + { Real sum (0.0); for (int j=0; j < i; j++) sum += y (j) * L(i,j); y (i) = (rhs (i) - sum)/L(i,i); } - - for (int i=0; i < n; i++) + + for (int i=0; i < n; i++) y (i) /= D(i); - // backward subst - Vector &x (out); // using input as return val. - for (int i=n-1; i >= 0; i--) { + // backward subst + Vector &x (out); // using input as return val. + for (int i=n-1; i >= 0; i--) + { Real sum (0.0); for (int j=i+1; j < n; j++) sum += L(j,i)*x (j); @@ -45,28 +47,30 @@ Choleski_decomposition::full_matrix_solve (Vector &out, Vector const &rhs)const void Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs)const { - int n= rhs.dim(); - int b = L.band_i(); - assert (n == L.dim()); + int n= rhs.dim(); + int b = L.band_i(); + assert (n == L.dim()); - out.set_dim (n); + out.set_dim (n); + + Vector y; + y.set_dim (n); - Vector y; - y.set_dim (n); - - // forward substitution - for (int i=0; i < n; i++) { + // forward substitution + for (int i=0; i < n; i++) + { Real sum (0.0); for (int j= 0 >? i - b; j < i; j++) sum += y (j) * L(i,j); y (i) = (rhs (i) - sum)/L(i,i); } - for (int i=0; i < n; i++) + for (int i=0; i < n; i++) y (i) /= D(i); - // backward subst - Vector &x (out); // using input as return val. - for (int i=n-1; i >= 0; i--) { + // backward subst + Vector &x (out); // using input as return val. + for (int i=n-1; i >= 0; i--) + { Real sum (0.0); for (int j=i+1; j <= i + b&&j < n ; j++) sum += L(j,i)*x (j); @@ -77,18 +81,20 @@ Choleski_decomposition::band_matrix_solve (Vector &out, Vector const &rhs)const void Choleski_decomposition::solve (Vector &x, Vector const &rhs)const { - if (L.band_b()) { + if (L.band_b()) + { band_matrix_solve (x,rhs); - } else + } + else full_matrix_solve (x,rhs); } Vector Choleski_decomposition::solve (Vector rhs)const { - Vector r; - solve (r, rhs); - return r; + Vector r; + solve (r, rhs); + return r; } void @@ -96,14 +102,16 @@ Choleski_decomposition::full_matrix_decompose (Matrix const & P) { int n = P.dim(); - L.unit(); - for (int k= 0; k < n; k++) { - for (int j = 0; j < k; j++){ + L.unit(); + for (int k= 0; k < n; k++) + { + for (int j = 0; j < k; j++) + { Real sum (0.0); for (int l=0; l < j; l++) sum += L(k,l)*L(j,l)*D(l); L(k,j) = (P(k,j) - sum)/D(j); - } + } Real sum=0.0; for (int l=0; l < k; l++) @@ -117,17 +125,19 @@ Choleski_decomposition::full_matrix_decompose (Matrix const & P) void Choleski_decomposition::band_matrix_decompose (Matrix const &P) { - int n = P.dim(); - int b = P.band_i(); - L.unit(); - - for (int i= 0; i < n; i++) { - for (int j = 0 >? i - b; j < i; j++){ + int n = P.dim(); + int b = P.band_i(); + L.unit(); + + for (int i= 0; i < n; i++) + { + for (int j = 0 >? i - b; j < i; j++) + { Real sum (0.0); for (int l=0 >? i - b; l < j; l++) sum += L(i,l)*L(j,l)*D(l); L(i,j) = (P(i,j) - sum)/D(j); - } + } Real sum=0.0; for (int l=0 >? i - b; l < i; l++) @@ -135,8 +145,8 @@ Choleski_decomposition::band_matrix_decompose (Matrix const &P) Real d = P(i,i) - sum; D(i) = d; } - L.try_set_band(); - assert ( L.band_i() == P.band_i ()); + L.try_set_band(); + assert ( L.band_i() == P.band_i ()); } @@ -150,46 +160,47 @@ Choleski_decomposition::Choleski_decomposition (Matrix const & P) : L(P.dim()), D(P.dim ()) { #ifdef PARANOID - assert ((P-P.transposed()).norm ()/P.norm () < EPS); + assert ((P-P.transposed()).norm ()/P.norm () < EPS); #endif - if (P.band_b()) + if (P.band_b()) band_matrix_decompose (P); - else + else full_matrix_decompose (P); #ifdef PARANOID - assert ((original()-P).norm () / P.norm () < EPS); + assert ((original()-P).norm () / P.norm () < EPS); #endif } Matrix Choleski_decomposition::original() const { - Matrix T(L.dim()); - T.set_diag (D); - return L*T*L.transposed(); + Matrix T(L.dim()); + T.set_diag (D); + return L*T*L.transposed(); } Matrix Choleski_decomposition::inverse() const { - int n=L.dim(); - Matrix invm (n); - Vector e_i (n); - Vector inv (n); - for (int i = 0; i < n; i++) { + int n=L.dim(); + Matrix invm (n); + Vector e_i (n); + Vector inv (n); + for (int i = 0; i < n; i++) + { e_i.set_unit (i); solve (inv, e_i); for (int j = 0 ; j=0); - Full_storage f (dim(), 2*s+1); - for (int i=0; i < dim(); i++) { + assert (s>=0); + Full_storage f (dim(), 2*s+1); + for (int i=0; i < dim(); i++) + { int k=-s; for ( ; k < -band_size_i(); k++) f.elem (i,k + s) = 0.0; @@ -61,7 +62,7 @@ Diagonal_storage::set_band_size (int s) f.elem (i, k + s) =0.0; } - band_ = f; + band_ = f; } @@ -72,13 +73,13 @@ Diagonal_storage::set_band_size (int s) void Diagonal_storage::insert_row (int) { - assert (false); + assert (false); } void Diagonal_storage::delete_row (int) { - assert (false); + assert (false); } void @@ -94,9 +95,9 @@ Diagonal_storage::resize (int) void Diagonal_storage::delete_column (int) { - assert (false); + assert (false); } - + Diagonal_storage::~Diagonal_storage() { } @@ -105,27 +106,28 @@ Diagonal_storage::~Diagonal_storage() bool Diagonal_storage::band_elt_b (int i,int j)const { - return abs (i-j) <= band_size_i(); + return abs (i-j) <= band_size_i(); } void Diagonal_storage::assert_valid (int i,int j)const { - assert (band_elt_b (i,j)); - assert (i >=0 && j >=0 && i < dim() && j < dim ()); + assert (band_elt_b (i,j)); + assert (i >=0 && j >=0 && i < dim() && j < dim ()); } void Diagonal_storage::resize_dim (int d) { - Full_storage f (d, 2*band_size_i()+1); - for (int i=0; i < d && i < dim(); i++) { + Full_storage f (d, 2*band_size_i()+1); + for (int i=0; i < d && i < dim(); i++) + { for ( int k=0; k < 2*band_size_i(); k++) f.elem (i,k) = elem (i,k); } - band_ = f; + band_ = f; } @@ -133,16 +135,17 @@ Diagonal_storage::resize_dim (int d) bool Diagonal_storage::mult_ok (int i,int)const { - return i < dim(); + return i < dim(); } void Diagonal_storage::mult_next (int &i, int &j)const { - j++; - if ( j < i - band_size_i()) + j++; + if ( j < i - band_size_i()) j = i- band_size_i(); - if ( j > i + band_size_i() || j >= dim ()) { + if ( j > i + band_size_i() || j >= dim ()) + { i++; j = 0 >? i - band_size_i(); } @@ -151,17 +154,18 @@ Diagonal_storage::mult_next (int &i, int &j)const bool Diagonal_storage::trans_ok (int ,int j)const { - return j < dim(); + return j < dim(); } void Diagonal_storage::trans_next (int &i, int& j)const { - i++; - if ( i < j - band_size_i()) + i++; + if ( i < j - band_size_i()) i = j-band_size_i(); - - if ( i >= dim() || i > j + band_size_i ()) { + + if ( i >= dim() || i > j + band_size_i ()) + { j++; i = 0 >? j - band_size_i(); } @@ -172,23 +176,23 @@ static Real nul_entry=0.0; Real Diagonal_storage::elem (int i, int j)const { - if (abs ( i-j) > band_size_i()) + if (abs ( i-j) > band_size_i()) return 0; - else + else return band_.elem (i, j - i +band_size_i()); } Real & Diagonal_storage::elem (int i, int j) { - /* - if this fails, the previous call fucked up - */ - assert (!nul_entry); + /* + if this fails, the previous call fucked up + */ + assert (!nul_entry); - if (abs ( i-j) > band_size_i()) + if (abs ( i-j) > band_size_i()) return nul_entry; - else + else return band_.elem (i, j - i + band_size_i()); } @@ -200,17 +204,19 @@ bool Diagonal_storage::try_right_multiply (Matrix_storage*dest, const Matrix_storage*right)const { - if ( right->name() != Diagonal_storage::static_name ()) + if ( right->name() != Diagonal_storage::static_name ()) return false; - - const Diagonal_storage* right_diag = (Diagonal_storage const*)right; - int band2 = right_diag->band_size_i(); - int n = dim(); - /* - should check if dest is a Diagonal_storage of sufficient size too. - */ - for (int i=0; i < n; i++) { - for (int j = 0; j < n; j++) { + + const Diagonal_storage* right_diag = (Diagonal_storage const*)right; + int band2 = right_diag->band_size_i(); + int n = dim(); + /* + should check if dest is a Diagonal_storage of sufficient size too. + */ + for (int i=0; i < n; i++) + { + for (int j = 0; j < n; j++) + { int startk = i - band_size_i() >? 0 >? j - band2; int stopk = i + band_size_i() elem (k, j); dest->elem (i, j) = sum; - } + } } - return true; + return true; } IMPLEMENT_IS_TYPE_B1(Diagonal_storage, Matrix_storage); @@ -229,17 +235,17 @@ IMPLEMENT_IS_TYPE_B1(Diagonal_storage, Matrix_storage); Diagonal_storage::Diagonal_storage (Matrix_storage*stor_l, int band_i) { - set_band_size (band_i); - resize_dim (stor_l->dim()); + set_band_size (band_i); + resize_dim (stor_l->dim()); - for ( int i=0,j=0; mult_ok (i,j); mult_next (i,j)) + for ( int i=0,j=0; mult_ok (i,j); mult_next (i,j)) band_.elem (i, j + band_i -i) = stor_l->elem (i,j); } void Diagonal_storage::OK() const { - band_.OK(); + band_.OK(); } IMPLEMENT_VIRTUAL_COPY_CONS(Diagonal_storage, Matrix_storage); diff --git a/flower/directed-graph.cc b/flower/directed-graph.cc index 2c55688011..46511b4c31 100644 --- a/flower/directed-graph.cc +++ b/flower/directed-graph.cc @@ -18,13 +18,13 @@ Link_array const & Directed_graph_node::get_in_edge_arr() const { - return edge_in_l_arr_; + return edge_in_l_arr_; } Link_array const & Directed_graph_node::get_out_edge_arr()const { - return edge_out_l_arr_; + return edge_out_l_arr_; } /** @@ -37,7 +37,7 @@ Directed_graph_node::Directed_graph_node (Directed_graph_node const&) void Directed_graph_node::copy_edges_out (Directed_graph_node const &s) { - for (int i=0; i < s.edge_out_l_arr_.size(); i++) + for (int i=0; i < s.edge_out_l_arr_.size(); i++) add (s.edge_out_l_arr_[i]); } @@ -45,11 +45,12 @@ void Directed_graph_node::OK() const { #ifndef NDEBUG - for (int i=0; i < edge_out_l_arr_.size(); i++) { + for (int i=0; i < edge_out_l_arr_.size(); i++) + { assert (edge_out_l_arr_[i]-> edge_in_l_arr_.find_l (this)); } - for (int i=0; i < edge_in_l_arr_.size(); i++) + for (int i=0; i < edge_in_l_arr_.size(); i++) assert (edge_in_l_arr_[i]->contains_b (this)); #endif } @@ -57,52 +58,53 @@ Directed_graph_node::OK() const bool Directed_graph_node::contains_b (const Directed_graph_node *d)const { - return edge_out_l_arr_.find_l ((Directed_graph_node*)d); + return edge_out_l_arr_.find_l ((Directed_graph_node*)d); } - + void Directed_graph_node::remove_edge_out_idx (int i) { - PARANOID_OK(); - Directed_graph_node * d_l = edge_out_l_arr_.get (i); + PARANOID_OK(); + Directed_graph_node * d_l = edge_out_l_arr_.get (i); - int j = d_l->edge_in_l_arr_.find_i (this); - assert (j>=0); - d_l->edge_in_l_arr_.unordered_del (j); - PARANOID_OK(); + int j = d_l->edge_in_l_arr_.find_i (this); + assert (j>=0); + d_l->edge_in_l_arr_.unordered_del (j); + PARANOID_OK(); } void Directed_graph_node::remove_edge_in (Directed_graph_node *d_l) { - PARANOID_OK(); - d_l->remove_edge_out (this); - PARANOID_OK(); + PARANOID_OK(); + d_l->remove_edge_out (this); + PARANOID_OK(); } void Directed_graph_node::remove_edge_out (Directed_graph_node *d_l) { - PARANOID_OK(); - for (int i=0; i < edge_out_l_arr_.size();) { + PARANOID_OK(); + for (int i=0; i < edge_out_l_arr_.size();) + { if (edge_out_l_arr_[i]== d_l) remove_edge_out_idx (i); else i++; } - PARANOID_OK(); + PARANOID_OK(); } bool Directed_graph_node::linked_b()const { - return edge_out_l_arr_.size() || edge_in_l_arr_.size (); + return edge_out_l_arr_.size() || edge_in_l_arr_.size (); } void Directed_graph_node::junk_links() { - edge_in_l_arr_.set_size (0); - edge_out_l_arr_.set_size (0); + edge_in_l_arr_.set_size (0); + edge_out_l_arr_.set_size (0); } @@ -130,21 +132,21 @@ Directed_graph_node::unlink() Directed_graph_node::~Directed_graph_node() { - assert (!linked_b()); + assert (!linked_b()); } - + void Directed_graph_node::add (Directed_graph_node* dep_l) { - PARANOID_OK(); - if (!dep_l) + PARANOID_OK(); + if (!dep_l) return ; - dep_l->edge_in_l_arr_.push (this); - edge_out_l_arr_.push (dep_l); - PARANOID_OK(); + dep_l->edge_in_l_arr_.push (this); + edge_out_l_arr_.push (dep_l); + PARANOID_OK(); } - + Directed_graph_node::Directed_graph_node() { diff --git a/flower/dstream.cc b/flower/dstream.cc index f6d1d48867..f11576d590 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -23,88 +23,91 @@ const INDTAB = 2; static String strip_pretty (String pretty_str) { - int i = pretty_str.index_i ('('); - if (i>=0) + int i = pretty_str.index_i ('('); + if (i>=0) pretty_str = pretty_str.left_str (i); - - int l = pretty_str.index_last_i (' '); // strip until last ' ' - if (l>=0) + + int l = pretty_str.index_last_i (' '); // strip until last ' ' + if (l>=0) pretty_str = pretty_str.nomid_str (0,l+1); - return pretty_str; + return pretty_str; } static String strip_member (String pret) { - int l=pret.index_last_i (':')-1; - if (l>=0) + int l=pret.index_last_i (':')-1; + if (l>=0) pret = pret.left_str (l); - return pret; + return pret; } Dstream& Dstream::identify_as (String name) { - if (!os_l_) + if (!os_l_) return *this; - - String mem (strip_pretty (name)); - String cl (strip_member (mem)); - String idx = cl; - - if (silent_assoc_p_->elt_b (mem)) + + String mem (strip_pretty (name)); + String cl (strip_member (mem)); + String idx = cl; + + if (silent_assoc_p_->elt_b (mem)) idx = mem; - else if (silent_assoc_p_->elt_b (cl)) + else if (silent_assoc_p_->elt_b (cl)) idx = cl; - else { + else + { (*silent_assoc_p_)[idx] = false; } - local_silence_b_ = (*silent_assoc_p_)[idx]; - if (current_classname_str_ != idx && !local_silence_b_) { + local_silence_b_ = (*silent_assoc_p_)[idx]; + if (current_classname_str_ != idx && !local_silence_b_) + { current_classname_str_=idx; if (!(*silent_assoc_p_)["Dstream"]) *os_l_ << "[" << current_classname_str_ << ":]"; // messy. } - return *this; + return *this; } bool Dstream::silence (String s) { - if (!silent_assoc_p_->elt_b (s)) + if (!silent_assoc_p_->elt_b (s)) return false; - return (*silent_assoc_p_)[s]; + return (*silent_assoc_p_)[s]; } Dstream & Dstream::operator<<(String s) { - output (s); - return *this; + output (s); + return *this; } Dstream & Dstream::operator<<(void const *v_l) { - output (String_convert::pointer_str (v_l)); - return *this; + output (String_convert::pointer_str (v_l)); + return *this; } Dstream & Dstream::operator<<(char const *ch_l) { - output (ch_l); - return *this; + output (ch_l); + return *this; } void Dstream::output (String s) { - if (local_silence_b_|| !os_l_) + if (local_silence_b_|| !os_l_) return ; - - for (char const *cp = s ; *cp; cp++) - switch (*cp) { + + for (char const *cp = s ; *cp; cp++) + switch (*cp) + { case '{': case '[': case '(': indent_level_i_ += INDTAB; @@ -126,33 +129,34 @@ Dstream::output (String s) default: *os_l_ << *cp; break; - } - return ; + } + return ; } Dstream::Dstream (ostream *r, char const * cfg_nm) { - os_l_ = r; - silent_assoc_p_ = new Assoc; - indent_level_i_ = 0; - if (!os_l_) + os_l_ = r; + silent_assoc_p_ = new Assoc; + indent_level_i_ = 0; + if (!os_l_) return; - - char const * fn =cfg_nm ? cfg_nm : ".dstreamrc"; - { + + char const * fn =cfg_nm ? cfg_nm : ".dstreamrc"; + { ifstream ifs (fn); // can't open if (!ifs) return; } - Text_db cfg (fn); - while (! cfg.eof()){ + Text_db cfg (fn); + while (! cfg.eof()){ Text_record r (cfg++); - if (r.size() != 2) { + if (r.size() != 2) + { r.message ("not enough fields in Dstream init."); continue; - } + } (*silent_assoc_p_)[r[0]] = (bool)(int)(Scalar (r[1])); } @@ -161,14 +165,15 @@ Dstream::Dstream (ostream *r, char const * cfg_nm) Dstream::~Dstream() { - delete silent_assoc_p_; - assert (!indent_level_i_) ; + delete silent_assoc_p_; + assert (!indent_level_i_) ; } void Dstream::clear_silence() { - for (Assoc_iter i (*silent_assoc_p_); i.ok(); i++) { + for (Assoc_iter i (*silent_assoc_p_); i.ok(); i++) + { i.val() = 0; } } diff --git a/flower/flower-debug.cc b/flower/flower-debug.cc index 5ea5e50dc0..52156f983a 100644 --- a/flower/flower-debug.cc +++ b/flower/flower-debug.cc @@ -13,11 +13,11 @@ Dstream *flower_dstream = &default_flower_stream; void set_flower_debug (Dstream&ds, bool b) { #ifdef NPRINT - if (b) + if (b) cout << "Debug printout disabled, see the installation guide." << endl; #endif - - flower_check_debug = b; - flower_dstream = &ds; + + flower_check_debug = b; + flower_dstream = &ds; } diff --git a/flower/flower-version.cc b/flower/flower-version.cc index 84cfd803d3..6372f50277 100644 --- a/flower/flower-version.cc +++ b/flower/flower-version.cc @@ -10,7 +10,7 @@ static const int build= char const * flower_version_sz() { - static char v[1024]; - sprintf (v, s, build); - return v; + static char v[1024]; + sprintf (v, s, build); + return v; } diff --git a/flower/full-storage.cc b/flower/full-storage.cc index 34dcdad1b8..ee59ea23ed 100644 --- a/flower/full-storage.cc +++ b/flower/full-storage.cc @@ -12,10 +12,10 @@ void Full_storage::operator=(Full_storage const &fs) { - resize (fs.height_i_, fs.width_i_); - OK(); - fs.OK(); - for (int i=0; i= height_i_ && max_width_i_ >= width_i_); - assert (height_i_ >= 0 && width_i_ >= 0); - assert (els_p_p_||!max_height_i_); + assert (max_height_i_ >= height_i_ && max_width_i_ >= width_i_); + assert (height_i_ >= 0 && width_i_ >= 0); + assert (els_p_p_||!max_height_i_); #endif } @@ -37,18 +37,18 @@ Full_storage::OK() const Full_storage::~Full_storage() { - for (int i=0; i < max_height_i_; i++) + for (int i=0; i < max_height_i_; i++) delete [] els_p_p_[i]; - delete[] els_p_p_; + delete[] els_p_p_; } void Full_storage::resize (int rows, int cols) { - OK(); - resize_cols (rows); - resize_rows (cols); + OK(); + resize_cols (rows); + resize_rows (cols); } @@ -56,14 +56,14 @@ Full_storage::resize (int rows, int cols) bool Full_storage::mult_ok (int i, int) const { - return i < height_i_; + return i < height_i_; } bool Full_storage::trans_ok (int , int j) const { - return j < width_i_; + return j < width_i_; } @@ -71,9 +71,10 @@ Full_storage::trans_ok (int , int j) const void Full_storage::trans_next (int &i, int &j) const { - assert (trans_ok (i,j)); - i++; - if (i >= height_i_) { + assert (trans_ok (i,j)); + i++; + if (i >= height_i_) + { i=0; j ++; } @@ -83,9 +84,10 @@ Full_storage::trans_next (int &i, int &j) const void Full_storage::mult_next (int &i, int &j) const { - assert (mult_ok (i,j)); - j++; - if (j >= width_i_) { + assert (mult_ok (i,j)); + j++; + if (j >= width_i_) + { j=0; i++; } @@ -95,22 +97,22 @@ Full_storage::mult_next (int &i, int &j) const void Full_storage::delete_column (int k) { - assert (0 <= k &&k k ; i--) + assert (0 <= k&& k <=height_i_); + resize_cols (height_i_+1); + for (int i=height_i_-1; i > k ; i--) for (int j=0; j name() != Full_storage::static_name () || + if (dest->name() != Full_storage::static_name () || right->name() != Full_storage::static_name ()) return false; - Full_storage *d_l = (Full_storage*)dest; - Full_storage *r_l = (Full_storage*)right; - - d_l->set_size (height_i_, r_l->width_i_); - for (int i=0; i < d_l->height_i_; i++) - for (int j = 0; j < d_l->width_i_; j++) { + Full_storage *d_l = (Full_storage*)dest; + Full_storage *r_l = (Full_storage*)right; + + d_l->set_size (height_i_, r_l->width_i_); + for (int i=0; i < d_l->height_i_; i++) + for (int j = 0; j < d_l->width_i_; j++) + { Real &r (d_l->els_p_p_[i][j]); r=0.0; for (int k = 0; k < width_i_; k++) r += els_p_p_[i][k] * r_l->els_p_p_[k][j]; - } - return true; - - + } + return true; + + } IMPLEMENT_IS_TYPE_B1(Full_storage,Matrix_storage); void Full_storage::resize_cols (int newh) { - if (newh <= max_height_i_) { + if (newh <= max_height_i_) + { height_i_=newh; return; } - Real ** newa=new Real*[newh]; - int j=0; - for (; j < height_i_; j++) + Real ** newa=new Real*[newh]; + int j=0; + for (; j < height_i_; j++) newa[j] = els_p_p_[j]; - for (; j < newh; j++) + for (; j < newh; j++) newa[j] = new Real[max_width_i_]; - delete[] els_p_p_; - els_p_p_=newa; + delete[] els_p_p_; + els_p_p_=newa; - height_i_ = max_height_i_ = newh; + height_i_ = max_height_i_ = newh; } Full_storage::Full_storage (Matrix_storage*m) { - set_size (m->rows(), m->cols ()); - if ( !m->is_type_b ( Full_storage::static_name())) + set_size (m->rows(), m->cols ()); + if ( !m->is_type_b ( Full_storage::static_name())) for (int i=0; imult_ok (i,j); m->mult_next (i,j)) + for (int i,j=0; m->mult_ok (i,j); m->mult_next (i,j)) els_p_p_[i][j] = m->elem (i,j); } @@ -187,11 +191,13 @@ Full_storage::Full_storage (Matrix_storage*m) void Full_storage::resize_rows (int neww) { - if (neww <= max_width_i_) { + if (neww <= max_width_i_) + { width_i_=neww; return; } - for (int i=0; i < max_height_i_ ; i++) { + for (int i=0; i < max_height_i_ ; i++) + { Real* newa = new Real[neww]; for (int k=0; k < width_i_; k++) newa[k] = els_p_p_[i][k]; @@ -199,7 +205,7 @@ Full_storage::resize_rows (int neww) delete[] els_p_p_[i]; els_p_p_[i] = newa; } - width_i_ = max_width_i_ = neww; + width_i_ = max_width_i_ = neww; } #ifdef INLINE diff --git a/flower/include/cursor.icc b/flower/include/cursor.icc index d0b2439af4..4fce0b1953 100644 --- a/flower/include/cursor.icc +++ b/flower/include/cursor.icc @@ -20,126 +20,126 @@ inline Cursor::Cursor() : list_(*(List *)0) // ugh { - pointer_ = 0; + pointer_ = 0; } template inline Cursor::Cursor (const List& list, Link* pointer) : - list_((List&) list) + list_((List&) list) { - if ( list.size()) - pointer_ = pointer ? pointer : list.top_; - else - pointer_ = pointer; + if ( list.size()) + pointer_ = pointer ? pointer : list.top_; + else + pointer_ = pointer; } template inline Cursor::Cursor (const Cursor& cursor) : - list_( cursor.list_) + list_( cursor.list_) { - pointer_ = cursor.pointer_; + pointer_ = cursor.pointer_; } template inline T& Cursor::thing() { - assert (pointer_); - return pointer_->thing(); + assert (pointer_); + return pointer_->thing(); } template Cursor Cursor::operator =( const Cursor& c) { - assert (&list_ == &c.list_); - pointer_ = c.pointer_; - return *this; + assert (&list_ == &c.list_); + pointer_ = c.pointer_; + return *this; } template inline void Cursor::add (const T& th) { - list_.add (th, *this); + list_.add (th, *this); } template inline void Cursor::insert (const T& th) { - list_.insert (th, *this); + list_.insert (th, *this); } template inline List& Cursor::list() const { - return list_; + return list_; } template inline Link* Cursor::pointer() { - return pointer_; + return pointer_; } template inline bool Cursor::backward()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline bool Cursor::forward()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline bool Cursor::ok()const { - return ( pointer_ != 0); + return ( pointer_ != 0); } template inline void Cursor::next() { - assert (pointer_); - pointer_ = pointer_->next(); + assert (pointer_); + pointer_ = pointer_->next(); } template inline Cursor Cursor::operator ++( int) { - Cursor r (*this); - next(); - return r; + Cursor r (*this); + next(); + return r; } template inline void Cursor::previous() { - assert (pointer_); - pointer_ = pointer_->previous(); + assert (pointer_); + pointer_ = pointer_->previous(); } template inline Cursor Cursor::operator --( int) { - Cursor r (*this); - previous(); - return r; + Cursor r (*this); + previous(); + return r; } diff --git a/flower/include/cursor.tcc b/flower/include/cursor.tcc index 18f1fbb42a..4bf6347a1d 100644 --- a/flower/include/cursor.tcc +++ b/flower/include/cursor.tcc @@ -8,21 +8,21 @@ template void Cursor::backspace() { - Cursor c (*this); - if ( c.ok()) + Cursor c (*this); + if ( c.ok()) c--; - list_.remove (*this); + list_.remove (*this); } template void Cursor::del() { - Cursor c (*this); - if ( c.ok()) + Cursor c (*this); + if ( c.ok()) c++; - list_.remove (*this); - *this = c; + list_.remove (*this); + *this = c; } @@ -30,46 +30,46 @@ template Cursor Cursor::operator -=( int j) { - while (j--) + while (j--) (*this)--; - return *this; + return *this; } template Cursor Cursor::operator +=( int j) { - while (j++) + while (j++) (*this)++; - return *this; + return *this; } template Cursor Cursor::operator +( int i) const { - Cursor r = *this; + Cursor r = *this; - if (i<0) + if (i<0) return r -(-i); - while (i--) + while (i--) r++; - return r; + return r; } template Cursor Cursor::operator -( int i) const { - Cursor r = *this; - if (i<0) + Cursor r = *this; + if (i<0) return r +(-i); - while (i--) + while (i--) r--; - - return r; + + return r; } /* warning: can't use Cursor::operator == (Cursor), @@ -79,31 +79,33 @@ template int Cursor::operator-(Cursor rhs) const { - assert (rhs.list == list); - int dif = 0; + assert (rhs.list == list); + int dif = 0; - // search from *this on further up (positive difference) - Cursor c (*this); - while (c.ok() && c.pointer_ != rhs.pointer_) { + // search from *this on further up (positive difference) + Cursor c (*this); + while (c.ok() && c.pointer_ != rhs.pointer_) + { c--; dif++; } - - if (c.ok()) + + if (c.ok()) goto gotcha; // so, sue me. - // search in direction of bottom. (negative diff) - dif =0; - c=*this; - while (c.ok() && c.pointer_ !=rhs.pointer_) { + // search in direction of bottom. (negative diff) + dif =0; + c=*this; + while (c.ok() && c.pointer_ !=rhs.pointer_) + { dif --; c++; } - assert (c.ok()); + assert (c.ok()); gotcha: - assert ((*this - dif).pointer_ == c.pointer_); - return dif; + assert ((*this - dif).pointer_ == c.pointer_); + return dif; } #endif diff --git a/flower/include/full-storage.icc b/flower/include/full-storage.icc index d71dbe07e7..0e45f15b24 100644 --- a/flower/include/full-storage.icc +++ b/flower/include/full-storage.icc @@ -14,13 +14,13 @@ INLINE void Full_storage::init() { - els_p_p_=0; - height_i_=width_i_=max_height_i_=max_width_i_=0; + els_p_p_=0; + height_i_=width_i_=max_height_i_=max_width_i_=0; } INLINE bool Full_storage::valid (int i, int j)const { - return (i>=0 && i < height_i_) + return (i>=0 && i < height_i_) && (j < width_i_ && j >=0); } @@ -28,64 +28,64 @@ Full_storage::valid (int i, int j)const INLINE Full_storage::Full_storage (Full_storage const&s) { - init(); - (*this) = s; + init(); + (*this) = s; } INLINE Real& Full_storage::elem (int i,int j) { - assert (valid (i,j)); - return els_p_p_[i][j]; + assert (valid (i,j)); + return els_p_p_[i][j]; } INLINE Real Full_storage::elem (int i, int j) const { - assert (valid (i,j)); - return els_p_p_[i][j]; + assert (valid (i,j)); + return els_p_p_[i][j]; } INLINE Full_storage::Full_storage() { - init(); + init(); } INLINE int Full_storage::rows() const { - return height_i_; + return height_i_; } INLINE int Full_storage::cols() const { - return width_i_; + return width_i_; } INLINE int Full_storage::dim()const { - assert (rows()==cols ()); - return rows(); + assert (rows()==cols ()); + return rows(); } INLINE void Full_storage::resize (int i) { - resize (i,i); + resize (i,i); } INLINE Full_storage::Full_storage (int i,int j) { - init(); - set_size (i,j); + init(); + set_size (i,j); } INLINE Full_storage::Full_storage (int i) { - init(); - set_size (i); + init(); + set_size (i); } INLINE diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index efb7644133..50864b7894 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -20,60 +20,60 @@ template int _Interval__compare (const Interval_t&a,Interval_t const&b) { - if (a.left == b.left && a.right == b.right) + if (a.left == b.left && a.right == b.right) return 0; - - if (a.left <= b.left && a.right >= b.right) + + if (a.left <= b.left && a.right >= b.right) return 1; - if (a.left >= b.left && a.right <= b.right) + if (a.left >= b.left && a.right <= b.right) return -1; - return -2; + return -2; } template bool Interval_t::contains_b (Interval_t const& a)const { - int c_i= _Interval__compare (*this, a); - if (c_i == -2) + int c_i= _Interval__compare (*this, a); + if (c_i == -2) return false; - return c_i >= 0; + return c_i >= 0; } template int Interval__compare (const Interval_t&a,Interval_t const&b) { - int i = _Interval__compare (a,b); - if (i < -1) + int i = _Interval__compare (a,b); + if (i < -1) assert (false); - return i; + return i; } template void Interval_t::set_empty() { - left = (T) infinity(); - right = (T) -infinity(); + left = (T) infinity(); + right = (T) -infinity(); } template T Interval_t::length() const { - assert (right >= left); - return right-left; + assert (right >= left); + return right-left; } template void Interval_t::unite (Interval_t h) { - if (h.leftright) + if (h.right>right) right = h.right; } @@ -86,11 +86,11 @@ void Interval_t::intersect (Interval_t h) { #if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - left = h.left >? left; - right = h.right ? left; + right = h.right Interval_t intersect (Interval_t x, Interval_t const &y) { - x.intersect (y); - return x; + x.intersect (y); + return x; } template String Interval_t::str() const { - if (empty_b()) + if (empty_b()) return "[empty]"; - String s ("["); + String s ("["); - return s + String (left) + String ("," ) + String (right ) + String ("]" ); + return s + String (left) + String ("," ) + String (right ) + String ("]" ); } template bool Interval_t::elt_b (T r) { - return r >= left && r <= right; + return r >= left && r <= right; } diff --git a/flower/include/link.icc b/flower/include/link.icc index 68b87a73fc..7699f1dfbc 100644 --- a/flower/include/link.icc +++ b/flower/include/link.icc @@ -8,10 +8,12 @@ void Link::OK() const { #ifndef NDEBUG - if (previous_) { + if (previous_) + { assert (previous_->next_ == this); } - if (next_) { + if (next_) + { assert (next_->previous_ == this); } #endif @@ -20,18 +22,18 @@ Link::OK() const template inline Link::Link (const T& thing) : - thing_( thing) + thing_( thing) { - previous_ = next_ = 0; + previous_ = next_ = 0; } template inline Link::Link (Link* previous, Link* next, const T& thing) : - thing_( thing) + thing_( thing) { - previous_ = previous; - next_ = next; + previous_ = previous; + next_ = next; } template @@ -39,7 +41,7 @@ inline Link* Link::next() { - return next_; + return next_; } template @@ -47,7 +49,7 @@ inline Link* Link::previous() { - return previous_; + return previous_; } template @@ -55,40 +57,40 @@ inline void Link::add (const T& thing) { - - Link* l = new Link( this, next_, thing); - if ( next_) - next_->previous_ = l; - next_ = l; + + Link* l = new Link( this, next_, thing); + if ( next_) + next_->previous_ = l; + next_ = l; } template inline void Link::insert (const T& thing) { - // Link* l = new Link( next_, this, thing); + // Link* l = new Link( next_, this, thing); // bugfix hwn 16/9/96 - Link* l = new Link( previous_, this, thing); - if ( previous_) - previous_->next_ = l; - previous_ = l; + Link* l = new Link( previous_, this, thing); + if ( previous_) + previous_->next_ = l; + previous_ = l; } /* - don't forget to adjust #l#'s top_ and bottom_. - */ + don't forget to adjust #l#'s top_ and bottom_. + */ template inline void Link::remove (List &l) { - if ( previous_) - previous_->next_ = next_; - else + if ( previous_) + previous_->next_ = next_; + else l.top_ = next_; - if ( next_) - next_->previous_ = previous_; - else + if ( next_) + next_->previous_ = previous_; + else l.bottom_ = previous_; } @@ -97,6 +99,6 @@ inline T& Link::thing() { - return thing_; + return thing_; } #endif diff --git a/flower/include/list.icc b/flower/include/list.icc index 83ec3aa796..80d12f56ba 100644 --- a/flower/include/list.icc +++ b/flower/include/list.icc @@ -7,26 +7,27 @@ template inline List::List() { - set_empty(); + set_empty(); } template inline void List::set_empty() { - top_ = bottom_ = 0; - size_ = 0; + top_ = bottom_ = 0; + size_ = 0; } template inline void List::remove (Cursor me) { - if ( me.ok()){ + if ( me.ok()) + { Link *lp = me.pointer(); lp->remove (*this); delete lp; - size_--; + size_--; } } @@ -34,14 +35,14 @@ template inline int List::size() const { - return size_; + return size_; } template inline Cursor List::top()const { - return Cursor( *this, top_); + return Cursor( *this, top_); } @@ -49,7 +50,7 @@ template inline Cursor List::bottom()const { - return Cursor( *this, bottom_); + return Cursor( *this, bottom_); } diff --git a/flower/include/list.tcc b/flower/include/list.tcc index fb64cd3ee0..1233c4821d 100644 --- a/flower/include/list.tcc +++ b/flower/include/list.tcc @@ -18,9 +18,9 @@ template List::List (List const&src) { - set_empty(); - // probably el stupido - for (Cursor c (src); c.ok(); c++) + set_empty(); + // probably el stupido + for (Cursor c (src); c.ok(); c++) bottom().add (c); } @@ -28,37 +28,39 @@ template void List::OK() const { - int i = size_; - Link *lp = top_; - while (i--) { + int i = size_; + Link *lp = top_; + while (i--) + { assert (lp); lp->OK(); lp = lp->next(); } - assert (!lp); - i = size_; - lp = bottom_; - while (i--) { + assert (!lp); + i = size_; + lp = bottom_; + while (i--) + { assert (lp); lp->OK(); lp = lp->previous(); } - assert (!lp); + assert (!lp); } template void List::junk_links() { - Cursor c (*this); - while (c.ok()) + Cursor c (*this); + while (c.ok()) c.del(); } template List::~List() { - junk_links(); + junk_links(); } /** @@ -77,11 +79,12 @@ template void List::add (T const & thing, Cursor &after_me) { - if (!size_) { // not much choice if list is empty - bottom_ = top_ = new Link( thing); + if (!size_) { // not much choice if list is empty + bottom_ = top_ = new Link( thing); if (!after_me.ok()) after_me = bottom(); - } else { // add at aprioprate place + } + else { // add at aprioprate place if (!after_me.ok()) after_me = bottom(); Link *p =after_me.pointer(); @@ -90,19 +93,22 @@ List::add (T const & thing, Cursor &after_me) bottom_ = p->next(); } - size_++; + size_++; } template void List::insert (T const & thing, Cursor &before_me) { - if (!size_) { + if (!size_) + { bottom_ = top_ = new Link( thing); if (!before_me.ok()) before_me = top(); - } else { + } + else + { if (!before_me.ok()) before_me = top(); @@ -113,7 +119,7 @@ List::insert (T const & thing, Cursor &before_me) top_ = p->previous(); } - size_++; + size_++; } @@ -121,8 +127,9 @@ template void List::concatenate (List const&s) { - Cursor b (bottom()); - for (Cursor c (s); c.ok(); c++) { + Cursor b (bottom()); + for (Cursor c (s); c.ok(); c++) + { b.add (c); b++; } diff --git a/flower/include/pcursor.tcc b/flower/include/pcursor.tcc index e8de3d5da1..c2b459a267 100644 --- a/flower/include/pcursor.tcc +++ b/flower/include/pcursor.tcc @@ -5,12 +5,12 @@ void PCursor::junk() { #if !defined (NDEBUG) && defined (PARANOID) - list().OK(); + list().OK(); #endif - delete ptr(); + delete ptr(); #if !defined (NDEBUG)&&defined (PARANOID) - thing() = 0; - list().OK(); + thing() = 0; + list().OK(); #endif } diff --git a/flower/include/plist.icc b/flower/include/plist.icc index f4a3713761..7fda7abb2c 100644 --- a/flower/include/plist.icc +++ b/flower/include/plist.icc @@ -11,7 +11,8 @@ template void PL_copy (Pointer_list &to, Pointer_list const&src) { - for (PCursor pc (src); pc.ok(); pc++) { + for (PCursor pc (src); pc.ok(); pc++) + { T *q = pc; T *p=new T(*q) ; to.bottom().add (p); diff --git a/flower/include/plist.tcc b/flower/include/plist.tcc index f7733d508d..07c1a0118f 100644 --- a/flower/include/plist.tcc +++ b/flower/include/plist.tcc @@ -9,8 +9,9 @@ template void Pointer_list::junk() { - PCursor c (*this); - while (c.ok()) { + PCursor c (*this); + while (c.ok()) + { delete c.remove_p(); } } @@ -19,9 +20,9 @@ template PCursor Link_list::find (T what) const { - PCursor i (*this); - for (; i.ok(); i++) + PCursor i (*this); + for (; i.ok(); i++) if (i.ptr() == what) break; - return i; + return i; } diff --git a/flower/include/pointer.tcc b/flower/include/pointer.tcc index c35f92c497..5eed1f4ef6 100644 --- a/flower/include/pointer.tcc +++ b/flower/include/pointer.tcc @@ -15,7 +15,7 @@ inline T * P::copy_p()const { - return t_p? new T(*t_p) : 0; + return t_p? new T(*t_p) : 0; } template @@ -23,7 +23,7 @@ inline void P::copy (T const *l_C) { - t_p = l_C ? new T(*l_C) : 0; + t_p = l_C ? new T(*l_C) : 0; } template @@ -31,15 +31,15 @@ inline void P::junk() { - delete t_p; - t_p =0; + delete t_p; + t_p =0; } template inline P::P(P const &s) { - t_p = s.copy_p(); + t_p = s.copy_p(); } template @@ -47,15 +47,15 @@ inline P & P::operator =(P const&s) { - junk(); - copy (s.t_p); - return *this; + junk(); + copy (s.t_p); + return *this; } template inline P::~P() { - junk(); + junk(); } template @@ -63,11 +63,11 @@ inline void P::set_p (T * np) { - if (np == t_p) + if (np == t_p) return; - delete t_p; - - t_p = np; + delete t_p; + + t_p = np; } @@ -76,11 +76,11 @@ inline void P::set_l (T const * l_C) { - if (t_p == l_C) + if (t_p == l_C) return; - - junk(); - copy (l_C); + + junk(); + copy (l_C); } diff --git a/flower/include/string-data.icc b/flower/include/string-data.icc index 2a285db24f..6a88eef8c9 100644 --- a/flower/include/string-data.icc +++ b/flower/include/string-data.icc @@ -20,53 +20,54 @@ const int INITIALMAX=8; INLINE void String_data::OKW() { - assert (references == 1); + assert (references == 1); } INLINE void String_data::OK() { - assert (maxlen >= length_i_); - assert (bool (data_byte_p_)); - assert (references >= 1); + assert (maxlen >= length_i_); + assert (bool (data_byte_p_)); + assert (references >= 1); } INLINE String_data::String_data() { - references=0; - maxlen = INITIALMAX; - data_byte_p_ = new Byte[maxlen + 1]; - data_byte_p_[0] = 0; - length_i_ = 0; + references=0; + maxlen = INITIALMAX; + data_byte_p_ = new Byte[maxlen + 1]; + data_byte_p_[0] = 0; + length_i_ = 0; } INLINE String_data::String_data (String_data const &src) { - references=0; - maxlen = length_i_ = src.length_i_; - data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. - memcpy (data_byte_p_, src.data_byte_p_, length_i_ + 1); + references=0; + maxlen = length_i_ = src.length_i_; + data_byte_p_ = new Byte[maxlen+1]; // should calc GNU 8byte overhead. + memcpy (data_byte_p_, src.data_byte_p_, length_i_ + 1); } INLINE String_data::~String_data() { - assert (references == 0); - delete[] data_byte_p_; + assert (references == 0); + delete[] data_byte_p_; } INLINE void String_data::setmax (int j) { - OKW(); - if (j > maxlen) { + OKW(); + if (j > maxlen) + { delete data_byte_p_; maxlen = j; data_byte_p_ = new Byte[maxlen + 1]; - + data_byte_p_[0] = 0; length_i_ = 0; } @@ -84,8 +85,9 @@ String_data::setmax (int j) INLINE void String_data::remax (int j) { - OKW(); - if (j > maxlen) { + OKW(); + if (j > maxlen) + { Byte *p = new Byte[j + 1]; memcpy (p, data_byte_p_, ( maxlen = 0 && j <= length_i_); - data_byte_p_[j] = 0; - length_i_ = j; + OKW(); + assert (j >= 0 && j <= length_i_); + data_byte_p_[j] = 0; + length_i_ = j; } INLINE bool String_data::is_binary_bo()const { // return !memchr (data_byte_p_, length_i_, 0); - return ( (int)strlen ((char const*)data_byte_p_) != length_i_ ); + return ( (int)strlen ((char const*)data_byte_p_) != length_i_ ); } INLINE Byte& String_data::operator [](int j) { - assert (j >= 0 && j <= length_i_); - return data_byte_p_[j] ; + assert (j >= 0 && j <= length_i_); + return data_byte_p_[j] ; } INLINE Byte String_data::operator [](int j) const { - assert (j >= 0 && j <= length_i_); - return data_byte_p_[j]; + assert (j >= 0 && j <= length_i_); + return data_byte_p_[j]; } diff --git a/flower/include/string-handle.icc b/flower/include/string-handle.icc index e398e0a4ed..0f97839d82 100644 --- a/flower/include/string-handle.icc +++ b/flower/include/string-handle.icc @@ -19,20 +19,21 @@ INLINE void String_handle::down() { - if (!(--data->references)) delete data; data = 0; + if (!(--data->references)) delete data; data = 0; } /// increase ref count INLINE void String_handle::up (String_data *d) { - data=d; data->references ++; + data=d; data->references ++; } INLINE void String_handle::copy() { - if (data->references !=1){ + if (data->references !=1) + { String_data *newdata = new String_data (*data); down(); up (newdata); @@ -42,68 +43,68 @@ String_handle::copy() INLINE String_handle::String_handle() { - up (new String_data); + up (new String_data); } INLINE String_handle::~String_handle() { - down(); + down(); } INLINE String_handle::String_handle (String_handle const & src) { - up (src.data); + up (src.data); } INLINE Byte* String_handle::byte_l() { - copy(); - return data->byte_l(); + copy(); + return data->byte_l(); } INLINE char* String_handle::ch_l() { - copy(); - return (char*)data->byte_l(); + copy(); + return (char*)data->byte_l(); } INLINE Byte const* String_handle::byte_C() const { - return data->byte_C(); + return data->byte_C(); } INLINE char const* String_handle::ch_C() const { - return (char const*)data->byte_C(); + return (char const*)data->byte_C(); } INLINE void String_handle::operator =(String_handle const &src) { - if (this == &src) + if (this == &src) return; - down(); - up (src.data); + down(); + up (src.data); } INLINE void String_handle::operator += (char const *s) { - copy(); - *data += s; + copy(); + *data += s; } INLINE Byte String_handle::operator[](int j) const { - return (*data)[j]; + return (*data)[j]; } // !NOT SAFE! @@ -111,46 +112,46 @@ String_handle::operator[](int j) const INLINE Byte & String_handle::operator[](int j) { - copy(); // hmm. Not efficient - return data->byte_l()[j]; + copy(); // hmm. Not efficient + return data->byte_l()[j]; } INLINE void String_handle::append (Byte const* byte_C, int length_i) { - copy(); - data->append (byte_C, length_i); + copy(); + data->append (byte_C, length_i); } INLINE void String_handle::set (Byte const* byte_C, int length_i) { - copy(); - data->set (byte_C, length_i); + copy(); + data->set (byte_C, length_i); } INLINE void String_handle::operator = (char const *p) { - copy(); - data->set (p); + copy(); + data->set (p); } INLINE void String_handle::trunc (int j) { - copy(); data->trunc (j); + copy(); data->trunc (j); } INLINE int String_handle::length_i() const { - return data->length_i_; + return data->length_i_; } INLINE bool String_handle::is_binary_bo() const { - return data->is_binary_bo(); + return data->is_binary_bo(); } #endif diff --git a/flower/interval.cc b/flower/interval.cc index a50b10a464..433ca727aa 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -15,5 +15,5 @@ template INTERVAL__INSTANTIATE(Real); Real Interval_t::infinity() { - return HUGE_VAL; + return HUGE_VAL; } diff --git a/flower/lgetopt.cc b/flower/lgetopt.cc index 7ab4eb122b..a73334fe00 100644 --- a/flower/lgetopt.cc +++ b/flower/lgetopt.cc @@ -11,69 +11,76 @@ long Getopt_long::argument_to_i() { - long l; - if (!optional_argument_ch_C_ + long l; + if (!optional_argument_ch_C_ || sscanf (optional_argument_ch_C_, "%ld", &l) != 1) report (E_ILLEGALARG); - - return l; + + return l; } const Long_option_init * Getopt_long::parselong() { - char const *optnm = arg_value_ch_a_a_[array_index_i_] + 2 ; - assert (*optnm); - - char const *endopt = strchr (optnm, '='); - int searchlen = (endopt) ? endopt - optnm : strlen (optnm); - - found_option_l_=0; - for (int i=0; i< table_len_i_; i++) { + char const *optnm = arg_value_ch_a_a_[array_index_i_] + 2 ; + assert (*optnm); + + char const *endopt = strchr (optnm, '='); + int searchlen = (endopt) ? endopt - optnm : strlen (optnm); + + found_option_l_=0; + for (int i=0; i< table_len_i_; i++) + { char const *ln = option_a_[i].longname; - if (ln && !strncmp (ln, optnm, searchlen)) { + if (ln && !strncmp (ln, optnm, searchlen)) + { found_option_l_ = option_a_+i; break; - } - } + } + } - if (!found_option_l_) { + if (!found_option_l_) + { report (E_UNKNOWNOPTION); return 0; } - array_index_i_++; - argument_index_i_ = 0; + array_index_i_++; + argument_index_i_ = 0; - - if (found_option_l_->take_arg) { + + if (found_option_l_->take_arg) + { if (endopt) optional_argument_ch_C_ = endopt +1; // a '=' - else { + else + { optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_]; array_index_i_++; - } + } if (!optional_argument_ch_C_) report (E_ARGEXPECT); - } else { + } + else + { optional_argument_ch_C_ = 0; if (endopt) report (E_NOARGEXPECT); } - - return found_option_l_; + + return found_option_l_; } void Long_option_init::printon (ostream &errorout)const { - if (shortname) + if (shortname) errorout <<"-" << shortname; - if (shortname && longname) + if (shortname && longname) errorout << ", "; - if (longname) + if (longname) errorout << "`--" << longname << "'"; } @@ -81,23 +88,24 @@ Long_option_init::printon (ostream &errorout)const void Getopt_long::report (Errorcod c) { - error_ = c; - if (!error_ostream_l_) + error_ = c; + if (!error_ostream_l_) return; - *error_ostream_l_ << arg_value_ch_a_a_[0] << ": "; - switch (c) { - case E_ARGEXPECT: + *error_ostream_l_ << arg_value_ch_a_a_[0] << ": "; + switch (c) + { + case E_ARGEXPECT: *error_ostream_l_<< "option "; found_option_l_->printon (*error_ostream_l_); *error_ostream_l_ << "requires an argument"<longname << "' does not allow an argument"<printon (*error_ostream_l_); *error_ostream_l_ << '\n'; - default: + default: assert (false); } - exit (2); + exit (2); } - + const Long_option_init * Getopt_long::parseshort() { - char c=arg_value_ch_a_a_[array_index_i_][argument_index_i_]; - found_option_l_=0; - assert (c); - - for (int i=0; i < table_len_i_; i++) - if (option_a_[i].shortname == c) { + char c=arg_value_ch_a_a_[array_index_i_][argument_index_i_]; + found_option_l_=0; + assert (c); + + for (int i=0; i < table_len_i_; i++) + if (option_a_[i].shortname == c) + { found_option_l_ = option_a_+i; break; - } + } - if (!found_option_l_){ + if (!found_option_l_) + { report (E_UNKNOWNOPTION); return 0; } - argument_index_i_++; - if (!found_option_l_->take_arg){ + argument_index_i_++; + if (!found_option_l_->take_arg) + { optional_argument_ch_C_ = 0; return found_option_l_; } - optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_] + argument_index_i_; + optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_] + argument_index_i_; - array_index_i_ ++; - argument_index_i_ = 0; - - if (!optional_argument_ch_C_[0]) { + array_index_i_ ++; + argument_index_i_ = 0; + + if (!optional_argument_ch_C_[0]) + { optional_argument_ch_C_ = arg_value_ch_a_a_[array_index_i_]; array_index_i_ ++; } - if (!optional_argument_ch_C_) { + if (!optional_argument_ch_C_) + { report (E_ARGEXPECT); } - - return found_option_l_; + + return found_option_l_; } const Long_option_init * Getopt_long::operator()() { - if (!ok()) + if (!ok()) return 0; - - next(); - - if (argument_index_i_) + + next(); + + if (argument_index_i_) return parseshort(); - - const char * argument_C = arg_value_ch_a_a_[array_index_i_]; - - if (argument_C[0] != '-') + + const char * argument_C = arg_value_ch_a_a_[array_index_i_]; + + if (argument_C[0] != '-') return 0; - if (argument_C[1] == '-') {// what to do with "command -- bla" + if (argument_C[1] == '-') {// what to do with "command -- bla" if ( argument_C[2]) return parselong(); else return 0; - } else { - if (argument_C[ 1 ]) { + } + else + { + if (argument_C[ 1 ]) + { argument_index_i_ = 1; return parseshort(); - } else { + } + else + { return 0; - } + } } } Getopt_long::Getopt_long (int c, char **v, Long_option_init *lo) { - option_a_ = lo; - error_ostream_l_ = &cerr; - arg_value_ch_a_a_ = v; - argument_count_i_ = c; - array_index_i_ = 1; - argument_index_i_ = 0; - - // reached end of option table? - table_len_i_ =0; - for (int i = 0; option_a_[i].longname ||option_a_[i].shortname; i++) + option_a_ = lo; + error_ostream_l_ = &cerr; + arg_value_ch_a_a_ = v; + argument_count_i_ = c; + array_index_i_ = 1; + argument_index_i_ = 0; + + // reached end of option table? + table_len_i_ =0; + for (int i = 0; option_a_[i].longname ||option_a_[i].shortname; i++) table_len_i_ ++; } bool Getopt_long::ok()const { - return array_index_i_ < argument_count_i_; + return array_index_i_ < argument_count_i_; } void Getopt_long::next() { - error_ = E_NOERROR; - while (array_index_i_ < argument_count_i_ - && !arg_value_ch_a_a_[array_index_i_][argument_index_i_]) { + error_ = E_NOERROR; + while (array_index_i_ < argument_count_i_ + && !arg_value_ch_a_a_[array_index_i_][argument_index_i_]) + { array_index_i_++; argument_index_i_ = 0; } @@ -220,19 +239,20 @@ Getopt_long::next() char const * Getopt_long::current_arg() { - if (array_index_i_ >= argument_count_i_) + if (array_index_i_ >= argument_count_i_) return 0; - char const * a = arg_value_ch_a_a_[array_index_i_]; - return a + argument_index_i_; + char const * a = arg_value_ch_a_a_[array_index_i_]; + return a + argument_index_i_; } char const * Getopt_long::get_next_arg() { - char const * a = current_arg(); - if (a) { + char const * a = current_arg(); + if (a) + { array_index_i_ ++; argument_index_i_= 0; } - return a; + return a; } diff --git a/flower/libc-extension.cc b/flower/libc-extension.cc index c786a51efe..b380b1fd2d 100644 --- a/flower/libc-extension.cc +++ b/flower/libc-extension.cc @@ -16,7 +16,8 @@ char* strnlwr (char* start_l ,int n) { char * p = start_l + n; - while ( --p >= start_l) { + while (--p >= start_l) + { *p = tolower (*p); /* a macro on some compilers */ } return start_l; @@ -26,7 +27,8 @@ char* strnupr (char* start_l, int n) { char * p = start_l + n; - while ( --p >= start_l) { + while (--p >= start_l) + { *p = toupper (*p); /* a macro on some compilers */ } return start_l; @@ -40,17 +42,19 @@ strnupr (char* start_l, int n) char * memmem (Byte const * haystack, int haystack_len, - Byte const *needle,int needle_len) + Byte const *needle,int needle_len) { Byte const * end_haystack = haystack + haystack_len - needle_len; Byte const * end_needle = needle + needle_len ; /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation - is the spice of life */ - while (haystack < end_haystack) { + is the spice of life */ + while (haystack < end_haystack) + { Byte const *subneedle_l = needle; Byte const *subhaystack_l = haystack; - while (subneedle_l < end_needle) { + while (subneedle_l < end_needle) + { if (*subneedle_l++ != *subhaystack_l++) goto next; // yeah. I should be prosecuted. } @@ -68,7 +72,8 @@ Byte * memrchr (Byte const * p, int n, char c) { const Byte * q = p+n; - while (q > p) { + while (q > p) + { if (*--q == c) return (Byte*)q; } @@ -88,19 +93,20 @@ my_swap (T &t1, T &t2, T &tmp) Byte* strrev (Byte* byte_l, int length_i) { - Byte tmp_byte; + Byte tmp_byte; - Byte* left_l = byte_l; - Byte* right_l = byte_l + length_i; + Byte* left_l = byte_l; + Byte* right_l = byte_l + length_i; - while ( right_l > left_l) { - my_swap (*right_l-- , *left_l++ , tmp_byte); - } - return byte_l; + while (right_l > left_l) + { + my_swap (*right_l-- , *left_l++ , tmp_byte); + } + return byte_l; } #if ! HAVE_SNPRINTF -int snprintf ( char *str, size_t, +int snprintf (char *str, size_t, char const *format, ...) { va_list ap; diff --git a/flower/matrix-debug.cc b/flower/matrix-debug.cc index 7126c1378e..81aa05f39c 100644 --- a/flower/matrix-debug.cc +++ b/flower/matrix-debug.cc @@ -14,19 +14,21 @@ Matrix::operator String() const { - String s; + String s; #ifndef NPRINT - Matrix_storage const * stor_c_l = dat; - s=String ("matrix { (") + dat->name() + ")\n"; - for (int i=0; i< rows(); i++){ - for (int j = 0; j < cols(); j++) { + Matrix_storage const * stor_c_l = dat; + s=String ("matrix { (") + dat->name() + ")\n"; + for (int i=0; i< rows(); i++) + { + for (int j = 0; j < cols(); j++) + { s+= String (stor_c_l->elem (i,j), "%6f "); - } + } s+="\n"; } - s+="}\n"; + s+="}\n"; #endif - return s; + return s; } @@ -34,21 +36,22 @@ void Matrix::print() const { #ifndef NPRINT - fdebug << *this; + fdebug << *this; #endif } Vector::operator String() const { - String s; + String s; #ifndef NPRINT - s="vector ["; - for (int i=0; i < dim(); i++) { + s="vector ["; + for (int i=0; i < dim(); i++) + { s += String (dat[i], "%6f") + String (' '); } - s+="]"; + s+="]"; #endif - return s; + return s; } @@ -56,6 +59,6 @@ void Vector::print() const { #ifndef NDEBUG - fdebug << *this<<'\n'; + fdebug << *this<<'\n'; #endif } diff --git a/flower/matrix-storage.cc b/flower/matrix-storage.cc index 5ebc0e9072..698f673b25 100644 --- a/flower/matrix-storage.cc +++ b/flower/matrix-storage.cc @@ -12,17 +12,20 @@ void Matrix_storage::set_addition_result (Matrix_storage *&dat, Matrix_storage *right) { - if (dat && dat->name() == Diagonal_storage::static_name () - && right->name() == Diagonal_storage::static_name ()) { + if (dat && dat->name() == Diagonal_storage::static_name () + && right->name() == Diagonal_storage::static_name ()) + { Diagonal_storage *L = (Diagonal_storage*)dat; Diagonal_storage* R = (Diagonal_storage*) right; - if ( R->band_size_i() > L->band_size_i ()) { + if ( R->band_size_i() > L->band_size_i ()) + { L->set_band_size (R->band_size_i()); - } + } return ; } - if (!dat || !dat->is_type_b (Full_storage::static_name())) { + if (!dat || !dat->is_type_b (Full_storage::static_name())) + { Matrix_storage *new_stor = (dat)? new Full_storage (dat) : new Full_storage (right->rows(), right->cols ()); @@ -34,11 +37,11 @@ Matrix_storage::set_addition_result (Matrix_storage *&dat, Matrix_storage *right Matrix_storage* Matrix_storage::get_product_result (Matrix_storage*left, Matrix_storage*right) { - Matrix_storage* dest =0; - set_product_result (dest, left,right); - return dest; + Matrix_storage* dest =0; + set_product_result (dest, left,right); + return dest; } - + /* hairy @@ -47,25 +50,31 @@ void Matrix_storage::set_product_result (Matrix_storage*&dest, Matrix_storage*left, Matrix_storage*right) { - if ( left->name() == Diagonal_storage::static_name () - && right->name() == Diagonal_storage::static_name ()) { + if ( left->name() == Diagonal_storage::static_name () + && right->name() == Diagonal_storage::static_name ()) + { Diagonal_storage *L = (Diagonal_storage*)left; Diagonal_storage* R = (Diagonal_storage*) right; - if (L->band_size_i() + R->band_size_i () < L->dim ()/2) { - if (dest ->name() != Diagonal_storage::static_name ()){ + if (L->band_size_i() + R->band_size_i () < L->dim ()/2) + { + if (dest ->name() != Diagonal_storage::static_name ()) + { delete dest; dest = new Diagonal_storage; - } + } dest->set_size (L->dim()); return; - } + } } - if ( dest && dest->name() == Full_storage::static_name ()) { + if ( dest && dest->name() == Full_storage::static_name ()) + { dest->set_size (left->rows(), right->cols ()); - } else { + } + else + { delete dest; dest = new Full_storage (left->rows(), right->cols ()); } @@ -76,7 +85,7 @@ IMPLEMENT_IS_TYPE_B(Matrix_storage); Matrix_storage * Matrix_storage::get_full (int n, int m) { - return new Full_storage (n,m); + return new Full_storage (n,m); } @@ -85,38 +94,38 @@ Matrix_storage::get_full (int n, int m) Matrix_storage::try_right_multiply (Matrix_storage *, const Matrix_storage *)const { - return false; + return false; } Array Matrix_storage::row (int n) const { - Array r; - for (int j = 0; j < cols(); j++) + Array r; + for (int j = 0; j < cols(); j++) r.push (elem (n,j)); - return r; + return r; } Array Matrix_storage::column (int n) const { - Array r; - for (int i = 0; i < rows(); i++) + Array r; + for (int i = 0; i < rows(); i++) r.push (elem (i,n)); - return r; + return r; } void Matrix_storage::set_size (int rows, int cols) { - - resize (rows,cols); + + resize (rows,cols); } void Matrix_storage::set_size (int rows) { - + resize (rows); } @@ -124,16 +133,16 @@ Matrix_storage::set_size (int rows) void Matrix_storage::set_band (Matrix_storage *&mat, int b) { - Matrix_storage* ns = new Diagonal_storage (mat, b); - delete mat; - mat=ns; + Matrix_storage* ns = new Diagonal_storage (mat, b); + delete mat; + mat=ns; } void Matrix_storage::set_full (Matrix_storage *&mat) { - Matrix_storage* ns = new Full_storage (mat); - delete mat; - mat=ns; + Matrix_storage* ns = new Full_storage (mat); + delete mat; + mat=ns; } diff --git a/flower/matrix.cc b/flower/matrix.cc index fdb6085f7c..3f9b28f835 100644 --- a/flower/matrix.cc +++ b/flower/matrix.cc @@ -13,13 +13,14 @@ bool Matrix::band_b()const { - return dat->is_type_b (Diagonal_storage::static_name()); + return dat->is_type_b (Diagonal_storage::static_name()); } void Matrix::set_full() const { - if ( dat->name() != Full_storage::static_name ()) { + if ( dat->name() != Full_storage::static_name ()) + { Matrix_storage::set_full (((Matrix*)this)->dat); } } @@ -27,64 +28,64 @@ Matrix::set_full() const void Matrix::try_set_band()const { - if (band_b()) + if (band_b()) return; - - int b = band_i(); - if ( b > dim()/2) + + int b = band_i(); + if ( b > dim()/2) return; - // it only looks constant - Matrix*self = (Matrix*)this; - Matrix_storage::set_band (self->dat,b); + // it only looks constant + Matrix*self = (Matrix*)this; + Matrix_storage::set_band (self->dat,b); } Real Matrix::norm() const { - Real r =0.0; - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Real r =0.0; + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) r += sqr (dat->elem (i,j)); - return sqrt (r); + return sqrt (r); } void Matrix::fill (Real r) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=r; } void Matrix::set_diag (Real r) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=(i==j) ? r: 0.0; } void Matrix::set_diag (Vector d) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=(i==j) ? d (i): 0.0; } void Matrix::operator+=(Matrix const &m) { - Matrix_storage::set_addition_result (dat, m.dat); - assert (m.cols() == cols ()); - assert (m.rows() == rows ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Matrix_storage::set_addition_result (dat, m.dat); + assert (m.cols() == cols ()); + assert (m.rows() == rows ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) += m (i,j); } void Matrix::operator-=(Matrix const &m) { - Matrix_storage::set_addition_result (dat, m.dat); - assert (m.cols() == cols ()); - assert (m.rows() == rows ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Matrix_storage::set_addition_result (dat, m.dat); + assert (m.cols() == cols ()); + assert (m.rows() == rows ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) -= m (i,j); } @@ -92,28 +93,30 @@ Matrix::operator-=(Matrix const &m) void Matrix::operator*=(Real a) { - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j) *= a; } void Matrix::operator=(Matrix const &m) { - if (&m == this) + if (&m == this) return ; - delete dat; - dat = m.dat->clone(); + delete dat; + dat = m.dat->clone(); } int Matrix::band_i()const { - if ( band_b()) { + if ( band_b()) + { Diagonal_storage const * diag = (Diagonal_storage*) dat; return diag->band_size_i(); } - int starty = dim(); - while (starty >= 0) { + int starty = dim(); + while (starty >= 0) + { for ( int i = starty, j = 0; i < dim(); i++, j++) if (dat->elem (i,j)) goto gotcha; @@ -123,38 +126,38 @@ Matrix::band_i()const starty --; } gotcha: - return starty; + return starty; } - + Matrix::Matrix (Matrix const &m) { - m.OK(); - - dat = m.dat->clone(); + m.OK(); + + dat = m.dat->clone(); } Matrix::Matrix (int n, int m) { - dat = Matrix_storage::get_full (n,m); - fill (0); + dat = Matrix_storage::get_full (n,m); + fill (0); } Matrix::Matrix (Matrix_storage*stor_p) { - dat = stor_p; + dat = stor_p; } Matrix::Matrix (int n) { - dat = Matrix_storage::get_full (n,n); - fill (0); + dat = Matrix_storage::get_full (n,n); + fill (0); } Matrix::Matrix (Vector v, Vector w) { - dat = Matrix_storage::get_full (v.dim(), w.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + dat = Matrix_storage::get_full (v.dim(), w.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dat->elem (i,j)=v (i)*w (j); } @@ -162,52 +165,52 @@ Matrix::Matrix (Vector v, Vector w) Vector Matrix::row (int k) const { - int n=cols(); + int n=cols(); - - Vector v (n); - for (int i=0; i < n; i++) + + Vector v (n); + for (int i=0; i < n; i++) v (i)=dat->elem (k,i); - return v; + return v; } Vector Matrix::col (int k) const { - int n=rows(); - Vector v (n); - for (int i=0; i < n; i++) + int n=rows(); + Vector v (n); + for (int i=0; i < n; i++) v (i)=dat->elem (i,k); - return v; + return v; } Vector Matrix::left_multiply (Vector const & v) const { - Vector dest (v.dim()); - assert (dat->cols()==v.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Vector dest (v.dim()); + assert (dat->cols()==v.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dest (i)+= dat->elem (j,i)*v (j); - return dest; + return dest; } Vector Matrix::operator *(Vector const & v) const { - Vector dest (rows()); - assert (dat->cols()==v.dim ()); - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + Vector dest (rows()); + assert (dat->cols()==v.dim ()); + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) dest (i)+= dat->elem (i,j)*v (j); - return dest; + return dest; } Matrix operator /(Matrix const& m1,Real a) { - Matrix m (m1); - m /= a; - return m; + Matrix m (m1); + m /= a; + return m; } /* @@ -217,7 +220,8 @@ void Matrix::transpose() // delegate to storage? { #if 1 - for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) { + for (int i=0, j=0; dat->mult_ok (i,j); dat->mult_next (i,j)) + { if (i >= j) continue; Real r=dat->elem (i,j); @@ -230,40 +234,41 @@ Matrix::transpose() // delegate to storage? Matrix Matrix::operator-() const { - OK(); - Matrix m (*this); - m*=-1.0; - return m; + OK(); + Matrix m (*this); + m*=-1.0; + return m; } Matrix Matrix::transposed() const { - Matrix m (*this); - m.transpose(); - return m; + Matrix m (*this); + m.transpose(); + return m; } Matrix operator *(Matrix const &m1, Matrix const &m2) { - Matrix result (Matrix_storage::get_product_result (m1.dat, m2.dat)); + Matrix result (Matrix_storage::get_product_result (m1.dat, m2.dat)); - result.set_product (m1,m2); - return result; + result.set_product (m1,m2); + return result; } void Matrix::set_product (Matrix const &m1, Matrix const &m2) { - assert (m1.cols()==m2.rows ()); - assert (cols()==m2.cols () && rows ()==m1.rows ()); - - if (m1.dat->try_right_multiply (dat, m2.dat)) + assert (m1.cols()==m2.rows ()); + assert (cols()==m2.cols () && rows ()==m1.rows ()); + + if (m1.dat->try_right_multiply (dat, m2.dat)) return; - - for (int i=0, j=0; dat->mult_ok (i,j); - dat->mult_next (i,j)) { + + for (int i=0, j=0; dat->mult_ok (i,j); + dat->mult_next (i,j)) + { Real r=0.0; for (int k = 0; k < m1.cols(); k++) r += m1(i,k)*m2(k,j); @@ -274,10 +279,10 @@ Matrix::set_product (Matrix const &m1, Matrix const &m2) void Matrix::insert_row (Vector v, int k) { - int c = cols(); - assert (v.dim()==cols ()); - dat->insert_row (k); - for (int j=0; j < c; j++) + int c = cols(); + assert (v.dim()==cols ()); + dat->insert_row (k); + for (int j=0; j < c; j++) dat->elem (k,j)=v (j); } @@ -285,9 +290,10 @@ Matrix::insert_row (Vector v, int k) void Matrix::swap_columns (int c1, int c2) { - assert (c1>=0&& c1 < cols()&&c2 < cols () && c2 >=0); - int r = rows(); - for (int i=0; i< r; i++) { + assert (c1>=0&& c1 < cols()&&c2 < cols () && c2 >=0); + int r = rows(); + for (int i=0; i< r; i++) + { Real r=dat->elem (i,c1); dat->elem (i,c1) = dat->elem (i,c2); dat->elem (i,c2)=r; @@ -297,9 +303,10 @@ Matrix::swap_columns (int c1, int c2) void Matrix::swap_rows (int c1, int c2) { - assert (c1>=0&& c1 < rows()&&c2 < rows () && c2 >=0); - int c = cols(); - for (int i=0; i< c; i++) { + assert (c1>=0&& c1 < rows()&&c2 < rows () && c2 >=0); + int c = cols(); + for (int i=0; i< c; i++) + { Real r=dat->elem (c1,i); dat->elem (c1,i) = dat->elem (c2,i); dat->elem (c2,i)=r; @@ -310,8 +317,8 @@ Matrix::swap_rows (int c1, int c2) int Matrix::dim() const { - assert (cols() == rows ()); - return rows(); + assert (cols() == rows ()); + return rows(); } diff --git a/flower/path.cc b/flower/path.cc index be5f56a7f0..e880b200ae 100644 --- a/flower/path.cc +++ b/flower/path.cc @@ -17,36 +17,36 @@ void split_path (String path, String &drive, String &dirs, String &filebase, String &extension) { - // peel off components, one by one. - int di = path.index_i (':'); - if (di >= 0) + // peel off components, one by one. + int di = path.index_i (':'); + if (di >= 0) { drive = path.left_str (di + 1); path = path.right_str (path.len() - di -1); - } - else + } + else drive = ""; - - di = path.index_last_i (PATHSEP); - if (di >=0) + + di = path.index_last_i (PATHSEP); + if (di >=0) { dirs = path.left_str (di + 1); path = path.right_str (path.len()-di -1); - } - else + } + else dirs = ""; - - di = path.index_last_i ('.'); - if (di >= 0) + + di = path.index_last_i ('.'); + if (di >= 0) { filebase = path.left_str (di); extension =path.right_str (path.len()-di); - } - else + } + else { extension = ""; filebase = path; - } + } } /** find a file. @@ -57,10 +57,11 @@ String File_path::find (String nm)const { - fdebug << "looking for " << nm << ": "; - if ( !nm.length_i() || ( nm == "-") ) + fdebug << "looking for " << nm << ": "; + if ( !nm.length_i() || ( nm == "-") ) return nm; - for (int i=0; i < size(); i++) { + for (int i=0; i < size(); i++) + { String path = elem(i); if ( path.length_i() ) @@ -70,12 +71,13 @@ File_path::find (String nm)const fdebug << path << "? "; FILE *f = fopen (path.ch_C(), "r"); // ugh! - if (f) { + if (f) + { fdebug << "found\n"; fclose (f); return path; - } + } } - fdebug << "\n"; - return ""; + fdebug << "\n"; + return ""; } diff --git a/flower/rational.cc b/flower/rational.cc index 5b36be916c..11963238b5 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -12,7 +12,7 @@ void print_rat (Rational const &m) { - cout << String (m) << flush; + cout << String (m) << flush; } - + diff --git a/flower/scalar.cc b/flower/scalar.cc index 1a5e54ec27..db0b9ddb8c 100644 --- a/flower/scalar.cc +++ b/flower/scalar.cc @@ -3,55 +3,56 @@ #include "scalar.hh" Scalar::Scalar (Rational r) - :String (r) + :String (r) { } Scalar::operator Rational() { - int p = index_i ('/'); - if (p == -1) + int p = index_i ('/'); + if (p == -1) return int (*this); - - String s2 = right_str (len()-p-1); - String s1 = left_str (p); + + String s2 = right_str (len()-p-1); + String s1 = left_str (p); - return Rational (s1.value_i(), s2.value_i ()); + return Rational (s1.value_i(), s2.value_i ()); } bool Scalar::isnum() { - int conv = false; - if (len()) { + int conv = false; + if (len()) + { long l =0; conv = sscanf (strh_.ch_C(), "%ld", &l); } - return len() && conv; + return len() && conv; } Scalar::operator Real() { - assert (isnum()); - return value_f(); + assert (isnum()); + return value_f(); } Scalar::operator int() { - assert (isnum()); - return value_i(); + assert (isnum()); + return value_i(); } Scalar::operator bool() const { - if (!len()) + if (!len()) return false; - if (*this == "0") + if (*this == "0") return false; - String u (*this); - if ( u.upper_str() == "FALSE") + String u (*this); + if ( u.upper_str() == "FALSE") return false; - return true; + return true; } diff --git a/flower/string-convert.cc b/flower/string-convert.cc index 2f5ab5bfa3..c105169cee 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -27,119 +27,122 @@ static const int STRING_BUFFER_LEN=1024; String String_convert::bin2hex_str (String bin_str) { - String str; - Byte const* byte_C = bin_str.byte_C(); - for ( int i = 0; i < bin_str.length_i(); i++) { + String str; + Byte const* byte_C = bin_str.byte_C(); + for ( int i = 0; i < bin_str.length_i(); i++) + { str += (char)nibble2hex_byte (*byte_C >> 4); str += (char)nibble2hex_byte (*byte_C++); } - return str; + return str; } int String_convert::bin2_i (String bin_str) { - assert (bin_str.length_i() <= 4); + assert (bin_str.length_i() <= 4); - int result_i = 0; - for ( int i = 0; i < bin_str.length_i(); i++) { + int result_i = 0; + for ( int i = 0; i < bin_str.length_i(); i++) + { result_i <<= 8; result_i += (Byte)bin_str[ i ]; } - return result_i; + return result_i; } // breendet imp from String int String_convert::dec2_i (String dec_str) { - if ( !dec_str.length_i()) - return 0; + if ( !dec_str.length_i()) + return 0; - long l = 0; - int conv = sscanf (dec_str.ch_C(), "%ld", &l); - assert (conv); + long l = 0; + int conv = sscanf (dec_str.ch_C(), "%ld", &l); + assert (conv); - return (int)l; + return (int)l; } String String_convert::i64_str (I64 i64, char const* fmt) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, (fmt ? fmt : "%Ld"), i64); // assume radix 10 - return String (buffer); + return String (buffer); } // breendet imp from String double String_convert::dec2_f (String dec_str) { - if ( !dec_str.length_i()) - return 0; - double d = 0; - int conv = sscanf (dec_str.ch_C(), "%lf", &d); - assert (conv); - return d; + if ( !dec_str.length_i()) + return 0; + double d = 0; + int conv = sscanf (dec_str.ch_C(), "%lf", &d); + assert (conv); + return d; } int String_convert::hex2bin_i (String hex_str, String& bin_str_r) { - if ( hex_str.length_i() % 2) - hex_str = "0" + hex_str; - - bin_str_r = ""; - Byte const* byte_C= hex_str.byte_C(); - int i = 0; - while ( i < hex_str.length_i()) { - int high_i = hex2nibble_i (*byte_C++); - int low_i = hex2nibble_i (*byte_C++); - if ( high_i < 0 || low_i < 0) - return 1; // illegal char - bin_str_r += String ((char)( high_i << 4 | low_i), 1 ); - i += 2; + if ( hex_str.length_i() % 2) + hex_str = "0" + hex_str; + + bin_str_r = ""; + Byte const* byte_C= hex_str.byte_C(); + int i = 0; + while ( i < hex_str.length_i()) + { + int high_i = hex2nibble_i (*byte_C++); + int low_i = hex2nibble_i (*byte_C++); + if ( high_i < 0 || low_i < 0) + return 1; // illegal char + bin_str_r += String ((char)( high_i << 4 | low_i), 1 ); + i += 2; } - return 0; + return 0; } String String_convert::hex2bin_str (String hex_str) { - String str; + String str; // silly, asserts should alway be "on"! // assert (!hex2bin_i (hex_str, str) ); - int error_i = hex2bin_i (hex_str, str); - assert (!error_i); - return str; + int error_i = hex2bin_i (hex_str, str); + assert (!error_i); + return str; } int String_convert::hex2nibble_i (Byte byte) { - if ( byte >= '0' && byte <= '9') - return byte - '0'; - if ( byte >= 'A' && byte <= 'F') - return byte - 'A' + 10; - if ( byte >= 'a' && byte <= 'f') - return byte - 'a' + 10; - return -1; + if ( byte >= '0' && byte <= '9') + return byte - '0'; + if ( byte >= 'A' && byte <= 'F') + return byte - 'A' + 10; + if ( byte >= 'a' && byte <= 'f') + return byte - 'a' + 10; + return -1; } // stupido. Should use int_str() String String_convert::i2dec_str (int i, int length_i, char ch) { - char fill_ch = ch; - if ( fill_ch) - fill_ch = '0'; - - // ugh - String dec_str (i); - - // ugh - return String (fill_ch, length_i - dec_str.length_i()) + dec_str; + char fill_ch = ch; + if ( fill_ch) + fill_ch = '0'; + + // ugh + String dec_str (i); + + // ugh + return String (fill_ch, length_i - dec_str.length_i()) + dec_str; } @@ -147,38 +150,39 @@ String_convert::i2dec_str (int i, int length_i, char ch) String String_convert::u2hex_str (unsigned u, int length_i, char fill_ch) { - String str; - if ( !u) + String str; + if ( !u) str = "0"; #if 1 // both go... - while ( u) { + while ( u) + { str = String ((char)( ( u % 16)["0123456789abcdef"] ) ) + str; u /= 16; } #else - str += int_str (u, "%x"); // hmm. %lx vs. %x -> portability? + str += int_str (u, "%x"); // hmm. %lx vs. %x -> portability? #endif - str = String (fill_ch, length_i - str.length_i()) + str; - while ( ( str.length_i() > length_i) && ( str[ 0 ] == 'f' ) ) - str = str.mid_str (2, INT_MAX); + str = String (fill_ch, length_i - str.length_i()) + str; + while ( ( str.length_i() > length_i) && ( str[ 0 ] == 'f' ) ) + str = str.mid_str (2, INT_MAX); - return str; + return str; } String String_convert::i2hex_str (int i, int length_i, char fill_ch) { - return u2hex_str ((unsigned)i, length_i, fill_ch); + return u2hex_str ((unsigned)i, length_i, fill_ch); } Byte String_convert::nibble2hex_byte (Byte byte) { - if ( ( byte & 0x0f) <= 9 ) + if ( ( byte & 0x0f) <= 9 ) return ( byte & 0x0f) + '0'; - else + else return ( byte & 0x0f) - 10 + 'a'; } /** @@ -190,10 +194,10 @@ String_convert::nibble2hex_byte (Byte byte) String String_convert::int_str (int i, char const* fmt) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, (fmt ? fmt : "%d"), i); // assume radix 10 - return String (buffer); + return String (buffer); } /** @@ -204,49 +208,50 @@ String_convert::int_str (int i, char const* fmt) String String_convert::double_str (double f, char const* fmt) { - char buf[STRING_BUFFER_LEN]; + char buf[STRING_BUFFER_LEN]; - snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); - return String (buf); + snprintf (buf, STRING_BUFFER_LEN, fmt ? fmt : "%f", f); + return String (buf); } /** Make a string from a single character. @param - #n# is a repetition count, default value is 1 + #n# is a repetition count, default value is 1 */ String String_convert::char_str (char c, int n) { - n = n >= 0 ? n : 0; - char* ch_p = new char[ n ]; - memset (ch_p, c, n); - String s ((Byte*)ch_p, n); - delete ch_p; - return s; + n = n >= 0 ? n : 0; + char* ch_p = new char[ n ]; + memset (ch_p, c, n); + String s ((Byte*)ch_p, n); + delete ch_p; + return s; } String String_convert::rational_str (Rational r) { - char * n = Itoa (r.numerator()); // LEAK???? - - String s = n; - if (r.denominator() != 1) { + char * n = Itoa (r.numerator()); // LEAK???? + + String s = n; + if (r.denominator() != 1) + { char * d = Itoa (r.denominator()); s += String ('/') + String (d); //delete d; } /* delete n; - */ - return s; + */ + return s; } String String_convert::pointer_str (void const *l) { - char buffer[STRING_BUFFER_LEN]; - snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 - return String (buffer); + char buffer[STRING_BUFFER_LEN]; + snprintf (buffer, STRING_BUFFER_LEN, "%p", l); // assume radix 10 + return String (buffer); } diff --git a/flower/string.cc b/flower/string.cc index 1bd236114c..6651475b37 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -25,17 +25,17 @@ void* mymemmove (void* dest, void const* src, size_t n); Byte* String::copy_byte_p() const { - Byte const* src = strh_.byte_C(); - Byte* dest = new Byte[strh_.length_i() + 1]; - memcpy (dest, src, strh_.length_i() + 1); - return dest; + Byte const* src = strh_.byte_C(); + Byte* dest = new Byte[strh_.length_i() + 1]; + memcpy (dest, src, strh_.length_i() + 1); + return dest; } void String::print_on (ostream& os) const { - if (!strh_.is_binary_bo()) - os << ch_C(); - else + if (!strh_.is_binary_bo()) + os << ch_C(); + else for ( int i = 0; i < length_i(); i++) os << (Byte)(*this)[ i ]; } @@ -46,24 +46,24 @@ String::print_on (ostream& os) const String& String::operator = (String const&source) { - strh_ = source.strh_; - return *this; + strh_ = source.strh_; + return *this; } String::String (Rational r) { - *this = String_convert::rational_str (r); + *this = String_convert::rational_str (r); } String::String (double f, char const* fmt) { - *this= String_convert::double_str (f,fmt); + *this= String_convert::double_str (f,fmt); } String::String (char c, int n) { - *this = String_convert::char_str (c,n); + *this = String_convert::char_str (c,n); } /** @@ -72,71 +72,71 @@ String::String (char c, int n) */ String::String (int i, char const * format) { - *this = String_convert::int_str (i,format); + *this = String_convert::int_str (i,format); } String::String (bool b) { - *this = (char const*) (b ? "true" : "false"); + *this = (char const*) (b ? "true" : "false"); } String::String (char const* source) { - assert (source); - strh_ = source; + assert (source); + strh_ = source; } String::String (Byte const* byte_l, int length_i) { - strh_.set (byte_l, length_i); + strh_.set (byte_l, length_i); } void String::append (String s) { - strh_.append (s.byte_C(), s.length_i()); + strh_.append (s.byte_C(), s.length_i()); } void String::operator +=(String s) { - append (s); + append (s); } void String::prepend (String s) { - s += *this; - *this = s; + s += *this; + *this = s; } int String::length_i() const { - return strh_.length_i(); + return strh_.length_i(); } Byte const* String::byte_C() const { - return strh_.byte_C(); + return strh_.byte_C(); } char const* String::ch_C() const { - return strh_.ch_C(); + return strh_.ch_C(); } Byte* String::byte_l() { - return strh_.byte_l(); + return strh_.byte_l(); } char* String::ch_l() { - return strh_.ch_l(); + return strh_.ch_l(); } /** @@ -145,50 +145,51 @@ String::ch_l() int String::compare_i (String const& s1, String const& s2) { - Byte const* p1 = s1.byte_C(); - Byte const* p2 = s2.byte_C(); - if ( p1 == p2) + Byte const* p1 = s1.byte_C(); + Byte const* p2 = s2.byte_C(); + if ( p1 == p2) return 0; - int i1 = s1.length_i(); - int i2 = s2.length_i(); + int i1 = s1.length_i(); + int i2 = s2.length_i(); - int result= memcmp (p1, p2, i1 = 0) { + + int index_i = 0; + while (next_i >= 0) + { index_i += next_i; next_i = right_str (length_i() - index_i - length).index_i (string ); } - return index_i; + return index_i; } /** find a character. @@ -202,11 +203,11 @@ String::index_last_i (char const* string) const // UGK! int String::index_i (char c) const { - char const* me = strh_.ch_C(); - char const* p = (char const *) memchr (me,c, length_i()); - if ( p) + char const* me = strh_.ch_C(); + char const* p = (char const *) memchr (me,c, length_i()); + if ( p) return p - me; - return -1; + return -1; } /** @@ -218,13 +219,13 @@ String::index_i (char c) const int String::index_i (String searchfor) const { - char const* me = strh_.ch_C(); - char const* p = (char const *) memmem ( + char const* me = strh_.ch_C(); + char const* p = (char const *) memmem ( me, length_i(), searchfor.ch_C(), searchfor.length_i ()); - - if ( p) + + if ( p) return p - me; - else + else return -1; } @@ -236,59 +237,62 @@ String::index_i (String searchfor) const int String::index_any_i (String set) const { - int n = length_i(); - if ( !n) + int n = length_i(); + if ( !n) return -1; - void const * me_l = (void const *) strh_.ch_C(); - for (int i=0; i < set.length_i(); i++) { + void const * me_l = (void const *) strh_.ch_C(); + for (int i=0; i < set.length_i(); i++) + { char * found=(char*) memchr (me_l, set[i], n ); - if (found) { + if (found) + { return found - me_l; - } + } } - return -1; + return -1; } String String::left_str (int n) const { - if (n >= length_i()) + if (n >= length_i()) return *this; - String retval; - if (n < 1) - return retval; - - retval = *this; - retval.strh_.trunc (n); - return retval; + String retval; + if (n < 1) + return retval; + + retval = *this; + retval.strh_.trunc (n); + return retval; } String String::right_str (int n) const { - if (n > length_i()) + if (n > length_i()) return *this; - - if ( n < 1) - return ""; - - return String (strh_.byte_C() + length_i() - n, n); + + if ( n < 1) + return ""; + + return String (strh_.byte_C() + length_i() - n, n); } String String::nomid_str (int index_i, int n) const { - if ( index_i < 0) { + if ( index_i < 0) + { n += index_i; index_i = 0; } - if ( n <= 0) + if ( n <= 0) return *this; - - return + + return left_str (index_i) + right_str (length_i() - index_i - n) ; } @@ -299,67 +303,68 @@ String::nomid_str (int index_i, int n) const String String::mid_str (int index_i, int n) const { - if (index_i <0) { + if (index_i <0) + { n += index_i; index_i=0; } - - if ( !length_i() || ( index_i < 0) || ( index_i >= length_i () ) || ( n < 1 ) ) + + if ( !length_i() || ( index_i < 0) || ( index_i >= length_i () ) || ( n < 1 ) ) return String(); - if ( ( n > length_i()) || ( index_i + n > length_i () ) ) + if ( ( n > length_i()) || ( index_i + n > length_i () ) ) n = length_i() - index_i; - return String (byte_C() + index_i, n); + return String (byte_C() + index_i, n); } String String::upper_str() const { - String str = *this; - str.to_upper(); - return str; + String str = *this; + str.to_upper(); + return str; } void String::to_upper() { - char *s = (char*)strh_.byte_l(); - strnupr (s ,length_i()); + char *s = (char*)strh_.byte_l(); + strnupr (s ,length_i()); } void String::to_lower() { - char* s = strh_.ch_l(); - strnlwr (s,length_i()); + char* s = strh_.ch_l(); + strnlwr (s,length_i()); } String String::lower_str() const { - String str = *this; - str.to_lower(); - return str; + String str = *this; + str.to_lower(); + return str; } String String::reversed_str() const { - String str = *this; - strrev (str.byte_l(), str.length_i ()); - return str; + String str = *this; + strrev (str.byte_l(), str.length_i ()); + return str; } int String::value_i() const { - return String_convert::dec2_i (*this); + return String_convert::dec2_i (*this); } double String::value_f() const { - return String_convert::dec2_f (*this); + return String_convert::dec2_f (*this); } diff --git a/flower/stringtest.cc b/flower/stringtest.cc index b415de36e2..bc431567b9 100644 --- a/flower/stringtest.cc +++ b/flower/stringtest.cc @@ -11,32 +11,32 @@ void ctors() { - cout << "constructors"< a; - a.push ("abcd"); - a.push ("zxy"); - a.push ("abc"); - a.push (""); - a.sort (String::compare_i); - cout << "compares: "< a; + a.push ("abcd"); + a.push ("zxy"); + a.push ("abc"); + a.push (""); + a.sort (String::compare_i); + cout << "compares: "< fields; assert (!eof()); @@ -34,12 +37,12 @@ Text_db::get_record() { fields.push (s); gobble_white(); - } + } if (get_line() != "") assert (false); - + assert (fields.size()); return Text_record (fields, get_name(), line ()); } diff --git a/flower/text-stream.cc b/flower/text-stream.cc index a8eb695ea2..530c6f8ecd 100644 --- a/flower/text-stream.cc +++ b/flower/text-stream.cc @@ -2,23 +2,24 @@ Text_stream::Text_stream (String fn) { - ios::sync_with_stdio(); - if (fn == "") + ios::sync_with_stdio(); + if (fn == "") { name = ""; f = stdin; - } + } else { name = fn; f = fopen (fn, "r"); - } + } - if (!f) { + if (!f) + { cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; exit (1); - } + } line_no = 1; } @@ -26,6 +27,6 @@ Text_stream::Text_stream (String fn) void Text_stream::message (String s) { - cerr << "\n"< d) - : dat (d) + : dat (d) { } Vector::Vector (Vector const &n) - : dat (n.dat) + : dat (n.dat) { } Vector Vector::operator-() const { - Vector v (*this); - v*=-1; - return v; + Vector v (*this); + v*=-1; + return v; } void Vector::set_unit (int j) { - fill (0.0); - dat[j] = 1.0; + fill (0.0); + dat[j] = 1.0; } diff --git a/init/paper16.ly b/init/paper16.ly index de6a68c3ac..52278f3217 100644 --- a/init/paper16.ly +++ b/init/paper16.ly @@ -13,13 +13,18 @@ default_paper = \paper { notewidth = 5.0\pt; wholewidth = 4.8\pt; unitspace = 22.\pt; - basicspace = 4.\pt; + %geometric = 1.414; + %basicspace = 4.\pt; + geometric = 0.; + arithmetic_basicspace = 2.; + arithmetic_multiplier = 4.8\pt; + % interbeam = 2.667\pt; - geometric = 1.414; - gourlay_energybound = 50000.; - gourlay_maxmeasures = 6.; + + gourlay_energybound = 100000.; + gourlay_maxmeasures = 14.; castingalgorithm = \Gourlay; \symboltables { \table_sixteen } \requesttranslator { \orchestral_score_translator } diff --git a/init/symbol.ly b/init/symbol.ly index 8d84256d94..65bced4151 100644 --- a/init/symbol.ly +++ b/init/symbol.ly @@ -1,7 +1,12 @@ \version "0.1.1"; +breve = \duration { -1 0 } +longa = \duration { -2 0 } + \include "dynamic.ly" \include "dutch.ly" + + \include "script.ly" \include "paper16.ly" diff --git a/init/table16.ly b/init/table16.ly index f3fdd6de45..71cc34dcba 100644 --- a/init/table16.ly +++ b/init/table16.ly @@ -74,9 +74,10 @@ table_sixteen= } "balls" = \table { - "1" "\wholeball" 0.0\pt 6.0\pt -2.0\pt 2.0\pt - "2" "\halfball" 0.0\pt 5.0\pt -2.0\pt 2.0\pt - "4" "\quartball" 0.0\pt 5.0\pt -2.0\pt 2.0\pt + "-1" "\breveball" 0.0\pt 6.0\pt -2.0\pt 2.0\pt + "0" "\wholeball" 0.0\pt 6.0\pt -2.0\pt 2.0\pt + "1" "\halfball" 0.0\pt 5.0\pt -2.0\pt 2.0\pt + "2" "\quartball" 0.0\pt 5.0\pt -2.0\pt 2.0\pt } "slur" = \table { @@ -110,19 +111,21 @@ table_sixteen= } "rests" = \table { - "1o" "\outsidewholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt - "1" "\wholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt - "2" "\halfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt - "2o" "\outsidehalfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt - "4o" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt - "8o" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt - "16o" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt - "4" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt - "8" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt - "16" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt - "32" "\thirtysecondrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt - "64" "\sixtyfourthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt - "128" "\hundredtwentyeighthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt + "-1o" "\breverest" 0.0\pt 6.0\pt 0.0\pt 4.0\pt + "-1" "\breverest" 0.0\pt 6.0\pt 0.0\pt 4.0\pt + "0o" "\outsidewholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt + "0" "\wholerest" 0.0\pt 6.0\pt 0.0\pt 2.0\pt + "1" "\halfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt + "1o" "\outsidehalfrest" 0.0\pt 6.0\pt -2.0\pt 0.0\pt + "2o" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt + "3o" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt + "4o" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt + "2" "\quartrest" -5.0\pt 2.0\pt -5.0\pt 5.0\pt + "3" "\eighthrest" 0.0\pt 5.0\pt 0.0\pt 8.0\pt + "4" "\sixteenthrest" 0.0\pt 6.0\pt 0.0\pt 12.0\pt + "5" "\thirtysecondrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt + "6" "\sixtyfourthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt + "7" "\hundredtwentyeighthrest" 0.0\pt 6.0\pt 0.0\pt 16.0\pt } "meters" = \table { diff --git a/input/cadenza.ly b/input/cadenza.ly index 9814cad784..9c96602041 100644 --- a/input/cadenza.ly +++ b/input/cadenza.ly @@ -1,14 +1,14 @@ -%{MudelaHeader - filename: cadenza.ly - title: Cadenza ad libitum - description: Cadenza to Mozart Horn concerto 3 - composer(s): unknown - entered-by: HWN - copyright: public domain - - Tested Features: cadenza mode +\header{ +filename cadenza.ly +title Cadenza ad libitum +description Cadenza to Mozart Horn concerto 3 +composer unknown +enteredby HWN +copyright public domain +} -EndMudelaHeader +%{ +Tested Features: cadenza mode %} \version "0.1.1"; @@ -58,9 +58,6 @@ cad = \melodic {\id "Staff" "french horn"; \score { \melodic { \cad } \paper { - - unitspace= 16.0\mm; - geometric= 1.4; } \midi { \tempo 4 = 90; } } diff --git a/input/gallina.ly b/input/gallina.ly index 89b4298679..6509c9cd06 100644 --- a/input/gallina.ly +++ b/input/gallina.ly @@ -1,3 +1,14 @@ +\header{ +title La Gallina a 2 violini +date 1637 +source the manuscript of Canzoni overo Sonate Concertate + libro terzo, opera duodecima +composer Tarquinio Merula (1594/95-1665) +enteredby Mats Bengtsson +copyright Public Domain +} + + %{ From mats.bengtsson@s3.kth.seThu Aug 14 02:11:19 1997 Date: Wed, 13 Aug 1997 18:24:53 +0200 @@ -20,20 +31,12 @@ either. /Mats --------------------------------------------------- -%} -%{ - title: La Gallina a 2 violini - date: 1637 - source: the manuscript of Canzoni overo Sonate Concertate - libro terzo, opera duodecima - composer(s): Tarquinio Merula (?-?) - entered-by: Mats Bengtsson - copyright: Public Domain - - Tested Features: Note placement, multipart score, figured base +Tested Features: Note placement, multipart score, figured base, \breve +note: the sharp signs hoovering over the bass part are no mistake, but +part of the basso continuo + %} vi1=\melodic{ @@ -43,7 +46,7 @@ vi1=\melodic{ d8 d d d d4 A16 B c A | B8 G G G16 A B8 G G G16 A | B8 G G A16 B c4 B | - A8 D G4. Fis16 E Fis4 | + A8 D G2 Fis4 | G2 r2 | r1 | d8 d d d d4 A16 B c A | @@ -58,12 +61,12 @@ vi1=\melodic{ d8 G c2 B4 | c8 G G G16 A B4 G | r8 G G G16 A B4 G | - r8 E16 Fis G8 G Fis G G Fis| + r8 E16 Fis G8 G Fis! G G Fis! | G2 r | r1 | r16 d c B A G Fis E D8 d d d16 c | B8 d d d16 c B8 d d d16 e | - fis4 g2 fis4 | + fis4 g2 fis!4 | r16 g f e d c B A G8 g g g16 f | e8 g g g16 f e8 g g g16 a | b4 c'2 b4 | @@ -78,11 +81,11 @@ vi1=\melodic{ d1. | r4 d8 c B4 c8 d G4 A8 B | E1. | - r4 e8 d cis4 d8 e A4 B8 cis | + r4 e8 d cis4 d8 e A4 B8 cis! | Fis1. | r4 d d d d d | e e8 d c4 d8 e A4 B8 c | - Fis4 fis8 e d4 e8 fis B4 c8 d | + Fis4 fis8 e d4 e8 fis! B4 c8 d | G4 g g g g g | a4 c'8 b a4 b8 c' f4 g8 a | d4 g g g g g | @@ -95,12 +98,13 @@ vi1=\melodic{ c2 r | g8 g g g g4 d16 e f d | e8 G G G16 A B8 d d d16 e | - fis4 g2 fis4 | + fis4 g2 fis!4 | r16 g f e d c B A G8 g g g16 f | e2 r8 d d d16 e | fis a g fis e d c B A8 d d d16 e | - fis4 g2 fis4 | - g1 + fis4 g2 fis!4 | + \cadenza 1; + g\breve \bar "|."; } @@ -112,7 +116,7 @@ vi2=\melodic{ d8 d d d d4 A16 B c A | B8 G G G16 A B8 G G G16 A | B8 G G A16 B c4 B | - A8 D G4. Fis16 E Fis4 | + A8 D G2 Fis4 | G2 r2 | r1 | g8 g g g g4 d16 e f d | @@ -127,7 +131,7 @@ vi2=\melodic{ c4 B A2 | G r16 d c B A G Fis E | D8 d d d16 c B8 d d d16 e | - fis4 g g4. fis8 | + fis4 g g4. fis!8 | g2 r | r16 d c B A G Fis E D8 d d d16 c | B4 c2 B4 | @@ -141,18 +145,18 @@ vi2=\melodic{ r1. | r4 g8 f e4 f8 g c4 d8 e | A1. | - r4 a8 g fis4 g8 a d4 e8 fis | + r4 a8 g fis4 g8 a d4 e8 fis! | B1. | r4 g g g g g | a1. | r4 a a a a a | b d8 c B4 c8 d G4 A8 B | E4 g8 f e4 f8 g c4 d8 e | - A4 a8 g fis4 g8 a d4 e8 fis | + A4 a8 g fis4 g8 a d4 e8 fis! | B4 b8 a g4 a8 b e4 fis8 g | c4 A A A A A | B d8 c B4 c8 d D4 E | - Fis2 G Fis | + Fis2 G Fis! | \meter 4/4; G1 | r1 | r1 | @@ -165,7 +169,8 @@ vi2=\melodic{ c8 G G G16 A B d c B A G Fis E | D8 d d d16 e fis16 a g fis e d c B | A d c B A G Fis E D4 d | - B1 + \cadenza 1; + B\breve \bar "|."; } @@ -192,6 +197,7 @@ bc=\melodic{ G1 | \meter 3/2; g1. | c | + % 30 f | d^"\sharp" | g | c | A | d^"\sharp" | @@ -206,7 +212,9 @@ bc=\melodic{ G^"3 4 3" | c2 G | d1^"3 4 3" | G^"3 4 3" | c2 G | d1^"\sharp" ( | - ) d^"3 4 3" | G | + ) d^"3 4 3" | + \cadenza 1; + G\breve \bar "|."; } @@ -217,9 +225,13 @@ bc=\melodic{ \bc > \paper{ - linewidth=18.\cm; - gourlay_maxmeasures=5.; + %linewidth=18.\cm; + \output "gallina.out"; + gourlay_maxmeasures=7.; } + \midi{ + \tempo 4=90; +} } diff --git a/input/gallina.tex b/input/gallina.tex new file mode 100644 index 0000000000..db760e425b --- /dev/null +++ b/input/gallina.tex @@ -0,0 +1,24 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% gallina.tex +% Mats Bengtsson, 17/8 1997 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\documentclass[a4paper]{article} + +\addtolength{\oddsidemargin}{-1cm} +\addtolength{\topmargin}{-1cm} +\setlength{\textwidth}{15cm} +\begin{document} +\input lilyponddefs +\input titledefs + +\title{La Gallina a 2 violini \\ + \normalsize from \textit{Canzoni overo Sonate Concertate + libro terzo, opera duodecima}, 1637} +\composer{Tarquinio Merula (1594/95-1665)} +%\instrument{M\"a\ss ig} % heu +%#%\tempo{M\"a\ss ig} +\maketit +\input{gallina.out} + + +\end{document} diff --git a/input/header.ly b/input/header.ly index 71b146c913..49d223676e 100644 --- a/input/header.ly +++ b/input/header.ly @@ -1,17 +1,16 @@ -%{MudelaHeader +\header { +filename +title +date +description +opus +source +composers +enteredby +copyright +remarks +} - filename: - title: - date: - description: - opus: - source: - composers: - entered-by: - copyright: - remarks: - Tested Features: - -EndMudelaHeader +%{ +Tested Features: %} -\version "0.1.1"; diff --git a/input/kortjakje.ly b/input/kortjakje.ly index 6f0451ef6f..6c580c2467 100644 --- a/input/kortjakje.ly +++ b/input/kortjakje.ly @@ -1,14 +1,15 @@ -%{MudelaHeader - filename: kortjakje.ly - title: Ah, vous dirais-je, maman (variations) - description: bare bones version. (written down from memory :-) - composers: Mozart, KV 265 - entered-by: HWN - copyright: PD +\header{ +filename kortjakje.ly +title Ah, vous dirais-je, maman (variations) +description bare bones version. (written down from memory :-) +composers Mozart, KV 265 +entered-by HWN +copyright PD +} +%{ +Tested Features: example file with comments - Tested Features: example file with comments -EndMudelaHeader %} \version "0.1.1"; diff --git a/input/rhythm.ly b/input/rhythm.ly index a2ab538381..14454306a2 100644 --- a/input/rhythm.ly +++ b/input/rhythm.ly @@ -63,7 +63,5 @@ yanother = > \paper{ - unitspace =2.0\cm; - geometric =1.6; } } diff --git a/input/s.ly b/input/s.ly deleted file mode 100644 index f3aba775c0..0000000000 --- a/input/s.ly +++ /dev/null @@ -1,43 +0,0 @@ - -vi1=\melodic{ - \meter 4/4; - \octave c''; - - B8 G G G16 A B8 G G G16 A | - -} - -vi2=\melodic{ - \meter 4/4; - \octave c''; - -% r16 - r1 -} - -%{ -bc=\melodic{ - \clef "bass"; - \meter 4/4; - \octave c; - - G1 | -} -%} - -\score{ - < \multi 3; - \vi1 - \vi2 - - > - - \paper{ - geometric=1.2; - unitspace=8.\mm; - linewidth=18.\cm; - gourlay_maxmeasures=4.; - gourlay_energybound = 70000.; - basicspace = 2.8\pt; - } -} diff --git a/input/scales.ly b/input/scales.ly index f69bc1b650..ce2c3ba854 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -1,12 +1,9 @@ -%{MudelaHeader - - filename: scales.ly - title: - description: - composers: - entered-by: HWN - copyright: public domain - +\header{ +filename scales.ly +enteredby HWN +copyright public domain +} +%{ Tested Features: scripts, beams, transposition, EndMudelaHeader %} @@ -89,7 +86,5 @@ c1 \score{ \melodic {\blah} \paper{ - unitspace= 1.5 \cm; - geometric= 1.4; } } diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index 35ba9023f2..72d61415a1 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -1,18 +1,16 @@ -%{MudelaHeader - - filename: scsii-menuetto.ly - title: Solo Cello Suites, Suite II part V, Menuetto I - description: Cello suite transcribed for Viola - source: ? - opus: BWV 1008 no. 5 - composers: Johann Sebastian Bach (1685-1750) - entered-by: JCN - copyright: public domain +\header{ +filename scsii-menuetto.ly +title Solo Cello Suites, Suite II part V, Menuetto I +description Cello suite transcribed for Viola +source ? +opus BWV 1008 no. 5 +composers Johann Sebastian Bach (1685-1750) +enteredby JCN +copyright public domain +} +%{ Tested Features:breaking algorithm, chords, multivoice, accents - - -EndMudelaHeader %} \version "0.1.1"; @@ -107,9 +105,7 @@ IImenuetto = \melodic{ \id "Staff" "cello"; \IImenuetto } \paper{ - unitspace= 9.0\mm ;% to get lily to use only three lines - geometric= 1.40; - linewidth= 195.0\mm; + linewidth= 150.0\mm; \output "scsii-menuetto.out"; } \midi{ diff --git a/input/standchen.ly b/input/standchen.ly index 58d1dd27c1..e9daad7378 100644 --- a/input/standchen.ly +++ b/input/standchen.ly @@ -1,13 +1,13 @@ -%{MudelaHeader - - filename: standchen.ly - title: St\"andchen (Serenade) "Leise flehen meine Lieder" - opus: D. 957 No. 4 - composers: Franz Schubert (1797-1828) - Text by Ludwig Rellstab (1799-1860) - entered-by:JCN - copyright: public domain - +\header{ +filename standchen.ly +title St\"andchen (Serenade) "Leise flehen meine Lieder" +opus D. 957 No. 4 +composers Franz Schubert (1797-1828) + Text by Ludwig Rellstab (1799-1860) +enteredby JCN +copyright public domain +} +%{ Tested Features: multivoice, accents, lyrics, chords, piano music EndMudelaHeader @@ -480,11 +480,11 @@ tekstII = \lyric{ > > \paper{ - linewidth= 195.\mm; + linewidth= 150.\mm; + gourlay_maxmeasures = 8.; % on two pages... unitspace= 9.\mm; - geometric= 1.2; \output "standchen.out"; } \midi{ diff --git a/input/toccata-fuga-E.ly b/input/toccata-fuga-E.ly index 828796f9d0..4e75271f8f 100644 --- a/input/toccata-fuga-E.ly +++ b/input/toccata-fuga-E.ly @@ -1,22 +1,23 @@ -%{MudelaHeader +\header{ - filename: toccata-fuga-E.ly - title: toccata and fuga in E-major - opus: BWV 566 - toccata: 3 bar excerpt - 2nd fuga: transposed subject --- 4 bar excerpt +filename toccata-fuga-E.ly +title toccata and fuga in E-major +opus BWV 566 + toccata 3 bar excerpt + 2nd fuga transposed subject --- 4 bar excerpt - composers: Johann Sebastian Bach (1685-1750) - entered-by: JCN - copyright: public domain +composers Johann Sebastian Bach (1685-1750) +enteredby JCN +copyright public domain +} + +%{ Tested Features: purpose of this file is testing: * real-life collisions * multi-voice input --- splitting? * organ staff... - -EndMudelaHeader %} diff --git a/input/twinkle-pop.ly b/input/twinkle-pop.ly index 41561e6a44..1feeeb2eec 100644 --- a/input/twinkle-pop.ly +++ b/input/twinkle-pop.ly @@ -1,15 +1,15 @@ -%{MudelaHeader - - filename: twinkle.ly - title: Ah, vous dirais-je, maman - description: twinkle twinkle in pop-song-settings - composers: traditional - - entered-by: HWN, chords by Johan Vromans - copyright: public domain +\header{ +filename twinkle.ly +title Ah, vous dirais-je, maman +description twinkle twinkle in pop-song-settings +composers traditional + +enteredby HWN, chords by Johan Vromans +copyright public domain +} - Tested Features: lyrics and chords -EndMudelaHeader +%{ +Tested Features lyrics and chords %} \version "0.1.1"; @@ -43,5 +43,5 @@ texte = \lyric{ < \melodic < \id "Piano" ""; \melodie > \lyric < \id "Lyric" ""; \texte > > - \paper { unitspace= 2.5\cm; } + \paper { } } diff --git a/input/twinkle.ly b/input/twinkle.ly index ba47c25d35..588b26a33e 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -1,19 +1,18 @@ -%{MudelaHeader - - filename: twinkle.ly - title: twinkle twinkle little star - description: - traditional song in various languages. - "Ah, vous dirais-je, maman" - "Altijd is Kortjakje ziek" - "Twinkle twinkle little star" - - composers: Traditional - entered-by: HWN & JCN - copyright: public domain - - Tested Features: lyrics -EndMudelaHeader +\header{ +filename twinkle.ly +title twinkle twinkle little star +description traditional song in various languages. + "Ah, vous dirais-je, maman" + "Altijd is Kortjakje ziek" + "Twinkle twinkle little star" + +composers Traditional +enteredby HWN & JCN +copyright public domain +} +%{ +Tested Features: lyrics + %} \version "0.1.1"; @@ -140,7 +139,6 @@ textiii = \lyric{ > \paper{ - unitspace= 2.5\cm; } \midi{ \tempo 4 = 120 ; diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index 95ad2fc3ab..97429e7d88 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -1,13 +1,14 @@ +\header{ +filename wohltemperirt.ly +title Fuga a 3 +description Das Wohltemperirte Clavier I, Fuga II (c-minor) +opus BWV ? +source Henle's Urtext +composer Johann Sebastian Bach (1685-1750) +enteredby HWN and Werner Lemberg +copyright Public Domain" +} %{ - filename: wohltemperirt.ly - title: Fuga a 3 - description: Das Wohltemperirte Clavier I, Fuga II (c-minor) - Opus: BWV ? - source: Henle's Urtext - composer(s): Johann Sebastian Bach (1685-1750) - entered-by: HWN and Werner Lemberg - copyright: Public Domain - Tested Features: stem direction, multivoice, forced accidentals. %} @@ -176,7 +177,7 @@ bassdux = > \paper{ - gourlay_maxmeasures =4.; + gourlay_maxmeasures =5.; } \midi { diff --git a/lib/duration-convert.cc b/lib/duration-convert.cc index b2a7195103..c96273e5ba 100644 --- a/lib/duration-convert.cc +++ b/lib/duration-convert.cc @@ -23,8 +23,12 @@ Duration_convert::dur2_str( Duration dur ) { if ( dur.ticks_i_ ) return String( "[" ) + String( dur.ticks_i_ ) + "]"; - - String str( dur.type_i_ ); + + String str; + if (dur.durlog_i_ >= 0) + str="breve"; + else + str= String( type2_i(dur.durlog_i_) ); str += String( '.', dur.dots_i_ ); if ( dur.plet_b()) str += String( "*" ) + String( dur.plet_.iso_i_ ) @@ -48,6 +52,27 @@ Duration_convert::dur2ticks_i( Duration dur ) return dur2_mom( dur ) * Moment( Duration::division_1_i_s ); } + +int +Duration_convert::i2_type(int i) +{ + int t=0; + while (!(i & 1)) { + i >>= 1; + t++; + } + return t; +} + +int +Duration_convert::type2_i(int type) +{ + if (type<0) + return 0; + else + return 1 << type; +} + Moment Duration_convert::dur2_mom( Duration dur ) { @@ -55,16 +80,20 @@ Duration_convert::dur2_mom( Duration dur ) return Moment( dur.ticks_i_, Duration::division_1_i_s ); // or simply assert? - if ( !dur.type_i_ ) + if ( dur.durlog_i_<-10 ) return Moment( 0 ); - - Moment mom = Moment( 1 , dur.type_i_ ); + Moment mom; + if (dur.durlog_i_<0) + mom = Moment( type2_i( -dur.durlog_i_ ), 1 ); + else + mom = Moment( 1 , type2_i( dur.durlog_i_ ) ); Moment delta = mom; - while ( dur.dots_i_-- ) { + while ( dur.dots_i_-- ) + { delta /= 2.0; mom += delta; - } + } return mom * plet_factor_mom( dur ); } @@ -86,11 +115,12 @@ Duration_convert::i2_mom( int time_i, int division_1_i ) Duration Duration_convert::mom2_dur( Moment mom ) { - if (!mom) { + if (!mom) + { Duration dur; dur.set_plet(0,1); return dur; - } + } Duration dur = mom2standardised_dur( mom ); @@ -117,25 +147,28 @@ Duration_convert::mom2standardised_dur( Moment mom ) if ( !dur_array_s.size() ) set_array(); assert( dur_array_s.size() ); - for ( int i = 0; i < dur_array_s.size() - 1; i++ ) { + for ( int i = 0; i < dur_array_s.size() - 1; i++ ) + { Moment lower_mom = dur2_mom( dur_array_s[ i ] ); - if ( mom <= lower_mom ) { + if ( mom <= lower_mom ) + { // all arbitrary, but 3/4 will get rid of the noise... // kinda ok if ( i || ( mom / lower_mom > Moment( 3, 4 ) ) ) return dur_array_s[ i ]; - else { + else + { Duration d; - d.type_i_ = 0; + d.durlog_i_ = -100; return d; - } - } + } + } Moment upper_mom = dur2_mom( dur_array_s[ i + 1 ] ); if ( ( mom < upper_mom ) && ( ( mom - lower_mom ) / lower_mom < ( upper_mom - mom ) / upper_mom ) ) return dur_array_s[ i ]; - } + } return dur_array_s[ dur_array_s.size() - 1 ]; } @@ -181,7 +214,7 @@ Duration_convert::ticks2_dur( int ticks_i ) // huh? #if 0 - dur.type_i_ = 0; + dur.durlog_i_ = -100; dur.dots_i_ = 0; dur.set_ticks( ticks_i ); return dur; @@ -200,9 +233,9 @@ Duration_convert::ticks2standardised_dur( int ticks_i ) Duration_iterator::Duration_iterator() { - cursor_dur_.type_i_ = 128; + cursor_dur_.durlog_i_ = 7; if ( Duration_convert::no_smaller_than_i_s ) - cursor_dur_.type_i_ = Duration_convert::no_smaller_than_i_s; + cursor_dur_.durlog_i_ = Duration_convert::no_smaller_than_i_s; // cursor_dur_.set_plet( 1, 1 ); } @@ -240,7 +273,7 @@ Duration_iterator::forward_dur() 16. 0.0938 8 0.1250 16.. 0.1406 - 4:2/3 0.1667 + 4:2/3 0.1667 8. 0.1875 */ @@ -248,29 +281,33 @@ Duration_iterator::forward_dur() Duration dur = cursor_dur_; - if ( !cursor_dur_.dots_i_ && !cursor_dur_.plet_b() ) { - cursor_dur_.type_i_ *= 2; + if ( !cursor_dur_.dots_i_ && !cursor_dur_.plet_b() ) + { + cursor_dur_.durlog_i_ += 1; cursor_dur_.dots_i_ = 2; - } - else if ( cursor_dur_.dots_i_ == 2 ) { + } + else if ( cursor_dur_.dots_i_ == 2 ) + { assert( !cursor_dur_.plet_b() ); cursor_dur_.dots_i_ = 0; - cursor_dur_.type_i_ /= 4; + cursor_dur_.durlog_i_ -=2; cursor_dur_.set_plet( 2, 3 ); - } + } else if ( cursor_dur_.plet_b() && ( cursor_dur_.plet_.iso_i_ == 2 ) - && ( cursor_dur_.plet_.type_i_ == 3 ) ) { + && ( cursor_dur_.plet_.type_i_ == 3 ) ) + { assert( !cursor_dur_.dots_i_ ); cursor_dur_.set_plet( 1, 1 ); - cursor_dur_.type_i_ *= 2; + cursor_dur_.durlog_i_ += 1; cursor_dur_.dots_i_ = 1; - } - else if ( cursor_dur_.dots_i_ == 1 ) { + } + else if ( cursor_dur_.dots_i_ == 1 ) + { assert( !cursor_dur_.plet_b() ); cursor_dur_.dots_i_ = 0; - cursor_dur_.type_i_ /= 2; - } + cursor_dur_.durlog_i_ -= 1; + } if ( Duration_convert::no_triplets_b_s && cursor_dur_.plet_b() && ok() ) @@ -279,16 +316,16 @@ Duration_iterator::forward_dur() && ( cursor_dur_.dots_i_ == 2 ) && ok() ) forward_dur(); if ( Duration_convert::no_smaller_than_i_s - && ( cursor_dur_.type_i_ > Duration_convert::no_smaller_than_i_s ) && ok() ) + && ( cursor_dur_.durlog_i_ > Duration_convert::no_smaller_than_i_s ) && ok() ) forward_dur(); if ( Duration_convert::no_smaller_than_i_s && cursor_dur_.dots_i_ - && ( cursor_dur_.type_i_ >= Duration_convert::no_smaller_than_i_s ) + && ( cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s ) && ok() ) forward_dur(); if ( Duration_convert::no_smaller_than_i_s && ( cursor_dur_.dots_i_ == 2 ) - && ( cursor_dur_.type_i_ >= Duration_convert::no_smaller_than_i_s / 2 ) + && ( cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s / 2 ) && ok() ) forward_dur(); @@ -298,6 +335,6 @@ Duration_iterator::forward_dur() bool Duration_iterator::ok() { - return ( cursor_dur_.type_i_ - && !( ( cursor_dur_.type_i_ == 1 ) && ( cursor_dur_.dots_i_ > 2 ) ) ); + return ( cursor_dur_.durlog_i_ + && !( ( cursor_dur_.durlog_i_ == 0 ) && ( cursor_dur_.dots_i_ > 2 ) ) ); } diff --git a/lib/duration.cc b/lib/duration.cc index f81b3c2be9..c26699c5bd 100644 --- a/lib/duration.cc +++ b/lib/duration.cc @@ -22,29 +22,25 @@ int Duration::division_1_i_s = 384 * 4; Duration::Duration() { - type_i_ = 1; - dots_i_ = 0; - ticks_i_ = 0; + durlog_i_ = 0; + dots_i_ = 0; + ticks_i_ = 0; } Duration::Duration( int type_i, int dots_i = 0 ) { - type_i_ = type_i; - dots_i_ = dots_i; - ticks_i_ = 0; + durlog_i_ = type_i; + dots_i_ = dots_i; + ticks_i_ = 0; } bool Duration::duration_type_b(int t) { - int bit_i=0; - while (t > 0) - { - int rem = t % 2; - t /= 2; - bit_i += (rem == 1); - } - return bit_i == 1; + /* + ugh. Assuming behavior of conversion funcs on broken input. + */ + return t == Duration_convert::type2_i( Duration_convert::i2_type(t)); } // ugh, what's this? @@ -52,58 +48,40 @@ Duration::duration_type_b(int t) Moment Duration::length() const { - return Duration_convert::dur2_mom(*this); + return Duration_convert::dur2_mom(*this); } void Duration::set_plet(int i, int t) { - plet_.iso_i_ = i; - plet_.type_i_ = t; + plet_.iso_i_ = i; + plet_.type_i_ = t; } void Duration::set_plet(Duration d) { - plet_.iso_i_ = d.plet_.iso_i_; - plet_.type_i_ = d.plet_.type_i_; + plet_.iso_i_ = d.plet_.iso_i_; + plet_.type_i_ = d.plet_.type_i_; } void Duration::set_ticks( int ticks_i ) { - assert( !type_i_ ); - assert( !dots_i_ ); - ticks_i_ = ticks_i; + assert( durlog_i_ <10 ); + assert( !dots_i_ ); + ticks_i_ = ticks_i; } String Duration::str()const { - return Duration_convert::dur2_str(*this); + return Duration_convert::dur2_str(*this); } -Plet::Plet() -{ - type_i_ = 1; - iso_i_ = 1; -} - -Moment -Plet::mom()const -{ - return Moment( iso_i_, type_i_ ); -} bool Duration::plet_b() { - return !plet_.unit_b(); + return !plet_.unit_b(); } - -bool -Plet::unit_b()const -{ - return type_i_ == 1 && iso_i_ == 1; -} - diff --git a/lib/file-storage.cc b/lib/file-storage.cc index 16bee29c68..849c27c994 100644 --- a/lib/file-storage.cc +++ b/lib/file-storage.cc @@ -55,10 +55,11 @@ Mapped_file_storage::open(String name_str) { fildes_i_ = ::open( name_str, O_RDONLY ); - if ( fildes_i_ == -1 ) { + if ( fildes_i_ == -1 ) + { warning( String( "can't open: " ) + name_str + String( ": " ) + strerror( errno )); return; - } + } struct stat file_stat; fstat( fildes_i_, &file_stat ); @@ -69,21 +70,23 @@ Mapped_file_storage::open(String name_str) void Mapped_file_storage::unmap() { - if ( data_caddr_ ) { + if ( data_caddr_ ) + { munmap( data_caddr_, size_off_ ); data_caddr_ = 0; size_off_ = 0; - } + } } void Mapped_file_storage::close() { unmap(); - if ( fildes_i_ ) { + if ( fildes_i_ ) + { ::close( fildes_i_ ); fildes_i_ = 0; - } + } } int diff --git a/lib/includable-lexer.cc b/lib/includable-lexer.cc index 6b4348d5f2..73d00498a8 100644 --- a/lib/includable-lexer.cc +++ b/lib/includable-lexer.cc @@ -24,10 +24,11 @@ void Includable_lexer::new_input(String s, Sources * global_sources) { Source_file * sl = global_sources->get_file_l(s); - if (!sl) { + if (!sl) + { LexerError("Can't find file `" + s+ "'"); return; - } + } char_count_stack_.push(0); @@ -59,12 +60,14 @@ Includable_lexer::close_input() cout << "]"< +*/ + + +#ifndef PLET_HH +#define PLET_HH +#include "moment.hh" + +/** + The type and replacement value of a plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3. + + (plet) + */ +struct Plet { + Plet(); + Moment mom()const; + bool unit_b()const; + int iso_i_; // 2/3; 2 is not duration, maar of count! + int type_i_; +}; + +#endif // PLET_HH diff --git a/lib/input.cc b/lib/input.cc index 8478810052..6f05290422 100644 --- a/lib/input.cc +++ b/lib/input.cc @@ -40,15 +40,17 @@ Input::message(String message_str)const { String str = ""; - if ( source_file_l_ ) { + if ( source_file_l_ ) + { str += location_str() + String(": "); - } + } str += message_str; - if ( source_file_l_ ) { + if ( source_file_l_ ) + { str += ":\n"; str += source_file_l_->error_str( defined_ch_C_); - } + } cerr << str << endl; } diff --git a/lib/plet.cc b/lib/plet.cc new file mode 100644 index 0000000000..73df524f7d --- /dev/null +++ b/lib/plet.cc @@ -0,0 +1,29 @@ +/* + plet.cc -- implement Plet + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "plet.hh" + + +Plet::Plet() +{ + type_i_ = 1; + iso_i_ = 1; +} + +Moment +Plet::mom()const +{ + return Moment( iso_i_, type_i_ ); +} + +bool +Plet::unit_b()const +{ + return type_i_ == 1 && iso_i_ == 1; +} + diff --git a/lib/simple-file-storage.cc b/lib/simple-file-storage.cc index be022cee02..d66c2c2d9b 100644 --- a/lib/simple-file-storage.cc +++ b/lib/simple-file-storage.cc @@ -29,10 +29,11 @@ Simple_file_storage::Simple_file_storage(String s) { data_p_ =0; FILE * f = fopen ( s.ch_C(), "r"); - if ( !f ) { + if ( !f ) + { warning("can't open file\n"); return ; - } + } int ret = fseek( f, 0, SEEK_END); len_i_ = ftell(f); diff --git a/lib/source-file.cc b/lib/source-file.cc index ffc7a341ed..a67b466300 100644 --- a/lib/source-file.cc +++ b/lib/source-file.cc @@ -32,14 +32,16 @@ Source_file::istream_l() if ( !name_str_.length_i()) return &cin; - if ( !istream_p_ ) { + if ( !istream_p_ ) + { if ( length_i() ) // can-t this be done without such a hack? istream_p_ = new istrstream( ch_C(), length_i() ); - else { + else + { istream_p_ = new istrstream( "", 0 ); istream_p_->set(ios::eofbit); - } - } + } + } return istream_p_; } @@ -74,17 +76,19 @@ Source_file::error_str( char const* pos_ch_C )const pos_ch_C --; char const* begin_ch_C = pos_ch_C; while ( begin_ch_C > data_ch_C ) - if ( *--begin_ch_C == '\n' ) { + if ( *--begin_ch_C == '\n' ) + { begin_ch_C++; break; - } + } char const* end_ch_C = pos_ch_C; while ( end_ch_C < eof_C_ ) - if ( *end_ch_C++ == '\n' ) { + if ( *end_ch_C++ == '\n' ) + { end_ch_C--; break; - } + } // String( char const* p, int length ) is missing!? String line_str( (Byte const*)begin_ch_C, end_ch_C - begin_ch_C ); diff --git a/lib/source.cc b/lib/source.cc index ec490f17e7..e60041553c 100644 --- a/lib/source.cc +++ b/lib/source.cc @@ -34,12 +34,13 @@ Sources::set_path(File_path *f_C) Source_file* Sources::get_file_l(String &file_str ) //UGH { - if (path_C_){ + if (path_C_) + { String file_str_o = path_C_->find(file_str); if ( ( file_str_o == "" ) && ( file_str != "" ) ) return 0; file_str = file_str_o; - } + } Source_file * f_p= (!binary_b_) ? new Source_file(file_str) : new Binary_source_file(file_str); add(f_p); diff --git a/lily/VERSION b/lily/VERSION index d87385f587..7b9611af00 100644 --- a/lily/VERSION +++ b/lily/VERSION @@ -1,6 +1,6 @@ MAJOR_VERSION = 0 MINOR_VERSION = 1 -PATCH_LEVEL = 8 +PATCH_LEVEL = 9 # use to send patches, always empty for released version: # include separator: ".postfix", "-pl" makes rpm barf diff --git a/lily/atom.cc b/lily/atom.cc index ac3c246a03..fbb6e973f8 100644 --- a/lily/atom.cc +++ b/lily/atom.cc @@ -17,36 +17,36 @@ void Atom::print() const { #ifndef NPRINT - DOUT << "texstring: " < a; - a.push (print_dimen (off_.y())); - a.push (print_dimen (off_.x())); - a.push (sym_.tex); - return substitute_args (s, a); + /* infinity checks. */ + assert (abs (off_.x()) < 100 CM); + assert (abs (off_.y()) < 100 CM); + + // whugh.. Hard coded... + String s ("\\placebox{%}{%}{%}"); + Array a; + a.push (print_dimen (off_.y())); + a.push (print_dimen (off_.x())); + a.push (sym_.tex); + return substitute_args (s, a); } diff --git a/lily/audio-column.cc b/lily/audio-column.cc index e0d87b1a99..1df586be62 100644 --- a/lily/audio-column.cc +++ b/lily/audio-column.cc @@ -14,30 +14,30 @@ Audio_column::Audio_column (Moment at_mom) { - at_mom_ = at_mom; - audio_score_l_ = 0; + at_mom_ = at_mom; + audio_score_l_ = 0; } void Audio_column::add (Audio_item* l) { - audio_item_l_list_.bottom().add (l); - l->audio_column_l_ = this; + audio_item_l_list_.bottom().add (l); + l->audio_column_l_ = this; } Moment Audio_column::at_mom() const { - return at_mom_; + return at_mom_; } void Audio_column::print() const { #ifndef NPRINT - DOUT << "Audio_column {"; - DOUT << "at: " << at_mom_ << "\n"; - DOUT << "}\n"; + DOUT << "Audio_column {"; + DOUT << "at: " << at_mom_ << "\n"; + DOUT << "}\n"; #endif } diff --git a/lily/audio-item.cc b/lily/audio-item.cc index e5fbda129b..eaa895049a 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -12,19 +12,19 @@ Audio_instrument::Audio_instrument (String instrument_str) : Audio_item (0) { - str_ = instrument_str; + str_ = instrument_str; } Midi_item* Audio_instrument::midi_item_p() { - return str_.length_i() ? new Midi_instrument( 0, str_ ) : 0; + return str_.length_i() ? new Midi_instrument( 0, str_ ) : 0; } - + Audio_item::Audio_item (Request* req_l) { - audio_column_l_ = 0; - req_l_ = req_l; + audio_column_l_ = 0; + req_l_ = req_l; } Audio_key::Audio_key (Request* req_l) @@ -35,7 +35,7 @@ Audio_key::Audio_key (Request* req_l) Midi_item* Audio_key::midi_item_p() { - return new Midi_key (this); + return new Midi_key (this); } @@ -47,19 +47,19 @@ Audio_note::Audio_note (Request* req_l) Midi_item* Audio_note::midi_item_p() { - return new Midi_note (this); + return new Midi_note (this); } Audio_tempo::Audio_tempo (int per_minute_4_i) : Audio_item (0) { - per_minute_4_i_ = per_minute_4_i; + per_minute_4_i_ = per_minute_4_i; } Midi_item* Audio_tempo::midi_item_p() { - return new Midi_tempo (this); + return new Midi_tempo (this); } Audio_meter::Audio_meter (Request* req_l) @@ -70,7 +70,7 @@ Audio_meter::Audio_meter (Request* req_l) Midi_item* Audio_meter::midi_item_p() { - return new Midi_meter (this); + return new Midi_meter (this); } Audio_text::Audio_text (Audio_text::Type type, String text_str) @@ -83,7 +83,7 @@ Audio_text::Audio_text (Audio_text::Type type, String text_str) Midi_item* Audio_text::midi_item_p() { - return text_str_.length_i() ? new Midi_text( this ) : 0; + return text_str_.length_i() ? new Midi_text( this ) : 0; } diff --git a/lily/audio-score.cc b/lily/audio-score.cc index 57f012e233..1c406c5b7f 100644 --- a/lily/audio-score.cc +++ b/lily/audio-score.cc @@ -21,87 +21,87 @@ Audio_score::Audio_score (Score* l) { - score_l_ = l; + score_l_ = l; } void Audio_score::add (Audio_column* p) { - p->audio_score_l_ = this; - audio_column_p_list_.bottom().add (p); + p->audio_score_l_ = this; + audio_column_p_list_.bottom().add (p); } void Audio_score::output (Midi_stream& midi_stream_r) { - int tracks_i = audio_staff_l_list_.size() + 1; - // ugh - int clocks_per_4_i = 384; - midi_stream_r << Midi_header (1, tracks_i, clocks_per_4_i); - output_header_track (midi_stream_r); - int n = 1; - for ( PCursor i (audio_staff_l_list_); i.ok(); i++ ) + int tracks_i = audio_staff_l_list_.size() + 1; + // ugh + int clocks_per_4_i = 384; + midi_stream_r << Midi_header (1, tracks_i, clocks_per_4_i); + output_header_track (midi_stream_r); + int n = 1; + for ( PCursor i (audio_staff_l_list_); i.ok(); i++ ) i->output (midi_stream_r, n++); } void Audio_score::output_header_track (Midi_stream& midi_stream_r) { - Midi_track midi_track; - - time_t t = time (0); + Midi_track midi_track; + + time_t t = time (0); - // perhaps multiple text events? - String str = String ("Creator: ") + get_version_str() + "\n"; + // perhaps multiple text events? + String str = String ("Creator: ") + get_version_str() + "\n"; - Midi_text creator (Midi_text::TEXT, str); - midi_track.add (Moment (0), &creator ); + Midi_text creator (Midi_text::TEXT, str); + midi_track.add (Moment (0), &creator ); - str = "Automatically generated at "; - str += ctime (&t); - str = str.left_str (str.length_i() - 1); - str += "\n"; - Midi_text generate (Midi_text::TEXT, str); - midi_track.add (Moment (0), &generate ); + str = "Automatically generated at "; + str += ctime (&t); + str = str.left_str (str.length_i() - 1); + str += "\n"; + Midi_text generate (Midi_text::TEXT, str); + midi_track.add (Moment (0), &generate ); - str = "from musical definition: "; + str = "from musical definition: "; - str += score_l_->location_str(); - Midi_text from (Midi_text::TEXT, str); - midi_track.add (Moment (0), &from ); + str += score_l_->location_str(); + Midi_text from (Midi_text::TEXT, str); + midi_track.add (Moment (0), &from ); - Midi_text track_name (Midi_text::TRACK_NAME, "Track " + Midi_text track_name (Midi_text::TRACK_NAME, "Track " + String_convert::i2dec_str (0, 0, '0') ); - midi_track.add (Moment (0), &track_name ); + midi_track.add (Moment (0), &track_name ); - Midi_tempo tempo (score_l_->midi_p_->get_tempo_i (Moment (1, 4) ) ); - midi_track.add (Moment (0), &tempo); + Midi_tempo tempo (score_l_->midi_p_->get_tempo_i (Moment (1, 4) ) ); + midi_track.add (Moment (0), &tempo); - midi_stream_r << midi_track; + midi_stream_r << midi_track; } void Audio_score::add_staff (Audio_staff* l) { - audio_staff_l_list_.bottom().add (l); + audio_staff_l_list_.bottom().add (l); } void Audio_score::add (Audio_element *p) { - audio_elem_p_list_.bottom().add (p); + audio_elem_p_list_.bottom().add (p); } void Audio_score::print() const { #ifndef NPRINT - DOUT << "Audio_score { "; - score_l_->midi_p_->print(); - DOUT << "\ncolumns: "; - for ( PCursor i (audio_column_p_list_); i.ok(); i++ ) + DOUT << "Audio_score { "; + score_l_->midi_p_->print(); + DOUT << "\ncolumns: "; + for ( PCursor i (audio_column_p_list_); i.ok(); i++ ) i->print(); - DOUT << "}\n"; + DOUT << "}\n"; #endif } diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index c23b339b2b..21de1e0c9e 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -15,17 +15,17 @@ void Audio_staff::add (Audio_item* l) { - audio_item_l_list_.bottom().add (l); + audio_item_l_list_.bottom().add (l); } void Audio_staff::output (Midi_stream& midi_stream_r, int track_i) { - Midi_track midi_track; - midi_track.number_i_ = track_i; - for ( Midi_walker i (this, &midi_track); i.ok(); i++ ) + Midi_track midi_track; + midi_track.number_i_ = track_i; + for ( Midi_walker i (this, &midi_track); i.ok(); i++ ) i.process(); - midi_stream_r << midi_track; + midi_stream_r << midi_track; } IMPLEMENT_IS_TYPE_B1(Audio_staff, Audio_element); diff --git a/lily/axis-group-item.cc b/lily/axis-group-item.cc index c39a12c673..325c2a0297 100644 --- a/lily/axis-group-item.cc +++ b/lily/axis-group-item.cc @@ -13,8 +13,9 @@ IMPLEMENT_IS_TYPE_B2(Axis_group_item, Axis_group_element, Item); void Axis_group_item::OK() const { - Link_array elems = axis_admin_.elem_l_arr_; - for (int i=0; i < elems.size(); i++) { + Link_array elems = axis_admin_.elem_l_arr_; + for (int i=0; i < elems.size(); i++) + { Item * it_l = elems[i]->item(); assert (it_l); @@ -26,25 +27,27 @@ Axis_group_item::OK() const void Axis_group_item::do_breakable_col_processing() { - if (!pcol_l_->breakable_b()) + if (!pcol_l_->breakable_b()) return; - OK(); - copy_breakable_items(); - + OK(); + copy_breakable_items(); + - Link_array elems = axis_admin_.elem_l_arr_; - for (int i=0; i < elems.size(); i++) { + Link_array elems = axis_admin_.elem_l_arr_; + for (int i=0; i < elems.size(); i++) + { Item* it_l = elems[i]->item(); - for ( int j=0; j < 2; j++) { + for ( int j=0; j < 2; j++) + { Item *new_l = it_l->find_prebroken_piece (broken_to_a_[j]->pcol_l_); ((Axis_group_item*)broken_to_a_[j])->add_element (new_l); - } + } } - Item::do_breakable_col_processing(); + Item::do_breakable_col_processing(); } void Axis_group_item::do_print() const { - Axis_group_element::do_print(); + Axis_group_element::do_print(); } diff --git a/lily/axis-group-spanner.cc b/lily/axis-group-spanner.cc index a7fd4fa62b..1d45de3ae0 100644 --- a/lily/axis-group-spanner.cc +++ b/lily/axis-group-spanner.cc @@ -17,51 +17,59 @@ void Axis_group_spanner::do_break_processing_if_unbroken() { - Link_array elems = axis_admin_.elem_l_arr_; - Line_of_score *my_line = line_l(); - for (int i=0; i < elems.size(); i++) { - if (!elems[i]->line_l()) { + Link_array elems = axis_admin_.elem_l_arr_; + Line_of_score *my_line = line_l(); + for (int i=0; i < elems.size(); i++) + { + if (!elems[i]->line_l()) + { Item * item_l = elems[i]->item(); if (item_l && item_l->breakable_b_ - && item_l->break_status_i() == 0) { + && item_l->break_status_i() == 0) + { // last two checks are paranoia Item * broken_item_l = item_l->find_prebroken_piece (my_line); add_element (broken_item_l); - } + } remove_element (elems[i]); - } + } } - + } void Axis_group_spanner::do_break_processing() { - set_my_columns(); - bool breaking_self_b = ! Spanner::line_l(); - if (!breaking_self_b) { + set_my_columns(); + bool breaking_self_b = ! Spanner::line_l(); + if (!breaking_self_b) + { do_break_processing_if_unbroken(); Spanner::do_break_processing(); return; } - break_into_pieces (true); - Link_array loose_elems = axis_admin_.elem_l_arr_; - remove_all(); - - for (int i=0; i < loose_elems.size(); i++) { + break_into_pieces (true); + Link_array loose_elems = axis_admin_.elem_l_arr_; + remove_all(); + + for (int i=0; i < loose_elems.size(); i++) + { Score_elem * elt = loose_elems[i]; Line_of_score *elt_line = elt->line_l(); - if ( ! elt_line){ + if ( ! elt_line) + { /* this piece doesn't know where it belongs. Find out if it was broken, and use the broken remains */ - if (elt->spanner()) { + if (elt->spanner()) + { Spanner * sp = elt->spanner(); - for (int j =0; j < broken_into_l_arr_.size(); j++) { + for (int j =0; j < broken_into_l_arr_.size(); j++) + { Axis_group_spanner * my_broken_l = (Axis_group_spanner*)broken_into_l_arr_[j]; @@ -72,13 +80,16 @@ Axis_group_spanner::do_break_processing() if (broken_span_l) my_broken_l->add_element (broken_span_l); - } - } else if (elt->item() + } + } + else if (elt->item() && elt->item()->breakable_b_ - && elt->item()->break_status_i () == 0) { + && elt->item()->break_status_i () == 0) + { // broken items - for (int j =0; j < 2; j++) { + for (int j =0; j < 2; j++) + { Item * my_item = elt->item()->broken_to_a_[j]; Line_of_score * item_line_l = my_item->line_l() ; if ( ! item_line_l) @@ -88,26 +99,28 @@ Axis_group_spanner::do_break_processing() = (Axis_group_spanner*)find_broken_piece (item_line_l); if (v) v->add_element (my_item); - } + } - } - } else { + } + } + else + { /* this piece *does* know where it belongs. Put it in appropriate piece of this spanner */ Axis_group_spanner * my_broken_l = (Axis_group_spanner*)find_broken_piece (elt->line_l()); my_broken_l->add_element (elt); - } + } } - - Spanner::do_break_processing(); + + Spanner::do_break_processing(); } void Axis_group_spanner::do_print() const { - Axis_group_element::do_print(); + Axis_group_element::do_print(); } diff --git a/lily/axis-group.cc b/lily/axis-group.cc index 4e09739471..c0fff81760 100644 --- a/lily/axis-group.cc +++ b/lily/axis-group.cc @@ -13,33 +13,33 @@ /** don't copy anything: an element can only be in one Axis_group_element at one time. */ Axis_group_administration::Axis_group_administration ( - Axis_group_administration const&) + Axis_group_administration const&) { } bool Axis_group_administration::contains_b (Score_elem const *e)const { - return elem_l_arr_.find_l (e); + return elem_l_arr_.find_l (e); } Interval Axis_group_administration::extent (Axis axis)const { - Interval r; - for (int i=0; i < elem_l_arr_.size(); i++) + Interval r; + for (int i=0; i < elem_l_arr_.size(); i++) r.unite (elem_l_arr_[i]->extent (axis)); - return r; + return r; } void Axis_group_administration::add_element (Score_elem*e, Axis_group_element*g, Axis a1, Axis a2) { - assert (! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2]); - e->axis_group_l_a_[a1] = g; - e->axis_group_l_a_[a2] = g; - elem_l_arr_.push ( e); + assert (! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2]); + e->axis_group_l_a_[a1] = g; + e->axis_group_l_a_[a2] = g; + elem_l_arr_.push ( e); } @@ -47,22 +47,23 @@ Axis_group_administration::add_element (Score_elem*e, void Axis_group_administration::remove_element (Score_elem*e, Axis a1, Axis a2) { - assert (contains_b (e)); - elem_l_arr_.unordered_substitute (e,0); - - e->axis_group_l_a_[a1] = 0; - e->axis_group_l_a_[a2] = 0; + assert (contains_b (e)); + elem_l_arr_.unordered_substitute (e,0); + + e->axis_group_l_a_[a1] = 0; + e->axis_group_l_a_[a2] = 0; } void Axis_group_administration::remove_all (Axis a1, Axis a2) { - for (int i=0; i < elem_l_arr_.size(); i++) { + for (int i=0; i < elem_l_arr_.size(); i++) + { Score_elem*e=elem_l_arr_[i]; e->axis_group_l_a_[a1] = 0; e->axis_group_l_a_[a2] = 0; } - elem_l_arr_.clear(); + elem_l_arr_.clear(); } @@ -70,7 +71,7 @@ void Axis_group_administration::print() const { #ifndef NPRINT - for (int i=0; i < elem_l_arr_.size(); i++) + for (int i=0; i < elem_l_arr_.size(); i++) DOUT << elem_l_arr_[i]->name() << ' '; #endif } diff --git a/lily/axis.cc b/lily/axis.cc index 8217484340..d98d745b4c 100644 --- a/lily/axis.cc +++ b/lily/axis.cc @@ -12,5 +12,5 @@ String axis_name_str (Axis a) { - return String (a + 'x'); + return String (a + 'x'); } diff --git a/lily/bar-column-grav.cc b/lily/bar-column-grav.cc index 19b523cf78..4c073ac57e 100644 --- a/lily/bar-column-grav.cc +++ b/lily/bar-column-grav.cc @@ -15,36 +15,42 @@ Bar_column_engraver::Bar_column_engraver() { - bar_l_ =0; - barcol_p_ =0; + bar_l_ =0; + barcol_p_ =0; } void Bar_column_engraver::acknowledge_element (Score_elem_info info) { - if (info.elem_l_->is_type_b (Script::static_name()) + if (info.elem_l_->is_type_b (Script::static_name()) && info.req_l_->command() - && info.origin_grav_l_arr_.size() == 1) { + && info.origin_grav_l_arr_.size() == 1) + { script_l_arr_.push ((Script*)info.elem_l_->item()); - } else { + } + else + { if (info.origin_grav_l_arr_.size() == 1 && info.elem_l_->is_type_b (Bar::static_name())) bar_l_ = (Bar*)info.elem_l_->item(); } - if ( bar_l_ && !barcol_p_) { + if ( bar_l_ && !barcol_p_) + { barcol_p_ = new Bar_column; barcol_p_->breakable_b_ =true; barcol_p_->set_bar (bar_l_); announce_element (Score_elem_info (barcol_p_, 0)); } - if (barcol_p_) { - for (int i=0; i < script_l_arr_.size(); i++) { + if (barcol_p_) + { + for (int i=0; i < script_l_arr_.size(); i++) + { script_l_arr_[i]->breakable_b_ = true; barcol_p_->add (script_l_arr_[i]); - } + } script_l_arr_.clear(); } } @@ -52,7 +58,8 @@ Bar_column_engraver::acknowledge_element (Score_elem_info info) void Bar_column_engraver::do_pre_move_processing() { - if (barcol_p_) { + if (barcol_p_) + { typeset_element (barcol_p_); barcol_p_ =0; } @@ -61,8 +68,8 @@ Bar_column_engraver::do_pre_move_processing() void Bar_column_engraver::do_post_move_processing() { - script_l_arr_.clear(); - bar_l_ =0; + script_l_arr_.clear(); + bar_l_ =0; } IMPLEMENT_IS_TYPE_B1(Bar_column_engraver, Engraver); diff --git a/lily/bar-column.cc b/lily/bar-column.cc index 5f5dbf894b..f4c4d2f96b 100644 --- a/lily/bar-column.cc +++ b/lily/bar-column.cc @@ -11,22 +11,23 @@ Bar_column::Bar_column() { - bar_l_ =0; - breakable_b_ = true; + bar_l_ =0; + breakable_b_ = true; } void Bar_column::set_bar (Bar*b) { - Script_column::add_support (b); - bar_l_ = b; + Script_column::add_support (b); + bar_l_ = b; } void Bar_column::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Script_column::do_substitute_dependency (o,n); - if ( o == bar_l_) { + Script_column::do_substitute_dependency (o,n); + if ( o == bar_l_) + { bar_l_ = n ? (Bar*)n->item() : 0; } } diff --git a/lily/bar-grav.cc b/lily/bar-grav.cc index 740f5d5d04..c390c78a31 100644 --- a/lily/bar-grav.cc +++ b/lily/bar-grav.cc @@ -14,37 +14,43 @@ Bar_engraver::Bar_engraver() { - do_post_move_processing(); + do_post_move_processing(); } bool Bar_engraver::do_try_request (Request*r_l) { - Command_req* c_l = r_l->command(); - if (!c_l|| !c_l->bar()) + Command_req* c_l = r_l->command(); + if (!c_l|| !c_l->bar()) return false; - Bar_req * b= c_l->bar(); - if (bar_req_l_ && bar_req_l_->equal_b (b)) + Bar_req * b= c_l->bar(); + if (bar_req_l_ && bar_req_l_->equal_b (b)) return false; - - bar_req_l_ = b; + + bar_req_l_ = b; - return true; + return true; } void Bar_engraver::do_process_requests() { - if (bar_req_l_) { + if (bar_req_l_) + { bar_p_ = new Bar; bar_p_->type_str_=bar_req_l_->type_str_; - } else if (!get_staff_info().time_C_->whole_in_measure_) { + } + else if (!get_staff_info().time_C_->whole_in_measure_) + { bar_p_ = new Bar; } - - if (bar_p_){ + + if (bar_p_) + { announce_element (Score_elem_info (bar_p_, bar_req_l_)); - } else { + } + else + { Disallow_break_req r; daddy_grav_l_->try_request (&r); } @@ -54,7 +60,8 @@ Bar_engraver::do_process_requests() void Bar_engraver::do_pre_move_processing() { - if (bar_p_) { + if (bar_p_) + { typeset_element (bar_p_); bar_p_ =0; } @@ -63,8 +70,8 @@ Bar_engraver::do_pre_move_processing() void Bar_engraver::do_post_move_processing() { - bar_req_l_ = 0; - bar_p_ =0; + bar_req_l_ = 0; + bar_p_ =0; } diff --git a/lily/bar-number-grav.cc b/lily/bar-number-grav.cc index e824462a76..4a468119c7 100644 --- a/lily/bar-number-grav.cc +++ b/lily/bar-number-grav.cc @@ -15,8 +15,8 @@ Bar_number_grav::Bar_number_grav() { - number_i_ =1; - script_p_ =0; + number_i_ =1; + script_p_ =0; } static Command_script_req dummy; @@ -24,8 +24,9 @@ static Command_script_req dummy; void Bar_number_grav::acknowledge_element (Score_elem_info i) { - if (i.origin_grav_l_arr_.size() == 1 && - i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) { + if (i.origin_grav_l_arr_.size() == 1 && + i.elem_l_->is_type_b (Bar::static_name()) && !script_p_) + { script_p_ = new Script; Text_def *td_p =new Text_def; @@ -41,7 +42,8 @@ Bar_number_grav::acknowledge_element (Score_elem_info i) void Bar_number_grav::do_pre_move_processing() { - if ( script_p_) { + if ( script_p_) + { typeset_element (script_p_); script_p_ =0; } diff --git a/lily/bar.cc b/lily/bar.cc index 2f4b47b3b5..7dc97c7c59 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -15,9 +15,9 @@ Bar::Bar() { - breakable_b_ = true; - type_str_ = "|"; - spanned_i_ = 0; + breakable_b_ = true; + type_str_ = "|"; + spanned_i_ = 0; } @@ -27,17 +27,17 @@ IMPLEMENT_IS_TYPE_B1(Bar,Item); void Bar::do_print()const { - DOUT << type_str_; + DOUT << type_str_; } Molecule* Bar::brew_molecule_p()const { - Paper_def *p = paper(); - Symbol s = p->lookup_l()->bar (type_str_, + Paper_def *p = paper(); + Symbol s = p->lookup_l()->bar (type_str_, p->get_var ("bar_size")); - Molecule*output = new Molecule (Atom (s)); - return output; + Molecule*output = new Molecule (Atom (s)); + return output; } /** @@ -45,27 +45,28 @@ Bar::brew_molecule_p()const TODO: parametrise this (input-settable) */ static char const *bar_breaks[][3] ={ - {":|", ":|:", "|:"}, - {"|", "|", ""}, - {"", "|:", "|:"}, - {"||.", "||.", ""}, - {":|", ":|", ""}, - {0,0,0} + {":|", ":|:", "|:"}, + {"|", "|", ""}, + {"", "|:", "|:"}, + {"||.", "||.", ""}, + {":|", ":|", ""}, + {0,0,0} }; void Bar::do_pre_processing() { - for (int i=0; bar_breaks[i][0]; i++) { + for (int i=0; bar_breaks[i][0]; i++) + { if (bar_breaks[i][1] == type_str_) type_str_ = bar_breaks[i][break_status_i()+1]; } - /* - span_score_bar needs dims, so don't do + /* + span_score_bar needs dims, so don't do + + transparent_b_ = empty_b_ = (type_str_ == ""); - transparent_b_ = empty_b_ = (type_str_ == ""); - - */ + */ } - + diff --git a/lily/beam.cc b/lily/beam.cc index 1f595cddb6..70a1ce88d0 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -31,57 +31,57 @@ struct Stem_info { - Real x; - int dir_i_; - Real idealy_f_; - Real miny_f_; - int beams_i_; - - Stem_info(){} - Stem_info (Stem const *); + Real x; + int dir_i_; + Real idealy_f_; + Real miny_f_; + int beams_i_; + + Stem_info(){} + Stem_info (Stem const *); }; Stem_info::Stem_info (Stem const *s) { - x = s->hpos_f(); - dir_i_ = s->dir_i_; - beams_i_ = intlog2( s->flag_i_) - 2; + x = s->hpos_f(); + dir_i_ = s->dir_i_; + beams_i_ = intlog2( s->flag_i_) - 2; - /* - [todo] - * get algorithm + /* + [todo] + * get algorithm * runtime - Breitkopf + H\"artel: - miny_f_ = interline + #beams * interbeam + Breitkopf + H\"artel: + miny_f_ = interline + #beams * interbeam ideal8 = 2 * interline + interbeam ideal16,32,64,128 = 1.5 * interline + #beams * interbeam - * B\"arenreiter: - miny_f_ = interline + #beams * interbeam + * B\"arenreiter: + miny_f_ = interline + #beams * interbeam ideal8,16 = 2 interline + #beams * interbeam ideal32,64,128 = 1.5 interline + #beams * interbeam - - */ + + */ - Real notehead_y = s->paper()->interline_f (); - // huh? why do i need the / 2 + Real notehead_y = s->paper()->interline_f (); + // huh? why do i need the / 2 // Real interbeam_f = s->paper()->interbeam_f (); - Real interbeam_f = s->paper()->interbeam_f () / 2; - - /* well eh, huh? - idealy_f_ = dir_i_ * s->stem_start_f() + beams_i_ * interbeam_f; - if ( beams_i_ < 3) + Real interbeam_f = s->paper()->interbeam_f () / 2; + + /* well eh, huh? + idealy_f_ = dir_i_ * s->stem_start_f() + beams_i_ * interbeam_f; + if ( beams_i_ < 3) idealy_f_ += 2 * interline_f; - else + else idealy_f_ += 1.5 * interline_f; - */ + */ - idealy_f_ = dir_i_ * s->stem_end_f(); + idealy_f_ = dir_i_ * s->stem_end_f(); - miny_f_ = dir_i_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f; + miny_f_ = dir_i_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f; - idealy_f_ = miny_f_ >? idealy_f_; + idealy_f_ = miny_f_ >? idealy_f_; // assert (miny_f_ <= idealy_f_); } @@ -92,54 +92,58 @@ Stem_info::Stem_info (Stem const *s) Offset Beam::center()const { - Real w=(paper()->note_width () + width ().length ())/2.0; - return Offset (w, (left_pos + w* slope)*paper()->internote_f ()); + Real w=(paper()->note_width () + width ().length ())/2.0; + return Offset (w, (left_pos + w* slope)*paper()->internote_f ()); } Beam::Beam() { - slope = 0; - left_pos = 0.0; + slope = 0; + left_pos = 0.0; } void Beam::add (Stem*s) { - stems.push (s); - s->add_dependency (this); - s->print_flag_b_ = false; + stems.push (s); + s->add_dependency (this); + s->print_flag_b_ = false; } void Beam::set_default_dir() { - int up = 0, down = 0; - int up_count = 0, down_count = 0; + int up = 0, down = 0; + int up_count = 0, down_count = 0; - for (int i=0; i get_center_distance_from_top(); int cur_up = sl->get_center_distance_from_bottom(); - if (cur_down) { + if (cur_down) + { down += cur_down; down_count++; - } - if (cur_up) { + } + if (cur_up) + { up += cur_up; up_count++; - } + } } - if (!down) + if (!down) down_count = 1; - if (!up) + if (!up) up_count = 1; - // the following relation is equal to - // up / up_count > down / down_count - dir_i_ = (up * down_count > down * up_count) ? 1 : -1; + // the following relation is equal to + // up / up_count > down / down_count + dir_i_ = (up * down_count > down * up_count) ? 1 : -1; - for (int i=0; i dir_i_ = dir_i_; } @@ -156,8 +160,9 @@ Beam::set_default_dir() void Beam::solve_slope() { - Array sinfo; - for (int j=0; j sinfo; + for (int j=0; j set_default_extents(); @@ -167,53 +172,59 @@ Beam::solve_slope() Stem_info info (i); sinfo.push (info); } - if (! sinfo.size()) + if (! sinfo.size()) slope = left_pos = 0; - else if (sinfo.size() == 1) { + else if (sinfo.size() == 1) + { slope = 0; left_pos = sinfo[0].idealy_f_; - } else { + } + else + { Real leftx = sinfo[0].x; Least_squares l; - for (int i=0; i < sinfo.size(); i++) { + for (int i=0; i < sinfo.size(); i++) + { sinfo[i].x -= leftx; l.input.push (Offset (sinfo[i].x, sinfo[i].idealy_f_)); - } + } l.minimise (slope, left_pos); } - - Real dy = 0.0; - for (int i=0; i < sinfo.size(); i++) { + + Real dy = 0.0; + for (int i=0; i < sinfo.size(); i++) + { Real y = sinfo[i].x * slope + left_pos; Real my = sinfo[i].miny_f_; if (my - y > dy) dy = my -y; } - left_pos += dy; - left_pos *= dir_i_; + left_pos += dy; + left_pos *= dir_i_; - slope *= dir_i_; + slope *= dir_i_; - /* - This neat trick is by Werner Lemberg, damped = tanh (slope) corresponds - with some tables in [Wanske] - */ - slope = 0.6 * tanh (slope); + /* + This neat trick is by Werner Lemberg, damped = tanh (slope) corresponds + with some tables in [Wanske] + */ + slope = 0.6 * tanh (slope); // ugh - Real sl = slope*paper()->internote_f (); - paper()->lookup_l ()->beam (sl, 20 PT); - slope = sl /paper()->internote_f (); + Real sl = slope*paper()->internote_f (); + paper()->lookup_l ()->beam (sl, 20 PT); + slope = sl /paper()->internote_f (); } void Beam::set_stemlens() { - Real x0 = stems[0]->hpos_f(); - for (int j=0; j hpos_f(); + for (int j=0; j hpos_f()-x0; @@ -225,34 +236,36 @@ Beam::set_stemlens() void Beam::do_post_processing() { - if ( stems.size() < 2) { + if ( stems.size() < 2) + { warning ("Beam with less than 2 stems"); transparent_b_ = true; return ; } - solve_slope(); - set_stemlens(); + solve_slope(); + set_stemlens(); } void Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) { - def.OK(); - cur.OK(); - assert (cur.children.size() == stems.size ()); - - cur.split (def); + def.OK(); + cur.OK(); + assert (cur.children.size() == stems.size ()); + + cur.split (def); - Array b; - { + Array b; + { Array flags; - for (int j=0; j flag_i_))-2; assert (f>0); flags.push (f); - } + } int fi =0; b= cur.generate_beams (flags, fi); b.insert (0,0); @@ -260,7 +273,8 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) assert (stems.size() == b.size ()/2); } - for (int j=0, i=0; i < b.size() && j beams_left_i_ = b[i]; s->beams_right_i_ = b[i+1]; @@ -270,7 +284,7 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) void Beam::do_pre_processing() { - if (!dir_i_) + if (!dir_i_) set_default_dir(); } @@ -279,7 +293,7 @@ Beam::do_pre_processing() Interval Beam::do_width() const { - return Interval (stems[0]->hpos_f(), + return Interval (stems[0]->hpos_f(), stems.top()->hpos_f ()); } @@ -289,19 +303,20 @@ Beam::do_width() const Molecule Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const { - assert (!next || next->hpos_f() > here->hpos_f () ); - assert (!prev || prev->hpos_f() < here->hpos_f () ); + assert (!next || next->hpos_f() > here->hpos_f () ); + assert (!prev || prev->hpos_f() < here->hpos_f () ); // Real dy=paper()->internote_f ()*2; - Real dy = paper()->interbeam_f (); - Real stemdx = paper()->rule_thickness (); - Real sl = slope*paper()->internote_f (); - paper()->lookup_l ()->beam (sl, 20 PT); + Real dy = paper()->interbeam_f (); + Real stemdx = paper()->rule_thickness (); + Real sl = slope*paper()->internote_f (); + paper()->lookup_l ()->beam (sl, 20 PT); - Molecule leftbeams; - Molecule rightbeams; + Molecule leftbeams; + Molecule rightbeams; - /* half beams extending to the left. */ - if (prev) { + /* half beams extending to the left. */ + if (prev) + { int lhalfs= lhalfs = here->beams_left_i_ - prev->beams_right_i_ ; int lwholebeams= here->beams_left_i_ beams_right_i_ ; Real w = (here->hpos_f() - prev->hpos_f ())/4; @@ -310,14 +325,16 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const if (lhalfs) // generates warnings if not a = paper()->lookup_l ()->beam (sl, w); a.translate (Offset (-w, -w * sl)); - for (int j = 0; j < lhalfs; j++) { + for (int j = 0; j < lhalfs; j++) + { Atom b (a); b.translate (-dir_i_ * dy * (lwholebeams+j), Y_AXIS); leftbeams.add (b); - } + } } - if (next){ + if (next) + { int rhalfs = here->beams_right_i_ - next->beams_left_i_; int rwholebeams = here->beams_right_i_ beams_left_i_; @@ -325,25 +342,27 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev)const Atom a = paper()->lookup_l ()->beam (sl, w + stemdx); int j = 0; - for (; j < rwholebeams; j++) { + for (; j < rwholebeams; j++) + { Atom b (a); b.translate (-dir_i_ * dy * j, Y_AXIS); rightbeams.add (b); - } + } w /= 4; if (rhalfs) a = paper()->lookup_l ()->beam (sl, w); - for (; j < rwholebeams + rhalfs; j++) { + for (; j < rwholebeams + rhalfs; j++) + { Atom b (a); b.translate (-dir_i_ * dy * j, Y_AXIS); rightbeams.add (b); - } + } } - leftbeams.add (rightbeams); - return leftbeams; + leftbeams.add (rightbeams); + return leftbeams; } @@ -351,12 +370,13 @@ Molecule* Beam::brew_molecule_p() const { - Molecule *mol_p = new Molecule; - // huh? inter-what + Molecule *mol_p = new Molecule; + // huh? inter-what // Real inter_f = paper()->interbeam_f (); - Real inter_f = paper()->internote_f (); - Real x0 = stems[0]->hpos_f(); - for (int j=0; j internote_f (); + Real x0 = stems[0]->hpos_f(); + for (int j=0; j 0)? stems[j-1] : 0; Stem * next = (j < stems.size()-1) ? stems[j+1] :0; @@ -366,8 +386,8 @@ Beam::brew_molecule_p() const sb.translate (Offset (x, (x * slope + left_pos)* inter_f)); mol_p->add (sb); } - mol_p->translate (x0 - left_col_l_->hpos_f_, X_AXIS); - return mol_p; + mol_p->translate (x0 - left_col_l_->hpos_f_, X_AXIS); + return mol_p; } @@ -377,15 +397,16 @@ void Beam::do_print()const { #ifndef NPRINT - DOUT << "slope " <is_type_b (Stem::static_name())) { + if (o->is_type_b (Stem::static_name())) + { stems.substitute ((Stem*)o->item(), n?(Stem*) n->item ():0); } } diff --git a/lily/bow.cc b/lily/bow.cc index 728f9817a6..1ef733c61a 100644 --- a/lily/bow.cc +++ b/lily/bow.cc @@ -13,46 +13,46 @@ Bow::Bow() { - left_pos_i_ = right_pos_i_ = 0; - left_dx_f_ = right_dx_f_ = 0.0; + left_pos_i_ = right_pos_i_ = 0; + left_dx_f_ = right_dx_f_ = 0.0; } Offset Bow::center() const { - int dy = right_pos_i_-left_pos_i_; + int dy = right_pos_i_-left_pos_i_; - Real w = width().length (); + Real w = width().length (); - return Offset (w/2,dy * paper()->internote_f ()); + return Offset (w/2,dy * paper()->internote_f ()); } Molecule* Bow::brew_molecule_p() const { - Molecule*output = new Molecule; - Real w = width().length (); - - int dy = right_pos_i_ - left_pos_i_; - - Real nw_f = paper()->note_width (); - Real nh_f = paper()->internote_f (); - - - w+= (right_dx_f_ - left_dx_f_) * nw_f ; - Real round_w = w; // slur lookup rounds the slurwidth . - - Symbol sl = paper()->lookup_l ()->slur (dy , round_w, dir_i_); - - Real error = w-round_w; - - Atom a (sl); - a.translate (Offset ((left_dx_f_ + 0.5)*nw_f + error/2, + Molecule*output = new Molecule; + Real w = width().length (); + + int dy = right_pos_i_ - left_pos_i_; + + Real nw_f = paper()->note_width (); + Real nh_f = paper()->internote_f (); + + + w+= (right_dx_f_ - left_dx_f_) * nw_f ; + Real round_w = w; // slur lookup rounds the slurwidth . + + Symbol sl = paper()->lookup_l ()->slur (dy , round_w, dir_i_); + + Real error = w-round_w; + + Atom a (sl); + a.translate (Offset ((left_dx_f_ + 0.5)*nw_f + error/2, left_pos_i_ * nh_f)); - output->add (a); - return output; + output->add (a); + return output; } diff --git a/lily/boxes.cc b/lily/boxes.cc index 756ce87757..4a219a4864 100644 --- a/lily/boxes.cc +++ b/lily/boxes.cc @@ -8,7 +8,7 @@ Box::Box() Box::Box (Interval ix, Interval iy) { - x() = ix; - y() = iy; + x() = ix; + y() = iy; } diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index d3c9e5df79..b2ffbaee60 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -12,8 +12,8 @@ void Break_align_item::do_pre_processing() { - align_i_ = break_status_i(); - Horizontal_align_item::do_pre_processing(); + align_i_ = break_status_i(); + Horizontal_align_item::do_pre_processing(); } IMPLEMENT_IS_TYPE_B1(Break_align_item, Horizontal_align_item); diff --git a/lily/break.cc b/lily/break.cc index 2fb1935dfe..3ebba2eb63 100644 --- a/lily/break.cc +++ b/lily/break.cc @@ -17,26 +17,26 @@ String Col_stats::str() const { - String s (count_i_); - s += " lines"; - if (count_i_) + String s (count_i_); + s += " lines"; + if (count_i_) s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)"); - - return s; + + return s; } void Col_stats::add (Line_of_cols const& line) { - count_i_++; - cols_i_ += line.size(); + count_i_++; + cols_i_ += line.size(); } Col_stats::Col_stats() { - count_i_ =0; - cols_i_ =0; + count_i_ =0; + cols_i_ =0; } /* **************************************************************** */ @@ -44,49 +44,50 @@ Col_stats::Col_stats() Line_of_cols Break_algorithm::all_cols()const { - Line_of_cols retval; - for (PCursor c (pscore_l_->col_p_list_.top()); - c.ok(); c++) { + Line_of_cols retval; + for (PCursor c (pscore_l_->col_p_list_.top()); + c.ok(); c++) + { retval.push (c); } - return retval; + return retval; } Array Break_algorithm::find_break_indices() const { - Line_of_cols all (all_cols()); - Array retval; - - for (int i=0; i < all.size(); i++) + Line_of_cols all (all_cols()); + Array retval; + + for (int i=0; i < all.size(); i++) if (all[i]->breakable_b()) retval.push (i); - - if ( linelength <=0) + + if ( linelength <=0) while ( retval.size() >2) retval.del (1); - return retval; + return retval; } /// return all breakable columns Line_of_cols Break_algorithm::find_breaks() const { - Line_of_cols all (all_cols()); - Line_of_cols retval; - - for (int i=0; i < all.size(); i++) + Line_of_cols all (all_cols()); + Line_of_cols retval; + + for (int i=0; i < all.size(); i++) if (all[i]->breakable_b()) retval.push (all[i]); - if ( linelength <=0) + if ( linelength <=0) while ( retval.size() >2) retval.del (1); - return retval; + return retval; } @@ -96,86 +97,86 @@ Break_algorithm::find_breaks() const Line_spacer* Break_algorithm::generate_spacing_problem (Line_of_cols curline)const { - Line_spacer * sp= (*get_line_spacer)(); + Line_spacer * sp= (*get_line_spacer)(); - sp->paper_l_ = pscore_l_->paper_l_; - sp->add_column (curline[0], true, 0.0); - for (int i=1; i< curline.size()-1; i++) + sp->paper_l_ = pscore_l_->paper_l_; + sp->add_column (curline[0], true, 0.0); + for (int i=1; i< curline.size()-1; i++) sp->add_column (curline[i]); - if ( linelength > 0) + if ( linelength > 0) sp->add_column (curline.top(), true, linelength); - else + else sp->add_column (curline.top()); - sp->prepare(); - return sp; + sp->prepare(); + return sp; } Break_algorithm::Break_algorithm() { - pscore_l_ = 0; - get_line_spacer =0; - linelength = 0; + pscore_l_ = 0; + get_line_spacer =0; + linelength = 0; } void Break_algorithm::set_pscore (Paper_score*s) { - pscore_l_ = s; - linelength = s->paper_l_->linewidth_f(); - do_set_pscore(); + pscore_l_ = s; + linelength = s->paper_l_->linewidth_f(); + do_set_pscore(); } bool Break_algorithm::feasible (Line_of_cols curline) const { - if (linelength <= 0) + if (linelength <= 0) return true; - - Real l =0; - for (int i=0; i < curline.size(); i++) + + Real l =0; + for (int i=0; i < curline.size(); i++) l +=curline[i]->width().length (); - return l < linelength; + return l < linelength; } void Break_algorithm::problem_OK() const { - if (!pscore_l_->col_p_list_.size()) + if (!pscore_l_->col_p_list_.size()) error ("Score does not have any columns"); - OK(); + OK(); } void Break_algorithm::OK()const { #ifndef NDEBUG - iter_top (pscore_l_->col_p_list_,start); - PCursor end (pscore_l_->col_p_list_.bottom()); - - assert (start->breakable_b()); - assert (end->breakable_b()); + iter_top (pscore_l_->col_p_list_,start); + PCursor end (pscore_l_->col_p_list_.bottom()); + + assert (start->breakable_b()); + assert (end->breakable_b()); #endif } Array Break_algorithm::solve()const { - return do_solve(); + return do_solve(); } void Break_algorithm::do_set_pscore() { - + } void Break_algorithm::print_stats()const { - if (approx_stats_.count_i_) + if (approx_stats_.count_i_) *mlog << "\nApproximated: " << approx_stats_.str() << "\n"; - if (exact_stats_.count_i_) + if (exact_stats_.count_i_) *mlog << "Calculated exactly: " << exact_stats_.str() << "\n"; } diff --git a/lily/clef-grav.cc b/lily/clef-grav.cc index 93abaf2931..1afaa3cc44 100644 --- a/lily/clef-grav.cc +++ b/lily/clef-grav.cc @@ -16,46 +16,55 @@ Clef_engraver::Clef_engraver() { - clef_p_ = 0; - clef_req_l_ =0; - - set_type ("violin"); + clef_p_ = 0; + clef_req_l_ =0; + + set_type ("violin"); } bool Clef_engraver::set_type (String s) { - clef_type_str_ = s; - if (clef_type_str_ == "violin") { + clef_type_str_ = s; + if (clef_type_str_ == "violin") + { c0_position_i_= -2; - } else if (clef_type_str_ == "alto") { + } + else if (clef_type_str_ == "alto") + { c0_position_i_= 4; - } else if (clef_type_str_ == "tenor") { + } + else if (clef_type_str_ == "tenor") + { c0_position_i_= 6; - } else if (clef_type_str_ == "bass") { + } + else if (clef_type_str_ == "bass") + { c0_position_i_= 10; - } else + } + else return false; - - return true; + + return true; } void Clef_engraver::fill_staff_info (Staff_info &i) { - i.c0_position_i_l_ = &c0_position_i_; + i.c0_position_i_l_ = &c0_position_i_; } void Clef_engraver::read_req (Clef_change_req*c_l) { - if (!set_type (c_l->clef_str_)) + if (!set_type (c_l->clef_str_)) c_l->error ("unknown clef type "); } void Clef_engraver::acknowledge_element (Score_elem_info info) { - if (info.elem_l_->name() == Bar::static_name ()) { + if (info.elem_l_->name() == Bar::static_name ()) + { create_clef(); if ( !clef_req_l_) clef_p_->default_b_ = true; @@ -65,37 +74,39 @@ Clef_engraver::acknowledge_element (Score_elem_info info) void Clef_engraver::do_creation_processing() { - create_clef(); - clef_p_->default_b_ = false; + create_clef(); + clef_p_->default_b_ = false; } bool Clef_engraver::do_try_request (Request * r_l) { - Command_req* creq_l= r_l->command(); - if (!creq_l || !creq_l->clefchange()) + Command_req* creq_l= r_l->command(); + if (!creq_l || !creq_l->clefchange()) return false; - clef_req_l_ = creq_l->clefchange(); - - read_req (clef_req_l_); - return true; + clef_req_l_ = creq_l->clefchange(); + + read_req (clef_req_l_); + return true; } void Clef_engraver::create_clef() { - if (!clef_p_) { + if (!clef_p_) + { clef_p_ = new Clef_item; - announce_element (Score_elem_info (clef_p_,clef_req_l_)); + announce_element (Score_elem_info (clef_p_,clef_req_l_)); } - clef_p_->read (*this); + clef_p_->read (*this); } void Clef_engraver::do_process_requests() { - if (clef_req_l_) { + if (clef_req_l_) + { create_clef(); clef_p_->default_b_ = false; } @@ -104,23 +115,23 @@ Clef_engraver::do_process_requests() void Clef_engraver::do_pre_move_processing() { - if (!clef_p_) + if (!clef_p_) return; - typeset_element (clef_p_); - clef_p_ = 0; + typeset_element (clef_p_); + clef_p_ = 0; } - + void Clef_engraver::do_post_move_processing() { - clef_req_l_ = 0; + clef_req_l_ = 0; } void Clef_engraver::do_removal_processing() { - delete clef_p_; - clef_p_ =0; + delete clef_p_; + clef_p_ =0; } diff --git a/lily/clef-item.cc b/lily/clef-item.cc index b1a9c4a665..8a2534b111 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -17,9 +17,10 @@ void Clef_item::do_pre_processing() { - change_b_ = ! (break_status_i() == 1); + change_b_ = ! (break_status_i() == 1); - if (default_b_){ + if (default_b_) + { empty_b_ = (break_status_i() != 1); transparent_b_ = (break_status_i() != 1); } @@ -27,41 +28,41 @@ Clef_item::do_pre_processing() Clef_item::Clef_item() { - breakable_b_ =true; - default_b_ = false; - change_b_ = true; - read ("violin"); + breakable_b_ =true; + default_b_ = false; + change_b_ = true; + read ("violin"); } void Clef_item::read (String t) { - type_= t; - if (type_ == "violin") + type_= t; + if (type_ == "violin") y_off = 2; - if (type_ == "alto") + if (type_ == "alto") y_off = 4; - if (type_ == "tenor") + if (type_ == "tenor") y_off = 6; - if (type_ == "bass") + if (type_ == "bass") y_off = 6; } void Clef_item::read (Clef_engraver const &k) { - read (k.clef_type_str_); + read (k.clef_type_str_); } Molecule* Clef_item::brew_molecule_p()const { - String t = type_; - if (change_b_) + String t = type_; + if (change_b_) t += "_change"; - Symbol s = paper()->lookup_l ()->clef (t); - Molecule*output = new Molecule (Atom (s)); - output->translate (paper()->internote_f () * y_off, Y_AXIS); - return output; + Symbol s = paper()->lookup_l ()->clef (t); + Molecule*output = new Molecule (Atom (s)); + output->translate (paper()->internote_f () * y_off, Y_AXIS); + return output; } diff --git a/lily/col-info.cc b/lily/col-info.cc index deb2dee730..e05498f0e1 100644 --- a/lily/col-info.cc +++ b/lily/col-info.cc @@ -14,28 +14,28 @@ void Colinfo::print() const { #ifndef NPRINT - DOUT << "column { "; - if (fixed()) + DOUT << "column { "; + if (fixed()) DOUT << "fixed at " << fixed_position()<<", "; - assert (pcol_l_); - DOUT << "[" << minleft() << ", " << minright () << "]"; - DOUT <<"}\n"; + assert (pcol_l_); + DOUT << "[" << minleft() << ", " << minright () << "]"; + DOUT <<"}\n"; #endif } Colinfo::Colinfo (PCol *col_l, Real const *fixed_C) { - if (fixed_C) + if (fixed_C) fixpos_p_.set_l (fixed_C); - ugh_b_ = false; - pcol_l_ = col_l; - width = pcol_l_->width(); + ugh_b_ = false; + pcol_l_ = col_l; + width = pcol_l_->width(); } Colinfo::Colinfo() { - ugh_b_ = false; - pcol_l_ =0; + ugh_b_ = false; + pcol_l_ =0; } diff --git a/lily/colhpos.cc b/lily/colhpos.cc index 23d42e65ff..d7850f5c27 100644 --- a/lily/colhpos.cc +++ b/lily/colhpos.cc @@ -14,10 +14,10 @@ Col_hpositions::Col_hpositions() { - energy_f_ = infinity_f; - ugh_b_ = false; - satisfies_constraints_b_ = false; - spacer_l_ =0; + energy_f_ = infinity_f; + ugh_b_ = false; + satisfies_constraints_b_ = false; + spacer_l_ =0; } Col_hpositions::~Col_hpositions() @@ -28,17 +28,17 @@ Col_hpositions::~Col_hpositions() void Col_hpositions::add (PCol*c) { - cols.push (c); + cols.push (c); } void Col_hpositions::print() const { #ifndef NPRINT - DOUT << "energy : " << energy_f_ << '\n'; - DOUT << "line of " << config.size() << " cols\n"; - Vector v (config); - DOUT << v; + DOUT << "energy : " << energy_f_ << '\n'; + DOUT << "line of " << config.size() << " cols\n"; + Vector v (config); + DOUT << v; #endif } @@ -46,29 +46,29 @@ void Col_hpositions::OK()const { #ifndef NDEBUG - assert (config.size() == cols.size ()); + assert (config.size() == cols.size ()); #endif } void Col_hpositions::stupid_solution() { - energy_f_ = infinity_f; - ugh_b_ = true; - config = spacer_l_->default_solution(); + energy_f_ = infinity_f; + ugh_b_ = true; + config = spacer_l_->default_solution(); } void Col_hpositions::solve_line() { - spacer_l_->solve (this); + spacer_l_->solve (this); } void Col_hpositions::approximate_solve_line() { - spacer_l_->lower_bound_solution (this); + spacer_l_->lower_bound_solution (this); } diff --git a/lily/collision-grav.cc b/lily/collision-grav.cc index 600703bcd2..e25f249493 100644 --- a/lily/collision-grav.cc +++ b/lily/collision-grav.cc @@ -13,27 +13,29 @@ void Collision_engraver::acknowledge_element (Score_elem_info i) { - if (!(i.elem_l_->name() == Note_column::static_name ())) + if (!(i.elem_l_->name() == Note_column::static_name ())) return; - if (!col_p_) { + if (!col_p_) + { col_p_ = new Collision; announce_element (Score_elem_info (col_p_,0)); } - col_p_->add ((Note_column*)i.elem_l_->item()); + col_p_->add ((Note_column*)i.elem_l_->item()); } void Collision_engraver::do_pre_move_processing() { - if (col_p_) { + if (col_p_) + { typeset_element (col_p_); col_p_ =0; } } Collision_engraver::Collision_engraver() { - col_p_ =0; + col_p_ =0; } diff --git a/lily/collision.cc b/lily/collision.cc index 798c74be45..a5fd6aee0b 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -18,9 +18,9 @@ Collision::Collision() void Collision::add (Note_column* ncol_l) { - clash_l_arr_.push (ncol_l); - add_element (ncol_l); - add_dependency (ncol_l); + clash_l_arr_.push (ncol_l); + add_element (ncol_l); + add_dependency (ncol_l); } /** should derive of Array. @@ -28,11 +28,11 @@ Collision::add (Note_column* ncol_l) static int idx (int dir, bool h_shift_b) { - assert (abs (dir) == 1); - int j = dir > 0 ? 0 : 3; - if ( h_shift_b) + assert (abs (dir) == 1); + int j = dir > 0 ? 0 : 3; + if ( h_shift_b) j += dir; - return j; + return j; } /** This complicated routine moves note columns around horizontally @@ -46,101 +46,114 @@ int idx (int dir, bool h_shift_b) void Collision::do_pre_processing() { - if (clash_l_arr_.size() <= 1) + if (clash_l_arr_.size() <= 1) return; - - /* - [stem up, stem up shifted, stem down shifted, stem down] - */ - Array clash_group_arr_a[4]; - - for (int i=0; i < clash_l_arr_.size(); i++) { + + /* + [stem up, stem up shifted, stem down shifted, stem down] + */ + Array clash_group_arr_a[4]; + + for (int i=0; i < clash_l_arr_.size(); i++) + { Note_column* c_l = clash_l_arr_[i]; - if (! c_l->dir_i_) { + if (! c_l->dir_i_) + { warning ("No stem direction set. Ignoring column in clash. "); continue; - } + } int d = (c_l->dir_i_); clash_group_arr_a[idx (d, c_l->h_shift_b_)].push (c_l); } - - - for (int j=0; j < 4; j++) { - if (clash_group_arr_a[j].size() > 1) { + + + for (int j=0; j < 4; j++) + { + if (clash_group_arr_a[j].size() > 1) + { warning ("Too many clashing notecolumns. Ignoring them."); return; - } + } } - int d = 1; - do { - if (!clash_group_arr_a[idx (d, false)].size()){ + int d = 1; + do + { + if (!clash_group_arr_a[idx (d, false)].size()) + { clash_group_arr_a[idx (d, false)] = clash_group_arr_a[idx (d, true)]; clash_group_arr_a[idx (d, true)].clear(); - } - } while ((d *= -1) != 1); + } + } while ((d *= -1) != 1); - Interval_t y_extent[4]; - Note_column * col_l_a[4]; - Real x_off [4]; - int y_off[4]; - - for (int j =0 ; j < 4; j++) { + Interval_t y_extent[4]; + Note_column * col_l_a[4]; + Real x_off [4]; + int y_off[4]; + + for (int j =0 ; j < 4; j++) + { if (clash_group_arr_a[j].size()) col_l_a[j] = clash_group_arr_a[j][0]; else col_l_a[j] = 0; - if (col_l_a[j]) { + if (col_l_a[j]) + { y_extent[j] = col_l_a[j]->head_positions_interval(); - } + } x_off [j] = 0.0; y_off[j] = 0; } - - do { + + do + { x_off[idx (d, true)] = d*0.5; - } while ((d *= -1) != 1); + } while ((d *= -1) != 1); - // y_extent: smallest y-pos noteball interval containing all balls - // 4 (0..3) groups: stem up/down; shift on/off; - Interval_t middle (y_extent[idx (-1,0)].max(), + // y_extent: smallest y-pos noteball interval containing all balls + // 4 (0..3) groups: stem up/down; shift on/off; + Interval_t middle (y_extent[idx (-1,0)].max(), y_extent[idx (1,0)].min()); - Interval_t open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1); - do{ + Interval_t open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1); + do + { if (!open_middle.contains_b (y_extent[idx (d,true)])) x_off[idx (d, true)] = d *1.0 ; - } while ((d *= -1) != 1); + } while ((d *= -1) != 1); - if (!middle.empty_b() + if (!middle.empty_b() && middle.length() < 2 && col_l_a[idx (1,0)] && col_l_a[idx (-1,0)]) { // reproduction of bugfix at 3am ? Note_head * nu_l= col_l_a[idx (1,0)]->head_l_arr_[0]; Note_head * nd_l = col_l_a[idx (-1,0)]->head_l_arr_.top(); if (! (nu_l->balltype_i_ == nd_l->balltype_i_ - && nu_l->dots_i_ == nd_l->dots_i_ && middle.length() == 0)) { + && nu_l->dots_i_ == nd_l->dots_i_ && middle.length() == 0)) + { x_off[idx (1,0)] -= 0.5; x_off[idx (1,1)] -= 0.5; x_off[idx (-1,1)] += 0.5; x_off[idx (-1,0)] += 0.5; - } + } - } - Real inter_f = paper()->internote_f (); - Real wid_f = paper()->note_width (); - for (int j=0; j < 4; j++) { - if (col_l_a[j]) { + } + Real inter_f = paper()->internote_f (); + Real wid_f = paper()->note_width (); + for (int j=0; j < 4; j++) + { + if (col_l_a[j]) + { /* collision.cc:138: request for method `translate' is ambiguous (shaddup) */ Offset o (x_off[j] * wid_f, y_off[j] * inter_f); ((Score_elem*)col_l_a[j])->translate (o); - } + } } } @@ -150,6 +163,6 @@ IMPLEMENT_IS_TYPE_B1(Collision, Item); void Collision::do_substitute_dependency (Score_elem*o_l,Score_elem*n_l) { - clash_l_arr_.substitute ((Note_column*)o_l->item(), + clash_l_arr_.substitute ((Note_column*)o_l->item(), (Note_column*)(n_l?n_l->item():0)); } diff --git a/lily/command-request.cc b/lily/command-request.cc index 1c77d60f0f..051ce84465 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -24,21 +24,21 @@ void Cadenza_req::do_print()const { #ifndef NPRINT - DOUT << on_b_; + DOUT << on_b_; #endif } bool Cadenza_req::do_equal_b (Request*r)const { - Cadenza_req*cad = r->command()->timing ()->cadenza (); - - return cad->on_b_ == on_b_; + Cadenza_req*cad = r->command()->timing ()->cadenza (); + + return cad->on_b_ == on_b_; } Cadenza_req::Cadenza_req (bool b) { - on_b_ =b; + on_b_ =b; } /* *************** */ @@ -46,8 +46,8 @@ Cadenza_req::Cadenza_req (bool b) bool Bar_req::do_equal_b (Request*r)const { - Bar_req * b = r->command()->bar (); - return type_str_ == b->type_str_; + Bar_req * b = r->command()->bar (); + return type_str_ == b->type_str_; } @@ -56,25 +56,25 @@ IMPLEMENT_IS_TYPE_B1(Bar_req,Command_req); void Bar_req::do_print() const { - DOUT << type_str_; + DOUT << type_str_; } Bar_req::Bar_req (String s) { - type_str_ = s; + type_str_ = s; } Partial_measure_req::Partial_measure_req (Moment m) { - duration_ =m; + duration_ =m; } bool Partial_measure_req::do_equal_b (Request* r)const { - Partial_measure_req *p = r->command()->timing ()->partial (); + Partial_measure_req *p = r->command()->timing ()->partial (); - return p->duration_ == duration_; + return p->duration_ == duration_; } @@ -105,7 +105,7 @@ Barcheck_req::do_print() const{} bool Barcheck_req::do_equal_b (Request*)const { - return true; + return true; } /* *************** */ @@ -115,13 +115,13 @@ void Clef_change_req::do_print() const { #ifndef NPRINT - DOUT << clef_str_ ; + DOUT << clef_str_ ; #endif } Clef_change_req::Clef_change_req (String s) { - clef_str_ = s; + clef_str_ = s; } /* *************** */ @@ -131,7 +131,7 @@ void Group_feature_req::do_print() const { #ifndef NPRINT - DOUT << type_str_ << "=" << value_str_; + DOUT << type_str_ << "=" << value_str_; #endif } @@ -143,7 +143,7 @@ IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req); void Partial_measure_req::do_print() const { - DOUT << duration_; + DOUT << duration_; } @@ -153,52 +153,52 @@ void Meter_change_req::do_print() const { #ifndef NPRINT - DOUT << beats_i_ << "/" << one_beat_i_; + DOUT << beats_i_ << "/" << one_beat_i_; #endif } bool Meter_change_req::do_equal_b (Request * r)const { - Meter_change_req * m = r->command()->timing ()->meterchange (); - - return m->beats_i_ == beats_i_ + Meter_change_req * m = r->command()->timing ()->meterchange (); + + return m->beats_i_ == beats_i_ && one_beat_i_ == m->one_beat_i_; } Meter_change_req::Meter_change_req() { - beats_i_ = 0; - one_beat_i_ =0; + beats_i_ = 0; + one_beat_i_ =0; } void Meter_change_req::set (int b,int o) { - beats_i_=b; - one_beat_i_=o; + beats_i_=b; + one_beat_i_=o; } Tempo_req::Tempo_req() { - metronome_i_ = 60; - dur_. type_i_ = 4; + metronome_i_ = 60; + dur_. durlog_i_ = 2; } void Tempo_req::do_print()const { - DOUT << dur_.str() << " = " <transpose (d); } } @@ -237,7 +239,8 @@ IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req); void Key_change_req::squash_octaves() { - for (int i=0; i < melodic_p_arr_.size(); i++) { + for (int i=0; i < melodic_p_arr_.size(); i++) + { melodic_p_arr_[i]->octave_i_ = 0; } } @@ -246,7 +249,8 @@ void Key_change_req::do_print() const { #ifndef NPRINT - for (int i=0; i < melodic_p_arr_.size(); i++) { + for (int i=0; i < melodic_p_arr_.size(); i++) + { melodic_p_arr_[i]->print(); } #endif @@ -276,12 +280,13 @@ int Key_change_req::flats_i() { int flats_i = 0; - for ( int i = 0; i < melodic_p_arr_.size(); i++) { + for ( int i = 0; i < melodic_p_arr_.size(); i++) + { Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert (mel_l); if ( mel_l->accidental_i_ < 0) flats_i -= mel_l->accidental_i_; - } + } return flats_i; } @@ -295,12 +300,13 @@ int Key_change_req::sharps_i() { int sharps_i = 0; - for ( int i = 0; i < melodic_p_arr_.size(); i++) { + for ( int i = 0; i < melodic_p_arr_.size(); i++) + { Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert (mel_l); if ( mel_l->accidental_i_ > 0) sharps_i+= mel_l->accidental_i_; - } + } return sharps_i; } diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 574b91c9ff..d5c16cb442 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -15,16 +15,16 @@ Crescendo::Crescendo() { - grow_dir_i_ =0; - dir_i_ = -1 ; - left_dyn_b_ = right_dyn_b_ =false; - inside_staff_b_ = false; + grow_dir_i_ =0; + dir_i_ = -1 ; + left_dyn_b_ = right_dyn_b_ =false; + inside_staff_b_ = false; } Interval Crescendo::symbol_height()const { - return get_symbol().dim[Y_AXIS]; + return get_symbol().dim[Y_AXIS]; } static Real absdyn_dim = 10 PT; // ugh @@ -32,35 +32,38 @@ static Real absdyn_dim = 10 PT; // ugh Symbol Crescendo::get_symbol()const { - Real w_dim = width().length (); - if ( left_dyn_b_) { + Real w_dim = width().length (); + if ( left_dyn_b_) + { w_dim -= absdyn_dim; } - if ( right_dyn_b_) { + if ( right_dyn_b_) + { w_dim -= absdyn_dim; } - - if (w_dim < 0) { + + if (w_dim < 0) + { warning ("Crescendo too small"); w_dim = 0; } - return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_i_ < 0)); + return Symbol (paper()->lookup_l ()->hairpin (w_dim, grow_dir_i_ < 0)); } Molecule* Crescendo::brew_molecule_p() const { - Molecule* m_p =0; - Real x_off_dim=0.0; - if ( left_dyn_b_) + Molecule* m_p =0; + Real x_off_dim=0.0; + if ( left_dyn_b_) x_off_dim += absdyn_dim; - - m_p = new Molecule; - Symbol s (get_symbol()); - m_p->add (Atom (s)); - m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ())); - return m_p; + + m_p = new Molecule; + Symbol s (get_symbol()); + m_p->add (Atom (s)); + m_p->translate (Offset (x_off_dim, pos_i_ * paper()->internote_f ())); + return m_p; } diff --git a/lily/debug.cc b/lily/debug.cc index 964353f348..2141be63a4 100644 --- a/lily/debug.cc +++ b/lily/debug.cc @@ -13,11 +13,13 @@ ostream * nulldev =0; // ugh struct _Dinit { - _Dinit() { + _Dinit() + { nulldev = new ofstream ("/dev/null"); monitor = new Dstream (&cout,".dstreamrc"); } - ~_Dinit() { + ~_Dinit() + { delete nulldev; delete monitor; } @@ -31,14 +33,14 @@ struct _Dinit { void mynewhandler() { - assert (false); + assert (false); } void float_handler (int) { - cerr << "Floating point exception .. \n"<< flush; - assert (false); + cerr << "Floating point exception .. \n"<< flush; + assert (false); } /// just to make sure print_rat is linked in @@ -47,13 +49,13 @@ static void (*rat_printer)(Moment const&); void debug_init() { - rat_printer = print_rat; + rat_printer = print_rat; #ifndef NDEBUG - set_new_handler (&mynewhandler); + set_new_handler (&mynewhandler); #endif - set_flower_debug (*monitor, check_debug); - - signal (SIGFPE, float_handler); + set_flower_debug (*monitor, check_debug); + + signal (SIGFPE, float_handler); } bool check_debug=false; @@ -61,8 +63,8 @@ bool check_debug=false; void set_debug (bool b) { - check_debug =b; - set_flower_debug (*monitor, check_debug); + check_debug =b; + set_flower_debug (*monitor, check_debug); } diff --git a/lily/dimen.cc b/lily/dimen.cc index 4809adb951..73fa9d3ca7 100644 --- a/lily/dimen.cc +++ b/lily/dimen.cc @@ -6,34 +6,35 @@ Real parse_dimen (String dim) { - int i=dim.length_i()-1; - char const *s = dim; - while (i > 0 && (isspace (s[i]) || isalpha (s[i]))){ + int i=dim.length_i()-1; + char const *s = dim; + while (i > 0 && (isspace (s[i]) || isalpha (s[i]))) + { i--; } - String unit (s + i+1); - return convert_dimen (dim.value_f(), unit); + String unit (s + i+1); + return convert_dimen (dim.value_f(), unit); } Real convert_dimen (Real quant, String unit) { - if (unit == "cm") + if (unit == "cm") return quant * CM_TO_PT; - if (unit == "pt") + if (unit == "pt") return quant; - if (unit == "mm") + if (unit == "mm") return quant*CM_TO_PT/10; - if (unit == "in") + if (unit == "in") return quant * INCH_TO_PT; - error ("unknown length unit: `" + unit+"'"); + error ("unknown length unit: `" + unit+"'"); } String print_dimen (Real r) { - String s (r, "%.3f"); - s += "pt "; - return s; + String s (r, "%.3f"); + s += "pt "; + return s; } diff --git a/lily/directional-spanner.cc b/lily/directional-spanner.cc index 0e1c058f49..837fae76d9 100644 --- a/lily/directional-spanner.cc +++ b/lily/directional-spanner.cc @@ -3,17 +3,17 @@ void Directional_spanner::set_default_dir() { - dir_i_ = -1; + dir_i_ = -1; } void Directional_spanner::do_pre_processing() { - if (!dir_i_) + if (!dir_i_) set_default_dir(); } Directional_spanner::Directional_spanner() { - dir_i_ = 0; + dir_i_ = 0; } diff --git a/lily/dynamic-grav.cc b/lily/dynamic-grav.cc index 6bfe5585d7..a159d32d72 100644 --- a/lily/dynamic-grav.cc +++ b/lily/dynamic-grav.cc @@ -18,35 +18,37 @@ Dynamic_engraver::Dynamic_engraver() { - dir_i_ =0; - do_post_move_processing(); - dynamic_p_ =0; - to_end_cresc_p_ = cresc_p_ = 0; - cresc_req_l_ = 0; + dir_i_ =0; + do_post_move_processing(); + dynamic_p_ =0; + to_end_cresc_p_ = cresc_p_ = 0; + cresc_req_l_ = 0; } void Dynamic_engraver::do_post_move_processing() { - dynamic_req_l_arr_.clear(); + dynamic_req_l_arr_.clear(); } bool Dynamic_engraver::do_try_request (Request * r) { - Musical_req * m = r->musical(); - if (!m || !m->dynamic()) + Musical_req * m = r->musical(); + if (!m || !m->dynamic()) return false; - dynamic_req_l_arr_.push (m->dynamic()); - return true; + dynamic_req_l_arr_.push (m->dynamic()); + return true; } void Dynamic_engraver::do_process_requests() { - Crescendo* new_cresc_p=0; - for (int i=0; i < dynamic_req_l_arr_.size(); i++) { + Crescendo* new_cresc_p=0; + for (int i=0; i < dynamic_req_l_arr_.size(); i++) + { Dynamic_req *dreq_l = dynamic_req_l_arr_[i]; - if (dreq_l->absdynamic()) { + if (dreq_l->absdynamic()) + { Text_def * td_p = new Text_def; td_p->align_i_ = 0; String loud =Dynamic_req::loudness_str ( @@ -59,46 +61,58 @@ Dynamic_engraver::do_process_requests() dynamic_p_ = new Text_item (td_p); announce_element (Score_elem_info (dynamic_p_, dreq_l)); - } else if (dreq_l->span_dynamic()) { + } + else if (dreq_l->span_dynamic()) + { Span_dynamic_req* span_l = dreq_l->span_dynamic(); - if (span_l->spantype == Span_req::STOP) { - if (!cresc_p_) { + if (span_l->spantype == Span_req::STOP) + { + if (!cresc_p_) + { span_l->warning ("Can't find cresc to end "); - } else { + } + else + { assert (!to_end_cresc_p_); to_end_cresc_p_ =cresc_p_; cresc_p_ = 0; - } - } else if (span_l->spantype == Span_req::START) { + } + } + else if (span_l->spantype == Span_req::START) + { cresc_req_l_ = span_l; assert (!new_cresc_p); new_cresc_p = new Crescendo; new_cresc_p->grow_dir_i_ = span_l->dynamic_dir_i_; announce_element (Score_elem_info (new_cresc_p, span_l)); - } - } + } + } } - if ( new_cresc_p) { + if ( new_cresc_p) + { cresc_p_ = new_cresc_p; cresc_p_->left_col_l_ = get_staff_info().musical_l (); - if (dynamic_p_) { + if (dynamic_p_) + { cresc_p_->left_dyn_b_ = true; - } + } } } void Dynamic_engraver::do_pre_move_processing() { - Staff_symbol* s_l = get_staff_info().staff_sym_l_; - if (dynamic_p_) { + Staff_symbol* s_l = get_staff_info().staff_sym_l_; + if (dynamic_p_) + { dynamic_p_->set_staffsym (s_l); typeset_element (dynamic_p_); dynamic_p_ = 0; } - if ( to_end_cresc_p_) { + if ( to_end_cresc_p_) + { if (dynamic_p_) to_end_cresc_p_->right_dyn_b_=true; @@ -112,7 +126,7 @@ Dynamic_engraver::do_pre_move_processing() void Dynamic_engraver::set_feature (Feature i) { - if (i.type_ == "vdir") + if (i.type_ == "vdir") dir_i_ = i.value_; } @@ -122,17 +136,19 @@ ADD_THIS_ENGRAVER(Dynamic_engraver); Dynamic_engraver::~Dynamic_engraver() { - delete dynamic_p_; - delete to_end_cresc_p_; - if (cresc_p_) { + delete dynamic_p_; + delete to_end_cresc_p_; + if (cresc_p_) + { cresc_req_l_->warning ("unended crescendo"); } - delete cresc_p_; + delete cresc_p_; } void Dynamic_engraver::acknowledge_element (Score_elem_info i) { - if (i.elem_l_->name() == Note_column::static_name ()) { + if (i.elem_l_->name() == Note_column::static_name ()) + { if (dynamic_p_) dynamic_p_->add_support (i.elem_l_); if (to_end_cresc_p_) to_end_cresc_p_->add_support (i.elem_l_); diff --git a/lily/elem-group-item.cc b/lily/elem-group-item.cc index c22739a849..ec744fee45 100644 --- a/lily/elem-group-item.cc +++ b/lily/elem-group-item.cc @@ -13,7 +13,7 @@ void Horizontal_vertical_group_item::do_print()const { - Horizontal_vertical_group_element::do_print(); + Horizontal_vertical_group_element::do_print(); } IMPLEMENT_IS_TYPE_B2(Horizontal_vertical_group_item,Horizontal_vertical_group_element,Item); diff --git a/lily/elem-group.cc b/lily/elem-group.cc index e1902867ad..807573384f 100644 --- a/lily/elem-group.cc +++ b/lily/elem-group.cc @@ -14,26 +14,26 @@ void Axis_group_element::do_unlink() { - remove_all(); + remove_all(); } bool Axis_group_element::contains_b (Score_elem const*e)const { - return axis_admin_.contains_b (e); + return axis_admin_.contains_b (e); } Link_array Axis_group_element::get_extra_dependencies()const { - return axis_admin_.elem_l_arr_; + return axis_admin_.elem_l_arr_; } void Axis_group_element::do_print()const { - axis_admin_.print(); + axis_admin_.print(); } // **************** @@ -42,51 +42,51 @@ Axis_group_element::do_print()const void Vertical_group_element::add_element (Score_elem*e) { - axis_admin_.add_element (e, this, Y_AXIS, Y_AXIS); + axis_admin_.add_element (e, this, Y_AXIS, Y_AXIS); } void Vertical_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e, Y_AXIS, Y_AXIS); + axis_admin_.remove_element (e, Y_AXIS, Y_AXIS); } Interval Vertical_group_element::do_height() const { - return axis_admin_.extent (Y_AXIS); + return axis_admin_.extent (Y_AXIS); } void Vertical_group_element::remove_all() { - axis_admin_.remove_all (Y_AXIS,Y_AXIS); + axis_admin_.remove_all (Y_AXIS,Y_AXIS); } // **************** void Horizontal_group_element::remove_all() { - axis_admin_.remove_all (X_AXIS,X_AXIS); + axis_admin_.remove_all (X_AXIS,X_AXIS); } void Horizontal_group_element::add_element (Score_elem*e) { - axis_admin_.add_element (e,this, X_AXIS,X_AXIS); + axis_admin_.add_element (e,this, X_AXIS,X_AXIS); } void Horizontal_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e,X_AXIS,X_AXIS); + axis_admin_.remove_element (e,X_AXIS,X_AXIS); } Interval Horizontal_group_element::do_width()const { - return axis_admin_.extent (X_AXIS); + return axis_admin_.extent (X_AXIS); } @@ -95,18 +95,18 @@ Horizontal_group_element::do_width()const void Horizontal_vertical_group_element::remove_all() { - axis_admin_.remove_all (X_AXIS,Y_AXIS); + axis_admin_.remove_all (X_AXIS,Y_AXIS); } void Horizontal_vertical_group_element::add_element (Score_elem *e) { - axis_admin_.add_element (e, this, X_AXIS, Y_AXIS); + axis_admin_.add_element (e, this, X_AXIS, Y_AXIS); } void Horizontal_vertical_group_element::remove_element (Score_elem*e) { - axis_admin_.remove_element (e, X_AXIS, Y_AXIS); + axis_admin_.remove_element (e, X_AXIS, Y_AXIS); } diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index acf0c2587e..aae1051fb2 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -20,18 +20,19 @@ Engraver* get_engraver_p (String); void Engraver_group_engraver::print()const { - Engraver::print(); + Engraver::print(); } Engraver_group_engraver::~Engraver_group_engraver() { - assert (removable_b()); + assert (removable_b()); } void Engraver_group_engraver::check_removal() { - for (int i =0; i < group_l_arr_.size();) { + for (int i =0; i < group_l_arr_.size();) + { group_l_arr_[i]->check_removal(); if (group_l_arr_[i]->removable_b()) terminate_engraver (group_l_arr_[i]); @@ -43,20 +44,21 @@ Engraver_group_engraver::check_removal() bool Engraver_group_engraver::removable_b()const { - return !iterator_count_&& !group_l_arr_.size() ; + return !iterator_count_&& !group_l_arr_.size() ; } Engraver_group_engraver::Engraver_group_engraver() { - itrans_l_ = 0; + itrans_l_ = 0; } void Engraver_group_engraver::set_feature (Feature d) { - PCursor i (grav_list_.top()); - // why the while construct? - while (i.ok()) { + PCursor i (grav_list_.top()); + // why the while construct? + while (i.ok()) + { // this construction to ensure clean deletion Engraver *grav_l = i++; grav_l->set_feature (d); @@ -66,8 +68,9 @@ Engraver_group_engraver::set_feature (Feature d) void Engraver_group_engraver::sync_features() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->sync_features(); } @@ -76,8 +79,9 @@ Engraver_group_engraver::sync_features() void Engraver_group_engraver::do_pre_move_processing() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->pre_move_processing(); } @@ -86,8 +90,9 @@ Engraver_group_engraver::do_pre_move_processing() void Engraver_group_engraver::do_process_requests() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { Engraver *grav_l = i++; grav_l->process_requests(); } @@ -97,8 +102,9 @@ Engraver_group_engraver::do_process_requests() void Engraver_group_engraver::do_post_move_processing() { - PCursor i (grav_list_.top()); - while (i.ok()) { + PCursor i (grav_list_.top()); + while (i.ok()) + { // this construction to ensure clean deletion Engraver *grav_l = i++; grav_l->post_move_processing(); @@ -109,14 +115,14 @@ Engraver_group_engraver::do_post_move_processing() bool Engraver_group_engraver::contains_b (Engraver* grav_l)const { - bool parent_b = Engraver::contains_b (grav_l); - - if (parent_b) + bool parent_b = Engraver::contains_b (grav_l); + + if (parent_b) return true; - for (PCursor i (grav_list_.top()); i.ok (); i++) + for (PCursor i (grav_list_.top()); i.ok (); i++) if (i->contains_b (grav_l)) return true; - return false; + return false; } @@ -124,29 +130,32 @@ Engraver_group_engraver::contains_b (Engraver* grav_l)const bool Engraver_group_engraver::do_try_request (Request*req_l) { - bool hebbes_b =false; - for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) + bool hebbes_b =false; + for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) hebbes_b =nongroup_l_arr_[i]->try_request (req_l); - if (!hebbes_b && daddy_grav_l_) + if (!hebbes_b && daddy_grav_l_) hebbes_b = daddy_grav_l_->try_request (req_l); - return hebbes_b ; + return hebbes_b ; } bool Engraver_group_engraver::try_request (Request* r) { - return Engraver::try_request (r); + return Engraver::try_request (r); } void Engraver_group_engraver::add (Engraver *grav_p) { - grav_list_.bottom().add (grav_p); - grav_p->daddy_grav_l_ = this; + grav_list_.bottom().add (grav_p); + grav_p->daddy_grav_l_ = this; - if (grav_p->is_type_b (Engraver_group_engraver::static_name())) { + if (grav_p->is_type_b (Engraver_group_engraver::static_name())) + { group_l_arr_.push ((Engraver_group_engraver*)grav_p); - } else { + } + else + { nongroup_l_arr_ .push (grav_p); } } @@ -155,21 +164,21 @@ Engraver_group_engraver::add (Engraver *grav_p) Engraver * Engraver_group_engraver::remove_engraver_p (Engraver*grav_l) { - group_l_arr_.substitute ((Engraver_group_engraver*)grav_l,0); - nongroup_l_arr_.substitute (grav_l,0); - PCursor grav_cur (grav_list_.find (grav_l)); - - return grav_cur.remove_p(); + group_l_arr_.substitute ((Engraver_group_engraver*)grav_l,0); + nongroup_l_arr_.substitute (grav_l,0); + PCursor grav_cur (grav_list_.find (grav_l)); + + return grav_cur.remove_p(); } void Engraver_group_engraver::terminate_engraver (Engraver*r_l) { - DOUT << "Removing " << r_l->name() << " at " << get_staff_info ().when () << "\n"; - r_l->removal_processing(); - Engraver * grav_p =remove_engraver_p (r_l); - - delete grav_p; + DOUT << "Removing " << r_l->name() << " at " << get_staff_info ().when () << "\n"; + r_l->removal_processing(); + Engraver * grav_p =remove_engraver_p (r_l); + + delete grav_p; } IMPLEMENT_IS_TYPE_B2(Engraver_group_engraver,Engraver, Translator); @@ -180,11 +189,11 @@ void Engraver_group_engraver::do_print()const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << "ID: " << id_str_ ; - DOUT << " iterators: " << iterator_count_<< "\n"; - for (PCursor i (grav_list_.top()); i.ok (); i++) + DOUT << "ID: " << id_str_ ; + DOUT << " iterators: " << iterator_count_<< "\n"; + for (PCursor i (grav_list_.top()); i.ok (); i++) i->print(); #endif } @@ -193,24 +202,27 @@ Engraver_group_engraver::do_print()const Engraver_group_engraver* Engraver_group_engraver::find_engraver_l (String n, String id) { - if (name() == n && id_str_ == id) + if (name() == n && id_str_ == id) return this; - Engraver_group_engraver * r = 0; - for (int i =0; !r && i< group_l_arr_.size(); i++) { + Engraver_group_engraver * r = 0; + for (int i =0; !r && i< group_l_arr_.size(); i++) + { r = group_l_arr_[i]->find_engraver_l (n,id); } - - return r; + + return r; } Translator* Engraver_group_engraver::find_get_translator_l (String n,String id) { - Translator * ret=0; - Input_translator * itrans_l= itrans_l_-> recursive_find ( n); - if (itrans_l) { + Translator * ret=0; + Input_translator * itrans_l= itrans_l_-> recursive_find ( n); + if (itrans_l) + { ret = find_engraver_l (n,id); - if (!ret) { + if (!ret) + { Engraver_group_engraver * group = itrans_l-> get_group_engraver_p(); @@ -222,110 +234,115 @@ Engraver_group_engraver::find_get_translator_l (String n,String id) else return ret->find_get_translator_l (n,id); - } - } else if (daddy_grav_l_) + } + } + else if (daddy_grav_l_) ret =daddy_grav_l_->find_get_translator_l (n,id); - else { + else + { warning ("Can't find or create `" + n + "' called `" + id + "'\n"); ret =0; } - return ret; + return ret; } int Engraver_group_engraver::depth_i()const { - return daddy_grav_l_->depth_i() + 1; + return daddy_grav_l_->depth_i() + 1; } Translator* Engraver_group_engraver::ancestor_l (int l) { - if (!l || !daddy_grav_l_) + if (!l || !daddy_grav_l_) return this; - - return daddy_grav_l_->ancestor_l (l-1); + + return daddy_grav_l_->ancestor_l (l-1); } void Engraver_group_engraver::announce_element (Score_elem_info info) { - announce_info_arr_.push (info); - Engraver::announce_element (info); + announce_info_arr_.push (info); + Engraver::announce_element (info); } void Engraver_group_engraver::do_announces() { - for (int i=0; i < group_l_arr_.size(); i++) { + for (int i=0; i < group_l_arr_.size(); i++) + { group_l_arr_[i]->do_announces(); } - - Request dummy_req; + + Request dummy_req; - for (int j =0; j < announce_info_arr_.size(); j++){ - Score_elem_info info = announce_info_arr_[j]; - - if (!info.req_l_) + for (int j =0; j < announce_info_arr_.size(); j++) + { + Score_elem_info info = announce_info_arr_[j]; + + if (!info.req_l_) info.req_l_ = &dummy_req; - for (int i=0; i < nongroup_l_arr_.size(); i++) { // Is this good enough?6 + for (int i=0; i < nongroup_l_arr_.size(); i++) { // Is this good enough?6 if (nongroup_l_arr_[i] != info.origin_grav_l_arr_[0]) nongroup_l_arr_[i]->acknowledge_element (info); } } - announce_info_arr_.clear(); + announce_info_arr_.clear(); } void Engraver_group_engraver::do_removal_processing() { - for (PCursor i (grav_list_.top()); i.ok (); i++) + for (PCursor i (grav_list_.top()); i.ok (); i++) i->removal_processing(); } Staff_info Engraver_group_engraver::get_staff_info()const { - Staff_info inf = Engraver::get_staff_info(); + Staff_info inf = Engraver::get_staff_info(); - for (int i=0; i < nongroup_l_arr_.size(); i++) + for (int i=0; i < nongroup_l_arr_.size(); i++) nongroup_l_arr_[i]->fill_staff_info (inf); - - return inf; + + return inf; } Translator* Engraver_group_engraver::get_default_interpreter() { - // ? - if ( is_bottom_engraver_b()) + // ? + if ( is_bottom_engraver_b()) return daddy_grav_l_->get_default_interpreter(); - Engraver_group_engraver *grav_p= itrans_l_-> + Engraver_group_engraver *grav_p= itrans_l_-> get_default_itrans_l()->get_group_engraver_p (); - add (grav_p); - if (grav_p->is_bottom_engraver_b()) + add (grav_p); + if (grav_p->is_bottom_engraver_b()) return grav_p; - else + else return grav_p->get_default_interpreter(); } bool Engraver_group_engraver::is_bottom_engraver_b()const { - return !itrans_l_->get_default_itrans_l(); + return !itrans_l_->get_default_itrans_l(); } Engraver* Engraver_group_engraver::get_simple_engraver (char const *type)const { - for (int i=0; i < nongroup_l_arr_.size(); i++) { + for (int i=0; i < nongroup_l_arr_.size(); i++) + { if (nongroup_l_arr_[i]->name() == type) return nongroup_l_arr_[i]; } - if ( daddy_grav_l_) + if ( daddy_grav_l_) return daddy_grav_l_->get_simple_engraver (type); - return 0; + return 0; } diff --git a/lily/engraver.cc b/lily/engraver.cc index f3cf488c0c..52eba772e0 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -15,116 +15,117 @@ void Engraver::post_move_processing() { - if (status < CREATION_INITED) { + if (status < CREATION_INITED) + { do_creation_processing(); status = CREATION_INITED; } - if (status >= MOVE_INITED) + if (status >= MOVE_INITED) return; - do_post_move_processing(); - status = MOVE_INITED; + do_post_move_processing(); + status = MOVE_INITED; } void Engraver::removal_processing() { - if ( status < CREATION_INITED) + if ( status < CREATION_INITED) do_creation_processing(); - - do_removal_processing(); + + do_removal_processing(); } bool Engraver::try_request (Request * r) { - if (status < MOVE_INITED) + if (status < MOVE_INITED) post_move_processing(); - return do_try_request (r); + return do_try_request (r); } void Engraver::process_requests() { - if (status < PROCESSED_REQS) + if (status < PROCESSED_REQS) post_move_processing(); - else if (status >= PROCESSED_REQS) + else if (status >= PROCESSED_REQS) return; - - status = PROCESSED_REQS; - do_process_requests(); + + status = PROCESSED_REQS; + do_process_requests(); } void Engraver::pre_move_processing() { - do_pre_move_processing(); - status = CREATION_INITED; + do_pre_move_processing(); + status = CREATION_INITED; } void Engraver::fill_staff_info (Staff_info&) { - + } Scalar Engraver::get_feature (String t) { - return daddy_grav_l_->get_feature (t); + return daddy_grav_l_->get_feature (t); } bool Engraver::do_try_request (Request*) { - return false; + return false; } Engraver::Engraver() { - status = VIRGIN; - daddy_grav_l_ = 0; + status = VIRGIN; + daddy_grav_l_ = 0; } void Engraver::announce_element (Score_elem_info i) { - i.origin_grav_l_arr_.push (this); - daddy_grav_l_->announce_element (i); + i.origin_grav_l_arr_.push (this); + daddy_grav_l_->announce_element (i); } void Engraver::typeset_element (Score_elem*p) { - daddy_grav_l_->typeset_element (p); + daddy_grav_l_->typeset_element (p); } Paper_def* Engraver::paper()const { - return daddy_grav_l_->paper(); + return daddy_grav_l_->paper(); } bool Engraver::contains_b (Engraver *grav_l)const { - return this == grav_l; + return this == grav_l; } Staff_info Engraver::get_staff_info() const { - return daddy_grav_l_->get_staff_info(); + return daddy_grav_l_->get_staff_info(); } void Engraver::print() const { #ifndef NPRINT - DOUT << "\n" << name() << " {"; - do_print(); - DOUT << "}"; + DOUT << "\n" << name() << " {"; + do_print(); + DOUT << "}"; #endif } diff --git a/lily/general-script-def.cc b/lily/general-script-def.cc index 06b678a965..f3b202e805 100644 --- a/lily/general-script-def.cc +++ b/lily/general-script-def.cc @@ -13,47 +13,47 @@ int General_script_def::staff_dir_i()const { - return -1; + return -1; } int General_script_def::rel_stem_dir_i()const { - return 0; + return 0; } int General_script_def::priority_i()const { - return 1000; + return 1000; } bool General_script_def::inside_b()const { - return false; + return false; } bool General_script_def::equal_b (General_script_def const&g)const { - if (name() != g.name ()) + if (name() != g.name ()) return false; - return do_equal_b (&g); + return do_equal_b (&g); } bool General_script_def::do_equal_b (General_script_def const*)const { - return true; + return true; } void General_script_def::print() const { - DOUT << name() << "{"; - do_print(); - DOUT << "}"; + DOUT << name() << "{"; + do_print(); + DOUT << "}"; } void @@ -64,8 +64,8 @@ General_script_def::do_print() const Atom General_script_def::get_atom (Paper_def*, int)const { - Symbol s; - return Atom (s); + Symbol s; + return Atom (s); } IMPLEMENT_IS_TYPE_B(General_script_def); diff --git a/lily/global-gravs.cc b/lily/global-gravs.cc index df0df5322a..784c193939 100644 --- a/lily/global-gravs.cc +++ b/lily/global-gravs.cc @@ -13,14 +13,15 @@ #include "engraver.hh" struct Engraver_table_entry { - String name_str_; - Grav_ctor ctor_l_; - Engraver_table_entry (String s, Grav_ctor f) { + String name_str_; + Grav_ctor ctor_l_; + Engraver_table_entry (String s, Grav_ctor f) + { name_str_ =s; ctor_l_ = f; } - Engraver_table_entry() - { + Engraver_table_entry() + { ctor_l_ =0; } }; @@ -30,38 +31,40 @@ static Array *grav_table=0; void add_engraver (String s, Grav_ctor f) { - if (!grav_table) + if (!grav_table) grav_table = new Array; - - grav_table->push (Engraver_table_entry (s, f)); + + grav_table->push (Engraver_table_entry (s, f)); } Engraver* get_engraver_p (String s) { - for (int i=0; i < grav_table->size(); i++) { + for (int i=0; i < grav_table->size(); i++) + { if ((*grav_table)[i].name_str_ == s) return (*(*grav_table)[i].ctor_l_)(); } - error ("Unknown engraver `" + s +"\'"); - return 0; + error ("Unknown engraver `" + s +"\'"); + return 0; } #if 0 struct Performer_table_entry { - String name_str_; - Perf_ctor ctor_l_; - Performer_table_entry (String s, Perf_ctor f) { + String name_str_; + Perf_ctor ctor_l_; + Performer_table_entry (String s, Perf_ctor f) + { name_str_ =s; ctor_l_ = f; } - Performer_table_entry() - { + Performer_table_entry() + { ctor_l_ =0; - } + } } static Array *perf_table=0; @@ -69,21 +72,22 @@ static Array *perf_table=0; void add_performer (String s, Perf_ctor f) { - if (!perf_table) + if (!perf_table) perf_table = new Array; - - perf_table->push (Performer_table_entry (s, f)); + + perf_table->push (Performer_table_entry (s, f)); } Performer* get_performer_p (String s) { - for (int i=0; i < perf_table->size(); i++) { + for (int i=0; i < perf_table->size(); i++) + { if ((*perf_table)[i].name_str_ == s) return (*(*perf_table)[i].ctor_l_)(); } - error ("Unknown performer `" + s +"\'"); - return 0; + error ("Unknown performer `" + s +"\'"); + return 0; } #endif diff --git a/lily/global-performers.cc b/lily/global-performers.cc index 126a109319..69102aaf23 100644 --- a/lily/global-performers.cc +++ b/lily/global-performers.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "proto.hh" @@ -14,14 +14,15 @@ #include "performer.hh" struct Performer_table_entry { - String name_str_; - Perf_ctor ctor_l_; - Performer_table_entry (String s, Perf_ctor f) { + String name_str_; + Perf_ctor ctor_l_; + Performer_table_entry (String s, Perf_ctor f) + { name_str_ =s; ctor_l_ = f; } - Performer_table_entry() - { + Performer_table_entry() + { ctor_l_ =0; } }; @@ -31,20 +32,21 @@ static Array *perf_table=0; void add_Performer (String s, Perf_ctor f) { - if (!perf_table) + if (!perf_table) perf_table = new Array; - - perf_table->push (Performer_table_entry (s, f)); + + perf_table->push (Performer_table_entry (s, f)); } Performer* get_performer_p (String s) { - for (int i=0; i < perf_table->size(); i++) { + for (int i=0; i < perf_table->size(); i++) + { if ((*perf_table)[i].name_str_ == s) return (*(*perf_table)[i].ctor_l_)(); } - error ("Unknown performer `" + s +"\'"); - return 0; + error ("Unknown performer `" + s +"\'"); + return 0; } diff --git a/lily/global-translator.cc b/lily/global-translator.cc index 39cc56bc3d..f92156e6e4 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -13,45 +13,45 @@ Global_translator::Global_translator() { - score_l_ = 0; - last_mom_ = 0; + score_l_ = 0; + last_mom_ = 0; } Translator* Global_translator::ancestor_l (int) { - return this; + return this; } void Global_translator::add_moment_to_process (Moment m) { - if (m > last_mom_) + if (m > last_mom_) return; - - for (int i=0; i < extra_mom_pq_.size(); i++) + + for (int i=0; i < extra_mom_pq_.size(); i++) if (extra_mom_pq_[i] == m) return; - extra_mom_pq_.insert (m); + extra_mom_pq_.insert (m); } int Global_translator::depth_i()const { - return 0; + return 0; } void Global_translator::set_score (Score *s) { - score_l_ = s; - last_mom_ = score_l_->music_p_->time_int().max (); + score_l_ = s; + last_mom_ = score_l_->music_p_->time_int().max (); } void Global_translator::modify_next (Moment &w) { - while (extra_mom_pq_.size() && + while (extra_mom_pq_.size() && extra_mom_pq_.front() <= w) w =extra_mom_pq_.get(); @@ -60,7 +60,7 @@ Global_translator::modify_next (Moment &w) int Global_translator::moments_left_i()const { - return extra_mom_pq_.size(); + return extra_mom_pq_.size(); } void diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 85533c517b..90d07e6851 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -21,16 +21,17 @@ const HAPPY_DOTS_I = 3; Helper to trace back an optimal path */ struct Break_node { - /** this was the previous. If negative, this break should not be - considered: this path has infinite energy - - */ - int prev_break_i_; - Real energy_f_; - Col_hpositions line_config_; - Break_node() { - prev_break_i_ = -1; - } + /** this was the previous. If negative, this break should not be + considered: this path has infinite energy + + */ + int prev_break_i_; + Real energy_f_; + Col_hpositions line_config_; + Break_node() + { + prev_break_i_ = -1; + } }; /** @@ -41,141 +42,164 @@ Array Gourlay_breaking::do_solve()const { - Array optimal_paths; - Line_of_cols all = all_cols(); - Array breaks = find_break_indices(); - - optimal_paths.set_size (breaks.size()); + Array optimal_paths; + Line_of_cols all = all_cols(); + Array breaks = find_break_indices(); + + optimal_paths.set_size (breaks.size()); - Break_node first_node ; - first_node.prev_break_i_ = -1; - first_node.line_config_.energy_f_ = 0; - - optimal_paths[0] = first_node; - int break_idx=1; + Break_node first_node ; + first_node.prev_break_i_ = -1; + first_node.line_config_.energy_f_ = 0; + + optimal_paths[0] = first_node; + int break_idx=1; - for (; break_idx< breaks.size(); break_idx++) { - Array candidates; - Array candidate_lines; - Pointer_list spacer_p_list; + for (; break_idx< breaks.size(); break_idx++) + { + Array candidates; + Array candidate_lines; + Pointer_list spacer_p_list; - /* - start with a short line, add measures. At some point - the line becomes infeasible. Then we don't try to add more - */ - for (int start_idx = break_idx; start_idx--;){ - if (break_idx - start_idx > max_measures_i_) - break; - - if (optimal_paths[start_idx].prev_break_i_ < 0 - && optimal_paths[start_idx].line_config_.energy_f_) + /* + start with a short line, add measures. At some point + the line becomes infeasible. Then we don't try to add more + */ + for (int start_idx = break_idx; start_idx--;) + { + if (break_idx - start_idx > max_measures_i_) + break; + + if (optimal_paths[start_idx].prev_break_i_ < 0 + && optimal_paths[start_idx].line_config_.energy_f_) - continue; + continue; - Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1); + Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1); - line[0] = line[0]->postbreak_p_; - line.top() = line.top ()->prebreak_p_; + line[0] = line[0]->postbreak_p_; + line.top() = line.top ()->prebreak_p_; - if (!feasible (line)) - break; + if (!feasible (line)) + break; - Col_hpositions approx; - approx.cols = line; + Col_hpositions approx; + approx.cols = line; - approx.spacer_l_ = generate_spacing_problem (line); - spacer_p_list.bottom().add (approx.spacer_l_); + approx.spacer_l_ = generate_spacing_problem (line); + spacer_p_list.bottom().add (approx.spacer_l_); - ((Break_algorithm*)this)->approx_stats_.add (approx.cols); - approx.approximate_solve_line(); + ((Break_algorithm*)this)->approx_stats_.add (approx.cols); + approx.approximate_solve_line(); - if (approx.energy_f_ > energy_bound_f_){ - continue; + if (approx.energy_f_ > energy_bound_f_) + { + continue; } - // this is a likely candidate. Store it. - candidate_lines.push (approx); - candidates.push (start_idx); + // this is a likely candidate. Store it. + candidate_lines.push (approx); + candidates.push (start_idx); } - int minimal_j = -1; - Real minimal_energy = infinity_f; - for (int j=0; j < candidates.size(); j++) { - int start = candidates[j]; - if ( optimal_paths[start].line_config_.energy_f_ - + candidate_lines[j].energy_f_ > minimal_energy) + int minimal_j = -1; + Real minimal_energy = infinity_f; + for (int j=0; j < candidates.size(); j++) + { + int start = candidates[j]; + if ( optimal_paths[start].line_config_.energy_f_ + + candidate_lines[j].energy_f_ > minimal_energy) - continue; + continue; - if ( !candidate_lines[j].satisfies_constraints_b_) { - candidate_lines[j].solve_line(); - ((Break_algorithm*)this)->exact_stats_.add ( candidate_lines[j].cols); + if ( !candidate_lines[j].satisfies_constraints_b_) + { + candidate_lines[j].solve_line(); + ((Break_algorithm*)this)->exact_stats_.add ( candidate_lines[j].cols); } - Real this_energy - = optimal_paths[start].line_config_.energy_f_ - + candidate_lines[j].energy_f_ ; + Real this_energy + = optimal_paths[start].line_config_.energy_f_ + + candidate_lines[j].energy_f_ ; - if ( this_energy < minimal_energy) { - minimal_j = j; - minimal_energy = this_energy; + if ( this_energy < minimal_energy) + { + minimal_j = j; + minimal_energy = this_energy; } } - if (minimal_j < 0) { - optimal_paths[break_idx].prev_break_i_ = -1; - optimal_paths[break_idx].line_config_.energy_f_ = infinity_f; - } else { - optimal_paths[break_idx].prev_break_i_ = candidates[minimal_j]; - optimal_paths[break_idx].line_config_ = candidate_lines[minimal_j]; + if (minimal_j < 0) + { + optimal_paths[break_idx].prev_break_i_ = -1; + optimal_paths[break_idx].line_config_.energy_f_ = infinity_f; + } + else + { + optimal_paths[break_idx].prev_break_i_ = candidates[minimal_j]; + optimal_paths[break_idx].line_config_ = candidate_lines[minimal_j]; } - if ( !(break_idx % HAPPY_DOTS_I)) - *mlog << "[" << break_idx << "]"< final_breaks; + Array final_breaks; - Array lines; - /* skip 0-th element, since it is a "dummy" elt*/ - for (int i = optimal_paths.size()-1; i> 0;) { - final_breaks.push ( i); - assert ( i > optimal_paths[i].prev_break_i_); + Array lines; + Real min_energy_f_ = infinity_f; + Real max_energy_f_ = 0; + + /* skip 0-th element, since it is a "dummy" elt*/ + for (int i = optimal_paths.size()-1; i> 0;) + { + final_breaks.push ( i); + assert ( i > optimal_paths[i].prev_break_i_); + + // there was no "feasible path" + if (!optimal_paths[i].line_config_.config.size()) { + final_breaks.set_size (0); + break; + } + i = optimal_paths[i].prev_break_i_; + } - // there was no "feasible path" - if (!optimal_paths[i].line_config_.config.size()) - return lines; - i = optimal_paths[i].prev_break_i_; + print_stats(); + /* + TODO print variation in energy + */ + if (max_energy_f_ ) + { + ; } + + - for (int i= final_breaks.size(); i--;) - lines.push ( optimal_paths[final_breaks[i]].line_config_); + for (int i= final_breaks.size(); i--;) + lines.push ( optimal_paths[final_breaks[i]].line_config_); - - return lines; + + return lines; } Gourlay_breaking::Gourlay_breaking() { - get_line_spacer = Spring_spacer::constructor; - energy_bound_f_ = infinity_f; - max_measures_i_ = INT_MAX; + get_line_spacer = Spring_spacer::constructor; + energy_bound_f_ = infinity_f; + max_measures_i_ = INT_MAX; } void Gourlay_breaking::do_set_pscore() { - energy_bound_f_ = pscore_l_->paper_l_->get_var ("gourlay_energybound"); - max_measures_i_ =int (rint (pscore_l_->paper_l_->get_var ("gourlay_maxmeasures"))); + energy_bound_f_ = pscore_l_->paper_l_->get_var ("gourlay_energybound"); + max_measures_i_ =int (rint (pscore_l_->paper_l_->get_var ("gourlay_maxmeasures"))); } diff --git a/lily/grouping.cc b/lily/grouping.cc index ffda40e14f..c106db0861 100644 --- a/lily/grouping.cc +++ b/lily/grouping.cc @@ -13,17 +13,18 @@ void Rhythmic_grouping::init() { - interval_ = 0; - children.clear(); + interval_ = 0; + children.clear(); } void Rhythmic_grouping::OK()const { #ifndef NDEBUG - assert (bool (children.size()) != bool (interval_)); + assert (bool (children.size()) != bool (interval_)); - for (int i= 0; i < children.size(); i++) { + for (int i= 0; i < children.size(); i++) + { children[i]->OK(); if (i>0) assert (children[i-1]->interval().right == @@ -35,15 +36,15 @@ Rhythmic_grouping::OK()const Moment Rhythmic_grouping::length() const { - return interval().length (); + return interval().length (); } MInterval Rhythmic_grouping::interval()const { - if (interval_) + if (interval_) return *interval_; - else + else return MInterval (children[0]->interval().left, children.top()->interval ().right); @@ -52,17 +53,19 @@ Rhythmic_grouping::interval()const void Rhythmic_grouping::split (Rhythmic_grouping r) { - if (interval_) + if (interval_) return ; - - r.intersect (interval()); - split (r.intervals()); - - for (int i= 0; i < children.size(); i++) { - if (!children[i]->interval_) { + + r.intersect (interval()); + split (r.intervals()); + + for (int i= 0; i < children.size(); i++) + { + if (!children[i]->interval_) + { Rhythmic_grouping here (r); children[i]->split (here); - } + } } } @@ -70,37 +73,46 @@ Rhythmic_grouping::split (Rhythmic_grouping r) Array Rhythmic_grouping::intervals() { - Array r; - if (interval_ || children.size() == 1) { + Array r; + if (interval_ || children.size() == 1) + { MInterval i (interval()); MInterval r1(i), r2(i); r1.right = r2.left = i.center(); r.push (r1); r.push (r2); - } else { + } + else + { for (int i=0; i < children.size(); i++) r.push (children[i]->interval()); } - return r; + return r; } void Rhythmic_grouping::intersect (MInterval t) { - if (interval_) { + if (interval_) + { interval_->intersect (t); return; } - - for (int i=0; i < children.size(); i++) { + + for (int i=0; i < children.size(); i++) + { MInterval inter = intersection (t, children[i]->interval()); - if (inter.empty_b() || inter.length () <= Rational (0)) { + if (inter.empty_b() || inter.length () <= Rational (0)) + { delete children[i]; children[i] =0; - } else { + } + else + { children[i]->intersect (t); - } + } } - for (int i=0; i < children.size();) { + for (int i=0; i < children.size();) + { if (!children[i]) children.del (i); else @@ -120,164 +132,180 @@ Rhythmic_grouping::intersect (MInterval t) void Rhythmic_grouping::split (Array splitpoints) { - //check on splitpoints.. - int j = 0, i = 0, starti = 0, startj = 0; - - Array ch; - while (1) { + //check on splitpoints.. + int j = 0, i = 0, starti = 0, startj = 0; + + Array ch; + while (1) + { if ( i >= children.size() || j >= splitpoints.size ()) break; assert ( children[starti]->interval().left== splitpoints[startj].left); - if (children[i]->interval().right < splitpoints[j].right) { + if (children[i]->interval().right < splitpoints[j].right) + { i ++; - } else if (children[i]->interval().right > splitpoints[j].right) { + } + else if (children[i]->interval().right > splitpoints[j].right) + { j ++; - } else { + } + else + { - if (i == starti) { + if (i == starti) + { ch.push (children[i]); - } else { + } + else + { Rhythmic_grouping *newchild=new Rhythmic_grouping ( children.slice (starti, i+1)); ch.push (newchild); - } + } i ++; j++; starti = i; startj = j; - } + } } - if (ch.size() != 1) + if (ch.size() != 1) children = ch; } Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n) { - init(); - if (n == 1 || !n) { + init(); + if (n == 1 || !n) + { interval_ = new MInterval (t); return; } - Moment dt = t.length()/Rational (n); - MInterval basic = MInterval (t.left, t.left+dt); - for (int i= 0; i < n; i++) + Moment dt = t.length()/Rational (n); + MInterval basic = MInterval (t.left, t.left+dt); + for (int i= 0; i < n; i++) children.push (new Rhythmic_grouping (dt*Rational (i) + basic)); } Rhythmic_grouping::Rhythmic_grouping (Array r) - :children (r) + :children (r) { - interval_ =0; + interval_ =0; } Rhythmic_grouping::~Rhythmic_grouping() { - junk(); + junk(); } void Rhythmic_grouping::copy (Rhythmic_grouping const&s) { - interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; - for (int i=0; i < s.children.size(); i++) - children.push (new Rhythmic_grouping (*s.children[i])); + interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; + for (int i=0; i < s.children.size(); i++) + children.push (new Rhythmic_grouping (*s.children[i])); } void Rhythmic_grouping::operator=(Rhythmic_grouping const &s) { - junk(); - copy (s); + junk(); + copy (s); } Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s) { - init(); - copy (s); + init(); + copy (s); } void Rhythmic_grouping::junk() { - delete interval_; - for (int i=0; i < children.size(); i++) + delete interval_; + for (int i=0; i < children.size(); i++) delete children[i]; - init(); + init(); } void Rhythmic_grouping::print()const { #ifndef NPRINT - DOUT << "{ \n"; - if (interval_) + DOUT << "{ \n"; + if (interval_) DOUT <<" Interval "<< interval_->str(); - for (int i=0; i < children.size(); i++) { + for (int i=0; i < children.size(); i++) + { children[i]->print(); } - DOUT << "}\n"; + DOUT << "}\n"; #endif } bool Rhythmic_grouping::child_fit_b (Moment start) { - if (children.size()) + if (children.size()) return ( children.top()->interval ().right== start); - return true; + return true; } void Rhythmic_grouping::add_child (Moment start, Moment len) { - Moment stop = start+len; + Moment stop = start+len; - assert (child_fit_b (start)); - children.push (new Rhythmic_grouping (MInterval (start, stop))); + assert (child_fit_b (start)); + children.push (new Rhythmic_grouping (MInterval (start, stop))); } Rhythmic_grouping::Rhythmic_grouping() { - interval_ =0; + interval_ =0; } int min_elt (Array v) { - int i = 1000; // ugh - for (int j = 0 ; j < v.size(); j++) + int i = 1000; // ugh + for (int j = 0 ; j < v.size(); j++) i = i Rhythmic_grouping::generate_beams (Array flags, int &flagidx) { - assert (!interval_) ; - - Array< Array > children_beams; - for (int i=0; i < children.size(); i++) { + assert (!interval_) ; + + Array< Array > children_beams; + for (int i=0; i < children.size(); i++) + { Array child_beams; - if (children[i]->interval_) { + if (children[i]->interval_) + { int f = flags[flagidx++]; child_beams.push (f); - } else { + } + else + { child_beams = children[i]-> generate_beams (flags, flagidx); - } + } children_beams.push (child_beams); } - Array beams; - int lastm, m, nextm; - for (int i=0; i < children_beams.size(); i++) { + Array beams; + int lastm, m, nextm; + for (int i=0; i < children_beams.size(); i++) + { bool add_left = (i >0); bool add_right = (i < children_beams.size() -1); @@ -286,31 +314,34 @@ Rhythmic_grouping::generate_beams (Array flags, int &flagidx) if (add_right) nextm = min_elt (children_beams[i+1]); - if (children_beams[i].size() == 1) { + if (children_beams[i].size() == 1) + { if (add_right) beams.push (m); if (add_left) beams.push (m); - } else { + } + else + { if (add_left) beams.push (lastm translate (m); } @@ -318,33 +349,36 @@ Rhythmic_grouping::translate (Moment m) void Rhythmic_grouping::extend (MInterval m)const { - assert (m.left >= interval().left); - while (m.right >interval().right) { + assert (m.left >= interval().left); + while (m.right >interval().right) + { Array a (children); - for (int i=0; i < a.size(); i++) { + for (int i=0; i < a.size(); i++) + { a[i] =new Rhythmic_grouping (*children[i]); a[i]->translate (children.top()->interval ().right); - } + } ((Rhythmic_grouping*)this)->children.concat (a); } - assert (m.right <= interval().right); - OK(); + assert (m.right <= interval().right); + OK(); } Rhythmic_grouping parse_grouping (Array beat_i_arr, Array elt_length_arr) { - Moment here =0; - assert (beat_i_arr.size() == elt_length_arr.size ()); - - Array children; - for (int i=0; i < beat_i_arr.size(); i++) { + Moment here =0; + assert (beat_i_arr.size() == elt_length_arr.size ()); + + Array children; + for (int i=0; i < beat_i_arr.size(); i++) + { Moment last = here; here += elt_length_arr[i] * Moment (beat_i_arr[i]); children.push ( new Rhythmic_grouping (MInterval (last, here), beat_i_arr[i])); } - return Rhythmic_grouping (children); + return Rhythmic_grouping (children); } diff --git a/lily/head-column.cc b/lily/head-column.cc index af7001db90..a5d1ecbebd 100644 --- a/lily/head-column.cc +++ b/lily/head-column.cc @@ -14,20 +14,22 @@ Head_column::Head_column() { - stem_l_ = 0; - dir_i_ =0; + stem_l_ = 0; + dir_i_ =0; } void Head_column::do_substitute_dependency (Score_elem*o, Score_elem*n) { - Script_column::do_substitute_dependency (o,n); - if (o->name() == Note_head::static_name ()) { + Script_column::do_substitute_dependency (o,n); + if (o->name() == Note_head::static_name ()) + { head_l_arr_.substitute ((Note_head*)o->item(), (n)? (Note_head*)n->item() : 0); } - if (stem_l_ == o) { + if (stem_l_ == o) + { stem_l_ = n ? (Stem*)n->item():0; } } @@ -36,24 +38,24 @@ Head_column::do_substitute_dependency (Score_elem*o, void Head_column::set (Stem*stem_l) { - stem_l_ = stem_l; - Score_elem::add_dependency (stem_l); - for (int i=0; script_l_arr_.size(); i++) + stem_l_ = stem_l; + Score_elem::add_dependency (stem_l); + for (int i=0; script_l_arr_.size(); i++) script_l_arr_[i]->set_stem (stem_l); } void Head_column::add (Script *script_l) { - Script_column::add (script_l) ; - if (stem_l_) + Script_column::add (script_l) ; + if (stem_l_) script_l->set_stem (stem_l_); } void Head_column::add (Note_head *n_l) { - add_support (n_l); - head_l_arr_.push (n_l); + add_support (n_l); + head_l_arr_.push (n_l); } @@ -64,16 +66,17 @@ void Head_column::do_print() const { #ifndef NPRINT - DOUT << "heads: " << head_l_arr_.size(); + DOUT << "heads: " << head_l_arr_.size(); #endif } void Head_column::do_pre_processing() { - if (!dir_i_){ + if (!dir_i_) + { if (stem_l_) dir_i_ = stem_l_->dir_i_; } - Script_column::do_pre_processing(); + Script_column::do_pre_processing(); } diff --git a/lily/head-grav.cc b/lily/head-grav.cc index d1aaaed0af..29da2be66e 100644 --- a/lily/head-grav.cc +++ b/lily/head-grav.cc @@ -11,51 +11,55 @@ Note_head_engraver::Note_head_engraver() { - note_p_ = 0; - do_post_move_processing(); + note_p_ = 0; + do_post_move_processing(); } bool Note_head_engraver::do_try_request (Request *req_l) { - if (note_req_l_) + if (note_req_l_) return false; - - if (req_l->musical() && (req_l->musical ()->note () || req_l->musical ()->rest ())) + + if (req_l->musical() && (req_l->musical ()->note () || req_l->musical ()->rest ())) note_req_l_=req_l->musical()->rhythmic (); - else + else return false; - return true; + return true; } void Note_head_engraver::do_process_requests() { - if (!note_req_l_) + if (!note_req_l_) return; - - Note_head*n_p = new Note_head (8); // ugh - note_p_ = n_p; - n_p->set_rhythmic (note_req_l_->rhythmic()); + + Note_head*n_p = new Note_head (8); // ugh + note_p_ = n_p; + n_p->set_rhythmic (note_req_l_->rhythmic()); - if (note_req_l_->note()) { + if (note_req_l_->note()) + { n_p->position_i_ = note_req_l_->note()->height (); Staff_info inf = get_staff_info(); if (inf.c0_position_i_l_) n_p->position_i_ += *inf.c0_position_i_l_; - } else if (note_req_l_->rest()) { + } + else if (note_req_l_->rest()) + { n_p->rest_b_ = true; } - - Score_elem_info itinf (note_p_,note_req_l_); - announce_element (itinf); + + Score_elem_info itinf (note_p_,note_req_l_); + announce_element (itinf); } void Note_head_engraver::do_pre_move_processing() { - if (note_p_) { + if (note_p_) + { typeset_element (note_p_); note_p_ = 0; } @@ -63,7 +67,7 @@ Note_head_engraver::do_pre_move_processing() void Note_head_engraver::do_post_move_processing() { - note_req_l_ = 0; + note_req_l_ = 0; } diff --git a/lily/horizontal-align-item.cc b/lily/horizontal-align-item.cc index de24eed51d..163a1bf61c 100644 --- a/lily/horizontal-align-item.cc +++ b/lily/horizontal-align-item.cc @@ -14,28 +14,29 @@ void Horizontal_align_item::OK() const { for (int i =0; i < item_l_arr_.size(); i++) - assert ( pcol_l_ == item_l_arr_[i]->pcol_l_); + assert ( pcol_l_ == item_l_arr_[i]->pcol_l_); } bool Horizontal_align_item::contains_b (Item *i)const { - return item_l_arr_.find_l (i); + return item_l_arr_.find_l (i); } void Horizontal_align_item::add (Item *i,int p) { - assert (! contains_b (i)); - priority_i_arr_.push (p); - item_l_arr_.push (i); - add_dependency (i); + assert (! contains_b (i)); + priority_i_arr_.push (p); + item_l_arr_.push (i); + add_dependency (i); } void Horizontal_align_item::do_substitute_dependency (Score_elem*o,Score_elem*n) { - int i; - while ((i = item_l_arr_.find_i (o->item())) >=0) { + int i; + while ((i = item_l_arr_.find_i (o->item())) >=0) + { if (n) item_l_arr_[i] = n->item(); else @@ -44,25 +45,27 @@ Horizontal_align_item::do_substitute_dependency (Score_elem*o,Score_elem*n) } struct Horizontal_align_item_content { - Item * item_l_; - int priority_i_; - static int compare (Horizontal_align_item_content const &h1, - Horizontal_align_item_content const &h2) { + Item * item_l_; + int priority_i_; + static int compare (Horizontal_align_item_content const &h1, + Horizontal_align_item_content const &h2) + { return h1.priority_i_ - h2.priority_i_; } - Horizontal_align_item_content (Item*i, int p) { + Horizontal_align_item_content (Item*i, int p) + { priority_i_ = p; item_l_ = i; } - Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; } + Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; } }; void Horizontal_align_item::do_pre_processing() { - OK(); - { + OK(); + { Array content; for (int i =0; i < item_l_arr_.size(); i++) content.push ( @@ -71,43 +74,47 @@ Horizontal_align_item::do_pre_processing() content.sort (Horizontal_align_item_content::compare); item_l_arr_.clear(); priority_i_arr_.clear(); - for (int i =0; i < content.size(); i++) { + for (int i =0; i < content.size(); i++) + { item_l_arr_.push (content[i].item_l_); priority_i_arr_.push (content[i].priority_i_); - } + } } - - Array dims; - Real total =0; - for (int i =0; i < item_l_arr_.size(); i++) { + + Array dims; + Real total =0; + for (int i =0; i < item_l_arr_.size(); i++) + { Interval item_width= item_l_arr_[i]->width(); - if (item_width.empty_b()) { + if (item_width.empty_b()) + { item_width = Interval (0,0); - } + } dims.push (item_width); total += item_width.length(); } - Real where_f= total * (align_i_-1.0)/2.0; - Real center_dx_f = 0; - for ( int i=0 ; i < item_l_arr_.size(); i++) { + Real where_f= total * (align_i_-1.0)/2.0; + Real center_dx_f = 0; + for ( int i=0 ; i < item_l_arr_.size(); i++) + { Real dx = where_f -dims[i][-1]; item_l_arr_[i]->translate (dx , X_AXIS); if (item_l_arr_[i] == center_l_) center_dx_f = where_f; where_f += dims[i].length(); } - if (center_dx_f && !align_i_) + if (center_dx_f && !align_i_) for ( int i=0 ; i < item_l_arr_.size(); i++) item_l_arr_[i]->translate (- center_dx_f , X_AXIS); - + } Interval Horizontal_align_item::do_width() const { - return Interval (0,0); + return Interval (0,0); } void @@ -117,8 +124,8 @@ Horizontal_align_item::do_print()const Horizontal_align_item::Horizontal_align_item() { - center_l_ = 0; - align_i_ = 0; - empty_b_ = true; - transparent_b_ = true; + center_l_ = 0; + align_i_ = 0; + empty_b_ = true; + transparent_b_ = true; } diff --git a/lily/horizontal-group-item.cc b/lily/horizontal-group-item.cc index 409f2feadf..6b3afaf3da 100644 --- a/lily/horizontal-group-item.cc +++ b/lily/horizontal-group-item.cc @@ -14,5 +14,5 @@ IMPLEMENT_IS_TYPE_B2(Horizontal_group_item, Horizontal_group_element, Axis_group void Horizontal_group_item::do_print() const { - Axis_group_item::do_print(); + Axis_group_item::do_print(); } diff --git a/lily/idealspacing.cc b/lily/idealspacing.cc index 1209cc22f5..16298be1e1 100644 --- a/lily/idealspacing.cc +++ b/lily/idealspacing.cc @@ -15,22 +15,22 @@ void Idealspacing::print() const { #ifndef NPRINT - DOUT << "idealspacing {" ; - DOUT << "distance "<= 0); + assert (hooke_f_ >= 0); } diff --git a/lily/identifier.cc b/lily/identifier.cc index ff75e93311..ad7f5de1f4 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -24,36 +24,36 @@ IMPLEMENT_IS_TYPE_B(Identifier); Identifier::~Identifier() { - if (!accessed_b_ && !init_b_) + if (!accessed_b_ && !init_b_) warning ("Variable not used"); } void Identifier::error (String expect) { - String e ("Wrong identifier type: "); - e += String (name()) + "(expected " + expect + ")"; - ::error (e); + String e ("Wrong identifier type: "); + e += String (name()) + "(expected " + expect + ")"; + ::error (e); } Identifier::Identifier ( int code) { - token_code_i_ = code; - accessed_b_ = 0; - init_b_ = 0; + token_code_i_ = code; + accessed_b_ = 0; + init_b_ = 0; } void Identifier::print()const { - DOUT << "identifier "; - do_print(); + DOUT << "identifier "; + do_print(); } /* ugh. */ #define DEFAULT_PRINT(Class, Content_type, accessor) \ void \ Class::do_print() const { \ - ((Class*)this)->accessor()->print(); \ + ((Class*)this)->accessor()->print(); \ } \ class Class @@ -68,24 +68,29 @@ DEFAULT_PRINT(Score_id, Score, score); DEFAULT_PRINT(Midi_def_id,Midi_def, mididef); DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef); + +void +Duration_id::do_print()const +{} + void Real_id::do_print() const { - DOUT << *data_p_<< "\n"; + DOUT << *data_p_<< "\n"; } void Int_id::do_print() const { - DOUT << *data_p_<< "\n"; + DOUT << *data_p_<< "\n"; } #define DEFAULT_ACCESSOR(Idclass, Class, accessor)\ Class*\ Idclass::accessor () {\ - accessed_b_ = true;\ - return new Class (*data_p_);\ + accessed_b_ = true;\ + return new Class (*data_p_);\ } #define VIRTUAL_ACCESSOR(Idclass, Class, accessor)\ @@ -100,7 +105,7 @@ Idclass::accessor () {\ Idclass::~Idclass() { delete data_p_; }\ Idclass::Idclass (Class*st, int code):Identifier (code) { data_p_ = st; }\ - +IMPLEMENT_ID_CLASS(Duration_id, Duration, duration); IMPLEMENT_ID_CLASS(Input_translator_id, Input_translator, input_translator); IMPLEMENT_ID_CLASS(Int_id, int, intid); IMPLEMENT_ID_CLASS(Real_id, Real, real); @@ -115,9 +120,10 @@ IMPLEMENT_ID_CLASS(Paper_def_id, Paper_def, paperdef); Identifier::Identifier (Identifier const&) { - assert (false); + assert (false); } +DEFAULT_ACCESSOR(Duration_id, Duration, duration); DEFAULT_ACCESSOR(Input_translator_id,Input_translator, input_translator); DEFAULT_ACCESSOR(Int_id, int, intid); DEFAULT_ACCESSOR(Real_id, Real, real); diff --git a/lily/include/header.hh b/lily/include/header.hh new file mode 100644 index 0000000000..e48733ece4 --- /dev/null +++ b/lily/include/header.hh @@ -0,0 +1,21 @@ +/* + header.hh -- declare + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef HEADER_HH +#define HEADER_HH + +#include "string.hh" +#include "assoc.hh" + + +struct Header : Assoc +{ +}; + +#endif // HEADER_HH diff --git a/lily/include/identifier.hh b/lily/include/identifier.hh index 08e8346e80..dd4b8f75f8 100644 --- a/lily/include/identifier.hh +++ b/lily/include/identifier.hh @@ -42,6 +42,7 @@ struct Identifier : public Input { IDACCESSOR(Request, request) IDACCESSOR(Score, score) IDACCESSOR(int, intid) + IDACCESSOR(Duration, duration) protected: virtual void do_print()const=0; @@ -61,6 +62,7 @@ struct Idclass : Identifier {\ DECLARE_ID_CLASS(Input_translator_id, Input_translator, input_translator); +DECLARE_ID_CLASS(Duration_id, Duration, duration); DECLARE_ID_CLASS(Real_id, Real, real); DECLARE_ID_CLASS(Script_id, General_script_def, script); DECLARE_ID_CLASS(Lookup_id, Lookup, lookup); diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 5e42f95f1e..c024791de5 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -71,6 +71,7 @@ struct Global_translator; struct Group_change_req; struct Group_feature_req; struct Head_column; +struct Header; struct Horizontal_align_item; struct Horizontal_group_element; struct Horizontal_group_item; diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index d472a3ffa6..6928a0efea 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -44,6 +44,7 @@ public: void clear_notenames(); Identifier*lookup_identifier (String s); Melodic_req* lookup_melodic_req_l (String s); + void push_header_state(); void push_note_state(); void push_lyric_state(); void pop_state(); diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index cb75f8437f..41b8e2d38e 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -77,7 +77,10 @@ public: /** convert a duration to an idealspacing influence using the geometric_ and parameters. */ - Real duration_to_dist (Moment); + Real duration_to_dist (Moment, Real)const; + Real geometric_spacing(Moment)const; + Real arithmetic_constant(Moment minimal_mom)const; + Real arithmetic_spacing( Moment mom,Real constant)const; }; #endif // Paper_def_HH diff --git a/lily/include/score.hh b/lily/include/score.hh index e99e448a05..aa2501d9c2 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -28,6 +28,7 @@ public: Music * music_p_; Paper_score *pscore_p_; Audio_score* audio_score_p_; + Header * header_p_; int errorlevel_i_; diff --git a/lily/include/spring-spacer.hh b/lily/include/spring-spacer.hh index 27985d8e9e..e8dc25db3b 100644 --- a/lily/include/spring-spacer.hh +++ b/lily/include/spring-spacer.hh @@ -14,6 +14,7 @@ #include "plist.hh" #include "col-info.hh" #include "colhpos.hh" +#include "moment.hh" /** Determine positions of columns connected by springs and held apart by rods. @@ -41,64 +42,65 @@ */ class Spring_spacer : public Line_spacer { - friend class Durations_iter; + friend class Durations_iter; - Pointer_list ideal_p_list_; - Array cols; - Array loose_col_arr_; + Pointer_list ideal_p_list_; + Array cols; + Array loose_col_arr_; - /// mark column #i# as being loose. - void loosen_column (int i); - /// the index of #c# in #cols# - int col_id (PCol const *c) const; + /// mark column #i# as being loose. + void loosen_column (int i); + /// the index of #c# in #cols# + int col_id (PCol const *c) const; - /// generate an (nonoptimal) solution - Vector find_initial_solution() const; + /// generate an (nonoptimal) solution + Vector find_initial_solution() const; - /// check if problem is too tight - bool check_feasible() const; + /// check if problem is too tight + bool check_feasible() const; - /// does #this# contain the column #w#? - bool contains (PCol const *w); + /// does #this# contain the column #w#? + bool contains (PCol const *w); - /// make the energy function - void make_matrices (Matrix &quad, Vector &lin,Real&) const; + /// make the energy function + void make_matrices (Matrix &quad, Vector &lin,Real&) const; + void get_ruling_durations(Array&, Array&); - /// generate the LP constraints - void make_constraints (Mixed_qp& lp) const; + /// generate the LP constraints + void make_constraints (Mixed_qp& lp) const; - void handle_loose_cols(); - void position_loose_cols (Vector &) const; - /** - add a idealspacing to the problem. + void handle_loose_cols(); + void position_loose_cols (Vector &) const; + /** + add a idealspacing to the problem. One pair of columns can have no, one or more idealspacings, since they can be "summed" if the columns to which #i# refers are not in this problem, the spacing is ignored. */ - void add_ideal (Idealspacing const *i); - Vector try_initial_solution() const; - void calc_idealspacing(); - void set_fixed_cols (Mixed_qp&)const; - - Score_column* scol_l (int); - void connect (int i,int j, Real,Real); - Line_of_cols error_pcol_l_arr()const; + void add_ideal (Idealspacing const *i); + Vector try_initial_solution() const; + void calc_idealspacing(); + void set_fixed_cols (Mixed_qp&)const; + + Score_column* scol_l (int); + void connect (int i,int j, Real,Real); + Line_of_cols error_pcol_l_arr()const; public: - static Line_spacer *constructor(); + static Line_spacer *constructor(); - virtual void solve (Col_hpositions*) const; - virtual void lower_bound_solution (Col_hpositions*) const; - virtual void add_column (PCol *, bool fixed=false, Real fixpos=0.0); + virtual void solve (Col_hpositions*) const; + virtual void lower_bound_solution (Col_hpositions*) const; + virtual void add_column (PCol *, bool fixed=false, Real fixpos=0.0); - virtual Vector default_solution() const; - virtual bool check_constraints (Vector v) const; - virtual void OK() const; - virtual void print() const; - virtual void prepare(); - virtual ~Spring_spacer(){} + virtual Vector default_solution() const; + virtual bool check_constraints (Vector v) const; + virtual void OK() const; + virtual void print() const; + virtual void prepare(); + virtual ~Spring_spacer(){} }; #endif // SPRING_SPACER_HH diff --git a/lily/ineq-constrained-qp.cc b/lily/ineq-constrained-qp.cc index 29905fd3ae..f7b204fcff 100644 --- a/lily/ineq-constrained-qp.cc +++ b/lily/ineq-constrained-qp.cc @@ -17,41 +17,42 @@ const int MAXITER=100; // qlpsolve.hh /* - assume x (idx) == value, and adjust constraints, lin and quad accordingly + assume x (idx) == value, and adjust constraints, lin and quad accordingly - TODO: add const_term - */ + TODO: add const_term + */ void Ineq_constrained_qp::eliminate_var (int idx, Real value) { - Vector row (quad.row (idx)); - row*= value; + Vector row (quad.row (idx)); + row*= value; - quad.delete_row (idx); + quad.delete_row (idx); - quad.delete_column (idx); + quad.delete_column (idx); - lin.del (idx); - row.del (idx); - lin +=row ; + lin.del (idx); + row.del (idx); + lin +=row ; - for (int i=0; i < cons.size(); i++) { - consrhs[i] -= cons[i](idx) *value; - cons[i].del (idx); + for (int i=0; i < cons.size(); i++) + { + consrhs[i] -= cons[i](idx) *value; + cons[i].del (idx); } } void Ineq_constrained_qp::add_inequality_cons (Vector c, double r) { - cons.push (c); - consrhs.push (r); + cons.push (c); + consrhs.push (r); } Ineq_constrained_qp::Ineq_constrained_qp (int novars): - quad (novars), - lin (novars), - const_term (0.0) + quad (novars), + lin (novars), + const_term (0.0) { } @@ -59,77 +60,81 @@ void Ineq_constrained_qp::OK() const { #if !defined (NDEBUG) && defined (PARANOID) - assert (cons.size() == consrhs.size ()); - Matrix Qdif= quad - quad.transposed(); - assert (Qdif.norm()/quad.norm () < EPS); + assert (cons.size() == consrhs.size ()); + Matrix Qdif= quad - quad.transposed(); + assert (Qdif.norm()/quad.norm () < EPS); #endif } - + Real Ineq_constrained_qp::eval (Vector v) { - return v * quad * v + lin * v + const_term; + return v * quad * v + lin * v + const_term; } int min_elt_index (Vector v) { - Real m=infinity_f; - int idx=-1; - for (int i = 0; i < v.dim(); i++){ - if (v (i) < m) { + Real m=infinity_f; + int idx=-1; + for (int i = 0; i < v.dim(); i++) + { + if (v (i) < m) + { idx = i; m = v (i); - } + } assert (v (i) <= infinity_f); } - return idx; + return idx; } /**the numerical solving. Mordecai Avriel, Nonlinear Programming: analysis and methods (1976) - Prentice Hall. + Prentice Hall. - Section 13.3 + Section 13.3 - This is a "projected gradient" algorithm. Starting from a point x - the next point is found in a direction determined by projecting - the gradient onto the active constraints. (well, not really the - gradient. The optimal solution obeying the active constraints is - tried. This is why H = Q^-1 in initialisation)) + This is a "projected gradient" algorithm. Starting from a point x + the next point is found in a direction determined by projecting + the gradient onto the active constraints. (well, not really the + gradient. The optimal solution obeying the active constraints is + tried. This is why H = Q^-1 in initialisation)) - */ + */ Vector Ineq_constrained_qp::constraint_solve (Vector start) const { - if (!dim()) + if (!dim()) return Vector (0); - - // experimental - if (quad.dim() > 10) + + // experimental + if (quad.dim() > 10) quad.try_set_band(); - - Active_constraints act (this); - act.OK(); + + Active_constraints act (this); + act.OK(); - - Vector x (start); - Vector gradient=quad*x+lin; + + Vector x (start); + Vector gradient=quad*x+lin; // Real fvalue = x*quad*x/2 + lin*x + const_term; // it's no use. - Vector last_gradient (gradient); - int iterations=0; - - while (iterations++ < MAXITER) { + Vector last_gradient (gradient); + int iterations=0; + + while (iterations++ < MAXITER) + { Vector direction= - act.find_active_optimum (gradient); - + DOUT << "gradient "<< gradient<< "\ndirection " << direction<<"\n"; - if (direction.norm() > EPS) { + if (direction.norm() > EPS) + { DOUT << act.status() << '\n'; Real minalf = infinity_f; @@ -141,19 +146,21 @@ Ineq_constrained_qp::constraint_solve (Vector start) const we know the optimum on this "hyperplane". Check if we bump into the edges of the simplex */ - - for (Inactive_iter ia (act); ia.ok(); ia++) { + + for (Inactive_iter ia (act); ia.ok(); ia++) + { if (ia.vec() * direction >= 0) continue; Real alfa= - (ia.vec()*x - ia.rhs ())/ (ia.vec()*direction); - if (minalf > alfa) { + if (minalf > alfa) + { minidx = ia; minalf = alfa; - } - } + } + } Real unbounded_alfa = 1.0; Real optimal_step = min (minalf, unbounded_alfa); @@ -164,48 +171,55 @@ Ineq_constrained_qp::constraint_solve (Vector start) const DOUT << "step = " << optimal_step<< " (|dx| = " << deltax.norm() << ")\n"; - if (minalf < unbounded_alfa) { + if (minalf < unbounded_alfa) + { /* bumped into an edge. try again, in smaller space. */ act.add (minidx.idx()); DOUT << "adding cons "<< minidx.idx()<<'\n'; continue; - } + } /*ASSERT: we are at optimal solution for this "plane"*/ - - - } + + + } Vector lagrange_mult=act.get_lagrange (gradient); int m= min_elt_index (lagrange_mult); - if (m>=0 && lagrange_mult (m) > 0) { + if (m>=0 && lagrange_mult (m) > 0) + { break; // optimal sol. - } else if (m<0) { + } + else if (m<0) + { assert (gradient.norm() < EPS) ; break; - } + } DOUT << "dropping cons " << m<<'\n'; act.drop (m); } - if (iterations >= MAXITER) + if (iterations >= MAXITER) WARN<<"didn't converge!\n"; - - DOUT << ": found " << x<<" in " << iterations <<" iterations\n"; - assert_solution (x); - return x; + + DOUT << ": found " << x<<" in " << iterations <<" iterations\n"; + assert_solution (x); + return x; } - + Vector Ineq_constrained_qp::solve (Vector start)const { - /* no hassle if no constraints*/ - if ( ! cons.size()) { + /* no hassle if no constraints*/ + if ( ! cons.size()) + { Choleski_decomposition chol (quad); return - chol.solve (lin); - } else { + } + else + { return constraint_solve (start); } } diff --git a/lily/input-translator.cc b/lily/input-translator.cc index ddc0163053..34a65b7f3e 100644 --- a/lily/input-translator.cc +++ b/lily/input-translator.cc @@ -17,27 +17,27 @@ bool Input_translator::is_name_b (String n) { - for (int i=0; i < alias_str_arr_.size(); i++) + for (int i=0; i < alias_str_arr_.size(); i++) if (alias_str_arr_[i] == n) return true; - return false; + return false; } void Input_translator::print() const { #ifndef NPRINT - if ( ! check_debug) + if ( ! check_debug) return ; - DOUT << base_str_ <<" " << type_str_<<" {\n"; - DOUT << "Consists of "; - for (int i=0; i< consists_str_arr_.size(); i++) + DOUT << base_str_ <<" " << type_str_<<" {\n"; + DOUT << "Consists of "; + for (int i=0; i< consists_str_arr_.size(); i++) DOUT << consists_str_arr_[i] << ','; - if (contains_itrans_p_list_.size()) + if (contains_itrans_p_list_.size()) DOUT << "\nContains " ; - for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) + for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) i->print(); - DOUT << "}\n"; + DOUT << "}\n"; #endif } @@ -46,86 +46,90 @@ Input_translator::print() const Input_translator * Input_translator::recursive_find (String nm) { - if ( is_name_b (nm)) + if ( is_name_b (nm)) return this; - Input_translator * r =0; - // what bout for() ? - PCursor i (contains_itrans_p_list_.top()); - for (; !r &&i.ok(); i++) { + Input_translator * r =0; + // what bout for() ? + PCursor i (contains_itrans_p_list_.top()); + for (; !r &&i.ok(); i++) + { if (i->recursive_find (nm)) r = i.ptr(); } - return r; + return r; } Input_translator * Input_translator::find_itrans_l (String nm) { - for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) + for (PCursor i (contains_itrans_p_list_.top()); i.ok (); i++) if (i->is_name_b (nm)) return i; - return 0; + return 0; } Engraver_group_engraver * Input_translator::get_group_engraver_p() { - assert (base_str_ == "Engraver"); - Engraver_group_engraver * grav_p = (Engraver_group_engraver*) + assert (base_str_ == "Engraver"); + Engraver_group_engraver * grav_p = (Engraver_group_engraver*) get_engraver_p (type_str_); - for (int i=0; i < consists_str_arr_.size(); i++) { + for (int i=0; i < consists_str_arr_.size(); i++) + { grav_p->add (get_engraver_p (consists_str_arr_[i])); } - grav_p->itrans_l_ = this; - grav_p->id_str_ = default_id_str_; - return grav_p; + grav_p->itrans_l_ = this; + grav_p->id_str_ = default_id_str_; + return grav_p; } Performer_group_performer* Input_translator::get_group_performer_p() { - assert (base_str_ == "Performer"); - Performer_group_performer * perf_p = (Performer_group_performer*) + assert (base_str_ == "Performer"); + Performer_group_performer * perf_p = (Performer_group_performer*) get_performer_p (type_str_); - for (int i=0; i < consists_str_arr_.size(); i++) { + for (int i=0; i < consists_str_arr_.size(); i++) + { perf_p->add (get_performer_p (consists_str_arr_[i])); } - perf_p->itrans_l_ = this; - perf_p->id_str_ = default_id_str_; - return perf_p; + perf_p->itrans_l_ = this; + perf_p->id_str_ = default_id_str_; + return perf_p; } bool Input_translator::accept_req_b() { - return ! contains_itrans_p_list_.size(); + return ! contains_itrans_p_list_.size(); } void Input_translator::add (Input_translator *ip) { - contains_itrans_p_list_.bottom().add (ip); + contains_itrans_p_list_.bottom().add (ip); } Input_translator* Input_translator::get_default_itrans_l() { - if ( contains_itrans_p_list_.size()) + if ( contains_itrans_p_list_.size()) return contains_itrans_p_list_.top(); - else + else return 0; } Input_translator_list::Input_translator_list (Input_translator_list const &s) { - for (PCursor pc (s); pc.ok(); pc++) { + for (PCursor pc (s); pc.ok(); pc++) + { Input_translator *q = pc; Input_translator *p=new Input_translator (*q) ; bottom().add (p); diff --git a/lily/item.cc b/lily/item.cc index b47ac190e9..6c4a7699c8 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -14,10 +14,10 @@ Item::Item() { - breakable_b_ = false; - break_status_i_ = 0; - pcol_l_ = 0; - broken_to_a_[0] = broken_to_a_[1]=0; + breakable_b_ = false; + break_status_i_ = 0; + pcol_l_ = 0; + broken_to_a_[0] = broken_to_a_[1]=0; } IMPLEMENT_IS_TYPE_B1(Item, Score_elem); @@ -26,7 +26,7 @@ void Item::do_print() const { #ifndef NPRINT - DOUT << "(unknown)"; + DOUT << "(unknown)"; #endif } @@ -34,28 +34,29 @@ Item::do_print() const Real Item::hpos_f()const { - return pcol_l_->hpos_f_ + absolute_coordinate (X_AXIS); + return pcol_l_->hpos_f_ + absolute_coordinate (X_AXIS); } Line_of_score * Item::line_l()const { - return pcol_l_->line_l_; + return pcol_l_->line_l_; } int Item::break_status_i() const { - return break_status_i_; + return break_status_i_; } void Item::copy_breakable_items() { - if ( broken_to_a_[0] || broken_to_a_[1]) + if ( broken_to_a_[0] || broken_to_a_[1]) return; - Item *new_copies[2]; - for (int i=0; i < 2; i++) { + Item *new_copies[2]; + for (int i=0; i < 2; i++) + { Item * item_p = clone()->item (); item_p->copy_dependencies (*this); @@ -64,56 +65,56 @@ Item::copy_breakable_items() item_p->handle_prebroken_dependencies(); new_copies[i] =item_p; } - broken_to_a_= new_copies; + broken_to_a_= new_copies; } void Item::do_breakable_col_processing() { - if (!breakable_b_ || !pcol_l_->breakable_b()) + if (!breakable_b_ || !pcol_l_->breakable_b()) return; - copy_breakable_items(); - handle_prebroken_dependencies(); + copy_breakable_items(); + handle_prebroken_dependencies(); - /* - Otherwise the broken items won't be pre_process()'ed. - */ - add_dependency (broken_to_a_[0]); - add_dependency (broken_to_a_[1]); + /* + Otherwise the broken items won't be pre_process()'ed. + */ + add_dependency (broken_to_a_[0]); + add_dependency (broken_to_a_[1]); } Item* Item::find_prebroken_piece (Line_of_score*l) const { - if (line_l() == l) + if (line_l() == l) return (Item*)this; - else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l) + else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l) return broken_to_a_[0]; - else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l) + else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l) return broken_to_a_[1]; - return 0; + return 0; } Item* Item::find_prebroken_piece (PCol*c)const { - if (c == pcol_l_) + if (c == pcol_l_) return (Item *) this; // ugh - if (c == pcol_l_->prebreak_p_) + if (c == pcol_l_->prebreak_p_) return (Item *) broken_to_a_[0]; - else if (c==pcol_l_->postbreak_p_) + else if (c==pcol_l_->postbreak_p_) return (Item *)broken_to_a_[1]; - assert (false); + assert (false); } void Item::handle_prebroken_dependencies() { - if ( breakable_b_) + if ( breakable_b_) Score_elem::handle_prebroken_dependencies(); } diff --git a/lily/key-grav.cc b/lily/key-grav.cc index a29879bbf4..96d51998c4 100644 --- a/lily/key-grav.cc +++ b/lily/key-grav.cc @@ -20,14 +20,15 @@ Key_engraver::Key_engraver() { - kit_p_ = 0; - do_post_move_processing(); + kit_p_ = 0; + do_post_move_processing(); } void Key_engraver::create_key() { - if (!kit_p_) { + if (!kit_p_) + { int c0_i=0; Staff_info inf = get_staff_info(); @@ -36,31 +37,34 @@ Key_engraver::create_key() kit_p_ = new Key_item (c0_i); announce_element (Score_elem_info (kit_p_,keyreq_l_)); - kit_p_->read (*this); + kit_p_->read (*this); } } bool Key_engraver::do_try_request (Request * req_l) { - Command_req* creq_l= req_l->command(); - if (!creq_l|| !creq_l->keychange()) + Command_req* creq_l= req_l->command(); + if (!creq_l|| !creq_l->keychange()) return false; - - if (keyreq_l_) + + if (keyreq_l_) return false; // TODO - keyreq_l_ = creq_l->keychange(); - read_req (keyreq_l_); - return true; + keyreq_l_ = creq_l->keychange(); + read_req (keyreq_l_); + return true; } void Key_engraver::acknowledge_element (Score_elem_info info) { - Command_req * r_l = info.req_l_->command() ; - if (r_l && r_l->clefchange()) { + Command_req * r_l = info.req_l_->command() ; + if (r_l && r_l->clefchange()) + { create_key(); - } else if (info.elem_l_->name() == Bar::static_name ()) { + } + else if (info.elem_l_->name() == Bar::static_name ()) + { if ( !keyreq_l_) default_key_b_ = true; create_key(); @@ -71,9 +75,12 @@ Key_engraver::acknowledge_element (Score_elem_info info) void Key_engraver::do_process_requests() { - if (key_.multi_octave_b_) { + if (key_.multi_octave_b_) + { assert (false); // TODO . - } else if (keyreq_l_) { + } + else if (keyreq_l_) + { create_key(); } } @@ -81,7 +88,8 @@ Key_engraver::do_process_requests() void Key_engraver::do_pre_move_processing() { - if (kit_p_) { + if (kit_p_) + { kit_p_->default_b_ = default_key_b_; typeset_element (kit_p_); kit_p_ = 0; @@ -89,13 +97,14 @@ Key_engraver::do_pre_move_processing() } - + void Key_engraver::read_req (Key_change_req * r) { - key_.multi_octave_b_ = r->multi_octave_b_; - accidental_idx_arr_.clear(); - for (int i = 0; i < r->melodic_p_arr_.size(); i ++) { + key_.multi_octave_b_ = r->multi_octave_b_; + accidental_idx_arr_.clear(); + for (int i = 0; i < r->melodic_p_arr_.size(); i ++) + { Melodic_req * m_l =r->melodic_p_arr_[i]; int n_i =m_l->notename_i_; int a_i = m_l->accidental_i_; @@ -111,8 +120,8 @@ Key_engraver::read_req (Key_change_req * r) void Key_engraver::do_post_move_processing() { - keyreq_l_ = 0; - default_key_b_ = false; + keyreq_l_ = 0; + default_key_b_ = false; } diff --git a/lily/key-item.cc b/lily/key-item.cc index c765fd0206..12276dcbbf 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -22,17 +22,18 @@ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ Key_item::Key_item (int c) { - breakable_b_ =true; - default_b_ = false; - set_c_position (c); + breakable_b_ =true; + default_b_ = false; + set_c_position (c); } void Key_item::read (Key_engraver const & key_grav_r) { - assert (!key_grav_r.key_.multi_octave_b_); - const Array &idx_arr =key_grav_r.accidental_idx_arr_; - for (int i = 0 ; i< idx_arr.size(); i++) { + assert (!key_grav_r.key_.multi_octave_b_); + const Array &idx_arr =key_grav_r.accidental_idx_arr_; + for (int i = 0 ; i< idx_arr.size(); i++) + { int note = idx_arr[i]; int acc = ((Key &) key_grav_r.key_).oct (0).acc (note); @@ -43,44 +44,47 @@ Key_item::read (Key_engraver const & key_grav_r) void Key_item::set_c_position (int c0) { - int octaves =(abs (c0) / 7) +1 ; - c_position=(c0 + 7*octaves)%7; + int octaves =(abs (c0) / 7) +1 ; + c_position=(c0 + 7*octaves)%7; } void Key_item::add (int p, int a) { - if ((a<0 && p>FLAT_TOP_PITCH) || - (a>0 && p>SHARP_TOP_PITCH)) { - p -= 7; /* Typeset below c_position */ + if ((a<0 && p>FLAT_TOP_PITCH) || + (a>0 && p>SHARP_TOP_PITCH)) + { + p -= 7; /* Typeset below c_position */ } - pitch.push (p); - acc.push (a); + pitch.push (p); + acc.push (a); } Molecule* Key_item::brew_molecule_p()const { - Molecule*output = new Molecule; - Real inter = paper()->internote_f (); - - for (int i =0; i < pitch.size(); i++) { + Molecule*output = new Molecule; + Real inter = paper()->internote_f (); + + for (int i =0; i < pitch.size(); i++) + { Symbol s= paper()->lookup_l ()->accidental (acc[i]); Atom a (s); a.translate ((c_position + pitch[i]) * inter, Y_AXIS); Molecule m (a); output->add_right (m); } - if ( pitch.size()) { + if ( pitch.size()) + { Molecule m (paper()->lookup_l ()->fill (Box ( Interval (0, paper()->note_width ()), Interval (0,0)))); output->add_right (m); } - return output; + return output; } IMPLEMENT_IS_TYPE_B1(Key_item,Item); @@ -88,7 +92,8 @@ IMPLEMENT_IS_TYPE_B1(Key_item,Item); void Key_item::do_pre_processing() { - if (default_b_) { + if (default_b_) + { empty_b_ = transparent_b_ = (break_status_i() != 1); } } diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 0dfe7092f1..d4d0527aa0 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -17,7 +17,7 @@ ADD_THIS_PERFORMER(Key_performer); Key_performer::Key_performer() { - key_req_l_ = 0; + key_req_l_ = 0; } Key_performer::~Key_performer() @@ -28,31 +28,31 @@ void Key_performer::do_print() const { #ifndef NPRINT - if ( key_req_l_) - key_req_l_->print(); + if ( key_req_l_) + key_req_l_->print(); #endif } void Key_performer::process_requests() { - if ( key_req_l_) + if ( key_req_l_) play (new Audio_key (key_req_l_) ); - key_req_l_ = 0; + key_req_l_ = 0; } bool Key_performer::do_try_request (Request* req_l) { - if ( key_req_l_) + if ( key_req_l_) return false; - if ( req_l->command()) + if ( req_l->command()) key_req_l_ = req_l->command()->keychange (); - if ( key_req_l_) + if ( key_req_l_) return true; - return false; + return false; } diff --git a/lily/key.cc b/lily/key.cc index d755b68b3d..1a7892d4b1 100644 --- a/lily/key.cc +++ b/lily/key.cc @@ -16,40 +16,40 @@ const int ZEROOCTAVE=7; Octave_key::Octave_key() { - accidental_i_arr_.set_size (7); - for (int i= 0; i < 7 ; i++) + accidental_i_arr_.set_size (7); + for (int i= 0; i < 7 ; i++) accidental_i_arr_[i] = 0; } Key::Key() { - multi_octave_b_ = false; - octaves.set_size (OCTAVES); + multi_octave_b_ = false; + octaves.set_size (OCTAVES); } Octave_key& Key::oct (int i) { - return octaves[i+ZEROOCTAVE]; + return octaves[i+ZEROOCTAVE]; } void Octave_key::set (int i, int a) { - assert (a > -3 && a < 3); - accidental_i_arr_[i]=a; + assert (a > -3 && a < 3); + accidental_i_arr_[i]=a; } void Key::set (int o, int n , int a) { - octaves[o + ZEROOCTAVE].set (n,a); + octaves[o + ZEROOCTAVE].set (n,a); } void Key::set (int n, int a) { - for (int i= 0; i < OCTAVES ; i++) + for (int i= 0; i < OCTAVES ; i++) octaves[i].set (n,a); } diff --git a/lily/keyword.cc b/lily/keyword.cc index 4eec8b4f72..f027ee86d9 100644 --- a/lily/keyword.cc +++ b/lily/keyword.cc @@ -9,36 +9,36 @@ /* for the keyword table */ struct Keyword_ent { - char const *name; - int tokcode; + char const *name; + int tokcode; }; struct Keyword_table { - Keyword_ent *table; - int maxkey; - Keyword_table (Keyword_ent *); - int lookup (char const *s) const; + Keyword_ent *table; + int maxkey; + Keyword_table (Keyword_ent *); + int lookup (char const *s) const; }; /* for qsort */ int - tabcmp (void const * p1, void const * p2) + tabcmp (void const * p1, void const * p2) { - return strcmp (((Keyword_ent const *) p1)->name, - ((Keyword_ent const *) p2)->name); + return strcmp (((Keyword_ent const *) p1)->name, + ((Keyword_ent const *) p2)->name); } Keyword_table::Keyword_table (Keyword_ent *tab) { - table = tab; + table = tab; - /* count keywords */ - for (maxkey = 0; table[maxkey].name; maxkey++); + /* count keywords */ + for (maxkey = 0; table[maxkey].name; maxkey++); - /* sort them */ - qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); + /* sort them */ + qsort (table, maxkey, sizeof (Keyword_ent), tabcmp); } /* @@ -47,30 +47,31 @@ Keyword_table::Keyword_table (Keyword_ent *tab) int Keyword_table::lookup (char const *s)const { - int lo, - hi, - cmp, - result; - lo = 0; - hi = maxkey; + int lo, + hi, + cmp, + result; + lo = 0; + hi = maxkey; - /* binary search */ - do - { - cmp = (lo + hi) / 2; + /* binary search */ + do + { + cmp = (lo + hi) / 2; - result = strcmp (s, table[cmp].name); + result = strcmp (s, table[cmp].name); - if (result < 0) - hi = cmp; - else - lo = cmp; + if (result < 0) + hi = cmp; + else + lo = cmp; } - while (hi - lo > 1); - if (!strcmp (s, table[lo].name)) - { - return table[lo].tokcode; - } else - return -1; /* not found */ + while (hi - lo > 1); + if (!strcmp (s, table[lo].name)) + { + return table[lo].tokcode; + } + else + return -1; /* not found */ } diff --git a/lily/leastsquares.cc b/lily/leastsquares.cc index 7f274bf4d1..ab718a97f7 100644 --- a/lily/leastsquares.cc +++ b/lily/leastsquares.cc @@ -2,23 +2,24 @@ void Least_squares::OK() const { - assert (input.size() > 1); - Real dx = 0.0; - for (int i=1; i < input.size(); i++) + assert (input.size() > 1); + Real dx = 0.0; + for (int i=1; i < input.size(); i++) dx += abs (input[i-1].x() - input[i].x ()); - assert (dx); + assert (dx); } void Least_squares::minimise (Real &coef, Real &offset) { - OK(); - Real sx = 0.0; - Real sy = 0.0; - Real sqx =0.0; - Real sxy = 0.0; + OK(); + Real sx = 0.0; + Real sy = 0.0; + Real sqx =0.0; + Real sxy = 0.0; - for (int i=0; i < input.size();i++) { + for (int i=0; i < input.size();i++) + { Real x=input[i].x(); Real y = input[i].y(); sx += x; @@ -26,10 +27,10 @@ Least_squares::minimise (Real &coef, Real &offset) sqx += sqr (x); sxy += x*y; } - int N = input.size(); - + int N = input.size(); + - coef = (N * sxy - sx*sy)/(N*sqx - sqr (sx)); - offset = (sy - coef * sx)/N; + coef = (N * sxy - sx*sy)/(N*sqx - sqr (sx)); + offset = (sy - coef * sx)/N; } diff --git a/lily/lexer.l b/lily/lexer.l index 0372e75e98..8e702b7c79 100644 --- a/lily/lexer.l +++ b/lily/lexer.l @@ -22,6 +22,7 @@ #include +#include #include "string.hh" #include "string-convert.hh" @@ -32,6 +33,9 @@ #include "parseconstruct.hh" #include "main.hh" #include "identifier.hh" +void strip_trailing_white(String&); +void strip_leading_white(String&); + #define start_quote() \ yy_push_state(quote);\ @@ -52,6 +56,7 @@ %option warn %x incl +%x header %x lyrics %x notes %x quote @@ -73,6 +78,7 @@ INT -?{N}+ REAL ({INT}\.{N}*)|(-?\.{N}+) KEYWORD \\{WORD} WHITE [ \n\t\f] +HORIZONTALWHITE [ \t] BLACK [^ \n\t\f] RESTNAME [rs] NOTECOMMAND \\{A}+ @@ -94,7 +100,7 @@ LYRICS ({AA}|{NATIONAL})[^0-9 \t\n\f]* %[^{\n].* { } {WHITE}+ { - + } } @@ -107,13 +113,37 @@ LYRICS ({AA}|{NATIONAL})[^0-9 \t\n\f]* "%"+"}" { yy_pop_state(); } + <> { + LexerError("EOF found inside a comment"); + if (! close_input()) + yyterminate(); // can't move this, since it actually rets a YY_NULL + } } -<> { - LexerError("EOF found inside a comment"); - if (! close_input()) { - yyterminate(); // can't move this, since it actually rets a YY_NULL +
{ + [\{\}] { + return YYText()[0]; + } + ^{WORD} { + String s=YYText(); + yylval.string = new String(s); + return FIELDNAME; + } + {HORIZONTALWHITE}+{BLACK}.*\n { + String s=YYText(); + strip_leading_white(s); + strip_trailing_white(s); + yylval.string = new String(s); + return RECORDLINE; + } + {WHITE}* { + } + + . { + return YYText()[0]; } } + + \\include { yy_push_state(incl); } @@ -375,3 +405,29 @@ My_lily_lexer::lyric_state_b() const { return YY_START == lyrics; } + +void +My_lily_lexer::push_header_state() +{ + yy_push_state(header); +} + +void strip_trailing_white(String&s) +{ + int i=0; + for (; i < s.length_i(); i++) + if (!isspace(s[i])) + break; + + s = s.nomid_str(0, i); +} +void strip_leading_white(String&s) +{ + int i=s.length_i(); + while (i--) + if (!isspace(s[i])) + break; + + s = s.left_str(i+1); + +} diff --git a/lily/lexerinit.cc b/lily/lexerinit.cc index 698bc8bf7b..6f5cd27f26 100644 --- a/lily/lexerinit.cc +++ b/lily/lexerinit.cc @@ -26,5 +26,5 @@ yylex() { bool busy_parsing() { - return lexer; + return lexer; } diff --git a/lily/lily-version.cc b/lily/lily-version.cc index 65d8c72548..68a6b49037 100644 --- a/lily/lily-version.cc +++ b/lily/lily-version.cc @@ -10,7 +10,7 @@ static const int build= char const * lily_version_sz() { - static char v[1024]; // ugh - sprintf (v, s, build); - return v; + static char v[1024]; // ugh + sprintf (v, s, build); + return v; } diff --git a/lily/line-group-grav.cc b/lily/line-group-grav.cc index f023df2e1a..9d544d061e 100644 --- a/lily/line-group-grav.cc +++ b/lily/line-group-grav.cc @@ -15,13 +15,13 @@ Line_group_engraver::Line_group_engraver() { - staffline_p_ =0; + staffline_p_ =0; } void Line_group_engraver::acknowledge_element (Score_elem_info elem) { - if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS]) + if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS]) staffline_p_->add_element (elem.elem_l_); } @@ -29,19 +29,19 @@ Line_group_engraver::acknowledge_element (Score_elem_info elem) void Line_group_engraver::do_removal_processing() { - staffline_p_->right_col_l_ = get_staff_info().command_pcol_l (); - typeset_element (staffline_p_); - staffline_p_ = 0; + staffline_p_->right_col_l_ = get_staff_info().command_pcol_l (); + typeset_element (staffline_p_); + staffline_p_ = 0; } void Line_group_engraver::do_creation_processing() { - staffline_p_ = new Vertical_group_spanner ; - staffline_p_->left_col_l_ = get_staff_info().command_pcol_l (); + staffline_p_ = new Vertical_group_spanner ; + staffline_p_->left_col_l_ = get_staff_info().command_pcol_l (); - // don't broadcast to self. - announce_element (Score_elem_info (staffline_p_,0)); + // don't broadcast to self. + announce_element (Score_elem_info (staffline_p_,0)); } diff --git a/lily/line-spacer.cc b/lily/line-spacer.cc index 3729744ec0..5f51ad3ad4 100644 --- a/lily/line-spacer.cc +++ b/lily/line-spacer.cc @@ -11,10 +11,10 @@ Line_spacer::Line_spacer() { - paper_l_ =0; + paper_l_ =0; } Paper_def* Line_spacer::paper_l()const { - return paper_l_ ; + return paper_l_ ; } diff --git a/lily/local-key-grav.cc b/lily/local-key-grav.cc index b1e6cb6b90..82134c8608 100644 --- a/lily/local-key-grav.cc +++ b/lily/local-key-grav.cc @@ -17,15 +17,17 @@ Local_key_engraver::Local_key_engraver() { - key_C_ = 0; + key_C_ = 0; } void Local_key_engraver::do_pre_move_processing() { - Local_key_item *key_item_p = 0; - if (mel_l_arr_.size()) { - for (int i=0; i < mel_l_arr_.size(); i++) { + Local_key_item *key_item_p = 0; + if (mel_l_arr_.size()) + { + for (int i=0; i < mel_l_arr_.size(); i++) + { Item * support_l = support_l_arr_[i]; Note_req * note_l = mel_l_arr_[i]; @@ -37,10 +39,8 @@ Local_key_engraver::do_pre_move_processing() local_key_.oct (note_l->octave_i_).acc (note_l->notename_i_) == note_l->accidental_i_) continue; - - - - if (!key_item_p) { + if (!key_item_p) + { int c0_i=0; Staff_info inf = get_staff_info(); @@ -48,52 +48,61 @@ Local_key_engraver::do_pre_move_processing() c0_i = *get_staff_info().c0_position_i_l_; key_item_p = new Local_key_item (c0_i); - } + } key_item_p->add (note_l); key_item_p->add_support (support_l); local_key_.oct (note_l->octave_i_) .set (note_l->notename_i_, note_l->accidental_i_); - } + } } - if (key_item_p) { + if (key_item_p) + { for (int i=0; i < support_l_arr_.size(); i++) key_item_p->add_support (support_l_arr_[i]); announce_element (Score_elem_info (key_item_p, 0)); // ugh ugh ugh typeset_element (key_item_p); } - - mel_l_arr_.clear(); - tied_l_arr_.clear(); - support_l_arr_.clear(); - forced_l_arr_.clear(); + + mel_l_arr_.clear(); + tied_l_arr_.clear(); + support_l_arr_.clear(); + forced_l_arr_.clear(); } + /* whoah .. this looks hairy! */ void Local_key_engraver::acknowledge_element (Score_elem_info info) { - Score_elem * elem_l = info.elem_l_; - if (info.req_l_->musical() && info.req_l_->musical ()->note ()) { + Score_elem * elem_l = info.elem_l_; + if (info.req_l_->musical() && info.req_l_->musical ()->note ()) + { Note_req * note_l = info.req_l_->musical()->note (); Item * item_l = info.elem_l_->item(); mel_l_arr_.push (note_l); support_l_arr_.push (item_l); - } else if (info.req_l_->command() - && info.req_l_->command()->keychange ()) { + } + else if (info.req_l_->command() + && info.req_l_->command()->keychange ()) + { Key_engraver * key_grav_l = (Key_engraver*)info.origin_grav_l_arr_[0]; key_C_ = &key_grav_l->key_; local_key_ = *key_C_; - } else if (elem_l->name() == Key_item::static_name ()) { + } + else if (elem_l->name() == Key_item::static_name ()) + { Key_engraver * key_grav_l = (Key_engraver*)info.origin_grav_l_arr_[0]; key_C_ = &key_grav_l->key_; - } else if (elem_l->name() == Tie::static_name ()) { + } + else if (elem_l->name() == Tie::static_name ()) + { Tie * tie_l = (Tie*)elem_l->spanner(); if (tie_l->same_pitch_b_) tied_l_arr_.push (tie_l-> right_head_l_); @@ -103,8 +112,9 @@ Local_key_engraver::acknowledge_element (Score_elem_info info) void Local_key_engraver::do_process_requests() { - Time_description const * time_C_ = get_staff_info().time_C_; - if (time_C_ && !time_C_->whole_in_measure_){ + Time_description const * time_C_ = get_staff_info().time_C_; + if (time_C_ && !time_C_->whole_in_measure_) + { if (key_C_) local_key_= *key_C_; } diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 51464e9eb6..b81adc5fcf 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -19,59 +19,62 @@ Local_key_item::Local_key_item (int i) { - c0_position = i; + c0_position = i; } void Local_key_item::add_support (Item*head_l) { - support_items_.push (head_l); - add_dependency (head_l); + support_items_.push (head_l); + add_dependency (head_l); } void Local_key_item::add (Melodic_req*m_l) { - add (m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); + add (m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); } void Local_key_item::add (int o, int p , int a) { - Local_acc l; - l.octave_i_ = o; - l.name_i_ = p; - l.accidental_i_ = a; - for (int i=0; i< accs.size(); i++) + Local_acc l; + l.octave_i_ = o; + l.name_i_ = p; + l.accidental_i_ = a; + for (int i=0; i< accs.size(); i++) if (!Local_acc::compare (l, accs[i])) return; - - accs.push (l); + + accs.push (l); } void Local_key_item::do_pre_processing() { - accs.sort (Local_acc::compare); + accs.sort (Local_acc::compare); } Molecule* Local_key_item::brew_molecule_p()const { - Molecule* output = new Molecule; - Molecule*octmol = 0; - int lastoct = -100; - for (int i = 0; i < accs.size(); i++) { + Molecule* output = new Molecule; + Molecule*octmol = 0; + int lastoct = -100; + for (int i = 0; i < accs.size(); i++) + { // do one octave - if (accs[i].octave_i_ != lastoct) { - if (octmol){ + if (accs[i].octave_i_ != lastoct) + { + if (octmol) + { Real dy =lastoct*7*paper()->internote_f (); octmol->translate (dy, Y_AXIS); output->add (*octmol); delete octmol; - } + } octmol= new Molecule; - } + } lastoct = accs[i].octave_i_; Symbol s =paper()->lookup_l ()->accidental (accs[i].accidental_i_); Atom a (s); @@ -81,28 +84,29 @@ Local_key_item::brew_molecule_p()const octmol->add_right (a); } - if (octmol){ + if (octmol) + { Real dy =lastoct*7*paper()->internote_f (); octmol->translate (dy, Y_AXIS); output->add (*octmol); delete octmol; } - Interval head_width=itemlist_width (support_items_); - output->translate (-output->extent().x ().right + head_width.left , X_AXIS); - - return output; + Interval head_width=itemlist_width (support_items_); + output->translate (-output->extent().x ().right + head_width.left , X_AXIS); + + return output; } int Local_acc::compare (Local_acc&a, Local_acc&b) { - if (a.octave_i_ - b.octave_i_) + if (a.octave_i_ - b.octave_i_) return a.octave_i_ - b.octave_i_; - if (a.name_i_ - b.name_i_) + if (a.name_i_ - b.name_i_) return a.name_i_ - b.name_i_; - - return a.accidental_i_ - b.accidental_i_; + + return a.accidental_i_ - b.accidental_i_; }; IMPLEMENT_IS_TYPE_B1(Local_key_item,Item); @@ -110,8 +114,8 @@ IMPLEMENT_IS_TYPE_B1(Local_key_item,Item); void Local_key_item::do_substitute_dependency (Score_elem*o,Score_elem*n) { - Item* o_l = o->item(); - Item* n_l = n?n->item():0; + Item* o_l = o->item(); + Item* n_l = n?n->item():0; - support_items_.substitute (o_l, n_l); + support_items_.substitute (o_l, n_l); } diff --git a/lily/lookup.cc b/lily/lookup.cc index 6cdf835604..18407dece2 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -22,51 +22,51 @@ Lookup::Lookup() { - paper_l_ = 0; - texsetting = "\\unknowntexsetting"; - symtables_ = new Symtables; + paper_l_ = 0; + texsetting = "\\unknowntexsetting"; + symtables_ = new Symtables; } Lookup::Lookup (Lookup const &s) { - paper_l_ = s.paper_l_; - texsetting = s.texsetting; - symtables_ = new Symtables (*s.symtables_); + paper_l_ = s.paper_l_; + texsetting = s.texsetting; + symtables_ = new Symtables (*s.symtables_); } Lookup::~Lookup() { - delete symtables_; + delete symtables_; } void Lookup::add (String s, Symtable*p) { - symtables_->add (s, p); + symtables_->add (s, p); } void Lookup::print()const { - #ifndef NPRINT - DOUT << "Lookup: " << texsetting << " {\n"; - symtables_->print(); - DOUT << "}\n"; - #endif + #ifndef NPRINT + DOUT << "Lookup: " << texsetting << " {\n"; + symtables_->print(); + DOUT << "}\n"; + #endif } Symbol Lookup::text (String style, String text, int dir) const { - Array a; + Array a; - a.push (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 = tsym.dim; - return s; + a.push (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 = tsym.dim; + return s; } @@ -74,170 +74,175 @@ Lookup::text (String style, String text, int dir) const Symbol Lookup::ball (int j) const { - if (j > 4) - j = 4; + if (j > 2) + j = 2; - Symtable * st = (*symtables_)("balls"); - return st->lookup (String (j)); + Symtable * st = (*symtables_)("balls"); + return st->lookup (String (j)); } Symbol Lookup::rest (int j, bool o) const { - return (*symtables_)("rests")->lookup (String (j) + (o ? "o" : "")); + return (*symtables_)("rests")->lookup (String (j) + (o ? "o" : "")); } Symbol Lookup::fill (Box b) const { - Symbol s ((*symtables_)("param")->lookup ("fill")); - s.dim = b; - return s; + Symbol s ((*symtables_)("param")->lookup ("fill")); + s.dim = b; + return s; } Symbol Lookup::accidental (int j) const { - return (*symtables_)("accidentals")->lookup (String (j)); + return (*symtables_)("accidentals")->lookup (String (j)); } Symbol Lookup::bar (String s, Real h) const { - Array a; - a.push (print_dimen (h)); - Symbol ret=(*symtables_)("bars")->lookup (s);; - ret.tex = substitute_args (ret.tex, a); - ret.dim.y() = Interval (0, h); - return ret; + Array a; + a.push (print_dimen (h)); + Symbol ret=(*symtables_)("bars")->lookup (s);; + ret.tex = substitute_args (ret.tex, a); + ret.dim.y() = Interval (0, h); + return ret; } Symbol Lookup::script (String s) const { - return (*symtables_)("scripts")->lookup (s); + return (*symtables_)("scripts")->lookup (s); } Symbol Lookup::dynamic (String s) const { - return (*symtables_)("dynamics")->lookup (s); + return (*symtables_)("dynamics")->lookup (s); } Symbol Lookup::clef (String s) const { - return (*symtables_)("clefs")->lookup (s); + return (*symtables_)("clefs")->lookup (s); } Symbol Lookup::dots (int j) const { - if (j>3) { + if (j>3) + { j = 3; warning ("max 3 dots"); // todo } - return (*symtables_)("dots")->lookup (j); + return (*symtables_)("dots")->lookup (j); } Symbol Lookup::flag (int j) const { - return (*symtables_)("flags")->lookup (j); + return (*symtables_)("flags")->lookup (j); } Symbol Lookup::streepjes (int i) const { - assert (i); - - int arg; - String idx; - - if (i < 0) { + assert (i); + + int arg; + String idx; + + if (i < 0) + { idx = "botlines"; arg = -i; - } else { + } + else + { arg = i; idx = "toplines"; } - Symbol ret = (*symtables_)("streepjes")->lookup (idx); - - Array a; - a.push (arg); - ret.tex = substitute_args (ret.tex, a); + Symbol ret = (*symtables_)("streepjes")->lookup (idx); + + Array a; + a.push (arg); + ret.tex = substitute_args (ret.tex, a); - return ret; + return ret; } Symbol Lookup::hairpin (Real &wid, bool decresc) const { - int idx = int (rint (wid / 6 PT)); - if (!idx) idx ++; - wid = idx*6 PT; - String idxstr = (decresc)? "decrescendosym" : "crescendosym"; - Symbol ret=(*symtables_)("param")->lookup (idxstr); - - Array a; - a.push (idx); - ret.tex = substitute_args (ret.tex, a); - ret.dim.x() = Interval (0,wid); - return ret; + int idx = int (rint (wid / 6 PT)); + if (!idx) idx ++; + wid = idx*6 PT; + String idxstr = (decresc)? "decrescendosym" : "crescendosym"; + Symbol ret=(*symtables_)("param")->lookup (idxstr); + + Array a; + a.push (idx); + ret.tex = substitute_args (ret.tex, a); + ret.dim.x() = Interval (0,wid); + return ret; } Symbol Lookup::linestaff (int lines, Real wid) const { - Real internote_f = paper_l_ ->internote_f(); - Symbol s; - Real dy = (lines >0) ? (lines-1)*internote_f : 0; - s.dim = Box (Interval (0,wid), Interval (0,dy)); + Real internote_f = paper_l_ ->internote_f(); + Symbol s; + Real dy = (lines >0) ? (lines-1)*internote_f : 0; + s.dim = Box (Interval (0,wid), Interval (0,dy)); - Array a; - a.push (lines); - a.push (print_dimen (wid)); + Array a; + a.push (lines); + a.push (print_dimen (wid)); - s.tex = (*symtables_)("param")->lookup ("linestaf").tex; - s.tex = substitute_args (s.tex, a); + s.tex = (*symtables_)("param")->lookup ("linestaf").tex; + s.tex = substitute_args (s.tex, a); - return s; + return s; } Symbol Lookup::meter (Array a) const { - Symbol s; - s.dim.x() = Interval (0 PT, 10 PT); - s.dim.y() = Interval (0, 20 PT); // todo - String src = (*symtables_)("param")->lookup ("meter").tex; - s.tex = substitute_args (src,a); - return s; + Symbol s; + s.dim.x() = Interval (0 PT, 10 PT); + s.dim.y() = Interval (0, 20 PT); // todo + String src = (*symtables_)("param")->lookup ("meter").tex; + s.tex = substitute_args (src,a); + return s; } Symbol Lookup::stem (Real y1,Real y2) const { - if (y1 > y2) { + if (y1 > y2) + { Real t = y1; y1 = y2; y2 = t; } - Symbol s; - - s.dim.x() = Interval (0,0); - s.dim.y() = Interval (y1,y2); - - Array a; - a.push (print_dimen (y1)); - a.push (print_dimen (y2)); + Symbol s; + + s.dim.x() = Interval (0,0); + s.dim.y() = Interval (y1,y2); + + Array a; + a.push (print_dimen (y1)); + a.push (print_dimen (y2)); - String src = (*symtables_)("param")->lookup ("stem").tex; - s.tex = substitute_args (src,a); - return s; + String src = (*symtables_)("param")->lookup ("stem").tex; + s.tex = substitute_args (src,a); + return s; } /* @@ -246,25 +251,27 @@ Lookup::stem (Real y1,Real y2) const Symbol Lookup::vbrace (Real &y) const { - if (y < 2* 20 PT) { + if (y < 2* 20 PT) + { warning ( "piano brace too small (" + print_dimen (y)+ ")"); y = 2*20 PT; } - if (y > 67 * 2 PT) { + if (y > 67 * 2 PT) + { warning ( "piano brace too big (" + print_dimen (y)+ ")"); y = 67 *2 PT; } - - int idx = int (rint ((y/2.0 - 20) + 148)); - - Symbol s = (*symtables_)("param")->lookup ("brace"); - { + + int idx = int (rint ((y/2.0 - 20) + 148)); + + Symbol s = (*symtables_)("param")->lookup ("brace"); + { Array a; a.push (idx); s.tex = substitute_args (s.tex,a); s.dim.y() = Interval (0,y); } - { + { Array a; a.push (print_dimen (y/2)); a.push (print_dimen (0)); @@ -273,5 +280,5 @@ Lookup::vbrace (Real &y) const } - return s; + return s; } diff --git a/lily/lyric-grav.cc b/lily/lyric-grav.cc index c4a09ac34c..c29b46d5fe 100644 --- a/lily/lyric-grav.cc +++ b/lily/lyric-grav.cc @@ -15,25 +15,26 @@ Lyric_engraver::Lyric_engraver() { - lreq_l_ =0; - lyric_item_p_ =0; + lreq_l_ =0; + lyric_item_p_ =0; } bool Lyric_engraver::do_try_request (Request*r) { - Musical_req * m =r->musical(); - if (!m || ! m->lreq_l()) + Musical_req * m =r->musical(); + if (!m || ! m->lreq_l()) return false; - lreq_l_ = m->lreq_l(); + lreq_l_ = m->lreq_l(); - return true; + return true; } void Lyric_engraver::do_process_requests() { - if ( lreq_l_) { + if ( lreq_l_) + { lyric_item_p_ = new Text_item (lreq_l_->tdef_p_); lyric_item_p_->translate (paper()->note_width ()/2 , X_AXIS); @@ -46,13 +47,14 @@ Lyric_engraver::do_process_requests() void Lyric_engraver::do_post_move_processing() { - lreq_l_ =0; + lreq_l_ =0; } void Lyric_engraver::do_pre_move_processing() { - if ( lyric_item_p_){ + if ( lyric_item_p_) + { typeset_element (lyric_item_p_); lyric_item_p_ =0; } diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index cccc64216d..b800f3d1ad 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -28,27 +28,27 @@ void Lyric_performer::do_print() const { #ifndef NPRINT - if ( lreq_arr_.size()) - lreq_arr_[ 0 ]->print(); + if ( lreq_arr_.size()) + lreq_arr_[ 0 ]->print(); #endif } void Lyric_performer::process_requests() { - if ( lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i() ) + if ( lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i() ) play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_) ); - lreq_arr_.clear(); + lreq_arr_.clear(); } bool Lyric_performer::do_try_request (Request* req_l) { - Musical_req* m_l = req_l->musical(); - if ( !m_l || ! m_l->lreq_l()) + Musical_req* m_l = req_l->musical(); + if ( !m_l || ! m_l->lreq_l()) return false; - lreq_arr_.push (m_l->lreq_l()); + lreq_arr_.push (m_l->lreq_l()); - return true; + return true; } diff --git a/lily/main.cc b/lily/main.cc index a32b0a6a86..eb9f611543 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -28,27 +28,27 @@ int exit_status_i_; void destill_inname (String &name_str_r); Long_option_init theopts[] = { - {1, "output", 'o'}, - {0, "warranty", 'w'}, - {0, "help", 'h'}, - {0, "debug", 'd'}, - {1, "init", 'i'}, - {1, "include", 'I'}, - {0, "midi", 'M'}, - {0, "ignore-version", 'V'}, - {0,0,0} + {1, "output", 'o'}, + {0, "warranty", 'w'}, + {0, "help", 'h'}, + {0, "debug", 'd'}, + {1, "init", 'i'}, + {1, "include", 'I'}, + {0, "midi", 'M'}, + {0, "ignore-version", 'V'}, + {0,0,0} }; void usage() { - cout << - "Usage: lilypond [options] [mudela-file]\n" + cout << + "Usage: lilypond [options] [mudela-file]\n" "Typeset and or produce midi output from mudela-file or stdin\n" "\n" "Options:\n" " -d, --debug enable debugging output\n" - " -I, --include=DIR add DIR to search path\n" + " -I, --include=DIR add DIR to search path\n" " -i, --init=FILE use FILE as init file\n" " -h, --help this help\n" " -w, --warranty show warranty and copyright\n" @@ -71,14 +71,14 @@ usage() "\n"; ; - - + + } void notice() { - cout << + cout << "\n" "GNU LilyPond -- The GNU Project music typesetter.\n" "Copyright 1996,97 by\n" @@ -106,49 +106,54 @@ static File_path path; void do_one_file (String init_str, String file_str) { - if ( init_str != "" && "" == path.find (init_str) ) { + if ( init_str != "" && "" == path.find (init_str) ) + { error ( "Can not find `" + init_str +"\'"); return ; } - if ( file_str!= "" && path.find (file_str) == "" ) { + if ( file_str!= "" && path.find (file_str) == "" ) + { error ( "Can not find `" + file_str + "'"); return ; } - - Sources sources; - source_l_g = &sources; - source_l_g->set_path (&path); - { + + Sources sources; + source_l_g = &sources; + source_l_g->set_path (&path); + { My_lily_parser parser (source_l_g); parser.set_version_check (version_ignore_b_); parser.parse_file (init_str, file_str); } - do_scores(); - source_l_g = 0; + do_scores(); + source_l_g = 0; } int main (int argc, char **argv) { - debug_init(); // should be first + debug_init(); // should be first - // must override (come before) "/usr/local/share/lilypond"! - char const * env_l=getenv ("LILYINCLUDE"); - if (env_l) { + // must override (come before) "/usr/local/share/lilypond"! + char const * env_l=getenv ("LILYINCLUDE"); + if (env_l) + { path.add (env_l); } - path.add (""); - path.add (String (DIR_DATADIR) + "/init/" ); - - path.push (DIR_DATADIR); - - Getopt_long oparser (argc, argv,theopts); - cout << get_version_str() << endl; - String init_str ("symbol.ly"); - - while (Long_option_init const * opt = oparser()) { - switch ( opt->shortname){ + path.add (""); + path.add (String (DIR_DATADIR) + "/init/" ); + + path.push (DIR_DATADIR); + + Getopt_long oparser (argc, argv,theopts); + cout << get_version_str() << endl; + String init_str ("symbol.ly"); + + while (Long_option_init const * opt = oparser()) + { + switch ( opt->shortname) + { case 'o': set_default_output (oparser.optional_argument_ch_C_); break; @@ -178,31 +183,33 @@ main (int argc, char **argv) default: assert (false); break; - } + } } - int p=0; - const char *arg ; - while ( (arg= oparser.get_next_arg())) { + int p=0; + const char *arg ; + while ( (arg= oparser.get_next_arg())) + { String f (arg); destill_inname (f); do_one_file (init_str,f); p++; } - if (!p) { + if (!p) + { do_one_file (init_str, ""); } - return exit_status_i_; + return exit_status_i_; } /// make input file name: add default extension. "" is stdin. void destill_inname (String &name_str_r) { - if ( name_str_r.length_i()) - { - if (name_str_r[ 0 ] != '-') + if ( name_str_r.length_i()) + { + if (name_str_r[ 0 ] != '-') { String a,b,c,d; split_path (name_str_r,a,b,c,d); @@ -211,7 +218,8 @@ destill_inname (String &name_str_r) if (d == "") d = ".ly"; name_str_r = a+b+c+d; - } - } else name_str_r = ""; + } + } + else name_str_r = ""; } diff --git a/lily/meter-grav.cc b/lily/meter-grav.cc index eff12b4a6c..7f5a0d3bc8 100644 --- a/lily/meter-grav.cc +++ b/lily/meter-grav.cc @@ -13,78 +13,93 @@ Meter_engraver::Meter_engraver() { - meter_req_l_ = 0; - meter_p_ =0; - default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh + meter_req_l_ = 0; + meter_p_ =0; + default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh } void Meter_engraver::fill_staff_info (Staff_info&inf) { - inf.time_C_ = &time_; - inf.rhythmic_C_ = &default_grouping_; + inf.time_C_ = &time_; + inf.rhythmic_C_ = &default_grouping_; } bool Meter_engraver::do_try_request (Request*r) { - bool gotcha = false; + bool gotcha = false; - if (r->command() && r->command ()->timing ()) { + if (r->command() && r->command ()->timing ()) + { gotcha = true; Timing_req * tr_l = r->command()->timing (); Meter_change_req *m_l = tr_l->meterchange(); - if (m_l) { + if (m_l) + { meter_req_l_ = m_l; int b_i= m_l->beats_i_; int o_i = m_l->one_beat_i_; if (! time_.allow_meter_change_b()) tr_l->warning ("Meter change not allowed here"); - else{ + else + { time_.set_meter (b_i, o_i); default_grouping_ = Rhythmic_grouping (MInterval (0,Moment (b_i, o_i)), b_i); - } - } else if (tr_l->partial()) { + } + } + else if (tr_l->partial()) + { Moment m = tr_l->partial()->duration_; String error = time_.try_set_partial_str (m); - if (error != "") { + if (error != "") + { tr_l->warning (error); - } else + } + else time_.setpartial (m); - } else if (tr_l->barcheck()) { - if (time_.whole_in_measure_) { + } + else if (tr_l->barcheck()) + { + if (time_.whole_in_measure_) + { tr_l ->warning ("Barcheck failed"); time_.whole_in_measure_ = 0; // resync time_.error_b_ = true; - } + } - } else if (tr_l->cadenza()) { + } + else if (tr_l->cadenza()) + { time_.set_cadenza (tr_l->cadenza()->on_b_); - } else if (tr_l->measuregrouping()) { + } + else if (tr_l->measuregrouping()) + { default_grouping_ = parse_grouping ( tr_l->measuregrouping()->beat_i_arr_, tr_l->measuregrouping()->elt_length_arr_); } } - - return gotcha; + + return gotcha; } void Meter_engraver::do_creation_processing() { - time_.when_ = get_staff_info().when (); + time_.when_ = get_staff_info().when (); } void Meter_engraver::do_process_requests() { - if (meter_req_l_) { + if (meter_req_l_) + { Array args; args.push (meter_req_l_->beats_i_); args.push (meter_req_l_->one_beat_i_); @@ -92,33 +107,35 @@ Meter_engraver::do_process_requests() meter_p_ = new Meter (args); } - if (meter_p_) + if (meter_p_) announce_element (Score_elem_info (meter_p_, meter_req_l_)); } void Meter_engraver::do_pre_move_processing() { - if (meter_p_) { + if (meter_p_) + { typeset_element (meter_p_); meter_p_ =0; meter_req_l_ = 0; } - Engraver_group_engraver * grav_l = daddy_grav_l_; - while (grav_l->daddy_grav_l_) { + Engraver_group_engraver * grav_l = daddy_grav_l_; + while (grav_l->daddy_grav_l_) + { grav_l = grav_l->daddy_grav_l_; } - - assert (grav_l->name() == Score_engraver::static_name ()); - if (!time_.cadenza_b_) + + assert (grav_l->name() == Score_engraver::static_name ()); + if (!time_.cadenza_b_) ((Score_engraver*)grav_l)->add_moment_to_process (time_.next_bar_moment()); } void Meter_engraver::do_post_move_processing() { - time_.add (get_staff_info().when () - time_.when_); + time_.add (get_staff_info().when () - time_.when_); } diff --git a/lily/meter-performer.cc b/lily/meter-performer.cc index 6d6d1ee4a9..0d23bb9a9b 100644 --- a/lily/meter-performer.cc +++ b/lily/meter-performer.cc @@ -15,7 +15,7 @@ ADD_THIS_PERFORMER(Meter_performer); Meter_performer::Meter_performer() { - meter_req_l_ = 0; + meter_req_l_ = 0; } Meter_performer::~Meter_performer() @@ -26,31 +26,31 @@ void Meter_performer::do_print() const { #ifndef NPRINT - if ( meter_req_l_) - meter_req_l_->print(); + if ( meter_req_l_) + meter_req_l_->print(); #endif } void Meter_performer::process_requests() { - if ( meter_req_l_) + if ( meter_req_l_) play (new Audio_meter (meter_req_l_) ); - meter_req_l_ = 0; + meter_req_l_ = 0; } bool Meter_performer::do_try_request (Request* req_l) { - if ( meter_req_l_) + if ( meter_req_l_) return false; - if ( req_l->command()) + if ( req_l->command()) meter_req_l_ = req_l->command()->meterchange (); - if ( meter_req_l_) + if ( meter_req_l_) return true; - return false; + return false; } diff --git a/lily/meter.cc b/lily/meter.cc index dc7efa3a5c..e8fcd8f9f0 100644 --- a/lily/meter.cc +++ b/lily/meter.cc @@ -5,16 +5,16 @@ #include "lookup.hh" Meter::Meter (Arraya) - :args (a) + :args (a) { - breakable_b_ = true; + breakable_b_ = true; } Molecule* Meter::brew_molecule_p()const { - Symbol s = paper()->lookup_l ()->meter (args); - return new Molecule (Atom (s)); + Symbol s = paper()->lookup_l ()->meter (args); + return new Molecule (Atom (s)); } diff --git a/lily/midi-def.cc b/lily/midi-def.cc index 95b3e25b0c..2307155ba8 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -29,66 +29,66 @@ int Midi_def::num_i_s = 4; Midi_def::Midi_def() { - outfile_str_ = ""; - itrans_p_ = 0; - // ugh - set_tempo (Moment (1, 4), 60 ); + outfile_str_ = ""; + itrans_p_ = 0; + // ugh + set_tempo (Moment (1, 4), 60 ); } Midi_def::Midi_def (Midi_def const& s) { - whole_seconds_f_ = s.whole_seconds_f_; - itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_) : 0; - outfile_str_ = s.outfile_str_; + whole_seconds_f_ = s.whole_seconds_f_; + itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_) : 0; + outfile_str_ = s.outfile_str_; } Midi_def::~Midi_def() { - delete itrans_p_; + delete itrans_p_; } Real Midi_def::duration_to_seconds_f (Moment mom) { - if ( !mom) + if ( !mom) return 0; - - return Moment (whole_seconds_f_) * mom; + + return Moment (whole_seconds_f_) * mom; } Global_translator* Midi_def::get_global_translator_p() const { - return itrans_p_->get_group_performer_p()->global_l (); + return itrans_p_->get_group_performer_p()->global_l (); } int Midi_def::get_tempo_i (Moment moment) { - return Moment (whole_seconds_f_) * Moment (60 ) * moment; + return Moment (whole_seconds_f_) * Moment (60 ) * moment; } void Midi_def::print() const { #ifndef NPRINT - DOUT << "Midi {"; - DOUT << "4/min: " << Real (60) / ( whole_seconds_f_ * 4 ); - DOUT << "out: " << outfile_str_; - DOUT << "}\n"; + DOUT << "Midi {"; + DOUT << "4/min: " << Real (60) / ( whole_seconds_f_ * 4 ); + DOUT << "out: " << outfile_str_; + DOUT << "}\n"; #endif } void Midi_def::set (Input_translator* itrans_p) { - delete itrans_p_; - itrans_p_ = itrans_p; + delete itrans_p_; + itrans_p_ = itrans_p; } void Midi_def::set_tempo (Moment moment, int count_per_minute_i) { - whole_seconds_f_ = Moment (count_per_minute_i) / Moment (60 ) / moment; + whole_seconds_f_ = Moment (count_per_minute_i) / Moment (60 ) / moment; } diff --git a/lily/midi-item.cc b/lily/midi-item.cc index b2341e1734..47af53eb3b 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -32,451 +32,451 @@ IMPLEMENT_IS_TYPE_B1(Midi_text, Midi_item); IMPLEMENT_IS_TYPE_B1(Midi_track, Midi_chunk); Midi_chunk::Midi_chunk() - : Midi_item (0) + : Midi_item (0) { } void Midi_chunk::add (String str) { - data_str_ += str; + data_str_ += str; } void Midi_chunk::set (String header_str, String data_str, String footer_str) { - data_str_ = data_str; - footer_str_ = footer_str; - header_str_ = header_str; + data_str_ = data_str; + footer_str_ = footer_str; + header_str_ = header_str; } String Midi_chunk::str() const { - String str = header_str_; - String length_str = String_convert::i2hex_str (data_str_.length_i() + footer_str_.length_i (), 8, '0'); - length_str = String_convert::hex2bin_str (length_str); - str += length_str; - str += data_str_; - str += footer_str_; - return str; + String str = header_str_; + String length_str = String_convert::i2hex_str (data_str_.length_i() + footer_str_.length_i (), 8, '0'); + length_str = String_convert::hex2bin_str (length_str); + str += length_str; + str += data_str_; + str += footer_str_; + return str; } Midi_duration::Midi_duration (Real seconds_f) - : Midi_item (0) + : Midi_item (0) { - seconds_f_ = seconds_f; + seconds_f_ = seconds_f; } String Midi_duration::str() const { - return String (""; + return String (""; } Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i) - : Midi_chunk() + : Midi_chunk() { - String str; + String str; - String format_str = String_convert::i2hex_str (format_i, 4, '0'); - str += String_convert::hex2bin_str (format_str); + String format_str = String_convert::i2hex_str (format_i, 4, '0'); + str += String_convert::hex2bin_str (format_str); - String tracks_str = String_convert::i2hex_str (tracks_i, 4, '0'); - str += String_convert::hex2bin_str (tracks_str); + String tracks_str = String_convert::i2hex_str (tracks_i, 4, '0'); + str += String_convert::hex2bin_str (tracks_str); - String tempo_str = String_convert::i2hex_str (clocks_per_4_i, 4, '0'); - str += String_convert::hex2bin_str (tempo_str); + String tempo_str = String_convert::i2hex_str (clocks_per_4_i, 4, '0'); + str += String_convert::hex2bin_str (tempo_str); - set ("MThd", str, ""); + set ("MThd", str, ""); } char const* const instrument_name_sz_a_[ ] = { - /* default is usually piano */ - /* 0 */ "piano", - - /* (1-8 piano) */ - /* 1 */ "acoustic grand", - /* 2 */ "bright acoustic", - /* 3 */ "electric grand", - /* 4 */ "honky-tonk", - /* 5 */ "electric piano 1", - /* 6 */ "electric piano 2", - /* 7 */ "harpsichord", - /* 8 */ "clav", - - /* (9-16 chrom percussion) */ - /* 9 */ "celesta", - /* 10 */ "glockenspiel", - /* 11 */ "music box", - /* 12 */ "vibraphone", - /* 13 */ "marimba", - /* 14 */ "xylophone", - /* 15 */ "tubular bells", - /* 16 */ "dulcimer", - - /* (17-24 organ) */ - /* 17 */ "drawbar organ", - /* 18 */ "percussive organ", - /* 19 */ "rock organ", - /* 20 */ "church organ", - /* 21 */ "reed organ", - /* 22 */ "accoridan", - /* 23 */ "harmonica", - /* 24 */ "tango accordian", - - /* (25-32 guitar) */ - /* 25 */ "acoustic guitar (nylon)", - /* 26 */ "acoustic guitar (steel)", - /* 27 */ "electric guitar (jazz)", - /* 28 */ "electric guitar (clean)", - /* 29 */ "electric guitar (muted)", - /* 30 */ "overdriven guitar", - /* 31 */ "distortion guitar", - /* 32 */ "guitar harmonics", - - /* (33-40 bass) */ - /* 33 */ "acoustic bass", - /* 34 */ "electric bass (finger)", - /* 35 */ "electric bass (pick)", - /* 36 */ "fretless bass", - /* 37 */ "slap bass 1", - /* 38 */ "slap bass 2", - /* 39 */ "synth bass 1", - /* 40 */ "synth bass 2", - - /* (41-48 strings) */ - /* 41 */ "violin", - /* 42 */ "viola", - /* 43 */ "cello", - /* 44 */ "contrabass", - /* 45 */ "tremolo strings", - /* 46 */ "pizzicato strings", - /* 47 */ "orchestral strings", - /* 48 */ "timpani", - - /* (49-56 ensemble) */ - /* 49 */ "string ensemble 1", - /* 50 */ "string ensemble 2", - /* 51 */ "synthstrings 1", - /* 52 */ "synthstrings 2", - /* 53 */ "choir aahs", - /* 54 */ "voice oohs", - /* 55 */ "synth voice", - /* 56 */ "orchestra hit", - - /* (57-64 brass) */ - /* 57 */ "trumpet", - /* 58 */ "trombone", - /* 59 */ "tuba", - /* 60 */ "muted trumpet", - /* 61 */ "french horn", - /* 62 */ "brass section", - /* 63 */ "synthbrass 1", - /* 64 */ "synthbrass 2", - - /* (65-72 reed) */ - /* 65 */ "soprano sax", - /* 66 */ "alto sax", - /* 67 */ "tenor sax", - /* 68 */ "baritone sax", - /* 69 */ "oboe", - /* 70 */ "english horn", - /* 71 */ "bassoon", - /* 72 */ "clarinet", - - /* (73-80 pipe) */ - /* 73 */ "piccolo", - /* 74 */ "flute", - /* 75 */ "recorder", - /* 76 */ "pan flute", - /* 77 */ "blown bottle", - /* 78 */ "skakuhachi", - /* 79 */ "whistle", - /* 80 */ "ocarina", - - /* (81-88 synth lead) */ - /* 81 */ "lead 1 (square)", - /* 82 */ "lead 2 (sawtooth)", - /* 83 */ "lead 3 (calliope)", - /* 84 */ "lead 4 (chiff)", - /* 85 */ "lead 5 (charang)", - /* 86 */ "lead 6 (voice)", - /* 87 */ "lead 7 (fifths)", - /* 88 */ "lead 8 (bass+lead)", - - /* (89-96 synth pad) */ - /* 89 */ "pad 1 (new age)", - /* 90 */ "pad 2 (warm)", - /* 91 */ "pad 3 (polysynth)", - /* 92 */ "pad 4 (choir)", - /* 93 */ "pad 5 (bowed)", - /* 94 */ "pad 6 (metallic)", - /* 95 */ "pad 7 (halo)", - /* 96 */ "pad 8 (sweep)", - - /* (97-104 synth effects) */ - /* 97 */ "fx 1 (rain)", - /* 98 */ "fx 2 (soundtrack)", - /* 99 */ "fx 3 (crystal)", - /* 100 */ "fx 4 (atmosphere)", - /* 101 */ "fx 5 (brightness)", - /* 102 */ "fx 6 (goblins)", - /* 103 */ "fx 7 (echoes)", - /* 104 */ "fx 8 (sci-fi)", - - /* (105-112 ethnic) */ - /* 105 */ "sitar", - /* 106 */ "banjo", - /* 107 */ "shamisen", - /* 108 */ "koto", - /* 109 */ "kalimba", - /* 110 */ "bagpipe", - /* 111 */ "fiddle", - /* 112 */ "shanai", - - /* (113-120 percussive) */ - /* 113 */ "tinkle bell", - /* 114 */ "agogo", - /* 115 */ "steel drums", - /* 116 */ "woodblock", - /* 117 */ "taiko drum", - /* 118 */ "melodic tom", - /* 119 */ "synth drum", - /* 120 */ "reverse cymbal", - - /* (121-128 sound effects) */ - /* 121 */ "guitar fret noise", - /* 122 */ "breath noise", - /* 123 */ "seashore", - /* 124 */ "bird tweet", - /* 125 */ "telephone ring", - /* 126 */ "helicopter", - /* 127 */ "applause", - /* 128 */ "gunshot", - 0 + /* default is usually piano */ + /* 0 */ "piano", + + /* (1-8 piano) */ + /* 1 */ "acoustic grand", + /* 2 */ "bright acoustic", + /* 3 */ "electric grand", + /* 4 */ "honky-tonk", + /* 5 */ "electric piano 1", + /* 6 */ "electric piano 2", + /* 7 */ "harpsichord", + /* 8 */ "clav", + + /* (9-16 chrom percussion) */ + /* 9 */ "celesta", + /* 10 */ "glockenspiel", + /* 11 */ "music box", + /* 12 */ "vibraphone", + /* 13 */ "marimba", + /* 14 */ "xylophone", + /* 15 */ "tubular bells", + /* 16 */ "dulcimer", + + /* (17-24 organ) */ + /* 17 */ "drawbar organ", + /* 18 */ "percussive organ", + /* 19 */ "rock organ", + /* 20 */ "church organ", + /* 21 */ "reed organ", + /* 22 */ "accoridan", + /* 23 */ "harmonica", + /* 24 */ "tango accordian", + + /* (25-32 guitar) */ + /* 25 */ "acoustic guitar (nylon)", + /* 26 */ "acoustic guitar (steel)", + /* 27 */ "electric guitar (jazz)", + /* 28 */ "electric guitar (clean)", + /* 29 */ "electric guitar (muted)", + /* 30 */ "overdriven guitar", + /* 31 */ "distortion guitar", + /* 32 */ "guitar harmonics", + + /* (33-40 bass) */ + /* 33 */ "acoustic bass", + /* 34 */ "electric bass (finger)", + /* 35 */ "electric bass (pick)", + /* 36 */ "fretless bass", + /* 37 */ "slap bass 1", + /* 38 */ "slap bass 2", + /* 39 */ "synth bass 1", + /* 40 */ "synth bass 2", + + /* (41-48 strings) */ + /* 41 */ "violin", + /* 42 */ "viola", + /* 43 */ "cello", + /* 44 */ "contrabass", + /* 45 */ "tremolo strings", + /* 46 */ "pizzicato strings", + /* 47 */ "orchestral strings", + /* 48 */ "timpani", + + /* (49-56 ensemble) */ + /* 49 */ "string ensemble 1", + /* 50 */ "string ensemble 2", + /* 51 */ "synthstrings 1", + /* 52 */ "synthstrings 2", + /* 53 */ "choir aahs", + /* 54 */ "voice oohs", + /* 55 */ "synth voice", + /* 56 */ "orchestra hit", + + /* (57-64 brass) */ + /* 57 */ "trumpet", + /* 58 */ "trombone", + /* 59 */ "tuba", + /* 60 */ "muted trumpet", + /* 61 */ "french horn", + /* 62 */ "brass section", + /* 63 */ "synthbrass 1", + /* 64 */ "synthbrass 2", + + /* (65-72 reed) */ + /* 65 */ "soprano sax", + /* 66 */ "alto sax", + /* 67 */ "tenor sax", + /* 68 */ "baritone sax", + /* 69 */ "oboe", + /* 70 */ "english horn", + /* 71 */ "bassoon", + /* 72 */ "clarinet", + + /* (73-80 pipe) */ + /* 73 */ "piccolo", + /* 74 */ "flute", + /* 75 */ "recorder", + /* 76 */ "pan flute", + /* 77 */ "blown bottle", + /* 78 */ "skakuhachi", + /* 79 */ "whistle", + /* 80 */ "ocarina", + + /* (81-88 synth lead) */ + /* 81 */ "lead 1 (square)", + /* 82 */ "lead 2 (sawtooth)", + /* 83 */ "lead 3 (calliope)", + /* 84 */ "lead 4 (chiff)", + /* 85 */ "lead 5 (charang)", + /* 86 */ "lead 6 (voice)", + /* 87 */ "lead 7 (fifths)", + /* 88 */ "lead 8 (bass+lead)", + + /* (89-96 synth pad) */ + /* 89 */ "pad 1 (new age)", + /* 90 */ "pad 2 (warm)", + /* 91 */ "pad 3 (polysynth)", + /* 92 */ "pad 4 (choir)", + /* 93 */ "pad 5 (bowed)", + /* 94 */ "pad 6 (metallic)", + /* 95 */ "pad 7 (halo)", + /* 96 */ "pad 8 (sweep)", + + /* (97-104 synth effects) */ + /* 97 */ "fx 1 (rain)", + /* 98 */ "fx 2 (soundtrack)", + /* 99 */ "fx 3 (crystal)", + /* 100 */ "fx 4 (atmosphere)", + /* 101 */ "fx 5 (brightness)", + /* 102 */ "fx 6 (goblins)", + /* 103 */ "fx 7 (echoes)", + /* 104 */ "fx 8 (sci-fi)", + + /* (105-112 ethnic) */ + /* 105 */ "sitar", + /* 106 */ "banjo", + /* 107 */ "shamisen", + /* 108 */ "koto", + /* 109 */ "kalimba", + /* 110 */ "bagpipe", + /* 111 */ "fiddle", + /* 112 */ "shanai", + + /* (113-120 percussive) */ + /* 113 */ "tinkle bell", + /* 114 */ "agogo", + /* 115 */ "steel drums", + /* 116 */ "woodblock", + /* 117 */ "taiko drum", + /* 118 */ "melodic tom", + /* 119 */ "synth drum", + /* 120 */ "reverse cymbal", + + /* (121-128 sound effects) */ + /* 121 */ "guitar fret noise", + /* 122 */ "breath noise", + /* 123 */ "seashore", + /* 124 */ "bird tweet", + /* 125 */ "telephone ring", + /* 126 */ "helicopter", + /* 127 */ "applause", + /* 128 */ "gunshot", + 0 }; Midi_instrument::Midi_instrument (int channel_i, String instrument_str) - : Midi_item (0) + : Midi_item (0) { - instrument_str_ = instrument_str; - instrument_str_.to_lower(); - channel_i_ = channel_i; + instrument_str_ = instrument_str; + instrument_str_.to_lower(); + channel_i_ = channel_i; } - + String Midi_instrument::str() const { - Byte program_byte = 0; - for ( int i = 0; instrument_name_sz_a_[i]; i++) - if ( instrument_str_ == String (instrument_name_sz_a_[ i ])) { - program_byte = (Byte)i; - break; - } + Byte program_byte = 0; + for ( int i = 0; instrument_name_sz_a_[i]; i++) + if ( instrument_str_ == String (instrument_name_sz_a_[ i ])) + { + program_byte = (Byte)i; + break; + } - if ( !program_byte) - return String (""); - - String str = String ((char)( 0xc0 + channel_i_) ); - str += String ((char)program_byte); - return str; + String str = String ((char)( 0xc0 + channel_i_) ); + str += String ((char)program_byte); + return str; } Midi_item::Midi_item (Audio_item* audio_item_l) { - audio_item_l_ = audio_item_l; - channel_i_ = 0; + audio_item_l_ = audio_item_l; + channel_i_ = 0; } void Midi_item::output (Midi_stream* midi_stream_l) const { - *midi_stream_l << str(); + *midi_stream_l << str(); } String Midi_item::i2varint_str (int i) { - int buffer_i = i & 0x7f; - while ( (i >>= 7) > 0) { - buffer_i <<= 8; - buffer_i |= 0x80; - buffer_i += (i & 0x7f); + int buffer_i = i & 0x7f; + while ( (i >>= 7) > 0) + { + buffer_i <<= 8; + buffer_i |= 0x80; + buffer_i += (i & 0x7f); } - String str; - while ( 1) { - str += (char)buffer_i; - if ( buffer_i & 0x80) - buffer_i >>= 8; - else - break; + String str; + while ( 1) + { + str += (char)buffer_i; + if ( buffer_i & 0x80) + buffer_i >>= 8; + else + break; } - return str; + return str; } Midi_key::Midi_key (Audio_item* audio_item_l) - : Midi_item (audio_item_l) + : Midi_item (audio_item_l) { } String Midi_key::str() const { - Key_change_req* k = audio_item_l_->req_l_->command()->keychange (); - int sharps_i = k->sharps_i(); - int flats_i = k->flats_i(); + Key_change_req* k = audio_item_l_->req_l_->command()->keychange (); + int sharps_i = k->sharps_i(); + int flats_i = k->flats_i(); - // midi cannot handle non-conventional keys - if ( flats_i && sharps_i) - return ""; - int accidentals_i = sharps_i - flats_i; + // midi cannot handle non-conventional keys + if ( flats_i && sharps_i) + return ""; + int accidentals_i = sharps_i - flats_i; - String str = "ff5902"; - str += String_convert::i2hex_str (accidentals_i, 2, '0'); - int minor_i = k->minor_b(); - str += String_convert::i2hex_str (minor_i, 2, '0'); - return String_convert::hex2bin_str (str); + String str = "ff5902"; + str += String_convert::i2hex_str (accidentals_i, 2, '0'); + int minor_i = k->minor_b(); + str += String_convert::i2hex_str (minor_i, 2, '0'); + return String_convert::hex2bin_str (str); } Midi_meter::Midi_meter (Audio_item* audio_item_l) - : Midi_item (audio_item_l) + : Midi_item (audio_item_l) { - clocks_per_1_i_ = 18; + clocks_per_1_i_ = 18; } String Midi_meter::str() const { - Meter_change_req* m = audio_item_l_->req_l_->command()->meterchange (); - int num_i = m->beats_i_; - int den_i = m->one_beat_i_; + Meter_change_req* m = audio_item_l_->req_l_->command()->meterchange (); + int num_i = m->beats_i_; + int den_i = m->one_beat_i_; - String str = "ff5804"; - str += String_convert::i2hex_str (num_i, 2, '0'); - str += String_convert::i2hex_str (intlog2( den_i) , 2, '0' ); - str += String_convert::i2hex_str (clocks_per_1_i_, 2, '0'); - str += String_convert::i2hex_str (8, 2, '0'); - return String_convert::hex2bin_str (str); + String str = "ff5804"; + str += String_convert::i2hex_str (num_i, 2, '0'); + str += String_convert::i2hex_str (intlog2( den_i) , 2, '0' ); + str += String_convert::i2hex_str (clocks_per_1_i_, 2, '0'); + str += String_convert::i2hex_str (8, 2, '0'); + return String_convert::hex2bin_str (str); } Midi_note::Midi_note (Audio_item* audio_item_l) - : Midi_item (audio_item_l) + : Midi_item (audio_item_l) { - dynamic_byte_ = 0x7f; + dynamic_byte_ = 0x7f; } Moment Midi_note::duration() const { - return audio_item_l_->req_l_->musical()->rhythmic ()->duration (); + return audio_item_l_->req_l_->musical()->rhythmic ()->duration (); } int Midi_note::pitch_i() const { - return audio_item_l_->req_l_->musical()->melodic ()->pitch (); + return audio_item_l_->req_l_->musical()->melodic ()->pitch (); } String Midi_note::str() const { - if ( pitch_i() == INT_MAX) - return String (""); + if ( pitch_i() == INT_MAX) + return String (""); - Byte status_byte = (char)( 0x90 + channel_i_); + Byte status_byte = (char)( 0x90 + channel_i_); - String str = String ((char)status_byte); - str += (char)( pitch_i() + c0_pitch_i_c_); + String str = String ((char)status_byte); + str += (char)( pitch_i() + c0_pitch_i_c_); - // poor man's staff dynamics: - str += (char)( dynamic_byte_ - 0x10 * channel_i_); + // poor man's staff dynamics: + str += (char)( dynamic_byte_ - 0x10 * channel_i_); - return str; + return str; } Midi_note_off::Midi_note_off (Midi_note* midi_note_l) - : Midi_item (midi_note_l->audio_item_l_) + : Midi_item (midi_note_l->audio_item_l_) { - // 0x64 is supposed to be neutral, but let's try - aftertouch_byte_ = 0x64; - channel_i_ = midi_note_l->channel_i_; + // 0x64 is supposed to be neutral, but let's try + aftertouch_byte_ = 0x64; + channel_i_ = midi_note_l->channel_i_; } int Midi_note_off::pitch_i() const { - return audio_item_l_->req_l_->musical()->melodic ()->pitch (); + return audio_item_l_->req_l_->musical()->melodic ()->pitch (); } String Midi_note_off::str() const { - if ( pitch_i() == INT_MAX) - return String (""); + if ( pitch_i() == INT_MAX) + return String (""); - Byte status_byte = (char)( 0x80 + channel_i_); + Byte status_byte = (char)( 0x80 + channel_i_); - String str = String ((char)status_byte); - str += (char)( pitch_i() + Midi_note::c0_pitch_i_c_); - str += (char)aftertouch_byte_; - return str; + String str = String ((char)status_byte); + str += (char)( pitch_i() + Midi_note::c0_pitch_i_c_); + str += (char)aftertouch_byte_; + return str; } Midi_tempo::Midi_tempo (Audio_item* audio_item_l) - : Midi_item (audio_item_l) + : Midi_item (audio_item_l) { - per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_)->per_minute_4_i_; + per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_)->per_minute_4_i_; } Midi_tempo::Midi_tempo (int per_minute_4_i) - : Midi_item (0) + : Midi_item (0) { - per_minute_4_i_ = per_minute_4_i; + per_minute_4_i_ = per_minute_4_i; } String Midi_tempo::str() const { - int useconds_per_4_i = 60 * (int)1e6 / per_minute_4_i_; - String str = "ff5103"; - str += String_convert::i2hex_str (useconds_per_4_i, 6, '0'); - return String_convert::hex2bin_str (str); + int useconds_per_4_i = 60 * (int)1e6 / per_minute_4_i_; + String str = "ff5103"; + str += String_convert::i2hex_str (useconds_per_4_i, 6, '0'); + return String_convert::hex2bin_str (str); } Midi_text::Midi_text (Audio_item* audio_item_l) - : Midi_item (audio_item_l) + : Midi_item (audio_item_l) { - text_str_ = ( (Audio_text*)audio_item_l_)->text_str_; - type_ = (Type)( (Audio_text*)audio_item_l_)->type_; + text_str_ = ( (Audio_text*)audio_item_l_)->text_str_; + type_ = (Type)( (Audio_text*)audio_item_l_)->type_; } Midi_text::Midi_text (Midi_text::Type type, String text_str) - : Midi_item (0) + : Midi_item (0) { - text_str_ = text_str; - type_ = type; + text_str_ = text_str; + type_ = type; } String Midi_text::str() const { - String str = "ff" + String_convert::i2hex_str (type_, 2, '0'); - str = String_convert::hex2bin_str (str); - str += i2varint_str (text_str_.length_i()); - str += text_str_; - return str; + String str = "ff" + String_convert::i2hex_str (type_, 2, '0'); + str = String_convert::hex2bin_str (str); + str += i2varint_str (text_str_.length_i()); + str += text_str_; + return str; } Midi_track::Midi_track() - : Midi_chunk() + : Midi_chunk() { -// 4D 54 72 6B MTrk -// 00 00 00 3B chunk length (59) -// 00 FF 58 04 04 02 18 08 time signature -// 00 FF 51 03 07 A1 20 tempo + // 4D 54 72 6B MTrk + // 00 00 00 3B chunk length (59) + // 00 FF 58 04 04 02 18 08 time signature + // 00 FF 51 03 07 A1 20 tempo // FF 59 02 sf mi Key Signature // sf = -7: 7 flats @@ -487,47 +487,48 @@ Midi_track::Midi_track() // mi = 0: major key // mi = 1: minor key - number_i_ = 0; + number_i_ = 0; - char const* data_ch_C = "" -// "00" "ff58" "0404" "0218" "08" -// "00" "ff51" "0307" "a120" -// why a key at all, in midi? -// key: C -// "00" "ff59" "02" "00" "00" -// key: F (scsii-menuetto) -// "00" "ff59" "02" "ff" "00" + char const* data_ch_C = "" + // "00" "ff58" "0404" "0218" "08" + // "00" "ff51" "0307" "a120" + // why a key at all, in midi? + // key: C + // "00" "ff59" "02" "00" "00" + // key: F (scsii-menuetto) + // "00" "ff59" "02" "ff" "00" ; - String data_str; - // only for format 0 (currently using format 1)? - data_str += String_convert::hex2bin_str (data_ch_C); + String data_str; + // only for format 0 (currently using format 1)? + data_str += String_convert::hex2bin_str (data_ch_C); - char const* footer_ch_C = "00" "ff2f" "00"; - String footer_str = String_convert::hex2bin_str (footer_ch_C); + char const* footer_ch_C = "00" "ff2f" "00"; + String footer_str = String_convert::hex2bin_str (footer_ch_C); - set ("MTrk", data_str, footer_str); + set ("MTrk", data_str, footer_str); } void Midi_track::add (int delta_time_i, String event_str) { - if ( delta_time_i < 0) { - cout << String_convert::bin2hex_str (i2varint_str (delta_time_i) ) << endl; - cout << String_convert::bin2hex_str (event_str) << endl; + if ( delta_time_i < 0) + { + cout << String_convert::bin2hex_str (i2varint_str (delta_time_i) ) << endl; + cout << String_convert::bin2hex_str (event_str) << endl; } - assert (delta_time_i >= 0); - assert(event_str.length_i()); - Midi_chunk::add (i2varint_str (delta_time_i) + event_str ); + assert (delta_time_i >= 0); + assert(event_str.length_i()); + Midi_chunk::add (i2varint_str (delta_time_i) + event_str ); } void Midi_track::add (Moment delta_time_moment, Midi_item* mitem_l) { - // use convention of 384 clocks per 4 - // use Duration_convert - int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4 ); - // ? int ( delta_time_moment * 4 * 384) - add (delta_time_i, mitem_l->str()); + // use convention of 384 clocks per 4 + // use Duration_convert + int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4 ); + // ? int ( delta_time_moment * 4 * 384) + add (delta_time_i, mitem_l->str()); } diff --git a/lily/midi-stream.cc b/lily/midi-stream.cc index fadd2f06f5..5f1b3ee501 100644 --- a/lily/midi-stream.cc +++ b/lily/midi-stream.cc @@ -17,52 +17,52 @@ Midi_stream::Midi_stream (String filename_str) { - filename_str_ = filename_str; - os_p_ = 0; - open(); + filename_str_ = filename_str; + os_p_ = 0; + open(); } Midi_stream::~Midi_stream() { - delete os_p_; + delete os_p_; } Midi_stream& Midi_stream::operator <<( String str) { - if ( check_debug) + if ( check_debug) str = String_convert::bin2hex_str (str); - - *os_p_ << str; + + *os_p_ << str; - if ( check_debug) - *os_p_ << "\n"; + if ( check_debug) + *os_p_ << "\n"; - return *this; + return *this; } Midi_stream& Midi_stream::operator <<( Midi_item const& mitem_c_r) { // *this << mitem_c_r.str(); - mitem_c_r.output (this); - if ( check_debug) - *os_p_ << "\n"; - return *this; + mitem_c_r.output (this); + if ( check_debug) + *os_p_ << "\n"; + return *this; } Midi_stream& Midi_stream::operator <<( int i) { - // output binary string ourselves - *this << Midi_item::i2varint_str (i); - return *this; + // output binary string ourselves + *this << Midi_item::i2varint_str (i); + return *this; } void Midi_stream::open() { - os_p_ = new ofstream (filename_str_); - if ( !*os_p_) + os_p_ = new ofstream (filename_str_); + if ( !*os_p_) error ("can't open `" + filename_str_ + "\'"); } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 9c2d9ff75d..aea8fcc0d7 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + Jan Nieuwenhuizen */ #include "midi-walker.hh" @@ -17,26 +17,26 @@ Midi_note_event::Midi_note_event() { - ignore_b_ = false; + ignore_b_ = false; } int compare (Midi_note_event const& left, Midi_note_event const& right) { - return sign (left.key - right.key); + return sign (left.key - right.key); } Midi_walker::Midi_walker (Audio_staff* audio_staff_l, Midi_track* track_l) - : PCursor( audio_staff_l->audio_item_l_list_) + : PCursor( audio_staff_l->audio_item_l_list_) { - track_l_ = track_l; - last_mom_ = 0; + track_l_ = track_l; + last_mom_ = 0; } Midi_walker::~Midi_walker() { - // ugh - do_stop_notes (last_mom_ + Moment (10, 1) ); + // ugh + do_stop_notes (last_mom_ + Moment (10, 1) ); } /** @@ -45,22 +45,24 @@ Midi_walker::~Midi_walker() void Midi_walker::do_start_note (Midi_note* note_l) { - Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom (); - for ( int i=0; i < stop_note_queue.size(); i++) { - if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) { + Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom (); + for ( int i=0; i < stop_note_queue.size(); i++) + { + if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ()) + { if ( stop_note_queue[ i ].key < stop_mom) stop_note_queue[ i ].ignore_b_ = true; else // skip the stopnote return; - } + } } - Midi_note_event e; - e.val = new Midi_note_off (note_l); - e.key = stop_mom; - stop_note_queue.insert (e); - - output_event (ptr()->audio_column_l_->at_mom (), note_l); + Midi_note_event e; + e.val = new Midi_note_off (note_l); + e.key = stop_mom; + stop_note_queue.insert (e); + + output_event (ptr()->audio_column_l_->at_mom (), note_l); } /** @@ -69,7 +71,8 @@ Midi_walker::do_start_note (Midi_note* note_l) void Midi_walker::do_stop_notes (Moment max_mom) { - while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) { + while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom) + { Midi_note_event e = stop_note_queue.get(); if ( e.ignore_b_) continue; @@ -87,26 +90,26 @@ Midi_walker::do_stop_notes (Moment max_mom) void Midi_walker::output_event (Moment now_mom, Midi_item* l) { - Moment delta_t = now_mom - last_mom_ ; - last_mom_ += delta_t; - track_l_->add (delta_t, l); + Moment delta_t = now_mom - last_mom_ ; + last_mom_ += delta_t; + track_l_->add (delta_t, l); } void Midi_walker::process() { - do_stop_notes (ptr()->audio_column_l_->at_mom ()); + do_stop_notes (ptr()->audio_column_l_->at_mom ()); - Midi_item* p = ptr()->midi_item_p (); - if ( !p ) + Midi_item* p = ptr()->midi_item_p (); + if ( !p ) return; - p->channel_i_ = track_l_->number_i_; - - if ( p->name() != Midi_note::static_name ()) + p->channel_i_ = track_l_->number_i_; + + if ( p->name() != Midi_note::static_name ()) output_event (ptr()->audio_column_l_->at_mom (), p); - else + else do_start_note ((Midi_note*)p); - delete p; + delete p; } diff --git a/lily/misc.cc b/lily/misc.cc index 946e27e4bb..d150d55792 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -14,32 +14,34 @@ int intlog2(int d) { - int i=0; - while (!(d&1)) { + int i=0; + while (!(d&1)) + { d/= 2; i++; } - assert (!(d/2)); - return i; + assert (!(d/2)); + return i; } double log_2(double x) { - return log (x) /log (2.0); + return log (x) /log (2.0); } #if 1 Interval itemlist_width (const Array &its) { - Interval iv ; - iv.set_empty(); - - for (int j =0; j < its.size(); j++){ + Interval iv ; + iv.set_empty(); + + for (int j =0; j < its.size(); j++) + { iv.unite (its[j]->width()); } - return iv; + return iv; } #endif diff --git a/lily/molecule.cc b/lily/molecule.cc index 663a554e93..ad176da26f 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -17,39 +17,40 @@ String Molecule::TeX_string() const { - String s; - for (iter_top (ats,c); c.ok(); c++) + String s; + for (iter_top (ats,c); c.ok(); c++) s+=c->TeX_string(); - return s; + return s; } Box Molecule::extent() const { - Box b; - for (iter_top (ats,c); c.ok(); c++) + Box b; + for (iter_top (ats,c); c.ok(); c++) b.unite (c->extent()); - return b; + return b; } void Molecule::translate (Offset o) { - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->translate (o); } void Molecule::translate (Real x,Axis a) { - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->translate (x,a); } void Molecule::add (Molecule const &m) { - for (iter_top (m.ats,c); c.ok(); c++) { + for (iter_top (m.ats,c); c.ok(); c++) + { add (**c); } } @@ -57,78 +58,82 @@ Molecule::add (Molecule const &m) void Molecule::add_right (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } - Real xof=extent().x ().right - m.extent ().x ().left; + Real xof=extent().x ().right - m.extent ().x ().left; - - Molecule toadd (m); - toadd.translate (Offset (xof, 0.0)); - add (toadd); + + Molecule toadd (m); + toadd.translate (Offset (xof, 0.0)); + add (toadd); } void Molecule::add_left (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } Real xof=extent().x ().left - m.extent ().x ().right; - Molecule toadd (m); - toadd.translate (Offset (xof, 0.0)); - add (toadd); + Molecule toadd (m); + toadd.translate (Offset (xof, 0.0)); + add (toadd); } void Molecule::add_top (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } Real yof=extent().y ().right - m.extent ().y ().left; - Molecule toadd (m); - toadd.translate (yof, Y_AXIS); - add (toadd); + Molecule toadd (m); + toadd.translate (yof, Y_AXIS); + add (toadd); } void Molecule::add_bottom (Molecule const &m) { - if (!ats.size()) { + if (!ats.size()) + { add (m); return; } - Real yof=extent().y ().left- m.extent ().y ().right; - Molecule toadd (m); - toadd.translate (yof, Y_AXIS); - add (toadd); + Real yof=extent().y ().left- m.extent ().y ().right; + Molecule toadd (m); + toadd.translate (yof, Y_AXIS); + add (toadd); } void Molecule::operator = (Molecule const &) { - assert (false); + assert (false); } Molecule::Molecule (Molecule const &s) { - add (s); + add (s); } void Molecule::print() const { #ifndef NPRINT - if (! check_debug) + if (! check_debug) return; - for (iter_top (ats,c); c.ok(); c++) + for (iter_top (ats,c); c.ok(); c++) c->print(); #endif } @@ -136,5 +141,5 @@ Molecule::print() const void Molecule::add (Atom const &a) { - ats.bottom().add (new Atom (a)); + ats.bottom().add (new Atom (a)); } diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 2314320165..56a6476ff6 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -29,60 +29,60 @@ void Music_iterator::print() const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << name() << "{"; - DOUT << "report to " << + DOUT << name() << "{"; + DOUT << "report to " << report_to_l() << " (" << report_to_l ()->name () << ")\n"; - DOUT << "next at " << next_moment() << " "; - do_print(); - DOUT << "}\n"; + DOUT << "next at " << next_moment() << " "; + do_print(); + DOUT << "}\n"; #endif } Translator * Music_iterator::get_req_translator_l() { - assert (report_to_l()); - if (report_to_l()->is_bottom_engraver_b ()) + assert (report_to_l()); + if (report_to_l()->is_bottom_engraver_b ()) return report_to_l(); - set_translator (report_to_l()->get_default_interpreter ()); - return report_to_l(); + set_translator (report_to_l()->get_default_interpreter ()); + return report_to_l(); } void Music_iterator::push_translator (Translator*t) { - report_to_l_arr_.push (t); - t->iterator_count_ ++; + report_to_l_arr_.push (t); + t->iterator_count_ ++; } void Music_iterator::pop_translator() { - report_to_l()->iterator_count_ --; - assert (report_to_l()->iterator_count_ >=0); - report_to_l_arr_.pop(); + report_to_l()->iterator_count_ --; + assert (report_to_l()->iterator_count_ >=0); + report_to_l_arr_.pop(); } Translator* Music_iterator::report_to_l()const { - if (! report_to_l_arr_.size()) + if (! report_to_l_arr_.size()) return 0; - return report_to_l_arr_.top(); + return report_to_l_arr_.top(); } void Music_iterator::set_translator (Translator*trans) { - if (report_to_l()==trans) + if (report_to_l()==trans) return; - if ( report_to_l()) + if ( report_to_l()) pop_translator(); - if (trans) + if (trans) push_translator (trans); } @@ -94,86 +94,90 @@ Music_iterator::construct_children() Music_iterator::~Music_iterator() { - set_translator (0); + set_translator (0); } Moment Music_iterator::next_moment()const { - return 0; + return 0; } void Music_iterator::process_and_next (Moment) { - first_b_ = false; + first_b_ = false; } bool Music_iterator::ok()const { - return first_b_; + return first_b_; } Music_iterator* Music_iterator::static_get_iterator_p (Music *m, Translator *report_l) { - Music_iterator * p =0; - if (m->is_type_b (Request_chord::static_name())) + Music_iterator * p =0; + if (m->is_type_b (Request_chord::static_name())) p = new Request_chord_iterator ((Request_chord*) m); - else if (m->is_type_b (Chord::static_name())) + else if (m->is_type_b (Chord::static_name())) p = new Chord_iterator ((Chord*) m); - else if (m->is_type_b (Voice::static_name())) + else if (m->is_type_b (Voice::static_name())) p = new Voice_iterator ((Voice*) m); - - if (m -> type_str_ != "") { + + if (m -> type_str_ != "") + { Translator * a =report_l-> find_get_translator_l (m-> type_str_, m->id_str_); p->set_translator (a); - } + } - if (! p->report_to_l()) + if (! p->report_to_l()) p ->set_translator (report_l); - - return p; + + return p; } Music_iterator* Music_iterator::get_iterator_p (Music*m)const { - Music_iterator*p = static_get_iterator_p (m,report_to_l()); - p->daddy_iter_l_ = (Music_iterator*)this; - p->construct_children(); - return p; + Music_iterator*p = static_get_iterator_p (m,report_to_l()); + p->daddy_iter_l_ = (Music_iterator*)this; + p->construct_children(); + return p; } Music_iterator::Music_iterator() { - daddy_iter_l_ =0; - first_b_ = true; + daddy_iter_l_ =0; + first_b_ = true; } /* ************** */ Chord_iterator::Chord_iterator (Chord const *chord_C) { - chord_C_ = chord_C; + chord_C_ = chord_C; } void Chord_iterator::construct_children() { - int j = 0; - for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; - i.ok(); j++, i++) { + int j = 0; + for (PCursor i (chord_C_->music_p_list_.top()); //, int j = 0; + i.ok(); j++, i++) + { Music_iterator * mi = get_iterator_p (i.ptr()); - if ( mi->ok()) { + if ( mi->ok()) + { set_translator (mi->report_to_l()->ancestor_l ( chord_C_->multi_level_i_) ); children_p_list_.bottom().add (mi); - } else + } + else delete mi; } } @@ -181,7 +185,8 @@ void Chord_iterator::do_print() const { #ifndef NPRINT - for (PCursor i (children_p_list_.top()); i.ok (); i++) { + for (PCursor i (children_p_list_.top()); i.ok (); i++) + { i->print(); } #endif @@ -190,16 +195,18 @@ Chord_iterator::do_print() const void Chord_iterator::process_and_next (Moment until) { - for (PCursor i (children_p_list_.top()); i.ok ();) { - if (i->next_moment() == until) { + for (PCursor i (children_p_list_.top()); i.ok ();) + { + if (i->next_moment() == until) + { i->process_and_next (until); - } + } if (!i->ok()) delete i.remove_p(); else i++; } - Music_iterator::process_and_next (until); + Music_iterator::process_and_next (until); } @@ -208,10 +215,10 @@ IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator); Moment Chord_iterator::next_moment()const { - Moment next_ = infinity_mom; - for (PCursor i (children_p_list_.top()); i.ok (); i++) + Moment next_ = infinity_mom; + for (PCursor i (children_p_list_.top()); i.ok (); i++) next_ = next_ next_moment() ; - return next_; + return next_; } @@ -219,7 +226,7 @@ Chord_iterator::next_moment()const bool Chord_iterator::ok()const { - return children_p_list_.size(); + return children_p_list_.size(); } /* ************** */ @@ -227,60 +234,64 @@ Chord_iterator::ok()const void Voice_iterator::do_print()const { - if (iter_p_) + if (iter_p_) iter_p_->print(); } Voice_iterator::Voice_iterator (Voice const*v) - : PCursor ( v->music_p_list_) + : PCursor ( v->music_p_list_) { - here_mom_ = v->offset_mom_; - voice_C_ = v; - iter_p_ =0; + here_mom_ = v->offset_mom_; + voice_C_ = v; + iter_p_ =0; } void Voice_iterator::construct_children() { - while (PCursor::ok()) { + while (PCursor::ok()) + { start_next_element(); - if ( !iter_p_->ok()) { + if ( !iter_p_->ok()) + { leave_element(); - } else { + } + else + { set_voice_translator(); break; - } + } } } void Voice_iterator::leave_element() { - delete iter_p_; - iter_p_ =0; - MInterval elt_time = ptr()->time_int (); - if (!elt_time.empty_b()) + delete iter_p_; + iter_p_ =0; + MInterval elt_time = ptr()->time_int (); + if (!elt_time.empty_b()) here_mom_ += elt_time.length(); - PCursor::next(); + PCursor::next(); } void Voice_iterator::start_next_element() { - assert (!iter_p_); - iter_p_ = get_iterator_p (ptr()); + assert (!iter_p_); + iter_p_ = get_iterator_p (ptr()); } void Voice_iterator::set_voice_translator() { - if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) + if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ()) set_translator (iter_p_->report_to_l()); } Voice_iterator::~Voice_iterator() { - assert (! iter_p_); + assert (! iter_p_); } @@ -289,42 +300,48 @@ IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator); void Voice_iterator::process_and_next (Moment until) { - while (1) { + while (1) + { Moment local_until = until - here_mom_; - while ( iter_p_->ok()) { + while ( iter_p_->ok()) + { Moment here = iter_p_->next_moment(); if (here != local_until) goto loopexit; iter_p_->process_and_next (local_until); - } + } - if (!iter_p_->ok()) { + if (!iter_p_->ok()) + { leave_element(); - if ( PCursor::ok()) { + if ( PCursor::ok()) + { start_next_element(); set_voice_translator(); - } else { + } + else + { goto loopexit; - } - } + } + } } loopexit: - Music_iterator::process_and_next (until); + Music_iterator::process_and_next (until); } Moment Voice_iterator::next_moment()const { - return iter_p_->next_moment() + here_mom_; + return iter_p_->next_moment() + here_mom_; } bool Voice_iterator::ok()const { - return iter_p_; + return iter_p_; } @@ -333,21 +350,21 @@ IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator); void Request_chord_iterator::construct_children() { - get_req_translator_l(); + get_req_translator_l(); } Request_chord_iterator::Request_chord_iterator (Request_chord*el_l) { - elt_l_ = el_l; - elt_duration_ = el_l->time_int().length (); - last_b_ = false; + elt_l_ = el_l; + elt_duration_ = el_l->time_int().length (); + last_b_ = false; } bool Request_chord_iterator::ok()const { - return (elt_duration_ && !last_b_) || first_b_; + return (elt_duration_ && !last_b_) || first_b_; } @@ -355,34 +372,36 @@ Request_chord_iterator::ok()const Moment Request_chord_iterator::next_moment()const { - Moment m (0); - if (!first_b_) + Moment m (0); + if (!first_b_) m = elt_duration_; - return m; + return m; } void Request_chord_iterator::do_print() const { #ifndef NPRINT - DOUT << "duration: " << elt_duration_; + DOUT << "duration: " << elt_duration_; #endif } void Request_chord_iterator::process_and_next (Moment mom) { - if ( first_b_) { - for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) { + if ( first_b_) + { + for (PCursor i (elt_l_->music_p_list_); i.ok(); i++) + { assert (i->is_type_b (Request::static_name())); Request * req_l = (Request*)i.ptr(); bool gotcha = report_to_l()->try_request (req_l); if (!gotcha) req_l->warning ("Junking request: " + String (req_l->name())); - } + } first_b_ = false; } - if ( mom >= elt_duration_) + if ( mom >= elt_duration_) last_b_ = true; } diff --git a/lily/music-list.cc b/lily/music-list.cc index 8fd903f0d3..ad10bce46e 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -13,10 +13,10 @@ #include "music-list.hh" Music_list::Music_list (Music_list const&s) - : Music (s) + : Music (s) { - multi_level_i_ = s.multi_level_i_; - for (iter (s.music_p_list_.top(), i); i.ok (); i++) + multi_level_i_ = s.multi_level_i_; + for (iter (s.music_p_list_.top(), i); i.ok (); i++) add (i->clone()); } @@ -27,17 +27,17 @@ IMPLEMENT_IS_TYPE_B1(Chord,Music_list); MInterval Chord::time_int()const { - MInterval m; - for (iter (music_p_list_.top(), i); i.ok (); i++) + MInterval m; + for (iter (music_p_list_.top(), i); i.ok (); i++) m.unite (i->time_int()); - return m; + return m; } void Chord::translate (Moment m) { - for (iter (music_p_list_.top(), i); i.ok (); i++) + for (iter (music_p_list_.top(), i); i.ok (); i++) i->translate (m); } @@ -48,51 +48,52 @@ Chord::Chord() Voice::Voice() { - offset_mom_ =0; + offset_mom_ =0; } MInterval Voice::time_int() const { - Moment last=0; - for (iter (music_p_list_.top(), i); i.ok (); i++) { + Moment last=0; + for (iter (music_p_list_.top(), i); i.ok (); i++) + { MInterval interval = i->time_int(); - /* + /* c4 <> c4 - */ + */ if ( !interval.empty_b()) last += interval.length(); } - return offset_mom_ + MInterval (0,last); + return offset_mom_ + MInterval (0,last); } void Voice::translate (Moment dt) { - offset_mom_ += dt; + offset_mom_ += dt; } Music_list::Music_list() { - multi_level_i_ = 0; + multi_level_i_ = 0; } void Music_list::add (Music*m_p) { - if (!m_p) + if (!m_p) return; - m_p->parent_music_l_ = this; - music_p_list_.bottom().add (m_p); + m_p->parent_music_l_ = this; + music_p_list_.bottom().add (m_p); } void Music_list::transpose (Melodic_req const*rq) { - for (iter (music_p_list_.top(),i); i.ok (); i++) + for (iter (music_p_list_.top(),i); i.ok (); i++) i->transpose (rq); } @@ -100,7 +101,7 @@ void Music_list::do_print()const { #ifndef NPRINT - for (iter (music_p_list_.top(),i); i.ok (); i++) + for (iter (music_p_list_.top(),i); i.ok (); i++) i->print(); #endif } @@ -110,5 +111,5 @@ IMPLEMENT_IS_TYPE_B1(Request_chord, Chord); Request_chord::Request_chord() { - multi_level_i_ =0; + multi_level_i_ =0; } diff --git a/lily/music.cc b/lily/music.cc index b9dcde679d..6cd34fc2a0 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -14,27 +14,27 @@ MInterval Music::time_int() const { - return MInterval (0,0); + return MInterval (0,0); } void Music::print()const { #ifndef NPRINT - if ( ! check_debug) + if ( ! check_debug) return ; - DOUT << name() << "{"; - if (type_str_!="" || id_str_!="") + DOUT << name() << "{"; + if (type_str_!="" || id_str_!="") DOUT << "`" <= 7) { + int old_pitch = pitch(); + int delta_pitch = delta.pitch(); + octave_i_ += delta.octave_i_; + notename_i_ += delta.notename_i_; + while (notename_i_ >= 7) + { notename_i_ -= 7; octave_i_ ++; } - int new_pitch = pitch(); - int delta_acc = new_pitch - old_pitch - delta_pitch; - - accidental_i_ -= delta_acc; - if (abs (accidental_i_) > 2) { + int new_pitch = pitch(); + int delta_acc = new_pitch - old_pitch - delta_pitch; + + accidental_i_ -= delta_acc; + if (abs (accidental_i_) > 2) + { delta.warning ("transposition makes accidental larger than 2"); } } @@ -114,31 +116,31 @@ IMPLEMENT_IS_TYPE_B1(Melodic_req,Musical_req); bool Melodic_req::do_equal_b (Request*r)const { - Melodic_req* m= r->musical()->melodic (); - return !compare (*m, *this); + Melodic_req* m= r->musical()->melodic (); + return !compare (*m, *this); } int Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2) { - int o= m1.octave_i_ - m2.octave_i_; - int n = m1.notename_i_ - m2.notename_i_; - int a = m1.accidental_i_ - m2.accidental_i_; - - if (o) + int o= m1.octave_i_ - m2.octave_i_; + int n = m1.notename_i_ - m2.notename_i_; + int a = m1.accidental_i_ - m2.accidental_i_; + + if (o) return o; - if ( n) + if ( n) return n; - if (a) + if (a) return a; - return 0; + return 0; } void Melodic_req::do_print() const { #ifndef NPRINT - DOUT << "notename: " << notename_i_ + DOUT << "notename: " << notename_i_ << " acc: " <musical()->rhythmic (); + Rhythmic_req* rh = r->musical()->rhythmic (); - return !compare (*this, *rh); + return !compare (*this, *rh); } void Rhythmic_req::set_duration (Duration d) { - duration_ = d; + duration_ = d; } Rhythmic_req::Rhythmic_req() @@ -192,22 +194,22 @@ void Rhythmic_req::do_print() const { #ifndef NPRINT - DOUT << "duration { " <align_i_ = 0; // centre - dir_i_ = -1; // lyrics below (invisible) staff + def_p->align_i_ = 0; // centre + dir_i_ = -1; // lyrics below (invisible) staff } @@ -216,21 +218,21 @@ IMPLEMENT_IS_TYPE_B2(Lyric_req,Musical_req,Rhythmic_req); void Lyric_req::do_print() const { - Rhythmic_req::do_print(); - Text_req::do_print(); + Rhythmic_req::do_print(); + Text_req::do_print(); } /* *************** */ bool Note_req::do_equal_b (Request*r)const { - return Rhythmic_req::do_equal_b (r) && Melodic_req::do_equal_b (r); + return Rhythmic_req::do_equal_b (r) && Melodic_req::do_equal_b (r); } Note_req::Note_req() { - forceacc_b_ = false; + forceacc_b_ = false; } IMPLEMENT_IS_TYPE_B2(Note_req,Melodic_req,Rhythmic_req); @@ -239,11 +241,12 @@ void Note_req::do_print() const { #ifndef NPRINT - Melodic_req::do_print(); - if (forceacc_b_) { + Melodic_req::do_print(); + if (forceacc_b_) + { DOUT << " force accidental\n"; } - Rhythmic_req::do_print(); + Rhythmic_req::do_print(); #endif } /* *************** */ @@ -253,13 +256,13 @@ IMPLEMENT_IS_TYPE_B1(Rest_req,Rhythmic_req); void Rest_req::do_print() const { - Rhythmic_req::do_print(); + Rhythmic_req::do_print(); } /* *************** */ Beam_req::Beam_req() { - nplet = 0; + nplet = 0; } IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req); @@ -276,20 +279,20 @@ Slur_req::do_print()const{} bool Span_req:: do_equal_b (Request*r)const { - Span_req * s = r->span(); - return spantype - s->spantype; + Span_req * s = r->span(); + return spantype - s->spantype; } Span_req::Span_req() { - spantype = NOSPAN; + spantype = NOSPAN; } /* *************** */ Script_req::Script_req (Script_req const&s) { - dir_i_ = s.dir_i_; - scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone() : 0; + dir_i_ = s.dir_i_; + scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone() : 0; } /* @@ -300,15 +303,15 @@ Script_req::Script_req (Script_req const&s) bool Script_req::do_equal_b (Request*r)const { - Script_req * s = r->script(); - - return scriptdef_p_->equal_b (*s->scriptdef_p_); + Script_req * s = r->script(); + + return scriptdef_p_->equal_b (*s->scriptdef_p_); } Script_req::Script_req() { - dir_i_ = 0; - scriptdef_p_ = 0; + dir_i_ = 0; + scriptdef_p_ = 0; } @@ -318,15 +321,15 @@ void Script_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; - scriptdef_p_->print(); + DOUT << " dir " << dir_i_ ; + scriptdef_p_->print(); #endif } void Musical_script_req::do_print() const { - Script_req::do_print(); + Script_req::do_print(); } @@ -335,27 +338,27 @@ IMPLEMENT_IS_TYPE_B2(Musical_script_req,Musical_req, Script_req); Script_req::~Script_req() { - delete scriptdef_p_; + delete scriptdef_p_; } /* *************** */ Text_req::~Text_req() { - delete tdef_p_; - tdef_p_ = 0; + delete tdef_p_; + tdef_p_ = 0; } Text_req::Text_req (Text_req const& src) { - tdef_p_ = new Text_def (*src.tdef_p_); - dir_i_ = src.dir_i_; + tdef_p_ = new Text_def (*src.tdef_p_); + dir_i_ = src.dir_i_; } Text_req::Text_req (int dir_i, Text_def* tdef_p) { - dir_i_ = dir_i; - tdef_p_ = tdef_p; + dir_i_ = dir_i; + tdef_p_ = tdef_p; } @@ -365,8 +368,8 @@ void Text_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; - tdef_p_->print(); + DOUT << " dir " << dir_i_ ; + tdef_p_->print(); #endif } @@ -380,7 +383,7 @@ Skip_req::do_print() const { #ifndef NPRINT - DOUT << "duration: " << duration(); + DOUT << "duration: " << duration(); #endif } @@ -391,7 +394,7 @@ IMPLEMENT_IS_TYPE_B1(Dynamic_req,Musical_req); void Dynamic_req::do_print() const { - Musical_req::do_print(); + Musical_req::do_print(); } @@ -401,37 +404,38 @@ void Absolute_dynamic_req::do_print() const { #ifndef NPRINT - Dynamic_req::do_print(); - DOUT << " loudness " <; - errorlevel_i_ = 0; - post_quotes_b_ = false; - note_tab_p_ = new Notename_table; + keytable_p_ = new Keyword_table (the_key_tab); + identifier_assoc_p_ = new Assoc; + errorlevel_i_ = 0; + post_quotes_b_ = false; + note_tab_p_ = new Notename_table; } int My_lily_lexer::lookup_keyword (String s) { - return keytable_p_->lookup (s); + return keytable_p_->lookup (s); } Identifier* My_lily_lexer::lookup_identifier (String s) { - if (!identifier_assoc_p_->elt_b (s)) + if (!identifier_assoc_p_->elt_b (s)) return 0; - - return (*identifier_assoc_p_)[s]; + + return (*identifier_assoc_p_)[s]; } void My_lily_lexer::set_identifier (String name_str, Identifier*i) { - Identifier *old = lookup_identifier (name_str); - if (old) { + Identifier *old = lookup_identifier (name_str); + if (old) + { old->warning( "redeclaration of \\" + name_str); delete old; } - (*identifier_assoc_p_)[name_str] = i; + (*identifier_assoc_p_)[name_str] = i; } My_lily_lexer::~My_lily_lexer() { - delete keytable_p_; + delete keytable_p_; - for (Assoc_iter - ai (*identifier_assoc_p_); ai.ok(); ai++) { + for (Assoc_iter + ai (*identifier_assoc_p_); ai.ok(); ai++) + { DOUT << "deleting: " << ai.key()<<'\n'; delete ai.val(); } - delete note_tab_p_; - delete identifier_assoc_p_; + delete note_tab_p_; + delete identifier_assoc_p_; } void My_lily_lexer::print_declarations (bool init_b)const { - for (Assoc_iter ai (*identifier_assoc_p_); ai.ok(); - ai++) { - if (ai.val()->init_b_ == init_b) { + for (Assoc_iter ai (*identifier_assoc_p_); ai.ok(); + ai++) + { + if (ai.val()->init_b_ == init_b) + { DOUT << ai.key() << '='; ai.val()->print (); - } + } } } void My_lily_lexer::LexerError (char const *s) { - if (include_stack_.empty()) { + if (include_stack_.empty()) + { *mlog << "error at EOF" << s << '\n'; - } else { + } + else + { errorlevel_i_ |= 1; Input spot (source_file_l(),here_ch_C()); @@ -146,18 +154,18 @@ My_lily_lexer::LexerError (char const *s) Melodic_req* My_lily_lexer::lookup_melodic_req_l (String s) { - return note_tab_p_->get_l (s); + return note_tab_p_->get_l (s); } void My_lily_lexer::add_notename (String s, Melodic_req *p) { - note_tab_p_->add (s,p); + note_tab_p_->add (s,p); } void My_lily_lexer::clear_notenames() { - delete note_tab_p_; - note_tab_p_ = new Notename_table; + delete note_tab_p_; + note_tab_p_ = new Notename_table; } diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index a8db01da18..f195e9ef5e 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -18,22 +18,22 @@ void My_lily_parser::clear_notenames() { - lexer_p_->clear_notenames(); + lexer_p_->clear_notenames(); } void My_lily_parser::set_version_check (bool ig) { - ignore_version_b_ = ig; + ignore_version_b_ = ig; } void My_lily_parser::set_debug() { #ifndef NPRINT - String s = ""; - if (init_parse_b_) + String s = ""; + if (init_parse_b_) s = "Init"; - set_yydebug (!monitor->silence (s+"Parser") && check_debug); - lexer_p_->set_debug (!monitor->silence (s+"Lexer") && check_debug); + set_yydebug (!monitor->silence (s+"Parser") && check_debug); + lexer_p_->set_debug (!monitor->silence (s+"Lexer") && check_debug); #endif } @@ -41,11 +41,12 @@ void My_lily_parser::print_declarations() { #ifndef NPRINT - String s = ""; - - if (init_parse_b_) + String s = ""; + + if (init_parse_b_) s = "Init"; - if (!monitor->silence (s+"Declarations") && check_debug) { + if (!monitor->silence (s+"Declarations") && check_debug) + { lexer_p_->print_declarations (init_parse_b_); } #endif @@ -54,71 +55,73 @@ My_lily_parser::print_declarations() void My_lily_parser::parse_file (String init, String s) { - lexer_p_ = new My_lily_lexer; - init_str_ = init; - - *mlog << "Parsing ... "; - - init_parse_b_ = true; - lexer_p_->new_input (init, source_l_); - do_yyparse(); - print_declarations(); - - init_parse_b_ = false; - lexer_p_->new_input (s , source_l_); - do_yyparse(); - print_declarations(); - - - if (!define_spot_array_.empty()) + lexer_p_ = new My_lily_lexer; + init_str_ = init; + + *mlog << "Parsing ... "; + + init_parse_b_ = true; + set_debug(); + lexer_p_->new_input (init, source_l_); + do_yyparse(); + print_declarations(); + + init_parse_b_ = false; + set_debug(); + lexer_p_->new_input (s , source_l_); + do_yyparse(); + print_declarations(); + + + if (!define_spot_array_.empty()) warning ("Braces don't match."); } My_lily_parser::~My_lily_parser() { - delete lexer_p_; + delete lexer_p_; } - + void My_lily_parser::remember_spot() { - define_spot_array_.push (here_input()); + define_spot_array_.push (here_input()); } char const * My_lily_parser::here_ch_C()const { - return lexer_p_->here_ch_C(); + return lexer_p_->here_ch_C(); } void My_lily_parser::parser_error (String s) { - here_input().error (s); - if ( fatal_error_i_) + here_input().error (s); + if ( fatal_error_i_) exit (fatal_error_i_); - error_level_i_ = 1; + error_level_i_ = 1; } void My_lily_parser::set_duration_mode (String s) { - s = s.upper_str(); - last_duration_mode_b_ = (s== "LAST"); + s = s.upper_str(); + last_duration_mode_b_ = (s== "LAST"); } void My_lily_parser::set_default_duration (Duration const *d) { - last_duration_mode_b_ = false; - default_duration_ = *d; + last_duration_mode_b_ = false; + default_duration_ = *d; } void My_lily_parser::set_last_duration (Duration const *d) { - if (last_duration_mode_b_) + if (last_duration_mode_b_) default_duration_ = *d; } @@ -126,57 +129,59 @@ My_lily_parser::set_last_duration (Duration const *d) Chord* My_lily_parser::get_word_element (Text_def* tdef_p, Duration * duration_p) { - Chord* velt_p = new Request_chord; - - Lyric_req* lreq_p = new Lyric_req (tdef_p); + Chord* velt_p = new Request_chord; + + Lyric_req* lreq_p = new Lyric_req (tdef_p); - lreq_p->duration_ = *duration_p; - lreq_p->set_spot (here_input()); + lreq_p->duration_ = *duration_p; + lreq_p->set_spot (here_input()); - velt_p->add (lreq_p); + velt_p->add (lreq_p); - delete duration_p; - return velt_p; + delete duration_p; + return velt_p; } Chord * My_lily_parser::get_rest_element (String s, Duration * duration_p) { - Chord* velt_p = new Request_chord; - velt_p->set_spot (here_input()); + Chord* velt_p = new Request_chord; + velt_p->set_spot (here_input()); - if (s=="s") { /* Space */ + if (s=="s") { /* Space */ Skip_req * skip_p = new Skip_req; skip_p->duration_ = *duration_p; skip_p->set_spot (here_input()); velt_p->add (skip_p); } - else { + else + { Rest_req * rest_req_p = new Rest_req; rest_req_p->duration_ = *duration_p; rest_req_p->set_spot (here_input()); velt_p->add (rest_req_p); } - Stem_req * stem_p = new Stem_req; - stem_p->duration_ = *duration_p; - stem_p->set_spot ( here_input()); - velt_p->add (stem_p); + Stem_req * stem_p = new Stem_req; + stem_p->duration_ = *duration_p; + stem_p->set_spot ( here_input()); + velt_p->add (stem_p); - delete duration_p; - return velt_p; + delete duration_p; + return velt_p; } Chord * My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p) { - Chord*v = new Request_chord; - v->set_spot (here_input()); + Chord*v = new Request_chord; + v->set_spot (here_input()); - v->add (rq); - - if (duration_p->type_i_ >= 2) { + v->add (rq); + + if (duration_p->durlog_i_ >= 1) + { Stem_req * stem_req_p = new Stem_req(); stem_req_p->duration_ = *duration_p; @@ -184,114 +189,119 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p) v->add (stem_req_p); } - rq->set_duration (*duration_p); - rq->set_spot (here_input()); - delete duration_p ; - return v; + rq->set_duration (*duration_p); + rq->set_spot (here_input()); + delete duration_p ; + return v; } Request* My_lily_parser::get_parens_request (char c) { - Request* req_p=0; - switch (c) { + Request* req_p=0; + switch (c) + { - case '~': + case '~': req_p = new Tie_req; break; - case '[': - case ']': - { + case '[': + case ']': + { Beam_req*b = new Beam_req; int p_i=plet_.type_i_ ; // ugh . Should junk? if (p_i!= 1) b->nplet = p_i; req_p = b; } - break; + break; - case '>': - case '!': - case '<': + case '>': + case '!': + case '<': req_p = new Span_dynamic_req; break; - - case ')': - case '(': + + case ')': + case '(': req_p = new Slur_req; break; - default: + default: assert (false); break; } - - switch (c) { - case '<': - case '>': - case '(': - case '[': + + switch (c) + { + case '<': + case '>': + case '(': + case '[': req_p->span()->spantype = Span_req::START; break; - case '!': - case ')': - case ']': + case '!': + case ')': + case ']': req_p->span()->spantype = Span_req::STOP; break; - default: + default: break; } - if (req_p->musical()->span_dynamic ()) { + if (req_p->musical()->span_dynamic ()) + { Span_dynamic_req* s_l= (req_p->musical()->span_dynamic ()) ; s_l->dynamic_dir_i_ = (c == '<') ? 1:-1; } - req_p->set_spot (here_input()); - return req_p; + req_p->set_spot (here_input()); + return req_p; } My_lily_parser::My_lily_parser (Sources * source_l) { - first_b_ = true; - source_l_ = source_l; - lexer_p_ = 0; - default_duration_.type_i_ = 4; - default_octave_i_ = 0; - textstyle_str_="roman"; // in lexer? - error_level_i_ = 0; - last_duration_mode_b_ = true; - fatal_error_i_ = 0; + first_b_ = true; + source_l_ = source_l; + lexer_p_ = 0; + default_duration_.durlog_i_ = 2; + default_octave_i_ = 0; + textstyle_str_="roman"; // in lexer? + error_level_i_ = 0; + last_duration_mode_b_ = true; + fatal_error_i_ = 0; } void My_lily_parser::add_requests (Chord*v) { - for (int i = 0; i < pre_reqs.size(); i++) { + for (int i = 0; i < pre_reqs.size(); i++) + { v->add (pre_reqs[i]); } - pre_reqs.clear(); - for (int i = 0; i add (post_reqs[i]); } - post_reqs.clear(); + post_reqs.clear(); } Input My_lily_parser::pop_spot() { - return define_spot_array_.pop(); + return define_spot_array_.pop(); } Input My_lily_parser::here_input()const { - Source_file * f_l= lexer_p_->source_file_l(); - return Input (f_l, here_ch_C()); + Source_file * f_l= lexer_p_->source_file_l(); + return Input (f_l, here_ch_C()); } void My_lily_parser::add_notename (String s, Melodic_req * m_p) { - lexer_p_->add_notename (s, m_p); + lexer_p_->add_notename (s, m_p); } diff --git a/lily/note-column-grav.cc b/lily/note-column-grav.cc index d9811ef370..34e12316d0 100644 --- a/lily/note-column-grav.cc +++ b/lily/note-column-grav.cc @@ -16,68 +16,78 @@ bool Note_column_engraver::acceptable_elem_b (Score_elem const*elem_C)const { - char const*nC = elem_C->name(); - return (nC == Script::static_name() || nC == Note_head::static_name () + char const*nC = elem_C->name(); + return (nC == Script::static_name() || nC == Note_head::static_name () || nC == Stem::static_name()); } Note_column* Note_column_engraver::note_col_l() { - if (!ncol_p_){ + if (!ncol_p_) + { ncol_p_ = new Note_column; announce_element (Score_elem_info (ncol_p_, 0)); } - return ncol_p_; + return ncol_p_; } Rest_column * Note_column_engraver::rest_col_l() { - if (!restcol_p_) { + if (!restcol_p_) + { restcol_p_ = new Rest_column; announce_element (Score_elem_info (restcol_p_,0)); } - return restcol_p_; + return restcol_p_; } void Note_column_engraver::acknowledge_element (Score_elem_info i) { - if (!acceptable_elem_b (i.elem_l_)) + if (!acceptable_elem_b (i.elem_l_)) return; - char const*nC = i.elem_l_->name(); + char const*nC = i.elem_l_->name(); - if (nC == Script::static_name() && i.req_l_ && i.req_l_->musical ()) { + if (nC == Script::static_name() && i.req_l_ && i.req_l_->musical ()) + { script_l_arr_.push ((Script*)i.elem_l_->item()); - } else if (nC == Note_head::static_name()) { + } + else if (nC == Note_head::static_name()) + { Note_head * h_l = (Note_head*)i.elem_l_->item(); if (h_l->rest_b_) rest_col_l()->add (h_l); else note_col_l()->add (h_l); - } else if (nC == Stem::static_name()){ + } + else if (nC == Stem::static_name()) + { stem_l_ = (Stem*)i.elem_l_->item(); } - if ( ncol_p_ || restcol_p_) { - if ( stem_l_) { + if ( ncol_p_ || restcol_p_) + { + if ( stem_l_) + { if (restcol_p_&& !restcol_p_->stem_l_) restcol_p_->set (stem_l_); if (ncol_p_ && !ncol_p_->stem_l_) ncol_p_->set (stem_l_); - } - - - for (int i=0; i < script_l_arr_.size(); i++) { + } + + + for (int i=0; i < script_l_arr_.size(); i++) + { if (restcol_p_) restcol_p_->add (script_l_arr_[i]); if ( ncol_p_) ncol_p_->add (script_l_arr_[i]); - } - + } + script_l_arr_.clear(); } @@ -86,7 +96,8 @@ Note_column_engraver::acknowledge_element (Score_elem_info i) void Note_column_engraver::do_pre_move_processing() { - if (ncol_p_) { + if (ncol_p_) + { if (! ncol_p_->h_shift_b_) ncol_p_->h_shift_b_ = h_shift_b_; if (! ncol_p_->dir_i_) @@ -95,7 +106,8 @@ Note_column_engraver::do_pre_move_processing() typeset_element (ncol_p_); ncol_p_ =0; } - if (restcol_p_) { + if (restcol_p_) + { if (! restcol_p_->dir_i_) restcol_p_->dir_i_ = dir_i_; @@ -107,27 +119,27 @@ Note_column_engraver::do_pre_move_processing() void Note_column_engraver::do_post_move_processing() { - script_l_arr_.clear(); - stem_l_ =0; + script_l_arr_.clear(); + stem_l_ =0; } void Note_column_engraver::set_feature (Feature i) { - if (i.type_ == "vdir") + if (i.type_ == "vdir") dir_i_ = i.value_; - if (i.type_ == "hshift") + if (i.type_ == "hshift") h_shift_b_ = (bool)(int)i.value_; } Note_column_engraver::Note_column_engraver() { - dir_i_ =0; - h_shift_b_ = false; - - ncol_p_=0; - restcol_p_ =0; - do_post_move_processing(); + dir_i_ =0; + h_shift_b_ = false; + + ncol_p_=0; + restcol_p_ =0; + do_post_move_processing(); } diff --git a/lily/note-column.cc b/lily/note-column.cc index 343414c035..19cf429928 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -17,26 +17,26 @@ IMPLEMENT_IS_TYPE_B1(Note_column,Head_column); void Note_column::set (Stem*s) { - stem_l_ = s; - add_support (s); + stem_l_ = s; + add_support (s); } Note_column::Note_column() { - h_shift_b_ =false; + h_shift_b_ =false; } void Note_column::sort() { - head_l_arr_.sort (Note_head::compare); + head_l_arr_.sort (Note_head::compare); } - + Interval_t Note_column::head_positions_interval()const { - ((Note_column*)this)->sort(); - return Interval_t ( head_l_arr_[0]->position_i_, + ((Note_column*)this)->sort(); + return Interval_t ( head_l_arr_[0]->position_i_, head_l_arr_.top()->position_i_); } @@ -45,10 +45,11 @@ Note_column::head_positions_interval()const void Note_column::do_pre_processing() { - if (!dir_i_&& !stem_l_){ + if (!dir_i_&& !stem_l_) + { dir_i_ = (head_positions_interval().center () >= 5) ? -1 : 1; } - Head_column::do_pre_processing(); + Head_column::do_pre_processing(); } - + diff --git a/lily/note-performer.cc b/lily/note-performer.cc index e9e5dd5ca7..dd2ac9da14 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -19,15 +19,16 @@ ADD_THIS_PERFORMER(Note_performer); Note_performer::Note_performer() { - note_req_l_ = 0; + note_req_l_ = 0; } void Note_performer::do_print() const { #ifndef NPRINT - if ( note_req_l_) { - note_req_l_->print(); + if ( note_req_l_) + { + note_req_l_->print(); } #endif } @@ -35,23 +36,23 @@ Note_performer::do_print() const void Note_performer::process_requests() { - // this is _really_ braindead, but it generates some output - if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) + // this is _really_ braindead, but it generates some output + if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ()) return; - play (new Audio_note (note_req_l_) ); - note_req_l_ = 0; + play (new Audio_note (note_req_l_) ); + note_req_l_ = 0; } bool Note_performer::do_try_request (Request* req_l) { - if ( note_req_l_) + if ( note_req_l_) return false; - - if ( !req_l->musical() || !req_l->musical ()->note ()) + + if ( !req_l->musical() || !req_l->musical ()->note ()) return false; - note_req_l_ = req_l->musical()->melodic (); - return true; + note_req_l_ = req_l->musical()->melodic (); + return true; } diff --git a/lily/note.cc b/lily/note.cc index 2b1a8c447b..ec84dbba52 100644 --- a/lily/note.cc +++ b/lily/note.cc @@ -20,37 +20,38 @@ String * get_scriptdef (char c) { - String s; - switch (c) { - case '^' : s = "marcato"; + String s; + switch (c) + { + case '^' : s = "marcato"; break; - case '+' : s = "stopped"; + case '+' : s = "stopped"; break; - case '-' : s = "tenuto"; + case '-' : s = "tenuto"; break; - case '|': s = "staccatissimo"; + case '|': s = "staccatissimo"; break; - case 'o' : s = ""; + case 'o' : s = ""; break; - case '>' : s = "accent"; + case '>' : s = "accent"; break; - case 'v' : s = ""; + case 'v' : s = ""; break; - case '.' : s = "staccato"; + case '.' : s = "staccato"; break; - default: + default: assert (false); } - return new String (s); + return new String (s); } Request* get_script_req (int d , General_script_def*def) { - Musical_script_req* script_req_p = new Musical_script_req; - script_req_p->dir_i_ =d; - script_req_p->scriptdef_p_=def; - return script_req_p; + Musical_script_req* script_req_p = new Musical_script_req; + script_req_p->dir_i_ =d; + script_req_p->scriptdef_p_=def; + return script_req_p; } @@ -58,28 +59,29 @@ get_script_req (int d , General_script_def*def) Request* get_stemdir_req (int d) { - d = sign (long (d)); - Group_feature_req * gfreq_p = new Group_feature_req; - gfreq_p->type_str_ = "vdir"; - gfreq_p->value_str_ = String (d); - return gfreq_p; + d = sign (long (d)); + Group_feature_req * gfreq_p = new Group_feature_req; + gfreq_p->type_str_ = "vdir"; + gfreq_p->value_str_ = String (d); + return gfreq_p; } Request* get_hshift_req (int i) { Group_feature_req * gfreq_p = new Group_feature_req; - gfreq_p->type_str_ = "hshift"; - gfreq_p->value_str_ = String (i); - return gfreq_p; + gfreq_p->type_str_ = "hshift"; + gfreq_p->value_str_ = String (i); + return gfreq_p; } - + Request* get_grouping_req (Array i_arr) { - Measure_grouping_req * mr_p = new Measure_grouping_req; - for (int i=0; i elt_length_arr_.push (Moment (1, i_arr[i++])); mr_p->beat_i_arr_.push (i_arr[i++]); } - return mr_p; + return mr_p; } diff --git a/lily/notehead.cc b/lily/notehead.cc index 860fee7258..6871240ff9 100644 --- a/lily/notehead.cc +++ b/lily/notehead.cc @@ -21,37 +21,38 @@ Separate notehead into - Rhythmic_head - Note_head - Rest + Rhythmic_head + Note_head + Rest - and Stem takes Rhythmic_heads + and Stem takes Rhythmic_heads */ Note_head::Note_head (int ss) { - x_dir_i_ = 0; - staff_size_i_=ss; - position_i_ = 0; - balltype_i_ = 0; - dots_i_ = 0; - dot_delta_y_i_ = 0; - extremal_i_ = 0; - rest_b_ = false; + x_dir_i_ = 0; + staff_size_i_=ss; + position_i_ = 0; + balltype_i_ = 0; + dots_i_ = 0; + dot_delta_y_i_ = 0; + extremal_i_ = 0; + rest_b_ = false; } void Note_head::do_pre_processing() { - // 8 ball looks the same as 4 ball: - if (balltype_i_ > 4 && !rest_b_) - balltype_i_ = 4; - - if (rest_b_) { - if (balltype_i_ == 1) + // 8 ball looks the same as 4 ball: + if (balltype_i_ > 2 && !rest_b_) + balltype_i_ = 2; + + if (rest_b_) + { + if (balltype_i_ == 0) position_i_ += 6; - else if (balltype_i_ == 2) + else if (balltype_i_ == 0) position_i_ += 4; } } @@ -59,10 +60,10 @@ Note_head::do_pre_processing() void Note_head::set_rhythmic (Rhythmic_req*r_req_l) { - balltype_i_ = r_req_l->duration_.type_i_; - dots_i_ = r_req_l->duration_.dots_i_; + balltype_i_ = r_req_l->duration_.durlog_i_; + dots_i_ = r_req_l->duration_.dots_i_; } - + IMPLEMENT_IS_TYPE_B1(Note_head,Item); @@ -70,9 +71,9 @@ void Note_head::do_print()const { #ifndef NPRINT - if (rest_b_) + if (rest_b_) DOUT << "REST! "; - DOUT << "balltype_i_ "<< balltype_i_ << ", position_i_ = "<< position_i_ + DOUT << "balltype_i_ "<< balltype_i_ << ", position_i_ = "<< position_i_ << "dots_i_ " << dots_i_; #endif } @@ -81,15 +82,15 @@ Note_head::do_print()const int Note_head::compare (Note_head *const &a, Note_head * const &b) { - return a->position_i_ - b->position_i_; + return a->position_i_ - b->position_i_; } void Note_head::set_dots() { - if (!(position_i_ %2) && rest_b_ && balltype_i_ == 1) + if (!(position_i_ %2) && rest_b_ && balltype_i_ == 0) dot_delta_y_i_ = -1; - else if (!(position_i_ %2)) + else if (!(position_i_ %2)) dot_delta_y_i_ = 1; } @@ -99,23 +100,25 @@ Note_head::set_dots() Molecule* Note_head::brew_molecule_p() const { - ((Note_head*)this)->set_dots(); // UGH GUH - Molecule*out = 0; - Paper_def *p = paper(); - Real inter_f = p->internote_f(); - Symbol s; - - // ugh - bool streepjes_b = (position_i_<-1) || (position_i_ > staff_size_i_+1); - - if (!rest_b_) + ((Note_head*)this)->set_dots(); // UGH GUH + Molecule*out = 0; + Paper_def *p = paper(); + Real inter_f = p->internote_f(); + Symbol s; + + // ugh + bool streepjes_b = (position_i_<-1) || (position_i_ > staff_size_i_+1); + + if (!rest_b_) s = p->lookup_l()->ball (balltype_i_); - else { + else + { s = p->lookup_l()->rest (balltype_i_, streepjes_b); } - out = new Molecule (Atom (s)); - out->translate (x_dir_i_ * s.dim.x().length () , X_AXIS); - if (dots_i_) { + out = new Molecule (Atom (s)); + out->translate (x_dir_i_ * s.dim.x().length () , X_AXIS); + if (dots_i_) + { Symbol d = p->lookup_l()->dots (dots_i_); Molecule dm; dm.add (Atom (d)); @@ -123,12 +126,14 @@ Note_head::brew_molecule_p() const out->add_right (dm); } - - if (rest_b_) { + + if (rest_b_) + { streepjes_b = false; } - - if (streepjes_b) { + + if (streepjes_b) + { int dir = sign (position_i_); int s =(position_i_<-1) ? -((-position_i_)/2): (position_i_-staff_size_i_)/2; @@ -139,8 +144,8 @@ Note_head::brew_molecule_p() const sm.translate (-inter_f* dir, Y_AXIS); out->add (sm); } - - out->translate (inter_f*position_i_, Y_AXIS); - return out; + + out->translate (inter_f*position_i_, Y_AXIS); + return out; } diff --git a/lily/notename-table.cc b/lily/notename-table.cc index 325d91e5f8..049f0cdfcb 100644 --- a/lily/notename-table.cc +++ b/lily/notename-table.cc @@ -15,14 +15,14 @@ template class P; void Notename_table::add (String s, Melodic_req *m_p) { - elem (s).set_p (m_p); + elem (s).set_p (m_p); } Melodic_req* Notename_table::get_l (String s) { - if (! elt_b (s)) + if (! elt_b (s)) return 0; - return elem (s); + return elem (s); } - + diff --git a/lily/p-col.cc b/lily/p-col.cc index 69813e8a7e..9e5be11664 100644 --- a/lily/p-col.cc +++ b/lily/p-col.cc @@ -14,40 +14,41 @@ Interval PCol::width() const { - Interval w; + Interval w; - for (iter_top (its,i); i.ok(); i++) + for (iter_top (its,i); i.ok(); i++) w.unite (i->width()); - if (w.empty_b()) + if (w.empty_b()) w.unite (Interval (0,0)); - return w; + return w; } void PCol::clean_breakable_items() { - if (!line_l_) { + if (!line_l_) + { its.junk_links(); } - if (prebreak_p_) + if (prebreak_p_) prebreak_p_->clean_breakable_items(); - if (postbreak_p_) + if (postbreak_p_) postbreak_p_->clean_breakable_items(); } int PCol::rank_i() const { - return rank_i_; + return rank_i_; } void PCol::set_rank (int i) { - rank_i_ = i; - if (prebreak_p_) + rank_i_ = i; + if (prebreak_p_) prebreak_p_->rank_i_ = i; - if (postbreak_p_) + if (postbreak_p_) postbreak_p_->rank_i_ = i; } @@ -55,36 +56,42 @@ void PCol::print() const { #ifndef NPRINT - DOUT << "PCol {"; + DOUT << "PCol {"; - DOUT << "rank: " << rank_i_ << '\n'; + DOUT << "rank: " << rank_i_ << '\n'; - DOUT << "# symbols: " << its.size() ; - if (breakable_b()){ - DOUT << "\npre,post: "; - prebreak_p_->print(); - postbreak_p_->print(); - } else if (daddy_l_) { + DOUT << "# symbols: " << its.size() ; + if (prebreak_p_){ + DOUT << "\npre: "; + prebreak_p_->print(); + } + if (postbreak_p_) { + DOUT << "post: "; + postbreak_p_->print(); + } + else if (daddy_l_) + { DOUT <<'\n' << ((this == daddy_l_->prebreak_p_) ? "prebreak" : "postbreak"); DOUT << '\n'; } - DOUT << "extent: " << width().str () << "\n"; - DOUT << "}\n"; + DOUT << "extent: " << width().str () << "\n"; + DOUT << "}\n"; #endif } int PCol::compare (PCol const &c1, PCol const &c2) { - return c1.rank_i() - c2.rank_i (); + return c1.rank_i() - c2.rank_i (); } void PCol::OK() const { #ifndef NDEBUG - if (prebreak_p_ || postbreak_p_) { + if (prebreak_p_ || postbreak_p_) + { assert (prebreak_p_&&postbreak_p_); assert (prebreak_p_->daddy_l_ == this); assert (postbreak_p_->daddy_l_ == this); @@ -95,63 +102,63 @@ PCol::OK() const void PCol::set_breakable() { - if (breakable_b()) + if (breakable_b()) return; - do_set_breakable(); - prebreak_p_->pscore_l_ = pscore_l_; - postbreak_p_->pscore_l_ = pscore_l_; + do_set_breakable(); + prebreak_p_->pscore_l_ = pscore_l_; + postbreak_p_->pscore_l_ = pscore_l_; - prebreak_p_->daddy_l_ = postbreak_p_->daddy_l_ = this; + prebreak_p_->daddy_l_ = postbreak_p_->daddy_l_ = this; } void PCol::do_set_breakable() { - prebreak_p_ = new PCol; - postbreak_p_ = new PCol; + prebreak_p_ = new PCol; + postbreak_p_ = new PCol; } bool PCol::breakpoint_b() const { - return !line_l_; + return !line_l_; } bool PCol::breakable_b() const { - return prebreak_p_||postbreak_p_; + return prebreak_p_||postbreak_p_||daddy_l_; } PCol::PCol() { - used_b_ = false; - error_mark_b_ = false; - daddy_l_ = 0; - prebreak_p_=0; - postbreak_p_=0; - line_l_=0; - hpos_f_ = -1.0; - pscore_l_ = 0; - rank_i_ = -1; + used_b_ = false; + error_mark_b_ = false; + daddy_l_ = 0; + prebreak_p_=0; + postbreak_p_=0; + line_l_=0; + hpos_f_ = -1.0; + pscore_l_ = 0; + rank_i_ = -1; } PCol::~PCol() { - delete prebreak_p_; - delete postbreak_p_; + delete prebreak_p_; + delete postbreak_p_; } void PCol::add (Item *i) { - its.bottom().add (i); - i->pcol_l_ = this; + its.bottom().add (i); + i->pcol_l_ = this; } bool PCol::used_b()const { - return daddy_l_ || breakable_b() || its.size ()|| used_b_; + return daddy_l_ || breakable_b() || its.size ()|| used_b_; } diff --git a/lily/p-score.cc b/lily/p-score.cc index 73ab917422..dbf5d84525 100644 --- a/lily/p-score.cc +++ b/lily/p-score.cc @@ -21,97 +21,103 @@ Paper_score::Paper_score (Paper_def*p) { - paper_l_ = p; - super_elem_l_ = new Super_elem; - typeset_element (super_elem_l_); + paper_l_ = p; + super_elem_l_ = new Super_elem; + typeset_element (super_elem_l_); } Paper_score::~Paper_score() { - super_elem_l_->unlink_all(); + super_elem_l_->unlink_all(); } void Paper_score::typeset_element (Score_elem * elem_p) { - elem_p_list_.bottom().add (elem_p); - elem_p->pscore_l_ = this; + elem_p_list_.bottom().add (elem_p); + elem_p->pscore_l_ = this; - elem_p->add_processing(); + elem_p->add_processing(); } void Paper_score::typeset_item (Item *i, PCol *c) { - assert (c && i); - int breakstat = i->break_status_i_; + assert (c && i); + int breakstat = i->break_status_i_; - if (breakstat == -1) { + if (breakstat == -1) + { c = c->prebreak_p_; - }else if (breakstat == 1) { + }else if (breakstat == 1) + { c = c->postbreak_p_; } - c->add (i); - typeset_element (i); + c->add (i); + typeset_element (i); } void Paper_score::typeset_broken_spanner (Spanner*span_p) { - span_p->left_col_l_->starters.bottom().add (span_p); - assert (span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_); + span_p->left_col_l_->starters.bottom().add (span_p); + assert (span_p->left_col_l_->line_l_ == span_p->right_col_l_->line_l_); - typeset_element (span_p); + typeset_element (span_p); } void Paper_score::typeset_unbroken_spanner (Spanner*span_p) { - span_p_list_.bottom().add (span_p); - span_p->pscore_l_=this; + span_p_list_.bottom().add (span_p); + span_p->pscore_l_=this; - if (span_p->left_col_l_) + if (span_p->left_col_l_) span_p->left_col_l_->used_b_ = true; - if ( span_p->right_col_l_) + if ( span_p->right_col_l_) span_p->right_col_l_->used_b_ = true; - - // do not init start/stop fields. These are for broken spans only. - span_p->add_processing(); + + // do not init start/stop fields. These are for broken spans only. + span_p->add_processing(); } void Paper_score::clean_cols() { - int rank_i = 0; - for (iter_top (col_p_list_,c); c.ok();) - if (!c->used_b()) { + int rank_i = 0; + for (iter_top (col_p_list_,c); c.ok();) + if (!c->used_b()) + { delete c.remove_p(); - } else { + } + else + { c->set_rank (rank_i++); c++; - } + } } void Paper_score::add (PCol *p) { - p->pscore_l_ = this; - if (p->breakable_b()){ + p->pscore_l_ = this; + if (p->breakable_b()) + { p->prebreak_p_->pscore_l_ = this; p->postbreak_p_->pscore_l_ = this; } - col_p_list_.bottom().add (p); + col_p_list_.bottom().add (p); } void Paper_score::output (Tex_stream &ts) { - ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n"; - ts<< super_elem_l_->TeX_string(); - ts << "\n\\EndLilyPondOutput"; + ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n"; + ts<< super_elem_l_->TeX_string(); + ts << "\n\\EndLilyPondOutput"; } @@ -119,9 +125,9 @@ void Paper_score::OK()const { #ifndef NDEBUG - for (iter_top (col_p_list_,cc); cc.ok(); cc++) + for (iter_top (col_p_list_,cc); cc.ok(); cc++) cc->OK(); - for (PCursor i (elem_p_list_.top()); i.ok (); i++) + for (PCursor i (elem_p_list_.top()); i.ok (); i++) i->OK(); #endif } @@ -130,118 +136,127 @@ void Paper_score::print() const { #ifndef NPRINT - if ( !check_debug) + if ( !check_debug) return ; - DOUT << "Paper_score { "; - paper_l_->print(); - DOUT << "\n elements: "; - for (iter_top (elem_p_list_,cc); cc.ok(); cc++) + DOUT << "Paper_score { "; + paper_l_->print(); + DOUT << "\n elements: "; + for (iter_top (elem_p_list_,cc); cc.ok(); cc++) cc->print(); - DOUT << "\n unbroken spanners: "; - for (iter (span_p_list_.top(), i); i.ok (); i++) + DOUT << "\n unbroken spanners: "; + for (iter (span_p_list_.top(), i); i.ok (); i++) i->print(); - DOUT << "\ncolumns: "; - for (iter_top (col_p_list_,cc); cc.ok(); cc++) + DOUT << "\ncolumns: "; + for (iter_top (col_p_list_,cc); cc.ok(); cc++) cc->print(); - - DOUT << "}\n"; + + DOUT << "}\n"; #endif } void Paper_score::preprocess() { - super_elem_l_->breakable_col_processing(); - super_elem_l_->pre_processing(); + super_elem_l_->breakable_col_processing(); + super_elem_l_->pre_processing(); } void Paper_score::postprocess() { - super_elem_l_->post_processing(); - super_elem_l_->molecule_processing(); + super_elem_l_->post_processing(); + super_elem_l_->molecule_processing(); } PCursor Paper_score::find_col (PCol const *c)const { - PCol const *what = c; - if (what->daddy_l_) + PCol const *what = c; + if (what->daddy_l_) what = what->daddy_l_; - - return col_p_list_.find ((PCol*)what); + + return col_p_list_.find ((PCol*)what); } void Paper_score::set_breaking (Array const &breaking) { - super_elem_l_->line_of_score_l_->set_breaking (breaking); - super_elem_l_->break_processing(); + super_elem_l_->line_of_score_l_->set_breaking (breaking); + super_elem_l_->break_processing(); - for (iter (span_p_list_.top(),i); i.ok ();) { + for (iter (span_p_list_.top(),i); i.ok ();) + { Spanner *span_p = i.remove_p(); - if (span_p->broken_b()) { + if (span_p->broken_b()) + { span_p->unlink(); delete span_p; - }else{ + }else + { typeset_broken_spanner (span_p); - } + } } - for (iter (elem_p_list_.top(),i); i.ok () ;) { + for (iter (elem_p_list_.top(),i); i.ok () ;) + { Item *i_l =i->item(); - if ( i_l && !i_l->pcol_l_->line_l_) { + if ( i_l && !i_l->pcol_l_->line_l_) + { i_l->unlink(); delete i.remove_p(); - } else + } + else i++; } - for (iter_top (col_p_list_, i); i.ok(); i++) + for (iter_top (col_p_list_, i); i.ok(); i++) i->clean_breakable_items(); } void Paper_score::calc_breaking() { - Break_algorithm *algorithm_p; - Array sol; - bool try_wrap = ! paper_l_->get_var ("castingalgorithm"); + Break_algorithm *algorithm_p; + Array sol; + bool try_wrap = ! paper_l_->get_var ("castingalgorithm"); - if (!try_wrap) { + if (!try_wrap) + { algorithm_p = new Gourlay_breaking ; algorithm_p->set_pscore (this); sol = algorithm_p->solve(); delete algorithm_p; - if ( ! sol.size()) { + if ( ! sol.size()) + { warning ("Can not solve this casting problem exactly; revert to Word_wrap"); try_wrap = true; - } + } } - if (try_wrap) { + if (try_wrap) + { algorithm_p = new Word_wrap; algorithm_p->set_pscore (this); sol = algorithm_p->solve(); delete algorithm_p; } - set_breaking (sol); + set_breaking (sol); } void Paper_score::process() { - clean_cols(); - print(); - *mlog << "Preprocessing elements... " < i (elem_p_list_.top()); i.ok (); i++) + for (PCursor i (elem_p_list_.top()); i.ok (); i++) assert (i->status() >= 9); #endif } @@ -250,56 +265,58 @@ Paper_score::process() Link_array Paper_score::breakable_col_range (PCol*l,PCol*r)const { - Link_array ret; + Link_array ret; - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) { + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) + { if (start->breakable_b()) ret.push (start); start++; } - return ret; + return ret; } Link_array Paper_score::col_range (PCol*l,PCol*r)const { - Link_array ret; - - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - ret.push (l); - - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) + Link_array ret; + + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + ret.push (l); + + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) ret.push (start++); - ret.push (r); - return ret; + ret.push (r); + return ret; } Link_array Paper_score::broken_col_range (PCol*l,PCol*r)const { - Link_array ret; + Link_array ret; - PCursor start (l ? find_col (l)+1 : col_p_list_.top()); - PCursor stop (r ? find_col (r) : col_p_list_.bottom()); + PCursor start (l ? find_col (l)+1 : col_p_list_.top()); + PCursor stop (r ? find_col (r) : col_p_list_.bottom()); - /* - ugh! windows-suck-suck-suck. - */ - while ( PCursor::compare (start,stop) < 0) { + /* + ugh! windows-suck-suck-suck. + */ + while ( PCursor::compare (start,stop) < 0) + { if (start->breakable_b() && !start->line_l_) ret.push (start); start++; } - return ret; + return ret; } diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 78f053d20e..8950d98723 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -23,122 +23,152 @@ Paper_def::set_var (String s, Real r) { real_vars_p_->elem (s) = r; } - + Real Paper_def::get_var (String s)const { - if (! real_vars_p_->elt_b (s)) - error ( "unknown paper variable `" + s+"'"); - return real_vars_p_->elem (s); + if (! real_vars_p_->elt_b (s)) + error ( "unknown paper variable `" + s+"'"); + return real_vars_p_->elem (s); } Real Paper_def::linewidth_f() const { - return get_var ("linewidth"); + return get_var ("linewidth"); +} + +Real +Paper_def::duration_to_dist (Moment d,Real k)const +{ + if (get_var("geometric")) + return geometric_spacing(d); + return arithmetic_spacing(d,k); } + +/** + Get the measure wide constant for arithmetic. + + @see + John S. Gourlay. ``Spacing a Line of Music,'' Technical Report + OSU-CISRC-10/87-TR35, Department of Computer and Information Science, + The Ohio State University, 1987. + + */ Real -Paper_def::duration_to_dist (Moment d) +Paper_def::arithmetic_constant(Moment d) const { - Real dur_f = (d) ?pow (get_var ("geometric"), log_2(d)) : 0; - return get_var ("basicspace") + get_var ("unitspace") * dur_f; + return get_var("arithmetic_basicspace") - log_2(Moment(1,8) ; + itrans_p_ = 0; + lookup_p_ = 0; + real_vars_p_ = new Assoc; } Paper_def::~Paper_def() { - delete itrans_p_; - delete real_vars_p_; - delete lookup_p_; + delete itrans_p_; + delete real_vars_p_; + delete lookup_p_; } Paper_def::Paper_def (Paper_def const&s) { - itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_):0; - lookup_p_ = s.lookup_p_? new Lookup (*s.lookup_p_) : 0; - lookup_p_->paper_l_ = this; - real_vars_p_ = new Assoc (*s.real_vars_p_); - outfile_str_ = s.outfile_str_; + itrans_p_ = s.itrans_p_ ? new Input_translator (*s.itrans_p_):0; + lookup_p_ = s.lookup_p_? new Lookup (*s.lookup_p_) : 0; + lookup_p_->paper_l_ = this; + real_vars_p_ = new Assoc (*s.real_vars_p_); + outfile_str_ = s.outfile_str_; } void Paper_def::set (Input_translator * itrans_p) { - delete itrans_p_; - itrans_p_ = itrans_p; + delete itrans_p_; + itrans_p_ = itrans_p; } void Paper_def::set (Lookup*l) { - assert (l != lookup_p_); - delete lookup_p_; - lookup_p_ = l; - lookup_p_->paper_l_ = this; + assert (l != lookup_p_); + delete lookup_p_; + lookup_p_ = l; + lookup_p_->paper_l_ = this; } Real Paper_def::interline_f() const { - return get_var ("interline"); + return get_var ("interline"); } Real Paper_def::rule_thickness()const { - return get_var ("rule_thickness"); + return get_var ("rule_thickness"); } Real Paper_def::interbeam_f() const { - return get_var ("interbeam"); + return get_var ("interbeam"); } Real Paper_def::internote_f() const { - return interline_f() / 2; + return interline_f() / 2; } Real Paper_def::note_width()const { - return get_var ("notewidth"); + return get_var ("notewidth"); } void Paper_def::print() const { #ifndef NPRINT - DOUT << "Paper {"; - DOUT << "out: " <print(); - itrans_p_->print(); - for (Assoc_iter i (*real_vars_p_); i.ok(); i++) { + DOUT << "Paper {"; + DOUT << "out: " <print(); + itrans_p_->print(); + for (Assoc_iter i (*real_vars_p_); i.ok(); i++) + { DOUT << i.key() << "= " << i.val () << "\n"; } - DOUT << "}\n"; + DOUT << "}\n"; #endif } Lookup const * Paper_def::lookup_l() { - assert (lookup_p_); - return lookup_p_; + assert (lookup_p_); + return lookup_p_; } Global_translator* Paper_def::get_global_translator_p() const { - return itrans_p_->get_group_engraver_p()->global_l (); + return itrans_p_->get_group_engraver_p()->global_l (); } diff --git a/lily/parser.y b/lily/parser.y index 8722ffb133..b72857d0d2 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -1,7 +1,7 @@ %{ // -*-Fundamental-*- /* - parser.y -- lily parser + parser.y -- YACC parser for mudela source file of the GNU LilyPond music typesetter @@ -34,6 +34,8 @@ #include "input-translator.hh" #include "score.hh" #include "music-list.hh" +#include "header.hh" +#include "duration-convert.hh" #ifndef NDEBUG #define YYDEBUG 1 @@ -62,6 +64,7 @@ Music *music; Music_list *musiclist; Score *score; + Header *header; Interval *interval; Lookup*lookup; Melodic_req * melreq; @@ -111,13 +114,14 @@ yylex(YYSTYPE *s, void * v_l) %token CONSISTS %token ACCEPTS %token CM_T -%token DURATIONCOMMAND +%token DURATION %token ABSDYNAMIC %token END %token GROUPING %token GROUP %token REQUESTTRANSLATOR %token HSHIFT +%token HEADER %token IN_T %token ID %token LYRIC @@ -129,7 +133,7 @@ yylex(YYSTYPE *s, void * v_l) %token MM_T %token MULTI %token NOTENAMES -%token OCTAVECOMMAND +%token OCTAVE %token OUTPUT %token PAPER %token PARTIAL @@ -157,6 +161,7 @@ yylex(YYSTYPE *s, void * v_l) %type dots %token INT %token NOTENAME_ID +%token DURATION_IDENTIFIER %token IDENTIFIER %token MELODIC_REQUEST_IDENTIFIER %token MUSIC_IDENTIFIER @@ -173,11 +178,13 @@ yylex(YYSTYPE *s, void * v_l) %token REQUEST_IDENTIFIER %token REAL %token DURATION RESTNAME -%token STRING +%token STRING +%token FIELDNAME RECORDLINE %token POST_QUOTES %token PRE_QUOTES +%type
mudela_header mudela_header_body %type box %type open_request_parens close_request_parens %type open_plet_parens close_plet_parens @@ -185,7 +192,8 @@ yylex(YYSTYPE *s, void * v_l) %type int %type script_dir %type identifier_init -%type explicit_duration notemode_duration entered_notemode_duration +%type explicit_steno_duration notemode_duration +%type entered_notemode_duration explicit_duration %type dinterval %type intastint_list %type symtables symtables_body @@ -201,7 +209,8 @@ yylex(YYSTYPE *s, void * v_l) %type paper_block paper_body %type dim real %type unit -%type post_request pre_request command_req verbose_command_req abbrev_command_req +%type post_request pre_request command_req verbose_command_req +%type abbrev_command_req %type script_req dynamic_req %type score_block score_body %type