diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2006-12-24 19:58:29 +0100 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2006-12-24 19:58:29 +0100 |
commit | a8c9b0b94722bcc493ecd121a6efddec6e5d879d (patch) | |
tree | 494df0f23e82fbacee4f23d15cc267ab7191ca33 | |
parent | e1679a36d8dcf7535bd5e91b9fae3609bf37a0b6 (diff) |
fix chord name accidentals. Add regtest.
-rw-r--r-- | input/regression/chord-names-languages.ly | 47 | ||||
-rw-r--r-- | scm/chord-name.scm | 28 |
2 files changed, 63 insertions, 12 deletions
diff --git a/input/regression/chord-names-languages.ly b/input/regression/chord-names-languages.ly new file mode 100644 index 0000000000..f1ca5b4a49 --- /dev/null +++ b/input/regression/chord-names-languages.ly @@ -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 } +>> diff --git a/scm/chord-name.scm b/scm/chord-name.scm index fe4ba7ab12..33f82c9501 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -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." @@ -50,36 +51,39 @@ (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. |