X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fmidi-walker.hh;h=f23b7407e89aa8e59f05ff76fe3d307389e8e438;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=d99b6efe67c9ad3b365d855a2be506468db296c9;hpb=a2896b23ce12cc61e9cd4495324c9ca5551cb947;p=lilypond.git diff --git a/lily/include/midi-walker.hh b/lily/include/midi-walker.hh index d99b6efe67..f23b7407e8 100644 --- a/lily/include/midi-walker.hh +++ b/lily/include/midi-walker.hh @@ -1,101 +1,66 @@ /* - midi-walker.hh -- declare Midi_walker + This file is part of LilyPond, the GNU music typesetter. - (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen - */ + Copyright (C) 1996--2015 Han-Wen Nienhuys + Jan Nieuwenhuizen -#ifndef MIDIWALKER_HH -#define MIDIWALKER_HH + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -#include "lily-proto.hh" - -#if 0 + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . +*/ -/* - sketch. . . +#ifndef MIDI_WALKER_HH +#define MIDI_WALKER_HH - 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 ; - } - -}; +#include "pqueue.hh" +#include "lily-proto.hh" +#include "moment.hh" -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 { - + bool ignore_; + Midi_note_event (); }; -class Note_performer : public Performer { - Melodic_req * current_l_; - Moment switch_off_at_,switch_on_at_; +int compare (Midi_note_event const &left, Midi_note_event const &right); - - virtual void process_request() { - if (when() == switch_off_at_ ) - play_event( Note_event(current_l_->pitch() )) -}; - -class Voice_performer : - public Performer_group_performer, public Interpreter +/** + walk audio and output midi +*/ +class Midi_walker { - +public: + Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track, int start_tick); + ~Midi_walker (); + + void process (); + void operator ++(int); + bool ok () const; + void finalize (); + +private: + void do_start_note (Midi_note *note); + void do_stop_notes (int); + void output_event (int, Midi_item *l); + Midi_item *get_midi (Audio_item *); + Midi_track *track_; + bool percussion_; + bool merge_unisons_; + vsize index_; + vector items_; + PQueue stop_note_queue; + int last_tick_; + + vector midi_events_; }; -class Score_performer: - public Performer_group_performer, public Global_translator -{ - 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_ ); - } -}; - -#endif - -#endif // MIDIWALKER_HH - - +#endif // MIDI_WALKER_HH