From: Jan Nieuwenhuizen Date: Tue, 21 Dec 1999 20:55:32 +0000 (+0100) Subject: patch::: 1.3.15.jcn4 X-Git-Tag: release/1.3.16~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0d22357ccd02d1d3ec5c844c407e4d4a72375b63;p=lilypond.git patch::: 1.3.15.jcn4 pl 15.jcn4 - removed old notename2scm conversion - beam-dir-algorithm through scm - bfs paper-scm - bf: knee-stemlengths pl 15.jcn3 --- diff --git a/CHANGES b/CHANGES index cc642f8d83..2821f437c0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,10 @@ -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 diff --git a/VERSION b/VERSION index 4a05daddf6..d1c8ac5e5e 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond 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. diff --git a/input/test/banter-chords.ly b/input/test/banter-chords.ly index 77ef6e5f06..4fce5022c5 100644 --- a/input/test/banter-chords.ly +++ b/input/test/banter-chords.ly @@ -16,14 +16,14 @@ TestedFeatures = "Banter named chords"; % 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" . ""))) ) - pitch-names-alist)) + note-names-alist)) #(set! chord-names-alist (append diff --git a/input/test/knee-mult.ly b/input/test/knee-mult.ly new file mode 100644 index 0000000000..98eb91407c --- /dev/null +++ b/input/test/knee-mult.ly @@ -0,0 +1,24 @@ +\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"; diff --git a/lily/beam.cc b/lily/beam.cc index c77b84839c..b0a7deffc5 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -120,46 +120,21 @@ Beam::get_default_dir () const } 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"); } @@ -444,16 +419,16 @@ Beam::calc_stem_y_f (Stem* s, Real y, Real dy) const 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; } diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index c22fd18a5b..e5e31c38f5 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -15,6 +15,7 @@ #include "main.hh" #include "dimensions.hh" #include "text-item.hh" +#include "lily-guile.icc" ADD_THIS_TRANSLATOR (Chord_name_engraver); @@ -73,8 +74,20 @@ Chord_name_engraver::do_process_requests () 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)); } diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 4b6eff78a9..f994dd3452 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -16,31 +16,9 @@ #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" @@ -72,21 +50,21 @@ Chord_name::ly_text2molecule (SCM scm) const { 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) { @@ -129,17 +107,26 @@ diff_pitch (Musical_pitch tonic, Musical_pitch p) return diff; } +/* + JUNKME + */ bool Chord_name::user_chord_name (Array pitch_arr, Chord_mol* name_p) const { - SCM chord = SCM_EOL; Array 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)); diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 13e3421f0c..cf101fd895 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -16,14 +16,12 @@ 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 { diff --git a/lily/include/chord-name.hh b/lily/include/chord-name.hh index 04c20ffb18..dc49f205c2 100644 --- a/lily/include/chord-name.hh +++ b/lily/include/chord-name.hh @@ -23,6 +23,12 @@ public: Molecule bass_mol; }; +/** + elt_properties: + pitches: list of musical-pitch + inversion(optional): musical-pitch + bass(optional): musical-pitch + */ class Chord_name : public Item { public: @@ -33,8 +39,6 @@ public: bool user_chord_name (Array pitch_arr, Chord_mol* name_p) const; void banter (Array pitch_arr, Chord_mol* name_p) const; - void set (Chord const& c); - protected: virtual Molecule* do_brew_molecule_p () const; }; diff --git a/lily/stem.cc b/lily/stem.cc index 4ef5b7de2c..d4bea2a5ec 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -260,16 +260,6 @@ Stem::get_default_stemlen () 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; diff --git a/ly/params.ly b/ly/params.ly index 4a9018966a..4a8de0dbaa 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -34,15 +34,6 @@ to the width of a quarter note head. 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 ; diff --git a/scm/chord-names.scm b/scm/chord-names.scm index 3329c144d6..a5a428d649 100644 --- a/scm/chord-names.scm +++ b/scm/chord-names.scm @@ -1,11 +1,11 @@ -;; 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 @@ -17,10 +17,13 @@ ;((0 . 1) . ("C" ("feta-1" . ""))) ;((0 . -1) . ("C" ("feta-1" . ""))) ) - 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)))) @@ -47,9 +50,7 @@ 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)))) diff --git a/scm/generic-property.scm b/scm/generic-property.scm index c6104e21d7..e622e9d0dc 100644 --- a/scm/generic-property.scm +++ b/scm/generic-property.scm @@ -5,7 +5,6 @@ (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) diff --git a/scm/paper.scm b/scm/paper.scm index ce28ebf4bf..3c291a4f09 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -21,13 +21,19 @@ ;; 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))) @@ -45,18 +51,49 @@ 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)) @@ -68,7 +105,7 @@ ;; 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))