2 midiwalker.cc -- implement Midi_walker
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwenhuizen <jan@digicash.com>
9 #include "musicalrequest.hh"
13 #include "midiwalker.hh"
14 #include "midiitem.hh"
15 #include "midistream.hh"
18 Midi_walker::Midi_walker(Staff *st_l, Midi_track* track_l)
19 : PCursor<Staff_column*>(st_l->cols_)
26 Midi_walker::do_stop_notes(Moment max_moment)
28 while (stop_notes.size() && stop_notes.front_idx() <= max_moment) {
29 Moment stop_moment = stop_notes.front_idx();
30 Melodic_req * req_l = stop_notes.get();
32 Midi_note note(req_l, track_l_->number_i_, false);
34 Moment delta_t = stop_moment-last_moment_ ;
35 last_moment_ += delta_t;
36 track_l_->add(delta_t, ¬e );
41 Midi_walker::process_requests()
43 do_stop_notes(ptr()->when());
44 for ( int i = 0; i < ptr()->musicalreq_l_arr_.size(); i++ ) {
46 Rhythmic_req *n = ptr()->musicalreq_l_arr_[i]->rhythmic();
47 if ( !n || !(n->note() || n->rest()) )
50 Midi_note note(n->melodic(), track_l_->number_i_, true);
51 stop_notes.enter(n->melodic(), n->duration() + ptr()->when() );
53 track_l_->add(dt, ¬e);
57 Midi_walker::~Midi_walker()
59 do_stop_notes( last_moment_ + Moment(10,1)); // ugh