X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fmidi-walker.hh;h=040cb6fa573ecac3890788868502b1bdeade12db;hb=fce447b68f92a29ba4a94f45fb134c15b90ae121;hp=d99b6efe67c9ad3b365d855a2be506468db296c9;hpb=a2896b23ce12cc61e9cd4495324c9ca5551cb947;p=lilypond.git diff --git a/lily/include/midi-walker.hh b/lily/include/midi-walker.hh index d99b6efe67..040cb6fa57 100644 --- a/lily/include/midi-walker.hh +++ b/lily/include/midi-walker.hh @@ -1,101 +1,50 @@ /* midi-walker.hh -- declare Midi_walker - (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen - */ - -#ifndef MIDIWALKER_HH -#define MIDIWALKER_HH + (c) 1996--2004 Han-Wen Nienhuys + Jan Nieuwenhuizen + */ +#ifndef MIDI_WALKER_HH +#define MIDI_WALKER_HH +#include "pqueue.hh" #include "lily-proto.hh" +#include "moment.hh" -#if 0 - -/* - sketch. . . - - It would be totally cool to share code with the Engraver hierarchy, - but this is very tough i think. - - */ -class Performer { - Performer_group_performer * daddy_perf_l_; - - virtual bool try_request(Request*r) - { - return daddy_perf_l_->try_request(r); - } - virtual void play_event( Midi_item i ) { daddy_perf_l_->play_event (i ); } -}; - -class Performer_group_performer : public Performer, public Translator { - Pointer_list perf_p_list_; - - Link_array group_l_arr_; - Link_array nongroup_l_arr_; - - bool try_request(Request*r) - { - bool hebbes_b =false; - for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++) - hebbes_b =nongroup_l_arr_[i]->try_request(req_l); - if (!hebbes_b) - hebbes_b = daddy_grav_l_->try_request(req_l); - return hebbes_b ; - } - -}; - -class Staff_performer : public Performer_group_performer +struct Midi_note_event : PQueue_ent { - int midi_track_i_; - String instrument_str() { - return Translator::id_str_; - } - virtual void play_event ( Midi_item i) - { - i.track_i_ = midi_track_i_; - Performer::play_event(i); - } -}; - -class Voice_performer_group_performer : public Performer_group_performer { - -}; - -class Note_performer : public Performer { - Melodic_req * current_l_; - Moment switch_off_at_,switch_on_at_; - - - virtual void process_request() { - if (when() == switch_off_at_ ) - play_event( Note_event(current_l_->pitch() )) + bool ignore_b_; + Midi_note_event (); }; -class Voice_performer : - public Performer_group_performer, public Interpreter -{ - -}; +int compare (Midi_note_event const& left, Midi_note_event const& right); -class Score_performer: - public Performer_group_performer, public Global_translator +/** + walk audio and output midi + */ +class Midi_walker { - Midi_file * file_p_; - Moment prev_; - virtual void play_event(Midi_item i) - { - file_p_->output (i); - } - virtual void prepare(Moment m){ - file_p_->move ( m -prev_ ); - } +public: + Midi_walker (Audio_staff* audio_staff, Midi_track* midi_track); + ~Midi_walker (); + + void process (); + void operator ++ (int); + bool ok () const; + +private: + void do_start_note (Midi_note* note); + void do_stop_notes (Moment now_mom); + void output_event (Moment now_mom, Midi_item* l); + + Midi_track* track_; + Audio_staff* staff_; + int index_; + Link_array * items_; + PQueue stop_note_queue; + Moment last_mom_; }; -#endif - -#endif // MIDIWALKER_HH - +#endif // MIDI_WALKER_HH