-pl 15.jcn2
+pl 15.jcn4
+ - removed old notename2scm conversion
+ - beam-dir-algorithm through scm
+ - bfs paper-scm
+ - bf: knee-stemlengths
+
+pl 15.jcn3
- moved poor man's stem arrays to scm
pl 15.jcn2
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=15
-MY_PATCH_LEVEL=jcn3
+MY_PATCH_LEVEL=jcn4
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
% when this file has been parsed...
% {
-#(set! pitch-names-alist
+#(set! note-names-alist
(append
'(
; use these for German naming
((6 . 0) . ("H" ""))
((6 . -1) . ("B" ("feta-1" . "\12")))
)
- pitch-names-alist))
+ note-names-alist))
#(set! chord-names-alist
(append
--- /dev/null
+\score{
+ \context PianoStaff <
+ \context Staff=one \notes\relative c'{
+ s1
+ }
+ \context Staff=two \notes\relative c'{
+ \clef bass;
+% no knee
+ \stemup [c8 \translator Staff=one \stemdown g'16 f]
+ s8
+ s2
+ }
+ >
+ \paper{
+ \translator{
+ \GrandStaffContext
+ minVerticalAlign = 2.8*\staffheight;
+ maxVerticalAlign = 2.8*\staffheight;
+ }
+ linewidth=-1.;
+ }
+}
+
+\version "1.3.5";
} while (flip(&d) != DOWN);
- /*
- [Ross] states that the majority of the notes dictates the
- direction (and not the mean of "center distance")
- But is that because it really looks better, or because he wants
- to provide some real simple hands-on rules?
-
- We have our doubts, so we simply provide all sensible alternatives.
-
- If dir is not determined: up (see stem::get_default_dir ()) */
-
- Direction beam_dir = CENTER;
- Direction neutral_dir = (Direction)(int)paper_l ()->get_var ("stem_default_neutral_direction");
-
- SCM a = get_elt_property ("beam-dir-algorithm");
-
- if (a == ly_symbol2scm ("majority")) // should get default from paper.
- beam_dir = (count[UP] == count[DOWN]) ? neutral_dir
- : (count[UP] > count[DOWN]) ? UP : DOWN;
- else if (a == ly_symbol2scm ("mean"))
- // mean center distance
- beam_dir = (total[UP] == total[DOWN]) ? neutral_dir
- : (total[UP] > total[DOWN]) ? UP : DOWN;
- else if (a == ly_symbol2scm ("median"))
- {
- // median center distance
- if (count[DOWN] && count[UP])
- {
- beam_dir = (total[UP] / count[UP] == total[DOWN] / count[DOWN])
- ? neutral_dir
- : (total[UP] / count[UP] > total[DOWN] / count[DOWN]) ? UP : DOWN;
- }
- else
- {
- beam_dir = (count[UP] == count[DOWN]) ? neutral_dir
- : (count[UP] > count[DOWN]) ? UP : DOWN;
- }
- }
+ SCM s = scm_eval (gh_list (ly_symbol2scm ("beam-dir-algorithm"),
+ ly_quote_scm (gh_cons (gh_int2scm (count[UP]),
+ gh_int2scm (count[DOWN]))),
+ ly_quote_scm (gh_cons (gh_int2scm (total[UP]),
+ gh_int2scm (total[DOWN]))),
+ SCM_UNDEFINED));
+ if (gh_number_p (s) && gh_scm2int (s))
+ return to_dir (s);
- return beam_dir;
+ /*
+ If dir is not determined: get from paper
+ */
+ return (Direction)(int)
+ paper_l ()->get_var ("stem_default_neutral_direction");
}
if (get_direction () != s->get_direction ())
{
stem_y -= get_direction ()
- * (thick / 2 + (beam_multiplicity - 1 - stem_multiplicity))
- * interbeam_f;
+ * (thick / 2 + (beam_multiplicity - 1) * interbeam_f);
Staff_symbol_referencer_interface me (s);
Staff_symbol_referencer_interface last (last_visible_stem ());
- if ((s != first_visible_stem ())
- && me.staff_symbol_l () != last.staff_symbol_l ())
- stem_y += get_direction ()
- * (beam_multiplicity - stem_multiplicity) * interbeam_f;
+ // huh, why not for first visible?
+ if (//(s != first_visible_stem ()) &&
+ me.staff_symbol_l () != last.staff_symbol_l ())
+ stem_y += get_direction ()
+ * (beam_multiplicity - stem_multiplicity) * interbeam_f;
}
return stem_y;
}
#include "main.hh"
#include "dimensions.hh"
#include "text-item.hh"
+#include "lily-guile.icc"
ADD_THIS_TRANSLATOR (Chord_name_engraver);
find_inversion_b = gh_scm2bool (chord_inversion);
chord_name_p_ = new Chord_name;
- chord_name_p_->set (to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_, find_inversion_b));
-
+ Chord chord = to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_,
+ find_inversion_b);
+
+ /*
+ Hmm, why not represent complete chord as list?
+ ((tonic third fifth) (inversion bass))
+ */
+ chord_name_p_->set_elt_property ("pitches", array_to_scm (chord.pitch_arr_));
+ if (chord.inversion_b_)
+ chord_name_p_->set_elt_property ("inversion",
+ to_scm (chord.inversion_pitch_));
+ if (chord.bass_b_)
+ chord_name_p_->set_elt_property ("bass", to_scm (chord.bass_pitch_));
+
announce_element (Score_element_info (chord_name_p_, 0));
}
#include "lily-guile.icc"
/*
- ugh, move to chord-name-engraver
-
- Hmm, why not represent complete chord as list?
- ((tonic third fifth) (inversion bass))
- */
-void
-Chord_name::set (Chord const& c)
-{
- set_elt_property ("pitches", array_to_scm (c.pitch_arr_));
- if (c.inversion_b_)
- set_elt_property ("inversion", to_scm (c.inversion_pitch_));
- if (c.bass_b_)
- set_elt_property ("bass", to_scm (c.bass_pitch_));
-}
-
-/*
- junkme
+ TODO: move text lookup out of Chord_name
*/
-SCM
-notename2scm (Musical_pitch p)
-{
- return gh_cons (gh_int2scm (p.notename_i_), gh_int2scm (p.accidental_i_));
-}
-
/*
word is roman text or styled text:
"text"
{
while (gh_cdr (scm) != SCM_EOL)
{
- mol.add_at_edge (X_AXIS, RIGHT,
- ly_word2molecule (gh_car (scm)), 0);
+ mol.add_at_edge (X_AXIS, RIGHT, ly_word2molecule (gh_car (scm)), 0);
scm = gh_cdr (scm);
}
scm = gh_car (scm);
}
- mol.add_at_edge (X_AXIS, RIGHT,
- ly_word2molecule (scm), 0);
+ mol.add_at_edge (X_AXIS, RIGHT, ly_word2molecule (scm), 0);
return mol;
}
Molecule
Chord_name::pitch2molecule (Musical_pitch p) const
{
- SCM name = scm_eval (gh_list (ly_symbol2scm ("user-pitch-name"), ly_quote_scm (notename2scm (p)), SCM_UNDEFINED));
+ SCM name = scm_eval (gh_list (ly_symbol2scm ("user-pitch-name"),
+ ly_quote_scm (to_scm (p)),
+ SCM_UNDEFINED));
if (name != SCM_UNSPECIFIED)
{
return diff;
}
+/*
+ JUNKME
+ */
bool
Chord_name::user_chord_name (Array<Musical_pitch> pitch_arr, Chord_mol* name_p) const
{
- SCM chord = SCM_EOL;
Array<Musical_pitch> chord_type = pitch_arr;
Chord::rebuild_transpose (&chord_type, diff_pitch (pitch_arr[0], Musical_pitch (0)), false);
+#if 0
+ SCM chord = SCM_EOL;
for (int i= chord_type.size (); i--; )
- chord = gh_cons (notename2scm (chord_type[i]), chord);
+ chord = gh_cons (to_scm (chord_type[i]), chord);
+#else
+ SCM chord = array_to_scm (chord_type);
+#endif
- SCM name = scm_eval (gh_list (ly_symbol2scm ("user-chord-name"), ly_quote_scm (chord), SCM_UNDEFINED));
+ SCM name = scm_eval (gh_list (ly_symbol2scm ("user-chord-name"),
+ ly_quote_scm (chord),
+ SCM_UNDEFINED));
if (gh_pair_p (name))
{
name_p->modifier_mol = ly_text2molecule (gh_car (name));
Beam adjusts the stems its owns to make sure that they reach the
beam and that point in the correct direction (urg?)
-elt property:
-
-damping: amount of beam slope damping. (int)
-
-should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams
-
-slope_quantisation: 'none, 'normal or 'traditional
+ elt_properties:
+ y-position: real (position of left edge)
+ height: real (dy)
+ damping: amount of beam slope damping. (int)
+ should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams
*/
class Beam : public Directional_spanner
{
Molecule bass_mol;
};
+/**
+ elt_properties:
+ pitches: list of musical-pitch
+ inversion(optional): musical-pitch
+ bass(optional): musical-pitch
+ */
class Chord_name : public Item
{
public:
bool user_chord_name (Array<Musical_pitch> pitch_arr, Chord_mol* name_p) const;
void banter (Array<Musical_pitch> pitch_arr, Chord_mol* name_p) const;
- void set (Chord const& c);
-
protected:
virtual Molecule* do_brew_molecule_p () const;
};
&& (get_direction () != get_default_dir ()))
length_f -= shorten_f;
-#if 0
- /*
- UGK.!
- */
- if (flag_i () >= 5)
- length_f += 2.0;
- if (flag_i () >= 6)
- length_f += 1.0;
-#endif
-
Real st_f = head_positions()[-dir] + dir * length_f;
bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED;
arithmetic_basicspace = 2.;
arithmetic_multiplier = 0.9 * \quartwidth ;
-% there are several ways to calculate the direction of a beam
-%
-% * MAJORITY : number count of up or down notes
-% * MEAN : mean centre distance of all notes
-% * MEDIAN : mean centre distance weighted per note
-%
-
-#'beam-dir-algorithm = #'majority %urg.
-
#'Stem_tremolo::beam-width = 1.5 * \quartwidth ;
-;; pitch: (notename . accidental)
+;; note-name: (note . accidental)
;; list: (list-of-pitches . (modifier-string . addition-subtraction-string))
;; if a complete chord is found, use name
;; if a chord's base triad is found (c e g), use name
-(define pitch-names-alist '())
-(set! pitch-names-alist
+(define note-names-alist '())
+(set! note-names-alist
(append
'(
; use these for German naming
;((0 . 1) . ("C" ("feta-1" . "\10")))
;((0 . -1) . ("C" ("feta-1" . "\12")))
)
- pitch-names-alist))
+ note-names-alist))
+(define (pitch->note-name pitch)
+ (cons (car pitch) (cadr pitch)))
+
(define (user-pitch-name pitch)
- (let ((entry (assoc pitch pitch-names-alist)))
+ (let ((entry (assoc (pitch->note-name pitch) note-names-alist)))
(if entry
(cdr entry))))
chord-names-alist))
(define (user-chord-name chord)
- ;(display chord)
- ;(newline)
- (let ((entry (assoc chord chord-names-alist)))
- (if entry
- (cdr entry))))
-
+ (let ((entry (assoc (map (lambda (x) (pitch->note-name x)) chord)
+ chord-names-alist)))
+ (if entry
+ (cdr entry))))
(list 'beamSlopeDamping number? 'damping)
(list 'autoKneeGap number? 'auto-knee-gap)
(list 'autoInterstaffKneeGap number? 'auto-interstaff-knee-gap)
- (list 'beamQuantisation symbol? 'slope-quantisation)
(list 'beamDirAlgorithm symbol? 'beam-dir-algorithm)
(list 'beamSlope number? 'height)
(list 'beamVerticalPosition number? 'y-position)
;; inter seems to be a modern quirk, we don't use that
+(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-normal-dy-quants
- '(0 (/2 (+ beam-thickness staff-line) 2) (+ beam-thickness staff-line) 1))
+ (list 0 (/ (+ 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)))
+ (let ((quants (list 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)))
quants))
-;;; Default variables and settings
+;; There are several ways to calculate the direction of a beam
+;;
+;; * majority: number count of up or down notes
+;; * mean : mean centre distance of all notes
+;; * median : mean centre distance weighted per note
+
+(define (dir-compare up down)
+ (if (= up down)
+ 0
+ (if (> up down)
+ 1
+ -1)))
+
+;; (up . down)
+(define (beam-dir-majority count total)
+ (dir-compare (car count) (cdr count)))
+
+(define (beam-dir-mean count total)
+ (dir-compare (car total) (cdr total)))
+
+(define (beam-dir-median count total)
+ (if (and (> (car count) 0)
+ (> (cdr count) 0))
+ (dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count)))
+ (dir-compare (car count) (cdr count))))
+
-(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)))
+;;; Default variables and settings
(define beam-height-quants beam-normal-dy-quants)
(define beam-vertical-position-quants beam-normal-y-quants)
+;; [Ross] states that the majority of the notes dictates the
+;; direction (and not the mean of "center distance")
+;;
+;; But is that because it really looks better, or because he wants
+;; to provide some real simple hands-on rules?
+;;
+;; We have our doubts, so we simply provide all sensible alternatives.
+(define beam-dir-algorithm beam-dir-majority)
+
+
;; array index flag-2 (what a name!!), last if index>size
;; unbeamed stems
(define stem-length '(3.5 3.5 3.5 4.5 5.0))
;; beamed stems
(define beamed-stem-shorten '(0.5))
(define beamed-stem-length '(0.0 2.5 2.0 1.5))
-(define beamed-stem-minimum-length '(0.0 3.0 2.5 2.0))
+(define beamed-stem-minimum-length '(0.0 1.5 1.25 1.0))
(define grace-beamed-stem-minimum-length
(map (lambda (x) (* grace-length-factor x)) beamed-stem-minimum-length))