]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/midi-walker.hh
8ea8b27b6442b73829c9b68f9e4d2b8a862e11f5
[lilypond.git] / lily / include / midi-walker.hh
1 /*
2   midi-walker.hh -- declare Midi_walker
3
4   (c) 1996--2007 Han-Wen Nienhuys  <hanwen@xs4all.nl>
5   Jan Nieuwenhuizen <janneke@gnu.org>
6 */
7
8 #ifndef MIDI_WALKER_HH
9 #define MIDI_WALKER_HH
10
11 #include "pqueue.hh"
12 #include "lily-proto.hh"
13 #include "moment.hh"
14
15 struct Midi_note_event : PQueue_ent<int, Midi_note *>
16 {
17   bool ignore_;
18   Midi_note_event ();
19 };
20
21 int compare (Midi_note_event const &left, Midi_note_event const &right);
22
23 /**
24    walk audio and output midi
25 */
26 class Midi_walker
27 {
28 public:
29   Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track,
30                int channel);
31   ~Midi_walker ();
32
33   void process ();
34   void operator ++ (int);
35   bool ok () const;
36   void finalize ();
37 private:
38   void do_start_note (Midi_note *note);
39   void do_stop_notes (int);
40   void output_event (int, Midi_item *l);
41   Midi_item *get_midi (Audio_item*); 
42   int channel_;
43   Midi_track *track_;
44   Audio_staff *staff_;
45   vsize index_;
46   vector<Audio_item*> items_;
47   PQueue<Midi_note_event> stop_note_queue;
48   int last_tick_;
49
50   vector<Midi_item*> midi_events_;
51 };
52
53 #endif // MIDI_WALKER_HH