+pl 12.hwn1
+ - polynomial.hh
+ - bf: generic properties
+ - quantise_iv () fix.
+ - bezier cleanup
+ - class Polynomial
+ - use smobs for font metric tables/hashes.
+ - nl.po bf
+
+
pl 11.jcn3
- small beam fixes (interstaff knees still broken)
ctor_dict["Score_element"]->create_func ();
. * acc at tied note after linebreak.
. * fix font-naming and selecting
+. * sparse ties.
. * chord tonic: placement of accidental C#, Cb (from scm and C++)
. * note head on stem err msg in dutch.
. * why need to run -C mf twice?
PACKAGE_NAME=LilyPond
MAJOR_VERSION=1
MINOR_VERSION=3
-PATCH_LEVEL=12
+PATCH_LEVEL=13
MY_PATCH_LEVEL=
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
BIGGER=1,
START = -1,
STOP = 1,
- X=1,
- Y=-1,
};
inline Direction
#include "real.hh"
#include "axes.hh"
+#include "arithmetic-operator.hh"
+
+struct Offset;
+
+Offset complex_multiply (Offset, Offset);
+Offset complex_exp (Offset);
+
/** 2d vector
should change to Complex
*/
struct Offset {
public:
-
Real coordinate_a_[NO_AXES];
- Real &y() { return coordinate_a_[Y_AXIS]; }
- Real &x() { return coordinate_a_[X_AXIS]; }
- Real y() const { return coordinate_a_[Y_AXIS]; }
- Real x() const { return coordinate_a_[X_AXIS]; }
-
Real &operator[](Axis i) {
return coordinate_a_[i];
}
}
Offset& operator+=(Offset o) {
- x()+=o.x ();
- y()+=o.y ();
+ (*this)[X_AXIS] += o[X_AXIS];
+ (*this)[Y_AXIS] += o[Y_AXIS];
return *this;
}
Offset operator - () const {
Offset o = *this;
- o.x () = - o.x ();
- o.y () = - o.y ();
+
+ o[X_AXIS] = - o[X_AXIS];
+ o[Y_AXIS] = - o[Y_AXIS];
return o;
}
Offset& operator-=(Offset o) {
- x()-=o.x ();
- y()-=o.y ();
+ (*this)[X_AXIS] -= o[X_AXIS];
+ (*this)[Y_AXIS] -= o[Y_AXIS];
+
return *this;
}
Offset &scale (Offset o) {
- x()*=o.x ();
- y()*=o.y ();
+ (*this)[X_AXIS] *= o[X_AXIS];
+ (*this)[Y_AXIS] *= o[Y_AXIS];
+
return *this;
}
Offset &operator *=(Real a) {
- y() *= a;
- x() *= a;
+ (*this)[X_AXIS] *= a;
+ (*this)[Y_AXIS] *= a;
+
return *this;
}
Offset (Real ix , Real iy) {
- x()=ix;
- y()=iy;
+ coordinate_a_[X_AXIS] =ix;
+ coordinate_a_[Y_AXIS] =iy;
}
Offset() {
- x()=0.0;
- y()=0.0;
+ coordinate_a_[X_AXIS]=
+ coordinate_a_[Y_AXIS]=
+ 0.0;
}
-#ifndef STANDALONE
+
String str () const;
-#endif
void mirror (Axis);
Real arg () const;
Real length () const;
-};
-
-Offset complex_multiply (Offset, Offset);
-Offset complex_exp (Offset);
-
-
-inline Offset
-operator* (Offset z1, Offset z2)
-{
- return complex_multiply (z1,z2);
-}
-
-inline Offset
-operator+ (Offset o1, Offset const& o2)
-{
- o1 += o2;
- return o1;
-}
+ Offset operator *=(Offset z2) {
+ *this = complex_multiply (*this,z2);
+ return *this;
+ }
-inline Offset
-operator- (Offset o1, Offset const& o2)
-{
- o1 -= o2;
- return o1;
-}
+};
+IMPLEMENT_ARITHMETIC_OPERATOR(Offset, +);
+IMPLEMENT_ARITHMETIC_OPERATOR(Offset, -);
+IMPLEMENT_ARITHMETIC_OPERATOR(Offset, *);
inline Offset
operator* (Real o1, Offset o2)
--- /dev/null
+
+/*
+ * poly.h -- routines for manipulation of polynomials in one var
+ *
+ * (c) 1993, 1996,1999 Han-Wen Nienhuys
+ */
+
+#ifndef POLY_H
+#define POLY_H
+
+#include "array.hh"
+#include "arithmetic-operator.hh"
+#include "real.hh"
+
+/// structure for a polynomial in one var.
+struct Polynomial
+{
+ /// degree of polynomial
+ int degree ()const;
+
+ /// coefficients
+ Array<Real> coefs_;
+
+ // leading coef
+ Real &lc();
+
+ // leading coef
+ Real lc() const;
+ void print() const ;
+ Real eval(Real) const ;
+ void print_sols(Array<Real>) const ;
+ void check_sols(Array<Real>) const ;
+ void check_sol(Real x) const;
+ static Polynomial multiply(const Polynomial & p1, const Polynomial & p2);
+ static Polynomial power(int exponent, const Polynomial & src);
+
+ /// chop low coefficients
+ void clean();
+
+ /// eliminate #x# close to zero
+ void real_clean();
+ static Polynomial add(const Polynomial & p1, const Polynomial & p2);
+ void scalarmultiply(Real fact);
+ void operator *= (Real f) { scalarmultiply(f); }
+ void operator /= (Real f) { scalarmultiply(1/f); }
+ void operator += (Polynomial const &p2);
+ void operator *= (Polynomial const &p2);
+ void operator -= (Polynomial const &p2);
+ Polynomial (Real a, Real b =0.0);
+ Polynomial (){}
+ static Polynomial subtract(const Polynomial & p1, const Polynomial & p2);
+ void set_negate(const Polynomial & src);
+
+ /// take the derivative
+ void differentiate();
+ int set_mod(const Polynomial &u, const Polynomial &v);
+
+ void debug_clean();
+
+ Array<Real> solve_quadric()const;
+ Array<Real> solve_cubic()const;
+ Array<Real> solve_linear()const;
+
+ Array<Real> solve () const;
+};
+
+
+IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, - );
+IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, + );
+IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, * );
+
+inline Polynomial
+operator * (Polynomial p, Real a)
+{
+ p *=a;
+ return p;
+}
+inline Polynomial
+operator * (Real a,Polynomial p)
+{
+ p *=a;
+ return p;
+}
+#endif
+
Real
Offset::arg () const
{
- return atan2 (y (), x());
+ return atan2 (coordinate_a_[Y_AXIS], coordinate_a_[X_AXIS]);
}
/**
Real
Offset::length () const
{
- return sqrt (sqr (x()) + sqr (y()));
+ return sqrt (sqr (coordinate_a_[X_AXIS]) + sqr (coordinate_a_[Y_AXIS]));
}
void
Offset::mirror (Axis a)
--- /dev/null
+/*
+ poly.cc -- routines for manipulation of polynomials in one var
+
+ (c) 1993--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ */
+
+
+#include "polynomial.hh"
+
+/*
+ Een beter milieu begint bij uzelf. Hergebruik!
+
+
+ This was ripped from Rayce, a raytracer I once wrote.
+*/
+
+Real
+Polynomial::eval (Real x)const
+{
+ Real p = 0.0;
+
+ // horner's scheme
+ for (int i = coefs_.size (); i--; )
+ p = x * p + coefs_[i];
+
+ return p;
+}
+
+
+Polynomial
+Polynomial::multiply(const Polynomial & p1, const Polynomial & p2)
+{
+ Polynomial dest;
+
+ int deg= p1.degree () + p2.degree ();
+ for (int i = 0; i <= deg; i++)
+ {
+ dest.coefs_.push (0);
+ for (int j = 0; j <= i; j++)
+ if (i - j <= p2.degree () && j <= p1.degree ())
+ dest.coefs_.top () += p1.coefs_[j] * p2.coefs_[i - j];
+ }
+
+ return dest;
+}
+
+void
+Polynomial::differentiate()
+{
+ for (int i = 1; i<= degree (); i++)
+ {
+ coefs_[i-1] = coefs_[i] * i;
+ }
+}
+
+Polynomial
+Polynomial::power(int exponent, const Polynomial & src)
+{
+ int e = exponent;
+ Polynomial dest(1), base(src);
+
+ // classicint power. invariant: src^exponent = dest * src ^ e
+ // greetings go out to Lex Bijlsma & Jaap vd Woude
+ while (e > 0)
+ {
+ if (e % 2)
+ {
+ dest = multiply(dest, base);
+ e--;
+ } else
+ {
+ base = multiply(base, base);
+ e /= 2;
+ }
+ }
+ return dest;
+}
+
+const Real FUDGE = 1e-8;
+
+void
+Polynomial::clean()
+{
+ int i;
+ for (i = 0; i <= degree (); i++)
+ {
+ if (abs(coefs_[i]) < FUDGE)
+ coefs_[i] = 0.0;
+ }
+
+ while (degree () > 0 && fabs (coefs_.top ()) < FUDGE * fabs (coefs_.top (1)))
+ coefs_.pop ();
+}
+
+
+Polynomial
+Polynomial::add(const Polynomial & p1, const Polynomial & p2)
+{
+ Polynomial dest;
+ int tempord = p2.degree () >? p1.degree ();
+ for (int i = 0; i <= tempord; i++)
+ {
+ Real temp = 0.0;
+ if (i <= p1.degree ())
+ temp += p1.coefs_[i];
+ if (i <= p2.degree ())
+ temp += p2.coefs_[i];
+ dest.coefs_.push (temp);
+ }
+ return dest;
+}
+
+void
+Polynomial::scalarmultiply(Real fact)
+{
+ for (int i = 0; i <= degree (); i++)
+ coefs_[i] *= fact;
+}
+
+Polynomial
+Polynomial::subtract(const Polynomial & p1, const Polynomial & p2)
+{
+ Polynomial dest;
+ int tempord = p2.degree () >? p1.degree ();
+
+ for (int i = 0; i <= tempord; i++)
+ {
+ Real temp = 0.0; // can't store result directly.. a=a-b
+ if (i <= p1.degree ())
+ temp += p1.coefs_[i];
+ if (i <= p2.degree ())
+ temp -= p2.coefs_[i];
+ dest.coefs_.push (temp);
+ }
+ return dest;
+
+}
+
+void
+Polynomial::set_negate(const Polynomial & src)
+{
+ for (int i = 0; i <= src.degree(); i++)
+ coefs_[i] = -src.coefs_[i];
+}
+
+/// mod of #u/v#
+int
+Polynomial::set_mod(const Polynomial &u, const Polynomial &v)
+{
+ (*this) = u;
+
+ if (v.lc() < 0.0) {
+ for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2)
+ coefs_[k] = -coefs_[k];
+
+ for (int k = u.degree () - v.degree (); k >= 0; k--)
+ for (int j = v.degree () + k - 1; j >= k; j--)
+ coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k];
+ } else {
+ for (int k = u.degree () - v.degree (); k >= 0; k--)
+ for (int j = v.degree () + k - 1; j >= k; j--)
+ coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k];
+ }
+
+ int k = v.degree () - 1;
+ while (k >= 0 && coefs_[k] == 0.0)
+ k--;
+
+ coefs_.set_size(1+ ( (k < 0) ? 0 : k));
+ return degree();
+}
+
+void
+Polynomial::check_sol(Real x) const
+{
+ Real f=eval(x);
+ Polynomial p(*this);
+ p.differentiate();
+ Real d = p.eval(x);
+
+ if( abs(f) > abs(d) * FUDGE)
+ ;
+ /*
+ warning("x=%f is not a root of polynomial\n"
+ "f(x)=%f, f'(x)=%f \n", x, f, d); */
+}
+
+void
+Polynomial::check_sols(Array<Real> roots) const
+{
+ for (int i=0; i< roots.size (); i++)
+ check_sol(roots[i]);
+}
+
+Polynomial::Polynomial (Real a, Real b)
+{
+ coefs_.push (a);
+ if (b)
+ coefs_.push (b);
+}
+
+/* cubic root. */
+inline Real cubic_root(Real x)
+{
+ if (x > 0.0)
+ return pow(x, 1.0/3.0) ;
+ else if (x < 0.0)
+ return -pow(-x, 1.0/3.0);
+ else
+ return 0.0;
+}
+
+static bool
+iszero (Real r)
+{
+ return !r;
+}
+
+Array<Real>
+Polynomial::solve_cubic()const
+{
+ Array<Real> sol;
+
+ /* normal form: x^3 + Ax^2 + Bx + C = 0 */
+ Real A = coefs_[2] / coefs_[3];
+ Real B = coefs_[1] / coefs_[3];
+ Real C = coefs_[0] / coefs_[3];
+
+ /*
+ * substitute x = y - A/3 to eliminate quadric term: x^3 +px + q = 0
+ */
+
+ Real sq_A = A * A;
+ Real p = 1.0 / 3 * (-1.0 / 3 * sq_A + B);
+ Real q = 1.0 / 2 * (2.0 / 27 * A * sq_A - 1.0 / 3 * A * B + C);
+
+ /* use Cardano's formula */
+
+ Real cb_p = p * p * p;
+ Real D = q * q + cb_p;
+
+ if (iszero(D)) {
+ if (iszero(q)) { /* one triple solution */
+ sol.push (0);
+ sol.push (0);
+ sol.push (0);
+ } else { /* one single and one double solution */
+ Real u = cubic_root(-q);
+
+ sol.push (2 * u);
+ sol.push (-u);
+ }
+ } else if (D < 0) { /* Casus irreducibilis: three real solutions */
+ Real phi = 1.0 / 3 * acos(-q / sqrt(-cb_p));
+ Real t = 2 * sqrt(-p);
+
+ sol.push (t * cos(phi));
+ sol.push (-t * cos(phi + M_PI / 3));
+ sol.push ( -t * cos(phi - M_PI / 3));
+ } else { /* one real solution */
+ Real sqrt_D = sqrt(D);
+ Real u = cubic_root(sqrt_D - q);
+ Real v = -cubic_root(sqrt_D + q);
+
+ sol.push ( u + v);
+ }
+
+ /* resubstitute */
+ Real sub = 1.0 / 3 * A;
+
+ for (int i = sol.size (); i--;)
+ {
+ sol[i] -= sub;
+
+ assert (fabs (eval (sol[i]) ) < 1e-8);
+ }
+
+ return sol;
+}
+
+Real
+Polynomial::lc () const
+{
+ return coefs_.top();
+}
+
+Real&
+Polynomial::lc ()
+{
+ return coefs_.top ();
+}
+
+int
+Polynomial::degree ()const
+{
+ return coefs_.size () -1;
+}
+/*
+ all roots of quadratic eqn.
+ */
+Array<Real>
+Polynomial::solve_quadric()const
+{
+ Array<Real> sol;
+ /* normal form: x^2 + px + q = 0 */
+ Real p = coefs_[1] / (2 * coefs_[2]);
+ Real q = coefs_[0] / coefs_[2];
+
+ Real D = p * p - q;
+
+ if (D>0) {
+ D = sqrt(D);
+
+ sol.push ( D - p);
+ sol.push ( -D - p);
+ }
+ return sol;
+}
+
+/* solve linear equation */
+Array<Real>
+Polynomial::solve_linear()const
+{
+ Array<Real> s;
+ if (coefs_[1])
+ s.push ( -coefs_[0] / coefs_[1]);
+ return s;
+}
+
+
+Array<Real>
+Polynomial::solve () const
+{
+ Polynomial * me = (Polynomial*) this;
+ me->clean ();
+
+ switch (degree ())
+ {
+ case 1:
+ return solve_linear ();
+ case 2:
+ return solve_quadric ();
+ case 3:
+ return solve_cubic ();
+ }
+ assert (false);
+ Array<Real> s;
+ return s;
+}
+
+void
+Polynomial:: operator *= (Polynomial const &p2)
+{
+ *this = multiply (*this,p2);
+}
+
+void
+Polynomial::operator += (Polynomial const &p)
+{
+ *this = add( *this, p);
+}
+
+void
+Polynomial::operator -= (Polynomial const &p)
+{
+ *this = subtract(*this, p);
+}
--- /dev/null
+
+% Generated by mudela-book.py; options are center
+\include "paper16.ly"
+\paper { linewidth = 390.000000 \pt; }
+
+\header {
+ title = "The river is flowing";
+ composer = "Traditional (?)";
+}
+\include "paper16.ly"
+
+melody = \notes \relative c' {
+ \partial 8;
+ g8 |
+
+}
+
+text = \lyrics {
+ The
+}
+
+accompaniment =\chords {
+ r8
+ c2:3- f:3-.7 d:min es4 c8:min r8
+ c2:min f:min7 g:7^3.5 c:min }
+
+\score {
+ \simultaneous {
+
+ \addlyrics
+ \context Staff = mel {
+ \melody
+ }
+ \context Lyrics \text
+ }
+% \midi { }
+ \paper { linewidth = 10.0\cm; }
+}
# input/test/Makefile
depth = ../..
-examples=font20
+examples=font20 sleur
LOCALSTEPMAKE_TEMPLATES=mutopia
include $(depth)/make/stepmake.make
}
#define READSTRING(k) if (key == #k) { \
- afm.k ## _ = input.get_line (); continue; }
+ afm->k ## _ = input.get_line (); continue; }
#define READBOX(b) if (key == #b) { \
- afm.b ## _ = read_box (input); continue; }
+ afm->b ## _ = read_box (input); continue; }
#define READREAL(r) if (key == #r) { \
- afm.r ## _ = read_real (input); continue; }
+ afm->r ## _ = read_real (input); continue; }
Real
read_real(Data_file &d)
return b;
}
-Adobe_font_metric
+Adobe_font_metric *
read_afm_file (String fn)
{
Data_file input (fn);
{}
int font_size = String_convert::dec2_i(fn.cut_str(i+1,INT_MAX));
- Adobe_font_metric afm;
-
+ Adobe_font_metric *afm = new Adobe_font_metric;
for (i=0; i < 256; i++)
{
- afm.ascii_to_metric_idx_.push (-1);
+ afm->ascii_to_metric_idx_.push (-1);
}
while (!input.eof_b ())
if (key == "StartCharMetrics")
{
input.get_line ();
- afm.read_char_metrics (input, font_size);
+ afm->read_char_metrics (input, font_size);
}
if (key == "EndFontMetrics")
break;
// todo: fucks up if item both in Halign & Valign.
SCM min_dims = e->remove_elt_property ("minimum-space");
- if (min_dims != SCM_UNDEFINED)
+ if (gh_pair_p (min_dims) &&
+ gh_number_p (gh_car (min_dims))
+ && gh_number_p (gh_cdr (min_dims)))
{
- y.unite (Interval (gh_scm2double (SCM_CAR (min_dims)),
- gh_scm2double (SCM_CDR (min_dims))));
+ y.unite (Interval (gh_scm2double (gh_car (min_dims)),
+ gh_scm2double (gh_cdr (min_dims))));
}
SCM extra_dims = e->remove_elt_property ("extra-space");
- if (extra_dims != SCM_UNDEFINED)
+ if (gh_pair_p (extra_dims) &&
+ gh_number_p (gh_car (extra_dims))
+ && gh_number_p (gh_cdr (extra_dims)))
{
- y[LEFT] += gh_scm2double (SCM_CAR (extra_dims));
- y[RIGHT] += gh_scm2double (SCM_CDR (extra_dims));
+ y[LEFT] += gh_scm2double (gh_car (extra_dims));
+ y[RIGHT] += gh_scm2double (gh_cdr (extra_dims));
}
elems.push (e);
if (center_f)
translate_axis ( - center_f, axis ());
-
-
- // dim_cache_[axis ()]->invalidate ();
-
}
Align_element::Align_element()
#include "warn.hh"
#include "afm.hh"
#include "tfm.hh"
-#include "dictionary-iter.hh"
#include "lily-guile.hh"
#include "tfm-reader.hh"
Adobe_font_metric *
All_font_metrics::find_afm (String name)
{
- if (!afm_p_dict_.elem_b (name))
+ SCM sname = ly_symbol2scm (name.ch_C ());
+ if (!afm_p_dict_.elem_b (sname))
{
String path = name + ".afm";
path = search_path_.find (path);
return 0;
*mlog << "[" << path;
- Adobe_font_metric
- * afm_p = new Adobe_font_metric (read_afm_file (path));
+ Adobe_font_metric * afm_p = read_afm_file (path);
afm_p->name_str_ = name;
*mlog << "]" << flush ;
- afm_p_dict_[name] = afm_p;
+ afm_p_dict_[sname] = afm_p->self_scm_;
+ scm_unprotect_object (afm_p->self_scm_);
}
- return afm_p_dict_[name];
+
+ return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (afm_p_dict_[sname]));
}
Scaled_font_metric *
{
Scaled_font_metric * s=0;
String index = nm + "@" + to_str (m);
- if (!scaled_p_dict_.elem_b (index))
+ SCM sname = ly_symbol2scm (index.ch_C ());
+
+ Font_metric *fm =0;
+ if (!scaled_p_dict_.elem_b (sname))
{
Font_metric *f = find_font (nm);
s = new Scaled_font_metric (f, m);
- scaled_p_dict_[index] = s;
- return s;
+ scaled_p_dict_[sname] = s->self_scm_;
+ fm = s;
+ scm_unprotect_object (s->self_scm_);
}
else
- return scaled_p_dict_[index];
+ fm = unsmob_metrics (scaled_p_dict_[sname]);
+
+ return dynamic_cast<Scaled_font_metric*> (fm);
}
Tex_font_metric *
All_font_metrics::find_tfm (String name)
{
- if (!tfm_p_dict_.elem_b (name))
+ SCM sname = ly_symbol2scm (name.ch_C ());
+ if (!tfm_p_dict_.elem_b (sname))
{
String path = name + ".tfm";
path = search_path_.find (path);
*mlog << "]" << flush ;
- tfm_p_dict_[name] = tfm_p;
+ tfm_p_dict_[sname] = tfm_p->self_scm_;
+ scm_unprotect_object (tfm_p->self_scm_);
}
- return tfm_p_dict_[name];
+
+ return
+ dynamic_cast<Tex_font_metric*> (unsmob_metrics (tfm_p_dict_[sname]));
}
error (_f ("Can't find default font: `%s'", default_font_sz_));
error (_f ("(search path: `%s'", search_path_.str ()));
error (_ ("Giving up"));
+
+ return 0;
}
SCM
All_font_metrics::font_descriptions () const
{
- SCM l = SCM_EOL;
- for (Dictionary_iter<Adobe_font_metric*> ai(afm_p_dict_); ai.ok (); ai++)
- l = gh_cons (ai.val ()->description (), l);
- for (Dictionary_iter<Tex_font_metric*> ai(tfm_p_dict_); ai.ok (); ai++)
- l = gh_cons(ai.val ()->description (), l);
-
- for (Dictionary_iter<Scaled_font_metric*> ai(scaled_p_dict_); ai.ok (); ai++)
- l = gh_cons (ai.val ()->description (),l);
-
- return l;
+ SCM l[] = {0,0,0};
+
+ l[0] = afm_p_dict_.to_alist ();
+ l[1] = tfm_p_dict_.to_alist ();
+ l[2] = scaled_p_dict_.to_alist ();
+
+ SCM list = SCM_EOL;
+ for (int i=0; i < 3; i++)
+ {
+ for (SCM s = l[i]; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Font_metric * fm = unsmob_metrics (gh_cdar (s));
+
+ list = gh_cons (fm->description (), list);
+ }
+ }
+ return list;
+}
+
+Font_metric *
+unsmob_metrics( SCM s)
+{
+ if (SMOB_IS_TYPE_B(Font_metric, s))
+ return SMOB_TO_TYPE(Font_metric, s);
+ else
+ return 0;
}
+
+#include "ly-smobs.icc"
+IMPLEMENT_SMOBS(Font_metric);
/*
[TODO]
- * center beam symbol
* less hairy code
* move paper vars to scm
- */
-
-//#include <math.h>
+*/
#include "beaming.hh"
#include "dimensions.hh"
}
if (!get_direction ())
- set_direction (calc_default_dir ());
+ set_direction (get_default_dir ());
auto_knees ();
set_stem_directions ();
FIXME
*/
Direction
-Beam::calc_default_dir () const
+Beam::get_default_dir () const
{
Drul_array<int> total;
total[UP] = total[DOWN] = 0;
allowed_fraction[1] = (beam_f / 2 + staffline_f / 2);
allowed_fraction[2] = (beam_f + staffline_f);
- Interval iv = quantise_iv (allowed_fraction, interline_f, abs (dy));
+ allowed_fraction.push (interline_f);
+ Interval iv = quantise_iv (allowed_fraction, abs (dy));
Real q = (abs (dy) - iv[SMALLER] <= iv[BIGGER] - abs (dy))
? iv[SMALLER]
: iv[BIGGER];
allowed_position.push (hang);
}
+ allowed_position.push (space);
Real up_y = get_direction () * y;
- Interval iv = quantise_iv (allowed_position, space, up_y);
+ Interval iv = quantise_iv (allowed_position, up_y);
Real q = up_y - iv[SMALLER] <= iv[BIGGER] - up_y
? iv[SMALLER] : iv[BIGGER];
#include <math.h>
#include "bezier.hh"
-#include "misc.hh"
-
-#ifndef STANDALONE
-#include "dimensions.hh"
-#include "direction.hh"
-#include "paper-def.hh"
-#include "debug.hh"
-#include "main.hh"
-#define BEZIER_BOW_DEBUG_OUT if (flower_dstream && !flower_dstream->silent_b ("Bezier_bow")) cout
-#else
-#define BEZIER_BOW_DEBUG_OUT cerr
-#endif
-
+#include "polynomial.hh"
/*
- [TODO]
- * better names, esp. for all calc_foo functions
- * blow_fit vs calc_default (Real) and calc_f (Real)
- * exact height / tangent calculation
+ Formula of the bezier 3-spline
+ sum_{j=0}^3 (3 over j) z_j (1-t)^(3-j) t^j
*/
-
-/*
- UGH. Remove debugging junk.
- */
-
-
-void
-Curve::flipy ()
-{
- for (int i = 0; i < size (); i++)
- (*this)[i].mirror (Y_AXIS);
-}
-
-int
-Curve::largest_disturbing ()
-{
- Real alpha = 0;
- int j = 0;
- for (int i = 1; i < size (); i++)
- {
- if ((*this)[i][Y_AXIS] > 0)
- {
- Real phi = (*this)[i][Y_AXIS] / (*this)[i][X_AXIS];
- if (phi > alpha)
- {
- alpha = phi;
- j = i;
- }
- }
- }
- return j;
-}
-
-void
-Curve::rotate (Real phi)
-{
- Offset rot (complex_exp (Offset (0, phi)));
- for (int i = 0; i < size (); i++)
- (*this)[i] = complex_multiply (rot, (*this)[i]);
-}
-
-void
-Curve::translate (Offset o)
-{
- for (int i = 0; i < size (); i++)
- (*this)[i] += o;
-}
-
Bezier::Bezier ()
{
- control_.set_size (4);
-}
-
-void
-Bezier::calc (int steps)
-{
- steps = steps >? 10;
- curve_.set_size (steps);
- Real dt = 1.0 / curve_.size ();
- Offset c = 3.0 * (control_[1] - control_[0]);
- Offset b = 3.0 * (control_[2] - control_[1]) - c;
- Offset a = control_[3] - (control_[0] + c + b);
- Real t = 0.0;
- for (int i = 0; i < curve_.size (); i++ )
- {
- curve_[i] = ((a * t + b) * t + c) * t + control_[0];
- t += dt;
- }
-}
-
-void
-Bezier::print () const
-{
-#ifndef NPRINT
- if (flower_dstream && !flower_dstream->silent_b ("Bezier_controls"))
- {
- if (control_[1].length ())
- {
- cout << "Bezier\n";
- cout << "Controls: ";
- for (int i=0; i < control_.size (); i++)
- cout << control_[i].str () << ", ";
- }
- }
-#endif
-}
-
-void
-Bezier::set (Array<Offset> points)
-{
- assert (points.size () == 4);
- control_ = points;
}
Real
-Bezier::y (Real x)
+Bezier::get_other_coordinate (Axis a, Real x) const
{
- // ugh
- // bounds func should be templatised to take array of offsets too?
- Array<Real> positions;
- for (int i = 0; i < curve_.size (); i++)
- positions.push (curve_[i][X_AXIS]);
-
- Slice slice = get_bounds_slice (positions, x);
- // ugh
- Offset z1 = curve_[0 >? slice[BIGGER] - 1];
- Offset z2 = curve_[1 >? slice[BIGGER]];
- Real multiplier = (x - z2[X_AXIS]) / (z1[X_AXIS] - z2[X_AXIS]);
- Real y = z1[Y_AXIS] * multiplier + (1.0 - multiplier) * z2[Y_AXIS];
-
- return y;
-}
-
-
-Bezier_bow::Bezier_bow (Paper_def* paper_l)
-{
- paper_l_ = paper_l;
- return_.set_size (4);
-}
-
-void
-Bezier_bow::blow_fit ()
-{
- Real dy1 = check_fit_f ();
- if (!dy1)
- return;
-
- // be careful not to take too big step
- Real f = 0.3;
- Real h1 = dy1 * f;
- control_[1][Y_AXIS] += h1;
- control_[2][Y_AXIS] += h1;
- return_[1][Y_AXIS] += h1;
- return_[2][Y_AXIS] += h1;
-
- calc_bezier ();
- Real dy2 = check_fit_f ();
- if (!dy2)
- return;
-
-#ifndef STANDALONE
- Real internote_f = paper_l_->get_var ("interline")/2.0;
-#else
- Real internote_f = STAFFHEIGHT / 8;
-#endif
-
- Real epsilon = internote_f / 4;
- if (abs (dy2 - dy1) < epsilon)
- return;
+ Axis other = Axis ((a +1)%NO_AXES);
+ Array<Real> ts = solve_point (a, x);
- /*
- Assume
- dy = B (h)
- with
- B (h) = a * h + b;
-
- Then we get for h : B (h) = 0
-
- B(0) = dy1 = a * 0 + b => b = dy1
- B(h1) = dy2 = a * h1 + b => a * f * dy1 + b = dy2
-
- =>
-
- a * dy1 / 2 + dy1 = dy2 => a = (dy2 - dy1) / (f * dy1)
- */
-
- Real a = (dy2 - dy1) / (f * dy1);
- Real b = dy1;
- Real h = -b / a;
-
- if (sign (h) != sign (h1))
- return;
-
- if (sign (h) != sign (h1))
- return;
-
- control_[1][Y_AXIS] += -h1 +h;
- control_[2][Y_AXIS] += -h1 +h;
- return_[1][Y_AXIS] += -h1 +h;
- return_[2][Y_AXIS] += -h1 +h;
-}
-
-void
-Bezier_bow::calc_bezier ()
-{
- Real s = sqrt (control_[3][X_AXIS] * control_[3][X_AXIS]
- + control_[1][Y_AXIS] * control_[2][Y_AXIS]);
-#ifndef STANDALONE
- Real internote = paper_l_->get_var ("interline")/2.0;
-#else
- Real internote = STAFFHEIGHT / 8;
-#endif
- int steps = (int)rint (s / internote);
- Bezier::calc (steps);
+ Offset c = curve_point (ts[0]);
+ assert (fabs (c[a] - x) < 1e-8);
+
+ return c[other];
}
Real
-Bezier_bow::calc_f (Real height)
+binomial_coefficient (Real over , int under)
{
- transform ();
- calc_default (height);
- calc_bezier ();
+ Real x = 1.0;
- Real dy = check_fit_f ();
- calc_return (0, 0);
+ while (under)
+ {
+ x *= over / Real (under);
- transform_back ();
- return dy;
+ over -= 1.0;
+ under --;
+ }
+ return x;
}
-void
-Bezier_bow::calc ()
+Offset
+Bezier::curve_point (Real t)const
{
-#ifndef NPRINT
-// if (flower_dstream && !flower_dstream->silent_b ("Bezier_bow_controls"))
- if (flower_dstream && !(flower_dstream->silent_b ("Bezier_controls")
- && flower_dstream->silent_b ("Bezier_bow_controls")))
- {
- cout << "Before transform*********\n";
- print ();
- cout << "************************\n";
- }
-#endif
- transform ();
- print ();
-
- calc_controls ();
+ Real tj = 1;
+ Real one_min_tj = (1-t)*(1-t)*(1-t);
- /*
- duh, this is crude (control-points)
- perhaps it's even better to check the amount of blow_fit ()
- */
- for (int i=0; i < control_.size (); i++)
+ Offset o;
+ for (int j=0 ; j < 4; j++)
{
- Real y = control_[i][Y_AXIS];
- curve_extent_drul_[Y].unite (Interval (y, y));
- Real x = control_[i][X_AXIS];
- curve_extent_drul_[X].unite (Interval (x, x));
- }
+ o += control_[j] * binomial_coefficient (3, j)
+ * pow (t,j) * pow (1-t, 3-j);
- print ();
- transform_back ();
-#ifndef NPRINT
-// if (flower_dstream && !flower_dstream->silent_b ("Bezier_bow_controls"))
- if (flower_dstream && !(flower_dstream->silent_b ("Bezier_controls")
- && flower_dstream->silent_b ("Bezier_bow_controls")))
- {
- cout << "After transform*********\n";
- print ();
- cout << "************************\n";
+ tj *= t;
+ if (1-t)
+ one_min_tj /= (1-t);
}
-#endif
-}
-/*
- [TODO]
- * see if it works
- * document in Documentation/fonts.tex
- */
-
-/*
- Clipping
-
- This function tries to address two issues:
- * the tangents of the slur should always point inwards
- in the actual slur, i.e. *after rotating back*.
-
- * slurs shouldn't be too high
- let's try : h <= 1.2 b && h <= 3 staffheight?
+ assert (fabs (o[X_AXIS] - polynomial (X_AXIS).eval (t))< 1e-8);
+ assert (fabs (o[Y_AXIS] - polynomial (Y_AXIS).eval (t))< 1e-8);
- We could calculate the tangent of the bezier curve from
- both ends going inward, and clip the slur at the point
- where the tangent (after rotation) points up (or inward
- with a certain maximum angle).
- However, we assume that real clipping is not the best
- answer. We expect that moving the outer control point up
- if the slur becomes too high will result in a nicer slur
- after recalculation.
+ return o;
+}
- Knowing that the tangent is the line through the first
- two control points, we'll clip (move the outer control
- point upwards) too if the tangent points outwards.
- */
-bool
-Bezier_bow::calc_clipping ()
+Polynomial
+Bezier::polynomial (Axis a)const
{
-#ifndef STANDALONE
- Real clip_height = paper_l_->get_var ("slur_clip_height");
- Real clip_ratio = paper_l_->get_var ("slur_clip_ratio");
- Real clip_angle = paper_l_->get_var ("slur_clip_angle");
-#else
- Real staffsize_f = STAFFHEIGHT;
- Real clip_height = 3.0 * staffsize_f;
- Real clip_ratio = 1.2;
- Real clip_angle = 100;
-#endif
-
- Real b = control_[3][X_AXIS] - control_[0][X_AXIS];
- Real clip_h = clip_ratio * b <? clip_height;
- Real begin_h = control_[1][Y_AXIS] - control_[0][Y_AXIS];
- Real end_h = control_[2][Y_AXIS] - control_[3][Y_AXIS];
- Real begin_dy = 0 >? begin_h - clip_h;
- Real end_dy = 0 >? end_h - clip_h;
-
- Real pi = M_PI;
- Real begin_alpha = (control_[1] - control_[0]).arg () + get_direction () * alpha_;
- Real end_alpha = pi - (control_[2] - control_[3]).arg () - get_direction () * alpha_;
-
- Real max_alpha = clip_angle / 90 * pi / 2;
- if ((begin_dy < 0) && (end_dy < 0)
- && (begin_alpha < max_alpha) && (end_alpha < max_alpha))
- return false;
-
- transform_back ();
-
- bool again = true;
-
- if ((begin_dy > 0) || (end_dy > 0))
+ Polynomial p (0.0);
+ for (int j=0; j <= 3; j++)
{
- Real dy = (begin_dy + end_dy) / 4;
- dy *= cos (alpha_);
- encompass_[0][Y_AXIS] += get_direction () * dy;
- encompass_[encompass_.size () - 1][Y_AXIS] += get_direction () * dy;
+ p += control_[j][a]
+ * Polynomial::power (j , Polynomial (0,1))*
+ Polynomial::power (3 - j, Polynomial (1,-1))*
+ binomial_coefficient(3, j);
}
- else
- {
- //ugh
- Real c = 0.4;
- if (begin_alpha >= max_alpha)
- begin_dy = 0 >? c * begin_alpha / max_alpha * begin_h;
- if (end_alpha >= max_alpha)
- end_dy = 0 >? c * end_alpha / max_alpha * end_h;
-
- encompass_[0][Y_AXIS] += get_direction () * begin_dy;
- encompass_[encompass_.size () - 1][Y_AXIS] += get_direction () * end_dy;
- Offset delta = encompass_[encompass_.size () - 1] - encompass_[0];
- alpha_ = delta.arg ();
- }
-
- transform ();
-
- return again;
+ return p;
}
-void
-Bezier_bow::calc_controls ()
+/**
+ Remove all numbers outside [0,1] from SOL
+ */
+Array<Real>
+filter_solutions (Array<Real> sol)
{
- for (int i = 0; i < 3; i++)
- {
- if (i && !calc_clipping ())
- return;
-
- /*
- why do we always recalc from 0?
- shouldn't calc_f () be used (too), rather than blow_fit () (only)?
- */
- calc_default (0);
- calc_bezier ();
-
- if (check_fit_bo ())
- {
- calc_return (0, 0);
- return;
- }
- calc_tangent_controls ();
-
- blow_fit ();
- // ugh
- blow_fit ();
- }
+ for (int i = sol.size (); i--;)
+ if (sol[i] < 0 || sol[i] >1)
+ sol.del (i);
+ return sol;
}
-void
-Bezier_bow::calc_return (Real begin_alpha, Real end_alpha)
+/**
+ find t such that derivative is proportional to DERIV
+ */
+Array<Real>
+Bezier::solve_derivative (Offset deriv)const
{
-#ifndef STANDALONE
- Real thick = paper_l_->get_var ("slur_thickness");
-#else
- Real thick = 1.8 * 0.4 PT;
-#endif
+ Polynomial xp[2];
- return_[0] = control_[3];
- return_[3] = control_[0];
-
- return_[1] = control_[2] - thick * complex_exp (Offset (0, 90 + end_alpha));
- return_[2] = control_[1]
- - thick * complex_exp (Offset (0, 90 - begin_alpha));
+ xp[X_AXIS] = polynomial (X_AXIS);
+ xp[Y_AXIS] = polynomial (Y_AXIS);
+ Polynomial combine = xp[X_AXIS] * deriv[Y_AXIS] - xp[Y_AXIS] * deriv [X_AXIS];
+ return filter_solutions (combine.solve ());
}
+
/*
- See Documentation/fonts.tex
- */
-void
-Bezier_bow::calc_tangent_controls ()
+ Find t such that curve_point (t)[AX] == COORDINATE
+*/
+Array<Real>
+Bezier::solve_point (Axis ax, Real coordinate) const
{
- Offset ijk_p (control_[3][X_AXIS] / 2, control_[1][Y_AXIS]);
- BEZIER_BOW_DEBUG_OUT << "ijk: " << ijk_p[X_AXIS] << ", " << ijk_p[Y_AXIS] << endl;
-
- Real default_rc = ijk_p[Y_AXIS] / ijk_p[X_AXIS];
-
- int begin_disturb = encompass_.largest_disturbing ();
- Offset begin_p = begin_disturb ? Offset (encompass_[begin_disturb][X_AXIS],
- encompass_[begin_disturb][Y_AXIS]) : ijk_p;
- Real begin_rc = begin_p[Y_AXIS] / begin_p[X_AXIS];
- if (default_rc > begin_rc)
- {
- begin_p = ijk_p;
- begin_rc = default_rc;
- }
-
- Curve reversed;
- reversed.set_size (encompass_.size ());
- Real b = control_[3][X_AXIS];
- for (int i = 0; i < encompass_.size (); i++ )
- {
- // b 1 0
- // r = - * c
- // 0 0 -1
- reversed[i][X_AXIS] = b - encompass_[encompass_.size () - i - 1][X_AXIS];
- reversed[i][Y_AXIS] = encompass_[encompass_.size () - i - 1][Y_AXIS];
- }
-
- int end_disturb = reversed.largest_disturbing ();
- end_disturb = end_disturb ? encompass_.size () - end_disturb - 1 : 0;
- Offset end_p = end_disturb ? Offset (encompass_[end_disturb][X_AXIS],
- encompass_[end_disturb][Y_AXIS]) : ijk_p;
- Real end_rc = end_p[Y_AXIS] / (control_[3][X_AXIS] - end_p[X_AXIS]);
- if (default_rc > end_rc)
- {
- end_p = ijk_p;
- end_rc = default_rc;
- }
-
- Real height =control_[1][Y_AXIS];
- for (int i = 0; i < encompass_.size (); i++ )
- height = height >? encompass_[i][Y_AXIS];
-
- // emperic computer science:
- // * tangents somewhat steeper than minimal line
-#ifndef STANDALONE
- Real internote = paper_l_->get_var ("interline")/2.0;
- Real rc_correct = paper_l_->get_var ("slur_rc_factor");
-#else
- Real internote = STAFFHEIGHT / 8;
- Real rc_correct = 2.4;
-#endif
-
- begin_rc *= rc_correct;
- end_rc *= rc_correct;
- Real rc1 = begin_rc;
- Real rc2 = -end_rc;
+ Polynomial p(polynomial (ax));
+ p.coefs_[0] -= coordinate;
- Real begin_alpha = atan (begin_rc);
- Real end_alpha = atan (-end_rc);
- Real theta = (begin_alpha - end_alpha) / 2;
-
- Real epsilon = internote / 5;
-
- // if we have two disturbing points, have height line through those...
- if (!((abs (begin_p[X_AXIS] - end_p[X_AXIS]) < epsilon)
- && (abs (begin_p[Y_AXIS] - end_p[Y_AXIS]) < epsilon)))
- theta = atan (end_p[Y_AXIS] - begin_p[Y_AXIS]) / (end_p[X_AXIS] - begin_p[X_AXIS]);
-
- Real rc3 = tan (theta);
- // ugh: be less steep
- rc3 /= 2*rc_correct;
-
- Real c2 = -rc2 * control_[3][X_AXIS];
- Real c3 = begin_p[Y_AXIS] > end_p[Y_AXIS] ? begin_p[Y_AXIS]
- - rc3 * begin_p[X_AXIS] : end_p[Y_AXIS] - rc3 * end_p[X_AXIS];
-
- control_[1][X_AXIS] = c3 / (rc1 - rc3);
- control_[1][Y_AXIS] = rc1 * control_[1][X_AXIS];
- control_[2][X_AXIS] = (c3 - c2) / (rc2 - rc3);
- control_[2][Y_AXIS] = rc2 * control_[2][X_AXIS] + c2;
-
- calc_return (begin_alpha, end_alpha);
-}
-
-bool
-Bezier_bow::check_fit_bo ()
-{
- for (int i = 1; i < encompass_.size () - 1; i++)
- if ((encompass_[i][X_AXIS] > encompass_[0][X_AXIS])
- && (encompass_[i][X_AXIS] < encompass_[encompass_.size () -1][X_AXIS]))
- if (encompass_[i][Y_AXIS] > y (encompass_[i][X_AXIS]))
- return false;
- return true;
-}
-
-Real
-Bezier_bow::check_fit_f ()
-{
- Real dy = 0;
- for (int i = 1; i < encompass_.size () - 1; i++)
- if ((encompass_[i][X_AXIS] > encompass_[0][X_AXIS])
- && (encompass_[i][X_AXIS] < encompass_[encompass_.size () -1][X_AXIS]))
- dy = dy >? (encompass_[i][Y_AXIS] - y (encompass_[i][X_AXIS]));
- return dy;
+ Array<Real> sol (p.solve ());
+ return filter_solutions (sol);
}
-void
-Bezier_bow::print () const
+Interval
+Bezier::extent (Axis a)const
{
-#ifndef NPRINT
- Bezier::print ();
- if (flower_dstream && !flower_dstream->silent_b ("Bezier_bow_controls"))
+ int o = (a+1)%NO_AXES;
+ Offset d;
+ d[Axis (o)] =1.0;
+ Interval iv;
+ Array<Real> sols (solve_derivative (d));
+ sols.push (1.0);
+ sols.push (0.0);
+ for (int i= sols.size (); i--;)
{
- cout << "Bezier_bow\n";
- cout << "Encompass: ";
- for (int i=0; i < encompass_.size (); i++)
- cout << encompass_[i].str () << ", ";
-// cout << "\n";
+ Offset o (curve_point (sols[i]));
+ iv.unite (Interval (o[a],o[a]));
}
-#endif
+ return iv;
}
void
-Bezier_bow::set (Array<Offset> points, Direction dir)
+Bezier::flip (Axis a)
{
- set_direction (dir);
- encompass_ = points;
+ for (int i = CONTROL_COUNT; i--;)
+ control_[i][a] = - control_[i][a];
}
void
-Bezier_bow::transform ()
+Bezier::rotate (Real phi)
{
- origin_ = encompass_[0];
- encompass_.translate (-origin_);
-
- Offset delta = encompass_[encompass_.size () - 1] - encompass_[0];
- alpha_ = delta.arg ();
-
- encompass_.rotate (-alpha_);
-
- if (get_direction () == DOWN)
- encompass_.flipy ();
+ Offset rot (complex_exp (Offset (0, phi)));
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ control_[i] = complex_multiply (rot, control_[i]);
}
void
-Bezier_bow::transform_back ()
+Bezier::translate (Offset o)
{
- if (get_direction () == DOWN)
- {
- control_.flipy ();
- return_.flipy ();
- encompass_.flipy ();
- }
-
- control_.rotate (alpha_);
- control_.translate (origin_);
-
- return_.rotate (alpha_);
- return_.translate (origin_);
-
- encompass_.rotate (alpha_);
- encompass_.translate (origin_);
+ for (int i = 0; i < CONTROL_COUNT; i++)
+ control_[i] += o;
}
-/*
- See Documentation/fonts.tex
- */
void
-Bezier_bow::calc_default (Real h)
+Bezier::check_sanity () const
{
- Real pi = M_PI;
-#ifndef STANDALONE
- Real height_limit = paper_l_->get_var ("slur_height_limit");
- Real ratio = paper_l_->get_var ("slur_ratio");
-#else
- Real staffsize_f = STAFFHEIGHT;
- Real height_limit = staffsize_f;
- Real ratio = 1.0/3.0;
-#endif
-
- Real alpha = height_limit * 2.0 / pi;
- Real beta = pi * ratio / (2.0 * height_limit);
-
- Offset delta (encompass_[encompass_.size () - 1][X_AXIS]
- - encompass_[0][X_AXIS], 0);
- Real b = delta.length ();
- Real indent = alpha * atan (beta * b);
- Real height = indent + h;
-
- Array<Offset> control;
- control.push (Offset (0, 0));
- control.push (Offset (indent, height));
- control.push (Offset (b - indent, height));
- control.push (Offset (b, 0));
- Bezier::set (control);
+ for (int i=0; i < CONTROL_COUNT; i++)
+ assert (!isnan (control_[i].length ())
+ && !isinf (control_[i].length ()));
}
-
-
#include "paper-def.hh"
#include "molecule.hh"
#include "lookup.hh"
-#include "bezier.hh"
+#include "bezier-bow.hh"
#include "main.hh"
Bow::Bow ()
return iv;
}
-Drul_array<Interval>
-Bow::curve_extent_drul () const
+Interval
+Bow::curve_extent (Axis a) const
{
Bezier_bow b (paper_l ());
b.set (get_encompass_offset_arr (), get_direction ());
b.calc ();
- return b.curve_extent_drul_;
+ return b.curve_.extent (a);
}
Array<Offset>
b.set (get_encompass_offset_arr (), get_direction ());
b.calc ();
Array<Offset> controls;
- controls.set_size (8);
for (int i = 0; i < 4; i++)
- controls[i] = b.control_[i];
+ controls.push (b.curve_.control_[i]);
for (int i = 0; i < 4; i++)
- controls[i + 4] = b.return_[i];
+ controls.push (b.return_.control_[i]);
return controls;
}
Array<int>
Break_algorithm::find_break_indices () const
{
- Line_of_cols all (pscore_l_->col_l_arr_);
+ Link_array<Paper_column> all (pscore_l_->col_l_arr_);
Array<int> retval;
for (int i=0; i < all.size (); i++)
}
-Line_of_cols
+Link_array<Paper_column>
Break_algorithm::find_breaks () const
{
- Line_of_cols all (pscore_l_->col_l_arr_);
- Line_of_cols retval;
+ Link_array<Paper_column> all (pscore_l_->col_l_arr_);
+ Link_array<Paper_column> retval;
for (int i=0; i < all.size (); i++)
if (all[i]->breakable_b ())
Simple_spacer*
-Break_algorithm::generate_spacing_problem (Line_of_cols curline, Interval line) const
+Break_algorithm::generate_spacing_problem (Link_array<Paper_column> curline, Interval line) const
{
Simple_spacer * sp = new Simple_spacer;
Paper_def * d = pscore_l_->paper_l_;
SCM extra_space
= scm_eval (scm_listify (ly_symbol2scm ("break-align-spacer"),
current_origin, next_origin, SCM_UNDEFINED));
- SCM symbol = SCM_CAR (extra_space);
+ SCM symbol = gh_car (extra_space);
Real spc = gh_scm2double (SCM_CADR(extra_space));
spc *= interline;
// skip the first sym.
- symbol_list = SCM_CDR (scm_reverse (symbol_list));
+ symbol_list = gh_cdr (scm_reverse (symbol_list));
for (int i=0; i <elems.size()-1; i++)
{
- String sym_str = ly_scm2string (SCM_CAR (symbol_list));
+ String sym_str = ly_scm2string (gh_car (symbol_list));
elems[i]->set_elt_property (sym_str,
scm_cons (gh_double2scm (0),
gh_double2scm (dists[i+1])));
- symbol_list = SCM_CDR (symbol_list);
+ symbol_list = gh_cdr (symbol_list);
}
Real stretch_distance =0.;
- if (SCM_CAR (symbol_list) == ly_symbol2scm ("extra-space"))
+ if (gh_car (symbol_list) == ly_symbol2scm ("extra-space"))
{
spring_len += dists.top ();
stretch_distance = dists.top ();
}
- else if (SCM_CAR (symbol_list) == ly_symbol2scm ("minimum-space"))
+ else if (gh_car (symbol_list) == ly_symbol2scm ("minimum-space"))
{
spring_len = spring_len >? dists.top ();
stretch_distance = spring_len;
{
delete inversion_p_;
delete bass_p_;
- // AAARGH, why doesn't Score_elt do this?
- unsmobify_self ();
}
Array<Musical_pitch>
chord = gh_cons (pitch2scm (chord_type[i]), chord);
SCM name = scm_eval (gh_list (ly_symbol2scm ("user-chord-name"), ly_quote_scm (chord), SCM_UNDEFINED));
- if (name != SCM_UNSPECIFIED)
+ if (gh_pair_p (name))
{
name_p->modifier_mol = ly_text2molecule (gh_car (name));
name_p->addition_mol = ly_text2molecule (gh_cdr (name));
force_f_ = 0;
}
-Column_x_positions::~Column_x_positions()
-{
-}
-
-
-void
-Column_x_positions::print() const
-{
-#ifndef NPRINT
- DEBUG_OUT << "energy : " << energy_f_ << '\n';
- DEBUG_OUT << "line of " << config_.size() << " cols\n";
-#endif
-}
#include "paper-def.hh"
#include "debug.hh"
#include "score-column.hh"
+#include "atom.hh"
Crescendo::Crescendo ()
{
dyn_b_drul_[LEFT] = dyn_b_drul_[RIGHT] =false;
}
-Molecule
-Crescendo::get_symbol () const
+
+
+Molecule*
+Crescendo::do_brew_molecule_p () const
{
- Real w_dim = spanner_length()- get_broken_left_end_align ();
Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
+ Real extra_left = get_broken_left_end_align ();
+
+ if (dyn_b_drul_[LEFT])
+ extra_left += absdyn_dim;
+
+
+
+ Real width = spanner_length()- get_broken_left_end_align ();
+
if (dyn_b_drul_[LEFT])
{
- w_dim -= absdyn_dim;
+ width -= absdyn_dim;
}
if (dyn_b_drul_[RIGHT])
{
- w_dim -= absdyn_dim;
+ width -= absdyn_dim;
}
- if (w_dim < 0)
+ if (width < 0)
{
warning (_ ("crescendo") + " " + _ ("too small"));
- w_dim = 0;
+ width = 0;
}
Drul_array<bool> broken;
Real height = paper_l()->get_var ("crescendo_height");
Real thick = paper_l ()->get_var ("crescendo_thickness");
- return Molecule (lookup_l ()->hairpin (w_dim, height, thick, grow_dir_ < 0, continued));
-}
-
-Molecule*
-Crescendo::do_brew_molecule_p () const
-{
- Molecule* m_p =0;
- Real absdyn_dim = paper_l ()-> get_var ("crescendo_shorten");
- Real x_off_dim = get_broken_left_end_align ();
-
- if (dyn_b_drul_[LEFT])
- x_off_dim += absdyn_dim;
-
- m_p = new Molecule;
- Molecule s (get_symbol ());
- m_p->add_molecule (s);
- m_p->translate_axis (x_off_dim, X_AXIS);
- return m_p;
+ const char* hairpin = (grow_dir_ < 0)? "decrescendo" : "crescendo";
+ Atom at (gh_list (ly_symbol2scm (hairpin),
+ gh_double2scm (thick),
+ gh_double2scm (width),
+ gh_double2scm (height),
+ gh_double2scm (continued ? height/2 : 0.0),
+ SCM_UNDEFINED));
+ Molecule * m
+ = new Molecule;
+
+ m->dim_.x () = Interval (0, width);
+ m->dim_.y () = Interval (-2*height, 2*height);
+ m->add_atom (&at);
+
+ m->translate_axis (extra_left, X_AXIS);
+ return m;
}
(c) 1996,98 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+
#include <fstream.h>
#include <signal.h>
bool check_malloc_b = false;
-// #define MEMORY_PARANOID
-
-#ifdef MEMORY_PARANOID
-
-#include <malloc.h>
-
-void
-frobnify (void *p, size_t s)
-{
- char *cp = (char*)p;
- char *e = cp + s;
- while (cp < e)
- {
- *cp++ ^=42;
- }
-}
-
-
-void *
-operator new (size_t size)
-{
- void *result;
- result = malloc (size);
- if (check_malloc_b)
- frobnify (result, size);
- return result;
-}
-
-void *to_frob; int frob_size;
-
-void
-set_frobnify (void * p, size_t sz)
-{
- to_frob = p;
- frob_size = sz;
-}
-
-void
-operator delete (void *p)
-{
- if (!p)
- return ;
- if (p == to_frob)
- {
- frobnify (p, frob_size);
- to_frob = 0;
- frob_size=0;
- }
-
- free (p);
-}
-#endif // MEMORY_PARANOID
-
void
set_debug (bool b)
{
Dimension_cache::init()
{
callback_l_ =0;
-
basic_offset_ =0.0;
extra_offset_ =0.0;
}
-void
-Dimension_cache::invalidate ()
-{
- /* off_valid_b_ =false;
- valid_b_ = false;*/
-}
-
-
-void
-Dimension_cache::set_offset (Real x)
-{
- // ugh!
- /*
-
- UGH ! UGH !
-
- */
-
- extra_offset_ = x;
-}
-
void
Dimension_cache::translate (Real x)
{
}
else if (!valid_b_)
{
-
nc->dim_= (*callback_l_ ) (nc);
nc->valid_b_ = true;
}
set_direction (UP);
Staff_symbol_referencer_interface si (this);
- int p = si.position_f ();
+ int p = int (si.position_f ());
if (!(p % 2))
si.set_position (p + get_direction ());
}
void
Engraver_group_engraver::do_announces()
{
- Link_array<Translator_group> groups = group_l_arr ();
- for (int i=0; i < groups.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- Engraver_group_engraver * group = dynamic_cast<Engraver_group_engraver*> (groups[i]);
- if (group)
- {
- group->do_announces();
- }
+ if (Engraver_group_engraver *trg = dynamic_cast <Engraver_group_engraver *> (p->car_))
+ trg->do_announces ();
}
-
+
Request dummy_req;
- Link_array<Translator> nongroups = nongroup_l_arr ();
while (announce_info_arr_.size ())
{
for (int j =0; j < announce_info_arr_.size(); j++)
if (!info.req_l_)
info.req_l_ = &dummy_req;
- for (int i=0; i < nongroups.size(); i++)
- { // Is this good enough?
- Engraver * eng = dynamic_cast<Engraver*> (nongroups[i]);
- if (eng && eng!= info.origin_trans_l_arr_[0])
- eng->acknowledge_element (info);
+
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
+ {
+ if (!dynamic_cast <Engraver_group_engraver *> (p->car_))
+ {
+ Engraver * eng = dynamic_cast<Engraver*> (p->car_);
+ if (eng && eng!= info.origin_trans_l_arr_[0])
+ eng->acknowledge_element (info);
+ }
}
}
+
announce_info_arr_.clear ();
- for (int i=0; i < nongroups.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- Engraver * eng = dynamic_cast<Engraver*> (nongroups[i]);
- if (eng)
- eng->process_acknowledged ();
+ if (!dynamic_cast <Engraver_group_engraver *> (p->car_))
+ {
+ Engraver * eng = dynamic_cast<Engraver*> (p->car_);
+ if (eng)
+ eng->process_acknowledged ();
+ }
}
-
}
}
{
Staff_info inf = Engraver::get_staff_info();
- Link_array<Translator> simple_translators = nongroup_l_arr ();
- for (int i=0; i < simple_translators.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- Engraver * eng = dynamic_cast<Engraver*> (simple_translators[i]);
- if (eng)
- eng->fill_staff_info (inf);
+ if (!dynamic_cast <Engraver_group_engraver *> (p->car_))
+ {
+ Engraver * eng = dynamic_cast<Engraver*> (p->car_);
+ if (eng)
+ eng->fill_staff_info (inf);
+ }
}
return inf;
}
}
Font_metric::~Font_metric ()
+{
+ unsmobify_self ();
+}
+
+Font_metric::Font_metric ()
+{
+ self_scm_ = SCM_EOL;
+ smobify_self ();
+}
+
+Font_metric::Font_metric (Font_metric const &)
{
}
gh_set_cdr_x (od, gh_int2scm (magstep_i_));
return od;
}
+
+
+void
+Font_metric::do_smobify_self ()
+{
+}
+
+SCM
+Font_metric::mark_smob (SCM s)
+{
+ return SCM_EOL;
+}
+
+int
+Font_metric::print_smob (SCM s, SCM port, scm_print_state * )
+{
+ scm_puts ("#<Font_metric>", port);
+
+ return 1;
+}
+
+
+
+
Gourlay_breaking::do_solve () const
{
Array<Break_node> optimal_paths;
- Line_of_cols all = pscore_l_->col_l_arr_ ;
+ Link_array<Paper_column> all = pscore_l_->col_l_arr_ ;
Array<int> breaks = find_break_indices ();
optimal_paths.set_size (breaks.size ());
for (int start_idx = break_idx; start_idx--;)
{
- Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1);
+ Link_array<Paper_column> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
line[0] = dynamic_cast<Paper_column*>(line[0]->find_broken_piece (RIGHT));
line.top () = dynamic_cast<Paper_column*>(line.top ()->find_broken_piece (LEFT));
bool
Grace_performer_group::do_try_music (Music *m)
{
- bool hebbes_b =false;
-
- Link_array<Translator> nongroups (nongroup_l_arr ());
-
- for (int i =0; !hebbes_b && i < nongroups.size() ; i++)
- hebbes_b =nongroups[i]->try_music (m);
-
- return hebbes_b;
+ return try_music_on_nongroup_children (m);
}
Character_metric const *get_char (int, bool) const;
};
-Adobe_font_metric read_afm_file (String fn);
+Adobe_font_metric *read_afm_file (String fn);
#include "file-path.hh"
#include "lily-proto.hh"
#include "font-metric.hh"
-#include "lily-guile.hh"
+#include "scm-hash.hh"
/**
Interface to all .afm files living in the filesystem.
*/
class All_font_metrics
{
- Dictionary<Adobe_font_metric*> afm_p_dict_;
- Dictionary<Tex_font_metric*> tfm_p_dict_;
- Dictionary<Scaled_font_metric*> scaled_p_dict_;
+ Scheme_hash_table afm_p_dict_;
+ Scheme_hash_table tfm_p_dict_;
+ Scheme_hash_table scaled_p_dict_;
+
File_path search_path_;
public:
SCM font_descriptions () const;
};
-
+Font_metric * unsmob_metrics (SCM s);
#endif /* ALL_FONTS_HH */
Stem* first_visible_stem () const;
Stem* last_visible_stem () const;
- /**
- the slope of the beam in dy/dx
- */
- Real dydx_f_;
-
- /// position of leftmost end of beam
- Real left_y_;
-
Beam ();
void add_stem (Stem*);
void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
private:
- Direction calc_default_dir () const;
+ Direction get_default_dir () const;
void set_stem_directions ();
void auto_knees ();
bool auto_knee (String gap_str, bool interstaff_b);
Real quantise_dy_f (Real dy) const;
Real quantise_y_f (Real y, Real dy, int quant_dir);
int forced_stem_count () const;
-
};
#endif // BEAM_HH
--- /dev/null
+/*
+ bezier-bow.hh -- declare Bezier_bow
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef BEZIER_BOW_HH
+#define BEZIER_BOW_HH
+
+#include "bezier.hh"
+#include "lily-proto.hh"
+
+
+/**
+ Implement bow specific bezier curve
+ */
+class Bezier_bow
+{
+public:
+ Bezier_bow (Paper_def* paper_l);
+
+ /**
+ Calculate bezier curve for bow from bow paratime_signatures.
+ */
+ void blow_fit ();
+ void calc ();
+ Real calc_f (Real height);
+ void calc_bezier ();
+ bool calc_clipping ();
+ void calc_controls ();
+ void check_sanity () const;
+ void calc_default (Real h);
+ void calc_return (Real begin_alpha, Real end_alpha);
+ void calc_tangent_controls ();
+ bool check_fit_b () const;
+ Real check_fit_f () const;
+ void set (Array<Offset> points, Direction dir);
+ void transform ();
+ void transform_back ();
+
+ Array<Offset> encompass_;
+
+ Paper_def* paper_l_;
+ Direction dir_;
+ Real alpha_;
+ Offset origin_;
+
+
+ Bezier curve_;
+ Bezier return_;
+};
+
+
+#endif /* BEZIER_BOW_HH */
+
#ifndef BEZIER_HH
#define BEZIER_HH
-#ifndef STANDALONE
-#include "lily-proto.hh"
-#endif
#include "real.hh"
-#include "curve.hh"
#include "drul-array.hh"
#include "interval.hh"
+#include "axes.hh"
+#include "offset.hh"
+#include "array.hh"
+#include "polynomial.hh"
/**
Simple bezier curve
public:
Bezier ();
- /**
- Calculate bezier curve into Offset (x,y) array.
- */
- void calc (int steps);
- void print () const;
-
- void set (Array<Offset> points);
-
- /**
- Return y that goes with x by interpolation.
- */
- Real y (Real x);
-
- Curve curve_;
- Curve control_;
-};
-
-/**
- Implement bow specific bezier curve
- */
-class Bezier_bow : public Bezier
-{
-public:
- Bezier_bow (Paper_def* paper_l);
-
- /**
- Calculate bezier curve for bow from bow paratime_signatures.
- */
- void blow_fit ();
- void calc ();
- Real calc_f (Real height);
- void calc_bezier ();
- bool calc_clipping ();
- void calc_controls ();
- void calc_default (Real h);
- void calc_return (Real begin_alpha, Real end_alpha);
- void calc_tangent_controls ();
- bool check_fit_bo ();
- Real check_fit_f ();
- void print () const;
- void set (Array<Offset> points, Direction dir);
- void transform ();
- void transform_back ();
-
- Paper_def* paper_l_;
- Curve encompass_;
- Direction dir_;
- void set_direction (Direction d ) { dir_ = d; }
- Direction get_direction () const { return dir_; }
-
- Real alpha_;
- Offset origin_;
- Curve return_;
- Drul_array<Interval> curve_extent_drul_;
+ void rotate (Real);
+ void translate (Offset);
+ void flip (Axis);
+ void check_sanity () const;
+ Real get_other_coordinate (Axis a, Real x) const;
+ Array<Real> solve_point (Axis, Real coordinate) const;
+ Array<Real> solve_derivative (Offset) const;
+ Interval extent (Axis)const;
+ Polynomial polynomial (Axis)const;
+ Offset curve_point (Real t) const;
+
+ static const int CONTROL_COUNT = 4;
+ Offset control_[CONTROL_COUNT];
};
#define BOW_HH
#include "directional-spanner.hh"
-#include "curve.hh"
/**
Base class for anything that looks like a slur.
Array<Offset> get_controls () const;
virtual Array<Offset> get_encompass_offset_arr () const;
static Interval dim_callback (Dimension_cache const*);
- Drul_array<Interval> curve_extent_drul () const;
+ Interval curve_extent (Axis) const;
Drul_array<Real> dy_f_drul_;
Drul_array<Real> dx_f_drul_;
Real linewidth_f_;
/// search all pcols which are breakable.
- Line_of_cols find_breaks() const;
+ Link_array<Paper_column> find_breaks() const;
Array<int> find_break_indices() const;
void approximate_solve_line (Column_x_positions*) const;
/// does curline fit on the paper?
- bool feasible (Line_of_cols) const;
+ bool feasible (Link_array<Paper_column>) const;
- Simple_spacer* generate_spacing_problem (Line_of_cols, Interval) const;
+ Simple_spacer* generate_spacing_problem (Link_array<Paper_column>, Interval) const;
virtual Array<Column_x_positions> do_solve() const=0;
virtual void do_set_pscore();
#include "parray.hh"
#include "lily-proto.hh"
-typedef Link_array<Paper_column> Line_of_cols;
-struct Column_x_positions {
-
- Line_of_cols cols_;
+struct Column_x_positions
+{
+ Link_array<Paper_column> cols_;
Array<Real> config_;
Real force_f_;
Real energy_f_;
bool satisfies_constraints_b_;
- ~Column_x_positions();
Column_x_positions();
- void print() const;
};
+++ /dev/null
-/*
- curve.hh -- declare point and curve
-
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-#ifndef CURVE_HH
-#define CURVE_HH
-
-#ifndef STANDALONE
-#include "lily-proto.hh"
-#endif
-
-#include "real.hh"
-
-#include "offset.hh"
-#include "array.hh"
-
-class Curve : public Array<Offset>
-{
-public:
- void flipy ();
- int largest_disturbing ();
- void rotate (Real phi);
- void translate (Offset o);
-
- void operator = (Array<Offset> const & src)
- {
- Array<Offset>::operator =(src);
- }
- void operator = (Curve const & src)
- {
- Array<Offset>::operator =((Array<Offset>)src);
- }
-};
-
-#endif // CURVE_HH
-
Score_element *element_l () const { return elt_l_; }
- void invalidate ();
- void invalidate_dependencies ();
-
Dimension_cache(Dimension_cache const&);
Dimension_cache ();
void set_empty (bool);
void translate (Real);
- // junkme.
- void set_offset (Real);
-
bool valid_b () const { return valid_b_; }
bool empty_b() const;
Interval get_dim () const;
#include "box.hh"
#include "lily-guile.hh"
+#include "smobs.hh"
struct Character_metric
{
struct Font_metric
{
+ Font_metric ();
String name_str_;
virtual SCM description () const;
virtual Character_metric const *get_char (int ascii, bool warn) const;
virtual ~Font_metric ();
virtual Box text_dimension (String) const;
+
+ DECLARE_SMOBS;
+private:
+ Font_metric (Font_metric const&); // no copy.
};
#include "pqueue.hh"
-class Iteration_interface_translator : public virtual Translator_group {
-};
-
class Global_translator : public virtual Translator_group{
PQueue<Moment> extra_mom_pq_;
public:
Item (Item const &);
protected:
virtual void do_breakable_col_processing();
- virtual void handle_prebroken_dependencies();
- //virtual void handle_prebroken_dependents ();
void copy_breakable_items();
};
/* 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;
};
struct Notename_table;
struct Offset;
struct Paper_column;
+struct Polynomial;
struct Paper_def;
struct Paper_outputter;
struct Paper_score;
Molecule ledger_line (Interval) const;
Molecule fill (Box b) const;
Molecule filledbox (Box b) const;
- Molecule hairpin (Real width, Real height, Real thick, bool decresc, bool continued) const;
Molecule tuplet_bracket (Real dy, Real dx, Real gap, Real thick,Real height, Direction dir) const;
Molecule accordion (SCM arg, Real interline_f) const;
Molecule slur (Array<Offset> controls, Real thick) const;
double log_2(double x) ;
int intlog2(int d);
-#if 0
- // defined in real.hh
inline int
-abs (int i){
- return (i < 0)?-i:i;
+sign (int i)
+{
+ if (i<0)
+ return -1;
+ else if (i)
+ return 1;
+ else return 0;
}
-#endif
-
-inline int
-sign (int i) {
- if (i<0) return -1;
- else if (i) return 1;
- else return 0;
-}
-
-#ifndef STANDALONE
-#include "lily-proto.hh"
-Interval itemlist_width (const Link_array<Item> &its);
-#endif
-void set_frobnify (void*, size_t);
-int get_lower_bound (Array<Real> const& positions, Real x);
-Slice get_bounds_slice (Array<Real> const& positions, Real x);
-Interval get_bounds_iv (Array<Real> const& positions, Real x);
-Interval quantise_iv (Array<Real> const& positions, Real period, Real x);
+Interval quantise_iv (Array<Real> positions, Real x);
#endif
/**
be next to noteheads.
-
- UGH. another reduplication of Staff_side
*/
class Note_head_side: public virtual Item, public virtual Directional_element
{
#ifndef NOTENAME_TABLE_HH
#define NOTENAME_TABLE_HH
-#include "pointer.hh"
#include "string.hh"
#include "lily-proto.hh"
-#include "dictionary.hh"
-#include "musical-pitch.hh"
-class Notename_table : public Dictionary<Musical_pitch>{
+class Notename_table {
+ Dictionary<Musical_pitch> *pitch_dict_;
public:
+ Notename_table ();
+ ~Notename_table ();
+ Notename_table (Notename_table const&);
+ Musical_pitch get_pitch(String s) const;
+ void add_note_name (String, Musical_pitch const *p);
String get_name (Musical_pitch) const;
+ bool elem_b (String )const;
};
#endif // NOTENAME_TABLE_HH
#ifndef SCOPE_HH
#define SCOPE_HH
-#include "dictionary.hh"
#include "lily-proto.hh"
#include "lily-guile.hh"
-#include "dictionary-iter.hh"
-#include "protected-scm.hh"
-class Scope : private Hash_table<Protected_scm,Identifier*> {
+class Protected_scm;
+class Scope {
+ Hash_table<Protected_scm,Identifier*> *id_dict_;
public:
void print () const;
bool elem_b (String ) const;
friend class Scope_iter;
};
-class Scope_iter : public Hash_table_iter<Protected_scm,Identifier*> {
+class Scope_iter {
+ Hash_table_iter<Protected_scm,Identifier*> * iter_;
public:
+ void operator ++(int);
+ bool ok ()const;
Scope_iter(Scope const&);
String key () const;
+ Identifier* val () const;
SCM scm_key () const;
};
*/
class Score_element {
+ /**
+ The lookup, determined by the font size. Cache this value.
+ */
+ Lookup * lookup_l_;
+public:
/**
properties specific for this element. Destructor will not call
scm_unprotect, so as to allow more flexible GC arrangements. The
*/
SCM element_property_alist_;
- /**
- The lookup, determined by the font size. Cache this value.
- */
- Lookup * lookup_l_;
-public:
+
Score_element *original_l_;
/**
*/
void set_empty (Axis a);
bool empty_b (Axis a) const;
- void invalidate_cache (Axis);
Interval extent (Axis) const;
/**
protected:
void set_my_columns ();
VIRTUAL_COPY_CONS(Score_element);
-
- /**
- this is virtual; for instance, Line_of_score overrides it.
- */
- virtual void break_into_pieces ();
Real get_broken_left_end_align () const;
- friend Axis_group_spanner; // UGH
-
virtual void do_space_processing ();
virtual void do_break_processing ();
Real spanner_length () const;
int iterator_count_;
friend class Interpretation_context_handle;
+protected:
Cons_list<Translator> trans_p_list_;
public:
Translator_group();
void add_translator (Translator *trans_p);
- Link_array<Translator> nongroup_l_arr () const;
- Link_array<Translator_group> group_l_arr () const;
-
- virtual Global_translator *global_l() { return 0; }
-
/// Score_register = 0, Staff_registers = 1, etc)
Translator_group* ancestor_l (int l=1);
int depth_i() const;
Translator *remove_translator_p (Translator*trans_l);
void check_removal ();
-
-
Translator *get_simple_translator (String) const;
Translator_group *find_existing_translator_l (String n, String id);
Translator_group *find_create_translator_l (String n, String id);
}
}
-void
-Item::handle_prebroken_dependencies()
-{
- if (original_l_)
- Score_element::handle_prebroken_dependencies();
-}
+
bool
Item::broken_original_b () const
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 ());
+ dx += abs (input[i-1][X_AXIS] - input[i][X_AXIS]);
assert (dx);
}
for (int i=0; i < input.size();i++)
{
- Real x=input[i].x();
- Real y = input[i].y();
- sx += x;
- sy += y;
- sqx += sqr (x);
- sxy += x*y;
+ Real x=input[i][X_AXIS];
+ Real y = input[i][Y_AXIS];
+ sx += x;
+ sy += y;
+ sqx += sqr (x);
+ sxy += x*y;
}
int N = input.size();
index_cell (SCM s, Direction d)
{
assert (d);
- return (d == LEFT) ? SCM_CAR (s) : SCM_CDR (s);
+ return (d == LEFT) ? gh_car (s) : gh_cdr (s);
}
SCM
* note_distance;
Molecule m (accidental (p.accidental_i_,
- accidental_arr_[i].cautionary_b_,
- accidental_arr_[i].natural_b_));
+ accidental_arr_[i].cautionary_b_,
+ accidental_arr_[i].natural_b_));
m.translate_axis (dy, Y_AXIS);
octave_mol_p->add_at_edge (X_AXIS, RIGHT, m, 0);
return m;
}
-Molecule
-Lookup::hairpin (Real width, Real height, Real thick, bool decresc, bool continued) const
-{
- Molecule m;
-
- const char* hairpin = decresc ? "decrescendo" : "crescendo";
- Atom at (gh_list (ly_symbol2scm (hairpin),
- gh_double2scm (thick),
- gh_double2scm (width),
- gh_double2scm (height),
- gh_double2scm (continued ? height/2 : 0.0),
- SCM_UNDEFINED));
- m.dim_.x () = Interval (0, width);
- m.dim_.y () = Interval (-2*height, 2*height);
- m.add_atom (&at);
- return m;
-}
Molecule
Lookup::tuplet_bracket (Real dy , Real dx, Real thick, Real gap,
Lookup::accordion (SCM s, Real interline_f) const
{
Molecule m;
- String sym = ly_scm2string(SCM_CAR(s));
- String reg = ly_scm2string(SCM_CAR(SCM_CDR(s)));
+ String sym = ly_scm2string(gh_car (s));
+ String reg = ly_scm2string(gh_car (gh_cdr(s)));
if (sym == "Discant")
{
#include <iostream.h>
#include <assert.h>
#include <locale.h>
+
#include "lily-guile.hh"
#include "lily-version.hh"
"USA.\n");
}
-
void
setup_paths ()
{
char *suffixes[] = {"ly", "afm", "scm", "tfm", "cmtfm", "ps", 0};
- for (char **s = suffixes; *s; s++){
- if (!prefix_directory.empty_b())
- global_path.add (prefix_directory + to_str ('/') + String (*s));
- else
- global_path.add (String (DIR_DATADIR) + to_str ('/') + String(*s));
- }
+ for (char **s = suffixes; *s; s++)
+ {
+ if (!prefix_directory.empty_b())
+ global_path.add (prefix_directory + to_str ('/') + String (*s));
+ else
+ global_path.add (String (DIR_DATADIR) + to_str ('/') + String(*s));
+ }
}
need to do this first. Engravers use lily.scm contents.
*/
init_lily_guile ();
- read_lily_scm_file ( "lily.scm");
+ read_lily_scm_file ("lily.scm");
cout << endl;
call_constructors ();
*/
#include <math.h>
-
#include "misc.hh"
-#ifndef STANDALONE
-#include "item.hh"
-#endif
-
int
-intlog2(int d) {
+intlog2(int d)
+{
int i=0;
while (!(d&1))
{
}
double
-log_2(double x) {
- return log (x) /log (2.0);
-}
-
-
-/*
- TODO
- group in some Array_*
- make more generic / templatise
- */
-int
-get_lower_bound (Array<Real> const& positions, Real x)
+log_2(double x)
{
- if (x < positions[0])
- return 0;
- for (int i = 1; i < positions.size (); i++)
- if (x < positions[i])
- return i - 1;
- return positions.size () - 1;
+ return log (x) /log (2.0);
}
-Slice
-get_bounds_slice (Array<Real> const& positions, Real x)
-{
- int l = get_lower_bound (positions, x);
- int u = positions.size () - 1 <? l + 1;
- if (x < positions[l])
- u = l;
- return Slice (l, u);
-}
-Interval
-get_bounds_iv (Array<Real> const& positions, Real x)
+static int
+comp (Real const &a, Real const &b)
{
- Slice slice = get_bounds_slice (positions, x);
- return Interval (positions[slice[SMALLER]], positions[slice[BIGGER]]);
+ return sign (a-b);
}
-// silly name
Interval
-quantise_iv (Array<Real> const& positions, Real period, Real x)
+quantise_iv (Array<Real> positions, Real x)
{
- /*
- ugh
- assume that
- * positions are sorted,
- * positions are nonnegative
- * period starts at zero
- */
+ positions.sort (comp);
+ Real period = positions.top () - positions[0];
+
+ int n = int ((x - positions[0]) / period);
+ Real frac = (x - positions[0] ) - n * period;
- int n = (int)(x / period);
- Real frac = (x / period - n) * period;
- if (frac < 0)
+ while (frac < 0)
{
frac += period;
- n--;
+ n --;
}
-
- Slice slice = get_bounds_slice (positions, frac);
- Interval iv(positions[slice[SMALLER]], positions[slice[BIGGER]]);
-
- if (slice[SMALLER] == slice[BIGGER])
+
+ Real px = frac + positions[0];
+ assert ( positions[0] <= px && px <= positions.top ());
+ int i=0;
+ for (; i < positions.size () - 1; i++)
{
- if (slice[SMALLER] == 0)
- iv[SMALLER] = - period + positions.top ();
- else
- iv[BIGGER] = period + positions[0];
+ if (positions[i] <= px && px <= positions[i+1])
+ break;
}
- iv += period * n;
-
- return iv;
+ return Interval (positions[i] , positions[i+1]) + period * n;
}
#ifdef ATOM_SMOB
#define MOL_EOL SCM_EOL
-#define NEXT_CELL(a) SCM_CDR(a)
+#define NEXT_CELL(a) gh_cdr(a)
#define CELLTYPE SCM
#define UNBOX_ATOM(a) Atom::atom_l (a)
#define BOX_ATOM(a) a->make_smob ()
#define NEWCELL(a,b) gh_cons (a,b)
-#define UNBOX_PTR(a) SCM_CAR(a)
+#define UNBOX_PTR(a) gh_car (a)
#else
#define MOL_EOL 0
#define NEXT_CELL(a) ptr->next_
int
Moment::print_smob (SCM s, SCM port, scm_print_state *)
{
- Moment *r = (Moment *) SCM_CDR (s);
+ Moment *r = (Moment *) gh_cdr (s);
scm_puts ("#<Mom ", port);
String str(r->str());
Musical_pitch
My_lily_lexer::lookup_notename (String s)
{
- return (*note_tab_p_)[s];
+ return note_tab_p_->get_pitch (s);
}
Musical_pitch
My_lily_lexer::lookup_chordmodifier (String s)
{
- return (*chordmodifier_tab_p_)[s];
+ return chordmodifier_tab_p_->get_pitch (s);
}
bool
void
Note_column::translate_rests (int dy_i)
{
- // invalidate_cache (Y_AXIS);
-
SCM s = get_elt_property ("rests");
for (; gh_pair_p (s); s = gh_cdr (s))
{
{
Stem * st = stem_l ();
return st? st->first_head (): 0;
-
}
if (Dots *d = dots_l ())
{ // move into Rhythmic_head?
-
Staff_symbol_referencer_interface si (d);
Staff_symbol_referencer_interface me (this);
*/
#include "notename-table.hh"
-#include "pointer.tcc"
-#include "musical-request.hh"
#include "dictionary-iter.hh"
+#include "dictionary.hh"
+#include "musical-pitch.hh"
String
Notename_table::get_name (Musical_pitch m) const
{
-
- for (Dictionary_iter<Musical_pitch> ai (*this); ai.ok (); ai++)
+ for (Dictionary_iter<Musical_pitch> ai (*pitch_dict_); ai.ok (); ai++)
{
if (ai.val () == m)
return ai.key ();
return "r"; // rest.
}
+
+void
+Notename_table::add_note_name (String s,
+ Musical_pitch const *p)
+{
+ pitch_dict_->elem (s) = *p;
+}
+
+Notename_table::Notename_table ()
+{
+ pitch_dict_ = new Dictionary<Musical_pitch>;
+}
+
+Notename_table::~Notename_table()
+{
+ delete pitch_dict_;
+}
+
+Notename_table::Notename_table (Notename_table const &s)
+{
+ pitch_dict_ = new Dictionary<Musical_pitch> (*s.pitch_dict_);
+}
+bool
+Notename_table::elem_b (String s)const
+{
+ return pitch_dict_->elem_b (s);
+}
+Musical_pitch
+Notename_table::get_pitch (String s)const
+{
+ return (*pitch_dict_)[s];
+}
SCM box_scm
= gh_list (ly_symbol2scm ("placebox"),
- gh_double2scm (a_off.x ()),
- gh_double2scm (a_off.y ()),
+ gh_double2scm (a_off[X_AXIS]),
+ gh_double2scm (a_off[Y_AXIS]),
SCM(i->func_),
SCM_UNDEFINED);
{
elem_p->pscore_l_ = this;
- SCM_CDR(element_smob_list_) = gh_cons (elem_p->self_scm_,
- SCM_CDR (element_smob_list_));
+ gh_set_cdr_x(element_smob_list_,
+ gh_cons (elem_p->self_scm_, gh_cdr (element_smob_list_)));
elem_p->set_elt_property ("full-name",
gh_str02scm((char*)elem_p->name()));
DEBUG_OUT << "Paper_score { ";
DEBUG_OUT << "\n elements: ";
- for (SCM p = SCM_CDR (element_smob_list_);
+ for (SCM p = gh_cdr (element_smob_list_);
p != SCM_EOL;
- p = SCM_CDR(p))
- gh_display (SCM_CAR(p));
+ p = gh_cdr(p))
+ gh_display (gh_car (p));
DEBUG_OUT << "}\n";
#endif
}
#include "midi-def.hh"
#include "main.hh"
#include "file-path.hh"
-#include "keyword.hh"
#include "debug.hh"
#include "dimensions.hh"
#include "identifier.hh"
%token ALTERNATIVE
%token BAR
%token BREATHE
-%token CADENZA
%token CHORDMODIFIERS
%token CHORDS
%token HYPHEN
$$ = $1-> access_content_Notename_table(true);
}
| notenames_body STRING '=' explicit_musical_pitch {
- (*$$)[ly_scm2string ($2)] = *$4;
-
+ $$->add_note_name (ly_scm2string ($2), $4);
delete $4;
}
;
void
Performer_group_performer::do_announces()
{
- Link_array<Translator_group> groups = group_l_arr ();
- for (int i=0; i < groups.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- Performer_group_performer * group = dynamic_cast<Performer_group_performer*> (groups[i]);
- if (group)
- {
- group->do_announces();
- }
+ if (Performer_group_performer *trg = dynamic_cast <Performer_group_performer *> (p->car_))
+ trg->do_announces ();
}
+
Request dummy_req;
- Link_array<Translator> nongroups = nongroup_l_arr ();
while (announce_info_arr_.size ())
{
for (int j =0; j < announce_info_arr_.size(); j++)
if (!info.req_l_)
info.req_l_ = &dummy_req;
- for (int i=0; i < nongroups.size(); i++)
- { // Is this good enough?
- Performer * eng = dynamic_cast<Performer*> (nongroups[i]);
- // urg, huh? core dump?
- //if (eng && eng!= info.origin_trans_l_arr_[0])
- if (eng && info.origin_trans_l_arr_.size ()
- && eng!= info.origin_trans_l_arr_[0])
- eng->acknowledge_element (info);
+
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
+ {
+ if (!dynamic_cast <Performer_group_performer *> (p->car_))
+ {
+ Performer * eng = dynamic_cast<Performer*> (p->car_);
+ // urg, huh? core dump?
+ //if (eng && eng!= info.origin_trans_l_arr_[0])
+ if (eng && info.origin_trans_l_arr_.size ()
+ && eng!= info.origin_trans_l_arr_[0])
+ eng->acknowledge_element (info);
+ }
+ }
+ announce_info_arr_.clear ();
+
+
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
+ {
+ if (!dynamic_cast <Performer_group_performer *> (p->car_))
+ {
+ Performer * eng = dynamic_cast<Performer*> (p->car_);
+ if (eng)
+ eng->process_acknowledged ();
+ }
}
}
- announce_info_arr_.clear ();
- for (int i=0; i < nongroups.size(); i++)
- {
- Performer * eng = dynamic_cast<Performer*> (nongroups[i]);
- if (eng)
- eng->process_acknowledged ();
- }
-
}
}
void
Property_engraver::apply_properties (SCM p, Score_element *e)
{
- for (; SCM_NIMP (p); p = gh_cdr (p))
+ for (; gh_pair_p (p); p = gh_cdr (p))
{
SCM entry = gh_car (p);
SCM prop_sym = gh_car (entry);
SCM type_p = gh_cadr (entry);
SCM elt_prop_name = gh_caddr (entry);
- /*
- urg scm <-> symbol-string
- */
- if (e->get_elt_property (ly_scm2string (elt_prop_name)) != SCM_UNDEFINED)
+ SCM preset = scm_assq(prop_sym, e->element_property_alist_);
+ if (preset != SCM_BOOL_F)
continue;
-
+
SCM val = get_property (prop_sym, 0);
if (val != SCM_UNDEFINED
&& gh_apply (type_p, scm_listify (val, SCM_UNDEFINED))
}
int
-Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*ps)
+Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*)
{
assert (SMOB_IS_TYPE_B (Scheme_hash_table, s));
Scheme_hash_table *me = SMOB_TO_TYPE(Scheme_hash_table,s);
#include "dictionary-iter.hh"
#include "debug.hh"
#include "identifier.hh"
+#include "dictionary.hh"
+#include "protected-scm.hh"
void
Scope::print () const
{
+#ifndef NPRINT
bool init_b = false; // ugh
for (Scope_iter ai (*this); ai.ok(); ai++)
{
ai.val()->print ();
}
}
+#endif
}
Scope::~Scope ()
DEBUG_OUT << "deleting: " << ai.key() << '\n';
delete ai.val ();
}
+ delete id_dict_;
}
Scope::Scope (Scope const&s)
- : Hash_table<Protected_scm,Identifier*> (s)
{
+ id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
for (Scope_iter ai (s); ai.ok(); ai++)
{
- (*this)[ai.scm_key ()] = ai.val ()->clone ();
+ id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
}
}
Scope::Scope ()
{
- hash_func_ = ly_pscm_hash;
+ id_dict_ = new Hash_table<Protected_scm,Identifier*>;
+ id_dict_->hash_func_ = ly_pscm_hash;
}
bool
Scope::elem_b (String s) const
{
- return elem_b (ly_symbol2scm (s.ch_C()));
+ return id_dict_->elem_b (ly_symbol2scm (s.ch_C()));
}
Identifier *&
Scope::elem (String s)
{
- return elem (ly_symbol2scm (s.ch_C()));
+ return id_dict_->elem (ly_symbol2scm (s.ch_C()));
}
Scope_iter::Scope_iter (Scope const &s)
- : Hash_table_iter<Protected_scm,Identifier*>(s)
{
+ iter_ = new Hash_table_iter<Protected_scm,Identifier*>(*s.id_dict_);
}
String
Scope_iter::key () const
{
- SCM s= Hash_table_iter<Protected_scm,Identifier*>::key ();
+ SCM s= iter_->key ();
return ly_symbol2string (s);
}
bool
Scope::elem_b (SCM s) const
{
- return Hash_table<Protected_scm,Identifier*> ::elem_b (s);
+ return id_dict_->elem_b (s);
}
Identifier* &
Scope::elem (SCM s)
{
- return Hash_table<Protected_scm,Identifier*> ::elem (s);
+ return id_dict_->elem (s);
}
SCM
Scope_iter::scm_key () const
{
- return Hash_table_iter<Protected_scm,Identifier*>::key ();
+ return iter_->key ();
+}
+
+bool
+Scope_iter::ok () const
+{
+ return iter_->ok();
+}
+
+void
+Scope_iter::operator ++(int)
+{
+ (*iter_) ++;
+}
+
+Identifier*
+Scope_iter::val ()const
+{
+ return iter_->val ();
}
SCM s = scm_assq(sym, element_property_alist_);
if (s != SCM_BOOL_F)
- return SCM_CDR (s);
+ return gh_cdr (s);
if (pscore_l_)
{
}
return s;
}
-#if 0
-void
-Score_element::recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)())
-{
- Score_element * sc = unsmob_element ( s);
- if (sc)
- {
- (sc->*meth_ptr) ();
- }
- else if (gh_pair_p (s))
- {
- recurse_into_smobs (gh_car (s), meth_ptr);
- recurse_into_smobs (gh_cdr (s), meth_ptr);
- }
-}
-#endif
void
Score_element::handle_broken_dependencies()
{
Line_of_score *line = line_l();
-
- SCM rec = get_elt_property ("handle-broken-deps");
- if (gh_boolean_p (rec) && gh_scm2bool (rec))
- return;
-
- set_elt_property ("handle-broken-deps", SCM_BOOL_T);
element_property_alist_ = handle_broken_smobs (element_property_alist_,
line ? line->self_scm_ : SCM_UNDEFINED);
-
if (!line)
return;
}
SCM
Score_element::mark_smob (SCM ses)
{
- void * mp = (void*) SCM_CDR(ses);
+ void * mp = (void*) gh_cdr(ses);
Score_element * s = (Score_element*) mp;
assert (s->self_scm_ == ses);
int
Score_element::print_smob (SCM s, SCM port, scm_print_state *)
{
- Score_element *sc = (Score_element *) SCM_CDR (s);
+ Score_element *sc = (Score_element *) gh_cdr (s);
scm_puts ("#<Score_element ", port);
scm_puts ((char *)sc->name (), port);
SCM
Score_element::equal_p (SCM a, SCM b)
{
- return SCM_CDR(a) == SCM_CDR(b) ? SCM_BOOL_T : SCM_BOOL_F;
+ return gh_cdr(a) == gh_cdr(b) ? SCM_BOOL_T : SCM_BOOL_F;
}
void
}
-/*
- JUNKME
- */
-void
-Score_element::invalidate_cache (Axis a)
-{
- // dim_cache_[a]->invalidate ();
-}
-
Score_element*
Score_element::parent_l (Axis a) const
{
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
+#include "debug.hh"
#include "dimension-cache.hh"
-#include "super-element.hh"
#include "line-of-score.hh"
-#include "debug.hh"
#include "item.hh"
#include "score-engraver.hh"
#include "paper-score.hh"
list = gh_cdr (list);
p->set_elt_property ("molecule",
- SCM_CAR(list));
-
- list = SCM_CDR(list);
- bool follow_staff = gh_scm2bool (SCM_CAR(list));
- list = SCM_CDR(list);
- int relative_stem_dir = gh_scm2int (SCM_CAR(list));
- list = SCM_CDR(list);
- int force_dir =gh_scm2int (SCM_CAR(list));
- list = SCM_CDR(list);
- SCM priority = SCM_CAR(list);
+ gh_car (list));
+
+ list = gh_cdr(list);
+ bool follow_staff = gh_scm2bool (gh_car (list));
+ list = gh_cdr(list);
+ int relative_stem_dir = gh_scm2int (gh_car (list));
+ list = gh_cdr(list);
+ int force_dir =gh_scm2int (gh_car (list));
+ list = gh_cdr(list);
+ SCM priority = gh_car (list);
if (relative_stem_dir)
SCM s = get_elt_property ("molecule");
assert (s != SCM_UNDEFINED);
- SCM key = SCM_CAR (s);
+ SCM key = gh_car (s);
if (key == ly_symbol2scm ("feta"))
{
return lookup_l ()->afm_find ("scripts-" +
Direction d = LEFT;
do
{
- dx_f_drul_[d] = dy_f_drul_[d] = 0;
+ dx_f_drul_[d] = 0;
+ dy_f_drul_[d] = 0;
+
if ((note_column_drul[d] == spanned_drul_[d])
&& note_column_drul[d]->first_head ()
&& (note_column_drul[d]->stem_l ()))
*/
for (int i = 0; i < 3; i++)
{
- Drul_array<Interval> curve_xy_drul = curve_extent_drul ();
- Real height_f = curve_xy_drul[Y].length ();
- Real width_f = curve_xy_drul[X].length ();
+ Real height_f = curve_extent (Y_AXIS).length ();
+ Real width_f = curve_extent (X_AXIS).length ();
dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
if (!fix_broken_b)
if (next_stretch_hint != SCM_UNDEFINED)
// see regtest spacing-tight
- stretch_dist += - gh_scm2double (SCM_CAR (next_stretch_hint));
+ stretch_dist += - gh_scm2double (gh_car (next_stretch_hint));
else
stretch_dist += right_dist;
if (scm_ilength (dl) != 1 && scm_ilength (dr) != 1)
return 0.;
- dl = SCM_CAR(dl);
- dr = SCM_CAR(dr);
+ dl = gh_car (dl);
+ dr = gh_car (dr);
assert (gh_number_p (dl) && gh_number_p(dr));
int d1 = gh_scm2int (dl);
#include "break-align-item.hh"
void
-Spanner::break_into_pieces ()
+Spanner::do_break_processing()
{
+ //break_into_pieces
+
if (line_l () || broken_b ())
return;
}
-
-void
-Spanner::do_break_processing()
-{
- break_into_pieces ();
-}
-
Spanner::Spanner ()
{
spanned_drul_[LEFT]=0;
Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS);
if (r< l)
- warning (_ ("spanner with negative length"));
-
+ programming_error ("spanner with negative length");
+
return r-l;
}
Score_element*
Spanner::find_broken_piece (Line_of_score*l) const
{
- Spanner* me = (Spanner*) this;
- me->break_into_pieces ();
-
int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare);
if (idx < 0)
+++ /dev/null
-/*
- timing-translator.cc -- implement Timing_translator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "timing-translator.hh"
-#include "translator-group.hh"
-#include "debug.hh"
void
Translator_group::check_removal()
{
- Link_array<Translator_group> groups (group_l_arr ());
-
- for (int i =0; i < groups.size(); i++)
+ Cons<Translator> *next =0;
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = next)
{
- groups[i]->check_removal();
- if (groups[i]->removable_b())
- terminate_translator (groups[i]);
+ next = p->next_;
+ if (Translator_group *trg = dynamic_cast <Translator_group *> (p->car_))
+ {
+ trg->check_removal ();
+ if (trg->removable_b())
+ terminate_translator (trg);
+ }
}
}
if (is_alias_b (n) && (id_str_ == id || id.empty_b ()))
return this;
- Link_array<Translator_group> groups (group_l_arr ());
+
Translator_group* r = 0;
- for (int i =0; !r && i < groups.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- r = groups[i]->find_existing_translator_l (n,id);
+ if (Translator_group *trg = dynamic_cast <Translator_group *> (p->car_))
+ r = trg->find_existing_translator_l (n, id);
}
return r;
{
bool hebbes_b =false;
- Link_array<Translator> nongroups (nongroup_l_arr ());
-
- for (int i =0; !hebbes_b && i < nongroups.size() ; i++)
- hebbes_b =nongroups[i]->try_music (m);
+ for (Cons<Translator> *p = trans_p_list_.head_; !hebbes_b && p; p = p->next_)
+ {
+ if (!dynamic_cast <Translator_group *> (p->car_))
+ {
+ hebbes_b = p->car_->try_music (m);
+ }
+ }
return hebbes_b;
}
return daddy_trans_l_->ancestor_l (level-1);
}
-Link_array<Translator_group>
-Translator_group::group_l_arr () const
-{
- Link_array<Translator_group> groups;
- for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
- {
- if (dynamic_cast <Translator_group *> (p->car_))
- groups.push (dynamic_cast <Translator_group *> (p->car_));
- }
- return groups;
-}
-Link_array<Translator>
-Translator_group::nongroup_l_arr () const
-{
- Link_array<Translator> groups;
- for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
- {
- if (!dynamic_cast <Translator_group *> (p->car_))
- groups.push (p->car_);
- }
- return groups;
-}
-/**
- End translator: call "destructor", remove from hierarchy, and delete
- */
+
+
void
Translator_group::terminate_translator (Translator*r_l)
Translator*
Translator_group::get_simple_translator (String type) const
{
- Link_array<Translator> nongroups (nongroup_l_arr ());
- for (int i=0; i < nongroups.size(); i++)
+ for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
{
- if (classname (nongroups[i]) == type)
- return nongroups[i];
+ if (classname (p->car_) == type)
+ return p->car_;
}
if (daddy_trans_l_)
return daddy_trans_l_->get_simple_translator (type);
infinity=10000
beamslopeproportional =
- \property Score.beamslopedamping = 0
+ \property Score.beamSlopedamping = 0
beamslopedamped =
- \property Score.beamslopedamping = 1
+ \property Score.beamSlopedamping = 1
beamslopezero =
- \property Score.beamslopedamping = \infinity
+ \property Score.beamSlopedamping = \infinity
% this sucks, you'd want to pass an array, at least
% (or embedded code: you still can't dictate the slope / stemlength)
beamposfree =
- \property Score.beamquantisation = 0
+ \property Score.beamQuantisation = 0
beamposnormal =
- \property Score.beamquantisation = 1
+ \property Score.beamQuantisation = 1
beampostraditional =
- \property Score.beamquantisation = 2
+ \property Score.beamQuantisation = 2
slurnormal =
Begin3
Title: LilyPond
-Version: 1.3.12
-Entered-date: 16DEC99
+Version: 1.3.13
+Entered-date: 18DEC99
Description:
Keywords: music notation typesetting midi fonts engraving
Author: hanwen@cs.uu.nl (Han-Wen Nienhuys)
janneke@gnu.org (Jan Nieuwenhuizen)
Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys)
Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert
- 1000k lilypond-1.3.12.tar.gz
+ 1000k lilypond-1.3.13.tar.gz
Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/
- 1000k lilypond-1.3.12.tar.gz
+ 1000k lilypond-1.3.13.tar.gz
Copying-policy: GPL
End
Name: lilypond
-Version: 1.3.12
+Version: 1.3.13
Release: 1
Copyright: GPL
Group: Applications/Publishing
-Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.12.tar.gz
+Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.13.tar.gz
Summary: A program for printing sheet music.
URL: http://www.cs.uu.nl/~hanwen/lilypond
# get Packager from (undocumented?) ~/.rpmmacros!
#: stem-engraver.cc:80
#, c-format
msgid "Adding note head to incompatible stem (type = %d)"
-msgstr "Voeg noot bolletje toe aan onverenigbare stok (type = %s)"
+msgstr "Voeg noot bolletje toe aan onverenigbare stok (type = %d)"
#: stem.cc:26
msgid "stem direction set already!"