]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/midi-walker.cc
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / midi-walker.cc
index 57e5ac499390b7de56901e2f661e46bd3a729749..8a315d6f2cd828aa6e2bed921aba05a13b474f99 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -33,8 +33,10 @@ compare (Midi_note_event const &left, Midi_note_event const &right)
     return 0;
 }
 
-Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track)
+Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track,
+                         int channel)
 {
+  channel_ = channel;
   track_ = track;
   index_ = 0;
   items_ = &audio_staff->audio_items_;
@@ -55,13 +57,13 @@ void
 Midi_walker::do_start_note (Midi_note *note)
 {
   Audio_item *ptr = (*items_)[index_];
-  Moment stop_mom = note->get_length () + ptr->audio_column_->at_mom ();
+  Moment stop_mom = note->get_length () + ptr->audio_column_->when ();
 
   bool play_start = true;
-  for (int i = 0; i < stop_note_queue.size (); i++)
+  for (vsize i = 0; i < stop_note_queue.size (); i++)
     {
       /* if this pith already in queue */
-      if (stop_note_queue[i].val->get_pitch () == note->get_pitch ())
+      if (stop_note_queue[i].val->get_semitone_pitch () == note->get_semitone_pitch ())
        {
          if (stop_note_queue[i].key < stop_mom)
            {
@@ -91,7 +93,7 @@ Midi_walker::do_start_note (Midi_note *note)
       stop_note_queue.insert (e);
 
       if (play_start)
-       output_event (ptr->audio_column_->at_mom (), note);
+       output_event (ptr->audio_column_->when (), note);
     }
 }
 
@@ -131,9 +133,7 @@ Midi_walker::output_event (Moment now_mom, Midi_item *l)
     start with graces
   */
   if (delta_t < Moment (0))
-    {
-      delta_t = Moment (0);
-    }
+    delta_t = Moment (0);
 
   track_->add (delta_t, l);
 }
@@ -142,11 +142,13 @@ void
 Midi_walker::process ()
 {
   Audio_item *audio = (*items_)[index_];
-  do_stop_notes (audio->audio_column_->at_mom ());
+  do_stop_notes (audio->audio_column_->when ());
 
   if (Midi_item *midi = Midi_item::get_midi (audio))
     {
-      midi->channel_ = track_->channel_;
+      if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (midi))
+       mci->channel_ = channel_;
+      
       //midi->channel_ = track_->number_;
       if (Midi_note *note = dynamic_cast<Midi_note *> (midi))
        {
@@ -154,7 +156,7 @@ Midi_walker::process ()
            do_start_note (note);
        }
       else
-       output_event (audio->audio_column_->at_mom (), midi);
+       output_event (audio->audio_column_->when (), midi);
     }
 }