Stem 0
Stem 0
Stem_req 0
-Symtable 0
-Symtables 0
+Symtable 1
+Symtables 1
+
Text_def 0
Text_req 0
Time_description 0
-12/Aug/97 LilyPond 0.1.7 1
+12/Aug/97 LilyPond 0.1.9 1
}
}
***************************
+
+ \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 }
+ > }
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
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<GNU> bison
+B<1.25>. Don't forget to do "make clean" after installing it. Don't
+forget to remove the stale F<bison.simple> as well.
If the problem persists, then please mail me.
-8/Aug/97 LilyPond 0.1.7 1
+8/Aug/97 LilyPond 0.1.9 1
-8/Aug/97 LilyPond 0.1.7 2
+8/Aug/97 LilyPond 0.1.9 2
-8/Aug/97 LilyPond 0.1.7 3
+8/Aug/97 LilyPond 0.1.9 3
-8/Aug/97 LilyPond 0.1.7 4
+8/Aug/97 LilyPond 0.1.9 4
-8/Aug/97 LilyPond 0.1.7 5
+8/Aug/97 LilyPond 0.1.9 5
-8/Aug/97 LilyPond 0.1.7 6
+8/Aug/97 LilyPond 0.1.9 6
+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.
- 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
- 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.
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()
* (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?
- quiet/ignore-version options
- logfile output
+ * piano staff
+
* elaborate Staff_side baseclass:
- scripts
- text
- 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"
- 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
- 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
- specify number of lines
- set linelength per line
+ * Rhythmic staff.
+
SEVERELY LACKING:
* SPEED!
* multibar rests
- * barnumbers, markers
+ * markers
* abbreviations c4=16
* <c f a>4 ?
- * should have \require{package.ly} to read req'd packages.
-
* Viola mode?
@c c g e g
* 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
* 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.
IDEAS
- * derive PCol from Score_elem? More in Score_elems? Spacing?
-
* scoping in Lexer: do general id- assignments in mudela.
ID '=' EXPR;
* 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
* 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
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 =
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);
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);
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
{
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++)
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++)
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 ());
}
: 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<n; j++)
invm (i,j) = inv (j);
}
-
+
#ifdef PARANOID
- Matrix I1(n), I2(original());
- I1.unit();
- assert ((I1-I2*invm).norm()/I2.norm () < EPS);
+ Matrix I1(n), I2(original());
+ I1.unit();
+ assert ((I1-I2*invm).norm()/I2.norm () < EPS);
#endif
-
- return invm;
+
+ return invm;
}
void
Data_file::gobble_white()
{
- char c;
-
- while ((c=data_get()) == ' ' ||c == '\t')
+ char c;
+
+ while ((c=data_get()) == ' ' ||c == '\t')
if (eof())
break;
- data_unget (c);
+ data_unget (c);
}
String
Data_file::get_word()
{// should handle escape seq's
- String s;
+ String s;
- while (1)
+ while (1)
{
char c = data_get();
{
data_unget (c);
break;
- }
+ }
if (c == '\"')
}
else
s += c;
- }
-
- return s;
+ }
+
+ return s;
}
/** get a char
*/
char
Data_file::data_get() {
- char c = get();
- if (!rawmode && c == '#') // gobble comment
+ char c = get();
+ if (!rawmode && c == '#') // gobble comment
{
while ((c = get()) != '\n' && !eof ())
;
return '\n';
- }
+ }
- return c;
+ return c;
}
/// read line, gobble '\n'
String Data_file::get_line()
{
- char c;
- String s;
+ char c;
+ String s;
- while ((c = data_get()) != '\n' && !eof ())
+ while ((c = data_get()) != '\n' && !eof ())
s += c;
- return s;
+ return s;
}
/// gobble stuff before first entry on a line.
void
Data_file::gobble_leading_white()
{
- // eat blank lines.
- while (!eof()) {
+ // eat blank lines.
+ while (!eof())
+ {
char c = data_get();
- if (!isspace (c)) {
+ if (!isspace (c))
+ {
data_unget (c);
break;
- }
+ }
}
}
int
Diagonal_storage::dim()const
{
- return band_.rows();
+ return band_.rows();
}
Diagonal_storage::Diagonal_storage()
int
Diagonal_storage::rows() const
{
- return band_.rows();
+ return band_.rows();
}
int
Diagonal_storage::cols() const
{
- return band_.rows();
+ return band_.rows();
}
int
Diagonal_storage::band_size_i()const
{
- return (band_.cols()-1)/2;
+ return (band_.cols()-1)/2;
}
void
Diagonal_storage::set_band_size (int s)
{
- assert (s>=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;
f.elem (i, k + s) =0.0;
}
- band_ = f;
+ band_ = f;
}
void
Diagonal_storage::insert_row (int)
{
- assert (false);
+ assert (false);
}
void
Diagonal_storage::delete_row (int)
{
- assert (false);
+ assert (false);
}
void
void
Diagonal_storage::delete_column (int)
{
- assert (false);
+ assert (false);
}
-
+
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;
}
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();
}
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();
}
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());
}
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() <? n-1 <? j + band2;
int relk = startk + band_size_i() -i;
sum += band_.elem (i, relk++) * right_diag->elem (k, j);
dest->elem (i, j) = sum;
- }
+ }
}
- return true;
+ return true;
}
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);
Link_array<Directed_graph_node> const &
Directed_graph_node::get_in_edge_arr() const
{
- return edge_in_l_arr_;
+ return edge_in_l_arr_;
}
Link_array<Directed_graph_node> const &
Directed_graph_node::get_out_edge_arr()const
{
- return edge_out_l_arr_;
+ return edge_out_l_arr_;
}
/**
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]);
}
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
}
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);
}
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()
{
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;
default:
*os_l_ << *cp;
break;
- }
- return ;
+ }
+ return ;
}
Dstream::Dstream (ostream *r, char const * cfg_nm)
{
- os_l_ = r;
- silent_assoc_p_ = new Assoc<String,bool>;
- indent_level_i_ = 0;
- if (!os_l_)
+ os_l_ = r;
+ silent_assoc_p_ = new Assoc<String,bool>;
+ 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]));
}
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<String, bool> i (*silent_assoc_p_); i.ok(); i++) {
+ for (Assoc_iter<String, bool> i (*silent_assoc_p_); i.ok(); i++)
+ {
i.val() = 0;
}
}
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;
}
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;
}
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_; i++)
+ resize (fs.height_i_, fs.width_i_);
+ OK();
+ fs.OK();
+ for (int i=0; i<height_i_; i++)
for (int j=0; j<width_i_; j++)
els_p_p_[i][j]= fs.els_p_p_[i][j];
}
{
#ifndef NDEBUG
- 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_);
+ 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
}
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);
}
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_;
}
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 ++;
}
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++;
}
void
Full_storage::delete_column (int k)
{
- assert (0 <= k &&k<width_i_);
- for (int i=0; i< height_i_ ; i++)
+ assert (0 <= k &&k<width_i_);
+ for (int i=0; i< height_i_ ; i++)
for (int j=k+1; j <width_i_; j++)
els_p_p_[i][j-1]=els_p_p_[i][j];
- width_i_--;
+ width_i_--;
}
void
Full_storage::delete_row (int k)
{
- assert (0 <= k &&k<height_i_);
- for (int i=k+1; i < height_i_ ; i++)
+ assert (0 <= k &&k<height_i_);
+ for (int i=k+1; i < height_i_ ; i++)
for (int j=0; j < width_i_; j++)
els_p_p_[i-1][j]=els_p_p_[i][j];
- height_i_--;
+ height_i_--;
}
void
Full_storage::insert_row (int k)
{
- assert (0 <= k&& k <=height_i_);
- resize_cols (height_i_+1);
- for (int i=height_i_-1; i > 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 <width_i_; j++)
els_p_p_[i][j]=els_p_p_[i-1][j];
bool
Full_storage::try_right_multiply (Matrix_storage * dest, Matrix_storage const * right)const
{
- if (dest->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; i<height_i_; i++)
for (int j=0; j<width_i_; j++)
els_p_p_[i][j]=0.0;
- for (int i,j=0; m->mult_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);
}
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];
delete[] els_p_p_[i];
els_p_p_[i] = newa;
}
- width_i_ = max_width_i_ = neww;
+ width_i_ = max_width_i_ = neww;
}
#ifdef INLINE
Cursor<T>::Cursor()
: list_(*(List<T> *)0) // ugh
{
- pointer_ = 0;
+ pointer_ = 0;
}
template<class T>
inline
Cursor<T>::Cursor (const List<T>& list, Link<T>* pointer) :
- list_((List<T>&) list)
+ list_((List<T>&) list)
{
- if ( list.size())
- pointer_ = pointer ? pointer : list.top_;
- else
- pointer_ = pointer;
+ if ( list.size())
+ pointer_ = pointer ? pointer : list.top_;
+ else
+ pointer_ = pointer;
}
template<class T>
inline
Cursor<T>::Cursor (const Cursor<T>& cursor) :
- list_( cursor.list_)
+ list_( cursor.list_)
{
- pointer_ = cursor.pointer_;
+ pointer_ = cursor.pointer_;
}
template<class T>
inline T&
Cursor<T>::thing()
{
- assert (pointer_);
- return pointer_->thing();
+ assert (pointer_);
+ return pointer_->thing();
}
template<class T>
Cursor<T>
Cursor<T>::operator =( const Cursor<T>& c)
{
- assert (&list_ == &c.list_);
- pointer_ = c.pointer_;
- return *this;
+ assert (&list_ == &c.list_);
+ pointer_ = c.pointer_;
+ return *this;
}
template<class T>
inline void
Cursor<T>::add (const T& th)
{
- list_.add (th, *this);
+ list_.add (th, *this);
}
template<class T>
inline void
Cursor<T>::insert (const T& th)
{
- list_.insert (th, *this);
+ list_.insert (th, *this);
}
template<class T>
inline List<T>&
Cursor<T>::list() const
{
- return list_;
+ return list_;
}
template<class T>
inline Link<T>*
Cursor<T>::pointer()
{
- return pointer_;
+ return pointer_;
}
template<class T>
inline bool
Cursor<T>::backward()const
{
- return ( pointer_ != 0);
+ return ( pointer_ != 0);
}
template<class T>
inline bool
Cursor<T>::forward()const
{
- return ( pointer_ != 0);
+ return ( pointer_ != 0);
}
template<class T>
inline bool
Cursor<T>::ok()const
{
- return ( pointer_ != 0);
+ return ( pointer_ != 0);
}
template<class T>
inline void
Cursor<T>::next()
{
- assert (pointer_);
- pointer_ = pointer_->next();
+ assert (pointer_);
+ pointer_ = pointer_->next();
}
template<class T>
inline Cursor<T>
Cursor<T>::operator ++( int)
{
- Cursor<T> r (*this);
- next();
- return r;
+ Cursor<T> r (*this);
+ next();
+ return r;
}
template<class T>
inline void
Cursor<T>::previous()
{
- assert (pointer_);
- pointer_ = pointer_->previous();
+ assert (pointer_);
+ pointer_ = pointer_->previous();
}
template<class T>
inline Cursor<T>
Cursor<T>::operator --( int)
{
- Cursor<T> r (*this);
- previous();
- return r;
+ Cursor<T> r (*this);
+ previous();
+ return r;
}
void
Cursor<T>::backspace()
{
- Cursor<T> c (*this);
- if ( c.ok())
+ Cursor<T> c (*this);
+ if ( c.ok())
c--;
- list_.remove (*this);
+ list_.remove (*this);
}
template<class T>
void
Cursor<T>::del()
{
- Cursor<T> c (*this);
- if ( c.ok())
+ Cursor<T> c (*this);
+ if ( c.ok())
c++;
- list_.remove (*this);
- *this = c;
+ list_.remove (*this);
+ *this = c;
}
Cursor<T>
Cursor<T>::operator -=( int j)
{
- while (j--)
+ while (j--)
(*this)--;
- return *this;
+ return *this;
}
template<class T>
Cursor<T>
Cursor<T>::operator +=( int j)
{
- while (j++)
+ while (j++)
(*this)++;
- return *this;
+ return *this;
}
template<class T>
Cursor<T>
Cursor<T>::operator +( int i) const
{
- Cursor<T> r = *this;
+ Cursor<T> r = *this;
- if (i<0)
+ if (i<0)
return r -(-i);
- while (i--)
+ while (i--)
r++;
- return r;
+ return r;
}
template<class T>
Cursor<T>
Cursor<T>::operator -( int i) const
{
- Cursor<T> r = *this;
- if (i<0)
+ Cursor<T> r = *this;
+ if (i<0)
return r +(-i);
- while (i--)
+ while (i--)
r--;
-
- return r;
+
+ return r;
}
/*
warning: can't use Cursor::operator == (Cursor),
int
Cursor<T>::operator-(Cursor<T> 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<T> c (*this);
- while (c.ok() && c.pointer_ != rhs.pointer_) {
+ // search from *this on further up (positive difference)
+ Cursor<T> 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
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);
}
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
int
_Interval__compare (const Interval_t<T>&a,Interval_t<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<class T>
bool
Interval_t<T>::contains_b (Interval_t<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<class T>
int
Interval__compare (const Interval_t<T>&a,Interval_t<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<class T>
void
Interval_t<T>::set_empty()
{
- left = (T) infinity();
- right = (T) -infinity();
+ left = (T) infinity();
+ right = (T) -infinity();
}
template<class T>
T
Interval_t<T>::length() const {
- assert (right >= left);
- return right-left;
+ assert (right >= left);
+ return right-left;
}
template<class T>
void
Interval_t<T>::unite (Interval_t<T> h)
{
- if (h.left<left)
+ if (h.left<left)
left = h.left;
- if (h.right>right)
+ if (h.right>right)
right = h.right;
}
Interval_t<T>::intersect (Interval_t<T> h)
{
#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
- left = h.left >? left;
- right = h.right <?right;
+ left = h.left >? left;
+ right = h.right <?right;
#else
- left = max (h.left, left);
- right = min (h.right, right);
+ left = max (h.left, left);
+ right = min (h.right, right);
#endif
}
Interval_t<T>
intersect (Interval_t<T> x, Interval_t<T> const &y)
{
- x.intersect (y);
- return x;
+ x.intersect (y);
+ return x;
}
template<class T>
String
Interval_t<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<class T>
bool
Interval_t<T>::elt_b (T r)
{
- return r >= left && r <= right;
+ return r >= left && r <= right;
}
Link<T>::OK() const
{
#ifndef NDEBUG
- if (previous_) {
+ if (previous_)
+ {
assert (previous_->next_ == this);
}
- if (next_) {
+ if (next_)
+ {
assert (next_->previous_ == this);
}
#endif
template<class T>
inline
Link<T>::Link (const T& thing) :
- thing_( thing)
+ thing_( thing)
{
- previous_ = next_ = 0;
+ previous_ = next_ = 0;
}
template<class T>
inline
Link<T>::Link (Link<T>* previous, Link<T>* next, const T& thing) :
- thing_( thing)
+ thing_( thing)
{
- previous_ = previous;
- next_ = next;
+ previous_ = previous;
+ next_ = next;
}
template<class T>
Link<T>*
Link<T>::next()
{
- return next_;
+ return next_;
}
template<class T>
Link<T>*
Link<T>::previous()
{
- return previous_;
+ return previous_;
}
template<class T>
void
Link<T>::add (const T& thing)
{
-
- Link<T>* l = new Link<T>( this, next_, thing);
- if ( next_)
- next_->previous_ = l;
- next_ = l;
+
+ Link<T>* l = new Link<T>( this, next_, thing);
+ if ( next_)
+ next_->previous_ = l;
+ next_ = l;
}
template<class T>
inline void
Link<T>::insert (const T& thing)
{
- // Link<T>* l = new Link<T>( next_, this, thing);
+ // Link<T>* l = new Link<T>( next_, this, thing);
// bugfix hwn 16/9/96
- Link<T>* l = new Link<T>( previous_, this, thing);
- if ( previous_)
- previous_->next_ = l;
- previous_ = l;
+ Link<T>* l = new Link<T>( 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<class T>
inline void
Link<T>::remove (List<T> &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_;
}
T&
Link<T>::thing()
{
- return thing_;
+ return thing_;
}
#endif
inline
List<T>::List()
{
- set_empty();
+ set_empty();
}
template<class T>
inline void
List<T>::set_empty()
{
- top_ = bottom_ = 0;
- size_ = 0;
+ top_ = bottom_ = 0;
+ size_ = 0;
}
template<class T>
inline void
List<T>::remove (Cursor<T> me)
{
- if ( me.ok()){
+ if ( me.ok())
+ {
Link<T> *lp = me.pointer();
lp->remove (*this);
delete lp;
- size_--;
+ size_--;
}
}
inline int
List<T>::size() const
{
- return size_;
+ return size_;
}
template<class T>
inline Cursor<T>
List<T>::top()const
{
- return Cursor<T>( *this, top_);
+ return Cursor<T>( *this, top_);
}
inline Cursor<T>
List<T>::bottom()const
{
- return Cursor<T>( *this, bottom_);
+ return Cursor<T>( *this, bottom_);
}
template<class T>
List<T>::List (List const&src)
{
- set_empty();
- // probably el stupido
- for (Cursor<T> c (src); c.ok(); c++)
+ set_empty();
+ // probably el stupido
+ for (Cursor<T> c (src); c.ok(); c++)
bottom().add (c);
}
void
List<T>::OK() const
{
- int i = size_;
- Link<T> *lp = top_;
- while (i--) {
+ int i = size_;
+ Link<T> *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<class T>
void
List<T>::junk_links()
{
- Cursor<T> c (*this);
- while (c.ok())
+ Cursor<T> c (*this);
+ while (c.ok())
c.del();
}
template<class T>
List<T>::~List()
{
- junk_links();
+ junk_links();
}
/**
void
List<T>::add (T const & thing, Cursor<T> &after_me)
{
- if (!size_) { // not much choice if list is empty
- bottom_ = top_ = new Link<T>( thing);
+ if (!size_) { // not much choice if list is empty
+ bottom_ = top_ = new Link<T>( 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<T> *p =after_me.pointer();
bottom_ = p->next();
}
- size_++;
+ size_++;
}
template<class T>
void
List<T>::insert (T const & thing, Cursor<T> &before_me)
{
- if (!size_) {
+ if (!size_)
+ {
bottom_ = top_ = new Link<T>( thing);
if (!before_me.ok())
before_me = top();
- } else {
+ }
+ else
+ {
if (!before_me.ok())
before_me = top();
top_ = p->previous();
}
- size_++;
+ size_++;
}
void
List<T>::concatenate (List<T> const&s)
{
- Cursor<T> b (bottom());
- for (Cursor<T> c (s); c.ok(); c++) {
+ Cursor<T> b (bottom());
+ for (Cursor<T> c (s); c.ok(); c++)
+ {
b.add (c);
b++;
}
PCursor<T>::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
}
void
PL_copy (Pointer_list<T*> &to, Pointer_list<T*> const&src)
{
- for (PCursor<T*> pc (src); pc.ok(); pc++) {
+ for (PCursor<T*> pc (src); pc.ok(); pc++)
+ {
T *q = pc;
T *p=new T(*q) ;
to.bottom().add (p);
void
Pointer_list<T>::junk()
{
- PCursor<T> c (*this);
- while (c.ok()) {
+ PCursor<T> c (*this);
+ while (c.ok())
+ {
delete c.remove_p();
}
}
PCursor<T>
Link_list<T>::find (T what) const
{
- PCursor<T> i (*this);
- for (; i.ok(); i++)
+ PCursor<T> i (*this);
+ for (; i.ok(); i++)
if (i.ptr() == what)
break;
- return i;
+ return i;
}
T *
P<T>::copy_p()const
{
- return t_p? new T(*t_p) : 0;
+ return t_p? new T(*t_p) : 0;
}
template<class T>
void
P<T>::copy (T const *l_C)
{
- t_p = l_C ? new T(*l_C) : 0;
+ t_p = l_C ? new T(*l_C) : 0;
}
template<class T>
void
P<T>::junk()
{
- delete t_p;
- t_p =0;
+ delete t_p;
+ t_p =0;
}
template<class T>
inline
P<T>::P(P<T> const &s)
{
- t_p = s.copy_p();
+ t_p = s.copy_p();
}
template<class T>
P<T> &
P<T>::operator =(P const&s)
{
- junk();
- copy (s.t_p);
- return *this;
+ junk();
+ copy (s.t_p);
+ return *this;
}
template<class T>
inline
P<T>::~P() {
- junk();
+ junk();
}
template<class T>
void
P<T>::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;
}
void
P<T>::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);
}
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;
}
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 <? length_i_) + 1 );
maxlen = j;
INLINE void
String_data::tighten()
{ // should be dec'd const
- maxlen = length_i_;
- Byte *p = new Byte[maxlen + 1];
- memcpy (p, data_byte_p_, length_i_ + 1);
- delete[] data_byte_p_;
- data_byte_p_ = p;
+ maxlen = length_i_;
+ Byte *p = new Byte[maxlen + 1];
+ memcpy (p, data_byte_p_, length_i_ + 1);
+ delete[] data_byte_p_;
+ data_byte_p_ = p;
}
// assignment.
INLINE void
String_data::set (Byte const* byte_C, int length_i)
{
- OKW();
+ OKW();
- assert (byte_C && byte_C != data_byte_p_);
+ assert (byte_C && byte_C != data_byte_p_);
- length_i_ = length_i;
- remax (length_i_); // copies too
- memcpy (data_byte_p_, byte_C, length_i_);
- data_byte_p_[ length_i_ ] = 0;
+ length_i_ = length_i;
+ remax (length_i_); // copies too
+ memcpy (data_byte_p_, byte_C, length_i_);
+ data_byte_p_[ length_i_ ] = 0;
}
INLINE
void
String_data::set (char const* ch_C)
{
- set ((Byte const*)ch_C, strlen (ch_C) );
+ set ((Byte const*)ch_C, strlen (ch_C) );
}
INLINE void
String_data::append (Byte const* byte_C, int length_i)
{
- OK();
- OKW();
- int old_i = length_i_;
-
- length_i_ += length_i;
- remax (length_i_);
- memcpy (data_byte_p_ + old_i, byte_C, length_i);
- data_byte_p_[ length_i_ ] = 0;
+ OK();
+ OKW();
+ int old_i = length_i_;
+
+ length_i_ += length_i;
+ remax (length_i_);
+ memcpy (data_byte_p_ + old_i, byte_C, length_i);
+ data_byte_p_[ length_i_ ] = 0;
}
INLINE
void
String_data::operator += ( char const* ch_C)
{
- append ((Byte const*)ch_C, strlen (ch_C) );
+ append ((Byte const*)ch_C, strlen (ch_C) );
}
char const*
String_data::ch_C() const
{
- return (char const*)data_byte_p_;
+ return (char const*)data_byte_p_;
}
INLINE char*
String_data::ch_l()
{
- return (char*)data_byte_p_;
+ return (char*)data_byte_p_;
}
INLINE Byte const*
String_data::byte_C() const
{
- return data_byte_p_;
+ return data_byte_p_;
}
INLINE Byte*
String_data::byte_l()
{
- OKW();
- return data_byte_p_;
+ OKW();
+ return data_byte_p_;
}
INLINE
void
String_data::trunc (int j)
{
- OKW();
- assert (j >= 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];
}
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);
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!
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
Real
Interval_t<Real>::infinity()
{
- return HUGE_VAL;
+ return HUGE_VAL;
}
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 << "'";
}
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"<<endl;
break;
- case E_NOARGEXPECT:
+ case E_NOARGEXPECT:
*error_ostream_l_ << "option `--" <<
found_option_l_->longname << "' does not allow an argument"<<endl;
break;
- case E_UNKNOWNOPTION:
+ case E_UNKNOWNOPTION:
*error_ostream_l_ << "unrecognized option ";
if (argument_index_i_)
*error_ostream_l_ << "-" << arg_value_ch_a_a_[array_index_i_][argument_index_i_] << endl;
*error_ostream_l_ << arg_value_ch_a_a_[array_index_i_] << endl;
break;
- case E_ILLEGALARG:
+ case E_ILLEGALARG:
*error_ostream_l_ << "illegal argument `" << optional_argument_ch_C_ << "\'to option ";
found_option_l_->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;
}
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;
}
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;
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;
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.
}
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;
}
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;
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;
}
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;
}
Vector::print() const
{
#ifndef NDEBUG
- fdebug << *this<<'\n';
+ fdebug << *this<<'\n';
#endif
}
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 ());
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
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 ());
}
Matrix_storage *
Matrix_storage::get_full (int n, int m)
{
- return new Full_storage (n,m);
+ return new Full_storage (n,m);
}
Matrix_storage::try_right_multiply (Matrix_storage *,
const Matrix_storage *)const
{
- return false;
+ return false;
}
Array<Real>
Matrix_storage::row (int n) const
{
- Array<Real> r;
- for (int j = 0; j < cols(); j++)
+ Array<Real> r;
+ for (int j = 0; j < cols(); j++)
r.push (elem (n,j));
- return r;
+ return r;
}
Array<Real>
Matrix_storage::column (int n) const
{
- Array<Real> r;
- for (int i = 0; i < rows(); i++)
+ Array<Real> 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);
}
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;
}
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);
}
}
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);
}
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;
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);
}
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;
}
/*
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);
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);
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);
}
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;
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;
int
Matrix::dim() const
{
- assert (cols() == rows ());
- return rows();
+ assert (cols() == rows ());
+ return rows();
}
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.
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() )
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 "";
}
void
print_rat (Rational const &m)
{
- cout << String (m) << flush;
+ cout << String (m) << flush;
}
-
+
#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;
}
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;
}
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';
}
/**
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);
}
/**
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);
}
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 ];
}
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);
}
/**
*/
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);
}
\f
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();
}
/**
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 <? i2);
- return result ? result : i1-i2;
+ int result= memcmp (p1, p2, i1 <? i2);
+ return result ? result : i1-i2;
}
\f
int
String::index_last_i (char const c) const
{
- if ( !length_i())
+ if ( !length_i())
return -1;
- char const* me = strh_.ch_C();
- char const* p = memrchr (me, length_i(), c);
- if ( p)
+ char const* me = strh_.ch_C();
+ char const* p = memrchr (me, length_i(), c);
+ if ( p)
return p - me;
- return -1;
+ return -1;
}
int
String::index_last_i (char const* string) const // UGK!
{
- assert (false); // broken
- int length = strlen (string); // ugrh
- if ( !length_i() || !length)
+ assert (false); // broken
+ int length = strlen (string); // ugrh
+ if ( !length_i() || !length)
return -1;
-
- int next_i = index_i (string);
- if ( next_i == -1)
+
+ int next_i = index_i (string);
+ if ( next_i == -1)
return -1;
-
- int index_i = 0;
- while (next_i >= 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.
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;
}
/**
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;
}
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;
}
\f
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) ;
}
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);
}
\f
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);
}
void
ctors()
{
- cout << "constructors"<<endl;
-
- String str ("hai");
- String def;
- String fromi (10);
- String fromc ('c');
- String fromf (1.32e-2, "%g");
-
- cout << str << endl;
- cout << def << endl;
- cout << fromi<< endl;
- cout << fromc<< endl;
- cout << fromf<< endl;
+ cout << "constructors"<<endl;
+
+ String str ("hai");
+ String def;
+ String fromi (10);
+ String fromc ('c');
+ String fromf (1.32e-2, "%g");
+
+ cout << str << endl;
+ cout << def << endl;
+ cout << fromi<< endl;
+ cout << fromc<< endl;
+ cout << fromf<< endl;
}
void
cmp()
{
- Array<String> a;
- a.push ("abcd");
- a.push ("zxy");
- a.push ("abc");
- a.push ("");
- a.sort (String::compare_i);
- cout << "compares: "<<endl;
- for (int i=0; i < a.size(); i++)
+ Array<String> a;
+ a.push ("abcd");
+ a.push ("zxy");
+ a.push ("abc");
+ a.push ("");
+ a.sort (String::compare_i);
+ cout << "compares: "<<endl;
+ for (int i=0; i < a.size(); i++)
cout << a[i] << endl;
}
void
searching()
{
- String hay = "foobarbazblub";
-
- char c = 'b';
- String cstr =c;
- String set = "bar";
- cout << "hay = \"" << hay << "\" len="<< hay.length_i()<<endl;
- cout << "index_i ('"<< c<<"') " << c << "= " << hay.index_i (c) <<endl;
- cout << "last_index_i ('"<< c<<"') " << c << "= " << hay.index_last_i (c) <<endl;
+ String hay = "foobarbazblub";
+
+ char c = 'b';
+ String cstr =c;
+ String set = "bar";
+ cout << "hay = \"" << hay << "\" len="<< hay.length_i()<<endl;
+ cout << "index_i ('"<< c<<"') " << c << "= " << hay.index_i (c) <<endl;
+ cout << "last_index_i ('"<< c<<"') " << c << "= " << hay.index_last_i (c) <<endl;
// cout << "last index of cstr " << c << ": " << hay.index_last_i (cstr) <<endl;
// cout << "index_last_i (\""<<set<<"\"): " << hay.index_last_i (set) <<endl;
- cout << "index_i (\""<<set<<"\"): " << hay.index_i (set) <<endl;
- cout << "index_any (\"" << set << "\"): " << cstr << ": " << hay.index_any_i (cstr) <<endl;
+ cout << "index_i (\""<<set<<"\"): " << hay.index_i (set) <<endl;
+ cout << "index_any (\"" << set << "\"): " << cstr << ": " << hay.index_any_i (cstr) <<endl;
-
-
+
+
}
void
kutenpeer()
{
- String str ("hai");
- for (int i=-1; i < str.length_i()+2; i++) {
+ String str ("hai");
+ for (int i=-1; i < str.length_i()+2; i++)
+ {
cout<<" left_str (" << i<<"): " << str.left_str (i) << endl;
cout<<" right_str ("<<i<<"): " << str.right_str (i) << endl;
}
- str = "blonde haren";
- cout << str<<endl;
- cout << "mid (2,6)="<<str.mid_str (2,3)<<endl;
- cout << "nomid (2,6)="<<str.nomid_str (2,3)<<endl;
+ str = "blonde haren";
+ cout << str<<endl;
+ cout << "mid (2,6)="<<str.mid_str (2,3)<<endl;
+ cout << "nomid (2,6)="<<str.nomid_str (2,3)<<endl;
}
int
main()
{
- ctors();
- cmp();
- searching();
- kutenpeer();
- String str ("hai");
- cout << str << endl;
- cout << "left" << endl;
- str += " daar";
- cout << str << endl;
-
- str = String ("Hallo") + " daaR" + '!';
- cout << str << endl;
-
- cout << "up: " << str.upper_str() << " down: " << str.lower_str ()<<endl;
-
- if ( str == String ("") )
- cout << str << " is empty" << endl;
- else
+ ctors();
+ cmp();
+ searching();
+ kutenpeer();
+ String str ("hai");
+ cout << str << endl;
+ cout << "left" << endl;
+ str += " daar";
+ cout << str << endl;
+
+ str = String ("Hallo") + " daaR" + '!';
+ cout << str << endl;
+
+ cout << "up: " << str.upper_str() << " down: " << str.lower_str ()<<endl;
+
+ if ( str == String ("") )
+ cout << str << " is empty" << endl;
+ else
cout << str << " is not empty"<<endl;
-
- String fn = "";
- if ( fn == "")
- cout << fn << " is empty" << endl;
- else
+
+ String fn = "";
+ if ( fn == "")
+ cout << fn << " is empty" << endl;
+ else
assert (false);
-
- fn = "";
- fn += "";
- delete fn.copy_byte_p();
- delete str.copy_byte_p();
+
+ fn = "";
+ fn += "";
+ delete fn.copy_byte_p();
+ delete str.copy_byte_p();
- cout << String_convert::bin2hex_str (String ((char)0xff) ) << endl;
+ cout << String_convert::bin2hex_str (String ((char)0xff) ) << endl;
}
#endif STRING_TEST
bool
Text_db::eof()
{
- Data_file::gobble_leading_white();
- return Data_file::eof();
+ Data_file::gobble_leading_white();
+ return Data_file::eof();
}
void
Text_db::gobble_leading_white()
{
- while (1) {
+ while (1)
+ {
Data_file::gobble_leading_white();
if (eof())
return ;
char c;
- if ((c = data_get()) !='\n'){
+ if ((c = data_get()) !='\n')
+ {
data_unget (c);
return ;
}
- }
+ }
}
Text_record
Text_db::get_record()
{
- while (1) {
+ while (1)
+ {
String s;
Array<String> fields;
assert (!eof());
{
fields.push (s);
gobble_white();
- }
+ }
if (get_line() != "")
assert (false);
-
+
assert (fields.size());
return Text_record (fields, get_name(), line ());
}
Text_stream::Text_stream (String fn)
{
- ios::sync_with_stdio();
- if (fn == "")
+ ios::sync_with_stdio();
+ if (fn == "")
{
name = "<STDIN>";
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;
}
void
Text_stream::message (String s)
{
- cerr << "\n"<<get_name() << ": " << line ()<<": "<<s<<endl;
+ cerr << "\n"<<get_name() << ": " << line ()<<": "<<s<<endl;
}
#include "unionfind.hh"
/*
- see a book on data structures
- */
+ see a book on data structures
+ */
Union_find::Union_find (int n)
{
- classes.set_size (n);
+ classes.set_size (n);
- for (int i=0; i < n; i++) {
+ for (int i=0; i < n; i++)
+ {
classes[i] = i;
}
}
int
Union_find::find (int i)
{
- int rep = i;
- while (classes[rep] != rep)
+ int rep = i;
+ while (classes[rep] != rep)
rep = classes[rep];
- while (classes[i] != rep) {
+ while (classes[i] != rep)
+ {
int next =classes[i];
classes[i] = rep;
i = next;
}
- return rep;
+ return rep;
}
void
Union_find::connect (int i, int j)
{
- i = find (i);
- j = find (j);
- classes[i] = j;
+ i = find (i);
+ j = find (j);
+ classes[i] = j;
}
#include "vector.hh"
Vector::Vector (Array<Real> 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;
}
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 }
\version "0.1.1";
+breve = \duration { -1 0 }
+longa = \duration { -2 0 }
+
\include "dynamic.ly"
\include "dutch.ly"
+
+
\include "script.ly"
\include "paper16.ly"
}
"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 {
}
"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 {
-%{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";
\score {
\melodic { \cad }
\paper {
-
- unitspace= 16.0\mm;
- geometric= 1.4;
}
\midi { \tempo 4 = 90; }
}
+\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
/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{
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 |
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 |
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 |
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 "|.";
}
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 |
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 |
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 |
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 "|.";
}
G1 |
\meter 3/2;
g1. | c |
+ % 30
f | d^"\sharp" |
g | c |
A | d^"\sharp" |
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 "|.";
}
\bc
>
\paper{
- linewidth=18.\cm;
- gourlay_maxmeasures=5.;
+ %linewidth=18.\cm;
+ \output "gallina.out";
+ gourlay_maxmeasures=7.;
}
+ \midi{
+ \tempo 4=90;
+}
}
--- /dev/null
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% 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}
-%{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";
-%{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";
>
\paper{
- unitspace =2.0\cm;
- geometric =1.6;
}
}
+++ /dev/null
-
-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;
- }
-}
-%{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
%}
\score{
\melodic {\blah}
\paper{
- unitspace= 1.5 \cm;
- geometric= 1.4;
}
}
-%{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";
\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{
-%{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
>
>
\paper{
- linewidth= 195.\mm;
+ linewidth= 150.\mm;
+ gourlay_maxmeasures = 8.;
% on two pages...
unitspace= 9.\mm;
- geometric= 1.2;
\output "standchen.out";
}
\midi{
-%{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
%}
-%{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";
< \melodic < \id "Piano" ""; \melodie >
\lyric < \id "Lyric" ""; \texte >
>
- \paper { unitspace= 2.5\cm; }
+ \paper { }
}
-%{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";
>
\paper{
- unitspace= 2.5\cm;
}
\midi{
\tempo 4 = 120 ;
+\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.
%}
>
\paper{
- gourlay_maxmeasures =4.;
+ gourlay_maxmeasures =5.;
}
\midi {
{
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_ )
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 )
{
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 );
}
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 );
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 ];
}
// huh?
#if 0
- dur.type_i_ = 0;
+ dur.durlog_i_ = -100;
dur.dots_i_ = 0;
dur.set_ticks( ticks_i );
return dur;
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 );
}
16. 0.0938
8 0.1250
16.. 0.1406
- 4:2/3 0.1667
+ 4:2/3 0.1667
8. 0.1875
*/
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() )
&& ( 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();
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 ) ) );
}
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?
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;
-}
-
{
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 );
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
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);
cout << "]"<<flush;
yy_delete_buffer(yy_current_buffer );
yy_current_buffer = 0;
- if (state_stack_.empty()) {
+ if (state_stack_.empty())
+ {
return false;
- }else {
+ }else
+ {
yy_switch_to_buffer(state_stack_.pop());
return true;
- }
+ }
}
char const*
Includable_lexer::~Includable_lexer()
{
- while (!include_stack_.empty()) {
+ while (!include_stack_.empty())
+ {
close_input();
};
}
-
/*
duration-convert.hh -- declare
/// Return number of ticks in (ticks, division_1) representation
static int dur2ticks_i( Duration dur );
+ /// Return the type_i representation of note length i
+ static int i2_type(int i);
+
+ /// Return the note length corresponding to the type_i representation
+ /// Return 0 if longer than whole note.
+ static int type2_i(int type);
+
/// Return Moment representation (fraction of whole note).
static Moment dur2_mom( Duration dur );
#include "fproto.hh"
#include "moment.hh"
-
+#include "plet.hh"
// ugh, to get me in lily lib
extern bool no_triplets_bo_g;
-/**
- 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_;
-};
/**
Class to handle "musical" durations. This means: balltype 1,2,4,etc. and dots.
(dur)
*/
struct Duration {
- /**
- Ctor of Duration. type_i should be a power of 2.
- */
- Duration();
- Duration( int type_i, int dots_i = 0 );
- /// is the "plet factor" of this note != 1 ?
- bool plet_b();
- String str()const;
- void set_plet(int,int );
- void set_plet(Duration );
- static bool duration_type_b(int t);
- void set_ticks( int ticks_i );
- Moment length() const ; // zo naai mij
- static int division_1_i_s;
- int type_i_;
- int dots_i_;
- Plet plet_;
- int ticks_i_;
+ /**
+ Ctor of Duration.
+ */
+ Duration();
+ Duration( int type_i, int dots_i = 0 );
+ /// is the "plet factor" of this note != 1 ?
+ bool plet_b();
+ String str()const;
+ void set_plet(int,int );
+ void set_plet(Duration );
+ static bool duration_type_b(int t);
+ void set_ticks( int ticks_i );
+ Moment length() const ; // zo naai mij
+ static int division_1_i_s;
+
+ /// Logarithm of the base duration.
+ int durlog_i_;
+ int dots_i_;
+ Plet plet_;
+ int ticks_i_;
};
#endif // DURATION_HH
--- /dev/null
+/*
+ plet.hh -- declare Plet
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#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
{
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;
}
--- /dev/null
+/*
+ plet.cc -- implement Plet
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#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;
+}
+
{
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);
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_;
}
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 );
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);
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
Atom::print() const
{
#ifndef NPRINT
- DOUT << "texstring: " <<sym_.tex<<"\n";
+ DOUT << "texstring: " <<sym_.tex<<"\n";
#endif
}
Box
Atom::extent() const
{
- Box b (sym_.dim);
- b.translate (off_);
- return b;
+ Box b (sym_.dim);
+ b.translate (off_);
+ return b;
}
Atom::Atom (Symbol s)
{
- sym_=s;
+ sym_=s;
}
String
Atom::TeX_string() const
{
- /* infinity checks. */
- assert (abs (off_.x()) < 100 CM);
- assert (abs (off_.y()) < 100 CM);
-
- // whugh.. Hard coded...
- String s ("\\placebox{%}{%}{%}");
- Array<String> 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<String> a;
+ a.push (print_dimen (off_.y()));
+ a.push (print_dimen (off_.x()));
+ a.push (sym_.tex);
+ return substitute_args (s, a);
}
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
}
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)
Midi_item*
Audio_key::midi_item_p()
{
- return new Midi_key (this);
+ return new Midi_key (this);
}
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)
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)
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;
}
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<Audio_staff*> 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<Audio_staff*> 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<Audio_column*> i (audio_column_p_list_); i.ok(); i++ )
+ DOUT << "Audio_score { ";
+ score_l_->midi_p_->print();
+ DOUT << "\ncolumns: ";
+ for ( PCursor<Audio_column*> i (audio_column_p_list_); i.ok(); i++ )
i->print();
- DOUT << "}\n";
+ DOUT << "}\n";
#endif
}
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);
void
Axis_group_item::OK() const
{
- Link_array<Score_elem> elems = axis_admin_.elem_l_arr_;
- for (int i=0; i < elems.size(); i++) {
+ Link_array<Score_elem> elems = axis_admin_.elem_l_arr_;
+ for (int i=0; i < elems.size(); i++)
+ {
Item * it_l = elems[i]->item();
assert (it_l);
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<Score_elem> elems = axis_admin_.elem_l_arr_;
- for (int i=0; i < elems.size(); i++) {
+ Link_array<Score_elem> 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();
}
void
Axis_group_spanner::do_break_processing_if_unbroken()
{
- Link_array<Score_elem> 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<Score_elem> 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<Score_elem> loose_elems = axis_admin_.elem_l_arr_;
- remove_all();
-
- for (int i=0; i < loose_elems.size(); i++) {
+ break_into_pieces (true);
+ Link_array<Score_elem> 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];
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)
= (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();
}
/** 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);
}
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();
}
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
}
String
axis_name_str (Axis a)
{
- return String (a + 'x');
+ return String (a + 'x');
}
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();
}
}
void
Bar_column_engraver::do_pre_move_processing()
{
- if (barcol_p_) {
+ if (barcol_p_)
+ {
typeset_element (barcol_p_);
barcol_p_ =0;
}
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);
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;
}
}
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);
}
void
Bar_engraver::do_pre_move_processing()
{
- if (bar_p_) {
+ if (bar_p_)
+ {
typeset_element (bar_p_);
bar_p_ =0;
}
void
Bar_engraver::do_post_move_processing()
{
- bar_req_l_ = 0;
- bar_p_ =0;
+ bar_req_l_ = 0;
+ bar_p_ =0;
}
Bar_number_grav::Bar_number_grav()
{
- number_i_ =1;
- script_p_ =0;
+ number_i_ =1;
+ script_p_ =0;
}
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;
void
Bar_number_grav::do_pre_move_processing()
{
- if ( script_p_) {
+ if ( script_p_)
+ {
typeset_element (script_p_);
script_p_ =0;
}
Bar::Bar()
{
- breakable_b_ = true;
- type_str_ = "|";
- spanned_i_ = 0;
+ breakable_b_ = true;
+ type_str_ = "|";
+ spanned_i_ = 0;
}
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;
}
/**
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_ == "");
-
- */
+ */
}
-
+
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_);
}
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 <stems.size(); i++) {
+ for (int i=0; i <stems.size(); i++)
+ {
Stem *sl = stems[i];
int cur_down = sl->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 <stems.size(); i++) {
+ for (int i=0; i <stems.size(); i++)
+ {
Stem *sl = stems[i];
sl->dir_i_ = dir_i_;
}
void
Beam::solve_slope()
{
- Array<Stem_info> sinfo;
- for (int j=0; j <stems.size(); j++) {
+ Array<Stem_info> sinfo;
+ for (int j=0; j <stems.size(); j++)
+ {
Stem *i = stems[j];
i->set_default_extents();
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 <stems.size(); j++) {
+ Real x0 = stems[0]->hpos_f();
+ for (int j=0; j <stems.size(); j++)
+ {
Stem *s = stems[j];
Real x = s->hpos_f()-x0;
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<int> b;
- {
+ Array<int> b;
+ {
Array<int> flags;
- for (int j=0; j <stems.size(); j++) {
+ for (int j=0; j <stems.size(); j++)
+ {
Stem *s = stems[j];
int f = intlog2(abs (s->flag_i_))-2;
assert (f>0);
flags.push (f);
- }
+ }
int fi =0;
b= cur.generate_beams (flags, fi);
b.insert (0,0);
assert (stems.size() == b.size ()/2);
}
- for (int j=0, i=0; i < b.size() && j <stems.size (); i+= 2, j++) {
+ for (int j=0, i=0; i < b.size() && j <stems.size (); i+= 2, j++)
+ {
Stem *s = stems[j];
s->beams_left_i_ = b[i];
s->beams_right_i_ = b[i+1];
void
Beam::do_pre_processing()
{
- if (!dir_i_)
+ if (!dir_i_)
set_default_dir();
}
Interval
Beam::do_width() const
{
- return Interval (stems[0]->hpos_f(),
+ return Interval (stems[0]->hpos_f(),
stems.top()->hpos_f ());
}
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_ <? prev->beams_right_i_ ;
Real w = (here->hpos_f() - prev->hpos_f ())/4;
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_ <? next->beams_left_i_;
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;
}
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 <stems.size(); j++) {
+ Real inter_f = paper()->internote_f ();
+ Real x0 = stems[0]->hpos_f();
+ for (int j=0; j <stems.size(); j++)
+ {
Stem *i = stems[j];
Stem * prev = (j > 0)? stems[j-1] : 0;
Stem * next = (j < stems.size()-1) ? stems[j+1] :0;
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;
}
Beam::do_print()const
{
#ifndef NPRINT
- DOUT << "slope " <<slope << "left ypos " << left_pos;
- Spanner::do_print();
+ DOUT << "slope " <<slope << "left ypos " << left_pos;
+ Spanner::do_print();
#endif
}
void
Beam::do_substitute_dependent (Score_elem*o,Score_elem*n)
{
- if (o->is_type_b (Stem::static_name())) {
+ if (o->is_type_b (Stem::static_name()))
+ {
stems.substitute ((Stem*)o->item(), n?(Stem*) n->item ():0);
}
}
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;
}
Box::Box (Interval ix, Interval iy)
{
- x() = ix;
- y() = iy;
+ x() = ix;
+ y() = iy;
}
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);
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;
}
/* **************************************************************** */
Line_of_cols
Break_algorithm::all_cols()const
{
- Line_of_cols retval;
- for (PCursor<PCol*> c (pscore_l_->col_p_list_.top());
- c.ok(); c++) {
+ Line_of_cols retval;
+ for (PCursor<PCol*> c (pscore_l_->col_p_list_.top());
+ c.ok(); c++)
+ {
retval.push (c);
}
- return retval;
+ return retval;
}
Array<int>
Break_algorithm::find_break_indices() const
{
- Line_of_cols all (all_cols());
- Array<int> retval;
-
- for (int i=0; i < all.size(); i++)
+ Line_of_cols all (all_cols());
+ Array<int> 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;
}
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<PCol *> end (pscore_l_->col_p_list_.bottom());
-
- assert (start->breakable_b());
- assert (end->breakable_b());
+ iter_top (pscore_l_->col_p_list_,start);
+ PCursor<PCol *> end (pscore_l_->col_p_list_.bottom());
+
+ assert (start->breakable_b());
+ assert (end->breakable_b());
#endif
}
Array<Col_hpositions>
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";
}
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;
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;
}
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;
}
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);
}
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;
}
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;
}
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()
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
}
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);
}
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;
}
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.
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
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<Note_column*> 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<Note_column*> 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<int> 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<int> 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<int> 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<int> middle (y_extent[idx (-1,0)].max(),
y_extent[idx (1,0)].min());
- Interval_t<int> open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1);
- do{
+ Interval_t<int> 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);
- }
+ }
}
}
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));
}
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;
}
/* *************** */
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_;
}
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_;
}
bool
Barcheck_req::do_equal_b (Request*)const
{
- return true;
+ return true;
}
/* *************** */
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;
}
/* *************** */
Group_feature_req::do_print() const
{
#ifndef NPRINT
- DOUT << type_str_ << "=" << value_str_;
+ DOUT << type_str_ << "=" << value_str_;
#endif
}
void
Partial_measure_req::do_print() const
{
- DOUT << duration_;
+ DOUT << duration_;
}
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() << " = " <<metronome_i_ ;
+ DOUT << dur_.str() << " = " <<metronome_i_ ;
}
IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
bool
Tempo_req::do_equal_b (Request *r)const
{
- Tempo_req *t = r->command()->timing ()->tempo ();
-
- return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
+ Tempo_req *t = r->command()->timing ()->tempo ();
+
+ return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
}
/* *************** */
void
Measure_grouping_req::do_print() const
{
- for (int i=0; i < elt_length_arr_.size(); i++) {
+ for (int i=0; i < elt_length_arr_.size(); i++)
+ {
DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
}
}
bool
Measure_grouping_req::do_equal_b (Request*)const
{
- return false; // todo
+ return false; // todo
}
/* *************** */
void
Key_change_req::transpose (Melodic_req const & d)const
{
- WARN << "don't know how to transpose a key. \n";
- for (int i=0; i < melodic_p_arr_.size(); i++) {
+ WARN << "don't know how to transpose a key. \n";
+ for (int i=0; i < melodic_p_arr_.size(); i++)
+ {
melodic_p_arr_[i]->transpose (d);
}
}
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;
}
}
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
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;
}
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;
}
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
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;
}
// ugh
struct _Dinit {
- _Dinit() {
+ _Dinit()
+ {
nulldev = new ofstream ("/dev/null");
monitor = new Dstream (&cout,".dstreamrc");
}
- ~_Dinit() {
+ ~_Dinit()
+ {
delete nulldev;
delete monitor;
}
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
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;
void
set_debug (bool b)
{
- check_debug =b;
- set_flower_debug (*monitor, check_debug);
+ check_debug =b;
+ set_flower_debug (*monitor, check_debug);
}
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;
}
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;
}
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 (
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;
void
Dynamic_engraver::set_feature (Feature i)
{
- if (i.type_ == "vdir")
+ if (i.type_ == "vdir")
dir_i_ = i.value_;
}
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_);
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);
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<Score_elem>
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();
}
// ****************
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);
}
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);
}
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]);
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<Engraver*> i (grav_list_.top());
- // why the while construct?
- while (i.ok()) {
+ PCursor<Engraver*> 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);
void
Engraver_group_engraver::sync_features()
{
- PCursor<Engraver*> i (grav_list_.top());
- while (i.ok()) {
+ PCursor<Engraver*> i (grav_list_.top());
+ while (i.ok())
+ {
Engraver *grav_l = i++;
grav_l->sync_features();
}
void
Engraver_group_engraver::do_pre_move_processing()
{
- PCursor<Engraver*> i (grav_list_.top());
- while (i.ok()) {
+ PCursor<Engraver*> i (grav_list_.top());
+ while (i.ok())
+ {
Engraver *grav_l = i++;
grav_l->pre_move_processing();
}
void
Engraver_group_engraver::do_process_requests()
{
- PCursor<Engraver*> i (grav_list_.top());
- while (i.ok()) {
+ PCursor<Engraver*> i (grav_list_.top());
+ while (i.ok())
+ {
Engraver *grav_l = i++;
grav_l->process_requests();
}
void
Engraver_group_engraver::do_post_move_processing()
{
- PCursor<Engraver*> i (grav_list_.top());
- while (i.ok()) {
+ PCursor<Engraver*> i (grav_list_.top());
+ while (i.ok())
+ {
// this construction to ensure clean deletion
Engraver *grav_l = i++;
grav_l->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<Engraver*> i (grav_list_.top()); i.ok (); i++)
+ for (PCursor<Engraver*> i (grav_list_.top()); i.ok (); i++)
if (i->contains_b (grav_l))
return true;
- return false;
+ return false;
}
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);
}
}
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<Engraver*> 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<Engraver*> 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);
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<Engraver*> i (grav_list_.top()); i.ok (); i++)
+ DOUT << "ID: " << id_str_ ;
+ DOUT << " iterators: " << iterator_count_<< "\n";
+ for (PCursor<Engraver*> i (grav_list_.top()); i.ok (); i++)
i->print();
#endif
}
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();
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<Engraver*> i (grav_list_.top()); i.ok (); i++)
+ for (PCursor<Engraver*> 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;
}
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
}
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
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);
#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;
}
};
void
add_engraver (String s, Grav_ctor f)
{
- if (!grav_table)
+ if (!grav_table)
grav_table = new Array<Engraver_table_entry>;
-
- 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<Performer_table_entry> *perf_table=0;
void
add_performer (String s, Perf_ctor f)
{
- if (!perf_table)
+ if (!perf_table)
perf_table = new Array<Performer_table_entry>;
-
- 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
source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
- Jan Nieuwenhuizen <jan@digicash.com>
+ Jan Nieuwenhuizen <jan@digicash.com>
*/
#include "proto.hh"
#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;
}
};
void
add_Performer (String s, Perf_ctor f)
{
- if (!perf_table)
+ if (!perf_table)
perf_table = new Array<Performer_table_entry>;
-
- 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;
}
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();
int
Global_translator::moments_left_i()const
{
- return extra_mom_pq_.size();
+ return extra_mom_pq_.size();
}
void
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;
+ }
};
/**
Gourlay_breaking::do_solve()const
{
- Array<Break_node> optimal_paths;
- Line_of_cols all = all_cols();
- Array<int> breaks = find_break_indices();
-
- optimal_paths.set_size (breaks.size());
+ Array<Break_node> optimal_paths;
+ Line_of_cols all = all_cols();
+ Array<int> 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<int> candidates;
- Array<Col_hpositions> candidate_lines;
- Pointer_list<Line_spacer*> spacer_p_list;
+ for (; break_idx< breaks.size(); break_idx++)
+ {
+ Array<int> candidates;
+ Array<Col_hpositions> candidate_lines;
+ Pointer_list<Line_spacer*> 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 << "]"<<flush;
- }
-
- if ( break_idx % HAPPY_DOTS_I)
+ if ( !(break_idx % HAPPY_DOTS_I))
*mlog << "[" << break_idx << "]"<<flush;
- print_stats();
+ }
-
+ if ( break_idx % HAPPY_DOTS_I)
+ *mlog << "[" << break_idx << "]"<<flush;
- Array<int> final_breaks;
+ Array<int> final_breaks;
- Array<Col_hpositions> 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<Col_hpositions> 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")));
}
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 ==
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);
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);
- }
+ }
}
}
Array<MInterval>
Rhythmic_grouping::intervals()
{
- Array<MInterval> r;
- if (interval_ || children.size() == 1) {
+ Array<MInterval> 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
void
Rhythmic_grouping::split (Array<MInterval> splitpoints)
{
- //check on splitpoints..
- int j = 0, i = 0, starti = 0, startj = 0;
-
- Array<Rhythmic_grouping*> ch;
- while (1) {
+ //check on splitpoints..
+ int j = 0, i = 0, starti = 0, startj = 0;
+
+ Array<Rhythmic_grouping*> 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<Rhythmic_grouping*> 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<int> 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 <? v[j];
- return i;
+ return i;
}
Array<int>
Rhythmic_grouping::generate_beams (Array<int> flags, int &flagidx)
{
- assert (!interval_) ;
-
- Array< Array<int> > children_beams;
- for (int i=0; i < children.size(); i++) {
+ assert (!interval_) ;
+
+ Array< Array<int> > children_beams;
+ for (int i=0; i < children.size(); i++)
+ {
Array<int> 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<int> beams;
- int lastm, m, nextm;
- for (int i=0; i < children_beams.size(); i++) {
+ Array<int> 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);
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 <? m);
beams.concat (children_beams[i]);
if (add_right)
beams.push (m <? nextm);
- }
+ }
lastm = m;
m = nextm;
}
- assert (!(beams.size()%2));
- return beams;
+ assert (!(beams.size()%2));
+ return beams;
}
void
Rhythmic_grouping::translate (Moment m)
{
- if (interval_)
+ if (interval_)
*interval_ += m;
- else
+ else
for (int i=0; i < children.size(); i++)
children[i]->translate (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<Rhythmic_grouping*> 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<int> beat_i_arr, Array<Moment> elt_length_arr)
{
- Moment here =0;
- assert (beat_i_arr.size() == elt_length_arr.size ());
-
- Array<Rhythmic_grouping*> children;
- for (int i=0; i < beat_i_arr.size(); i++) {
+ Moment here =0;
+ assert (beat_i_arr.size() == elt_length_arr.size ());
+
+ Array<Rhythmic_grouping*> 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);
}
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;
}
}
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);
}
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();
}
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;
}
void
Note_head_engraver::do_post_move_processing()
{
- note_req_l_ = 0;
+ note_req_l_ = 0;
}
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
}
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<Horizontal_align_item_content> content;
for (int i =0; i < item_l_arr_.size(); i++)
content.push (
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<Interval> dims;
- Real total =0;
- for (int i =0; i < item_l_arr_.size(); i++) {
+
+ Array<Interval> 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
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;
}
void
Horizontal_group_item::do_print() const
{
- Axis_group_item::do_print();
+ Axis_group_item::do_print();
}
Idealspacing::print() const
{
#ifndef NPRINT
- DOUT << "idealspacing {" ;
- DOUT << "distance "<<space_f_<< " strength " << hooke_f_ ;
- DOUT << "left " << left_i_ << " right " << right_i_ << "}\n";
+ DOUT << "idealspacing {" ;
+ DOUT << "distance "<<space_f_<< " strength " << hooke_f_ ;
+ DOUT << "left " << left_i_ << " right " << right_i_ << "}\n";
#endif
}
Idealspacing::Idealspacing()
{
- space_f_ = 0.0;
- hooke_f_ = 0.0;
- left_i_ = -1;
- right_i_ = -1;
+ space_f_ = 0.0;
+ hooke_f_ = 0.0;
+ left_i_ = -1;
+ right_i_ = -1;
}
void
Idealspacing::OK() const
{
- assert (hooke_f_ >= 0);
+ assert (hooke_f_ >= 0);
}
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
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)\
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);
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);
--- /dev/null
+/*
+ header.hh -- declare
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef HEADER_HH
+#define HEADER_HH
+
+#include "string.hh"
+#include "assoc.hh"
+
+
+struct Header : Assoc<String, String>
+{
+};
+
+#endif // HEADER_HH
IDACCESSOR(Request, request)
IDACCESSOR(Score, score)
IDACCESSOR(int, intid)
+ IDACCESSOR(Duration, duration)
protected:
virtual void do_print()const=0;
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);
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;
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();
/** 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
Music * music_p_;
Paper_score *pscore_p_;
Audio_score* audio_score_p_;
+ Header * header_p_;
int errorlevel_i_;
#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.
*/
class Spring_spacer : public Line_spacer {
- friend class Durations_iter;
+ friend class Durations_iter;
- Pointer_list<Idealspacing *> ideal_p_list_;
- Array<Colinfo> cols;
- Array<Colinfo> loose_col_arr_;
+ Pointer_list<Idealspacing *> ideal_p_list_;
+ Array<Colinfo> cols;
+ Array<Colinfo> 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<Moment>&, Array<Moment>&);
- /// 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
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)
{
}
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;
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);
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);
}
}
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<Input_translator*> i (contains_itrans_p_list_.top()); i.ok (); i++)
+ for (PCursor<Input_translator*> i (contains_itrans_p_list_.top()); i.ok (); i++)
i->print();
- DOUT << "}\n";
+ DOUT << "}\n";
#endif
}
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<Input_translator*> i (contains_itrans_p_list_.top());
- for (; !r &&i.ok(); i++) {
+ Input_translator * r =0;
+ // what bout for() ?
+ PCursor<Input_translator*> 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<Input_translator*> i (contains_itrans_p_list_.top()); i.ok (); i++)
+ for (PCursor<Input_translator*> 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<Input_translator*> pc (s); pc.ok(); pc++) {
+ for (PCursor<Input_translator*> pc (s); pc.ok(); pc++)
+ {
Input_translator *q = pc;
Input_translator *p=new Input_translator (*q) ;
bottom().add (p);
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);
Item::do_print() const
{
#ifndef NPRINT
- DOUT << "(unknown)";
+ DOUT << "(unknown)";
#endif
}
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);
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();
}
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();
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();
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();
}
}
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;
}
-
+
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_;
void
Key_engraver::do_post_move_processing()
{
- keyreq_l_ = 0;
- default_key_b_ = false;
+ keyreq_l_ = 0;
+ default_key_b_ = false;
}
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<int> &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<int> &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);
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);
void
Key_item::do_pre_processing()
{
- if (default_b_) {
+ if (default_b_)
+ {
empty_b_ = transparent_b_ = (break_status_i() != 1);
}
}
Key_performer::Key_performer()
{
- key_req_l_ = 0;
+ key_req_l_ = 0;
}
Key_performer::~Key_performer()
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;
}
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);
}
/* 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);
}
/*
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 */
}
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;
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;
}
#include <stdio.h>
+#include <ctype.h>
#include "string.hh"
#include "string-convert.hh"
#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);\
%option warn
%x incl
+%x header
%x lyrics
%x notes
%x quote
REAL ({INT}\.{N}*)|(-?\.{N}+)
KEYWORD \\{WORD}
WHITE [ \n\t\f]
+HORIZONTALWHITE [ \t]
BLACK [^ \n\t\f]
RESTNAME [rs]
NOTECOMMAND \\{A}+
%[^{\n].* {
}
{WHITE}+ {
-
+
}
}
"%"+"}" {
yy_pop_state();
}
+ <<EOF>> {
+ LexerError("EOF found inside a comment");
+ if (! close_input())
+ yyterminate(); // can't move this, since it actually rets a YY_NULL
+ }
}
-<longcomment><<EOF>> {
- LexerError("EOF found inside a comment");
- if (! close_input()) {
- yyterminate(); // can't move this, since it actually rets a YY_NULL
+<header>{
+ [\{\}] {
+ 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];
}
}
+
+
<notes,INITIAL,lyrics>\\include {
yy_push_state(incl);
}
{
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);
+
+}
bool
busy_parsing()
{
- return lexer;
+ return lexer;
}
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;
}
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_);
}
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));
}
Line_spacer::Line_spacer()
{
- paper_l_ =0;
+ paper_l_ =0;
}
Paper_def*
Line_spacer::paper_l()const
{
- return paper_l_ ;
+ return paper_l_ ;
}
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];
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();
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_);
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_;
}
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);
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);
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);
}
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<String> a;
+ Array<String> 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;
}
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<String> 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<String> 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<String> a;
- a.push (arg);
- ret.tex = substitute_args (ret.tex, a);
+ Symbol ret = (*symtables_)("streepjes")->lookup (idx);
+
+ Array<String> 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<String> 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<String> 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<String> a;
- a.push (lines);
- a.push (print_dimen (wid));
+ Array<String> 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<Scalar> 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<String> 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<String> 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;
}
/*
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<String> a;
a.push (idx);
s.tex = substitute_args (s.tex,a);
s.dim.y() = Interval (0,y);
}
- {
+ {
Array<String> a;
a.push (print_dimen (y/2));
a.push (print_dimen (0));
}
- return s;
+ return s;
}
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);
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;
}
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;
}
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"
"\n";
;
-
-
+
+
}
void
notice()
{
- cout <<
+ cout <<
"\n"
"GNU LilyPond -- The GNU Project music typesetter.\n"
"Copyright 1996,97 by\n"
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;
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);
if (d == "")
d = ".ly";
name_str_r = a+b+c+d;
- }
- } else name_str_r = "";
+ }
+ }
+ else name_str_r = "";
}
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<Scalar> args;
args.push (meter_req_l_->beats_i_);
args.push (meter_req_l_->one_beat_i_);
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_);
}
Meter_performer::Meter_performer()
{
- meter_req_l_ = 0;
+ meter_req_l_ = 0;
}
Meter_performer::~Meter_performer()
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;
}
#include "lookup.hh"
Meter::Meter (Array<Scalar>a)
- :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));
}
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;
}
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 ("<duration: ") + String (seconds_f_ ) + ">";
+ return String ("<duration: ") + String (seconds_f_ ) + ">";
}
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
// 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());
}
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_ + "\'");
}
source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
- Jan Nieuwenhuizen <jan@digicash.com>
+ Jan Nieuwenhuizen <jan@digicash.com>
*/
#include "midi-walker.hh"
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_item*>( audio_staff_l->audio_item_l_list_)
+ : PCursor<Audio_item*>( 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) );
}
/**
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);
}
/**
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;
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;
}
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<Item*> &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
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);
}
}
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
}
void
Molecule::add (Atom const &a)
{
- ats.bottom().add (new Atom (a));
+ ats.bottom().add (new Atom (a));
}
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);
}
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<Music*> i (chord_C_->music_p_list_.top()); //, int j = 0;
- i.ok(); j++, i++) {
+ int j = 0;
+ for (PCursor<Music*> 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;
}
}
Chord_iterator::do_print() const
{
#ifndef NPRINT
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++) {
+ for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
+ {
i->print();
}
#endif
void
Chord_iterator::process_and_next (Moment until)
{
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();) {
- if (i->next_moment() == until) {
+ for (PCursor<Music_iterator*> 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);
}
Moment
Chord_iterator::next_moment()const
{
- Moment next_ = infinity_mom;
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
+ Moment next_ = infinity_mom;
+ for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
next_ = next_ <? i->next_moment() ;
- return next_;
+ return next_;
}
bool
Chord_iterator::ok()const
{
- return children_p_list_.size();
+ return children_p_list_.size();
}
/* ************** */
void
Voice_iterator::do_print()const
{
- if (iter_p_)
+ if (iter_p_)
iter_p_->print();
}
Voice_iterator::Voice_iterator (Voice const*v)
- : PCursor<Music*> ( v->music_p_list_)
+ : PCursor<Music*> ( 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<Music*>::ok()) {
+ while (PCursor<Music*>::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<Music*>::next();
+ PCursor<Music*>::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_);
}
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<Music*>::ok()) {
+ if ( PCursor<Music*>::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_;
}
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_;
}
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<Music*> i (elt_l_->music_p_list_); i.ok(); i++) {
+ if ( first_b_)
+ {
+ for (PCursor<Music*> 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;
}
#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());
}
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);
}
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);
}
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
}
Request_chord::Request_chord()
{
- multi_level_i_ =0;
+ multi_level_i_ =0;
}
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 << "`" <<type_str_ << " = " << id_str_<<"\'";
- do_print();
- DOUT << "}\n";
+ do_print();
+ DOUT << "}\n";
#endif
}
void
Music::transpose (Melodic_req const*)
{
-
+
}
void
-
+
Music::Music()
{
- parent_music_l_ =0;
+ parent_music_l_ =0;
}
IMPLEMENT_IS_TYPE_B1(Change_reg,Music)
Stem_req::do_print() const
{
#ifndef NPRINT
- Rhythmic_req::do_print();
- DOUT << "dir : " << dir_i_;
+ Rhythmic_req::do_print();
+ DOUT << "dir : " << dir_i_;
#endif
}
Stem_req::Stem_req()
{
- dir_i_ = 0;
+ dir_i_ = 0;
}
/* ************** */
Span_req::do_print() const
{
#ifndef NPRINT
- DOUT << spantype ;
+ DOUT << spantype ;
#endif
}
Spacing_req::Spacing_req()
{
- next = 0;
- distance = 0;
- strength = 0;
+ next = 0;
+ distance = 0;
+ strength = 0;
}
IMPLEMENT_IS_TYPE_B1(Spacing_req,Request);
Spacing_req::do_print()const
{
#ifndef NPRINT
- DOUT << "next " << next << "dist " << distance << "strength\n";
+ DOUT << "next " << next << "dist " << distance << "strength\n";
#endif
}
void
Blank_req::do_print()const
{
- Spacing_req::do_print();
+ Spacing_req::do_print();
}
/* *************** */
Melodic_req::Melodic_req()
{
- notename_i_ = 0;
- octave_i_ = 0;
- accidental_i_ = 0;
+ notename_i_ = 0;
+ octave_i_ = 0;
+ accidental_i_ = 0;
}
void
Melodic_req::transpose (Melodic_req const & delta)
{
- int old_pitch = pitch();
- int delta_pitch = delta.pitch();
- octave_i_ += delta.octave_i_;
- notename_i_ += delta.notename_i_;
- while (notename_i_ >= 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");
}
}
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: " <<accidental_i_<<" oct: "<< octave_i_;
#endif
}
int
Melodic_req::height() const
{
- return notename_i_ + octave_i_*7;
+ return notename_i_ + octave_i_*7;
}
/*
int
Melodic_req::pitch() const
{
- return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
+ return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
}
/* *************** */
int
Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
{
- return (r1.duration() - r2.duration ());
+ return (r1.duration() - r2.duration ());
}
bool
Rhythmic_req::do_equal_b (Request*r)const
{
- Rhythmic_req* rh = r->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()
Rhythmic_req::do_print() const
{
#ifndef NPRINT
- DOUT << "duration { " <<duration_.str() << "}";
+ DOUT << "duration { " <<duration_.str() << "}";
#endif
}
Moment
Rhythmic_req::duration() const {
- return duration_.length();
+ return duration_.length();
}
/* *************** */
Lyric_req::Lyric_req (Text_def* def_p)
- :Text_req (0, def_p)
+ :Text_req (0, def_p)
{
- def_p->align_i_ = 0; // centre
- dir_i_ = -1; // lyrics below (invisible) staff
+ def_p->align_i_ = 0; // centre
+ dir_i_ = -1; // lyrics below (invisible) staff
}
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);
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
}
/* *************** */
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);
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;
}
/*
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;
}
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();
}
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;
}
Text_req::do_print() const
{
#ifndef NPRINT
- DOUT << " dir " << dir_i_ ;
- tdef_p_->print();
+ DOUT << " dir " << dir_i_ ;
+ tdef_p_->print();
#endif
}
{
#ifndef NPRINT
- DOUT << "duration: " << duration();
+ DOUT << "duration: " << duration();
#endif
}
void
Dynamic_req::do_print() const
{
- Musical_req::do_print();
+ Musical_req::do_print();
}
Absolute_dynamic_req::do_print() const
{
#ifndef NPRINT
- Dynamic_req::do_print();
- DOUT << " loudness " <<loudness_str (loudness_);
+ Dynamic_req::do_print();
+ DOUT << " loudness " <<loudness_str (loudness_);
#endif
}
String
Dynamic_req::loudness_str (Loudness l)
{
- switch (l) {
- case FFF: return "fff";
- case FF: return "ff";
- case F: return "f";
- case MF: return "mf";
- case MP: return "mp";
- case P: return "p";
- case PP: return "pp";
- case PPP: return "ppp";
+ switch (l)
+ {
+ case FFF: return "fff";
+ case FF: return "ff";
+ case F: return "f";
+ case MF: return "mf";
+ case MP: return "mp";
+ case P: return "p";
+ case PP: return "pp";
+ case PPP: return "ppp";
}
- assert (false);
- return "";
+ assert (false);
+ return "";
}
Absolute_dynamic_req::Absolute_dynamic_req()
{
- loudness_ = MF;
+ loudness_ = MF;
}
Span_dynamic_req::Span_dynamic_req()
{
- dynamic_dir_i_ = 0;
+ dynamic_dir_i_ = 0;
}
Span_dynamic_req::do_print()const
{
#ifndef NPRINT
- Span_req::do_print();
- DOUT << "louder/louder: " <<dynamic_dir_i_;
+ Span_req::do_print();
+ DOUT << "louder/louder: " <<dynamic_dir_i_;
#endif
}
#include "parseconstruct.hh"
static Keyword_ent the_key_tab[]={
- {"accepts", ACCEPTS},
- {"alias", ALIAS},
- {"bar", BAR},
- {"cadenza", CADENZA},
- {"clear", CLEAR},
- {"clef", CLEF},
- {"cm", CM_T},
- {"consists", CONSISTS},
- {"contains", CONTAINS},
- {"duration", DURATIONCOMMAND},
- {"absdynamic", ABSDYNAMIC},
- {"group", GROUP},
- {"hshift", HSHIFT},
- {"id", ID},
- {"in", IN_T},
- {"requesttranslator", REQUESTTRANSLATOR},
- {"lyric", LYRIC},
- {"key", KEY},
- {"melodic" , MELODIC},
- {"melodic_request", MELODIC_REQUEST},
- {"meter", METER},
- {"midi", MIDI},
- {"mm", MM_T},
- {"multi", MULTI},
- {"notenames", NOTENAMES},
- {"octave", OCTAVECOMMAND},
- {"output", OUTPUT},
- {"partial", PARTIAL},
- {"paper", PAPER},
- {"plet", PLET},
- {"pt", PT_T},
- {"score", SCORE},
- {"script", SCRIPT},
- {"skip", SKIP},
- {"staff", STAFF},
- {"stem", STEM},
- {"table", TABLE},
- {"spandynamic", SPANDYNAMIC},
- {"symboltables", SYMBOLTABLES},
- {"tempo", TEMPO},
- {"texid", TEXID},
- {"textstyle", TEXTSTYLE},
- {"transpose", TRANSPOSE},
- {"version", VERSION},
- {"grouping", GROUPING},
- {0,0}
+ {"accepts", ACCEPTS},
+ {"alias", ALIAS},
+ {"bar", BAR},
+ {"cadenza", CADENZA},
+ {"clear", CLEAR},
+ {"clef", CLEF},
+ {"cm", CM_T},
+ {"consists", CONSISTS},
+ {"contains", CONTAINS},
+ {"duration", DURATION},
+ {"absdynamic", ABSDYNAMIC},
+ {"group", GROUP},
+ {"hshift", HSHIFT},
+ {"id", ID},
+ {"in", IN_T},
+ {"requesttranslator", REQUESTTRANSLATOR},
+ {"lyric", LYRIC},
+ {"key", KEY},
+ {"melodic" , MELODIC},
+ {"melodic_request", MELODIC_REQUEST},
+ {"meter", METER},
+ {"midi", MIDI},
+ {"mm", MM_T},
+ {"multi", MULTI},
+ {"header", HEADER},
+ {"notenames", NOTENAMES},
+ {"octave", OCTAVE},
+ {"output", OUTPUT},
+ {"partial", PARTIAL},
+ {"paper", PAPER},
+ {"plet", PLET},
+ {"pt", PT_T},
+ {"score", SCORE},
+ {"script", SCRIPT},
+ {"skip", SKIP},
+ {"staff", STAFF},
+ {"stem", STEM},
+ {"table", TABLE},
+ {"spandynamic", SPANDYNAMIC},
+ {"symboltables", SYMBOLTABLES},
+ {"tempo", TEMPO},
+ {"texid", TEXID},
+ {"textstyle", TEXTSTYLE},
+ {"transpose", TRANSPOSE},
+ {"version", VERSION},
+ {"grouping", GROUPING},
+ {0,0}
};
My_lily_lexer::My_lily_lexer()
{
- keytable_p_ = new Keyword_table (the_key_tab);
- identifier_assoc_p_ = new Assoc<String, Identifier*>;
- 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<String, Identifier*>;
+ 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<String,Identifier*>
- ai (*identifier_assoc_p_); ai.ok(); ai++) {
+ for (Assoc_iter<String,Identifier*>
+ 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<String,Identifier*> ai (*identifier_assoc_p_); ai.ok();
- ai++) {
- if (ai.val()->init_b_ == init_b) {
+ for (Assoc_iter<String,Identifier*> 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());
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;
}
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
}
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
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;
}
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;
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 <post_reqs.size(); i++) {
+ pre_reqs.clear();
+ for (int i = 0; i <post_reqs.size(); i++)
+ {
v->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);
}
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();
}
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_)
typeset_element (ncol_p_);
ncol_p_ =0;
}
- if (restcol_p_) {
+ if (restcol_p_)
+ {
if (! restcol_p_->dir_i_)
restcol_p_->dir_i_ = dir_i_;
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();
}
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<int>
Note_column::head_positions_interval()const
{
- ((Note_column*)this)->sort();
- return Interval_t<int> ( head_l_arr_[0]->position_i_,
+ ((Note_column*)this)->sort();
+ return Interval_t<int> ( head_l_arr_[0]->position_i_,
head_l_arr_.top()->position_i_);
}
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();
}
-
+
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
}
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;
}
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;
}
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<int> i_arr)
{
- Measure_grouping_req * mr_p = new Measure_grouping_req;
- for (int i=0; i <i_arr.size();) {
+ Measure_grouping_req * mr_p = new Measure_grouping_req;
+ for (int i=0; i <i_arr.size();)
+ {
mr_p->elt_length_arr_.push (Moment (1, i_arr[i++]));
mr_p->beat_i_arr_.push (i_arr[i++]);
}
- return mr_p;
+ return mr_p;
}
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;
}
}
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);
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
}
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;
}
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));
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;
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;
}
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);
}
-
+
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;
}
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);
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_;
}
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";
}
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<Score_elem*> i (elem_p_list_.top()); i.ok (); i++)
+ for (PCursor<Score_elem*> i (elem_p_list_.top()); i.ok (); i++)
i->OK();
#endif
}
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<PCol *>
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<Col_hpositions> 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<Col_hpositions> sol;
- bool try_wrap = ! paper_l_->get_var ("castingalgorithm");
+ Break_algorithm *algorithm_p;
+ Array<Col_hpositions> 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... " <<flush;
- preprocess();
- *mlog << "\nCalculating column positions ... " <<flush;
- calc_breaking();
- *mlog << "\nPostprocessing elements..." << endl;
- postprocess();
-
+ clean_cols();
+ print();
+ *mlog << "Preprocessing elements... " <<flush;
+ preprocess();
+ *mlog << "\nCalculating column positions ... " <<flush;
+ calc_breaking();
+ *mlog << "\nPostprocessing elements..." << endl;
+ postprocess();
+
#ifndef NDEBUGA
- for (PCursor<Score_elem*> i (elem_p_list_.top()); i.ok (); i++)
+ for (PCursor<Score_elem*> i (elem_p_list_.top()); i.ok (); i++)
assert (i->status() >= 9);
#endif
}
Link_array<PCol>
Paper_score::breakable_col_range (PCol*l,PCol*r)const
{
- Link_array<PCol> ret;
+ Link_array<PCol> ret;
- PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
- PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
+ PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
+ PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
- /*
- ugh! windows-suck-suck-suck.
- */
- while ( PCursor<PCol*>::compare (start,stop) < 0) {
+ /*
+ ugh! windows-suck-suck-suck.
+ */
+ while ( PCursor<PCol*>::compare (start,stop) < 0)
+ {
if (start->breakable_b())
ret.push (start);
start++;
}
- return ret;
+ return ret;
}
Link_array<PCol>
Paper_score::col_range (PCol*l,PCol*r)const
{
- Link_array<PCol> ret;
-
- PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
- PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
- ret.push (l);
-
- /*
- ugh! windows-suck-suck-suck.
- */
- while ( PCursor<PCol*>::compare (start,stop) < 0)
+ Link_array<PCol> ret;
+
+ PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
+ PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
+ ret.push (l);
+
+ /*
+ ugh! windows-suck-suck-suck.
+ */
+ while ( PCursor<PCol*>::compare (start,stop) < 0)
ret.push (start++);
- ret.push (r);
- return ret;
+ ret.push (r);
+ return ret;
}
Link_array<PCol>
Paper_score::broken_col_range (PCol*l,PCol*r)const
{
- Link_array<PCol> ret;
+ Link_array<PCol> ret;
- PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
- PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
+ PCursor<PCol*> start (l ? find_col (l)+1 : col_p_list_.top());
+ PCursor<PCol*> stop (r ? find_col (r) : col_p_list_.bottom());
- /*
- ugh! windows-suck-suck-suck.
- */
- while ( PCursor<PCol*>::compare (start,stop) < 0) {
+ /*
+ ugh! windows-suck-suck-suck.
+ */
+ while ( PCursor<PCol*>::compare (start,stop) < 0)
+ {
if (start->breakable_b() && !start->line_l_)
ret.push (start);
start++;
}
- return ret;
+ return ret;
}
{
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) <? d);
}
+Real
+Paper_def::arithmetic_spacing(Moment d ,Real k)const
+{
+ return (log_2(d) + k)* get_var( "arithmetic_multiplier");
+}
+
+Real
+Paper_def::geometric_spacing(Moment d) const
+{
+ Real dur_f = (d) ?pow (get_var ("geometric"), log_2(d)) : 0;
+ return get_var ("basicspace") + get_var ("unitspace") * dur_f;
+}
Paper_def::Paper_def()
{
- itrans_p_ = 0;
- lookup_p_ = 0;
- real_vars_p_ = new Assoc<String,Real>;
+ itrans_p_ = 0;
+ lookup_p_ = 0;
+ real_vars_p_ = new Assoc<String,Real>;
}
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<String,Real> (*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<String,Real> (*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: " <<outfile_str_;
- lookup_p_->print();
- itrans_p_->print();
- for (Assoc_iter<String,Real> i (*real_vars_p_); i.ok(); i++) {
+ DOUT << "Paper {";
+ DOUT << "out: " <<outfile_str_;
+ lookup_p_->print();
+ itrans_p_->print();
+ for (Assoc_iter<String,Real> 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 ();
}
%{ // -*-Fundamental-*-
/*
- parser.y -- lily parser
+ parser.y -- YACC parser for mudela
source file of the GNU LilyPond music typesetter
#include "input-translator.hh"
#include "score.hh"
#include "music-list.hh"
+#include "header.hh"
+#include "duration-convert.hh"
#ifndef NDEBUG
#define YYDEBUG 1
Music *music;
Music_list *musiclist;
Score *score;
+ Header *header;
Interval *interval;
Lookup*lookup;
Melodic_req * melreq;
%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
%token MM_T
%token MULTI
%token NOTENAMES
-%token OCTAVECOMMAND
+%token OCTAVE
%token OUTPUT
%token PAPER
%token PARTIAL
%type <i> dots
%token <i> INT
%token <melreq> NOTENAME_ID
+%token <id> DURATION_IDENTIFIER
%token <id> IDENTIFIER
%token <id> MELODIC_REQUEST_IDENTIFIER
%token <id> MUSIC_IDENTIFIER
%token <id> REQUEST_IDENTIFIER
%token <real> REAL
%token <string> DURATION RESTNAME
-%token <string> STRING
+%token <string> STRING
+%token <string> FIELDNAME RECORDLINE
%token <i> POST_QUOTES
%token <i> PRE_QUOTES
+%type <header> mudela_header mudela_header_body
%type <box> box
%type <c> open_request_parens close_request_parens
%type <c> open_plet_parens close_plet_parens
%type <i> int
%type <i> script_dir
%type <id> identifier_init
-%type <duration> explicit_duration notemode_duration entered_notemode_duration
+%type <duration> explicit_steno_duration notemode_duration
+%type <duration> entered_notemode_duration explicit_duration
%type <interval> dinterval
%type <intvec> intastint_list
%type <lookup> symtables symtables_body
%type <paper> paper_block paper_body
%type <real> dim real
%type <real> unit
-%type <request> post_request pre_request command_req verbose_command_req abbrev_command_req
+%type <request> post_request pre_request command_req verbose_command_req
+%type <request> abbrev_command_req
%type <request> script_req dynamic_req
%type <score> score_block score_body
%type <script> script_definition script_body mudela_script gen_script_def
%type <symtable> symtable symtable_body
%type <itrans> input_translator_spec input_translator_spec_body
%type <tempo> tempo_request
+%type <string> header_record
%left PRIORITY
%%
mudela: /* empty */
+ | mudela mudela_header {
+ }
| mudela score_block {
add_score($2);
}
delete $2;
}
;
+
+mudela_header_body:
+ {
+ $$ = new Header;
+ }
+ | mudela_header_body FIELDNAME header_record {
+ (*$$)[*$2] = *$3;
+ delete $2;
+ delete $3;
+ }
+ ;
+
+mudela_header:
+ HEADER {
+ THIS->lexer_p_->push_header_state();
+ }
+
+ '{' mudela_header_body '}' {
+ $$ = $4;
+ THIS->lexer_p_->pop_state();
+ }
+ ;
+
+
+header_record:
+ {
+ $$ = new String;
+ }
+ | header_record RECORDLINE {
+ *$$ += *$2;
+ delete $2;
+ }
+ ;
+
/*
DECLARATIONS
*/
| input_translator_spec {
$$ = new Input_translator_id ( $1, INPUT_TRANS_IDENTIFIER);
}
+ | explicit_duration {
+ $$ = new Duration_id( $1, DURATION_IDENTIFIER);
+ }
;
SCORE
*/
score_block:
- SCORE { THIS->remember_spot(); }
+ SCORE { THIS->remember_spot();
+ THIS->error_level_i_ =0;
+ }
/*cont*/ '{' score_body '}' {
$$ = $4;
$$->set_spot(THIS->pop_spot());
| SCORE_IDENTIFIER {
$$ = $1->score();
}
+ | score_body mudela_header {
+ $$->header_p_ = $2;
+ }
| score_body Music {
$$->music_p_ = $2;
}
}
;
+explicit_duration:
+ DURATION '{' int int '}' {
+ $$ = new Duration;
+ $$-> durlog_i_ = $3;
+ $$-> dots_i_ = $4;
+ }
+ ;
+
dynamic_req:
ABSDYNAMIC '{' int '}' {
Absolute_dynamic_req *ad_p = new Absolute_dynamic_req;
PLET INT '/' INT {
THIS->default_duration_.set_plet($2,$4);
}
- | DURATIONCOMMAND STRING {
+ | DURATION STRING {
THIS->set_duration_mode(*$2);
delete $2;
}
- | DURATIONCOMMAND entered_notemode_duration {
+ | DURATION entered_notemode_duration {
THIS->set_default_duration($2);
delete $2;
}
- | OCTAVECOMMAND {
+ | OCTAVE {
/*
This is weird, but default_octave_i_
is used in steno_note_req too
{
$$ = new Moment(0,1);
}
- | duration_length explicit_duration {
+ | duration_length explicit_steno_duration {
*$$ += $2->length();
}
;
$$ = new Duration(THIS->default_duration_);
$$->dots_i_ = $1;
}
- | explicit_duration {
+ | explicit_steno_duration {
THIS->set_last_duration($1);
$$ = $1;
}
}
;
-explicit_duration:
+explicit_steno_duration:
int {
$$ = new Duration;
if ( !Duration::duration_type_b($1) )
THIS->parser_error("Not a duration");
else {
- $$->type_i_ = $1;
+ $$->durlog_i_ = Duration_convert::i2_type($1);
}
}
- | explicit_duration '.' {
+ | DURATION_IDENTIFIER {
+ $$ = $1->duration();
+ }
+ | explicit_steno_duration '.' {
$$->dots_i_ ++;
}
- | explicit_duration '*' int {
+ | explicit_steno_duration '*' int {
$$->plet_.iso_i_ *= $3;
}
- | explicit_duration '/' int {
+ | explicit_steno_duration '/' int {
$$->plet_.type_i_ *= $3;
}
;
source file of the GNU LilyPond music typesetter
(c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
- Jan Nieuwenhuizen <jan@digicash.com>
+ Jan Nieuwenhuizen <jan@digicash.com>
*/
#include "performer-group-performer.hh"
void
Performer_group_performer::add (Performer *perf_p)
{
- perf_p_list_.bottom().add (perf_p);
- perf_p->daddy_perf_l_ = this;
+ perf_p_list_.bottom().add (perf_p);
+ perf_p->daddy_perf_l_ = this;
- if (perf_p->is_type_b (Performer_group_performer::static_name())) {
+ if (perf_p->is_type_b (Performer_group_performer::static_name()))
+ {
group_l_arr_.push ((Performer_group_performer*)perf_p);
- } else {
+ }
+ else
+ {
nongroup_l_arr_ .push (perf_p);
}
}
Translator*
Performer_group_performer::ancestor_l (int l)
{
- if (!l || !daddy_perf_l_)
+ if (!l || !daddy_perf_l_)
return this;
-
- return daddy_perf_l_->ancestor_l (l - 1);
+
+ return daddy_perf_l_->ancestor_l (l - 1);
}
int
Performer_group_performer::depth_i() const
{
- return daddy_perf_l_->depth_i() + 1;
+ return daddy_perf_l_->depth_i() + 1;
}
void
Performer_group_performer::do_creation_processing()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
i->creation_processing();
}
Performer_group_performer::do_print()const
{
#ifndef NPRINT
- if ( !check_debug)
+ if ( !check_debug)
return ;
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
i->print();
#endif
}
void
Performer_group_performer::do_removal_processing()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
i->do_removal_processing();
}
bool
Performer_group_performer::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_perf_l_)
+ if ( !hebbes_b && daddy_perf_l_)
hebbes_b = daddy_perf_l_->try_request (req_l);
- return hebbes_b ;
+ return hebbes_b ;
}
Translator*
Performer_group_performer::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_performer_l (n,id);
- if (!ret) {
+ if (!ret)
+ {
Performer_group_performer * group =
itrans_l-> get_group_performer_p();
else
return ret->find_get_translator_l (n,id);
- }
- } else if (daddy_perf_l_)
+ }
+ }
+ else if (daddy_perf_l_)
ret =daddy_perf_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;
}
Performer_group_performer*
Performer_group_performer::find_performer_l (String n, String id)
{
- if (name() == n && id_str_ == id)
+ if (name() == n && id_str_ == id)
return this;
- Performer_group_performer * r = 0;
- for (int i =0; !r && i< group_l_arr_.size(); i++) {
+ Performer_group_performer * r = 0;
+ for (int i =0; !r && i< group_l_arr_.size(); i++)
+ {
r = group_l_arr_[i]->find_performer_l (n,id);
}
-
- return r;
+
+ return r;
}
Translator*
Performer_group_performer::get_default_interpreter()
{
- // ?
- if ( is_bottom_performer_b())
+ // ?
+ if ( is_bottom_performer_b())
return daddy_perf_l_->get_default_interpreter();
- Performer_group_performer *perf_p= itrans_l_->
+ Performer_group_performer *perf_p= itrans_l_->
get_default_itrans_l()->get_group_performer_p ();
- add (perf_p);
- if (perf_p->is_bottom_performer_b())
+ add (perf_p);
+ if (perf_p->is_bottom_performer_b())
return perf_p;
- else
+ else
return perf_p->get_default_interpreter();
}
bool
Performer_group_performer::is_bottom_performer_b() const
{
- return !itrans_l_->get_default_itrans_l();
+ return !itrans_l_->get_default_itrans_l();
}
void
Performer_group_performer::print() const
{
- Performer::print();
+ Performer::print();
}
void
Performer_group_performer::process_requests()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
i->process_requests();
}
bool
Performer_group_performer::try_request (Request* r)
{
- return Performer::try_request (r);
+ return Performer::try_request (r);
}
source file of the GNU LilyPond music typesetter
(c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
- Jan Nieuwenhuizen <jan@digicash.com>
+ Jan Nieuwenhuizen <jan@digicash.com>
*/
Performer::Performer()
{
- daddy_perf_l_ = 0;
- init_b_ =false;
+ daddy_perf_l_ = 0;
+ init_b_ =false;
}
Performer::~Performer()
void
Performer::play (Audio_element* p)
{
- daddy_perf_l_->play (p);
+ daddy_perf_l_->play (p);
}
int
Performer::get_tempo_i()const
{
- return daddy_perf_l_->get_tempo_i();
+ return daddy_perf_l_->get_tempo_i();
}
void
Performer::print() const
{
#ifndef NPRINT
- DOUT << "\n" << name() << " {";
- do_print();
- DOUT << "}";
+ DOUT << "\n" << name() << " {";
+ do_print();
+ DOUT << "}";
#endif
}
bool
Performer::do_try_request (Request* req_l)
{
- return false;
+ return false;
}
bool
Performer::try_request (Request*r)
{
- if (!init_b_) {
+ if (!init_b_)
+ {
creation_processing();
}
- return do_try_request (r);
+ return do_try_request (r);
}
void
Performer::creation_processing()
{
- if (!init_b_) {
+ if (!init_b_)
+ {
do_creation_processing();
init_b_ = true;
}
void
Mixed_qp::add_equality_cons (Vector , double)
{
- assert (false);
+ assert (false);
}
void
Mixed_qp::add_fixed_var (int i, Real r)
{
- eq_cons.push (i);
- eq_consrhs.push (r);
+ eq_cons.push (i);
+ eq_consrhs.push (r);
}
/**
- eliminate appropriate variables, until we have a Ineq_constrained_qp
- then solve that.
+ eliminate appropriate variables, until we have a Ineq_constrained_qp
+ then solve that.
- PRE
- cons should be ascending
- */
+ PRE
+ cons should be ascending
+ */
Vector
Mixed_qp::solve (Vector start) const
{
- if (!dim())
+ if (!dim())
return Vector (0);
-
- print();
- Ineq_constrained_qp pure (*this);
-
- for (int i= eq_cons.size()-1; i>=0; i--) {
+
+ print();
+ Ineq_constrained_qp pure (*this);
+
+ for (int i= eq_cons.size()-1; i>=0; i--)
+ {
pure.eliminate_var (eq_cons[i], eq_consrhs[i]);
start.del (eq_cons[i]);
}
- Vector sol = pure.solve (start);
- for (int i= 0; i < eq_cons.size(); i++) {
+ Vector sol = pure.solve (start);
+ for (int i= 0; i < eq_cons.size(); i++)
+ {
sol.insert (eq_consrhs[i],eq_cons[i]);
}
- return sol;
+ return sol;
}
void
Ineq_constrained_qp::assert_solution (Vector sol) const
{
- Array<int> binding;
- for (int i=0; i < cons.size(); i++) {
+ Array<int> binding;
+ for (int i=0; i < cons.size(); i++)
+ {
Real R=cons[i] * sol- consrhs[i];
assert (R> -EPS);
if (R < EPS)
binding.push (i);
}
- // KKT check...
- // todo
+ // KKT check...
+ // todo
}
void
Ineq_constrained_qp::print() const
{
#ifndef NPRINT
- DOUT << "Quad " << quad;
- DOUT << "lin " << lin <<"\n"
+ DOUT << "Quad " << quad;
+ DOUT << "lin " << lin <<"\n"
<< "const " << const_term<<"\n";
- for (int i=0; i < cons.size(); i++) {
+ for (int i=0; i < cons.size(); i++)
+ {
DOUT << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
DOUT << "\n";
}
}
Mixed_qp::Mixed_qp (int n)
- : Ineq_constrained_qp (n)
+ : Ineq_constrained_qp (n)
{
}
Mixed_qp::OK() const
{
#ifndef NDEBUG
- Ineq_constrained_qp::OK();
- assert (eq_consrhs.size() == eq_cons.size ());
+ Ineq_constrained_qp::OK();
+ assert (eq_consrhs.size() == eq_cons.size ());
#endif
}
Mixed_qp::print() const
{
#ifndef NPRINT
- Ineq_constrained_qp::print();
- for (int i=0; i < eq_cons.size(); i++) {
+ Ineq_constrained_qp::print();
+ for (int i=0; i < eq_cons.size(); i++)
+ {
DOUT << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";
}
#endif
String
Active_constraints::status() const
{
- String s ("Active|Inactive [");
- for (int i=0; i< active.size(); i++) {
+ String s ("Active|Inactive [");
+ for (int i=0; i< active.size(); i++)
+ {
s += String (active[i]) + " ";
}
- s+="| ";
- for (int i=0; i< inactive.size(); i++) {
+ s+="| ";
+ for (int i=0; i< inactive.size(); i++)
+ {
s += String (inactive[i]) + " ";
}
- s+="]";
+ s+="]";
- return s;
+ return s;
}
void
Active_constraints::OK()
{
#ifndef NDEBUG
- H.OK();
- A.OK();
- assert (active.size() +inactive.size () == opt->cons.size ());
- assert (H.dim() == opt->dim ());
- assert (active.size() == A.rows ());
- Array<int> allcons;
-
- for (int i=0; i < opt->cons.size(); i++)
+ H.OK();
+ A.OK();
+ assert (active.size() +inactive.size () == opt->cons.size ());
+ assert (H.dim() == opt->dim ());
+ assert (active.size() == A.rows ());
+ Array<int> allcons;
+
+ for (int i=0; i < opt->cons.size(); i++)
allcons.push (0);
- for (int i=0; i < active.size(); i++) {
+ for (int i=0; i < active.size(); i++)
+ {
int j = active[i];
allcons[j]++;
}
- for (int i=0; i < inactive.size(); i++) {
+ for (int i=0; i < inactive.size(); i++)
+ {
int j = inactive[i];
allcons[j]++;
}
- for (int i=0; i < allcons.size(); i++)
+ for (int i=0; i < allcons.size(); i++)
assert (allcons[i] == 1);
#endif
}
Vector
Active_constraints::get_lagrange (Vector gradient)
{
- return (A*gradient);
+ return (A*gradient);
}
void
Active_constraints::add (int k)
{
- // add indices
- int cidx=inactive[k];
- active.push (cidx);
-
- inactive.swap (k,inactive.size()-1);
- inactive.pop();
-
- Vector a (opt->cons[cidx]);
- // update of matrices
- Vector Ha = H*a;
- Real aHa = a*Ha;
- Vector addrow (Ha.dim());
- if (abs (aHa) > EPS) {
+ // add indices
+ int cidx=inactive[k];
+ active.push (cidx);
+
+ inactive.swap (k,inactive.size()-1);
+ inactive.pop();
+
+ Vector a (opt->cons[cidx]);
+ // update of matrices
+ Vector Ha = H*a;
+ Real aHa = a*Ha;
+ Vector addrow (Ha.dim());
+ if (abs (aHa) > EPS)
+ {
/*
a != 0, so if Ha = O(EPS), then
Ha * aH / aHa = O(EPS^2/EPS)
if H*a == 0, the constraints are dependent.
*/
H -= Matrix (Ha/aHa , Ha);
-
+
/*
sorry, don't know how to justify this. ..
*/
addrow=Ha;
- addrow/= aHa;
+ addrow/= aHa;
A -= Matrix (A*a, addrow);
A.insert_row (addrow,A.rows());
- }else
+ }else
WARN << "degenerate constraints";
}
void
Active_constraints::drop (int k)
{
- int q=active.size()-1;
+ int q=active.size()-1;
- // drop indices
- inactive.push (active[k]);
- active.swap (k,q);
- A.swap_rows (k,q);
- active.pop();
+ // drop indices
+ inactive.push (active[k]);
+ active.swap (k,q);
+ A.swap_rows (k,q);
+ active.pop();
- Vector a (A.row (q));
- if (a.norm() > EPS) {
+ Vector a (A.row (q));
+ if (a.norm() > EPS)
+ {
/*
*/
- Real q = a*opt->quad*a;
+ Real q = a*opt->quad*a;
Matrix aaq (a,a/q);
H += aaq;
A -= A*opt->quad*aaq;
- }else
+ }else
WARN << "degenerate constraints";
#ifndef NDEBUG
- Vector rem_row (A.row (q));
- assert (rem_row.norm() < EPS);
+ Vector rem_row (A.row (q));
+ assert (rem_row.norm() < EPS);
#endif
-
- A.delete_row (q);
+
+ A.delete_row (q);
}
Active_constraints::Active_constraints (Ineq_constrained_qp const *op)
- : A(0,op->dim()),
+ : A(0,op->dim()),
H(op->dim()),
opt (op)
{
- for (int i=0; i < op->cons.size(); i++)
+ for (int i=0; i < op->cons.size(); i++)
inactive.push (i);
- Choleski_decomposition chol (op->quad);
+ Choleski_decomposition chol (op->quad);
- /*
- ugh.
- */
- H=chol.inverse();
- OK();
+ /*
+ ugh.
+ */
+ H=chol.inverse();
+ OK();
}
/** Find the optimum which is in the planes generated by the active
- constraints.
- */
+ constraints.
+ */
Vector
Active_constraints::find_active_optimum (Vector g)
{
- return H*g;
+ return H*g;
}
MInterval
Request::time_int() const
{
- return MInterval (0, duration());
+ return MInterval (0, duration());
}
bool
Request::equal_b (Request *r)const
{
- if ( is_type_b ( r->name()) )
+ if ( is_type_b ( r->name()) )
return r->do_equal_b ((Request*)this);
- if ( r->is_type_b (name()))
+ if ( r->is_type_b (name()))
return do_equal_b (r);
- return false;
+ return false;
}
bool
Request::do_equal_b (Request*)const
{
- return false;
+ return false;
}
-
+
Rest_collision_engraver::Rest_collision_engraver()
{
- rest_collision_p_ =0;
+ rest_collision_p_ =0;
}
void
Rest_collision_engraver::make_collision()
{
- if (!rest_collision_p_) {
+ if (!rest_collision_p_)
+ {
rest_collision_p_ = new Rest_collision;
announce_element (Score_elem_info (rest_collision_p_, 0));
}
void
Rest_collision_engraver::acknowledge_element (Score_elem_info i)
{
- char const * nC = i.elem_l_->name();
- if (nC == Note_column::static_name()) {
+ char const * nC = i.elem_l_->name();
+ if (nC == Note_column::static_name())
+ {
// what should i do, what should _engraver do?
make_collision();
rest_collision_p_->add ((Note_column*)i.elem_l_->item());
- } else if (nC == Rest_column::static_name()) {
+ }
+ else if (nC == Rest_column::static_name())
+ {
make_collision();
rest_collision_p_->add ((Rest_column*)i.elem_l_->item());
}
void
Rest_collision_engraver::do_pre_move_processing()
{
- if (rest_collision_p_) {
+ if (rest_collision_p_)
+ {
typeset_element (rest_collision_p_);
rest_collision_p_ = 0;
}
Rest_collision_engraver::do_print() const
{
#ifndef NPRINT
- if ( rest_collision_p_)
+ if ( rest_collision_p_)
rest_collision_p_->print();
#endif
}
void
Rest_collision::add (Note_column *nc_l)
{
- add_dependency (nc_l);
- ncol_l_arr_.push (nc_l);
+ add_dependency (nc_l);
+ ncol_l_arr_.push (nc_l);
}
void
Rest_collision::add (Rest_column *rc_l)
{
- add_dependency (rc_l);
- rest_l_arr_.push (rc_l);
+ add_dependency (rc_l);
+ rest_l_arr_.push (rc_l);
}
void
Rest_collision::do_post_processing()
{
- /*
- handle rest under beam (do_post: beams are calculated now)
-
- [todo]
- i-d like to have access to the beam itself,
- iso only the (half-initialised?) stem
-
- what about combination of collisions and rest under beam
- */
-
- // no rests to collide
- if (!rest_l_arr_.size())
- return;
- // can this happen?
- Stem* stem_l = rest_l_arr_[0]->stem_l_;
- if (!stem_l)
- return;
- // no beam
- if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_))
- return;
-
- int dir_i = rest_l_arr_[0]->dir_i_;
- int midpos = 4;
+ /*
+ handle rest under beam (do_post: beams are calculated now)
+
+ [todo]
+ i-d like to have access to the beam itself,
+ iso only the (half-initialised?) stem
+
+ what about combination of collisions and rest under beam
+ */
+
+ // no rests to collide
+ if (!rest_l_arr_.size())
+ return;
+ // can this happen?
+ Stem* stem_l = rest_l_arr_[0]->stem_l_;
+ if (!stem_l)
+ return;
+ // no beam
+ if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_))
+ return;
+
+ int dir_i = rest_l_arr_[0]->dir_i_;
+ int midpos = 4;
#if 1
- // ugh
- int stem_length_i = 7 - 2;
- // ugh, Stem::stem_start vs Stem::stem_end
- int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i;
+ // ugh
+ int stem_length_i = 7 - 2;
+ // ugh, Stem::stem_start vs Stem::stem_end
+ int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i;
#else // nogo: stem_start not set for rests?
- int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2;
+ int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2;
#endif
- rest_l_arr_[0]->translate_heads (pos);
+ rest_l_arr_[0]->translate_heads (pos);
}
void
Rest_collision::do_pre_processing()
{
- /*
- handle rest-rest and rest-note collisions
+ /*
+ handle rest-rest and rest-note collisions
- [todo]
- decide not to print rest if too crowded?
- */
+ [todo]
+ decide not to print rest if too crowded?
+ */
- // no rests to collide
- if (!rest_l_arr_.size())
- return;
+ // no rests to collide
+ if (!rest_l_arr_.size())
+ return;
- // no partners to collide with
- if (rest_l_arr_.size() + ncol_l_arr_.size () < 2)
+ // no partners to collide with
+ if (rest_l_arr_.size() + ncol_l_arr_.size () < 2)
return;
- // meisjes met meisjes
- if (!ncol_l_arr_.size()) {
+ // meisjes met meisjes
+ if (!ncol_l_arr_.size())
+ {
int dy = rest_l_arr_.size() > 2 ? 6 : 4;
rest_l_arr_[0]->translate_heads (rest_l_arr_[0]->dir_i_ *dy);
// top is last element...
rest_l_arr_.top()->translate_heads (rest_l_arr_.top ()->dir_i_* dy);
}
- // meisjes met jongetjes
- else {
+ // meisjes met jongetjes
+ else
+ {
#if 0 // breendet: rests go always under
// geen gemug, trug op je rug
int dir_i = -1;
// hope it's 4: if it works->doco
int midpos = 4;
- // minimum move
+ // minimum move
int minpos = 4;
// quart rest height
int size_i = 6;
int sep_i = 3 + size_i / 2;
- for (int i = 0; i < ncol_l_arr_.size(); i++) {
+ for (int i = 0; i < ncol_l_arr_.size(); i++)
+ {
// how to know whether to sort?
ncol_l_arr_[i]->sort();
for ( int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++)
minpos = minpos >? dir_i *
(ncol_l_arr_[i]->head_l_arr_[j]->position_i_ -midpos) + sep_i;
- }
+ }
rest_l_arr_[0]->translate_heads (dir_i * minpos);
#endif
}
Rest_collision::do_print() const
{
#ifndef NPRINT
- DOUT << "rests: " << rest_l_arr_.size() << ", ";
- DOUT << "cols: " << ncol_l_arr_.size();
+ DOUT << "rests: " << rest_l_arr_.size() << ", ";
+ DOUT << "cols: " << ncol_l_arr_.size();
#endif
}
void
Rest_collision::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
- Item*o_l = o->item();
- Item*n_l = n?n->item():0;
-
- rest_l_arr_.substitute ((Rest_column*)o_l,(Rest_column*)n_l);
- ncol_l_arr_.substitute ((Note_column*)o_l,(Note_column*)n_l);
+ Item*o_l = o->item();
+ Item*n_l = n?n->item():0;
+
+ rest_l_arr_.substitute ((Rest_column*)o_l,(Rest_column*)n_l);
+ ncol_l_arr_.substitute ((Note_column*)o_l,(Note_column*)n_l);
}
Rest_collision::Rest_collision()
{
- transparent_b_ = true;
- empty_b_ = true;
+ transparent_b_ = true;
+ empty_b_ = true;
}
void
Rest_column::translate_heads (int dy_i)
{
- for (int i=0; i < head_l_arr_.size(); i++)
+ for (int i=0; i < head_l_arr_.size(); i++)
head_l_arr_[i]->position_i_ += dy_i;
}
Score_align_engraver::Score_align_engraver()
{
- type_ch_C_ = 0;
- priority_i_ =0;
- align_p_=0;
+ type_ch_C_ = 0;
+ priority_i_ =0;
+ align_p_=0;
}
void
Score_align_engraver::do_pre_move_processing()
{
- if (align_p_) {
+ if (align_p_)
+ {
typeset_element (align_p_);
align_p_ =0;
}
void
Score_align_engraver::acknowledge_element (Score_elem_info inf)
{
- if (inf.elem_l_->is_type_b (type_ch_C_)) {
-
- if (!align_p_) {
+ if (inf.elem_l_->is_type_b (type_ch_C_))
+ {
+
+ if (!align_p_)
+ {
align_p_ = new Horizontal_group_item;
align_p_->breakable_b_ = true;
announce_element (Score_elem_info (align_p_,0));
- }
+ }
Score_elem * unbound_elem = inf.elem_l_;
while ( unbound_elem->axis_group_l_a_[X_AXIS])
unbound_elem = unbound_elem->axis_group_l_a_[X_AXIS];
align_p_->add_element (unbound_elem);
}
-
+
}
IMPLEMENT_IS_TYPE_B1(Score_align_engraver,Engraver);
class C ## _align_engraver : public Score_align_engraver \
{ \
public: \
- DECLARE_MY_RUNTIME_TYPEINFO; \
- C ## _align_engraver() : Score_align_engraver () \
- { type_ch_C_ = T::static_name();\
- priority_i_ = p;} \
+ DECLARE_MY_RUNTIME_TYPEINFO; \
+ C ## _align_engraver() : Score_align_engraver () \
+ { type_ch_C_ = T::static_name();\
+ priority_i_ = p;} \
}; \
ADD_THIS_ENGRAVER(C ## _align_engraver); \
IMPLEMENT_IS_TYPE_B1(C ## _align_engraver, Score_align_engraver) ;
Score_column::Score_column (Moment w)
{
- when_ = w;
- musical_b_ = false;
+ when_ = w;
+ musical_b_ = false;
}
void
Score_column::print() const
{
#ifndef NPRINT
- DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n';
- DOUT << "durations: [";
- for (int i=0; i < durations.size(); i++)
+ DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n';
+ DOUT << "durations: [";
+ for (int i=0; i < durations.size(); i++)
DOUT << durations[i] << " ";
- DOUT << "]\n";
- PCol::print();
- DOUT << "}\n";
+ DOUT << "]\n";
+ PCol::print();
+ DOUT << "}\n";
#endif
}
int
Moment_compare (Moment const &m1, Moment const &m2)
{
- return sign (m1-m2);
+ return sign (m1-m2);
}
void
Score_column::preprocess()
{
- durations.sort (Moment_compare);
+ durations.sort (Moment_compare);
}
void
Score_column::add_duration (Moment d)
{
- assert (d);
- for (int i = 0; i< durations.size(); i++) {
+ assert (d);
+ for (int i = 0; i< durations.size(); i++)
+ {
if (d == durations[i])
return ;
}
- durations.push (d);
+ durations.push (d);
}
void
Score_column::do_set_breakable()
{
- Score_column *c1 = new Score_column (when_);
- Score_column *c2 = new Score_column (when_);
- prebreak_p_ =c1;
- postbreak_p_ = c2;
- c1->durations = durations;
- c2->durations = durations;
- c1->musical_b_
+ Score_column *c1 = new Score_column (when_);
+ Score_column *c2 = new Score_column (when_);
+ prebreak_p_ =c1;
+ postbreak_p_ = c2;
+ c1->durations = durations;
+ c2->durations = durations;
+ c1->musical_b_
= c2->musical_b_ = musical_b_;
}
Score_elem_info::Score_elem_info (Score_elem*s_l, Request*r_l)
{
- elem_l_ = s_l;
- req_l_ = r_l;
+ elem_l_ = s_l;
+ req_l_ = r_l;
}
Score_elem_info::Score_elem_info()
{
- elem_l_ = 0;
- req_l_ = 0;
+ elem_l_ = 0;
+ req_l_ = 0;
}
Score_elem*
Score_elem::dependency (int i)const
{
- return (Score_elem*) get_out_edge_arr()[i];
+ return (Score_elem*) get_out_edge_arr()[i];
}
int
Score_elem::dependency_size() const
{
- return get_out_edge_arr().size ();
+ return get_out_edge_arr().size ();
}
Score_elem*
Score_elem::dependent (int i) const
{
- return (Score_elem*) get_in_edge_arr()[i];
+ return (Score_elem*) get_in_edge_arr()[i];
}
int
Score_elem::dependent_size() const
{
- return get_in_edge_arr().size ();
+ return get_in_edge_arr().size ();
}
String
Score_elem::TeX_string_without_offset (Offset o)const
{
- if (transparent_b_)
+ if (transparent_b_)
return "";
- String s ("\\placebox{%}{%}{%}");
- Array<String> a;
- a.push (print_dimen (o.y()));
- a.push (print_dimen (o.x()));
- String t = output->TeX_string();
- if (t == "")
+ String s ("\\placebox{%}{%}{%}");
+ Array<String> a;
+ a.push (print_dimen (o.y()));
+ a.push (print_dimen (o.x()));
+ String t = output->TeX_string();
+ if (t == "")
return t;
- a.push (t);
- String r;
- if (check_debug)
+ a.push (t);
+ String r;
+ if (check_debug)
r = String ("\n%start: ") + name() + "\n";
- r += substitute_args (s, a);;
- return r;
+ r += substitute_args (s, a);;
+ return r;
}
String
Score_elem::TeX_string() const
{
- assert (status_ > POSTCALCED);
- return TeX_string_without_offset (offset_);
+ assert (status_ > POSTCALCED);
+ return TeX_string_without_offset (offset_);
}
void
Score_elem::copy_dependencies (Score_elem const &s)
{
- /* called from derived ctor, so most info points to the same deps
- as (Directed_graph_node&)s. Nobody points to us, so don't copy
- dependents.
- */
- copy_edges_out (s);
+ /* called from derived ctor, so most info points to the same deps
+ as (Directed_graph_node&)s. Nobody points to us, so don't copy
+ dependents.
+ */
+ copy_edges_out (s);
}
Score_elem::Score_elem (Score_elem const&s)
{
- transparent_b_ = s.transparent_b_;
- empty_b_ = s.empty_b_;
- axis_group_l_a_[0] = axis_group_l_a_[1] =0;
- status_ = s.status_;
- assert (!s.output);
- output = 0;
- pscore_l_ = s.pscore_l_;
- offset_ = Offset (0,0);
+ transparent_b_ = s.transparent_b_;
+ empty_b_ = s.empty_b_;
+ axis_group_l_a_[0] = axis_group_l_a_[1] =0;
+ status_ = s.status_;
+ assert (!s.output);
+ output = 0;
+ pscore_l_ = s.pscore_l_;
+ offset_ = Offset (0,0);
}
Score_elem::~Score_elem()
{
- // some paranoia to prevent weird segv's
- assert (status_ < DELETED);
- delete output;
- status_ = DELETED;
- output = 0;
+ // some paranoia to prevent weird segv's
+ assert (status_ < DELETED);
+ delete output;
+ status_ = DELETED;
+ output = 0;
}
Real
Score_elem::absolute_coordinate (Axis a)const
{
- Real r = offset_[a];
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ Real r = offset_[a];
+ for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a])
r += axis_group_l->offset_[a];
- return r;
+ return r;
}
Offset
Score_elem::absolute_offset() const
{
- return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS));
+ return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS));
}
void
Score_elem::translate (Real y, Axis a)
{
- offset_[a] += y;
+ offset_[a] += y;
}
Real
Score_elem::relative_coordinate (Axis_group_element*e, Axis a)const
{
- Real r =0.0;
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ Real r =0.0;
+ for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
axis_group_l != e;
axis_group_l = axis_group_l->axis_group_l_a_[a])
r += axis_group_l->offset_[a];
- return r;
+ return r;
}
Axis_group_element*
Score_elem::common_group (Score_elem const* s, Axis a)const
{
- Link_array<Axis_group_element> my_groups;
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ Link_array<Axis_group_element> my_groups;
+ for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
axis_group_l;
axis_group_l = axis_group_l->axis_group_l_a_[a])
my_groups.push (axis_group_l);
- Axis_group_element* common_l=0;
- for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a];
+ Axis_group_element* common_l=0;
+ for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a];
!common_l && axis_group_l;
axis_group_l = axis_group_l->axis_group_l_a_[a])
common_l = my_groups.find_l (axis_group_l);
- return common_l;
+ return common_l;
}
void
Score_elem::translate (Offset O)
{
- offset_ += O;
+ offset_ += O;
}
Interval
Score_elem::do_width() const
{
- Interval r;
+ Interval r;
- if (!output){
+ if (!output)
+ {
Molecule*m = brew_molecule_p();
r = m->extent().x ();
delete m;
- } else
+ }
+ else
r = output->extent().x ();
- return r;
+ return r;
}
Interval
Score_elem::width() const
{
- return extent (X_AXIS);
+ return extent (X_AXIS);
}
Interval
Score_elem::extent (Axis a)const
{
- Interval r;
- if ( !empty_b_) {
+ Interval r;
+ if ( !empty_b_)
+ {
r = (a == X_AXIS)? do_width(): do_height ();
}
-
- if (!r.empty_b()) // float exception on DEC Alpha
+
+ if (!r.empty_b()) // float exception on DEC Alpha
r+=offset_[a];
- return r;
+ return r;
}
Interval
Score_elem::do_height() const
{
- Interval r;
- if (!output){
+ Interval r;
+ if (!output)
+ {
Molecule*m = brew_molecule_p();
r = m->extent().y ();
delete m;
- } else
+ }
+ else
r = output->extent().y ();
- return r;
+ return r;
}
Interval
Score_elem::height() const
{
- return extent (Y_AXIS);
+ return extent (Y_AXIS);
}
/*
Score_elem::print()const
{
#ifndef NPRINT
- DOUT << name() << "{\n";
- DOUT << "dets: " << dependent_size() << "dependencies: " <<
+ DOUT << name() << "{\n";
+ DOUT << "dets: " << dependent_size() << "dependencies: " <<
dependency_size();
- if (offset_.x() || offset_.y ())
+ if (offset_.x() || offset_.y ())
DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")";
- DOUT << "\n";
+ DOUT << "\n";
- do_print();
- if (output)
+ do_print();
+ if (output)
output->print();
-
- DOUT << "}\n";
+
+ DOUT << "}\n";
#endif
}
Score_elem::Score_elem()
{
- transparent_b_ = empty_b_ = false;
- axis_group_l_a_[0] = axis_group_l_a_[1] =0;
- pscore_l_=0;
- offset_ = Offset (0,0);
- output = 0;
- status_ = ORPHAN;
+ transparent_b_ = empty_b_ = false;
+ axis_group_l_a_[0] = axis_group_l_a_[1] =0;
+ pscore_l_=0;
+ offset_ = Offset (0,0);
+ output = 0;
+ status_ = ORPHAN;
}
Paper_def*
Score_elem::paper() const
{
- assert (pscore_l_);
- return pscore_l_->paper_l_;
+ assert (pscore_l_);
+ return pscore_l_->paper_l_;
}
void
Score_elem::add_processing()
{
- if (status_ >= VIRGIN)
+ if (status_ >= VIRGIN)
return;
- status_ = VIRGIN;
- do_add_processing();
+ status_ = VIRGIN;
+ do_add_processing();
}
void
Score_elem::pre_processing()
{
- if (status_ >= PRECALCED)
+ if (status_ >= PRECALCED)
return;
- assert (status_ != PRECALCING); // cyclic dependency
- status_ = PRECALCING;
+ assert (status_ != PRECALCING); // cyclic dependency
+ status_ = PRECALCING;
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->pre_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->pre_processing();
-
- do_pre_processing();
- status_ = PRECALCED;
+
+ do_pre_processing();
+ status_ = PRECALCED;
}
void
Score_elem::breakable_col_processing()
{
- if (status_ >= PREBROKEN)
+ if (status_ >= PREBROKEN)
return;
- if (status_== PREBREAKING) {
+ if (status_== PREBREAKING)
+ {
status_ = PREBROKEN;
return ;
}
- status_ = PREBREAKING;
+ status_ = PREBREAKING;
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->breakable_col_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->breakable_col_processing();
-
- do_breakable_col_processing();
- status_ = PREBROKEN;
+
+ do_breakable_col_processing();
+ status_ = PREBROKEN;
}
void
Score_elem::break_processing()
{
- if (status_ >= BROKEN)
+ if (status_ >= BROKEN)
return;
- if (status_ == BREAKING) {
+ if (status_ == BREAKING)
+ {
status_ = BROKEN;
return;
}
- status_ = BREAKING;
+ status_ = BREAKING;
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->break_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->break_processing();
-
+
-
- do_break_processing();
- status_ = BROKEN;
+
+ do_break_processing();
+ status_ = BROKEN;
}
void
Score_elem::do_break_processing()
{
- handle_broken_dependencies();
+ handle_broken_dependencies();
}
void
Score_elem::post_processing()
{
- if (status_ >= POSTCALCED)
+ if (status_ >= POSTCALCED)
return;
- assert (status_ != POSTCALCING);// cyclic dependency
- status_=POSTCALCING;
+ assert (status_ != POSTCALCING);// cyclic dependency
+ status_=POSTCALCING;
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->post_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->post_processing();
-
+
- do_post_processing();
- status_=POSTCALCED;
+ do_post_processing();
+ status_=POSTCALCED;
}
Score_elem::Status
Score_elem::status()const
{
- return status_;
+ return status_;
}
void
Score_elem::molecule_processing()
{
- if (status_ >= OUTPUT)
+ if (status_ >= OUTPUT)
return;
- status_ = OUTPUT; // do it only once.
+ status_ = OUTPUT; // do it only once.
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->molecule_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->molecule_processing();
-
+
- if (transparent_b_)
+ if (transparent_b_)
return ;
- output= brew_molecule_p();
+ output= brew_molecule_p();
}
/*
void
Score_elem::do_breakable_col_processing()
{
- handle_prebroken_dependencies();
+ handle_prebroken_dependencies();
}
void
Molecule*
Score_elem::brew_molecule_p()const
{
- Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0))));
- return new Molecule (a);
+ Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0))));
+ return new Molecule (a);
}
Line_of_score *
Score_elem::line_l()const
{
- return 0;
+ return 0;
}
/*
void
Score_elem::remove_dependency (Score_elem*e)
{
- remove_edge_out (e);
- substitute_dependency (e, 0);
+ remove_edge_out (e);
+ substitute_dependency (e, 0);
}
void
Score_elem::add_dependency (Score_elem*e)
{
- Directed_graph_node::add (e);
+ Directed_graph_node::add (e);
}
void
Score_elem::substitute_dependency (Score_elem* old, Score_elem* new_l)
{
- do_substitute_dependency (old,new_l);
- old->do_substitute_dependent (this, 0);
+ do_substitute_dependency (old,new_l);
+ old->do_substitute_dependent (this, 0);
}
void
Score_elem::junk_dependencies()
{
- while ( dependency_size()) {
+ while ( dependency_size())
+ {
remove_edge_out (dependency (0));
}
}
void
Score_elem::handle_broken_dependencies()
{
- Line_of_score *line = line_l();
- if (!line)
+ Line_of_score *line = line_l();
+ if (!line)
return;
- Link_array<Score_elem> remove_us_arr;
- for (int i=0; i < dependency_size(); i++) {
+ Link_array<Score_elem> remove_us_arr;
+ for (int i=0; i < dependency_size(); i++)
+ {
Score_elem * elt = dependency (i);
- if (elt->line_l() != line){
- if (elt->spanner()) {
+ if (elt->line_l() != line)
+ {
+ if (elt->spanner())
+ {
Spanner * sp = elt->spanner();
Spanner * broken = sp->find_broken_piece (line);
substitute_dependency (sp, broken);
add_dependency (broken);
- } else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b ()
- && elt->item()->break_status_i () == 0) {
+ }
+ else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b ()
+ && elt->item()->break_status_i () == 0)
+ {
Item * my_item = elt->item()->find_prebroken_piece (line);
substitute_dependency (elt, my_item);
if (my_item)
add_dependency (my_item);
- }
+ }
remove_us_arr.push (elt);
- }
+ }
}
- remove_us_arr.default_sort();
- remove_us_arr.uniq();
- for (int i=0; i <remove_us_arr.size(); i++)
+ remove_us_arr.default_sort();
+ remove_us_arr.uniq();
+ for (int i=0; i <remove_us_arr.size(); i++)
remove_dependency (remove_us_arr[i]);
- status_ = BROKEN;
+ status_ = BROKEN;
}
/*
void
Score_elem::handle_prebroken_dependencies()
{
- Link_array<Score_elem> old_arr, new_arr;
-
- for (int i=0; i < dependency_size(); i++) {
+ Link_array<Score_elem> old_arr, new_arr;
+
+ for (int i=0; i < dependency_size(); i++)
+ {
Score_elem * elt = dependency (i);
Item *it_l = elt->item();
if (it_l && it_l->breakable_b_)
- if (item()) {
+ if (item())
+ {
Score_elem *new_l = it_l->find_prebroken_piece (item()->pcol_l_);
- if (new_l != elt) {
+ if (new_l != elt)
+ {
new_arr.push (new_l);
old_arr.push (elt);
- }
- }else {
+ }
+ }else
+ {
new_arr.push (it_l->broken_to_a_[0]);
old_arr.push (0);
old_arr.push (0);
new_arr.push (it_l->broken_to_a_[1]);
- }
+ }
}
-
- for (int i=0; i < old_arr.size(); i++)
+
+ for (int i=0; i < old_arr.size(); i++)
if (old_arr[i])
substitute_dependency (old_arr[i], new_arr[i]);
- status_ = PREBROKEN;
+ status_ = PREBROKEN;
}
void
Score_elem::unlink_all()
{
- for (int i=0; i < dependency_size(); i++)
+ for (int i=0; i < dependency_size(); i++)
dependency (i)->unlink_all();
- Link_array<Score_elem> extra (get_extra_dependencies());
- for (int i=0; i < extra.size(); i++)
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
extra[i]->unlink_all();
-
- junk_links();
- axis_group_l_a_[0] = axis_group_l_a_[1] =0;
+
+ junk_links();
+ axis_group_l_a_[0] = axis_group_l_a_[1] =0;
}
void
Score_elem::unlink()
{
- do_unlink();
- while ( dependency_size()) {
+ do_unlink();
+ while ( dependency_size())
+ {
do_substitute_dependency (dependency (0),0);
remove_edge_out_idx (0);
}
- while ( dependent_size()) {
+ while ( dependent_size())
+ {
dependent (0)->remove_dependency (this);
}
- for (int j=0; j < 2; j++)
+ for (int j=0; j < 2; j++)
if ( axis_group_l_a_[j])
axis_group_l_a_[j]->remove_element (this);
Score_elem::OK()const
{
#ifndef NDEBUG
- for (int i=0; i < dependency_size(); i++) {
+ for (int i=0; i < dependency_size(); i++)
+ {
dependency (i)->OK();
}
#endif
Link_array<Score_elem>
Score_elem::get_extra_dependencies()const
{
- Link_array<Score_elem> empty;
- return empty;
+ Link_array<Score_elem> empty;
+ return empty;
}
void
Score_engraver::set_score (Score *s)
{
- Global_translator::set_score (s);
- scoreline_l_ = s->pscore_p_->super_elem_l_->line_of_score_l_;
+ Global_translator::set_score (s);
+ scoreline_l_ = s->pscore_p_->super_elem_l_->line_of_score_l_;
}
Score_engraver::Score_engraver()
{
- disallow_break_b_ = false;
- scoreline_l_ =0;
- command_column_l_ =0;
- musical_column_l_ =0;
- breaks_i_ =0;
+ disallow_break_b_ = false;
+ scoreline_l_ =0;
+ command_column_l_ =0;
+ musical_column_l_ =0;
+ breaks_i_ =0;
}
void
Score_engraver::prepare (Moment w)
{
- set_columns (new Score_column (w), new Score_column (w));
-
-
- disallow_break_b_ = false;
- post_move_processing();
+ set_columns (new Score_column (w), new Score_column (w));
+
+
+ disallow_break_b_ = false;
+ post_move_processing();
}
void
Score_engraver::finish()
{
- if ( (breaks_i_%8))
+ if ( (breaks_i_%8))
*mlog << "[" << breaks_i_ << "]" << flush;
- check_removal();
- removal_processing();
+ check_removal();
+ removal_processing();
}
void
Score_engraver::do_creation_processing()
{
- scoreline_l_->left_col_l_ = get_staff_info().command_pcol_l ();
- scoreline_l_->left_col_l_ ->set_breakable();
- Engraver_group_engraver::do_creation_processing();
+ scoreline_l_->left_col_l_ = get_staff_info().command_pcol_l ();
+ scoreline_l_->left_col_l_ ->set_breakable();
+ Engraver_group_engraver::do_creation_processing();
}
void
Score_engraver::do_removal_processing()
{
- Engraver_group_engraver::do_removal_processing();
- scoreline_l_->right_col_l_ = get_staff_info().command_pcol_l ();
- scoreline_l_->right_col_l_ ->set_breakable();
- typeset_all();
- set_columns (0,0);
+ Engraver_group_engraver::do_removal_processing();
+ scoreline_l_->right_col_l_ = get_staff_info().command_pcol_l ();
+ scoreline_l_->right_col_l_ ->set_breakable();
+ typeset_all();
+ set_columns (0,0);
}
void
Score_engraver::process()
{
- process_requests();
+ process_requests();
do_announces();
pre_move_processing();
check_removal();
void
Score_engraver::announce_element (Score_elem_info info)
{
- announce_info_arr_.push (info);
- info.origin_grav_l_arr_.push (this);
-
+ announce_info_arr_.push (info);
+ info.origin_grav_l_arr_.push (this);
+
}
void
Score_engraver::do_announces()
{
- /* All elements are propagated to the top upon announcement. If
- something was created during one run of
- Engraver_group_engraver::do_announces, then
- announce_info_arr_.size() will be nonzero again
+ /* All elements are propagated to the top upon announcement. If
+ something was created during one run of
+ Engraver_group_engraver::do_announces, then
+ announce_info_arr_.size() will be nonzero again
- */
- while (announce_info_arr_.size()) {
+ */
+ while (announce_info_arr_.size())
+ {
for (int i=0; i <announce_info_arr_.size(); i++)
/*
TODO
More subtle spacing
*/
- if (announce_info_arr_[i].req_l_) {
+ if (announce_info_arr_[i].req_l_)
+ {
Musical_req *m = announce_info_arr_[i].req_l_->musical();
- if (m && m->rhythmic()) {
+ if (m && m->rhythmic())
+ {
musical_column_l_->add_duration (m->duration());
- }
- }
+ }
+ }
Engraver_group_engraver::do_announces();
}
}
void
Score_engraver::typeset_element (Score_elem *elem_p)
{
- if ( elem_p->item() && elem_p->item ()->breakable_b_) {
+ if ( elem_p->item() && elem_p->item ()->breakable_b_)
+ {
nobreak_item_p_arr_.push (elem_p->item());
- } else
+ }
+ else
musical_item_p_arr_.push (elem_p);
}
void
Score_engraver::typeset_all()
{
- PCol * c= get_staff_info().command_pcol_l ();
- Paper_score *ps_l = score_l_->pscore_p_;
+ PCol * c= get_staff_info().command_pcol_l ();
+ Paper_score *ps_l = score_l_->pscore_p_;
- for (int i =0; i < nobreak_item_p_arr_.size(); i++) {
+ for (int i =0; i < nobreak_item_p_arr_.size(); i++)
+ {
ps_l->typeset_item (nobreak_item_p_arr_[i], c);
// should get rid of this.. .
scoreline_l_->add_dependency (nobreak_item_p_arr_[i]);
}
- nobreak_item_p_arr_.clear();
-
- for (int i=0; i < musical_item_p_arr_.size(); i++) {
+ nobreak_item_p_arr_.clear();
+
+ for (int i=0; i < musical_item_p_arr_.size(); i++)
+ {
PCol* m = get_staff_info().musical_pcol_l ();
Score_elem *elem_p = musical_item_p_arr_[i];
scoreline_l_->add (elem_p);
- if (elem_p->spanner()) {
+ if (elem_p->spanner())
+ {
ps_l->typeset_unbroken_spanner (elem_p->spanner());
- } else if (elem_p->item()) {
+ }
+ else if (elem_p->item())
+ {
ps_l->typeset_item (elem_p->item(), m);
- } else
+ }
+ else
assert (false);
}
- musical_item_p_arr_.clear();
+ musical_item_p_arr_.clear();
}
void
Score_engraver::do_pre_move_processing()
{
- if ( !disallow_break_b_){
+ if ( !disallow_break_b_)
+ {
get_staff_info().command_pcol_l ()->set_breakable ();
breaks_i_ ++;
if ( ! (breaks_i_%8))
*mlog << "[" << breaks_i_ << "]" << flush;
}
- // this generates all items.
- Engraver_group_engraver::do_pre_move_processing();
-
- typeset_all();
+ // this generates all items.
+ Engraver_group_engraver::do_pre_move_processing();
+
+ typeset_all();
}
void
Score_engraver::set_columns (Score_column *new_command_l,
Score_column *new_musical_l)
{
- if ( command_column_l_ && command_column_l_->used_b())
+ if ( command_column_l_ && command_column_l_->used_b())
score_l_->pscore_p_->add (command_column_l_);
- else {
+ else
+ {
delete command_column_l_ ;
command_column_l_ =0;
}
- if (new_command_l) {
+ if (new_command_l)
+ {
command_column_l_ = new_command_l;
command_column_l_->musical_b_ = false;
}
- if ( musical_column_l_ && musical_column_l_->used_b())
+ if ( musical_column_l_ && musical_column_l_->used_b())
score_l_->pscore_p_->add (musical_column_l_);
- else {
+ else
+ {
delete musical_column_l_;
musical_column_l_ = 0;
}
-
- if (new_musical_l) {
+
+ if (new_musical_l)
+ {
musical_column_l_ = new_musical_l;
musical_column_l_->musical_b_ = true;
}
Staff_info
Score_engraver::get_staff_info()const
{
- Staff_info inf;
+ Staff_info inf;
- inf.command_l_ = command_column_l_;
- inf.musical_l_ = musical_column_l_;
- return inf;
+ inf.command_l_ = command_column_l_;
+ inf.musical_l_ = musical_column_l_;
+ return inf;
}
Paper_def*
Score_engraver::paper()const
{
- return score_l_->paper_p_;
+ return score_l_->paper_p_;
}
bool
Score_engraver::do_try_request (Request*r)
{
- bool gotcha = Engraver_group_engraver::do_try_request (r);
- if ( !gotcha && r->command() && r->command ()->disallowbreak ())
+ bool gotcha = Engraver_group_engraver::do_try_request (r);
+ if ( !gotcha && r->command() && r->command ()->disallowbreak ())
disallow_break_b_ = true;
- return gotcha;
+ return gotcha;
}
IMPLEMENT_IS_TYPE_B1(Score_engraver,Engraver_group_engraver);
Score_horizontal_align_engraver::Score_horizontal_align_engraver()
{
- halign_p_ =0;
+ halign_p_ =0;
}
void
Score_horizontal_align_engraver::do_pre_move_processing()
{
- if (halign_p_) {
+ if (halign_p_)
+ {
typeset_element (halign_p_);
halign_p_ =0;
}
void
Score_horizontal_align_engraver::acknowledge_element (Score_elem_info i)
{
- Engraver* reg = i.origin_grav_l_arr_[0];
- if (reg->is_type_b (
+ Engraver* reg = i.origin_grav_l_arr_[0];
+ if (reg->is_type_b (
Score_align_engraver::static_name()))
- {
+ {
Score_align_engraver * align_grav_l = (Score_align_engraver*) reg;
- if (!halign_p_) {
+ if (!halign_p_)
+ {
halign_p_ = new Break_align_item;
halign_p_->breakable_b_ = true;
announce_element (Score_elem_info (halign_p_,0));
- }
+ }
Item * it = i.elem_l_->item();
if (align_grav_l->type_ch_C_ == Bar::static_name())
halign_p_->center_l_ = it;
Translator*
Score_performer::ancestor_l (int l)
{
- return Global_translator::ancestor_l (l);
+ return Global_translator::ancestor_l (l);
}
int
Score_performer::depth_i() const
{
- return Global_translator::depth_i();
+ return Global_translator::depth_i();
}
void
Score_performer::finish()
{
- Performer_group_performer::do_removal_processing();
+ Performer_group_performer::do_removal_processing();
}
void
Score_performer::play (Audio_element * p)
{
- if (p->is_type_b (Audio_item::static_name())) {
+ if (p->is_type_b (Audio_item::static_name()))
+ {
audio_column_l_->add ((Audio_item*)p);
- } else if (p->is_type_b (Audio_staff::static_name())) {
+ }
+ else if (p->is_type_b (Audio_staff::static_name()))
+ {
score_l_->audio_score_p_->add_staff ((Audio_staff*)p);
}
- score_l_->audio_score_p_->add (p);
+ score_l_->audio_score_p_->add (p);
}
void
Score_performer::prepare (Moment m)
{
- now_mom_ = m;
- audio_column_l_ = new Audio_column (m);
- score_l_->audio_score_p_->add (audio_column_l_);
+ now_mom_ = m;
+ audio_column_l_ = new Audio_column (m);
+ score_l_->audio_score_p_->add (audio_column_l_);
}
void
Score_performer::process()
{
- process_requests();
+ process_requests();
}
void
Score_performer::set_score (Score* score_l)
{
- Global_translator::set_score (score_l);
+ Global_translator::set_score (score_l);
}
int
Score_performer::get_tempo_i()const
{
- return score_l_->midi_p_->get_tempo_i (Moment (1, 4));
+ return score_l_->midi_p_->get_tempo_i (Moment (1, 4));
}
#include "music-iterator.hh"
#include "music.hh"
#include "global-translator.hh"
+#include "header.hh"
extern String default_out_fn;
Score::Score()
{
- pscore_p_=0;
- audio_score_p_ = 0;
- paper_p_ = 0;
- midi_p_ = 0;
- errorlevel_i_ = 0;
+ header_p_ =0;
+ pscore_p_=0;
+ audio_score_p_ = 0;
+ paper_p_ = 0;
+ midi_p_ = 0;
+ errorlevel_i_ = 0;
}
Score::Score (Score const &s)
{
- assert (!pscore_p_);
- music_p_ = s.music_p_->clone();
- midi_p_ = new Midi_def (*s.midi_p_);
- paper_p_ = new Paper_def (*s.paper_p_);
+ assert (!pscore_p_);
+ music_p_ = s.music_p_->clone();
+ midi_p_ = new Midi_def (*s.midi_p_);
+ paper_p_ = new Paper_def (*s.paper_p_);
+ header_p_ = new Header(*s.header_p_);
}
Score::~Score()
{
- delete music_p_;
- delete pscore_p_;
- delete audio_score_p_;
- delete paper_p_;
- delete midi_p_;
+ delete header_p_;
+ delete music_p_;
+ delete pscore_p_;
+ delete audio_score_p_;
+ delete paper_p_;
+ delete midi_p_;
}
void
Score::run_translator (Global_translator * trans_l)
{
- trans_l->set_score (this);
- Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_,
+ trans_l->set_score (this);
+ Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_,
trans_l);
- iter->construct_children();
+ iter->construct_children();
- if ( ! iter->ok()) {
+ if ( ! iter->ok())
+ {
delete iter;
warning ("Need music in a score");
errorlevel_i_ =1;
return ;
}
-
- trans_l->start();
-
- while ( iter->ok() || trans_l->moments_left_i ()) {
+
+ trans_l->start();
+
+ while ( iter->ok() || trans_l->moments_left_i ())
+ {
Moment w = infinity_mom;
- if (iter->ok()) {
+ if (iter->ok())
+ {
w = iter->next_moment();
DOUT << w;
iter->print();
- }
+ }
trans_l->modify_next (w);
trans_l->prepare (w);
trans_l->print();
iter->process_and_next (w);
trans_l->process();
}
- delete iter;
- trans_l->finish();
+ delete iter;
+ trans_l->finish();
}
void
Score::process()
{
- print();
- paper();
- midi();
+ print();
+ paper();
+ midi();
}
void
Score::midi()
{
- if ( !midi_p_)
+ if ( !midi_p_)
return;
-
- *mlog << "\nCreating MIDI elements ..." << flush;
- audio_score_p_ = new Audio_score (this);
-
- Global_translator* score_trans= midi_p_->get_global_translator_p();
- run_translator (score_trans);
- delete score_trans;
-
- if (errorlevel_i_){
+
+ *mlog << "\nCreating MIDI elements ..." << flush;
+ audio_score_p_ = new Audio_score (this);
+
+ Global_translator* score_trans= midi_p_->get_global_translator_p();
+ run_translator (score_trans);
+ delete score_trans;
+
+ if (errorlevel_i_)
+ {
// should we? hampers debugging.
warning ("Errors found, /*not processing score*/");
// return;
}
- *mlog << endl;
+ *mlog << endl;
- midi_output();
+ midi_output();
}
-
+
void
Score::paper()
{
- if (!paper_p_)
+ if (!paper_p_)
return;
-
- *mlog << "\nCreating elements ..." << flush;
- pscore_p_ = new Paper_score (paper_p_);
-
- Global_translator * score_trans= paper_p_->get_global_translator_p();
- run_translator (score_trans);
- delete score_trans;
-
- if (errorlevel_i_) {
+
+ *mlog << "\nCreating elements ..." << flush;
+ pscore_p_ = new Paper_score (paper_p_);
+
+ Global_translator * score_trans= paper_p_->get_global_translator_p();
+ run_translator (score_trans);
+ delete score_trans;
+
+ if (errorlevel_i_)
+ {
// should we? hampers debugging.
warning ("Errors found, /*not processing score*/");
// return;
}
-
- *mlog << endl;
- pscore_p_->process();
+
+ *mlog << endl;
+ pscore_p_->process();
- // output
- paper_output();
+ // output
+ paper_output();
}
void
Score::midi_output()
{
- if ( midi_p_->outfile_str_ == "")
+ if ( midi_p_->outfile_str_ == "")
midi_p_->outfile_str_ = default_out_fn + ".midi";
- Midi_stream midi_stream (midi_p_->outfile_str_);
- *mlog << "MIDI output to " << midi_p_->outfile_str_ << " ..." << endl;
+ Midi_stream midi_stream (midi_p_->outfile_str_);
+ *mlog << "MIDI output to " << midi_p_->outfile_str_ << " ..." << endl;
- audio_score_p_->output (midi_stream);
- *mlog << endl;
+ audio_score_p_->output (midi_stream);
+ *mlog << endl;
}
void
Score::paper_output()
{
- if (paper_p_->outfile_str_=="")
+ if (paper_p_->outfile_str_=="")
paper_p_->outfile_str_ = default_out_fn + ".tex";
- if ( errorlevel_i_) {
+ if ( errorlevel_i_)
+ {
*mlog << "lilypond: warning: no output to: " << paper_p_->outfile_str_
<< " (errorlevel=" << errorlevel_i_ << ")" << endl;
- return;
+ return;
}
- *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n";
-
- Tex_stream the_output (paper_p_->outfile_str_);
-
- the_output << "% outputting Score, defined at: " <<
+ *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n";
+
+ Tex_stream the_output (paper_p_->outfile_str_);
+
+ the_output << "% outputting Score, defined at: " <<
location_str() << "\n";
- pscore_p_->output (the_output);
+ pscore_p_->output (the_output);
}
void
Score::print() const
{
#ifndef NPRINT
- DOUT << "score {\n";
- music_p_->print();
- if (midi_p_)
+ DOUT << "score {\n";
+ music_p_->print();
+ if (midi_p_)
midi_p_->print();
-
- DOUT << "}\n";
+
+ DOUT << "}\n";
#endif
}
void
Score::set (Paper_def *pap_p)
{
- delete paper_p_;
- paper_p_ = pap_p;
+ delete paper_p_;
+ paper_p_ = pap_p;
}
void
Score::set (Midi_def* midi_p)
{
- delete midi_p_;
- midi_p_ = midi_p;
+ delete midi_p_;
+ midi_p_ = midi_p;
}
String
Line_of_score::TeX_string() const
{
- String s ("\\hbox{%<- line of score\n");
- if (error_mark_b_)
+ String s ("\\hbox{%<- line of score\n");
+ if (error_mark_b_)
s+= "\\scorelineerrormark";
-
-
- Real lastpos = cols[0]->hpos_f_;
- for (int i=0; i < cols.size(); i++){
+
+
+ Real lastpos = cols[0]->hpos_f_;
+ for (int i=0; i < cols.size(); i++)
+ {
PCol* col_l= cols[i];
// all items in the current line & staff.
String chunk_str;
Link_array<Score_elem> elems;
- if (col_l->error_mark_b_) {
+ if (col_l->error_mark_b_)
+ {
chunk_str += String ("\\columnerrormark");
- }
+ }
// now output the items.
- for (iter_top (col_l->its,j); j.ok(); j++) {
+ for (iter_top (col_l->its,j); j.ok(); j++)
+ {
elems.push (j);
- }
+ }
// spanners.
- for (iter_top (col_l->starters,j); j.ok(); j++) {
+ for (iter_top (col_l->starters,j); j.ok(); j++)
+ {
if (j->name() != name ())
elems.push (j);
- }
+ }
- for (int j =0; j< elems.size(); j++) {
+ for (int j =0; j< elems.size(); j++)
+ {
Offset o = elems[j]->absolute_offset();
o[X_AXIS] += cols[i]->hpos_f_;
s += elems[j]->TeX_string_without_offset (o);
- }
+ }
}
- s += "}";
- return s;
+ s += "}";
+ return s;
}
Line_of_score::Line_of_score()
{
- error_mark_b_ = 0;
+ error_mark_b_ = 0;
}
void
Line_of_score::add (Score_elem*e)
{
- // avoid excess dependencies.
- if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
+ // avoid excess dependencies.
+ if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
add_dependency (e);
}
bool
Line_of_score::contains_b (PCol const* c)const
{
- return cols.find_l ((PCol*)c);
+ return cols.find_l ((PCol*)c);
}
void
Line_of_score::set_breaking (Array<Col_hpositions> const &breaking)
{
- for (int j=0; j < breaking.size(); j++) {
+ for (int j=0; j < breaking.size(); j++)
+ {
const Array<PCol*> &curline (breaking[j].cols);
const Array<PCol*> &errors (breaking[j].error_col_l_arr_);
const Array<Real> &config (breaking[j].config);
Line_of_score *line_l=0;
Line_of_score *line_p =0;
- if (breaking.size() >1) {
+ if (breaking.size() >1)
+ {
line_p = (Line_of_score*)clone()->spanner ();
line_p->copy_dependencies (*this);
line_l = line_p;
- } else
+ }
+ else
line_l = this;
((Array<PCol*> &)line_l->cols) = curline;
line_l->left_col_l_ = curline[0];
line_l->right_col_l_= curline.top();
- if (line_p) {
+ if (line_p)
+ {
pscore_l_->typeset_broken_spanner (line_p);
broken_into_l_arr_.push (line_p);
- }
+ }
- for (int i=0; i < curline.size(); i++){
+ for (int i=0; i < curline.size(); i++)
+ {
curline[i]->hpos_f_ = config[i];
curline[i]->line_l_ = (Line_of_score*)line_l;
- }
+ }
}
}
Link_array<Line_of_score>
Line_of_score::get_lines()const
{
- Link_array<Line_of_score> ret;
+ Link_array<Line_of_score> ret;
- if (broken_into_l_arr_.size())
- for (int i=0; i < broken_into_l_arr_.size(); i++) {
+ if (broken_into_l_arr_.size())
+ for (int i=0; i < broken_into_l_arr_.size(); i++)
+ {
ret.push ((Line_of_score*)broken_into_l_arr_[i]);
- }
- else
+ }
+ else
ret.push ((Line_of_score*)this); // ugh
-
- return ret;
+
+ return ret;
}
void
Line_of_score::do_print()const
{
- Spanner::do_print();
+ Spanner::do_print();
}
Interval
Line_of_score::do_width()const
{
- return Spanner::do_width();
+ return Spanner::do_width();
}
void
do_scores()
{
- for (int i=0; i < score_array_global.size(); i++) {
+ for (int i=0; i < score_array_global.size(); i++)
+ {
Score *&is_p = score_array_global[i];
- if (only_midi) {
+ if (only_midi)
+ {
delete is_p->paper_p_;
is_p->paper_p_ = 0;
- }
+ }
- if (is_p->errorlevel_i_) {
+ if (is_p->errorlevel_i_)
+ {
is_p->warning ("Score contains errors. Will not process it. ");
exit_status_i_ |= 1;
- } else {
+ }
+ else
+ {
is_p->print();
is_p->process();
- }
+ }
delete is_p;
is_p =0;
}
- score_array_global.clear();
+ score_array_global.clear();
}
void
add_score (Score * s)
{
- score_array_global.push (s);
+ score_array_global.push (s);
}
void
set_default_output (String s)
{
- default_out_fn = s;
+ default_out_fn = s;
}
void
Script_column::add (Script*s_l)
{
- script_l_arr_.push (s_l);
- add_dependency (s_l);
- add_element (s_l);
+ script_l_arr_.push (s_l);
+ add_dependency (s_l);
+ add_element (s_l);
}
Script_column::do_print()const
{
#ifndef NPRINT
- DOUT << "scripts: " << script_l_arr_.size() << '\n';
+ DOUT << "scripts: " << script_l_arr_.size() << '\n';
#endif
}
static int
idx (bool inside, int dir)
{
- int j = (dir+1);
- if ( !inside)
+ int j = (dir+1);
+ if ( !inside)
j ++;
- return j;
+ return j;
}
void
Script_column::do_pre_processing()
{
- if (!script_l_arr_.size())
+ if (!script_l_arr_.size())
return;
-
- /* up+inside, up+outside, down+inside, down+outside */
- Array<Script*> placed_l_arr_a[4];
- for (int i=0; i < script_l_arr_.size(); i++) {
+
+ /* up+inside, up+outside, down+inside, down+outside */
+ Array<Script*> placed_l_arr_a[4];
+ for (int i=0; i < script_l_arr_.size(); i++)
+ {
Script*s_l = script_l_arr_[i];
placed_l_arr_a[idx (s_l->inside_staff_b_ , s_l->dir_i_) ].push (s_l);
}
-
- for (int j =0; j <4; j++) {
+
+ for (int j =0; j <4; j++)
+ {
placed_l_arr_a[j].sort (Script::compare);
}
- for (int j =0; j < 4; j++) {
+ for (int j =0; j < 4; j++)
+ {
if (placed_l_arr_a[j].size())
for (int i=0; i < support_l_arr_.size(); i++)
placed_l_arr_a[j][0]->add_support (support_l_arr_[i]);
}
-
- Item * support_l=0;
- int j = 0;
- for (; j < 2; j++) {
- for (int i=0; i < placed_l_arr_a[j].size(); i++) {
+
+ Item * support_l=0;
+ int j = 0;
+ for (; j < 2; j++)
+ {
+ for (int i=0; i < placed_l_arr_a[j].size(); i++)
+ {
if (support_l)
placed_l_arr_a[j][i]->add_support (support_l);
support_l = placed_l_arr_a[j][i];
- }
+ }
}
- support_l = 0;
- for (; j < 4; j++) {
- for (int i=0; i < placed_l_arr_a[j].size(); i++) {
+ support_l = 0;
+ for (; j < 4; j++)
+ {
+ for (int i=0; i < placed_l_arr_a[j].size(); i++)
+ {
if (support_l)
placed_l_arr_a[j][i]->add_support (support_l);
support_l = placed_l_arr_a[j][i];
- }
+ }
}
}
void
Script_column::add_support (Item*i_l)
{
- support_l_arr_.push (i_l);
- add_dependency (i_l);
- add_element (i_l);
+ support_l_arr_.push (i_l);
+ add_dependency (i_l);
+ add_element (i_l);
}
void
Script_column::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
- if (o->item()) {
+ if (o->item())
+ {
script_l_arr_.substitute ((Script*)o->item(),(Script*) (n?n->item ():0));
support_l_arr_.substitute (o->item(), (n?n->item ():0));
}
Script_def::Script_def()
{
- inside_staff_b_ = false;
- symidx_str_ = "unknown" ;
- rel_stem_dir_i_ =0;
- staff_dir_i_ = -1;
- invertsym_b_ = 0;
- priority_i_ =0;
+ inside_staff_b_ = false;
+ symidx_str_ = "unknown" ;
+ rel_stem_dir_i_ =0;
+ staff_dir_i_ = -1;
+ invertsym_b_ = 0;
+ priority_i_ =0;
}
void
Script_def::set_from_input (String idx, bool follow, int stem, int staff ,bool invert, int priority_i)
{
- inside_staff_b_ = follow;
- symidx_str_ = idx ;
- rel_stem_dir_i_ =stem;
- staff_dir_i_ = staff;
- invertsym_b_ = invert;
- priority_i_ =priority_i;
+ inside_staff_b_ = follow;
+ symidx_str_ = idx ;
+ rel_stem_dir_i_ =stem;
+ staff_dir_i_ = staff;
+ invertsym_b_ = invert;
+ priority_i_ =priority_i;
}
Script_def::do_print() const
{
#ifndef NPRINT
- DOUT << "Script_def{ idx: " << symidx_str_
+ DOUT << "Script_def{ idx: " << symidx_str_
<< " direction, stem: " << rel_stem_dir_i_ << " staff : " << staff_dir_i_ << "}\n";
#endif
}
bool
Script_def::do_equal_b (General_script_def const *g)const
{
- Script_def const * c = (Script_def const*) g;
- return (symidx_str_ == c->symidx_str_ &&
+ Script_def const * c = (Script_def const*) g;
+ return (symidx_str_ == c->symidx_str_ &&
rel_stem_dir_i_ == c->rel_stem_dir_i_&&
staff_dir_i_ == c->staff_dir_i_&&
invertsym_b_ == c->invertsym_b_);
int
Script_def::staff_dir_i() const
{
- return staff_dir_i_;
+ return staff_dir_i_;
}
int
Script_def::rel_stem_dir_i() const
{
- return rel_stem_dir_i_;
+ return rel_stem_dir_i_;
}
bool
Script_def::inside_b() const
{
- return inside_staff_b_;
+ return inside_staff_b_;
}
Atom
Script_def::get_atom (Paper_def *p , int d)const
{
- String preidx_str ="";
- if (invertsym_b_&& d < 0)
+ String preidx_str ="";
+ if (invertsym_b_&& d < 0)
preidx_str = "-";
- return p->lookup_l()->script (preidx_str + symidx_str_);
+ return p->lookup_l()->script (preidx_str + symidx_str_);
}
int
Script_def::priority_i()const
{
- return priority_i_;
+ return priority_i_;
}
-
-
+
+
Script_engraver::Script_engraver()
{
- do_post_move_processing();
+ do_post_move_processing();
}
bool
Script_engraver::do_try_request (Request *r_l)
{
- if (!r_l->musical() || ! r_l->musical ()->musicalscript ())
+ if (!r_l->musical() || ! r_l->musical ()->musicalscript ())
return false ;
-
- for (int i=0; i < script_req_l_arr_.size(); i++) {
+
+ for (int i=0; i < script_req_l_arr_.size(); i++)
+ {
if ( r_l->equal_b (script_req_l_arr_[i]))
return true;
}
- script_req_l_arr_.push (r_l->script());
-
- return true;
+ script_req_l_arr_.push (r_l->script());
+
+ return true;
}
void
Script_engraver::do_process_requests()
{
- for (int i=0; i < script_req_l_arr_.size(); i++){
+ for (int i=0; i < script_req_l_arr_.size(); i++)
+ {
Script_req* l=script_req_l_arr_[i];
Script *p =new Script;
p->dir_i_ = l->dir_i_;
void
Script_engraver::do_pre_move_processing()
{
- Staff_symbol* s_l = get_staff_info().staff_sym_l_;
- for (int i=0; i < script_p_arr_.size(); i++) {
+ Staff_symbol* s_l = get_staff_info().staff_sym_l_;
+ for (int i=0; i < script_p_arr_.size(); i++)
+ {
Script*script_p = script_p_arr_[i];
script_p->set_staffsym (s_l);
typeset_element (script_p);
}
- script_p_arr_.clear();
+ script_p_arr_.clear();
}
void
Script_engraver::do_post_move_processing()
{
- script_req_l_arr_.clear();
+ script_req_l_arr_.clear();
}
Script::do_print() const
{
#ifndef NPRINT
- specs_l_->print();
+ specs_l_->print();
#endif
}
void
Script::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
- Staff_side::do_substitute_dependency (o,n);
- if (o == stem_l_) {
+ Staff_side::do_substitute_dependency (o,n);
+ if (o == stem_l_)
+ {
stem_l_ = n ? (Stem*)n->item() : 0;
}
}
void
Script::set_stem (Stem*st_l)
{
- stem_l_ = st_l;
- add_support (st_l);
+ stem_l_ = st_l;
+ add_support (st_l);
}
Script::Script()
{
- specs_l_ = 0;
- inside_staff_b_ = false;
- stem_l_ = 0;
- dir_i_ = 0;
+ specs_l_ = 0;
+ inside_staff_b_ = false;
+ stem_l_ = 0;
+ dir_i_ = 0;
}
void
Script::set_default_dir()
{
- int s_i=specs_l_->rel_stem_dir_i();
- if (s_i) {
+ int s_i=specs_l_->rel_stem_dir_i();
+ if (s_i)
+ {
if (stem_l_)
dir_i_ = stem_l_->dir_i_ * s_i;
- else{
+ else
+ {
specs_l_->warning ("Script needs stem direction");
dir_i_ = -1;
- }
- } else {
+ }
+ }
+ else
+ {
dir_i_ =specs_l_->staff_dir_i();
}
- assert (dir_i_);
+ assert (dir_i_);
}
Interval
Script::do_width() const
{
- return specs_l_->get_atom (paper(), dir_i_).extent ().x ();
+ return specs_l_->get_atom (paper(), dir_i_).extent ().x ();
}
void
Script::do_pre_processing()
{
- if (breakable_b_ && break_status_i() != 1) {
+ if (breakable_b_ && break_status_i() != 1)
+ {
transparent_b_ = empty_b_ = true;
}
-
- if (!dir_i_)
+
+ if (!dir_i_)
set_default_dir();
- inside_staff_b_ = specs_l_->inside_b();
+ inside_staff_b_ = specs_l_->inside_b();
}
Interval
Script::symbol_height()const
{
- return specs_l_->get_atom (paper(), dir_i_).extent ().y ();
+ return specs_l_->get_atom (paper(), dir_i_).extent ().y ();
}
Molecule*
Script::brew_molecule_p() const
{
- Real dy = paper()->internote_f ();
-
- Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_i_));
- out->translate (dy * pos_i_, Y_AXIS);
- return out;
+ Real dy = paper()->internote_f ();
+
+ Molecule*out = new Molecule (specs_l_->get_atom (paper(), dir_i_));
+ out->translate (dy * pos_i_, Y_AXIS);
+ return out;
}
int
Script::compare (Script *const&l1, Script *const&l2)
{
- return l1->specs_l_->priority_i() - l2->specs_l_->priority_i ();
+ return l1->specs_l_->priority_i() - l2->specs_l_->priority_i ();
}
-
+
bool
Slur_engraver::do_try_request (Request *req_l)
{
- Musical_req *mus_l = req_l->musical();
- if (!mus_l || !mus_l->slur())
+ Musical_req *mus_l = req_l->musical();
+ if (!mus_l || !mus_l->slur())
return false;
- new_slur_req_l_arr_.push (mus_l->slur());
- return true;
+ new_slur_req_l_arr_.push (mus_l->slur());
+ return true;
}
void
Slur_engraver::acknowledge_element (Score_elem_info info)
{
- if (info.elem_l_->name() == Note_column::static_name ()) {
+ if (info.elem_l_->name() == Note_column::static_name ())
+ {
Note_column *col_l =(Note_column*) info.elem_l_->item() ;// ugh
for (int i = 0; i < slur_l_stack_.size(); i++)
slur_l_stack_[i]->add (col_l);
void
Slur_engraver::set_feature (Feature f)
{
- if (f.type_ == "vdir")
+ if (f.type_ == "vdir")
dir_i_ = f.value_ ;
}
*/
Slur_engraver::Slur_engraver()
{
- dir_i_ =0;
+ dir_i_ =0;
}
void
Slur_engraver::do_process_requests()
{
- Array<Slur*> start_slur_l_arr_;
- for (int i=0; i< new_slur_req_l_arr_.size(); i++) {
+ Array<Slur*> start_slur_l_arr_;
+ for (int i=0; i< new_slur_req_l_arr_.size(); i++)
+ {
Slur_req* slur_req_l = new_slur_req_l_arr_[i];
// end slur: move the slur to other array
- if (slur_req_l->spantype == Span_req::STOP) {
+ if (slur_req_l->spantype == Span_req::STOP)
+ {
if (slur_l_stack_.empty())
slur_req_l->warning ("can't find slur to end");
- else {
+ else
+ {
end_slur_l_arr_.push (slur_l_stack_.pop());
requests_arr_.pop();
- }
- } else if (slur_req_l->spantype == Span_req::START) {
+ }
+ }
+ else if (slur_req_l->spantype == Span_req::START)
+ {
// push a new slur onto stack.
//(use temp. array to wait for all slur STOPs)
Slur * s_p =new Slur;
requests_arr_.push (slur_req_l);
start_slur_l_arr_.push (s_p);
announce_element (Score_elem_info (s_p, slur_req_l));
- }
+ }
}
- for (int i=0; i < start_slur_l_arr_.size(); i++)
+ for (int i=0; i < start_slur_l_arr_.size(); i++)
slur_l_stack_.push (start_slur_l_arr_[i]);
}
void
Slur_engraver::do_pre_move_processing()
{
- for (int i = 0; i < end_slur_l_arr_.size(); i++) {
+ for (int i = 0; i < end_slur_l_arr_.size(); i++)
+ {
if (dir_i_)
end_slur_l_arr_[i]->dir_i_ = dir_i_;
typeset_element (end_slur_l_arr_[i]);
}
- end_slur_l_arr_.clear();
+ end_slur_l_arr_.clear();
}
void
Slur_engraver::do_post_move_processing()
{
- new_slur_req_l_arr_.clear();
+ new_slur_req_l_arr_.clear();
}
Slur_engraver::~Slur_engraver()
{
- for (int i=0; i < requests_arr_.size(); i++) {
+ for (int i=0; i < requests_arr_.size(); i++)
+ {
requests_arr_[i]->warning ("unterminated slur");
}
}
void
Slur::add (Note_column*n)
{
- encompass_arr_.push (n);
- add_dependency (n);
+ encompass_arr_.push (n);
+ add_dependency (n);
}
void
Slur::set_default_dir()
{
- dir_i_ = -1;
- for (int i=0; i < encompass_arr_.size(); i ++) {
- if (encompass_arr_[i]->dir_i_ < 0) {
+ dir_i_ = -1;
+ for (int i=0; i < encompass_arr_.size(); i ++)
+ {
+ if (encompass_arr_[i]->dir_i_ < 0)
+ {
dir_i_ =1;
break;
- }
+ }
}
}
void
Slur::do_pre_processing()
{
- right_col_l_ = encompass_arr_.top()->pcol_l_;
- left_col_l_ = encompass_arr_[0]->pcol_l_;
+ right_col_l_ = encompass_arr_.top()->pcol_l_;
+ left_col_l_ = encompass_arr_[0]->pcol_l_;
}
void
Slur::do_substitute_dependency (Score_elem*o, Score_elem*n)
{
- int i;
- while ((i = encompass_arr_.find_i ((Note_column*)o->item())) >=0) {
+ int i;
+ while ((i = encompass_arr_.find_i ((Note_column*)o->item())) >=0)
+ {
if (n)
encompass_arr_[i] = (Note_column*)n->item();
else
static int
Note_column_compare (Note_column *const&n1 , Note_column* const&n2)
{
- return n1->pcol_l_->rank_i() - n2->pcol_l_->rank_i ();
+ return n1->pcol_l_->rank_i() - n2->pcol_l_->rank_i ();
}
void
Slur::do_post_processing()
{
- encompass_arr_.sort (Note_column_compare);
- if (!dir_i_)
+ encompass_arr_.sort (Note_column_compare);
+ if (!dir_i_)
set_default_dir();
- Real inter_f = paper()->internote_f ();
-
- if (encompass_arr_[0]->stem_l_)
- left_pos_i_ = rint (encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f);
- else
- left_pos_i_ = rint ( encompass_arr_[0]->head_positions_interval()[dir_i_]);
-
- if (encompass_arr_.top()->stem_l_)
- right_pos_i_ = rint (encompass_arr_.top()->stem_l_->height ()[dir_i_]/inter_f);
- else
- right_pos_i_ = rint (encompass_arr_.top()->head_positions_interval ()[dir_i_]);
-
- left_pos_i_ += dir_i_;
- right_pos_i_ += dir_i_;
+ Real inter_f = paper()->internote_f ();
+
+ if (encompass_arr_[0]->stem_l_)
+ left_pos_i_ = rint (encompass_arr_[0]->stem_l_->height()[dir_i_]/inter_f);
+ else
+ left_pos_i_ = rint ( encompass_arr_[0]->head_positions_interval()[dir_i_]);
+
+ if (encompass_arr_.top()->stem_l_)
+ right_pos_i_ = rint (encompass_arr_.top()->stem_l_->height ()[dir_i_]/inter_f);
+ else
+ right_pos_i_ = rint (encompass_arr_.top()->head_positions_interval ()[dir_i_]);
+
+ left_pos_i_ += dir_i_;
+ right_pos_i_ += dir_i_;
}
IMPLEMENT_IS_TYPE_B1(Slur,Spanner);
Span_bar_engraver::Span_bar_engraver()
{
- spanbar_p_ =0;
- valign_l_ =0;
+ spanbar_p_ =0;
+ valign_l_ =0;
}
Span_bar*
Span_bar_engraver::get_span_bar_p()const
{
- return new Span_bar;
+ return new Span_bar;
}
void
Span_bar_engraver::acknowledge_element (Score_elem_info i)
{
- int depth = i.origin_grav_l_arr_.size();
- if ( depth > 1
+ int depth = i.origin_grav_l_arr_.size();
+ if ( depth > 1
&& i.elem_l_->is_type_b (Bar::static_name()) )
- {
+ {
bar_l_arr_.push ((Bar*)i.elem_l_->item());
- if (bar_l_arr_.size() >= 2 && !spanbar_p_) {
+ if (bar_l_arr_.size() >= 2 && !spanbar_p_)
+ {
spanbar_p_ = get_span_bar_p();
announce_element (Score_elem_info (spanbar_p_,0));
- }
- } else if (i.elem_l_->is_type_b (Vertical_align_spanner::static_name())
- && i.origin_grav_l_arr_.size() <= 2) {
+ }
+ }
+ else if (i.elem_l_->is_type_b (Vertical_align_spanner::static_name())
+ && i.origin_grav_l_arr_.size() <= 2)
+ {
valign_l_ = (Vertical_align_spanner*)i.elem_l_->spanner();
}
}
void
Span_bar_engraver::do_pre_move_processing()
{
- if (spanbar_p_) {
+ if (spanbar_p_)
+ {
for (int i=0; i < bar_l_arr_.size() ; i++)
spanbar_p_->add (bar_l_arr_[i]);
spanbar_p_->set (valign_l_);
typeset_element (spanbar_p_);
spanbar_p_ =0;
}
- bar_l_arr_.set_size (0);
+ bar_l_arr_.set_size (0);
}
void
Span_bar::add (Bar*b)
{
- b->spanned_i_ ++;
- spanning_l_arr_.push (b);
- add_dependency (b);
+ b->spanned_i_ ++;
+ spanning_l_arr_.push (b);
+ add_dependency (b);
}
void
Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
{
- Bar * bold = 0;
- if (o->is_type_b (Bar::static_name()))
+ Bar * bold = 0;
+ if (o->is_type_b (Bar::static_name()))
bold = (Bar*)o->item();
- else
+ else
return;
- bold->spanned_i_ --;
- Bar * b =0;
- if (n && n->is_type_b (Bar::static_name())) {
+ bold->spanned_i_ --;
+ Bar * b =0;
+ if (n && n->is_type_b (Bar::static_name()))
+ {
b = (Bar*)n->item();
b->spanned_i_ ++;
}
-
- spanning_l_arr_.substitute (bold , b);
+
+ spanning_l_arr_.substitute (bold , b);
}
void
Span_bar::set (Vertical_align_element *a)
{
- add_dependency (a);
+ add_dependency (a);
}
-
+
Interval
Span_bar::do_width() const
{
- return paper()->lookup_l ()->bar (type_str_, 40 PT).dim.x (); // ugh
+ return paper()->lookup_l ()->bar (type_str_, 40 PT).dim.x (); // ugh
}
void
Span_bar::do_pre_processing()
{
- if ( spanning_l_arr_.size() < 1) {
+ if ( spanning_l_arr_.size() < 1)
+ {
transparent_b_ = true;
empty_b_ =true;
- } else {
+ }
+ else
+ {
if (type_str_ == "")
type_str_ = spanning_l_arr_[0]->type_str_;
- if (type_str_ =="") {
+ if (type_str_ =="")
+ {
transparent_b_=true;
empty_b_ = true;
- } else if ( type_str_ == "|:") {
+ }
+ else if ( type_str_ == "|:")
+ {
type_str_ = ".|";
- } else if ( type_str_ == ":|"){
+ }
+ else if ( type_str_ == ":|")
+ {
type_str_ = "|.";
- }
+ }
}
}
Symbol
Span_bar::get_bar_sym (Real dy) const
{
- return paper()->lookup_l ()->bar (type_str_, dy);
+ return paper()->lookup_l ()->bar (type_str_, dy);
}
Molecule*
Span_bar::brew_molecule_p()const
{
- Interval y_int;
- for (int i=0; i < spanning_l_arr_.size(); i++) {
+ Interval y_int;
+ for (int i=0; i < spanning_l_arr_.size(); i++)
+ {
Axis_group_element *common =
common_group (spanning_l_arr_[i], Y_AXIS);
y_int.unite (y + spanning_l_arr_[i]->height());
}
- Symbol s = get_bar_sym (y_int.length());
- Molecule*output = new Molecule (Atom (s));
- output->translate ( y_int[-1], Y_AXIS);
- return output;
+ Symbol s = get_bar_sym (y_int.length());
+ Molecule*output = new Molecule (Atom (s));
+ output->translate ( y_int[-1], Y_AXIS);
+ return output;
}
Span_bar::Span_bar()
{
- type_str_ = "";
+ type_str_ = "";
}
Span_bar*
Span_score_bar_engraver::get_span_bar_p() const
{
- return new Span_score_bar;
+ return new Span_score_bar;
}
Span_bar*
Piano_bar_engraver::get_span_bar_p() const
{
- return new Piano_brace;
+ return new Piano_brace;
}
ADD_THIS_ENGRAVER(Piano_bar_engraver);
Span_score_bar::Span_score_bar()
{
- type_str_ = "|";
+ type_str_ = "|";
}
void
Span_score_bar::do_pre_processing()
{
- Span_bar::do_pre_processing();
-
- if ( break_status_i() != 1) {
+ Span_bar::do_pre_processing();
+
+ if ( break_status_i() != 1)
+ {
empty_b_ = transparent_b_ = true;
}
}
Symbol
Piano_brace::get_bar_sym (Real dy)const
{
- return paper()->lookup_l ()->vbrace (dy);
+ return paper()->lookup_l ()->vbrace (dy);
}
Interval
Piano_brace::do_width()const
{
- return Interval (0,0);
+ return Interval (0,0);
}
IMPLEMENT_IS_TYPE_B1(Span_score_bar, Span_bar);
IMPLEMENT_IS_TYPE_B1(Piano_brace, Span_score_bar);
-
+
Interval
Spanner_elem_group::do_width() const
{
- return Spanner::do_width();
+ return Spanner::do_width();
}
void
Spanner_elem_group::do_print() const
{
#ifndef NPRINT
- Spanner::do_print();
- Horizontal_vertical_group_element::do_print();
+ Spanner::do_print();
+ Horizontal_vertical_group_element::do_print();
#endif
}
Spanner::do_print()const
{
#ifndef NPRINT
- DOUT << "Between col ";
- if ( left_col_l_)
- DOUT << left_col_l_->rank_i();
- else
+ DOUT << "Between col ";
+ if ( left_col_l_)
+ DOUT << left_col_l_->rank_i();
+ else
DOUT << "nop";
- DOUT << ", ";
- if ( right_col_l_)
- DOUT << right_col_l_->rank_i();
- else
+ DOUT << ", ";
+ if ( right_col_l_)
+ DOUT << right_col_l_->rank_i();
+ else
DOUT << "nop";
- if (broken_into_l_arr_.size())
+ if (broken_into_l_arr_.size())
DOUT << "with broken pieces\n";
#endif
}
void
Spanner::break_into_pieces (bool copy_deps_b)
{
- if ( broken_into_l_arr_.size())
+ if ( broken_into_l_arr_.size())
return;
- PCol * left = left_col_l_;
- PCol * right = right_col_l_;
- if (left->daddy_l_) left = left->daddy_l_;
- if (right->daddy_l_) right = right->daddy_l_;
-
-
- Link_array<PCol> break_cols = pscore_l_->broken_col_range (left,right);
- Link_array<Spanner> broken_into_l_arr;
-
- break_cols.insert (left,0);
- break_cols.push (right);
-
- for (int i=1; i < break_cols.size(); i++) {
+ PCol * left = left_col_l_;
+ PCol * right = right_col_l_;
+ if (left->daddy_l_) left = left->daddy_l_;
+ if (right->daddy_l_) right = right->daddy_l_;
+
+
+ Link_array<PCol> break_cols = pscore_l_->broken_col_range (left,right);
+ Link_array<Spanner> broken_into_l_arr;
+
+ break_cols.insert (left,0);
+ break_cols.push (right);
+
+ for (int i=1; i < break_cols.size(); i++)
+ {
Spanner* span_p = clone()->spanner ();
if (copy_deps_b)
span_p->copy_dependencies (*this);
pscore_l_->typeset_broken_spanner (span_p);
broken_into_l_arr.push (span_p);
}
-
- broken_into_l_arr_ = broken_into_l_arr;
+
+ broken_into_l_arr_ = broken_into_l_arr;
}
void
{
if (!left_col_l_->line_l_)
left_col_l_ = left_col_l_->postbreak_p_;
- if (!right_col_l_->line_l_)
+ if (!right_col_l_->line_l_)
right_col_l_ = right_col_l_->prebreak_p_;
}
void
Spanner::do_break_processing()
{
- set_my_columns();
-
- if (!line_l()) {
+ set_my_columns();
+
+ if (!line_l())
+ {
break_into_pieces (true);
for (int i=0; i < broken_into_l_arr_.size(); i++)
broken_into_l_arr_[i]->handle_broken_dependencies();
- } else {
+ }
+ else
+ {
handle_broken_dependencies();
}
}
Spanner::Spanner()
{
- left_col_l_ = right_col_l_ = 0;
+ left_col_l_ = right_col_l_ = 0;
}
Interval
Spanner::do_width()const
{
- Real r = right_col_l_->hpos_f_;
- Real l = left_col_l_->hpos_f_;
- assert (*left_col_l_ < *right_col_l_);
- assert (r>=l);
+ Real r = right_col_l_->hpos_f_;
+ Real l = left_col_l_->hpos_f_;
+ assert (*left_col_l_ < *right_col_l_);
+ assert (r>=l);
- return Interval (0, r-l);
+ return Interval (0, r-l);
}
Line_of_score *
Spanner::line_l()const
{
- if ( left_col_l_->line_l_ != right_col_l_->line_l_)
+ if ( left_col_l_->line_l_ != right_col_l_->line_l_)
return 0;
- return left_col_l_->line_l_;
+ return left_col_l_->line_l_;
}
Spanner*
Spanner::find_broken_piece (Line_of_score*l)const
{
- for (int i=0; i < broken_into_l_arr_.size(); i++)
+ for (int i=0; i < broken_into_l_arr_.size(); i++)
if (broken_into_l_arr_[i]->line_l() == l)
return broken_into_l_arr_[i];
- return 0;
+ return 0;
}
bool
Spanner::broken_b()const
{
- return broken_into_l_arr_.size();
+ return broken_into_l_arr_.size();
}
Vector
Spring_spacer::default_solution()const
{
- return try_initial_solution() ;
+ return try_initial_solution() ;
}
Score_column*
Spring_spacer::scol_l (int i)
{
- return (Score_column*)cols[i].pcol_l_;
+ return (Score_column*)cols[i].pcol_l_;
}
const Real COLFUDGE=1e-3;
bool
Spring_spacer::contains (PCol const *w)
{
- for (int i=0; i< cols.size(); i++)
+ for (int i=0; i< cols.size(); i++)
if (cols[i].pcol_l_ == w)
return true;
- return false;
+ return false;
}
Spring_spacer::OK() const
{
#ifndef NDEBUG
- for (int i = 1; i < cols.size(); i++)
+ for (int i = 1; i < cols.size(); i++)
assert (cols[i].rank_i_ > cols[i-1].rank_i_);
- for (int i = 1; i < loose_col_arr_.size(); i++)
+ for (int i = 1; i < loose_col_arr_.size(); i++)
assert (loose_col_arr_[i].rank_i_ > loose_col_arr_[i-1].rank_i_);
#endif
}
void
Spring_spacer::handle_loose_cols()
{
- Union_find connected (cols.size());
- Array<int> fixed;
- for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++){
+ Union_find connected (cols.size());
+ Array<int> fixed;
+ for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+ {
connected.connect (i->left_i_,i->right_i_);
}
- for (int i = 0; i < cols.size(); i++)
+ for (int i = 0; i < cols.size(); i++)
if (cols[i].fixed())
fixed.push (i);
- for (int i=1; i < fixed.size(); i++)
+ for (int i=1; i < fixed.size(); i++)
connected.connect (fixed[i-1], fixed[i]);
- for (int i = cols.size(); i--;) {
- if (! connected.equiv (fixed[0], i)) {
+ for (int i = cols.size(); i--;)
+ {
+ if (! connected.equiv (fixed[0], i))
+ {
warning ("unconnected column: " + String (i));
loosen_column (i);
- }
+ }
}
- OK();
+ OK();
}
void
Spring_spacer::position_loose_cols (Vector &sol_vec)const
{
- if (!loose_col_arr_.size())
+ if (!loose_col_arr_.size())
return ;
- assert (sol_vec.dim());
- Array<bool> fix_b_arr;
- fix_b_arr.set_size (cols.size() + loose_col_arr_.size ());
- Real utter_right_f=-infinity_f;
- Real utter_left_f =infinity_f;
- for (int i=0; i < loose_col_arr_.size(); i++) {
+ assert (sol_vec.dim());
+ Array<bool> fix_b_arr;
+ fix_b_arr.set_size (cols.size() + loose_col_arr_.size ());
+ Real utter_right_f=-infinity_f;
+ Real utter_left_f =infinity_f;
+ for (int i=0; i < loose_col_arr_.size(); i++)
+ {
fix_b_arr[loose_col_arr_[i].rank_i_] = false;
}
- for (int i=0; i < cols.size(); i++) {
+ for (int i=0; i < cols.size(); i++)
+ {
int r= cols[i].rank_i_;
fix_b_arr[r] = true;
utter_right_f = utter_right_f >? sol_vec (i);
utter_left_f = utter_left_f <? sol_vec (i);
}
- Vector v (fix_b_arr.size());
- int j =0;
- int k =0;
- for (int i=0; i < v.dim(); i++) {
- if (fix_b_arr[i]) {
+ Vector v (fix_b_arr.size());
+ int j =0;
+ int k =0;
+ for (int i=0; i < v.dim(); i++)
+ {
+ if (fix_b_arr[i])
+ {
assert (cols[j].rank_i_ == i);
v (i) = sol_vec (j++);
- } else {
+ }
+ else
+ {
Real left_pos_f =
(j>0) ?sol_vec (j-1) : utter_left_f;
Real right_pos_f =
v (i) = (r - left_rank)*left_pos_f/ d_r +
(right_rank - r) *right_pos_f /d_r;
- }
+ }
}
- sol_vec = v;
+ sol_vec = v;
}
bool
Spring_spacer::check_constraints (Vector v) const
{
- int dim=v.dim();
- assert (dim == cols.size());
-
- for (int i=0; i < dim; i++) {
+ int dim=v.dim();
+ assert (dim == cols.size());
+
+ for (int i=0; i < dim; i++)
+ {
if (cols[i].fixed()&&
abs (cols[i].fixed_position() - v (i)) > COLFUDGE)
return false;
}
- return true;
+ return true;
}
bool
Spring_spacer::check_feasible() const
{
- Vector sol (try_initial_solution());
- return check_constraints (sol);
+ Vector sol (try_initial_solution());
+ return check_constraints (sol);
}
/// generate a solution which obeys the min distances and fixed positions
Vector
Spring_spacer::try_initial_solution() const
{
- int dim=cols.size();
- Vector initsol (dim);
- for (int i=0; i < dim; i++) {
- if (cols[i].fixed()) {
+ int dim=cols.size();
+ Vector initsol (dim);
+ for (int i=0; i < dim; i++)
+ {
+ if (cols[i].fixed())
+ {
initsol (i)=cols[i].fixed_position();
- if (i > 0) {
+ if (i > 0)
+ {
Real r =initsol (i-1) + cols[i-1].minright();
- if (initsol (i) < r) {
+ if (initsol (i) < r)
+ {
warning ("overriding fixed position");
initsol (i) =r;
- }
- }
+ }
+ }
- } else {
+ }
+ else
+ {
Real mindist=cols[i-1].minright()
+cols[i].minleft();
if (mindist < 0.0)
}
}
- return initsol;
+ return initsol;
}
Vector
Spring_spacer::find_initial_solution() const
{
- Vector v (try_initial_solution());
- assert (check_constraints (v));
- return v;
+ Vector v (try_initial_solution());
+ assert (check_constraints (v));
+ return v;
}
// generate the matrices
void
Spring_spacer::make_matrices (Matrix &quad, Vector &lin, Real &c) const
{
- quad.fill (0);
- lin.fill (0);
- c = 0;
-
- for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++) {
+ quad.fill (0);
+ lin.fill (0);
+ c = 0;
+
+ for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+ {
int l = i->left_i_;
int r = i->right_i_;
void
Spring_spacer::set_fixed_cols (Mixed_qp &qp)const
{
- for (int j=0; j < cols.size(); j++)
+ for (int j=0; j < cols.size(); j++)
if (cols[j].fixed())
qp.add_fixed_var (j,cols[j].fixed_position());
-
+
}
// put the constraints into the LP problem
void
Spring_spacer::make_constraints (Mixed_qp& lp) const
{
- int dim=cols.size();
- for (int j=0; j < dim; j++) {
+ int dim=cols.size();
+ for (int j=0; j < dim; j++)
+ {
Colinfo c=cols[j];
- if (j > 0){
+ if (j > 0)
+ {
Vector c1(dim);
c1(j)=1.0 ;
c1(j-1)=-1.0 ;
lp.add_inequality_cons (c1, cols[j-1].minright() +
cols[j].minleft());
- }
+ }
}
}
void
Spring_spacer::lower_bound_solution (Col_hpositions*positions)const
{
- Mixed_qp lp (cols.size());
- make_matrices (lp.quad,lp.lin, lp.const_term);
- set_fixed_cols (lp);
+ Mixed_qp lp (cols.size());
+ make_matrices (lp.quad,lp.lin, lp.const_term);
+ set_fixed_cols (lp);
- Vector start (cols.size());
- start.fill (0.0);
- Vector solution_vec (lp.solve (start));
+ Vector start (cols.size());
+ start.fill (0.0);
+ Vector solution_vec (lp.solve (start));
- positions->energy_f_ = lp.eval (solution_vec);
- positions->config = solution_vec;
- positions->satisfies_constraints_b_ = check_constraints (solution_vec);
+ positions->energy_f_ = lp.eval (solution_vec);
+ positions->config = solution_vec;
+ positions->satisfies_constraints_b_ = check_constraints (solution_vec);
}
void
Spring_spacer::solve (Col_hpositions*positions) const
{
- assert (check_feasible());
+ assert (check_feasible());
- Mixed_qp lp (cols.size());
- make_matrices (lp.quad,lp.lin, lp.const_term);
- make_constraints (lp);
- set_fixed_cols (lp);
- Vector start=find_initial_solution();
- Vector solution_vec (lp.solve (start));
+ Mixed_qp lp (cols.size());
+ make_matrices (lp.quad,lp.lin, lp.const_term);
+ make_constraints (lp);
+ set_fixed_cols (lp);
+ Vector start=find_initial_solution();
+ Vector solution_vec (lp.solve (start));
- positions->satisfies_constraints_b_ = check_constraints (solution_vec);
- if (!positions->satisfies_constraints_b_) {
+ positions->satisfies_constraints_b_ = check_constraints (solution_vec);
+ if (!positions->satisfies_constraints_b_)
+ {
WARN << "solution doesn't satisfy constraints.\n" ;
}
- position_loose_cols (solution_vec);
- positions->energy_f_ = lp.eval (solution_vec);
- positions->config = solution_vec;
- positions->error_col_l_arr_ = error_pcol_l_arr();
-
+ position_loose_cols (solution_vec);
+ positions->energy_f_ = lp.eval (solution_vec);
+ positions->config = solution_vec;
+ positions->error_col_l_arr_ = error_pcol_l_arr();
+
}
/**
- add one column to the problem.
+ add one column to the problem.
*/
void
Spring_spacer::add_column (PCol *col, bool fixed, Real fixpos)
{
- Colinfo c (col,(fixed)? &fixpos : 0);
- if (cols.size())
+ Colinfo c (col,(fixed)? &fixpos : 0);
+ if (cols.size())
c.rank_i_ = cols.top().rank_i_+1;
- else
+ else
c.rank_i_ = 0;
- cols.push (c);
+ cols.push (c);
}
Line_of_cols
Spring_spacer::error_pcol_l_arr()const
{
- Array<PCol*> retval;
- for (int i=0; i< cols.size(); i++)
+ Array<PCol*> retval;
+ for (int i=0; i< cols.size(); i++)
if (cols[i].ugh_b_)
retval.push (cols[i].pcol_l_);
- for (int i=0; i < loose_col_arr_.size(); i++) {
+ for (int i=0; i < loose_col_arr_.size(); i++)
+ {
retval.push (loose_col_arr_[i].pcol_l_);
}
- return retval;
+ return retval;
}
void
Spring_spacer::loosen_column (int i)
{
- Colinfo c=cols.get (i);
- for (PCursor<Idealspacing*> j (ideal_p_list_.top()); j.ok (); j++){
+ Colinfo c=cols.get (i);
+ for (PCursor<Idealspacing*> j (ideal_p_list_.top()); j.ok (); j++)
+ {
if (j->left_i_ == i|| j->right_i_ == i)
j.del();
else
j++;
}
- c.ugh_b_ = true;
-
- int j=0;
- for (; j < loose_col_arr_.size(); j++) {
+ c.ugh_b_ = true;
+
+ int j=0;
+ for (; j < loose_col_arr_.size(); j++)
+ {
if (loose_col_arr_[j].rank_i_ > c.rank_i_)
break;
}
- loose_col_arr_.insert (c,j);
+ loose_col_arr_.insert (c,j);
}
Spring_spacer::print() const
{
#ifndef NPRINT
- for (int i=0; i < cols.size(); i++) {
+ for (int i=0; i < cols.size(); i++)
+ {
DOUT << "col " << i<<' ';
cols[i].print();
}
- for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++){
+ for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+ {
i->print();
}
#endif
void
Spring_spacer::connect (int i, int j, Real d, Real h)
{
- Idealspacing * s = new Idealspacing;
- s->left_i_ = i;
- s->right_i_ = j;
- s->space_f_ = d;
- s->hooke_f_ = h;
+ assert( d >= 0 && d <= 100 CM);
+ assert( h >=0);
+
+ Idealspacing * s = new Idealspacing;
+ s->left_i_ = i;
+ s->right_i_ = j;
+ s->space_f_ = d;
+ s->hooke_f_ = h;
+
+ ideal_p_list_.bottom().add (s);
+}
+
+
+
+
+void
+Spring_spacer::prepare()
+{
+ calc_idealspacing();
+ handle_loose_cols();
+ print();
+}
+
+Line_spacer*
+Spring_spacer::constructor()
+{
+ return new Spring_spacer;
+}
+
+
+
+/**
+ get the shortest_playing running note at a time. */
+void
+Spring_spacer::get_ruling_durations(Array<Moment> &shortest_playing_arr,
+ Array<Moment> &context_shortest_arr)
+{
+ for (int i=0; i < cols.size(); i++)
+ scol_l (i)->preprocess();
+
+ int start_context_i=0;
+ Moment context_shortest = infinity_mom;
+ context_shortest_arr.set_size(cols.size());
+
+ for (int i=0; i < cols.size(); i++)
+ {
+ Moment now = scol_l (i)->when();
+ Moment shortest_playing = infinity_mom;
+
+ if (scol_l(i)->breakable_b())
+ {
+ for (int ji=i; ji >= start_context_i; ji--)
+ context_shortest_arr[ji] = context_shortest;
+ start_context_i = i;
+ context_shortest = infinity_mom;
+ }
+ if (scol_l(i)->durations.size())
+ {
+ context_shortest = context_shortest <? scol_l(i)->durations[0];
+ }
+ // ji was j, but triggered ICE
+ for (int ji=i+1; ji --; )
+ {
+ if (scol_l(ji)->durations.size() &&
+ now - scol_l(ji)->when() >= shortest_playing)
+ break;
+
+ for (int k = scol_l (ji)->durations.size();
+ k-- && scol_l(ji)->durations[k] + scol_l(ji)->when() > now;
+ )
+ {
+ shortest_playing = shortest_playing <? scol_l(ji)->durations[k];
+ }
+ }
+ shortest_playing_arr.push(shortest_playing);
+ }
- ideal_p_list_.bottom().add (s);
+#ifndef NPRINT
+ DOUT << "shortest_playing/:[ ";
+ for (int i=0; i < shortest_playing_arr.size(); i++)
+ {
+ DOUT << shortest_playing_arr[i] << " ";
+ DOUT << context_shortest_arr[i] << ", ";
+ }
+ DOUT << "]\n";
+#endif
}
/**
void
Spring_spacer::calc_idealspacing()
{
-
- for (int i=0; i < cols.size(); i++)
- scol_l (i)->preprocess();
-
- /* get the shortest running note at a time. */
- Array<Moment> shortest_arr;
- for (int i=0; i < cols.size(); i++) {
- Moment now = scol_l (i)->when();
- Moment shortest = infinity_mom;
- // ji was j, but triggered ICE
- for (int ji=i+1; ji --; ) {
- if (scol_l(ji)->durations.size() &&
- now - scol_l(ji)->when() >= shortest)
- break;
-
- for (int k = scol_l (ji)->durations.size();
- k-- && scol_l(ji)->durations[k] + scol_l(ji)->when() > now;
- )
- {
- shortest = shortest <? scol_l(ji)->durations[k];
- }
- }
- shortest_arr.push(shortest);
- }
-
-#ifndef NPRINT
- DOUT << "shortest:[ ";
- for (int i=0; i < shortest_arr.size(); i++)
- DOUT << shortest_arr[i] << " ";
- DOUT << "]\n";
-#endif
+ Array<Moment> shortest_playing_arr;
+ Array<Moment> context_shortest_arr;
+ get_ruling_durations(shortest_playing_arr, context_shortest_arr);
+
- Array<Real> ideal_arr_;
- Array<Real> hooke_arr_;
- for (int i=0; i < cols.size(); i++){
- ideal_arr_.push (-1.0);
- hooke_arr_.push (1.0);
- }
+ Array<Real> ideal_arr_;
+ Array<Real> hooke_arr_;
+ for (int i=0; i < cols.size(); i++){
+ ideal_arr_.push (-1.0);
+ hooke_arr_.push (1.0);
+ }
- for (int i=0; i < cols.size(); i++) {
- if ( !scol_l (i)->musical_b()) {
- Real symbol_distance =cols[i].minright() + 2 PT;
- Real durational_distance = 0;
-
- if (i+1 < cols.size()) {
- Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when () ;
- /*
- ugh should use shortest distance
- */
- if (delta_t)
- durational_distance = paper_l()->duration_to_dist (delta_t) ;
- symbol_distance += cols[i+1].minleft();
+ for (int i=0; i < cols.size(); i++)
+ {
+ if ( !scol_l (i)->musical_b())
+ {
+ Real symbol_distance =cols[i].minright() + 2 PT;
+ Real durational_distance = 0;
+
+ if (i+1 < cols.size())
+ {
+ Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when () ;
+
+ Real k= paper_l()->arithmetic_constant(context_shortest_arr[i]);
+ /*
+ ugh should use shortest_playing distance
+ */
+ if (delta_t)
+ durational_distance = paper_l()->duration_to_dist (delta_t,k);
+ symbol_distance += cols[i+1].minleft();
}
- ideal_arr_[i] = symbol_distance >? durational_distance;
- hooke_arr_[i] = 2.0;
+ ideal_arr_[i] = symbol_distance >? durational_distance;
+ hooke_arr_[i] = 2.0;
}
}
- for (int i=0; i < cols.size(); i++) {
- if (scol_l (i)->musical_b()) {
- Moment shortest_len = shortest_arr[i];
- if ( ! shortest_len) {
- warning ("Can't find a ruling note at "
- +String (scol_l (i)->when()));
- shortest_len = 1;
+ for (int i=0; i < cols.size(); i++)
+ {
+ if (scol_l (i)->musical_b())
+ {
+ Moment shortest_playing_len = shortest_playing_arr[i];
+ Moment context_shortest = context_shortest_arr[i];
+ if ( ! shortest_playing_len)
+ {
+ warning ("Can't find a ruling note at "
+ +String (scol_l (i)->when()));
+ shortest_playing_len = 1;
+ }
+ if ( ! context_shortest )
+ {
+ warning("No minimum in measure at "
+ + String (scol_l (i)->when()));
+ context_shortest = 1;
}
- Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when ();
- Real dist = paper_l()->duration_to_dist (shortest_len);
- dist *= delta_t / shortest_len;
- if (!scol_l (i+1)->musical_b()) {
-
- Real minimum_dist = cols[i+1].minleft() + 2 PT + cols[i].minright () ;
- if (ideal_arr_[i+1] + minimum_dist < dist) {
- ideal_arr_[i] = dist - ideal_arr_[i+1];
- // hooke_arr_[i+1] =1.0;
+ Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when ();
+ Real k= paper_l()->arithmetic_constant(context_shortest);
+ Real dist = paper_l()->duration_to_dist (shortest_playing_len, k);
+ dist *= delta_t / shortest_playing_len;
+
+ /* all sorts of ugliness to avoid running into bars/clefs, but not taking
+ extra space if this is not needed */
+ if (!scol_l (i+1)->musical_b())
+ {
+ Real minimum_dist = cols[i+1].minleft() + 2 PT + cols[i].minright () ;
+ if (ideal_arr_[i+1] + minimum_dist < dist)
+ {
+ ideal_arr_[i] = dist - ideal_arr_[i+1];
+ // hooke_arr_[i+1] =1.0;
} else {
- ideal_arr_[i] = minimum_dist;
+ ideal_arr_[i] = minimum_dist;
}
-
+
} else
- ideal_arr_[i] = dist;
+ ideal_arr_[i] = dist;
}
}
- for (int i=0; i < ideal_arr_.size()-1; i++) {
- assert (ideal_arr_[i] >=0 && hooke_arr_[i] >=0);
- connect (i, i+1, ideal_arr_[i], hooke_arr_[i]);
+ for (int i=0; i < ideal_arr_.size()-1; i++)
+ {
+ assert (ideal_arr_[i] >=0 && hooke_arr_[i] >=0);
+ connect (i, i+1, ideal_arr_[i], hooke_arr_[i]);
}
}
-
-
-
-void
-Spring_spacer::prepare()
-{
- calc_idealspacing();
- handle_loose_cols();
- print();
-}
-
-Line_spacer*
-Spring_spacer::constructor()
-{
- return new Spring_spacer;
-}
-
Score*
Staff_info::score_l()
{
- return score_l_;
+ return score_l_;
}
Staff_info::Staff_info()
{
- score_l_ =0;
- c0_position_i_l_ = 0;
- time_C_ = 0;
- rhythmic_C_ =0;
- break_allowed_b_ = 0;
+ score_l_ =0;
+ c0_position_i_l_ = 0;
+ time_C_ = 0;
+ rhythmic_C_ =0;
+ break_allowed_b_ = 0;
}
Score_column*
Staff_info::musical_l()
{
- return musical_l_;
+ return musical_l_;
}
Score_column*
Staff_info::command_l()
{
- return command_l_;
+ return command_l_;
}
PCol*
Staff_info::command_pcol_l()
{
- return command_l();
+ return command_l();
}
PCol*
Staff_info::musical_pcol_l()
{
- return musical_l();
+ return musical_l();
}
Moment
Staff_info::when()
{
- return command_l()->when ();
+ return command_l()->when ();
}
Staff_performer::Staff_performer()
{
- audio_staff_p_ = 0;
+ audio_staff_p_ = 0;
}
Staff_performer::~Staff_performer()
{
- delete audio_staff_p_;
+ delete audio_staff_p_;
}
void
Staff_performer::do_creation_processing()
{
- audio_staff_p_ = new Audio_staff;
+ audio_staff_p_ = new Audio_staff;
- if (instrument_str().length_i()) {
+ if (instrument_str().length_i())
+ {
// staff name
play (new Audio_text ( Audio_text::TRACK_NAME, instrument_str ()));
// instrument description
play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str ()));
}
- // tempo
- play(new Audio_tempo(get_tempo_i()));
+ // tempo
+ play(new Audio_tempo(get_tempo_i()));
- if (instrument_str ().length_i ())
+ if (instrument_str ().length_i ())
// instrument
play (new Audio_instrument (instrument_str ()));
}
void
Staff_performer::do_removal_processing()
{
- Performer::play (audio_staff_p_);
- audio_staff_p_ = 0;
+ Performer::play (audio_staff_p_);
+ audio_staff_p_ = 0;
}
String
Staff_performer::instrument_str()
{
- return Translator::id_str_;
+ return Translator::id_str_;
}
void
Staff_performer::play (Audio_element* p)
{
- if (p->is_type_b (Audio_item::static_name())) {
+ if (p->is_type_b (Audio_item::static_name()))
+ {
audio_staff_p_->add ((Audio_item*)p);
}
- Performer::play (p);
+ Performer::play (p);
}
void
Staff_side::set_staffsym (Staff_symbol* s_l)
{
- staff_sym_l_ = s_l;
- add_dependency (s_l);
+ staff_sym_l_ = s_l;
+ add_dependency (s_l);
}
Staff_side::Staff_side()
{
- pos_i_ =0;
- sym_int_ = Interval (0,0);
- staff_size_i_ = 0;
- staff_sym_l_=0;
- dir_i_ =0;
- inside_staff_b_ =false;
+ pos_i_ =0;
+ sym_int_ = Interval (0,0);
+ staff_size_i_ = 0;
+ staff_sym_l_=0;
+ dir_i_ =0;
+ inside_staff_b_ =false;
}
void
Staff_side::read_staff_sym()
{
- if (! staff_sym_l_)
+ if (! staff_sym_l_)
return ;
- staff_size_i_ = staff_sym_l_->steps_i();
+ staff_size_i_ = staff_sym_l_->steps_i();
}
Interval
Staff_side::support_height() const
{
- Interval r;
-
- for (int i=0; i < support_l_arr_.size(); i++)
+ Interval r;
+
+ for (int i=0; i < support_l_arr_.size(); i++)
r.unite (support_l_arr_[i]->height());
- if (r.empty_b()) {
+ if (r.empty_b())
+ {
r = Interval (0,0);
}
- return r;
+ return r;
}
void
Staff_side::add_support (Score_elem*i)
{
- support_l_arr_.push (i);
- add_dependency (i);
+ support_l_arr_.push (i);
+ add_dependency (i);
}
int
Staff_side::get_position_i()const
{
- if (!dir_i_) {
+ if (!dir_i_)
+ {
warning ("Staff_side::get_position_i(): "
"somebody forgot to set my vertical direction, returning -20");
return -20;
}
-
+
- Real y=0;
- Real inter_f = paper()-> internote_f ();
- if (!inside_staff_b_) {
+ Real y=0;
+ Real inter_f = paper()-> internote_f ();
+ if (!inside_staff_b_)
+ {
y = (dir_i_ > 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2;
y *=inter_f;
Interval v= support_height();
- if (dir_i_ > 0) {
+ if (dir_i_ > 0)
+ {
y = y >? (v.max() + 2*inter_f);
- } else if (dir_i_ < 0) {
+ }
+ else if (dir_i_ < 0)
+ {
y = y <? (v.min() - 2*inter_f);
- }
- } else {
+ }
+ }
+ else
+ {
Interval v= support_height();
y = v[dir_i_] + 2*dir_i_*inter_f; // ugh
}
- return int (rint (Real (y)/inter_f)); // should ret a float?
+ return int (rint (Real (y)/inter_f)); // should ret a float?
}
Interval
Staff_side::symbol_height() const
{
- return Interval (0,0);
+ return Interval (0,0);
}
void
Staff_side::do_post_processing()
{
- sym_int_ = symbol_height();
- pos_i_ = get_position_i();
- if (dir_i_)
+ sym_int_ = symbol_height();
+ pos_i_ = get_position_i();
+ if (dir_i_)
pos_i_ += int (rint (- sym_int_[-dir_i_] / paper()->internote_f ()));
}
void
Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n)
{
- support_l_arr_.unordered_substitute (o,n);
- if (staff_sym_l_ == o)
+ support_l_arr_.unordered_substitute (o,n);
+ if (staff_sym_l_ == o)
staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0;
}
void
Staff_sym_engraver::fill_staff_info (Staff_info&i)
{
- i.staff_sym_l_ = span_p_;
+ i.staff_sym_l_ = span_p_;
}
Staff_sym_engraver::~Staff_sym_engraver()
{
- assert (!span_p_);
+ assert (!span_p_);
}
Staff_sym_engraver::Staff_sym_engraver()
void
Staff_sym_engraver::do_creation_processing()
{
- span_p_ = new Staff_symbol (NO_LINES);
- span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh
- announce_element (Score_elem_info (span_p_, 0));
+ span_p_ = new Staff_symbol (NO_LINES);
+ span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh
+ announce_element (Score_elem_info (span_p_, 0));
}
void
Staff_sym_engraver::do_removal_processing()
{
- span_p_->right_col_l_ = get_staff_info().command_pcol_l ();
- typeset_element (span_p_);
- span_p_ =0;
+ span_p_->right_col_l_ = get_staff_info().command_pcol_l ();
+ typeset_element (span_p_);
+ span_p_ =0;
}
Staff_symbol::Staff_symbol (int l)
{
- no_lines_i_ = l;
+ no_lines_i_ = l;
}
Staff_symbol::do_print()const
{
#ifndef NPRINT
- Spanner::do_print();
- DOUT << "lines: " << no_lines_i_;
+ Spanner::do_print();
+ DOUT << "lines: " << no_lines_i_;
#endif
}
Molecule*
Staff_symbol::brew_molecule_p() const
{
- Atom a = paper()->lookup_l ()->linestaff (no_lines_i_, width ().length ());
- return new Molecule (a);
+ Atom a = paper()->lookup_l ()->linestaff (no_lines_i_, width ().length ());
+ return new Molecule (a);
}
void
Staff_symbol::set_extent (PCol*p1, PCol*p2)
{
- assert (p1&&p2);
- left_col_l_ = p1;
- right_col_l_ = p2;
+ assert (p1&&p2);
+ left_col_l_ = p1;
+ right_col_l_ = p2;
}
Real
Staff_symbol::inter_note_f()const
{
- return paper()->internote_f ();
+ return paper()->internote_f ();
}
int
Staff_symbol::steps_i() const
{
- return no_lines_i_*2;
+ return no_lines_i_*2;
}
#include "grouping.hh"
#include "note-head.hh"
#include "time-description.hh"
+#include "duration-convert.hh"
Stem_beam_engraver::Stem_beam_engraver()
{
- do_post_move_processing();
+ do_post_move_processing();
- current_grouping = 0;
- beam_p_ = 0;
- default_dir_i_ =0;
- start_req_l_ = 0;
+ current_grouping = 0;
+ beam_p_ = 0;
+ default_dir_i_ =0;
+ start_req_l_ = 0;
}
bool
Stem_beam_engraver::do_try_request (Request*req_l)
{
-
- Musical_req* mus_l = req_l->musical();
- /* Debiele puntkomma's. Laat je er eentje per ongeluk achter een
- if (..) staan, lijkt het net op een luis in gcc.
-
- (ofwel Python rules)
- */
- if (!mus_l)
- return false;
+
+ Musical_req* mus_l = req_l->musical();
+ /* Debiele puntkomma's. Laat je er eentje per ongeluk achter een
+ if (..) staan, lijkt het net op een luis in gcc.
+
+ (ofwel Python rules)
+ */
+ if (!mus_l)
+ return false;
- if ( mus_l->beam()) {
- if (bool (beam_p_) == bool (mus_l->beam()->spantype == Span_req::START))
- return false;
+ if ( mus_l->beam())
+ {
+ if (bool (beam_p_) == bool (mus_l->beam()->spantype == Span_req::START))
+ return false;
- if (beam_req_l_ && beam_req_l_ ->equal_b (mus_l))
- return false;
+ if (beam_req_l_ && beam_req_l_ ->equal_b (mus_l))
+ return false;
- beam_req_l_ = mus_l->beam();
- return true;
- }
-
- if ( mus_l->stem()) {
- if (current_grouping && !current_grouping->child_fit_b (
- get_staff_info().time_C_->whole_in_measure_))
- return false;
-
- if (stem_req_l_ && !stem_req_l_->equal_b (mus_l) )
- return false;
-
- stem_req_l_ = mus_l->stem();
- return true;
- }
- return false;
+ beam_req_l_ = mus_l->beam();
+ return true;
+ }
+
+ if ( mus_l->stem())
+ {
+ if (current_grouping && !current_grouping->child_fit_b (
+ get_staff_info().time_C_->whole_in_measure_))
+ return false;
+
+ if (stem_req_l_ && !stem_req_l_->equal_b (mus_l) )
+ return false;
+
+ stem_req_l_ = mus_l->stem();
+ return true;
+ }
+ return false;
}
void
Stem_beam_engraver::do_process_requests()
{
- if (beam_req_l_) {
- if (beam_req_l_->spantype == Span_req::STOP) {
- end_beam_b_ = true;
- start_req_l_ = 0;
- } else {
- beam_p_ = new Beam;
- start_req_l_ = beam_req_l_;
- beam_p_->left_col_l_ = get_staff_info().musical_pcol_l ();
- current_grouping = new Rhythmic_grouping;
- if (beam_req_l_->nplet) {
- Text_spanner* t = new Text_spanner();
- Text_def *defp = new Text_def;
- t->set_support (beam_p_);
- defp->align_i_ = 0;
- defp->text_str_ = beam_req_l_->nplet;
- defp->style_str_="italic";
- t->spec_p_ = defp;
- announce_element (Score_elem_info (t,0));
- typeset_element (t);
+ if (beam_req_l_)
+ {
+ if (beam_req_l_->spantype == Span_req::STOP)
+ {
+ end_beam_b_ = true;
+ start_req_l_ = 0;
+ }
+ else
+ {
+ beam_p_ = new Beam;
+ start_req_l_ = beam_req_l_;
+ beam_p_->left_col_l_ = get_staff_info().musical_pcol_l ();
+ current_grouping = new Rhythmic_grouping;
+ if (beam_req_l_->nplet)
+ {
+ Text_spanner* t = new Text_spanner();
+ Text_def *defp = new Text_def;
+ t->set_support (beam_p_);
+ defp->align_i_ = 0;
+ defp->text_str_ = beam_req_l_->nplet;
+ defp->style_str_="italic";
+ t->spec_p_ = defp;
+ announce_element (Score_elem_info (t,0));
+ typeset_element (t);
}
- announce_element ( Score_elem_info (beam_p_, 0));
+ announce_element ( Score_elem_info (beam_p_, 0));
}
- }
-
- if (stem_req_l_) {
- stem_p_ = new Stem (8);
- if (current_grouping)
- current_grouping->add_child (
- get_staff_info().time_C_->whole_in_measure_,
- stem_req_l_->duration());
-
- stem_p_->flag_i_ = stem_req_l_->duration_.type_i_;
-
- if (beam_p_) {
- if (stem_req_l_->duration_.type_i_<= 4)
- stem_req_l_->warning ("stem doesn't fit in Beam");
- else
- beam_p_->add (stem_p_);
- stem_p_->print_flag_b_ = false;
- } else {
- stem_p_->print_flag_b_ = true;
+ }
+
+ if (stem_req_l_)
+ {
+ stem_p_ = new Stem (8);
+ if (current_grouping)
+ current_grouping->add_child (
+ get_staff_info().time_C_->whole_in_measure_,
+ stem_req_l_->duration());
+
+ stem_p_->flag_i_ = Duration_convert::type2_i
+ (stem_req_l_->duration_.durlog_i_); // should change rep. of flags too.
+
+ if (beam_p_)
+ {
+ if (stem_req_l_->duration_.durlog_i_<= 2)
+ stem_req_l_->warning ("stem doesn't fit in Beam");
+ else
+ beam_p_->add (stem_p_);
+ stem_p_->print_flag_b_ = false;
+ }
+ else
+ {
+ stem_p_->print_flag_b_ = true;
}
- announce_element (Score_elem_info (stem_p_, stem_req_l_));
- }
+ announce_element (Score_elem_info (stem_p_, stem_req_l_));
+ }
}
void
Stem_beam_engraver::acknowledge_element (Score_elem_info info)
{
- if (!stem_p_)
- return;
-
- if (info.elem_l_->name() == Note_head::static_name () &&
- stem_req_l_->duration()
- == info.req_l_->musical()->rhythmic ()->duration ()){
- Note_head * n_l= (Note_head*)info.elem_l_->item();
- stem_p_->add (n_l);
- }
+ if (!stem_p_)
+ return;
+
+ if (info.elem_l_->name() == Note_head::static_name () &&
+ stem_req_l_->duration()
+ == info.req_l_->musical()->rhythmic ()->duration ())
+ {
+ Note_head * n_l= (Note_head*)info.elem_l_->item();
+ stem_p_->add (n_l);
+ }
}
void
Stem_beam_engraver::do_pre_move_processing()
{
- if (stem_p_) {
- if (default_dir_i_)
- stem_p_->dir_i_ = default_dir_i_;
+ if (stem_p_)
+ {
+ if (default_dir_i_)
+ stem_p_->dir_i_ = default_dir_i_;
- typeset_element (stem_p_);
- stem_p_ = 0;
- }
- if (beam_p_ && end_beam_b_) {
- Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
- rg_C->extend (current_grouping->interval());
- beam_p_->set_grouping (*rg_C, *current_grouping);
- beam_p_->right_col_l_ = get_staff_info().musical_pcol_l ();
- typeset_element (beam_p_);
- delete current_grouping;
- current_grouping = 0;
- beam_p_ = 0;
- }
- end_beam_b_ = false;
+ typeset_element (stem_p_);
+ stem_p_ = 0;
+ }
+ if (beam_p_ && end_beam_b_)
+ {
+ Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
+ rg_C->extend (current_grouping->interval());
+ beam_p_->set_grouping (*rg_C, *current_grouping);
+ beam_p_->right_col_l_ = get_staff_info().musical_pcol_l ();
+ typeset_element (beam_p_);
+ delete current_grouping;
+ current_grouping = 0;
+ beam_p_ = 0;
+ }
+ end_beam_b_ = false;
}
void
Stem_beam_engraver::do_post_move_processing()
{
- stem_p_ = 0;
- beam_req_l_ = 0;
- stem_req_l_ = 0;
- end_beam_b_ = false;
+ stem_p_ = 0;
+ beam_req_l_ = 0;
+ stem_req_l_ = 0;
+ end_beam_b_ = false;
}
Stem_beam_engraver::~Stem_beam_engraver()
{
- if (beam_p_)
- start_req_l_->warning ("unterminated beam");
+ if (beam_p_)
+ start_req_l_->warning ("unterminated beam");
}
void
Stem_beam_engraver::set_feature (Feature i)
{
- if (i.type_ == "vdir")
- default_dir_i_ = i.value_;
+ if (i.type_ == "vdir")
+ default_dir_i_ = i.value_;
}
int
Stem::min_head_i()const
{
- int m = 1000;
- for (int i =0; i < head_l_arr_.size(); i++)
+ int m = 1000;
+ for (int i =0; i < head_l_arr_.size(); i++)
m = m <? head_l_arr_[i]->position_i_;
- return m;
+ return m;
}
int
Stem::max_head_i() const
{
- int m = -1000;
- for (int i =0; i < head_l_arr_.size(); i++)
+ int m = -1000;
+ for (int i =0; i < head_l_arr_.size(); i++)
m = m >? head_l_arr_[i]->position_i_;
- return m;
-
+ return m;
+
}
Stem::Stem (int c)
{
- beams_left_i_ = 0;
- beams_right_i_ = 0;
+ beams_left_i_ = 0;
+ beams_right_i_ = 0;
- stem_bottom_f_ = stem_top_f_ = 0;
- flag_i_ = 4;
- dir_i_ =0;
- staff_size_i_ = c;
+ stem_bottom_f_ = stem_top_f_ = 0;
+ flag_i_ = 4;
+ dir_i_ =0;
+ staff_size_i_ = c;
- print_flag_b_=true;
- stem_xoffset_f_ =0;
+ print_flag_b_=true;
+ stem_xoffset_f_ =0;
}
Stem::do_print() const
{
#ifndef NPRINT
- DOUT << "flag "<< flag_i_ << " print_flag_b_ " << print_flag_b_;
+ DOUT << "flag "<< flag_i_ << " print_flag_b_ " << print_flag_b_;
#endif
}
Real
Stem::stem_length_f()const
{
- return stem_top_f_-stem_bottom_f_ ;
+ return stem_top_f_-stem_bottom_f_ ;
}
Real
Stem::stem_start_f()const
{
- return (dir_i_ < 0)? stem_top_f_ : stem_bottom_f_;
+ return (dir_i_ < 0)? stem_top_f_ : stem_bottom_f_;
}
Real
Stem::stem_end_f() const
{
- return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_;
+ return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_;
}
void
Stem::set_stemend (Real se)
{
- // todo: margins
- if (! ((dir_i_ > 0 && se >= max_head_i()) ||
+ // todo: margins
+ if (! ((dir_i_ > 0 && se >= max_head_i()) ||
(se <= min_head_i() && dir_i_ <0)) )
warning ("Weird stem size; check for narrow beams");
- stem_top_f_ = (dir_i_ < 0) ? max_head_i() : se;
- stem_bottom_f_ = (dir_i_ < 0) ? se : min_head_i();
+ stem_top_f_ = (dir_i_ < 0) ? max_head_i() : se;
+ stem_bottom_f_ = (dir_i_ < 0) ? se : min_head_i();
}
void
Stem::add (Note_head *n)
{
- n->add_dependency (this);
- if (n->rest_b_) {
+ n->add_dependency (this);
+ if (n->rest_b_)
+ {
rest_l_arr_.push (n);
- } else if (n->balltype_i_ == 1) {
+ }
+ else if (n->balltype_i_ == 0)
+ {
whole_l_arr_.push (n);
return;
- } else{
+ }
+ else
+ {
head_l_arr_.push (n);
}
}
bool
Stem::invisible_b()const
{
- return !head_l_arr_.size();
+ return !head_l_arr_.size();
}
// if dir_i_ is set we return fake values.
int
Stem::get_center_distance_from_top()
{
- if (dir_i_)
+ if (dir_i_)
return (dir_i_ > 0) ? 0 : 1;
- int staff_center = staff_size_i_ / 2;
- int max = max_head_i() - staff_center;
- return max >? 0;
+ int staff_center = staff_size_i_ / 2;
+ int max = max_head_i() - staff_center;
+ return max >? 0;
}
// if dir_i_ is set we return fake values.
int
Stem::get_center_distance_from_bottom()
{
- if (dir_i_)
+ if (dir_i_)
return (dir_i_ > 0) ? 1 : 0;
- int staff_center = staff_size_i_ / 2;
- int min = staff_center - min_head_i();
- return min >? 0;
+ int staff_center = staff_size_i_ / 2;
+ int min = staff_center - min_head_i();
+ return min >? 0;
}
int
Stem::get_default_dir()
{
- if (dir_i_)
+ if (dir_i_)
return dir_i_;
- return (get_center_distance_from_top() >=
+ return (get_center_distance_from_top() >=
get_center_distance_from_bottom()) ? -1 : 1;
}
void
Stem::set_default_dir()
{
- dir_i_ = get_default_dir();
+ dir_i_ = get_default_dir();
}
void
Stem::set_default_stemlen()
{
- if (!dir_i_)
+ if (!dir_i_)
set_default_dir();
-
- // ugh... how about non 5-line staffs?
- if ((max_head_i() < -2 && dir_i_ == 1)
- ||(min_head_i() > staff_size_i_ && dir_i_ == -1)){
+
+ // ugh... how about non 5-line staffs?
+ if ((max_head_i() < -2 && dir_i_ == 1)
+ ||(min_head_i() > staff_size_i_ && dir_i_ == -1))
+ {
set_stemend (staff_size_i_ /2 -1);
- } else {
+ }
+ else
+ {
set_stemend ((dir_i_ > 0) ? max_head_i() + STEMLEN :
min_head_i() - STEMLEN);
void
Stem::set_default_extents()
{
- if (!stem_length_f())
+ if (!stem_length_f())
set_default_stemlen();
- set_stemend ((dir_i_< 0) ?
+ set_stemend ((dir_i_< 0) ?
max_head_i()-stem_length_f (): min_head_i () +stem_length_f ());
- if (dir_i_ > 0){
+ if (dir_i_ > 0){
stem_xoffset_f_ = paper()->note_width ()-paper ()->rule_thickness ();
- } else
+ }
+ else
stem_xoffset_f_ = 0;
}
void
Stem::set_noteheads()
{
- if (!head_l_arr_.size())
+ if (!head_l_arr_.size())
return;
- head_l_arr_.sort (Note_head::compare);
- if (dir_i_ < 0)
+ head_l_arr_.sort (Note_head::compare);
+ if (dir_i_ < 0)
head_l_arr_.reverse();
-
- head_l_arr_[0]->extremal_i_ = -1;
- head_l_arr_.top()->extremal_i_ = 1;
- int parity=1;
- int lastpos = head_l_arr_[0]->position_i_;
- for (int i=1; i < head_l_arr_.size(); i ++) {
+
+ head_l_arr_[0]->extremal_i_ = -1;
+ head_l_arr_.top()->extremal_i_ = 1;
+ int parity=1;
+ int lastpos = head_l_arr_[0]->position_i_;
+ for (int i=1; i < head_l_arr_.size(); i ++)
+ {
int dy =abs (lastpos- head_l_arr_[i]->position_i_);
- if (dy <= 1) {
+ if (dy <= 1)
+ {
if (parity)
head_l_arr_[i]->x_dir_i_ = (stem_xoffset_f_>0) ? 1:-1;
parity = !parity;
- } else
+ }
+ else
parity = 0;
lastpos = head_l_arr_[i]->position_i_;
}
void
Stem::do_pre_processing()
{
- if (stem_bottom_f_== stem_top_f_)
+ if (stem_bottom_f_== stem_top_f_)
set_default_extents();
- set_noteheads();
- flag_i_ = dir_i_*abs (flag_i_);
- transparent_b_ = invisible_b();
- empty_b_ = invisible_b();
+ set_noteheads();
+ flag_i_ = dir_i_*abs (flag_i_);
+ transparent_b_ = invisible_b();
+ empty_b_ = invisible_b();
}
Interval
Stem::do_width()const
{
- if (!print_flag_b_ || abs (flag_i_) <= 4)
+ if (!print_flag_b_ || abs (flag_i_) <= 4)
return Interval (0,0); // TODO!
- Paper_def*p= paper();
- Interval r (p->lookup_l()->flag (flag_i_).dim.x ());
- r+= stem_xoffset_f_;
- return r;
+ Paper_def*p= paper();
+ Interval r (p->lookup_l()->flag (flag_i_).dim.x ());
+ r+= stem_xoffset_f_;
+ return r;
}
Molecule*
Stem::brew_molecule_p()const
{
- Molecule *out =0;
-
- Real bot = stem_bottom_f_;
- Real top = stem_top_f_;
-
- assert (bot!=top);
+ Molecule *out =0;
+
+ Real bot = stem_bottom_f_;
+ Real top = stem_top_f_;
+
+ assert (bot!=top);
- Paper_def *p =paper();
+ Paper_def *p =paper();
- Real dy = p->internote_f();
- Symbol ss =p->lookup_l()->stem (bot*dy,top*dy);
+ Real dy = p->internote_f();
+ Symbol ss =p->lookup_l()->stem (bot*dy,top*dy);
- out = new Molecule (Atom (ss));
+ out = new Molecule (Atom (ss));
- if (print_flag_b_&&abs (flag_i_) > 4){
+ if (print_flag_b_&&abs (flag_i_) > 4)
+ {
Symbol fl = p->lookup_l()->flag (flag_i_);
Molecule m (fl);
if (flag_i_ < -4){
out->add_bottom (m);
- } else if (flag_i_ > 4) {
+ }
+ else if (flag_i_ > 4)
+ {
out->add_top (m);
- } else
+ }
+ else
assert (false);
}
- out->translate (stem_xoffset_f_, X_AXIS);
- return out;
+ out->translate (stem_xoffset_f_, X_AXIS);
+ return out;
}
Real
Stem::hpos_f()const
{
- return Item::hpos_f() + stem_xoffset_f_;
+ return Item::hpos_f() + stem_xoffset_f_;
}
void
Stem::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
- Item * o_l = o->item();
- Item * n_l = n? n->item():0;
- whole_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
- head_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
- rest_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
+ Item * o_l = o->item();
+ Item * n_l = n? n->item():0;
+ whole_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
+ head_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
+ rest_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
}
String
Super_elem::TeX_string()const
{
- String s;
- for (int i=0; i < lines_arr_.size(); i++){
+ String s;
+ for (int i=0; i < lines_arr_.size(); i++)
+ {
s += lines_arr_[i]->TeX_string();
if (i + 1<lines_arr_.size())
s += "\\interscoreline"; // TODO
}
- return s;
+ return s;
}
void
Super_elem::handle_broken_dependencies()
{
- lines_arr_ = line_of_score_l_->get_lines();
- for (int i =0; i < lines_arr_.size(); i++)
+ lines_arr_ = line_of_score_l_->get_lines();
+ for (int i =0; i < lines_arr_.size(); i++)
add_dependency (lines_arr_[i]);
}
-
+
void
Super_elem::do_substitute_dependency (Score_elem*o,Score_elem* n)
{
- if (line_of_score_l_ == o->spanner())
+ if (line_of_score_l_ == o->spanner())
line_of_score_l_ = n?(Line_of_score*)n->spanner():0;
}
Super_elem::Super_elem()
{
- line_of_score_l_ = new Line_of_score ;
+ line_of_score_l_ = new Line_of_score ;
}
void
Super_elem::do_add_processing()
{
- pscore_l_->typeset_unbroken_spanner (line_of_score_l_);
- add_dependency (line_of_score_l_);
+ pscore_l_->typeset_unbroken_spanner (line_of_score_l_);
+ add_dependency (line_of_score_l_);
}
bool
Swallow_engraver::do_try_request (Request*)
{
- return true;
+ return true;
}
Symbol::Symbol()
- : dim (Interval (0,0),Interval (0,0))
+ : dim (Interval (0,0),Interval (0,0))
{
- tex = "\\unknown";
+ tex = "\\unknown";
}
Symbol::Symbol (String s, Box b)
- : dim (b)
+ : dim (b)
{
- tex = s;
+ tex = s;
}
String
Symbol::str()const
{
- return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))";
+ return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))";
}
Symtables::Symtables (Symtables const &s)
{
- for (Assoc_iter<String, Symtable*> i (s); i.ok(); i++) {
+ for (Assoc_iter<String, Symtable*> i (s); i.ok(); i++)
+ {
add (i.key(), new Symtable (*i.val ()));
}
}
Symtables::~Symtables()
{
- for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++) {
+ for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
+ {
delete i.val();
}
}
Symbol
Symtable::lookup (String s) const
{
- if (elt_b (s))
+ if (elt_b (s))
return (*this)[s];
- else {
+ else
+ {
warning ("Symtable `" + id_str+ "\': unknown symbol `" +s+"'\n");
Symbol sy;
return sy;
Symtable*
Symtables::operator()(String s)
{
- return Assoc<String, Symtable*>::operator[](s);
+ return Assoc<String, Symtable*>::operator[](s);
}
void
Symtables::print() const
{
- for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++) {
+ for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
+ {
DOUT << "table \'" << i.key() << "\' {\n";
i.val()->print ();
DOUT << "}\n";
void
Symtable::print() const
{
- for (Assoc_iter<String, Symbol> i (*this); i.ok(); i++) {
+ for (Assoc_iter<String, Symbol> i (*this); i.ok(); i++)
+ {
DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n";
}
}
void
Symtables::add (String s, Symtable*p)
{
- p-> id_str = s;
- Assoc<String, Symtable*>::add (s,p);
+ p-> id_str = s;
+ Assoc<String, Symtable*>::add (s,p);
}
Rational
Interval_t<Rational>::infinity()
{
- return Rational (INT_MAX);
+ return Rational (INT_MAX);
}
int
Interval_t<int>::infinity()
{
- return INT_MAX;
+ return INT_MAX;
}
Symbol
Lookup::beam_element (int sidx, int widx, Real slope) const
{
- Symbol bs=(*symtables_)("beamslopes")->lookup ("slope");
-
- Array<String> args;
- args.push (sidx);
- args.push (widx);
- bs.tex = substitute_args (bs.tex,args);
- int w = 2 << widx;
- Real width = w PT;
- bs.dim.x() = Interval (0,width);
- bs.dim.y() = Interval (0,width*slope);
- return bs;
+ Symbol bs=(*symtables_)("beamslopes")->lookup ("slope");
+
+ Array<String> args;
+ args.push (sidx);
+ args.push (widx);
+ bs.tex = substitute_args (bs.tex,args);
+ int w = 2 << widx;
+ Real width = w PT;
+ bs.dim.x() = Interval (0,width);
+ bs.dim.y() = Interval (0,width*slope);
+ return bs;
}
// ugh.. hard wired tex-code.
static int
slope_index (Real &s)
{
- if (abs (s) > 0.5) {
+ if (abs (s) > 0.5)
+ {
WARN << "beam steeper than 0.5 (" << s << ")\n";
s = sign (s) * 0.5;
}
- int i = int (rint (s * 20.0));
+ int i = int (rint (s * 20.0));
- s = i/20.0;
- if (s>0)
+ s = i/20.0;
+ if (s>0)
return 6*i +122;
- else
+ else
return -6 * i+ 186;
}
Symbol
Lookup::rule_symbol (Real height, Real width) const
{
- Symbol bs=(*symtables_)("beamslopes")->lookup ("horizontal");
- Array<String> args;
- args.push (print_dimen (height));
- args.push (print_dimen (width));
- bs.tex = substitute_args (bs.tex,args);
- bs.dim.x() = Interval (0,width);
- bs.dim.y() = Interval (0,height);
- return bs;
+ Symbol bs=(*symtables_)("beamslopes")->lookup ("horizontal");
+ Array<String> args;
+ args.push (print_dimen (height));
+ args.push (print_dimen (width));
+ bs.tex = substitute_args (bs.tex,args);
+ bs.dim.x() = Interval (0,width);
+ bs.dim.y() = Interval (0,height);
+ return bs;
}
Symbol
Lookup::beam (Real &slope, Real width) const
{
- int sidx = slope_index (slope);
- if (!slope)
+ int sidx = slope_index (slope);
+ if (!slope)
return rule_symbol (2 PT, width);
- if (width < 2 PT) {
+ if (width < 2 PT)
+ {
WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
width = 2 PT;
}
- Real elemwidth = 64 PT;
- int widx = 5;
+ Real elemwidth = 64 PT;
+ int widx = 5;
- Molecule m;
-
- while (elemwidth > width) {
+ Molecule m;
+
+ while (elemwidth > width)
+ {
widx --;
elemwidth /= 2.0;
}
- Real overlap = elemwidth/4;
- Real last_x = width - elemwidth;
- Real x = overlap;
- Atom elem (beam_element (sidx, widx, slope));
- Atom a (elem);
- m.add (a);
- while (x < last_x) {
+ Real overlap = elemwidth/4;
+ Real last_x = width - elemwidth;
+ Real x = overlap;
+ Atom elem (beam_element (sidx, widx, slope));
+ Atom a (elem);
+ m.add (a);
+ while (x < last_x)
+ {
a=elem;
a.translate (Offset (x-overlap, (x-overlap)*slope));
m.add (a);
x += elemwidth - overlap;
}
- a=elem;
- a.translate (Offset (last_x, (last_x) * slope));
- m.add (a);
-
- Symbol ret;
- ret.tex = m.TeX_string();
- ret.dim.y() = Interval (0,width*slope);
- ret.dim.x() = Interval (0,width);
-
- return ret;
+ a=elem;
+ a.translate (Offset (last_x, (last_x) * slope));
+ m.add (a);
+
+ Symbol ret;
+ ret.tex = m.TeX_string();
+ ret.dim.y() = Interval (0,width*slope);
+ ret.dim.x() = Interval (0,width);
+
+ return ret;
}
static
char direction_char (int y_sign)
{
- char c='#';
- switch (y_sign){
- case -1:
+ char c='#';
+ switch (y_sign)
+ {
+ case -1:
c = 'd';
break;
- case 0:
+ case 0:
c = 'h';
break;
- case 1:
+ case 1:
c = 'u';
break;
- default:
+ default:
assert (false);
}
- return c;
+ return c;
}
Symbol
Lookup::half_slur_middlepart (Real &dx, int dir) const
{
- if (dx >= 400 PT) {// todo
+ if (dx >= 400 PT) {// todo
WARN<<"halfslur too large" <<print_dimen (dx)<< "shrinking (ugh)\n";
dx = 400 PT;
}
- int widx = int (floor (dx / 4.0));
- dx = widx * 4.0;
- if (widx) widx --;
- else {
+ int widx = int (floor (dx / 4.0));
+ dx = widx * 4.0;
+ if (widx) widx --;
+ else
+ {
WARN << "slur too narrow\n";
}
- Symbol s;
-
- s.dim.y() = Interval (min (0,0), max (0,0)); // todo
- s.dim.x() = Interval (0,dx);
+ Symbol s;
+
+ s.dim.y() = Interval (min (0,0), max (0,0)); // todo
+ s.dim.x() = Interval (0,dx);
- String f = String ("\\hslurchar");
- f += direction_char (0);
+ String f = String ("\\hslurchar");
+ f += direction_char (0);
- int idx = widx;
- if (dir < 0)
+ int idx = widx;
+ if (dir < 0)
idx += 128;
- assert (idx < 256);
+ assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
- s.tex = f;
- Atom a (s);
- a.translate (dx/2, X_AXIS);
- s.tex = a.TeX_string();
+ f+=String ("{") + String (idx ) + "}";
+ s.tex = f;
+ Atom a (s);
+ a.translate (dx/2, X_AXIS);
+ s.tex = a.TeX_string();
- return s;
+ return s;
}
Symbol
Lookup::half_slur (int dy, Real &dx, int dir, int xpart) const
{
- Real orig_dx = dx;
- if (!xpart)
+ Real orig_dx = dx;
+ if (!xpart)
return half_slur_middlepart (dx, dir);
- int widx;
-
- if (dx >= 96 PT) {
+ int widx;
+
+ if (dx >= 96 PT)
+ {
WARN << "Slur half too wide." << print_dimen (orig_dx) << " shrinking (ugh)\n";
dx = 96 PT;
}
- widx = int (rint (dx/12.0));
- dx = widx*12.0;
- if (widx)
+ widx = int (rint (dx/12.0));
+ dx = widx*12.0;
+ if (widx)
widx --;
- else {
+ else
+ {
WARN << "slur too narrow " << print_dimen (orig_dx)<<"\n";
}
- Symbol s;
- s.dim.x() = Interval (0,dx);
- s.dim.y() = Interval (min (0,dy), max (0,dy));
+ Symbol s;
+ s.dim.x() = Interval (0,dx);
+ s.dim.y() = Interval (min (0,dy), max (0,dy));
- String f = String ("\\hslurchar");
+ String f = String ("\\hslurchar");
- f+= direction_char (dir);
+ f+= direction_char (dir);
- int hidx = dy;
- if (hidx <0)
+ int hidx = dy;
+ if (hidx <0)
hidx = -hidx;
- hidx --;
- int idx =-1;
+ hidx --;
+ int idx =-1;
- idx = widx * 16 + hidx;
- if (xpart < 0)
+ idx = widx * 16 + hidx;
+ if (xpart < 0)
idx += 128;
-
- assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
+
+ assert (idx < 256);
+ f+=String ("{") + String (idx ) + "}";
-
- s.tex = f;
+
+ s.tex = f;
- return s;
+ return s;
}
Symbol
Lookup::slur (int dy , Real &dx, int dir) const
{
- assert (dx >=0 && abs (dir) <= 1);
- int y_sign = sign (dy);
+ assert (dx >=0 && abs (dir) <= 1);
+ int y_sign = sign (dy);
- bool large = abs (dy) > 8;
+ bool large = abs (dy) > 8;
- if (y_sign) {
+ if (y_sign)
+ {
large |= dx>= 4*16 PT;
- } else
+ }
+ else
large |= dx>= 4*54 PT;
-
- if (large) {
+
+ if (large)
+ {
return big_slur (dy, dx, dir);
}
- Real orig_dx = dx;
- int widx = int (floor (dx/4.0)); // slurs better too small..
- dx = 4.0 * widx;
- if (widx)
+ Real orig_dx = dx;
+ int widx = int (floor (dx/4.0)); // slurs better too small..
+ dx = 4.0 * widx;
+ if (widx)
widx --;
- else {
+ else
+ {
WARN << "slur too narrow: " << print_dimen (orig_dx) << "\n";
}
- int hidx = dy;
- if (hidx <0)
+ int hidx = dy;
+ if (hidx <0)
hidx = -hidx;
- hidx --;
- if (hidx > 8) {
+ hidx --;
+ if (hidx > 8)
+ {
WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
}
-
- Symbol s;
- s.dim.x() = Interval (0,dx);
- s.dim.y() = Interval (min (0,dy), max (0,dy));
+
+ Symbol s;
+ s.dim.x() = Interval (0,dx);
+ s.dim.y() = Interval (min (0,dy), max (0,dy));
- String f = String ("\\slurchar") + String (direction_char (y_sign));
+ String f = String ("\\slurchar") + String (direction_char (y_sign));
- int idx=-1;
- if (y_sign) {
+ int idx=-1;
+ if (y_sign) {
idx = hidx * 16 + widx;
if (dir < 0)
idx += 128;
- } else {
- if (dx >= 4*54 PT) {
+ }
+ else
+ {
+ if (dx >= 4*54 PT)
+ {
WARN << "slur too wide: " << print_dimen (dx) <<
" shrinking (ugh)\n";
dx = 4*54 PT;
- }
+ }
idx = widx;
if (dir < 0)
idx += 54;
}
-
- assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
- s.tex = f;
-
- Atom a (s);
- a.translate (dx/2, X_AXIS);
- s.dim = a.extent();
- s.tex = a.TeX_string();
- return s;
+
+ assert (idx < 256);
+ f+=String ("{") + String (idx ) + "}";
+ s.tex = f;
+
+ Atom a (s);
+ a.translate (dx/2, X_AXIS);
+ s.dim = a.extent();
+ s.tex = a.TeX_string();
+ return s;
}
Symbol
Lookup::big_slur (int dy , Real &dx, int dir) const
{
- assert (dx >= 24 PT);
- Real slur_extra =abs (dy) /2.0 + 2;
- int l_dy = int (Real (dy)/2 + slur_extra*dir);
- int r_dy = dy - l_dy;
-
- Real internote_f = paper_l_->internote_f();
- Real left_wid = dx/4.0;
- Real right_wid = left_wid;
-
- Atom l = half_slur (l_dy, left_wid, dir, -1);
- Atom r = half_slur (r_dy, right_wid, dir, 1);
- Real mid_wid = dx - left_wid - right_wid;
-
- Atom m = half_slur (0, mid_wid, dir, 0);
-
- Molecule mol;
- mol.add (l);
- Atom a (m);
- a.translate (slur_extra * internote_f, Y_AXIS);
- mol.add_right (m);
- mol.add_right (r);
- mol.translate (l_dy * internote_f, Y_AXIS);
- Symbol s;
- s.tex = mol.TeX_string();
- s.dim = mol.extent();
- return s;
+ assert (dx >= 24 PT);
+ Real slur_extra =abs (dy) /2.0 + 2;
+ int l_dy = int (Real (dy)/2 + slur_extra*dir);
+ int r_dy = dy - l_dy;
+
+ Real internote_f = paper_l_->internote_f();
+ Real left_wid = dx/4.0;
+ Real right_wid = left_wid;
+
+ Atom l = half_slur (l_dy, left_wid, dir, -1);
+ Atom r = half_slur (r_dy, right_wid, dir, 1);
+ Real mid_wid = dx - left_wid - right_wid;
+
+ Atom m = half_slur (0, mid_wid, dir, 0);
+
+ Molecule mol;
+ mol.add (l);
+ Atom a (m);
+ a.translate (slur_extra * internote_f, Y_AXIS);
+ mol.add_right (m);
+ mol.add_right (r);
+ mol.translate (l_dy * internote_f, Y_AXIS);
+ Symbol s;
+ s.tex = mol.TeX_string();
+ s.dim = mol.extent();
+ return s;
}
Tex_stream::Tex_stream (String filename)
{
- os = new ofstream (filename);
- if (!*os)
+ os = new ofstream (filename);
+ if (!*os)
error ("can't open `" + filename+"\'");
- nest_level = 0;
- line_len_i_ = 0;
- outputting_comment=false;
- header();
+ nest_level = 0;
+ line_len_i_ = 0;
+ outputting_comment=false;
+ header();
}
void
Tex_stream::header()
{
- *os << "% Creator: " << get_version_str() << "\n";
- *os << "% Automatically generated, at ";
- time_t t (time (0));
- *os << ctime (&t)<<"\n";
+ *os << "% Creator: " << get_version_str() << "\n";
+ *os << "% Automatically generated, at ";
+ time_t t (time (0));
+ *os << ctime (&t)<<"\n";
}
Tex_stream::~Tex_stream()
{
- delete os;
- assert (nest_level == 0);
+ delete os;
+ assert (nest_level == 0);
}
// print string. don't forget indent.
Tex_stream &
Tex_stream::operator<<(String s)
{
-
- for (char const *cp = s; *cp; cp++) {
- if (outputting_comment) {
+
+ for (char const *cp = s; *cp; cp++)
+ {
+ if (outputting_comment)
+ {
*os << *cp;
- if (*cp == '\n') {
+ if (*cp == '\n')
+ {
outputting_comment=false;
- }
+ }
continue;
- }
+ }
line_len_i_ ++;
switch (*cp)
{
nest_level--;
*os << *cp;
- if (nest_level < 0) {
+ if (nest_level < 0)
+ {
delete os; // we want to see the remains.
assert (nest_level>=0);
- }
+ }
/* FALLTHROUGH */
case '\n':
default:
*os << *cp;
break;
- }
+ }
}
- return *this;
+ return *this;
}
void
Tex_stream::break_line()
{
- *os << "%\n";
- *os << String (' ', nest_level);
- line_len_i_ = 0;
+ *os << "%\n";
+ *os << String (' ', nest_level);
+ line_len_i_ = 0;
}
/* *************************************************************** */
String
vstrut (Real h)
{
- return String ("\\vrule height ") + print_dimen (h) + "depth 0pt width 0pt";
+ return String ("\\vrule height ") + print_dimen (h) + "depth 0pt width 0pt";
}
static void
substitute_arg (String& r, String arg)
{
- int p = r.index_i ('%');
- if (p < 0)
+ int p = r.index_i ('%');
+ if (p < 0)
return ;
- r = r.left_str (p) + arg + r.right_str (r.length_i() - p -1);
+ r = r.left_str (p) + arg + r.right_str (r.length_i() - p -1);
}
String
substitute_args (String source, Array<String> args)
{
- String retval (source);
- for (int i = 0 ; i < args.size(); i++)
- substitute_arg (retval, args[i]);
- /*
- while (retval.index_i ('%') >= 0)
- substitute_arg (retval, "");
+ String retval (source);
+ for (int i = 0 ; i < args.size(); i++)
+ substitute_arg (retval, args[i]);
+ /*
+ while (retval.index_i ('%') >= 0)
+ substitute_arg (retval, "");
*/
- return retval;
+ return retval;
}
String
substitute_args (String source, Array<Scalar> args)
{
- Array<String> sv;
- for (int i = 0 ; i < args.size(); i++)
+ Array<String> sv;
+ for (int i = 0 ; i < args.size(); i++)
sv.push (args[i]);
-
- return substitute_args (source, sv);
+
+ return substitute_args (source, sv);
}
Interval
Text_def::width (Paper_def * p) const
{
- Atom a = get_atom (p,0);
+ Atom a = get_atom (p,0);
- Real guess_width_f = text_str_.length_i() * a.sym_.dim.x ().length (); // ugh
- Interval i (0, guess_width_f);
- i += - (align_i_ + 1)* i.center();
- return i;
+ Real guess_width_f = text_str_.length_i() * a.sym_.dim.x ().length (); // ugh
+ Interval i (0, guess_width_f);
+ i += - (align_i_ + 1)* i.center();
+ return i;
}
void
Text_def::do_print() const
{
#ifndef NPRINT
- DOUT << "align " <<align_i_ << " `" << text_str_ << "'";
+ DOUT << "align " <<align_i_ << " `" << text_str_ << "'";
#endif
}
Text_def::Text_def()
{
- align_i_ = 1; // right
- style_str_ = "roman";
+ align_i_ = 1; // right
+ style_str_ = "roman";
}
bool
Text_def::do_equal_b (General_script_def const *gdef) const
{
- Text_def const *def= (Text_def*)gdef;
- return align_i_ == def->align_i_ && text_str_ == def->text_str_
+ Text_def const *def= (Text_def*)gdef;
+ return align_i_ == def->align_i_ && text_str_ == def->text_str_
&& style_str_ == def->style_str_;
}
Atom
Text_def::get_atom (Paper_def *p, int) const
{
- return p->lookup_l()->text (style_str_, text_str_, -align_i_);
+ return p->lookup_l()->text (style_str_, text_str_, -align_i_);
}
void
Text_def::print() const
{
- DOUT << "Text `" << text_str_ << "\', style " <<
+ DOUT << "Text `" << text_str_ << "\', style " <<
style_str_ << "align " << align_i_ << '\n';
}
Text_engraver::Text_engraver()
{
- text_p_ = 0;
- dir_i_ =0;
- do_post_move_processing();
+ text_p_ = 0;
+ dir_i_ =0;
+ do_post_move_processing();
}
bool
Text_engraver::do_try_request (Request*req_l)
{
- Musical_req *m = req_l->musical();
- if (!m || ! m->text())
+ Musical_req *m = req_l->musical();
+ if (!m || ! m->text())
return false;
- if (text_req_l_ && text_req_l_->equal_b (m))
+ if (text_req_l_ && text_req_l_->equal_b (m))
return false;
- text_req_l_ = m->text();
- return true;
+ text_req_l_ = m->text();
+ return true;
}
void
Text_engraver::acknowledge_element (Score_elem_info i)
{
- if (text_p_ && i.elem_l_->name() == Note_column::static_name ()) {
+ if (text_p_ && i.elem_l_->name() == Note_column::static_name ())
+ {
text_p_->add_support (i.elem_l_);
}
}
void
Text_engraver::do_process_requests()
{
- if (text_req_l_) {
+ if (text_req_l_)
+ {
text_p_ = new Text_item (text_req_l_->tdef_p_, text_req_l_->dir_i_); // ugh
announce_element (Score_elem_info (text_p_, text_req_l_));
}
void
Text_engraver::do_pre_move_processing()
{
- if (text_p_) {
+ if (text_p_)
+ {
if (dir_i_ && !text_p_->dir_i_)
text_p_->dir_i_ = dir_i_;
Staff_symbol* s_l = get_staff_info().staff_sym_l_;
void
Text_engraver::set_feature (Feature i)
{
- if (i.type_ == "vdir")
+ if (i.type_ == "vdir")
dir_i_ = i.value_;
}
void
Text_engraver::do_post_move_processing()
{
- text_req_l_ = 0;
+ text_req_l_ = 0;
}
IMPLEMENT_IS_TYPE_B1(Text_engraver,Engraver);
Text_item::Text_item (General_script_def*tdef_l, int d)
{
- dir_i_ = d;
- fat_b_ = false;
- tdef_p_ = tdef_l->clone();
+ dir_i_ = d;
+ fat_b_ = false;
+ tdef_p_ = tdef_l->clone();
}
Text_item::~Text_item()
{
- delete tdef_p_;
+ delete tdef_p_;
}
void
Text_item::do_pre_processing()
{
- if (!dir_i_)
+ if (!dir_i_)
dir_i_ = -1;
}
Interval
Text_item::symbol_height()const
{
- return tdef_p_->get_atom (paper(), dir_i_).sym_.dim.y ();
+ return tdef_p_->get_atom (paper(), dir_i_).sym_.dim.y ();
}
-
+
Molecule*
Text_item::brew_molecule_p() const
{
- Atom a (tdef_p_->get_atom (paper(), dir_i_));
+ Atom a (tdef_p_->get_atom (paper(), dir_i_));
/*
if ( fat_b_)
a.sym.dim.x = tdef_p_->width (paper());
*/
- Molecule* mol_p = new Molecule (a);
+ Molecule* mol_p = new Molecule (a);
- if (dir_i_<0) // should do something better anyway.
+ if (dir_i_<0) // should do something better anyway.
mol_p->translate (-mol_p->extent().y ().left , Y_AXIS);
- mol_p->translate (pos_i_ * paper()->internote_f (), Y_AXIS);
-
- return mol_p;
+ mol_p->translate (pos_i_ * paper()->internote_f (), Y_AXIS);
+
+ return mol_p;
}
void
Text_spanner::set_support (Directional_spanner*d)
{
- if (support_span_l_)
+ if (support_span_l_)
remove_dependency (support_span_l_);
-
- support_span_l_ =d;
- add_dependency (d);
+
+ support_span_l_ =d;
+ add_dependency (d);
}
Text_spanner::Text_spanner()
{
- spec_p_ = 0;
- support_span_l_ = 0;
+ spec_p_ = 0;
+ support_span_l_ = 0;
}
void
Text_spanner::do_print() const
{
- spec_p_->print();
+ spec_p_->print();
}
void
Text_spanner::do_post_processing()
{
- text_off_ = support_span_l_->center() +
+ text_off_ = support_span_l_->center() +
Offset (0,support_span_l_->dir_i_ * paper()->internote_f () * 4); // todo
}
Molecule*
Text_spanner::brew_molecule_p() const
{
- Atom tsym (spec_p_->get_atom (paper(),0));
- tsym.translate (text_off_);
+ Atom tsym (spec_p_->get_atom (paper(),0));
+ tsym.translate (text_off_);
- Molecule*output = new Molecule;
- output->add (tsym);
- return output;
+ Molecule*output = new Molecule;
+ output->add (tsym);
+ return output;
}
void
Text_spanner::do_pre_processing()
{
- right_col_l_ = support_span_l_->right_col_l_;
- left_col_l_ = support_span_l_->left_col_l_;
- assert (left_col_l_ && right_col_l_);
+ right_col_l_ = support_span_l_->right_col_l_;
+ left_col_l_ = support_span_l_->left_col_l_;
+ assert (left_col_l_ && right_col_l_);
}
Interval
Text_spanner::height()const
{
- return brew_molecule_p()->extent ().y ();
+ return brew_molecule_p()->extent ().y ();
}
void
Text_spanner::do_substitute_dependency (Score_elem* o, Score_elem*n)
{
- if (support_span_l_ == o)
+ if (support_span_l_ == o)
support_span_l_ = (Directional_spanner*) (n?n->spanner():0);
}
Text_spanner::~Text_spanner()
{
- delete spec_p_;
+ delete spec_p_;
}
Text_spanner::Text_spanner (Text_spanner const&s)
- : Spanner (s)
+ : Spanner (s)
{
- support_span_l_ = s.support_span_l_;
- spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
- text_off_ = s.text_off_;
+ support_span_l_ = s.support_span_l_;
+ spec_p_ = s.spec_p_? s.spec_p_->clone() : 0;
+ text_off_ = s.text_off_;
}
Tie_engraver::Tie_engraver()
{
- end_tie_p_ = 0;
- tie_p_ = 0;
- req_l_ =0;
- end_req_l_ =0;
- end_mom_ = -1;
- melodic_req_l_ = 0;
- end_melodic_req_l_ =0;
- dir_i_ = 0;
+ end_tie_p_ = 0;
+ tie_p_ = 0;
+ req_l_ =0;
+ end_req_l_ =0;
+ end_mom_ = -1;
+ melodic_req_l_ = 0;
+ end_melodic_req_l_ =0;
+ dir_i_ = 0;
}
void
Tie_engraver::sync_features()
{
- dir_i_ = get_feature ("vdir");
+ dir_i_ = get_feature ("vdir");
}
-
+
void
Tie_engraver::do_post_move_processing()
{
- if (tie_p_ && get_staff_info().when () == end_mom_) {
+ if (tie_p_ && get_staff_info().when () == end_mom_)
+ {
end_tie_p_ = tie_p_;
end_req_l_ = req_l_;
end_melodic_req_l_ = melodic_req_l_;
bool
Tie_engraver::acceptable_request_b (Request*r)
{
- return r->musical() && r->musical ()->tie ();
+ return r->musical() && r->musical ()->tie ();
}
bool
Tie_engraver::do_try_request (Request*r)
{
- if (!acceptable_request_b (r))
+ if (!acceptable_request_b (r))
return false;
- if (req_l_) {
+ if (req_l_)
+ {
return false;
}
- req_l_ = r->musical()->tie ();
- end_mom_ = r->parent_music_l_->time_int().length ()
+ req_l_ = r->musical()->tie ();
+ end_mom_ = r->parent_music_l_->time_int().length ()
+ get_staff_info().when ();
- return true;
+ return true;
}
void
Tie_engraver::do_process_requests()
{
- if (req_l_ && ! tie_p_) {
+ if (req_l_ && ! tie_p_)
+ {
tie_p_ = new Tie;
}
}
void
Tie_engraver::acknowledge_element (Score_elem_info i)
{
- if (i.elem_l_->name() == Note_head::static_name ()) {
- if (tie_p_) {
+ if (i.elem_l_->name() == Note_head::static_name ())
+ {
+ if (tie_p_)
+ {
tie_p_->set_head (-1, (Note_head*)i.elem_l_->item());
melodic_req_l_ = i.req_l_->musical()->melodic ();
- }
+ }
- if (end_tie_p_) {
+ if (end_tie_p_)
+ {
end_tie_p_->set_head (1, (Note_head*)i.elem_l_->item());
if (!Melodic_req::compare ( *end_melodic_req_l_, *melodic_req_l_))
end_tie_p_->same_pitch_b_ = true;
announce_element (Score_elem_info (end_tie_p_,end_req_l_));
- }
+ }
}
}
void
Tie_engraver::do_pre_move_processing()
{
- if (end_tie_p_) {
+ if (end_tie_p_)
+ {
if (dir_i_)
end_tie_p_->dir_i_ = dir_i_;
Tie_engraver::~Tie_engraver()
{
- if (tie_p_) {
+ if (tie_p_)
+ {
req_l_->warning ("unended Tie");
delete tie_p_;
}
void
Tie_engraver::set_feature (Feature f)
{
- if (f.type_ == "vdir")
+ if (f.type_ == "vdir")
dir_i_ = f.value_;
}
void
Tie::set_head (int x_pos, Note_head * head_l)
{
- if (x_pos >0) {
+ if (x_pos >0)
+ {
assert (!right_head_l_);
right_head_l_ = head_l;
- } else {
+ }
+ else
+ {
assert (!left_head_l_);
left_head_l_ = head_l;
}
- add_dependency (head_l);
+ add_dependency (head_l);
}
Tie::Tie()
{
- right_head_l_ =0;
- left_head_l_ =0;
- same_pitch_b_ =false;
+ right_head_l_ =0;
+ left_head_l_ =0;
+ same_pitch_b_ =false;
}
void
Tie::set_default_dir()
{
- int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
- dir_i_ = (m < 5)? -1:1; // ugh
+ int m= (left_head_l_->position_i_ + right_head_l_->position_i_) /2 ;
+ dir_i_ = (m < 5)? -1:1; // ugh
}
-
+
void
Tie::do_add_processing()
{
- assert (left_head_l_ && right_head_l_);
- left_col_l_ = left_head_l_ -> pcol_l_;
- right_col_l_ = right_head_l_ -> pcol_l_;
+ assert (left_head_l_ && right_head_l_);
+ left_col_l_ = left_head_l_ -> pcol_l_;
+ right_col_l_ = right_head_l_ -> pcol_l_;
}
/**
void
Tie::do_post_processing()
{
- assert (left_head_l_ || right_head_l_);
- left_pos_i_ = (left_head_l_)?
+ assert (left_head_l_ || right_head_l_);
+ left_pos_i_ = (left_head_l_)?
left_head_l_->position_i_ : right_head_l_->position_i_;
- right_pos_i_ = (right_head_l_) ?
+ right_pos_i_ = (right_head_l_) ?
right_head_l_->position_i_ : left_head_l_->position_i_;
- if ( right_head_l_ && right_head_l_->extremal_i_) {
+ if ( right_head_l_ && right_head_l_->extremal_i_)
+ {
right_pos_i_ += 2*dir_i_;
right_dx_f_ -= 0.25;
- } else
+ }
+ else
right_dx_f_ -= 0.5;
- if (left_head_l_ && left_head_l_->extremal_i_) {
+ if (left_head_l_ && left_head_l_->extremal_i_)
+ {
left_pos_i_ += 2*dir_i_;
left_dx_f_ += 0.25;
- } else
+ }
+ else
left_dx_f_ += 0.5;
-
- if (!right_head_l_)
+
+ if (!right_head_l_)
right_pos_i_ = left_pos_i_;
- if (! left_head_l_)
+ if (! left_head_l_)
left_pos_i_ = right_pos_i_;
}
void
Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
{
- Note_head *new_l =n?(Note_head*)n->item():0;
- if (o->item() == left_head_l_)
+ Note_head *new_l =n?(Note_head*)n->item():0;
+ if (o->item() == left_head_l_)
left_head_l_ = new_l;
- else if (o->item() == right_head_l_)
+ else if (o->item() == right_head_l_)
right_head_l_ = new_l;
}
String
Time_description::str()const
{
- String s ("Time_description { ");
- if (cadenza_b_)
+ String s ("Time_description { ");
+ if (cadenza_b_)
s+=String (" (cadenza) ");
- s+= "at ";
- s+=when_;
- s+="\nmeter " + String (whole_per_measure_/one_beat_) +":" +
+ s+= "at ";
+ s+=when_;
+ s+="\nmeter " + String (whole_per_measure_/one_beat_) +":" +
String (Rational (Rational (1)/one_beat_));
- s+= "\nposition "+String (bars_i_) + ":"+ whole_in_measure_ +"\n}\n";
- return s;
+ s+= "\nposition "+String (bars_i_) + ":"+ whole_in_measure_ +"\n}\n";
+ return s;
}
void
Time_description::print() const
{
#ifndef NPRINT
- DOUT << str();
+ DOUT << str();
#endif
}
void
Time_description::OK() const
{
#ifndef NDEBUG
- if (!cadenza_b_)
+ if (!cadenza_b_)
assert (whole_in_measure_ < whole_per_measure_);
- assert (Moment (0) <= whole_in_measure_);
- assert (one_beat_);
+ assert (Moment (0) <= whole_in_measure_);
+ assert (one_beat_);
#endif
}
void
Time_description::set_cadenza (bool b)
{
- if (cadenza_b_ && !b) {
- if (whole_in_measure_) {
+ if (cadenza_b_ && !b)
+ {
+ if (whole_in_measure_)
+ {
bars_i_ ++; // should do?
whole_in_measure_ = 0;
- }
+ }
}
- cadenza_b_ = b ;
+ cadenza_b_ = b ;
}
Time_description::Time_description()
{
- error_b_ = false;
- whole_per_measure_ = 1;
- whole_in_measure_ =0;
- one_beat_ = Moment (1,4);
- when_ = 0;
- bars_i_ = 0;
- cadenza_b_ = false;
+ error_b_ = false;
+ whole_per_measure_ = 1;
+ whole_in_measure_ =0;
+ one_beat_ = Moment (1,4);
+ when_ = 0;
+ bars_i_ = 0;
+ cadenza_b_ = false;
}
void
Time_description::add (Moment dt)
{
- assert (dt >= Rational (0));
- when_ += dt;
- whole_in_measure_ += dt;
+ assert (dt >= Rational (0));
+ when_ += dt;
+ whole_in_measure_ += dt;
- while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_) {
+ while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_)
+ {
whole_in_measure_ -= whole_per_measure_;
bars_i_ ++;
}
void
Time_description::set_meter (int l, int o)
{
- assert (o);
- one_beat_ = Rational (1)/Moment (o);
- whole_per_measure_ = Moment (l) * one_beat_;
+ assert (o);
+ one_beat_ = Rational (1)/Moment (o);
+ whole_per_measure_ = Moment (l) * one_beat_;
}
bool
Time_description::allow_meter_change_b()
{
- return!(whole_in_measure_);
+ return!(whole_in_measure_);
}
/**
String
Time_description::try_set_partial_str (Moment p)const
{
- if (p<Rational (0))
+ if (p<Rational (0))
return ("Partial must be non-negative");
- if (p > whole_per_measure_)
+ if (p > whole_per_measure_)
return ("Partial measure too large");
- return "";
+ return "";
}
void
Time_description::setpartial (Moment p)
{
- whole_in_measure_ = whole_per_measure_ - p;
+ whole_in_measure_ = whole_per_measure_ - p;
}
Moment
Time_description::barleft()const
{
- assert (!cadenza_b_);
- return whole_per_measure_-whole_in_measure_;
+ assert (!cadenza_b_);
+ return whole_per_measure_-whole_in_measure_;
}
int
Time_description::compare (Time_description const &t1, Time_description const&t2)
{
- int i = sign (t1.when_-t2.when_);
+ int i = sign (t1.when_-t2.when_);
- if (!i) {
+ if (!i)
+ {
assert (t1.bars_i_==t2.bars_i_);
assert (t1.one_beat_ == t2.one_beat_);
assert (t1.whole_in_measure_ == t2.whole_in_measure_);
assert (t1.whole_per_measure_ == t2.whole_per_measure_);
}
- return i;
+ return i;
}
Moment
Time_description::next_bar_moment() const
{
- return when_ + barleft();
+ return when_ + barleft();
}
Timing_engraver::Timing_engraver()
{
- default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh
+ default_grouping_ = Rhythmic_grouping (MInterval (0,4),4); // ugh
}
void
Timing_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_;
}
Translator::Translator()
{
- iterator_count_ = 0;
+ iterator_count_ = 0;
}
bool
Translator::try_request (Request*)
{
- return false;
+ return false;
}
String
get_version_str()
{
- String s = lily_version_sz();
- s+="/";
- s+=flower_version_sz();
+ String s = lily_version_sz();
+ s+="/";
+ s+=flower_version_sz();
return s;
}
void
Vertical_align_element::add (Score_elem*el_l)
{
- assert (! contains_b (el_l));
- elem_l_arr_.push (el_l);
- add_dependency (el_l);
+ assert (! contains_b (el_l));
+ elem_l_arr_.push (el_l);
+ add_dependency (el_l);
}
void
Vertical_align_element::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
- int i;
- while ((i = elem_l_arr_.find_i (o))>=0)
+ int i;
+ while ((i = elem_l_arr_.find_i (o))>=0)
if (n)
elem_l_arr_[i] = n;
else
void
Vertical_align_element::do_post_processing()
{
- Array<Interval> dims;
- for (int i=0; i < elem_l_arr_.size(); i++) {
+ Array<Interval> dims;
+ for (int i=0; i < elem_l_arr_.size(); i++)
+ {
Interval y = elem_l_arr_[i]->height() ;
if (y.empty_b())
y = Interval (0,0);
dims.push (y);
}
- Real where_f=0;
- for ( int i=0 ; i < elem_l_arr_.size(); i++) {
+ Real where_f=0;
+ for ( int i=0 ; i < elem_l_arr_.size(); i++)
+ {
elem_l_arr_[i]->translate (- dims[i][1] - where_f, Y_AXIS);
where_f += dims[i].length();
}
bool
Vertical_align_element::contains_b (Score_elem const *e)const
{
- return elem_l_arr_.find_l (e);
+ return elem_l_arr_.find_l (e);
}
Vertical_align_element::Vertical_align_element()
{
- transparent_b_ = true;
- empty_b_ =true;
+ transparent_b_ = true;
+ empty_b_ =true;
}
Vertical_align_engraver::Vertical_align_engraver()
{
- valign_p_ =0;
+ valign_p_ =0;
}
void
Vertical_align_engraver::do_creation_processing()
{
- valign_p_ =new Vertical_align_spanner;
- valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ;
- announce_element (Score_elem_info (valign_p_ , 0));
+ valign_p_ =new Vertical_align_spanner;
+ valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ;
+ announce_element (Score_elem_info (valign_p_ , 0));
}
void
Vertical_align_engraver::do_removal_processing()
{
- valign_p_->right_col_l_ = get_staff_info().command_pcol_l ();
- typeset_element (valign_p_);
- valign_p_ =0;
+ valign_p_->right_col_l_ = get_staff_info().command_pcol_l ();
+ typeset_element (valign_p_);
+ valign_p_ =0;
}
void
Vertical_align_engraver::acknowledge_element (Score_elem_info i)
{
- if ( i.origin_grav_l_arr_.size() == 2 &&
+ if ( i.origin_grav_l_arr_.size() == 2 &&
i.elem_l_->is_type_b (Vertical_group_element::static_name()) &&
- !i.elem_l_->axis_group_l_a_[Y_AXIS] ) {
+ !i.elem_l_->axis_group_l_a_[Y_AXIS] )
+ {
assert (!valign_p_->contains_b (i.elem_l_));
valign_p_->add ( i.elem_l_);
Voice_group_engravers::Voice_group_engravers()
{
- dir_i_ =0;
+ dir_i_ =0;
}
bool
Voice_group_engravers::do_try_request (Request*r_l)
{
- Command_req* c_l = r_l->command();
- if (c_l&& c_l->groupfeature()) {
+ Command_req* c_l = r_l->command();
+ if (c_l&& c_l->groupfeature())
+ {
Feature f;
f.type_ = c_l->groupfeature()->type_str_;
f.value_ = c_l->groupfeature()->value_str_;
set_feature (f);
return true;
}
- return Engraver_group_engraver::do_try_request (r_l);
+ return Engraver_group_engraver::do_try_request (r_l);
}
Voice_group_engravers::do_print() const
{
#ifndef NPRINT
- Engraver_group_engraver::do_print();
+ Engraver_group_engraver::do_print();
#endif
}
Scalar
Voice_group_engravers::get_feature (String f)
{
- if (f == "vdir")
+ if (f == "vdir")
return dir_i_;
- Engraver_group_engraver::get_feature (f);
+ Engraver_group_engraver::get_feature (f);
}
ADD_THIS_ENGRAVER(Voice_group_engravers);
void
error_t (String const & s, Moment const & r)
{
- String t_mom = String (trunc (r)) + String (r - Moment (trunc (r)));
- String e=s+ " (t = " + t_mom + ")";
- error (e);
+ String t_mom = String (trunc (r)) + String (r - Moment (trunc (r)));
+ String e=s+ " (t = " + t_mom + ")";
+ error (e);
}
void
error_t (String const & s, Time_description const &t_tdes)
{
- String e=s+ " (at t=" + String (t_tdes.bars_i_) + ": " + String (t_tdes.whole_in_measure_) + ")\n";
- error (e);
+ String e=s+ " (at t=" + String (t_tdes.bars_i_) + ": " + String (t_tdes.whole_in_measure_) + ")\n";
+ error (e);
}
Array<Col_hpositions>
Word_wrap::do_solve()const
{
- problem_OK();
-
- PCursor<PCol*> curcol (pscore_l_->col_p_list_.top());
- Array<Col_hpositions> breaking;
- Line_of_cols breakpoints (find_breaks());
- assert (breakpoints.size()>=2);
-
- int break_idx_i=0;
- while ( break_idx_i < breakpoints.size() -1) {
+ problem_OK();
+
+ PCursor<PCol*> curcol (pscore_l_->col_p_list_.top());
+ Array<Col_hpositions> breaking;
+ Line_of_cols breakpoints (find_breaks());
+ assert (breakpoints.size()>=2);
+
+ int break_idx_i=0;
+ while ( break_idx_i < breakpoints.size() -1)
+ {
Col_hpositions minimum;
Col_hpositions current;
- // do another line
+ // do another line
PCol *post = breakpoints[break_idx_i]->postbreak_p_;
current.add (post);
curcol++; // skip the breakable.
break_idx_i++;
- while (break_idx_i < breakpoints.size()) {
+ while (break_idx_i < breakpoints.size())
+ {
// add another measure.
- while (breakpoints[break_idx_i] != curcol.ptr()){
+ while (breakpoints[break_idx_i] != curcol.ptr())
+ {
current.add (curcol);
curcol++;
- }
+ }
current.add (breakpoints[break_idx_i]->prebreak_p_);
current.spacer_l_ = generate_spacing_problem (current.cols);
// try to solve
- if (!feasible (current.cols)) {
- if (!minimum.cols.size()) {
+ if (!feasible (current.cols))
+ {
+ if (!minimum.cols.size())
+ {
warning ("Ugh, this measure is too long, breakpoint: "
+ String (break_idx_i) +
" (generating stupido solution)");
current.stupid_solution();
current.energy_f_ = - 1; // make sure we break out.
- } else
+ }
+ else
current.energy_f_ = infinity_f; // make sure we go back
- } else {
+ }
+ else
+ {
current.solve_line();
current.print();
- }
+ }
delete current.spacer_l_;
current.spacer_l_ =0;
// update minimum, or backup.
- if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0) {
+ if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0)
+ {
minimum = current;
- } else { // we're one col too far.
+ }
+ else { // we're one col too far.
break_idx_i--;
while (curcol.ptr() != breakpoints[break_idx_i])
curcol --;
break; // do the next line.
- }
+ }
// add nobreak version of breakable column
current.cols.top()=breakpoints[break_idx_i];
curcol ++;
break_idx_i++;
- }
+ }
*mlog << "[" <<break_idx_i<<"]"<<flush;
breaking.push (minimum);
}
- print_stats();
- return breaking;
+ print_stats();
+ return breaking;
}
Word_wrap::Word_wrap()
{
- get_line_spacer = Spring_spacer::constructor;
+ get_line_spacer = Spring_spacer::constructor;
}
Begin3
Title: LilyPond
-Version: 0.1.8
-Entered-date: 15AUG97
+Version: 0.1.9
+Entered-date: 17AUG97
Description: GNU LilyPond is a program which converts music
definition files into visual or auditive output: it can
typeset formatted sheet music to a TeX file and and
jan@digicash.com (Jan Nieuwenhuizen)
Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys)
Primary-site: sunsite.unc.edu /pub/Linux/apps
- 340k lilypond-0.1.8.tar.gz
+ 340k lilypond-0.1.9.tar.gz
Original-site: pcnov095.win.tue.nl /pub/lilypond/
- 340k lilypond-0.1.8.tar.gz
+ 340k lilypond-0.1.9.tar.gz
Copying-policy: GPL
End
Name: lilypond
-Version: 0.1.8
+Version: 0.1.9
Release: 1
Copyright: GPL
Group: Applications/Publishing
-Source0: pcnov095.win.tue.nl:/pub/lilypond/lilypond-0.1.8.tar.gz
+Source0: pcnov095.win.tue.nl:/pub/lilypond/lilypond-0.1.9.tar.gz
Summary: A preprocessor to make TeX typeset music.
URL: http://www.stack.nl/~hanwen/lilypond
Packager: Han-Wen Nienhuys <hanwen@stack.nl>
make prefix="$RPM_BUILD_ROOT/usr" install
%files
%doc Documentation/out/AUTHORS.text Documentation/out/CodingStyle.text Documentation/out/INSTALL.text Documentation/out/MANIFESTO.text Documentation/out/convert-mudela.text Documentation/out/faq.text Documentation/out/gnu-music.text Documentation/out/index.text Documentation/out/internals.text Documentation/out/language.text Documentation/out/lilypond.text Documentation/out/links.text Documentation/out/literature.text Documentation/out/mi2mu.text Documentation/out/mudela-book.text Documentation/out/mutopia.text Documentation/out/other-packages.text BUGS TODO NEWS DEDICATION ANNOUNCE README
-%doc input/beams.ly input/cadenza.ly input/collisions.ly input/coriolan-alto.ly input/gallina.ly input/header.ly input/keys.ly input/kortjakje.ly input/multi.ly input/pedal.ly input/rhythm.ly input/s.ly input/scales.ly input/scripts.ly input/scsii-menuetto.ly input/scsii-menuetto.tex input/slurs.ly input/standchen.ly input/standchen.tex input/toccata-fuga-E.ly input/twinkle-pop.ly input/twinkle.ly input/wohltemperirt.ly Documentation/mudela-course.doc Documentation/mudela-man.doc
+%doc input/beams.ly input/cadenza.ly input/collisions.ly input/coriolan-alto.ly input/gallina.ly input/header.ly input/keys.ly input/kortjakje.ly input/multi.ly input/pedal.ly input/rhythm.ly input/scales.ly input/scripts.ly input/scsii-menuetto.ly input/scsii-menuetto.tex input/slurs.ly input/standchen.ly input/standchen.tex input/toccata-fuga-E.ly input/twinkle-pop.ly input/twinkle.ly input/wohltemperirt.ly Documentation/mudela-course.doc Documentation/mudela-man.doc
%doc Documentation/lelie_logo.gif
/usr/bin/convert-mudela
/usr/bin/mudela-book
void
usage()
{
- LOGOUT(NORMAL_ver) <<
+ LOGOUT(NORMAL_ver) <<
"Usage: mi2mu [options] midi-file\n"
- "Translate midi-file to mudela\n"
- "\n"
- "Options:\n"
- " -b, --no-quantify write exact durations, e.g.: a4*385/384\n"
- " -d, --debug print lots of debugging stuff\n"
- " -h, --help this help\n"
- " -I, --include=DIR add DIR to search path\n"
- " -n, --no-silly assume no plets or double dots, smallest is 32\n"
- " -o, --output=FILE set FILE as default output\n"
- " -p, --no-plets assume no plets\n"
- " -q, --quiet be quiet\n"
- " -s, --smallest=N assume no shorter (reciprocal) durations than N\n"
- " -v, --verbose be verbose\n"
- " -w, --warranty show warranty and copyright\n"
- " -x, --no-double-dots assume no double dotted notes\n"
- ;
+ "Translate midi-file to mudela\n"
+ "\n"
+ "Options:\n"
+ " -b, --no-quantify write exact durations, e.g.: a4*385/384\n"
+ " -d, --debug print lots of debugging stuff\n"
+ " -h, --help this help\n"
+ " -I, --include=DIR add DIR to search path\n"
+ " -n, --no-silly assume no plets or double dots, smallest is 32\n"
+ " -o, --output=FILE set FILE as default output\n"
+ " -p, --no-plets assume no plets\n"
+ " -q, --quiet be quiet\n"
+ " -s, --smallest=N assume no shorter (reciprocal) durations than N\n"
+ " -v, --verbose be verbose\n"
+ " -w, --warranty show warranty and copyright\n"
+ " -x, --no-double-dots assume no double dotted notes\n"
+ ;
}
void
identify()
{
- LOGOUT(NORMAL_ver) << mi2mu_version_str() << endl;
+ LOGOUT(NORMAL_ver) << mi2mu_version_str() << endl;
}
-
+
void
notice()
{
- LOGOUT(NORMAL_ver) <<
- "\n"
- "Mi2mu, translate midi to mudela.\n"
- "Copyright (C) 1997 by\n"
- " Jan Nieuwenhuizen <jan@digicash.com>\n"
- " Han-Wen Nienhuys <hanwen@stack.nl>\n"
- "\n"
- " This program is free software; you can redistribute it and/or\n"
- "modify it under the terms of the GNU General Public License version 2\n"
- "as published by the Free Software Foundation.\n"
- "\n"
- " This program is distributed in the hope that it will be useful,\n"
- "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
- "General Public License for more details.\n"
- "\n"
- " You should have received a copy (refer to the file COPYING) of the\n"
- "GNU General Public License along with this program; if not, write to\n"
- "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
- "USA.\n";
+ LOGOUT(NORMAL_ver) <<
+ "\n"
+ "Mi2mu, translate midi to mudela.\n"
+ "Copyright (C) 1997 by\n"
+ " Jan Nieuwenhuizen <jan@digicash.com>\n"
+ " Han-Wen Nienhuys <hanwen@stack.nl>\n"
+ "\n"
+ " This program is free software; you can redistribute it and/or\n"
+ "modify it under the terms of the GNU General Public License version 2\n"
+ "as published by the Free Software Foundation.\n"
+ "\n"
+ " This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+ "General Public License for more details.\n"
+ "\n"
+ " You should have received a copy (refer to the file COPYING) of the\n"
+ "GNU General Public License along with this program; if not, write to\n"
+ "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
+ "USA.\n";
}
int
main (int argc_i, char* argv_sz_a[])
{
- rat_printer = print_rat;
+ rat_printer = print_rat;
- Long_option_init long_option_init_a[] = {
+ Long_option_init long_option_init_a[] =
+ {
{0, "no-quantify", 'b'},
{0, "debug", 'd'},
{0, "help", 'h'},
{0, "warranty", 'w'},
{0, "no-double-dots", 'x'},
{0,0,0}
- };
- Getopt_long getopt_long (argc_i, argv_sz_a, long_option_init_a);
+ };
+ Getopt_long getopt_long (argc_i, argv_sz_a, long_option_init_a);
- String output_str;
- while (Long_option_init const* long_option_init_p = getopt_long())
- switch (long_option_init_p->shortname) {
+ String output_str;
+ while (Long_option_init const* long_option_init_p = getopt_long())
+ switch (long_option_init_p->shortname)
+ {
case 'b':
Duration_convert::no_quantify_b_s = true;
break;
case 'n':
Duration_convert::no_double_dots_b_s = true;
Duration_convert::no_triplets_b_s = true;
- Duration_convert::no_smaller_than_i_s = 32;
+ Duration_convert::no_smaller_than_i_s = 5;
break;
case 'o':
output_str = getopt_long.optional_argument_ch_C_;
case 'q':
level_ver = QUIET_ver;
break;
- case 's': {
+ case 's':
+ {
int i = String_convert::dec2_i (getopt_long.optional_argument_ch_C_);
- if (!i) {
+ if (!i)
+ {
identify();
usage();
exit (2); //usage
- }
- Duration_convert::no_smaller_than_i_s = i;
- }
+ }
+ Duration_convert::no_smaller_than_i_s =
+ Duration_convert::i2_type(i);
+ }
break;
case 'v':
level_ver = VERBOSE_ver;
default:
assert (0);
break;
- }
+ }
- // flag -q must be checked first
- identify();
+ // flag -q must be checked first
+ identify();
- path.add ("");
- source_l_g->set_path (&path);
+ path.add ("");
+ source_l_g->set_path (&path);
- char const* arg_sz = 0;
- while ( (arg_sz = getopt_long.get_next_arg())) {
+ char const* arg_sz = 0;
+ while ( (arg_sz = getopt_long.get_next_arg()))
+ {
My_midi_parser midi_parser (arg_sz, & source);
midi_parser_l_g = &midi_parser;
if (error_i)
return error_i;
- if (!output_str.length_i()) {
+ if (!output_str.length_i())
+ {
String d, dir, base, ext;
split_path (arg_sz, d, dir, base, ext);
output_str = base + ext + ".ly";
- }
+ }
assert (midi_parser.mudela_score_p_);
midi_parser.mudela_score_p_->process();
midi_parser_l_g = 0;
}
- return 0;
+ return 0;
}
const char *
mi2mu_version_sz()
{
- static char v[1024];
- sprintf(v, s, build);
- return v;
+ static char v[1024];
+ sprintf(v, s, build);
+ return v;
}
Mudela_column::Mudela_column (Mudela_score* mudela_score_l, Moment mom)
{
- mudela_score_l_ = mudela_score_l;
- at_mom_ = mom;
+ mudela_score_l_ = mudela_score_l;
+ at_mom_ = mom;
}
void
Mudela_column::add_item (Mudela_item* mudela_item_l)
{
- mudela_item_l_list_.bottom().add (mudela_item_l);
+ mudela_item_l_list_.bottom().add (mudela_item_l);
}
Moment
Mudela_column::at_mom()
{
- return at_mom_;
+ return at_mom_;
}
Mudela_item::Mudela_item (Mudela_column* mudela_column_l)
{
- mudela_column_l_ = mudela_column_l;
+ mudela_column_l_ = mudela_column_l;
}
Moment
Mudela_item::at_mom()
{
- return mudela_column_l_->at_mom();
+ return mudela_column_l_->at_mom();
}
Moment
Mudela_item::duration_mom()
{
- return Moment (0);
+ return Moment (0);
}
void
Mudela_item::output (Mudela_stream& mudela_stream_r)
{
- mudela_stream_r << str() << String (" ");
+ mudela_stream_r << str() << String (" ");
}
Mudela_key::Mudela_key (int accidentals_i, int minor_i)
- : Mudela_item (0)
+ : Mudela_item (0)
{
- accidentals_i_ = accidentals_i;
- minor_i_ = minor_i;
- if (accidentals_i >= 0)
+ accidentals_i_ = accidentals_i;
+ minor_i_ = minor_i;
+ if (accidentals_i >= 0)
key_i_ = ((accidentals_i % 7)[ "cgdaebf" ] - 'a' - 2) % 7;
- else
+ else
key_i_ = ((-accidentals_i % 7)[ "cfbeadg" ] - 'a' - 2) % 7;
}
String
Mudela_key::str()
{
- String str = "\\key ";
- if (!minor_i_)
+ String str = "\\key ";
+ if (!minor_i_)
str += String ((char) ((key_i_ + 2) % 7 + 'A'));
- else // heu, -2: should be - 1 1/2: A -> fis
+ else // heu, -2: should be - 1 1/2: A -> fis
str += String ((char) ((key_i_ + 2 - 2) % 7 + 'a'));
- str = String ("% \"") + str
+ str = String ("% \"") + str
+ String('"') + "; % not supported yet\n";
- return str;
+ return str;
}
String
Mudela_key::notename_str (int pitch_i)
{
- // this may seem very smart,
- // but it-s only an excuse not to read a notename table
-
- // major scale: do-do
- // minor scale: la-la (= + 5)
- static int notename_i_a[ 12 ] = { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 };
- int notename_i = notename_i_a[ (minor_i_ * 5 + pitch_i) % 12 ];
-
- static int accidentals_i_a[ 12 ] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
- int accidental_i = accidentals_i_a[ minor_i_ * 5 + pitch_i % 12 ];
- if (accidental_i && (accidentals_i_ < 0)) {
+ // this may seem very smart,
+ // but it-s only an excuse not to read a notename table
+
+ // major scale: do-do
+ // minor scale: la-la (= + 5)
+ static int notename_i_a[ 12 ] = { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 };
+ int notename_i = notename_i_a[ (minor_i_ * 5 + pitch_i) % 12 ];
+
+ static int accidentals_i_a[ 12 ] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
+ int accidental_i = accidentals_i_a[ minor_i_ * 5 + pitch_i % 12 ];
+ if (accidental_i && (accidentals_i_ < 0))
+ {
accidental_i = - accidental_i;
notename_i = (notename_i + 1) % 7;
}
- String notename_str = (char) ( ((notename_i + 2) % 7) + 'a');
- while (accidental_i-- > 0)
+ String notename_str = (char) ( ((notename_i + 2) % 7) + 'a');
+ while (accidental_i-- > 0)
notename_str += "is";
- accidental_i++;
- while (accidental_i++ < 0)
+ accidental_i++;
+ while (accidental_i++ < 0)
if ((notename_str == "a") || (notename_str == "e"))
notename_str += "s";
else
notename_str += "es";
- accidental_i--;
+ accidental_i--;
- String de_octavate_str = String ('\'', (Mudela_note::c0_pitch_i_c_ + 11 - pitch_i) / 12);
- String octavate_str = String ('\'', (pitch_i - Mudela_note::c0_pitch_i_c_) / 12);
- return de_octavate_str + notename_str + octavate_str;
+ String de_octavate_str = String ('\'', (Mudela_note::c0_pitch_i_c_ + 11 - pitch_i) / 12);
+ String octavate_str = String ('\'', (pitch_i - Mudela_note::c0_pitch_i_c_) / 12);
+ return de_octavate_str + notename_str + octavate_str;
}
Mudela_meter::Mudela_meter (int num_i, int den_i, int clocks_4_i, int count_32_i)
: Mudela_item (0)
{
- sync_dur_.type_i_ = 8 ;
- sync_f_ = 1.0;
- if (count_32_i != 8)
+ sync_dur_.durlog_i_ = 3 ;
+ sync_f_ = 1.0;
+ if (count_32_i != 8)
warning (String ("#32 in quarter: ") + String (count_32_i));
- num_i_ = num_i;
- den_i_ = den_i;
- clocks_1_i_ = clocks_4_i * 4;
+ num_i_ = num_i;
+ den_i_ = den_i;
+ clocks_1_i_ = clocks_4_i * 4;
}
Moment
Mudela_meter::bar_mom()
{
- Duration d;
- d.type_i_ = (1 << den_i_);
- return Moment (num_i_) * Duration_convert::dur2_mom (d);
+ Duration d;
+ d.durlog_i_ = den_i_;
+ return Moment (num_i_) * Duration_convert::dur2_mom (d);
}
int
Mudela_meter::clocks_1_i()
{
- return clocks_1_i_;
+ return clocks_1_i_;
}
int
Mudela_meter::den_i()
{
- return den_i_;
+ return den_i_;
}
int
Mudela_meter::num_i()
{
- return num_i_;
+ return num_i_;
}
String
Mudela_meter::str()
{
- String str = "\\meter "
+ String str = "\\meter "
+ String (num_i_) + "/" + String (1 << den_i_)
+ ";\n";
- return str;
+ return str;
}
// statics Mudela_note
/*
this switch can be used to write simple plets like
- c4*2/3
+ c4*2/3
as
- \plet 2/3; c4 \plet 1/1;
+ \plet 2/3; c4 \plet 1/1;
*/
bool const Mudela_note::simple_plet_b_s = true;
Mudela_note::Mudela_note (Mudela_column* mudela_column_l, int channel_i, int pitch_i, int dyn_i)
- : Mudela_item (mudela_column_l)
+ : Mudela_item (mudela_column_l)
{
- // junk dynamics
- (void)dyn_i;
- channel_i_ = channel_i;
- pitch_i_ = pitch_i;
- end_column_l_ = 0;
+ // junk dynamics
+ (void)dyn_i;
+ channel_i_ = channel_i;
+ pitch_i_ = pitch_i;
+ end_column_l_ = 0;
}
String
Mudela_note::str()
{
- Duration dur = duration();
- if (!dur.type_i_)
+ Duration dur = duration();
+ if (dur.durlog_i_ < -10)
return "";
- String name_str = mudela_column_l_->mudela_score_l_->mudela_key_l_->notename_str (pitch_i_);
+ String name_str
+ = mudela_column_l_->mudela_score_l_->mudela_key_l_->notename_str (pitch_i_);
- if (simple_plet_b_s)
+ if (simple_plet_b_s)
return name_str + Duration_convert::dur2_str (dur) + " ";
- //ugh
- String str;
- if (dur.plet_b())
+ //ugh
+ String str;
+ if (dur.plet_b())
str += String ("\\plet ")
+ String_convert::i2dec_str (dur.plet_.iso_i_, 0, 0)
+ "/"
+ String_convert::i2dec_str (dur.plet_.type_i_, 0, 0)
+ "; ";
- str += name_str;
+ str += name_str;
- Duration tmp = dur;
- tmp.set_plet (1,1);
- str += Duration_convert::dur2_str (tmp);
+ Duration tmp = dur;
+ tmp.set_plet (1,1);
+ str += Duration_convert::dur2_str (tmp);
- if (dur.plet_b())
+ if (dur.plet_b())
str += String (" \\plet 1/1;");
- return str + " ";
+ return str + " ";
}
Duration
Mudela_note::duration()
{
- assert (end_column_l_);
- Moment mom = end_column_l_->at_mom() - at_mom();
- if (Duration_convert::no_quantify_b_s)
- return Duration_convert::mom2_dur (mom);
-
- return Duration_convert::mom2standardised_dur (mom);
+ assert (end_column_l_);
+ Moment mom = end_column_l_->at_mom() - at_mom();
+ return Duration_convert::mom2_dur (mom);
}
Moment
{
// ugh
// return Duration_convert::dur2_mom (duration());
- return end_column_l_->at_mom() - at_mom();
+ return end_column_l_->at_mom() - at_mom();
}
Mudela_skip::Mudela_skip (Mudela_column* mudela_column_l, Moment skip_mom)
- : Mudela_item (mudela_column_l)
+ : Mudela_item (mudela_column_l)
{
- mom_ = skip_mom;
+ mom_ = skip_mom;
}
Duration
Mudela_skip::duration()
{
- if (Duration_convert::no_quantify_b_s)
return Duration_convert::mom2_dur (mom_);
-
- return Duration_convert::mom2standardised_dur (mom_);
}
Moment
Mudela_skip::duration_mom()
{
- return Duration_convert::dur2_mom (duration());
+ return Duration_convert::dur2_mom (duration());
}
String
Mudela_skip::str()
{
- if (!mom_)
+ if (!mom_)
return String ("");
- Duration dur = duration();
- if (!dur.type_i_)
+ Duration dur = duration();
+ if (dur.durlog_i_<-10)
return "";
- String str = "\\skip ";
- str += Duration_convert::dur2_str (dur) + "; ";
+ String str = "\\skip ";
+ str += Duration_convert::dur2_str (dur) + "; ";
- return str;
+ return str;
}
Mudela_tempo::Mudela_tempo (int useconds_per_4_i)
: Mudela_item (0)
{
- useconds_per_4_i_ = useconds_per_4_i;
- seconds_per_1_f_ = (Real)useconds_per_4_i_ * 4 / 1e6;
+ useconds_per_4_i_ = useconds_per_4_i;
+ seconds_per_1_f_ = (Real)useconds_per_4_i_ * 4 / 1e6;
}
String
Mudela_tempo::str()
{
- String str = "\\tempo 4=";
- str += String (get_tempo_i (Moment (1, 4)));
- str += ";\n";
- return str;
+ String str = "\\tempo 4=";
+ str += String (get_tempo_i (Moment (1, 4)));
+ str += ";\n";
+ return str;
}
int
Mudela_tempo::useconds_per_4_i()
{
- return useconds_per_4_i_;
+ return useconds_per_4_i_;
}
int
Mudela_tempo::get_tempo_i (Moment moment)
{
- return Moment (60) / moment / Moment (seconds_per_1_f_);
+ return Moment (60) / moment / Moment (seconds_per_1_f_);
}
Mudela_text::Mudela_text (Mudela_text::Type type, String text_str)
: Mudela_item (0)
{
- type_ = type;
- text_str_ = text_str;
+ type_ = type;
+ text_str_ = text_str;
}
String
Mudela_text::str()
{
- if (!text_str_.length_i()
+ if (!text_str_.length_i()
|| (text_str_.length_i() != (int)strlen (text_str_.ch_C())))
return "";
- return "% " + text_str_ + "\n";
+ return "% " + text_str_ + "\n";
}
Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i)
{
- format_i_ = format_i;
- tracks_i_ = tracks_i;
- tempo_i_ = tempo_i;
- mudela_column_p_list_.bottom().add (new Mudela_column (this, Moment (0)));
+ format_i_ = format_i;
+ tracks_i_ = tracks_i;
+ tempo_i_ = tempo_i;
+ mudela_column_p_list_.bottom().add (new Mudela_column (this, Moment (0)));
}
Mudela_score::~Mudela_score()
void
Mudela_score::add_item (Mudela_item* mudela_item_p)
{
- mudela_staff_p_list_.bottom()->add_item (mudela_item_p);
+ mudela_staff_p_list_.bottom()->add_item (mudela_item_p);
}
void
Mudela_score::add_staff (Mudela_staff* mudela_staff_p)
{
- mudela_staff_p_list_.bottom().add (mudela_staff_p);
+ mudela_staff_p_list_.bottom().add (mudela_staff_p);
}
Mudela_column*
Mudela_score::mudela_column_l (Moment mom)
{
- for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++) {
- if (i->at_mom() > mom) {
+ for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
+ {
+ if (i->at_mom() > mom)
+ {
Mudela_column* p = new Mudela_column (this, mom);
i.insert (p);
return p;
- }
+ }
if (i->at_mom() == mom)
return *i;
}
- Mudela_column* p = new Mudela_column (this, mom);
- mudela_column_p_list_.bottom().add (p);
- return p;
+ Mudela_column* p = new Mudela_column (this, mom);
+ mudela_column_p_list_.bottom().add (p);
+ return p;
}
void
Mudela_score::output (String filename_str)
{
- LOGOUT(NORMAL_ver) << "Lily output to " << filename_str << " ..." << endl;
-
- // ugh, ugly midi type 1 fix
- if ( (mudela_staff_p_list_.size() == 1) && !mudela_staff_p_list_.top()->number_i_)
+ LOGOUT(NORMAL_ver) << "Lily output to " << filename_str << " ..." << endl;
+
+ // ugh, ugly midi type 1 fix
+ if ( (mudela_staff_p_list_.size() == 1) && !mudela_staff_p_list_.top()->number_i_)
mudela_staff_p_list_.top()->number_i_ = 1;
- int track_i = 0;
- Mudela_stream mudela_stream (filename_str);
- for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++) {
+ int track_i = 0;
+ Mudela_stream mudela_stream (filename_str);
+ for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ {
LOGOUT(NORMAL_ver) << "track " << track_i++ << ": " << flush;
i->output (mudela_stream);
mudela_stream << "\n";
LOGOUT(NORMAL_ver) << endl;
}
- mudela_stream << "\\score{\n";
- if (mudela_staff_p_list_.size() > 1)
+ mudela_stream << "\\score{\n";
+ if (mudela_staff_p_list_.size() > 1)
mudela_stream << "<\n\\multi 3;\n";
- for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++) {
+ for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ {
if ( (mudela_staff_p_list_.size() != 1)
&& (i == mudela_staff_p_list_.top()))
continue;
mudela_stream << "\\$" << i->id_str();
mudela_stream << " }\n";
}
- if (mudela_staff_p_list_.size() > 1)
+ if (mudela_staff_p_list_.size() > 1)
mudela_stream << ">\n";
- mudela_stream << "\\paper{}\n";
+ mudela_stream << "\\paper{}\n";
- mudela_stream << "\\midi{ ";
+ mudela_stream << "\\midi{ ";
// let's not use silly 0 track
mudela_staff_p_list_.bottom()->mudela_tempo_p_->output (mudela_stream);
- mudela_stream << "}\n";
+ mudela_stream << "}\n";
- mudela_stream << "}\n";
+ mudela_stream << "}\n";
}
void
Mudela_score::process()
{
- LOGOUT(NORMAL_ver) << "\nProcessing..." << endl;
+ LOGOUT(NORMAL_ver) << "\nProcessing..." << endl;
- LOGOUT(DEBUG_ver) << "columns\n";
- for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
+ LOGOUT(DEBUG_ver) << "columns\n";
+ for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << "\n";
- settle_columns();
- filter_tempo();
- quantify_columns();
- quantify_durations();
+ settle_columns();
+ filter_tempo();
+ quantify_columns();
+ quantify_durations();
- LOGOUT(NORMAL_ver) << "\nCreating voices..." << endl;
- int track_i = 0;
- for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++) {
+ LOGOUT(NORMAL_ver) << "\nCreating voices..." << endl;
+ int track_i = 0;
+ for (PCursor<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ {
LOGOUT(NORMAL_ver) << "track " << track_i++ << ": " << flush;
i->process();
LOGOUT(NORMAL_ver) << endl;
void
Mudela_score::filter_tempo()
{
- LOGOUT(NORMAL_ver) << "\nNOT Filtering tempo..." << endl;
+ LOGOUT(NORMAL_ver) << "\nNOT Filtering tempo..." << endl;
}
void
Mudela_score::quantify_columns()
{
- // ugh
- if (Duration_convert::no_quantify_b_s) {
+ // ugh
+ if (Duration_convert::no_quantify_b_s)
+ {
LOGOUT(NORMAL_ver) << "\nNOT Quantifying columns..." << endl;
return;
}
- LOGOUT(NORMAL_ver) << "\nQuantifying columns..." << endl;
+ LOGOUT(NORMAL_ver) << "\nQuantifying columns..." << endl;
- int n = 32 >? Duration_convert::no_smaller_than_i_s;
- Moment s = Moment (1, n);
- Moment sh = Moment (1, 2 * n);
- for (int i = 0; i < column_l_array_.size(); i++) {
+ int n = 5 >? Duration_convert::no_smaller_than_i_s;
+ Moment s = Moment (1, n);
+ Moment sh = Moment (1, 2 * n);
+ for (int i = 0; i < column_l_array_.size(); i++)
+ {
// Moment mom = column_l_array_[ i ]->at_mom();
// column_l_array_[ i ]->at_mom_ = Duration_convert::dur2_mom (dur);
column_l_array_[ i ]->at_mom_ =
// s * (int) ( (sh + column_l_array_[ i ]->at_mom()) / s);
s * (int) ( (column_l_array_[ i ]->at_mom()) / s);
LOGOUT(NORMAL_ver) << '.';
- }
- LOGOUT(NORMAL_ver) << endl;
+ }
+ LOGOUT(NORMAL_ver) << endl;
}
void
{
// LOGOUT(NORMAL_ver) << "\nNOT Settling columns..." << endl;
// return;
- LOGOUT(NORMAL_ver) << "\nSettling columns..." << endl;
+ LOGOUT(NORMAL_ver) << "\nSettling columns..." << endl;
- assert (!column_l_array_.size());
- int n = mudela_column_p_list_.size();
+ assert (!column_l_array_.size());
+ int n = mudela_column_p_list_.size();
// huh?
// column_l_array_.set_size (n);
- for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
+ for (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
column_l_array_.push (*i);
- int start_i = 0;
- int end_i = 0;
- Moment start_mom = 0;
- Duration smallest_dur;
- smallest_dur.type_i_ = 64;
- Moment const noise_mom = Duration_convert::dur2_mom (smallest_dur)
+ int start_i = 0;
+ int end_i = 0;
+ Moment start_mom = 0;
+ Duration smallest_dur;
+ smallest_dur.durlog_i_ = 6;
+ Moment const noise_mom = Duration_convert::dur2_mom (smallest_dur)
/ Moment (2);
- for (int i = 0; i < n; i++) {
- if (!start_i) {
+ for (int i = 0; i < n; i++)
+ {
+ if (!start_i)
+ {
start_i = end_i = i;
start_mom = column_l_array_[ i ]->at_mom();
continue;
- }
+ }
// find all columns within noise's distance
while ( (i < n)
#include "mudela-staff.hh"
#include "mudela-stream.hh"
#include "mudela-voice.hh"
+#include "my-midi-parser.hh"
+#include "mudela-score.hh"
+
Mudela_staff::Mudela_staff (int number_i, String copyright_str, String track_name_str, String instrument_str)
{
- number_i_ = number_i;
- copyright_str_ = copyright_str;
- instrument_str_ = instrument_str;
- name_str_ = track_name_str;
- mudela_meter_p_ = new Mudela_meter (4, 2, 24, 8);
- mudela_tempo_p_ = new Mudela_tempo (1000000);
+ number_i_ = number_i;
+ copyright_str_ = copyright_str;
+ instrument_str_ = instrument_str;
+ name_str_ = track_name_str;
+ mudela_meter_p_ = new Mudela_meter (4, 2, 24, 8);
+ mudela_tempo_p_ = new Mudela_tempo (1000000);
}
Mudela_staff::~Mudela_staff()
{
- delete mudela_meter_p_;
- delete mudela_tempo_p_;
+ delete mudela_meter_p_;
+ delete mudela_tempo_p_;
}
void
Mudela_staff::add_item (Mudela_item* mudela_item_p)
{
- mudela_item_p_list_.bottom().add (mudela_item_p);
- if (mudela_item_p->mudela_column_l_)
- mudela_item_p->mudela_column_l_->add_item (mudela_item_p);
+ mudela_item_p_list_.bottom().add (mudela_item_p);
+ if (mudela_item_p->mudela_column_l_)
+ mudela_item_p->mudela_column_l_->add_item (mudela_item_p);
}
void
Mudela_staff::eat_voice (Link_list<Mudela_item*>& items)
{
- Mudela_voice* voice_p = new Mudela_voice (this);
- mudela_voice_p_list_.bottom().add (voice_p);
-
-// Moment mom = items.top()->at_mom();
- Moment mom = 0;
-
- for (PCursor<Mudela_item*> i (items); i.ok();) {
- LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << "; ";
- LOGOUT(DEBUG_ver) << "dur: " << i->duration_mom() << "; ";
- LOGOUT(DEBUG_ver) << "mom: " << mom << " -> ";
- if (i->at_mom() > mom) {
- // ugh, liek
- voice_p->add_item (new Mudela_skip (i->mudela_column_l_, i->at_mom() - mom));
- mom = i->at_mom();
+ Mudela_voice* voice_p = new Mudela_voice (this);
+ mudela_voice_p_list_.bottom().add (voice_p);
+
+ // Moment mom = items.top()->at_mom();
+ Moment mom = 0;
+
+ for (PCursor<Mudela_item*> i (items); i.ok();)
+ {
+ LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << "; ";
+ LOGOUT(DEBUG_ver) << "dur: " << i->duration_mom() << "; ";
+ LOGOUT(DEBUG_ver) << "mom: " << mom << " -> ";
+ if (i->at_mom() > mom)
+ {
+ Moment dur = i->at_mom() - mom;
+ // ugh, need score
+ Mudela_column* start = midi_parser_l_g->mudela_score_p_->mudela_column_l (mom);
+ voice_p->add_item (new Mudela_skip (start, dur));
+ mom = i->at_mom();
}
- if (i->at_mom() == mom) {
- mom = i->at_mom() + i->duration_mom();
- voice_p->add_item (i.remove_p());
- // ugh
+ if (i->at_mom() == mom)
+ {
+ mom = i->at_mom() + i->duration_mom();
+ voice_p->add_item (i.remove_p());
+ // ugh
}
- else if (i.ok())
- i++;
- LOGOUT(DEBUG_ver) << "mom: " << mom << "\n";
+ else if (i.ok())
+ i++;
+ LOGOUT(DEBUG_ver) << "mom: " << mom << "\n";
}
}
String
Mudela_staff::id_str()
{
- String str = name_str();
- for (int i = 0; i < str.length_i(); i++)
- if ( (!i && !isalpha (str[ i ]))
- || !isalnum (str[ i ]))
- * (str.ch_l() + i) = '_';
- return str;
+ String str = name_str();
+ for (int i = 0; i < str.length_i(); i++)
+ if ( (!i && !isalpha (str[ i ]))
+ || !isalnum (str[ i ]))
+ * (str.ch_l() + i) = '_';
+ return str;
}
String
Mudela_staff::name_str()
{
- if (name_str_.length_i())
- return name_str_;
- return String ("track") + String (number_i_);
+ if (name_str_.length_i())
+ return name_str_;
+ return String ("track") + String (number_i_);
}
void
Mudela_staff::output (Mudela_stream& mudela_stream_r)
{
- mudela_stream_r << "$" << id_str() << " = \\melodic";
- mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "<" : "{");
- mudela_stream_r << "\n";
- mudela_stream_r << "% midi copyright:" << copyright_str_ << "\n";
- mudela_stream_r << "% instrument:" << instrument_str_ << "\n";
-
- if (mudela_voice_p_list_.size() == 1)
- mudela_voice_p_list_.top()->output (mudela_stream_r);
- else
- for (PCursor<Mudela_voice*> i (mudela_voice_p_list_); i.ok(); i++) {
- mudela_stream_r << "{ ";
- i->output (mudela_stream_r);
- mudela_stream_r << "} ";
- }
-
- mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "\n>" : "\n}");
- mudela_stream_r << " % " << name_str() << "\n";
+ mudela_stream_r << "$" << id_str() << " = \\melodic";
+ mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "<" : "{");
+ mudela_stream_r << "\n";
+ mudela_stream_r << "% midi copyright:" << copyright_str_ << "\n";
+ mudela_stream_r << "% instrument:" << instrument_str_ << "\n";
+
+ if (mudela_voice_p_list_.size() == 1)
+ mudela_voice_p_list_.top()->output (mudela_stream_r);
+ else
+ for (PCursor<Mudela_voice*> i (mudela_voice_p_list_); i.ok(); i++)
+ {
+ mudela_stream_r << "{ ";
+ i->output (mudela_stream_r);
+ mudela_stream_r << "} ";
+ }
+
+ mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "\n>" : "\n}");
+ mudela_stream_r << " % " << name_str() << "\n";
}
void
Mudela_staff::output_mudela_begin_bar (Mudela_stream& mudela_stream_r, Moment now_mom, int bar_i)
{
- Moment bar_mom = mudela_meter_p_->bar_mom();
- Moment into_bar_mom = now_mom - Moment (bar_i - 1) * bar_mom;
- if (bar_i > 1) {
- if (!into_bar_mom)
- mudela_stream_r << "|\n";
+ Moment bar_mom = mudela_meter_p_->bar_mom();
+ Moment into_bar_mom = now_mom - Moment (bar_i - 1) * bar_mom;
+ if (bar_i > 1)
+ {
+ if (!into_bar_mom)
+ mudela_stream_r << "|\n";
}
- mudela_stream_r << "% " << String_convert::i2dec_str (bar_i, 0, ' ');
- if (into_bar_mom)
- mudela_stream_r << ":" << Duration_convert::dur2_str (Duration_convert::mom2_dur (into_bar_mom));
- mudela_stream_r << "\n";
+ mudela_stream_r << "% " << String_convert::i2dec_str (bar_i, 0, ' ');
+ if (into_bar_mom)
+ mudela_stream_r << ":" << Duration_convert::dur2_str (Duration_convert::mom2_dur (into_bar_mom));
+ mudela_stream_r << "\n";
}
void
Mudela_staff::output_mudela_rest (Mudela_stream& mudela_stream_r, Moment begin_mom, Moment end_mom)
{
- Moment bar_mom = mudela_meter_p_->bar_mom();
- Moment now_mom = begin_mom;
+ Moment bar_mom = mudela_meter_p_->bar_mom();
+ Moment now_mom = begin_mom;
- int begin_bar_i = (int) (now_mom / bar_mom) + 1;
- int end_bar_i = (int) (end_mom / bar_mom) + 1;
+ int begin_bar_i = (int) (now_mom / bar_mom) + 1;
+ int end_bar_i = (int) (end_mom / bar_mom) + 1;
- if (end_bar_i == begin_bar_i) {
- output_mudela_rest_remain (mudela_stream_r, end_mom - begin_mom);
- return;
+ if (end_bar_i == begin_bar_i)
+ {
+ output_mudela_rest_remain (mudela_stream_r, end_mom - begin_mom);
+ return;
}
- // multiple bars involved
- int bar_i = (int) (now_mom / bar_mom) + 1;
-
- //fill current bar
- Moment begin_bar_mom = Moment (begin_bar_i - 1) * bar_mom;
- if (now_mom > begin_bar_mom) {
- int next_bar_i = (int) (now_mom / bar_mom) + 2;
- Moment next_bar_mom = Moment (next_bar_i - 1) * bar_mom;
- assert (next_bar_mom <= end_mom);
-
- Moment remain_mom = next_bar_mom - now_mom;
- if (remain_mom > Moment (0)) {
- output_mudela_rest_remain (mudela_stream_r, remain_mom);
- now_mom += remain_mom;
+ // multiple bars involved
+ int bar_i = (int) (now_mom / bar_mom) + 1;
+
+ //fill current bar
+ Moment begin_bar_mom = Moment (begin_bar_i - 1) * bar_mom;
+ if (now_mom > begin_bar_mom)
+ {
+ int next_bar_i = (int) (now_mom / bar_mom) + 2;
+ Moment next_bar_mom = Moment (next_bar_i - 1) * bar_mom;
+ assert (next_bar_mom <= end_mom);
+
+ Moment remain_mom = next_bar_mom - now_mom;
+ if (remain_mom > Moment (0))
+ {
+ output_mudela_rest_remain (mudela_stream_r, remain_mom);
+ now_mom += remain_mom;
}
- bar_i = check_end_bar_i (now_mom, bar_i);
+ bar_i = check_end_bar_i (now_mom, bar_i);
}
- // fill whole bars
- int count_i = end_bar_i - bar_i;
- for (int i = 0; i < count_i; i++) {
- int begin_bar_i = check_begin_bar_i (now_mom, bar_i);
- if (begin_bar_i)
- output_mudela_begin_bar (mudela_stream_r, now_mom, begin_bar_i);
- mudela_stream_r << "r1 ";
-// *mudela_stream_r.os_p_ << flush;
- if (begin_bar_i)
- LOGOUT(NORMAL_ver) << begin_bar_i << flush;
- bar_i = check_end_bar_i (now_mom, bar_i);
- now_mom += bar_mom;
+ // fill whole bars
+ int count_i = end_bar_i - bar_i;
+ for (int i = 0; i < count_i; i++)
+ {
+ int begin_bar_i = check_begin_bar_i (now_mom, bar_i);
+ if (begin_bar_i)
+ output_mudela_begin_bar (mudela_stream_r, now_mom, begin_bar_i);
+ mudela_stream_r << "r1 ";
+ // *mudela_stream_r.os_p_ << flush;
+ if (begin_bar_i)
+ LOGOUT(NORMAL_ver) << begin_bar_i << flush;
+ bar_i = check_end_bar_i (now_mom, bar_i);
+ now_mom += bar_mom;
}
- // use "int i" here, and gcc 2.7.2 hits internal compiler error
- int ii = check_begin_bar_i (now_mom, bar_i);
- if (ii)
- output_mudela_begin_bar (mudela_stream_r, now_mom, ii);
+ // use "int i" here, and gcc 2.7.2 hits internal compiler error
+ int ii = check_begin_bar_i (now_mom, bar_i);
+ if (ii)
+ output_mudela_begin_bar (mudela_stream_r, now_mom, ii);
-// bar_i = check_end_bar_i (now_mom, bar_i);
+ // bar_i = check_end_bar_i (now_mom, bar_i);
- Moment remain_mom = end_mom - Moment (end_bar_i - 1) * bar_mom;
- if (remain_mom > Moment (0)) {
- output_mudela_rest_remain (mudela_stream_r, remain_mom);
- now_mom += remain_mom;
+ Moment remain_mom = end_mom - Moment (end_bar_i - 1) * bar_mom;
+ if (remain_mom > Moment (0))
+ {
+ output_mudela_rest_remain (mudela_stream_r, remain_mom);
+ now_mom += remain_mom;
}
- assert (now_mom == end_mom);
+ assert (now_mom == end_mom);
}
void
Mudela_staff::output_mudela_rest_remain (Mudela_stream& mudela_stream_r, Moment mom)
{
- if (Duration_convert::no_quantify_b_s) {
- Duration dur = Duration_convert::mom2_dur (mom);
- mudela_stream_r << "r" << dur.str() << " ";
-// assert (mom == dur.mom());
- assert (mom == dur.length());
- return;
+ if (Duration_convert::no_quantify_b_s)
+ {
+ Duration dur = Duration_convert::mom2_dur (mom);
+ mudela_stream_r << "r" << dur.str() << " ";
+ // assert (mom == dur.mom());
+ assert (mom == dur.length());
+ return;
}
- Duration dur = Duration_convert::mom2standardised_dur (mom);
- if (dur.type_i_)
- mudela_stream_r << "r" << dur.str() << " ";
+ Duration dur = Duration_convert::mom2standardised_dur (mom);
+ if (dur.type_i_>-10)
+ mudela_stream_r << "r" << dur.str() << " ";
}
#endif
void
Mudela_staff::process()
{
- /*
- group items into voices
+ /*
+ group items into voices
*/
- Link_list<Mudela_item*> items;
- for (PCursor<Mudela_item*> i (mudela_item_p_list_); i.ok(); i++)
- items.bottom().add (*i);
-
- while (items.size())
- eat_voice (items);
+ Link_list<Mudela_item*> items;
+ for (PCursor<Mudela_item*> i (mudela_item_p_list_); i.ok(); i++)
+ items.bottom().add (*i);
+
+ while (items.size())
+ eat_voice (items);
}
void
Mudela_staff::set_tempo (int useconds_per_4_i)
{
- delete mudela_tempo_p_;
- mudela_tempo_p_ = new Mudela_tempo (useconds_per_4_i);
+ delete mudela_tempo_p_;
+ mudela_tempo_p_ = new Mudela_tempo (useconds_per_4_i);
}
void
Mudela_staff::set_meter (int num_i, int den_i, int clocks_i, int count_32_i)
{
- delete mudela_meter_p_;
- mudela_meter_p_ = new Mudela_meter (num_i, den_i, clocks_i, count_32_i);
+ delete mudela_meter_p_;
+ mudela_meter_p_ = new Mudela_meter (num_i, den_i, clocks_i, count_32_i);
}
Mudela_stream::Mudela_stream (String filename_str)
{
- filename_str_ = filename_str;
- os_p_ = 0;
- indent_i_ = 0;
- comment_mode_b_ = false;
- column_i_ = 0;
- wrap_column_i_ = 68;
- open();
- header();
+ filename_str_ = filename_str;
+ os_p_ = 0;
+ indent_i_ = 0;
+ comment_mode_b_ = false;
+ column_i_ = 0;
+ wrap_column_i_ = 68;
+ open();
+ header();
}
Mudela_stream::~Mudela_stream()
{
- delete os_p_;
- if (indent_i_)
+ delete os_p_;
+ if (indent_i_)
warning ("lily indent level: " + String (indent_i_));
}
Mudela_stream&
Mudela_stream::operator << (String str)
{
- static String word_sep_str = "{} \t\n";
- while (str.length_i()) {
+ static String word_sep_str = "{} \t\n";
+ while (str.length_i())
+ {
int i = str.index_any_i (word_sep_str) + 1;
if (!i)
i = str.length_i();
str = str.mid_str (i, str.length_i());
output_wrapped (word);
}
- return *this;
+ return *this;
}
Mudela_stream&
Mudela_stream::operator << (Mudela_item& mudela_item_r)
{
- mudela_item_r.output (*this);
- *os_p_ << flush;
- return *this;
+ mudela_item_r.output (*this);
+ *os_p_ << flush;
+ return *this;
}
void
Mudela_stream::handle_pending_indent()
{
- *os_p_ << String ('\t', pending_indent_i_);
- column_i_ += pending_indent_i_ * INDENT_i;
- pending_indent_i_ = 0;
+ *os_p_ << String ('\t', pending_indent_i_);
+ column_i_ += pending_indent_i_ * INDENT_i;
+ pending_indent_i_ = 0;
}
void
Mudela_stream::header()
{
- *os_p_ << "% Creator: " << mi2mu_version_str() << "\n";
- *os_p_ << "% Automatically generated, at ";
- time_t t (time (0));
- *os_p_ << ctime (&t);
- *os_p_ << "% from input file: ";
- *os_p_ << midi_parser_l_g->filename_str_;
- *os_p_ << "\n\n";
- // ugh
- *os_p_ << "\\version \"0.1.1\";\n";
+ *os_p_ << "% Creator: " << mi2mu_version_str() << "\n";
+ *os_p_ << "% Automatically generated, at ";
+ time_t t (time (0));
+ *os_p_ << ctime (&t);
+ *os_p_ << "% from input file: ";
+ *os_p_ << midi_parser_l_g->filename_str_;
+ *os_p_ << "\n\n";
+ // ugh
+ *os_p_ << "\\version \"0.1.1\";\n";
}
void
Mudela_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_ + "\'");
}
void
Mudela_stream::output (String str)
{
- for (int i = 0; i < str.length_i(); i++) {
+ for (int i = 0; i < str.length_i(); i++)
+ {
char c = str[ i ];
- switch (c) {
+ switch (c)
+ {
case '{' :
case '<' :
handle_pending_indent();
void
Mudela_stream::output_wrapped (String str)
{
- // enough room left -> doit
- if (column_i_ + str.length_i() <= wrap_column_i_) {
+ // enough room left -> doit
+ if (column_i_ + str.length_i() <= wrap_column_i_)
+ {
output (str);
return;
}
- // we're at BOL already; this will never fit -> doit
- if (column_i_ == indent_i_ * INDENT_i) {
+ // we're at BOL already; this will never fit -> doit
+ if (column_i_ == indent_i_ * INDENT_i)
+ {
output (str);
return;
}
-
- // ok, let's wrap
- // preserve comment mode
- if (comment_mode_b_)
+
+ // ok, let's wrap
+ // preserve comment mode
+ if (comment_mode_b_)
output (String ("\n%"));
- else
+ else
output (String ("\n"));
-
- output (str);
+
+ output (str);
}
Mudela_voice::Mudela_voice (Mudela_staff* mudela_staff_l)
{
- mudela_staff_l_ = mudela_staff_l;
+ mudela_staff_l_ = mudela_staff_l;
}
void
Mudela_voice::add_item (Mudela_item* mudela_item_l)
{
- mudela_item_l_list_.bottom().add (mudela_item_l);
+ mudela_item_l_list_.bottom().add (mudela_item_l);
}
Moment
Mudela_voice::begin_mom()
{
- return mudela_item_l_list_.size() ?
+ return mudela_item_l_list_.size() ?
mudela_item_l_list_.top()->at_mom() : Moment (0);
}
Moment
Mudela_voice::end_mom()
{
- return mudela_item_l_list_.size() ?
+ return mudela_item_l_list_.size() ?
mudela_item_l_list_.bottom()->at_mom() : Moment (0);
}
void
Mudela_voice::output (Mudela_stream& mudela_stream_r)
{
- if (!mudela_item_l_list_.size())
+ if (!mudela_item_l_list_.size())
return;
-
- if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
+
+ if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
mudela_stream_r << "\n";
- int current_bar_i = 0;
- Moment bar_mom = mudela_staff_l_->mudela_meter_p_->bar_mom();
+ int current_bar_i = 0;
+ Moment bar_mom = mudela_staff_l_->mudela_meter_p_->bar_mom();
- for (PCursor<Mudela_item*> i (mudela_item_l_list_); i.ok(); i++) {
+ for (PCursor<Mudela_item*> i (mudela_item_l_list_); i.ok(); i++)
+ {
Moment at_mom = i->mudela_column_l_->at_mom();
int bar_i = (int) (at_mom / bar_mom) + 1;
- if (bar_i > current_bar_i) {
- if (current_bar_i) {
+ if (bar_i > current_bar_i)
+ {
+ if (current_bar_i)
+ {
if (at_mom == Moment (bar_i - 1) * bar_mom)
mudela_stream_r << "|";
mudela_stream_r << "\n% ";
mudela_stream_r << String_convert::i2dec_str (bar_i, 0, ' ');
mudela_stream_r << "\n";
- }
+ }
LOGOUT(NORMAL_ver) << '[' << bar_i << ']' << flush;
current_bar_i = bar_i;
- }
+ }
- mudela_stream_r << i->str();
+ mudela_stream_r << **i;
}
- if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
+ if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
mudela_stream_r << "\n";
}
int
yylex()
{
- return midi_lexer_l_g->yylex();
+ return midi_lexer_l_g->yylex();
}
My_midi_lexer* midi_lexer_l_g = 0;
My_midi_lexer::My_midi_lexer (String &filename_str, Sources * sources)
{
- source_file_l_ = sources->get_file_l(filename_str);
- if (!source_file_l_)
+ source_file_l_ = sources->get_file_l(filename_str);
+ if (!source_file_l_)
::error ("can't find: `" + filename_str + "'");
- switch_streams (source_file_l_->istream_l(), 0);
- errorlevel_i_ = 0;
- char_count_ = 0;
- running_status_i_ = 0;
+ switch_streams (source_file_l_->istream_l(), 0);
+ errorlevel_i_ = 0;
+ char_count_ = 0;
+ running_status_i_ = 0;
}
My_midi_lexer::~My_midi_lexer()
void
My_midi_lexer::error (char const* sz_l)
{
- if (1|| !source_file_l_) {
+ if (1|| !source_file_l_)
+ {
cerr << "error at EOF: `" << sz_l << "'\n";
- } else {
+ }
+ else
+ {
// FIXME
#if 0
char const* ch_C = here_ch_C();
- if (ch_C) {
+ if (ch_C)
+ {
ch_C--;
while ( (*ch_C == ' ') || (*ch_C == '\t') || (*ch_C == '\n'))
ch_C--;
ch_C++;
- }
+ }
errorlevel_i_ |= 1;
error (sz_l);
#endif
char const*
My_midi_lexer::here_ch_C()
{
- return source_file_l_->ch_C() + char_count_ ;
+ return source_file_l_->ch_C() + char_count_ ;
}
int
My_midi_lexer::varint2_i (String str)
{
- int var_i = 0;
+ int var_i = 0;
- for (int i = 0; i < str.length_i(); i++) {
+ for (int i = 0; i < str.length_i(); i++)
+ {
Byte byte = str[ i ];
var_i <<= 7;
var_i += byte & 0x7f;
if (! (byte & 0x80))
return var_i;
}
- cout << "\nvarint2_i:" << String_convert::bin2hex_str (str) << endl;
- assert (0); // illegal varint
- return 0;
+ cout << "\nvarint2_i:" << String_convert::bin2hex_str (str) << endl;
+ assert (0); // illegal varint
+ return 0;
}
int
My_midi_lexer::close_i()
{
- return 0;
+ return 0;
}
void
yyerror(char const* sz_l)
{
- midi_parser_l_g->error (sz_l);
+ midi_parser_l_g->error (sz_l);
}
My_midi_parser::My_midi_parser (String filename_str, Sources *sources_l)
{
- filename_str_ = filename_str;
- midi_lexer_p_ = new My_midi_lexer (filename_str_,sources_l);
- midi_lexer_l_g = midi_lexer_p_; // ugh
+ filename_str_ = filename_str;
+ midi_lexer_p_ = new My_midi_lexer (filename_str_,sources_l);
+ midi_lexer_l_g = midi_lexer_p_; // ugh
- bar_i_ = 1;
+ bar_i_ = 1;
- defined_ch_C_ = 0;
- fatal_error_i_ = 0;
-
- mudela_column_l_ = 0;
- mudela_score_p_ = new Mudela_score (1, 1, 1);
+ defined_ch_C_ = 0;
+ fatal_error_i_ = 0;
+
+ mudela_column_l_ = 0;
+ mudela_score_p_ = new Mudela_score (1, 1, 1);
- // ugh, belong to Mudela_{score,staff}
- track_i_ = 0;
- mudela_staff_l_ = 0;
- mudela_key_p_ = 0;
- mudela_tempo_p_ = 0;
- mudela_meter_p_ = 0;
+ // ugh, belong to Mudela_{score,staff}
+ track_i_ = 0;
+ mudela_staff_l_ = 0;
+ mudela_key_p_ = 0;
+ mudela_tempo_p_ = 0;
+ mudela_meter_p_ = 0;
- reset();
+ reset();
}
My_midi_parser::~My_midi_parser()
{
- midi_lexer_l_g = 0; // ugh
+ midi_lexer_l_g = 0; // ugh
- delete midi_lexer_p_;
- delete mudela_key_p_;
- delete mudela_tempo_p_;
- delete mudela_meter_p_;
- delete mudela_score_p_;
+ delete midi_lexer_p_;
+ delete mudela_key_p_;
+ delete mudela_tempo_p_;
+ delete mudela_meter_p_;
+ delete mudela_score_p_;
}
void
My_midi_parser::reset()
{
// open_mudela_note_l_list_.clear();
- open_mudela_note_l_list_.junk_links();
+ open_mudela_note_l_list_.junk_links();
- // ugh
- delete mudela_key_p_;
- mudela_key_p_ = new Mudela_key (0, 0);
- // useconds per 4: 250000 === 60 4 per minute
- delete mudela_tempo_p_;
- mudela_tempo_p_ = new Mudela_tempo (1000000);
- delete mudela_meter_p_;
- mudela_meter_p_ = new Mudela_meter (4, 2, 24, 8);
+ // ugh
+ delete mudela_key_p_;
+ mudela_key_p_ = new Mudela_key (0, 0);
+ // useconds per 4: 250000 === 60 4 per minute
+ delete mudela_tempo_p_;
+ mudela_tempo_p_ = new Mudela_tempo (1000000);
+ delete mudela_meter_p_;
+ mudela_meter_p_ = new Mudela_meter (4, 2, 24, 8);
- bar_i_ = 1;
- mudela_column_l_ = mudela_score_p_->mudela_column_l (0);
+ bar_i_ = 1;
+ mudela_column_l_ = mudela_score_p_->mudela_column_l (0);
- // ugh
- copyright_str_ = "";
- track_name_str_ = "";
- instrument_str_ = "";
+ // ugh
+ copyright_str_ = "";
+ track_name_str_ = "";
+ instrument_str_ = "";
}
void
My_midi_parser::add_score (Mudela_score* mudela_score_p)
{
- assert (mudela_score_p_);
+ assert (mudela_score_p_);
#if 0 // ugh, already constructed
- mudela_score_p_ = mudela_score_p;
- if (!mudela_column_l_)
+ mudela_score_p_ = mudela_score_p;
+ if (!mudela_column_l_)
mudela_column_l_ = mudela_score_p_->mudela_column_l (0);
#endif
- mudela_score_p_->mudela_key_l_ = mudela_key_p_;
- mudela_score_p_->mudela_meter_l_ = mudela_meter_p_;
- mudela_score_p_->mudela_tempo_l_ = mudela_tempo_p_;
- bar_i_ = 1;
+ mudela_score_p_->mudela_key_l_ = mudela_key_p_;
+ mudela_score_p_->mudela_meter_l_ = mudela_meter_p_;
+ mudela_score_p_->mudela_tempo_l_ = mudela_tempo_p_;
+ bar_i_ = 1;
}
void
My_midi_parser::error (char const* sz_l)
{
- midi_lexer_l_g->error (sz_l);
+ midi_lexer_l_g->error (sz_l);
- if (fatal_error_i_)
+ if (fatal_error_i_)
exit (fatal_error_i_);
}
void
My_midi_parser::forward (int i)
{
- if (!i)
+ if (!i)
return;
- Duration dur;
- dur.type_i_ = (0);
- dur.set_ticks (i);
- Moment mom = at_mom() + Duration_convert::dur2_mom (dur);
+ Duration dur;
+ dur.durlog_i_ = -100;
+ dur.set_ticks (i);
+ Moment mom = at_mom() + Duration_convert::dur2_mom (dur);
- mudela_column_l_ = mudela_score_p_->mudela_column_l (mom);
+ mudela_column_l_ = mudela_score_p_->mudela_column_l (mom);
- if (i) {
+ if (i)
+ {
int bars_i = (int) (mom / mudela_meter_p_->bar_mom());
if (bars_i > bar_i_)
LOGOUT(NORMAL_ver) << '[' << bar_i_ << ']' << flush;
Moment
My_midi_parser::at_mom()
{
- assert (mudela_column_l_);
+ assert (mudela_column_l_);
// return mudela_column_l_ ? mudela_column_l_->at_mom() : 0;
- return mudela_column_l_->at_mom();
+ return mudela_column_l_->at_mom();
}
void
My_midi_parser::note_begin (int channel_i, int pitch_i, int dyn_i)
{
- // junk dynamics
- (void)dyn_i;
+ // junk dynamics
+ (void)dyn_i;
- Mudela_note* p = new Mudela_note (mudela_column_l_, channel_i, pitch_i, dyn_i);
+ Mudela_note* p = new Mudela_note (mudela_column_l_, channel_i, pitch_i, dyn_i);
// ugh, score doesn't know about last staff yet...
// mudela_score_p_->add_item (p);
- mudela_staff_l_->add_item (p);
- open_mudela_note_l_list_.bottom().add (p);
+ mudela_staff_l_->add_item (p);
+ open_mudela_note_l_list_.bottom().add (p);
}
void
My_midi_parser::note_end (int channel_i, int pitch_i, int aftertouch_i)
{
- // junk dynamics
- (void)aftertouch_i;
+ // junk dynamics
+ (void)aftertouch_i;
- // find
- for (PCursor<Mudela_note*> i (open_mudela_note_l_list_); i.ok(); i++) {
- if ( (i->pitch_i_ == pitch_i) && (i->channel_i_ == channel_i)) {
+ // find
+ for (PCursor<Mudela_note*> i (open_mudela_note_l_list_); i.ok(); i++)
+ {
+ if ( (i->pitch_i_ == pitch_i) && (i->channel_i_ == channel_i))
+ {
i->end_column_l_ = mudela_column_l_;
LOGOUT(DEBUG_ver) << "Note: " << pitch_i;
LOGOUT(DEBUG_ver) << "; " << i->mudela_column_l_->at_mom_;
LOGOUT(DEBUG_ver) << ", " << i->end_column_l_->at_mom_ << "\n";
i.remove_p();
return;
- }
+ }
}
- warning (String ("junking note-end event: ")
+ warning (String ("junking note-end event: ")
+ " channel = " + String_convert::i2dec_str (channel_i, 0, ' ')
+ ", pitch = " + String_convert::i2dec_str (pitch_i, 0, ' '));
}
void
My_midi_parser::note_end_all()
{
- // find
- for (PCursor<Mudela_note*> i (open_mudela_note_l_list_); i.ok(); i++) {
+ // find
+ for (PCursor<Mudela_note*> i (open_mudela_note_l_list_); i.ok(); i++)
+ {
i->end_column_l_ = mudela_column_l_;
i.remove_p();
// ugh
int
My_midi_parser::parse()
{
- LOGOUT(NORMAL_ver) << "\nParsing..." << flush;
- int i = ::yyparse();
- if (!i)
+ LOGOUT(NORMAL_ver) << "\nParsing..." << flush;
+ int i = ::yyparse();
+ if (!i)
note_end_all();
- return i;
+ return i;
}
void
My_midi_parser::set_division_4 (int division_4_i)
{
- division_1_i_ = division_4_i * 4;
- // ugh
- Duration::division_1_i_s = division_1_i_;
- if (division_4_i < 0)
+ division_1_i_ = division_4_i * 4;
+ // ugh
+ Duration::division_1_i_s = division_1_i_;
+ if (division_4_i < 0)
warning ("seconds iso metrical time");
}
void
My_midi_parser::set_key (int accidentals_i, int minor_i)
{
- delete mudela_key_p_;
- mudela_key_p_ = new Mudela_key (accidentals_i, minor_i);
+ delete mudela_key_p_;
+ mudela_key_p_ = new Mudela_key (accidentals_i, minor_i);
}
void
My_midi_parser::set_meter (int num_i, int den_i, int clocks_i, int count_32_i)
{
- delete mudela_meter_p_;
- mudela_meter_p_ = new Mudela_meter (num_i, den_i, clocks_i, count_32_i);
+ delete mudela_meter_p_;
+ mudela_meter_p_ = new Mudela_meter (num_i, den_i, clocks_i, count_32_i);
}
void
My_midi_parser::set_tempo (int useconds_per_4_i)
{
- delete mudela_tempo_p_;
- mudela_tempo_p_ = new Mudela_tempo (useconds_per_4_i);
+ delete mudela_tempo_p_;
+ mudela_tempo_p_ = new Mudela_tempo (useconds_per_4_i);
}
String
mi2mu_version_str()
{
- return String (mi2mu_version_sz())
+ return String (mi2mu_version_sz())
+ "/" + flower_version_sz()
+ " of " + __DATE__ + " " + __TIME__;
}
\mdef\quartball{'007}
\mdef\halfball{'010}
\mdef\wholeball{'011}
+\mdef\breveball{'040}
\mdef\halfrest{'074}
\mdef\wholerest{'075}
+\mdef\breverest{'072}
%% hmm
\mdef\outsidehalfrest{10}
\mdef\outsidewholerest{11}