]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 1976: Handle full rational pitch differences in fingering calculations.
authorDavid Kastrup <dak@gnu.org>
Sat, 15 Oct 2011 08:50:18 +0000 (10:50 +0200)
committerDavid Kastrup <dak@gnu.org>
Wed, 27 Jun 2012 05:42:27 +0000 (07:42 +0200)
Defines and uses ly:pitch-tones for rational pitch extraction.

lily/pitch-scheme.cc
scm/tablature.scm
scm/translation-functions.scm

index ad1753251f6c02265535daa261ef3401b5b8dccf..a188469fbd2fa4f02b404692512cc8900951ba69 100644 (file)
@@ -92,7 +92,7 @@ LY_DEFINE (ly_pitch_alteration, "ly:pitch-alteration",
   return ly_rational2scm (q);
 }
 
-LY_DEFINE (pitch_notename, "ly:pitch-notename",
+LY_DEFINE (ly_pitch_notename, "ly:pitch-notename",
            1, 0, 0, (SCM pp),
            "Extract the note name from pitch @var{pp}.")
 {
@@ -102,6 +102,16 @@ LY_DEFINE (pitch_notename, "ly:pitch-notename",
   return scm_from_int (q);
 }
 
+LY_DEFINE (ly_pitch_tones, "ly:pitch-tones",
+          1, 0, 0, (SCM pp),
+           "Calculate the number of tones of@tie{}@var{pp} from"
+           " middle@tie{}C as a rational number.")
+{
+  LY_ASSERT_SMOB (Pitch, pp, 1);
+  return ly_rational2scm (unsmob_pitch (pp)->tone_pitch ());
+}
+
+
 LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones",
            1, 0, 0, (SCM pp),
            "Calculate the number of quarter tones of@tie{}@var{pp} from"
index 2adaaa6ed6cc8c55e5f470e401087ebd8aecaba9..3304e24af78a4f9a5b5f4168037a264240cdce4b 100644 (file)
          (left-pitch (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch)))
 
-    (if (< (ly:pitch-semitones right-pitch) (ly:pitch-semitones left-pitch))
+    (if (< (ly:pitch-tones right-pitch) (ly:pitch-tones left-pitch))
         -0.75
         0.75)))
 
index 2dd8d2d92c8ac06aa1beee75fa124b32351eff4f..33acfbc7b42178a6f2c5ca585a989d73d6c27bdf 100644 (file)
@@ -286,7 +286,7 @@ along with @var{minimum-fret}, @var{maximum-stretch}, and
     (define (calc-fret pitch string tuning)
       "Calculate the fret to play @var{pitch} on @var{string} with
 @var{tuning}."
-      (- (ly:pitch-semitones pitch) (ly:pitch-semitones (list-ref tuning (1- string)))))
+      (* 2  (- (ly:pitch-tones pitch) (ly:pitch-tones (list-ref tuning (1- string))))))
 
     (define (note-pitch note)
       "Get the pitch (in semitones) from @var{note}."
@@ -342,6 +342,7 @@ notes?"
        (and (or (and (not restrain-open-strings)
                      (eq? fret 0))
                 (>= fret minimum-fret))
+            (integer? fret)
             (close-enough fret))))
 
     (define (open-string string pitch)
@@ -356,7 +357,10 @@ the current tuning?"
                                  tuning)))
        (if (< this-fret 0)
          (ly:warning (_ "Negative fret for pitch ~a on string ~a")
-                     (car pitch-entry) string))
+                     (car pitch-entry) string)
+         (if (not (integer? this-fret))
+             (ly:warning (_ "Missing fret for pitch ~a on string ~a")
+                         (car pitch-entry) string)))
        (delete-free-string string)
         (set! specified-frets (cons this-fret specified-frets))
         (list-set! string-fret-fingers
@@ -415,7 +419,7 @@ the current tuning?"
                            (ly:context-property context
                                                 'handleNegativeFrets
                                                 'recalculate)))
-                     (cond ((or (>= this-fret 0)
+                     (cond ((or (and (>= this-fret 0) (integer? this-fret))
                                 (eq? handle-negative 'include))
                              (set-fret! pitch-entry string finger))
                            ((eq? handle-negative 'recalculate)