]> git.donarmstrong.com Git - lilypond.git/commitdiff
fix chord name accidentals. Add regtest.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 24 Dec 2006 18:58:29 +0000 (19:58 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 24 Dec 2006 18:58:29 +0000 (19:58 +0100)
input/regression/chord-names-languages.ly [new file with mode: 0644]
scm/chord-name.scm

diff --git a/input/regression/chord-names-languages.ly b/input/regression/chord-names-languages.ly
new file mode 100644 (file)
index 0000000..f1ca5b4
--- /dev/null
@@ -0,0 +1,47 @@
+\version "2.10.0"
+\header  {
+    texidoc = "@cindex Chord Names German
+The english naming of chords (default) can be changed to german 
+(@code{\germanChords} replaces B and Bes to H and B), semi-german 
+(@code{\semiGermanChords} replaces B and Bes to H and Bb), italian
+(@code{\italianChords} uses Do Re Mi Fa Sol La Si), or french
+(@code{\frenchChords} replaces Re to RĂ©).
+
+" }
+
+scm = \chordmode {
+    e1/d c:m
+    % c/c cis/cis
+    % yeah, we get the idea. -hwn
+    
+    % cisis/cisis ces/ces ceses/ceses
+    b/b bis/bis bes/bes
+    % beses/beses
+} 
+
+
+\layout {
+    ragged-right = ##t 
+    \context {\ChordNames \consists Instrument_name_engraver }
+}
+
+<<
+    \new ChordNames {
+       \set instrumentName = #"default"
+       \scm
+    }
+    \new ChordNames {
+       \set instrumentName = #"german"
+       \germanChords \scm }
+    \new ChordNames {
+       \set instrumentName = #"semi-german"
+       \semiGermanChords \scm }
+    \new ChordNames {
+       \set instrumentName = #"italian"
+       \italianChords \scm }
+    \new ChordNames {
+       \set instrumentName = #"french"
+       \frenchChords \scm }
+
+    \context Voice { \scm }
+>>
index fe4ba7ab12305dc9e126abfc13e203f9bfbe4e97..33f82c95018c7324839f72d2efb2aedaea673e27 100644 (file)
@@ -21,7 +21,8 @@
        0.3
        0.6)
     (make-musicglyph-markup
-     (string-append "accidentals." (number->string alteration))))))
+     (format "accidentals.~a"
+            (inexact->exact (* 4 alteration)))))))
   
 (define (accidental->markup alteration)
   "Return accidental markup for ALTERATION."
      (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch)))
      (accidental->markup (ly:pitch-alteration pitch)))))
 
+(define (pitch-alteration-semitones pitch)
+  (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))
+
 (define-safe-public ((chord-name->german-markup B-instead-of-Bb) pitch)
   "Return pitch markup for PITCH, using german note names.
    If B-instead-of-Bb is set to #t real german names are returned.
    Otherwise semi-german names (with Bb and below keeping the british names)
 "
   (let* ((name (ly:pitch-notename pitch))
-         (alt (ly:pitch-alteration pitch))
-        (n-a (if (member (cons name alt) `((6 . ,FLAT) (6 . ,DOUBLE-FLAT)))
-                (cons 7 (+ (if B-instead-of-Bb SEMI-TONE 0) alt))
-                (cons name alt))))
+         (alt-semitones  (pitch-alteration-semitones pitch))
+        (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -2)))
+                 (cons 7 (+ (if B-instead-of-Bb 1 0) alt-semitones))
+                 (cons name alt-semitones))))
     (make-line-markup
      (list
       (make-simple-markup
        (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a)))
       (make-normal-size-super-markup
-       (accidental->markup (cdr n-a)))))))
+       (accidental->markup (/ (cdr n-a) 2)))))))
 
 (define-safe-public (note-name->german-markup pitch)
   (let* ((name (ly:pitch-notename pitch))
-        (alt (ly:pitch-alteration pitch))
-        (n-a (if (member (cons name alt) `((6 . ,FLAT) (6 . ,DOUBLE-FLAT)))
-                 (cons 7 (+ SEMI-TONE alt))
-                 (cons name alt))))
+        (alt-semitones (pitch-alteration-semitones pitch))
+        (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -2)))
+                 (cons 7 (+ 1 alt-semitones))
+                 (cons name alt-semitones))))
     (make-line-markup
      (list
       (string-append
        (list-ref '("c" "d" "e" "f" "g" "a" "h" "b") (car n-a))
        (if (or (equal? (car n-a) 2) (equal? (car n-a) 5))
-          (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (/ (cdr n-a) 2)))
-          (list-ref '("eses" "es" "" "is" "isis") (+ 2 (/ (cdr n-a) 2)))))))))
+          (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (cdr n-a)))
+          (list-ref '("eses" "es" "" "is" "isis") (+ 2 (cdr n-a)))))))))
 
 (define-public ((chord-name->italian-markup re-with-eacute) pitch)
   "Return pitch markup for PITCH, using italian/french note names.