source file of the GNU LilyPond music typesetter
- (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "audio-column.hh"
#include "audio-staff.hh"
#include "midi-item.hh"
+#include "midi-chunk.hh"
#include "midi-stream.hh"
#include "warn.hh"
Midi_walker::~Midi_walker ()
{
- do_stop_notes (INT_MAX);
+ junk_pointers (midi_events_);
}
+void
+Midi_walker::finalize ()
+{
+ do_stop_notes (INT_MAX);
+}
/**
Find out if start_note event is needed, and do it if needed.
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 ();
{
/* skip this stopnote,
don't play the start note */
- delete note;
note = 0;
break;
}
{
Midi_note_event e;
e.val = new Midi_note_off (note);
+
+ midi_events_.push_back (e.val);
e.key = int (stop_ticks);
stop_note_queue.insert (e);
}
}
-/**
- Output note events for all notes which end before #max_mom#
-*/
void
Midi_walker::do_stop_notes (int max_ticks)
{
Midi_note_event e = stop_note_queue.get ();
if (e.ignore_)
{
- delete e.val;
continue;
}
Audio_item *audio = items_[index_];
do_stop_notes (audio->audio_column_->ticks ());
- if (Midi_item *midi = Midi_item::get_midi (audio))
+ if (Midi_item *midi = get_midi (audio))
{
if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (midi))
mci->channel_ = channel_;
}
}
+Midi_item*
+Midi_walker::get_midi (Audio_item *i)
+{
+ Midi_item *mi = Midi_item::get_midi (i);
+ midi_events_.push_back (mi);
+ return mi;
+}
+
bool
Midi_walker::ok () const
{