+pl 15.jcn2
+ - beam quanting using scm lists
+
pl 14.hwn1jcn1
- chord-name uses scm members
- bfs: knee with different mults, interstaff knee, auto-knee
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=15
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
--- /dev/null
+%{
+Have some fun beam quanting
+%}
+
+% no y quantising
+#(define (beam-vertical-position-quants m dy) '())
+
+% rediculous dy quanting
+#(define beam-height-quants '(0 4))
+
+\score {
+ \notes\relative c'{
+ c8 c c c
+ c8 e g a
+ c,8 f b e
+ }
+}
#include "group-interface.hh"
#include "staff-symbol-referencer.hh"
#include "cross-staff.hh"
+#include "lily-guile.icc"
Beam::Beam ()
{
return;
int multiplicity = get_multiplicity ();
- SCM shorten = scm_eval (scm_listify (
- ly_symbol2scm ("beamed-stem-shorten"),
- gh_int2scm (multiplicity),
- SCM_UNDEFINED));
+ SCM shorten = scm_eval (gh_list (
+ ly_symbol2scm ("beamed-stem-shorten"),
+ gh_int2scm (multiplicity),
+ SCM_UNDEFINED));
Real shorten_f = gh_scm2double (shorten)
* Staff_symbol_referencer_interface (this).staff_space ();
return lengthen * get_direction ();
}
+/*
+ Hmm. At this time, beam position and slope are determined. Maybe,
+ stem directions and length should set to relative to the chord's
+ position of the beam. */
void
Beam::set_stem_length (Real y, Real dy)
{
/*
[Ross] (simplification of)
- Try to set dy complying with:
+ Set dy complying with:
- zero
- thick / 2 + staffline_f / 2
- thick + staffline_f
+ n * staff_space
-
- TODO: get allowed-positions as scm list (aarg: from paper block)
*/
Real
Beam::quantise_dy_f (Real dy) const
{
- SCM s = get_elt_property ("slope-quantisation");
-
- if (s == ly_symbol2scm ("none"))
+ SCM quants = ly_eval_str ("beam-height-quants");
+
+ Array<Real> a;
+ scm_to_array (quants, &a);
+ if (a.size () <= 1)
return dy;
Staff_symbol_referencer_interface st (this);
Real staff_space = st.staff_space ();
- Real staffline_f = paper_l ()->get_var ("stafflinethickness");
- Real thick = gh_scm2double (get_elt_property ("beam-thickness"));;
-
- Array<Real> allowed_fraction (3);
- allowed_fraction[0] = 0;
- allowed_fraction[1] = (thick / 2 + staffline_f / 2);
- allowed_fraction[2] = (thick + staffline_f);
-
- allowed_fraction.push (staff_space);
- Interval iv = quantise_iv (allowed_fraction, abs (dy));
+ Interval iv = quantise_iv (a, abs (dy)/staff_space) * staff_space;
Real q = (abs (dy) - iv[SMALLER] <= iv[BIGGER] - abs (dy))
? iv[SMALLER]
: iv[BIGGER];
-
+
return q * sign (dy);
}
Prevent interference from stafflines and beams.
See Documentation/tex/fonts.doc
- TODO: get allowed-positions as scm list (aarg: from paper block)
+ We only need to quantise the (left) y-position of the beam,
+ since dy is quantised too.
+ if extend_b then stems must *not* get shorter
*/
Real
Beam::quantise_y_f (Real y, Real dy, int quant_dir)
{
- /*
- We only need to quantise the (left) y-position of the beam,
- since dy is quantised too.
- if extend_b then stems must *not* get shorter
- */
- SCM s = get_elt_property ("slope-quantisation");
- if (s == ly_symbol2scm ("none"))
- return y;
-
- /*
- ----------------------------------------------------------
- ########
- ########
- ########
- --------------########------------------------------------
- ########
-
- hang straddle sit inter hang
- */
-
+ int multiplicity = get_multiplicity ();
Staff_symbol_referencer_interface st (this);
Real staff_space = st.staff_space ();
- Real staffline_f = paper_l ()->get_var ("stafflinethickness");
- Real thick = gh_scm2double (get_elt_property ("beam-thickness"));;
-
- Real straddle = 0;
- Real sit = thick / 2 - staffline_f / 2;
- Real hang = staff_space - thick / 2 + staffline_f / 2;
-
- /*
- Put all allowed positions into an array.
- Whether a position is allowed or not depends on
- strictness of quantisation, multiplicity and direction.
-
- For simplicity, we'll assume dir = UP and correct if
- dir = DOWN afterwards.
- */
-
- int multiplicity = get_multiplicity ();
-
-
- Array<Real> allowed_position;
- if (s == ly_symbol2scm ("normal"))
- {
- if ((multiplicity <= 2) || (abs (dy) >= staffline_f / 2))
- allowed_position.push (straddle);
- if ((multiplicity <= 1) || (abs (dy) >= staffline_f / 2))
- allowed_position.push (sit);
- allowed_position.push (hang);
- }
- else if (s == ly_symbol2scm ("traditional"))
- {
- // TODO: check and fix TRADITIONAL
- if ((multiplicity <= 2) || (abs (dy) >= staffline_f / 2))
- allowed_position.push (straddle);
- if ((multiplicity <= 1) && (dy <= staffline_f / 2))
- allowed_position.push (sit);
- if (dy >= -staffline_f / 2)
- allowed_position.push (hang);
- }
+ SCM quants = scm_eval (gh_list (
+ ly_symbol2scm ("beam-vertical-position-quants"),
+ gh_int2scm (multiplicity),
+ gh_double2scm (dy/staff_space),
+ SCM_UNDEFINED));
+ Array<Real> a;
+ scm_to_array (quants, &a);
+ if (a.size () <= 1)
+ return y;
- allowed_position.push (staff_space);
Real up_y = get_direction () * y;
- Interval iv = quantise_iv (allowed_position, up_y);
+ Interval iv = quantise_iv (a, up_y/staff_space) * staff_space;
Real q = up_y - iv[SMALLER] <= iv[BIGGER] - up_y
? iv[SMALLER] : iv[BIGGER];
#include "molecule.hh"
#include "paper-def.hh"
#include "lookup.hh"
-
-SCM
-to_scm (Musical_pitch p)
-{
- return gh_list (gh_int2scm (p.notename_i_), gh_int2scm (p.accidental_i_), gh_int2scm (p.octave_i_), SCM_UNDEFINED);
-}
-
-Musical_pitch
-from_scm (SCM s)
-{
- return Musical_pitch (gh_scm2int (gh_car (s)),
- gh_scm2int (gh_cadr (s)),
- gh_scm2int (gh_caddr (s)));
-}
-
-template<class T>SCM
-array_to_scm (Array<T> arr)
-{
- SCM list = SCM_EOL;
- for (int i = arr.size (); i--;)
- list = gh_cons (to_scm (arr[i]), list);
- return list;
-}
-
-/*
- Silly templates
- Array<T> scm_to_array (SCM s)
- */
-template<class T>void
-scm_to_array (SCM s, Array<T>* arr)
-{
- for (; gh_pair_p (s); s= gh_cdr (s))
- arr->push (from_scm (gh_car (s)));
-}
+#include "lily-guile.icc"
/*
ugh, move to chord-name-engraver
set_elt_property ("bass", to_scm (c.bass_pitch_));
}
+/*
+ junkme
+ */
+
SCM
notename2scm (Musical_pitch p)
{
if (s != SCM_UNDEFINED)
{
name.inversion_mol = lookup_l ()->text ("", "/", paper_l ());
- Molecule mol = pitch2molecule (from_scm (s));
+ Musical_pitch p;
+ scm_to (s, &p);
+ Molecule mol = pitch2molecule (p);
name.inversion_mol.add_at_edge (X_AXIS, RIGHT, mol, 0);
}
if (s != SCM_UNDEFINED)
{
name.bass_mol = lookup_l ()->text ("", "/", paper_l ());
- Molecule mol = pitch2molecule (from_scm (s));
+ Musical_pitch p;
+ scm_to (s, &p);
+ Molecule mol = pitch2molecule (p);
name.bass_mol.add_at_edge (X_AXIS, RIGHT, mol, 0);
}
SCM index_cell (SCM cellp, Direction d);
SCM index_set_cell (SCM cellp, Direction d, SCM val);
+template<class T>SCM array_to_scm (Array<T> arr);
+template<class T>void scm_to_array (SCM s, Array<T>* arr);
+
+//URG how templates suck!
+SCM to_scm (int i);
+void scm_to (SCM s, int* i);
+
+SCM to_scm (Real r);
+void scm_to (SCM s, Real* r);
+
/*
snarfing.
*/
} _ ## name ## _scm_initter; \
/* end define */
-
-
#endif // LILY_GUILE_HH
--- /dev/null
+/*
+ lily-guile.icc -- implement guile templates
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef LILY_GUILE_ICC
+#define LILY_GUILE_ICC
+
+#include "lily-guile.hh"
+
+template<class T>SCM
+array_to_scm (Array<T> arr)
+{
+ SCM list = SCM_EOL;
+ for (int i = arr.size (); i--;)
+ list = gh_cons (to_scm (arr[i]), list);
+ return list;
+}
+
+/*
+ Silly templates
+ Array<T> scm_to_array (SCM s)
+
+ check scm?
+ */
+template<class T>void
+scm_to_array (SCM s, Array<T>* arr)
+{
+ for (; gh_pair_p (s); s= gh_cdr (s))
+ {
+ T t;
+ scm_to (gh_car (s), &t);
+ arr->push (t);
+ }
+}
+
+#endif /* LILY_GUILE_ICC */
#include "lily-proto.hh"
#include "input.hh"
+#include "lily-guile.hh" // we need SCM
/** A "tonal" pitch. This is a pitch as it figures in diatonal western
music (12 semitones in an octave), as opposed to a frequence in Hz
void print () const;
};
+SCM to_scm (Musical_pitch p);
+void scm_to (SCM s, Musical_pitch* p);
+
#include "compare.hh"
INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare);
return s;
}
-#if 0
-SCM
-array_to_list (SCM *a , int l)
-{
- SCM list = SCM_EOL;
- for (int i= l; i--; )
- {
- list = gh_cons (a[i], list);
- }
- return list;
-}
-#endif
-
SCM
ly_warning (SCM str)
{
}
+SCM
+to_scm (int i)
+{
+ return gh_int2scm (i);
+}
+
+void
+scm_to (SCM s, int* i)
+{
+ // urg
+ *i = gh_number_p (s) ? gh_scm2int (s) : 0;
+}
+
+SCM
+to_scm (Real r)
+{
+ return gh_double2scm (r);
+}
+
+void
+scm_to (SCM s, Real* r)
+{
+ // urg
+ *r = gh_number_p (s) ? gh_scm2double (s) : 0;
+}
#include "debug.hh"
#include "main.hh"
+SCM
+to_scm (Musical_pitch p)
+{
+ return gh_list (gh_int2scm (p.notename_i_),
+ gh_int2scm (p.accidental_i_),
+ gh_int2scm (p.octave_i_),
+ SCM_UNDEFINED);
+}
+
+/*
+ TODO: check -- is_pitch () ?
+ */
+void
+scm_to (SCM s, Musical_pitch* p)
+{
+ *p = Musical_pitch (gh_scm2int (gh_car (s)),
+ gh_scm2int (gh_cadr (s)),
+ gh_scm2int (gh_caddr (s)));
+}
+
Musical_pitch::Musical_pitch (int n, int a, int o)
{
notename_i_ = n;
if (gh_number_p (s))
info.idealy_f_ -= gh_double2scm (s);
- Real interstaff_f = -beam_dir* calc_interstaff_dist (this, beam_l ());
+ Real interstaff_f = -beam_dir* calc_interstaff_dist (this, beam_l ());
info.idealy_f_ += interstaff_f;
info.miny_f_ += interstaff_f;
+
+#(eval-string (ly-gulp-file "paper.scm"))
+
\paper {
texsetting = "";
pssetting = "";
%
#'beam-dir-algorithm = #'majority %urg.
-#'Stem_tremolo::beam-width = 1.5 * \quartwidth ;
-
-% The beams should be prevented to conflict with the stafflines,
-% especially at small slopes.
-#'slope-quantisation = #'normal
+#'Stem_tremolo::beam-width = 1.5 * \quartwidth ;
#'Clef_item::visibility-lambda = #postbreak-only-visibility
#'Key_item::visibility-lambda = #postbreak-only-visibility
#'Breathing_sign::visibility-lambda = #non-postbreak-visibility
-
-%{
-dit(code(beam_dir_algorithm)) Specify algorithm for determining
-whether beams go up or down. It is real valued. If set to 2.0 then
-majority selection is used. If set to 3.0, then mean selection is
-used based on the mean center distance. If set to 4.0 then median
-selection is used, based on the median center distance.
-%}
-
-
% catch suspect beam slopes, set slope to zero if
% outer stem is lengthened more than
beam_lengthened = 0.2 * \interline;
'(minimum-space 0.0)))))
-;; Measured in interlines (urg: how to say #interline?)
-(define (stem-shorten flags) 0.5)
-(define (beamed-stem-shorten multiplicity) 0.5)
-
;;;;;;;; TeX
--- /dev/null
+;;; paper.scm -- scm paper variables and functions
+;;;
+;;; source file of the GNU LilyPond music typesetter
+;;;
+;;; (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+
+;;; All dimensions are measured in staff-spaces
+
+;; TODO
+;; - make easily customisable from mudela
+;; - take #forced stems into account (now done in C++)
+;; - take y-position of chord or beam into account
+(define (stem-shorten flags) 0.5)
+(define (beamed-stem-shorten multiplicity) 0.5)
+
+
+;; Beams should be prevented to conflict with the stafflines,
+;; especially at small slopes
+;; ----------------------------------------------------------
+;; ########
+;; ########
+;; ########
+;; --------------########------------------------------------
+;; ########
+;;
+;; hang straddle sit inter hang
+
+;; inter seems to be a modern quirk, we don't use that
+
+(define beam-normal-dy-quants
+ '(0 (/2 (+ beam-thickness staff-line) 2) (+ beam-thickness staff-line) 1))
+
+;; two popular veritcal beam quantings
+;; see params.ly: #'beam-vertical-quants
+(define (beam-normal-y-quants multiplicity dy)
+ (let ((quants `(,beam-hang 1)))
+ (if (or (<= multiplicity 1) (>= (abs dy) (/ staff-line 2)))
+ (set! quants (cons beam-sit quants)))
+ (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2)))
+ (set! quants (cons beam-straddle quants)))
+ quants))
+
+(define (beam-traditional-y-quants multiplicity dy)
+ (let ((quants '(1)))
+ (if (>= dy (/ staff-line -2))
+ (set! quants (cons beam-hang quants)))
+ (if (and (<= multiplicity 1) (<= dy (/ staff-line 2)))
+ (set! quants (cons beam-sit quants)))
+ (if (or (<= multiplicity 2) (>= (abs dy) (/ staff-line 2)))
+ (set! quants (cons beam-straddle quants)))
+ quants))
+
+
+;;; Default variables and settings
+
+(define staff-line 0.10)
+(define beam-thickness (* 0.52 (- 1 staff-line)))
+(define beam-straddle 0)
+(define beam-sit (/ (+ beam-thickness staff-line) 2))
+(define beam-hang (- 1 (/ (- beam-thickness staff-line) 2)))
+
+(define beam-height-quants beam-normal-dy-quants)
+(define beam-vertical-position-quants beam-normal-y-quants)
+
+