From: fred Date: Tue, 26 Mar 2002 23:21:22 +0000 (+0000) Subject: lilypond-1.3.46 X-Git-Tag: release/1.5.59~1655 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b9ffc34f7b37238e3fbf8f819e0392a60b026b3c;p=lilypond.git lilypond-1.3.46 --- diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index dc4a9de032..82025c42ef 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -101,6 +101,14 @@ not be on staff lines. @mudelafile{staccato-pos.ly} +@section Chord names + +Chord names are generated from a list pitches, and are customisable +from guile. For some unlogical names, guile customisation is used +by default. + +@mudelafile{chord-names.ly} + @section Grace notes Grace notes are typeset as an encapsulated piece of music. You can diff --git a/input/test/chord-names.ly b/input/test/chord-names.ly new file mode 100644 index 0000000000..87e82c4699 --- /dev/null +++ b/input/test/chord-names.ly @@ -0,0 +1,24 @@ +chord = \notes\transpose c''\chords{ + c1 + c:m + c:m5- + c:m5-.7- + c:7+ + c:m5-.7 + c:5-.7+ + c:m7 + c:7 +} + +\score{ + < + \context ChordNames \chord + \context Staff \chord + > + \paper{ + linewidth = -1.0; + \translator { \ChordNameContext chordNameWordSpace = #1 } + \translator { \LyricsContext textScriptWordSpace = #0.3 } + } +} + diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 27e3342e51..75a16226c9 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -31,11 +31,14 @@ Chord_name::ly_word2molecule (SCM scm) const String style; if (gh_pair_p (scm)) { - style = ly_scm2string (gh_car (scm)); + SCM s = gh_car (scm); + if (gh_string_p (s)) + style = ly_scm2string (s); scm = gh_cdr (scm); } - String text = ly_scm2string (scm); - return lookup_l ()->text (style, text, paper_l ()); + if (gh_string_p (scm)) + return lookup_l ()->text (style, ly_scm2string (scm), paper_l ()); + return Molecule (); } /* @@ -51,12 +54,16 @@ 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); + Molecule m = ly_word2molecule (gh_car (scm)); + if (!m.empty_b ()) + mol.add_at_edge (X_AXIS, RIGHT, m, 0); scm = gh_cdr (scm); } scm = gh_car (scm); } - mol.add_at_edge (X_AXIS, RIGHT, ly_word2molecule (scm), 0); + Molecule m = ly_word2molecule (scm); + if (!m.empty_b ()) + mol.add_at_edge (X_AXIS, RIGHT, m, 0); return mol; } @@ -78,9 +85,17 @@ Chord_name::pitch2molecule (Musical_pitch p) const We want the smaller size, even if we're big ourselves. */ if (p.accidental_i_) - mol.add_at_edge (X_AXIS, RIGHT, + { + Molecule acc = paper_l ()->lookup_l (-3)->afm_find + (String ("accidentals-") + to_str (p.accidental_i_)); + // urg, howto get a good superscript_y? + Real super_y = lookup_l ()->text ("", "x", paper_l ()).extent + ()[Y_AXIS].length () / 2; + super_y += -acc.extent ()[Y_AXIS][MIN]; + acc.translate_axis (super_y, Y_AXIS); + mol.add_at_edge (X_AXIS, RIGHT, acc, 0.0); + } - paper_l ()->lookup_l (-2)->afm_find (String ("accidentals-") + to_str (p.accidental_i_)), 0.0); return mol; } @@ -282,7 +297,8 @@ Chord_name::do_brew_molecule () const } // urg, howto get a good superscript_y? - Real super_y = lookup_l ()->text ("", "x", paper_l ()).dim_.y ().length ()/2; + Real super_y = lookup_l ()->text ("", "x", paper_l ()).extent + ()[Y_AXIS].length () / 2; if (!name.addition_mol.empty_b ()) name.addition_mol.translate (Offset (0, super_y)); diff --git a/scm/chord-names.scm b/scm/chord-names.scm index a5a428d649..7a8777fbc7 100644 --- a/scm/chord-names.scm +++ b/scm/chord-names.scm @@ -20,7 +20,7 @@ note-names-alist)) (define (pitch->note-name pitch) - (cons (car pitch) (cadr pitch))) + (cons (cadr pitch) (caddr pitch))) (define (user-pitch-name pitch) (let ((entry (assoc (pitch->note-name pitch) note-names-alist))) @@ -32,17 +32,17 @@ (append '( ; C iso C.no3.no5 - (((0 . 0)) . ("" . "")) + (((0 . 0)) . (#f . #f)) ; C iso C.no5 - (((0 . 0) (2 . 0)) . ("" . "")) + (((0 . 0) (2 . 0)) . (#f . #f)) ; Cm iso Cm.no5 - (((0 . 0) (2 . -1)) . ("m" . "")) + (((0 . 0) (2 . -1)) . ("m" . #f)) ; Cdim iso Cm5- - (((0 . 0) (2 . -1) (4 . -1)) . ("dim" . "")) + (((0 . 0) (2 . -1) (4 . -1)) . ("dim" . #f)) ; Co iso Cm5-7- ; urg ; (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" . ("feta-1" . "."))) - (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . ("" . ("script" . "o"))) + (((0 . 0) (2 . -1) (4 . -1) (6 . -2)) . (#f . ("script" . "o"))) ; Cdim9 (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1)) . ("dim" . ("script" . "9"))) (((0 . 0) (2 . -1) (4 . -1) (6 . -2) (1 . -1) (3 . -1)) . ("dim" . ("script" . "11")))