2011/7/11 Neil Puttock <n.putt...@gmail.com>:
> 2011/7/11 Janek Warchoł <lemniskata.bernoull...@gmail.com>:
>> 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.
>
> Please don't push without adding a commit message.

Sorry, i didn't notice.
Attached is a nicely described patch.

cheers,
Janek
From a45197e23e54783f1a8009d6a8528971b3378f8e 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 bend tuning fixes

1) The pitch isn't always rounded to the nearest equally
tempered value, so the result looks strange in a sequencer,
and artifacts caused by the pitch bends are more severe.

2) The tuning is rounded to cents before the pitch bends
are calculated.  It may not be a big deal, but there's no
need for it, and the code's simpler calculating the bends
directly.
---
 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