]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #258
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 30 Jan 2007 01:03:21 +0000 (02:03 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 30 Jan 2007 01:03:21 +0000 (02:03 +0100)
Decrease length of notes preceding grace.

input/regression/midi-microtone-off.ly [new file with mode: 0644]
lily/include/audio-item.hh
lily/midi-item.cc
lily/midi-walker.cc
lily/note-performer.cc

diff --git a/input/regression/midi-microtone-off.ly b/input/regression/midi-microtone-off.ly
new file mode 100644 (file)
index 0000000..653b97f
--- /dev/null
@@ -0,0 +1,17 @@
+\header {
+
+  texidoc = "Microtonal shifts should be corrected before the start of
+  the next (possibly grace) note.  "
+}
+
+\version "2.10.14"
+
+\score
+{
+  
+  \relative  {
+    a geseh \acciaccatura a geseh
+  }
+
+  \midi {}
+}
index c02eba58c19cbe04b4f118956ec60c6bafb9729e..81939867f3c6463b0df5b4ec45013ece28a67638 100644 (file)
 #include "moment.hh"
 #include "pitch.hh"
 
-/**
-
-Any piece of audio information.  We need virtual constructors, let's
-try decentralised factory for specific audio implemenations.
-*/
 class Audio_item : public Audio_element
 {
 public:
index 3d2d67a38e6b56319516a4322d78ee35842ffb4f..9f9868c6a3f65b0102405d82fe2b24cc81e26fed 100644 (file)
@@ -201,9 +201,6 @@ Midi_note::to_string () const
   // print warning if fine tuning was needed, HJJ
   if (get_fine_tuning () != 0)
     {
-      warning (_f ("experimental: temporarily fine tuning (of %d cents) a channel.",
-                  get_fine_tuning ()));
-
       finetune = PITCH_WHEEL_CENTER;
       // Move pitch wheel to a shifted position.
       // The pitch wheel range (of 4 semitones) is multiplied by the cents.
@@ -217,7 +214,7 @@ Midi_note::to_string () const
 
   str += ::to_string ((char) status_byte);
   str += ::to_string ((char) (get_semitone_pitch () + c0_pitch_));
-  str += ::to_string ((char)dynamic_byte_);
+  str += ::to_string ((char) dynamic_byte_);
 
   return str;
 }
index cef858c92768ebacf1374fb6d8f9bddb418a6536..782c3e2932ea3d6cbf10066f43b82547746c064b 100644 (file)
@@ -70,6 +70,7 @@ void
 Midi_walker::do_start_note (Midi_note *note)
 {
   Audio_item *ptr = items_[index_];
+  assert (note->audio_ == ptr);
   int stop_ticks = int (moment_to_real (note->audio_->length_mom_) * Real (384 * 4))
     + ptr->audio_column_->ticks ();
 
@@ -114,9 +115,6 @@ Midi_walker::do_start_note (Midi_note *note)
     }
 }
 
-/**
-   Output note events for all notes which end before #max_mom#
-*/
 void
 Midi_walker::do_stop_notes (int max_ticks)
 {
index 12996b73c993bb545f408cedced0434e321e77bf..d6554bbdc8520a4ded490bd6c26a24b9420c4422 100644 (file)
@@ -15,9 +15,6 @@
 
 #include "translator.icc"
 
-/**
-   Convert evs to audio notes.
-*/
 class Note_performer : public Performer
 {
 public:
@@ -31,63 +28,83 @@ protected:
 private:
   vector<Stream_event*> note_evs_;
   vector<Audio_note*> notes_;
+
+
+  vector<Audio_note*> last_notes_;
+  Moment last_start_;
+  
 };
 
 void
 Note_performer::process_music ()
 {
-  if (note_evs_.size ())
+  if (!note_evs_.size ())
+    return;
+
+  Pitch transposing;
+  SCM prop = get_property ("instrumentTransposition");
+  if (unsmob_pitch (prop))
+    transposing = *unsmob_pitch (prop);
+
+  for (vsize i = 0; i < note_evs_.size (); i ++)
     {
-      Pitch transposing;
-      SCM prop = get_property ("instrumentTransposition");
-      if (unsmob_pitch (prop))
-       transposing = *unsmob_pitch (prop);
+      Stream_event *n = note_evs_[i];
+      SCM pit = n->get_property ("pitch");
 
-      while (note_evs_.size ())
+      if (Pitch *pitp = unsmob_pitch (pit))
        {
-         Stream_event *n = note_evs_.back ();
-         note_evs_.pop_back ();
-         SCM pit = n->get_property ("pitch");
+         SCM articulations = n->get_property ("articulations");
+         Stream_event *tie_event = 0;
+         for (SCM s = articulations;
+              !tie_event && scm_is_pair (s);
+              s = scm_cdr (s))
+           {
+             Stream_event *ev = unsmob_stream_event (scm_car (s));
+             if (!ev)
+               continue;
+         
+             if (ev->in_event_class ("tie-event"))
+               tie_event = ev;
+           }
 
-         if (Pitch *pitp = unsmob_pitch (pit))
+         Moment len = get_event_length (n);
+         if (now_mom ().grace_part_)
            {
-              SCM articulations = n->get_property ("articulations");
-              Stream_event *tie_event = 0;
-              for (SCM s = articulations;
-                   !tie_event && scm_is_pair (s);
-                   s = scm_cdr (s))
-                {
-                  Stream_event *ev = unsmob_stream_event (scm_car (s));
-                  if (!ev)
-                    continue;
+             len.grace_part_ = len.main_part_;
+             len.main_part_ = Rational (0);
+           }
          
-                  if (ev->in_event_class ("tie-event"))
-                    tie_event = ev;
-                }
+         Audio_note *p = new Audio_note (*pitp, len, 
+                                         tie_event, transposing.negated ());
+         Audio_element_info info (p, n);
+         announce_element (info);
+         notes_.push_back (p);
 
-             Moment len = get_event_length (n);
-             if (now_mom ().grace_part_)
+         /*
+           shorten previous note.
+          */
+         if (now_mom ().grace_part_)
+           {
+             if (last_start_.grace_part_ == Rational (0))
                {
-                 len.grace_part_ = len.main_part_;
-                 len.main_part_ = Rational (0);
+                 for (vsize i = 0; i < last_notes_.size (); i++)
+                   last_notes_[i]->length_mom_ += Moment (0,
+                                                          now_mom().grace_part_);
                }
-             
-             Audio_note *p = new Audio_note (*pitp, len, 
-                                              tie_event, transposing.negated ());
-             Audio_element_info info (p, n);
-             announce_element (info);
-             notes_.push_back (p);
            }
        }
-      note_evs_.clear ();
     }
 }
 
 void
 Note_performer::stop_translation_timestep ()
 {
-  // why don't grace notes show up here?
-  // --> grace notes effectively do not get delayed
+  if (note_evs_.size ())
+    {
+      last_notes_ = notes_;
+      last_start_ = now_mom ();
+    }
+
   notes_.clear ();
   note_evs_.clear ();
 }