I've found and patched two problems with the pitch bend tuning code: 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. I don't think either of these are registered issues. As I'm new with Git, the two issues are mixed in the two patches. Problem (1) is fixed in get_semitone_pitch(). It's just a question of rounding off the result. Everything else is for problem (2). Graham
>From d402cd356203205f4863ad35f67ae23ff3422a03 Mon Sep 17 00:00:00 2001 From: Graham Breed <gbr...@gmail.com> Date: Fri, 24 Jun 2011 00:12:52 +0100 Subject: [PATCH 1/2] Pitch bends of full precision centered on zero. --- configure.in | 2 +- lily/midi-item.cc | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index cf0178f..1ea0428 100644 --- a/configure.in +++ b/configure.in @@ -140,7 +140,7 @@ STEPMAKE_PYTHON_DEVEL(REQUIRED) STEPMAKE_PATH_PROG(GHOSTSCRIPT, gs, OPTIONAL, 8.60) -STEPMAKE_PATH_PROG(FONTFORGE, fontforge, REQUIRED, 20100501) +STEPMAKE_PATH_PROG(FONTFORGE, fontforge, REQUIRED, 20090923) STEPMAKE_PATH_PROG(FONTFORGE, fontforge, OPTIONAL, 20110222) STEPMAKE_PATH_PROG(T1ASM, t1asm, REQUIRED) diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 1fcb259..bbc4691 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,14 +191,14 @@ 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 () + return int (0.5 + double ((audio_->pitch_.tone_pitch () + audio_->transposing_.tone_pitch ()) * Rational (2))); } @@ -214,10 +212,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
>From 888b2f2ab042e0cd966f53a21e027a1d385ac818 Mon Sep 17 00:00:00 2001 From: Graham Breed <gbr...@gmail.com> Date: Fri, 24 Jun 2011 18:05:38 +0100 Subject: [PATCH 2/2] Small pitch bends correct and tested. Pitch bends are not rounded to cents. --- lily/midi-item.cc | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lily/midi-item.cc b/lily/midi-item.cc index bbc4691..02bdd7a 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -198,8 +198,9 @@ Midi_note::get_fine_tuning () const int Midi_note::get_semitone_pitch () const { - return int (0.5 + 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 (tune > 0)? int (tune + 0.5): int(tune - 0.5); } string -- 1.7.0.4
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel