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"
12 #include "midiwalker.hh"
13 #include "midiitem.hh"
14 #include "midistream.hh"
16 #include "staffcolumn.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
);
39 /** advance the track to #now#, output the item, and adjust current
42 Midi_walker::output_event(Midi_item
&i
, Moment now
)
44 Moment delta_t
= now
- last_moment_
;
45 last_moment_
+= delta_t
;
46 track_l_
->add(delta_t
, &i
);
50 Midi_walker::process_requests()
52 do_stop_notes(ptr()->when());
53 for ( int i
= 0; i
< ptr()->musicalreq_l_arr_
.size(); i
++ ) {
55 Rhythmic_req
*n
= ptr()->musicalreq_l_arr_
[i
]->rhythmic();
58 Note_req
* note_l
= n
->note();
62 Midi_note
note(note_l
, track_l_
->number_i_
, true);
63 stop_notes
.enter(note_l
, n
->duration() + ptr()->when() );
64 output_event(note
, ptr()->when());
68 Midi_walker::~Midi_walker()
70 do_stop_notes( last_moment_
+ Moment(10,1)); // ugh