From: fred Date: Tue, 26 Mar 2002 22:44:40 +0000 (+0000) Subject: lilypond-1.3.16 X-Git-Tag: release/1.5.59~1932 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b264d168840599233cf63d601c84094c0d672d7e;p=lilypond.git lilypond-1.3.16 --- 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/chord-name-engraver.cc b/lily/chord-name-engraver.cc index fcc6031cbb..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); @@ -72,8 +73,21 @@ Chord_name_engraver::do_process_requests () if (gh_boolean_p (chord_inversion)) find_inversion_b = gh_scm2bool (chord_inversion); - chord_name_p_ = new Chord_name (to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_, find_inversion_b)); - + chord_name_p_ = new Chord_name; + 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 b190520b74..f994dd3452 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -13,17 +13,11 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" +#include "lily-guile.icc" -SCM -pitch2scm (Musical_pitch p) -{ - return gh_cons (gh_int2scm (p.notename_i_), gh_int2scm (p.accidental_i_)); -} - -Chord_name::Chord_name (Chord const& c) -{ - chord_ = c; -} +/* + TODO: move text lookup out of Chord_name + */ /* word is roman text or styled text: @@ -56,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 (pitch2scm (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) { @@ -113,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 (pitch2scm (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)); @@ -145,7 +148,7 @@ Chord_name::banter (Array pitch_arr, Chord_mol* name_p) const scale.push (Musical_pitch (i)); Musical_pitch tonic = pitch_arr[0]; - chord_.rebuild_transpose (&scale, tonic, true); + Chord::rebuild_transpose (&scale, tonic, true); /* Does chord include this step? -1 if flat @@ -214,10 +217,16 @@ Chord_name::banter (Array pitch_arr, Chord_mol* name_p) const } } +/* + TODO: + fix silly to-and-fro scm conversions + */ Molecule* Chord_name::do_brew_molecule_p () const { - Musical_pitch tonic = chord_.pitch_arr_[0]; + Array pitch_arr; + scm_to_array (get_elt_property ("pitches"), &pitch_arr); + Musical_pitch tonic = pitch_arr[0]; Chord_mol name; name.tonic_mol = pitch2molecule (tonic); @@ -230,17 +239,17 @@ Chord_name::do_brew_molecule_p () const maybe we should check all sub-lists of pitches, not just full list and base triad? */ - if (!user_chord_name (chord_.pitch_arr_, &name)) + if (!user_chord_name (pitch_arr, &name)) { /* else, check if user has listed base triad use user base name and add banter for remaining part */ - if ((chord_.pitch_arr_.size () > 2) - && user_chord_name (chord_.pitch_arr_.slice (0, 3), &name)) + if ((pitch_arr.size () > 2) + && user_chord_name (pitch_arr.slice (0, 3), &name)) { Array base = Chord::base_arr (tonic); - base.concat (chord_.pitch_arr_.slice (3, chord_.pitch_arr_.size ())); + base.concat (pitch_arr.slice (3, pitch_arr.size ())); banter (base, &name); } /* @@ -248,22 +257,27 @@ Chord_name::do_brew_molecule_p () const */ else { - banter (chord_.pitch_arr_, &name); + banter (pitch_arr, &name); } } - if (chord_.inversion_b_) + SCM s = get_elt_property ("inversion"); + if (s != SCM_UNDEFINED) { name.inversion_mol = lookup_l ()->text ("", "/", paper_l ()); - // zucht const& - Molecule mol = pitch2molecule (chord_.inversion_pitch_); + Musical_pitch p; + scm_to (s, &p); + Molecule mol = pitch2molecule (p); name.inversion_mol.add_at_edge (X_AXIS, RIGHT, mol, 0); } - if (chord_.bass_b_) + s = get_elt_property ("bass"); + if (s != SCM_UNDEFINED) { name.bass_mol = lookup_l ()->text ("", "/", paper_l ()); - Molecule mol = pitch2molecule (chord_.bass_pitch_); + Musical_pitch p; + scm_to (s, &p); + Molecule mol = pitch2molecule (p); name.bass_mol.add_at_edge (X_AXIS, RIGHT, mol, 0); } diff --git a/lily/include/chord-name.hh b/lily/include/chord-name.hh index 0089445694..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,14 +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; - Chord_name (Chord const& c); - - /* - ugh. Junkme, I must be elt property. - */ - - Chord chord_; - protected: virtual Molecule* do_brew_molecule_p () const; }; diff --git a/lily/include/lily-guile.icc b/lily/include/lily-guile.icc new file mode 100644 index 0000000000..9fb611a64b --- /dev/null +++ b/lily/include/lily-guile.icc @@ -0,0 +1,41 @@ +/* + lily-guile.icc -- implement guile templates + + source file of the GNU LilyPond music typesetter + + (c) 1999 Jan Nieuwenhuizen +*/ + +#ifndef LILY_GUILE_ICC +#define LILY_GUILE_ICC + +#include "lily-guile.hh" + +templateSCM +array_to_scm (Array arr) +{ + SCM list = SCM_EOL; + for (int i = arr.size (); i--;) + list = gh_cons (to_scm (arr[i]), list); + return list; +} + +/* + Silly templates + Array scm_to_array (SCM s) + + check scm? + */ +templatevoid +scm_to_array (SCM s, Array* arr) +{ + arr->clear (); + for (; gh_pair_p (s); s= gh_cdr (s)) + { + T t; + scm_to (gh_car (s), &t); + arr->push (t); + } +} + +#endif /* LILY_GUILE_ICC */ 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))))