2 midi-walker.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"
12 #include "midi-walker.hh"
13 #include "midi-item.hh"
14 #include "midi-stream.hh"
16 #include "staff-column.hh"
18 Midi_walker::Midi_walker(Staff *st_l, Midi_track* track_l)
19 : PCursor<Staff_column*>(st_l->cols_)
26 output notestop events for all notes which end before #max_moment#
29 Midi_walker::do_stop_notes(Moment max_moment)
31 while (stop_notes.size() && stop_notes.front_idx() <= max_moment) {
32 Moment stop_moment = stop_notes.front_idx();
33 Melodic_req * req_l = stop_notes.get();
35 Midi_note note(req_l, track_l_->number_i_, false);
36 output_event(note, stop_moment);
40 Find out if start_note event is needed, and do it if needed.
43 Midi_walker::do_start_note(Note_req*note_l)
45 Moment stop=note_l->duration() + ptr()->when();
46 for(int i=0; i < stop_notes.size(); i++)
47 if (stop_notes.value_arr_[i]->melodic()->pitch() ==
49 if ( stop_notes.indices_arr_[i] < stop){
52 return ; // removing this gives a feature ( ${c2 c4}$ output correctly)
55 return; // skip the stop note
56 break;// do the stop note
59 stop_notes.enter(note_l, stop);
60 Midi_note note(note_l, track_l_->number_i_, true);
61 output_event(note, ptr()->when());
65 /** advance the track to #now#, output the item, and adjust current
68 Midi_walker::output_event(Midi_item &i, Moment now)
70 Moment delta_t = now - last_moment_ ;
71 last_moment_ += delta_t;
72 track_l_->add(delta_t, &i );
76 Midi_walker::process_requests()
78 do_stop_notes(ptr()->when());
79 for ( int i = 0; i < ptr()->musicalreq_l_arr_.size(); i++ ) {
81 Rhythmic_req *n = ptr()->musicalreq_l_arr_[i]->rhythmic();
84 Note_req * note_l = n->note();
87 do_start_note(note_l);
92 Midi_walker::~Midi_walker()
94 do_stop_notes( last_moment_ + Moment(10,1)); // ugh