]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 763 Fretboards don't transpose properly
authorCarl Sorensen <c_sorensen@byu.edu>
Sun, 15 Mar 2009 03:34:58 +0000 (21:34 -0600)
committerPatrick McCarty <pnorcks@gmail.com>
Fri, 17 Jul 2009 07:45:53 +0000 (00:45 -0700)
A transpose that took a chord out of the default octave broke the
default fretboards.

The code is now modified to look both an octave up and an octave down
from the given octave if no entry is found for the given octave.
(cherry picked from commit 9bf6dcaf6ca27f7141ec825bb3569de8a5090dbb)

Documentation/user/fretted-strings.itely
input/regression/predefined-fretboards-transpose.ly [new file with mode: 0644]
scm/music-functions.scm
scm/translation-functions.scm

index 2ca609be5800857257ddf75a5f0e5581e6611d46..cf2d5f02507e8f031875437a21d2b8fef40ba548 100644 (file)
@@ -880,17 +880,19 @@ mychords = \chordmode{
 @end lilypond
 
 Different fret diagrams for the same chord name can be stored using different
-octaves of pitches.
+octaves of pitches.  The different octave should be at least two octaves
+above or below the default octave, because the octaves above and  below the
+default octave are used for transposing fretboards.
 
 @lilypond[verbatim, ragged-right, quote]
 \include "predefined-guitar-fretboards.ly"
 
-\storePredefinedDiagram \chordmode {c'}
+\storePredefinedDiagram \chordmode {c''}
                         #guitar-tuning
                         #(offset-fret 2 (chord-shape 'bes guitar-tuning))
 
 mychords = \chordmode{
-  c1 c'
+  c1 c''
 }
 
 <<
@@ -930,15 +932,15 @@ marking lists.
 
 % add some new chords based on the power chord shape
 
-\storePredefinedDiagram \chordmode {f'}
+\storePredefinedDiagram \chordmode {f''}
                         #guitar-tuning
                         #(chord-shape 'powerf guitar-tuning) 
-\storePredefinedDiagram \chordmode {g'}
+\storePredefinedDiagram \chordmode {g''}
                         #guitar-tuning
                         #(offset-fret 2 (chord-shape 'powerf guitar-tuning))
 
 mychords = \chordmode{
-  f1 f' g g'
+  f1 f'' g g''
 }
 
 <<
diff --git a/input/regression/predefined-fretboards-transpose.ly b/input/regression/predefined-fretboards-transpose.ly
new file mode 100644 (file)
index 0000000..091c492
--- /dev/null
@@ -0,0 +1,27 @@
+\version "2.13.0"
+\header{
+
+  texidoc="
+Transposition by less than one octave up or down should not affect
+predefined fretboards.
+
+"
+}
+
+
+\include "predefined-guitar-fretboards.ly"
+
+myChords = \chordmode { c1 d }
+
+mySequence = {
+
+  \myChords
+  \transpose c c' {\myChords}
+  \transpose c c, { \myChords}
+}
+
+<<
+  \new ChordNames {\mySequence}
+  \new FretBoards {\mySequence}
+>>
+
index 42a08cc344c0ec8731d3c1f428f0d7a06a6a5c4b..233ce575c43aa5cac3262f42ebd1909b4465be07 100644 (file)
@@ -939,6 +939,16 @@ Syntax:
      (skip-as-needed x parser)
    )))
 
+;;;;;;;;;;
+;;; general purpose music functions
+
+(define (shift-octave pitch octave-shift)
+  (_i "Add @var{octave-shift} to the octave of @var{pitch}.")
+  (ly:make-pitch
+     (+ (ly:pitch-octave pitch) octave-shift)
+     (ly:pitch-notename pitch)
+     (ly:pitch-alteration pitch)))
+
 
 ;;;;;;;;;;;;;;;;;
 ;; lyrics
index 902da1287d3390fc0fdd757df6773ca1bfbecb48..eefa9c0806a3b18088219b88cf413e7bccf45e5f 100644 (file)
                      ))
                  string-frets)
        (vector->list desc)))
+    
+  (define (get-predefined-fretboard predefined-fret-table tuning pitches)
+;   (_i "Search through @var{predefined-fret-table} looking for a predefined
+;fretboard with a key of @var{(tuning . pitches)}.  The search will check
+;both up and down an octave in order to accomodate transposition of the
+;chords.")
+   (define (get-fretboard key)
+    (let ((hash-handle
+           (hash-get-handle predefined-fret-table key)))
+     (if hash-handle
+         (cdr hash-handle)  ; return table entry
+         '())))
+
+   (let ((test-fretboard (get-fretboard (cons tuning pitches))))
+    (if (not (null? test-fretboard))
+        test-fretboard
+        (let ((test-fretboard 
+               (get-fretboard
+                (cons tuning (map (lambda (x) (shift-octave x 1)) pitches)))))
+         (if (not (null? test-fretboard))
+             test-fretboard
+             (get-fretboard 
+              (cons tuning (map (lambda (x) (shift-octave x -1)) pitches))))))))
 
 ;; body.
   (let*
               (acons 'string-count (length tunings) details)))
     (set! (ly:grob-property grob 'dot-placement-list)
         (if predefined-frets
-            (let ((hash-handle 
-                    (hash-get-handle
+            (let ((predefined-fretboard 
+                    (get-predefined-fretboard
                       predefined-frets
-                      (cons tunings pitches))))
-              (if hash-handle 
-                  (cdr hash-handle)  ;found default diagram
+                      tunings
+                      pitches)))
+              (if (null? predefined-fretboard)
                   (string-frets->dot-placement 
-                        string-frets my-string-count)))
+                        string-frets my-string-count)  ;no predefined diagram
+                  predefined-fretboard)) ;found default diagram
             (string-frets->dot-placement string-frets my-string-count)))))
 
 (define-public (determine-frets-mf notes string-numbers