2011/7/11 Graham Breed <gbr...@gmail.com>:
> Is that me?  I'm supposed to do something?  Here's a patch

Perfect!

Mike: please push this.
Colin: sorry for overlooking that the countdown was over.  We
definately need an integrated patch/issue tracker!

cheers,
Janek
From 54d259942dd3a7d0c5461ca71b111796be2f59ec Mon Sep 17 00:00:00 2001
From: Graham Breed <gbr...@gmail.com>
Date: Fri, 24 Jun 2011 00:12:52 +0100
Subject: [PATCH] Pitch bends of full precision centered on zero.

---
 lily/midi-item.cc |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lily/midi-item.cc b/lily/midi-item.cc
index 1fcb259..aa96849 100644
--- a/lily/midi-item.cc
+++ b/lily/midi-item.cc
@@ -28,10 +28,8 @@
 #include "string-convert.hh"
 #include "warn.hh"
 
-#define PITCH_WHEEL_TOP 0x3FFF
 #define PITCH_WHEEL_CENTER 0x2000
-#define PITCH_WHEEL_BOTTOM 0x0000
-#define PITCH_WHEEL_RANGE (PITCH_WHEEL_TOP - PITCH_WHEEL_BOTTOM)
+#define PITCH_WHEEL_SEMITONE 0X1000
 
 Midi_item *
 Midi_item::get_midi (Audio_item *a)
@@ -193,15 +191,16 @@ Midi_note::get_fine_tuning () const
 		   + audio_->transposing_.tone_pitch ()) * Rational (2);
   tune -= Rational (get_semitone_pitch ());
 
-  tune *= 100;
+  tune *= PITCH_WHEEL_SEMITONE;
   return (int) double (tune);
 }
 
 int
 Midi_note::get_semitone_pitch () const
 {
-  return int (double ((audio_->pitch_.tone_pitch ()
-		       + audio_->transposing_.tone_pitch ()) * Rational (2)));
+  double tune = double ((audio_->pitch_.tone_pitch ()
+		         + audio_->transposing_.tone_pitch ()) * Rational (2));
+  return int (rint (tune));
 }
 
 string
@@ -214,10 +213,7 @@ Midi_note::to_string () const
   // print warning if fine tuning was needed, HJJ
   if (get_fine_tuning () != 0)
     {
-      finetune = PITCH_WHEEL_CENTER;
-      // Move pitch wheel to a shifted position.
-      // The pitch wheel range (of 4 semitones) is multiplied by the cents.
-      finetune += (PITCH_WHEEL_RANGE *get_fine_tuning ()) / (4 * 100);
+      finetune = PITCH_WHEEL_CENTER + get_fine_tuning ();
 
       str += ::to_string ((char) (0xE0 + channel_));
       str += ::to_string ((char) (finetune & 0x7F));
-- 
1.7.0.4

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to