]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/midi-walker.hh
release: 1.0.1
[lilypond.git] / lily / include / midi-walker.hh
index d99b6efe67c9ad3b365d855a2be506468db296c9..3be3395e621f2a75b9530708b4380a0788fdadb5 100644 (file)
 /*
   midi-walker.hh -- declare Midi_walker
 
-  (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen <jan@digicash.com>
-  */
-
-#ifndef MIDIWALKER_HH
-#define MIDIWALKER_HH
+  (c) 1996,  1997--1998 Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+                 Jan Nieuwenhuizen <janneke@gnu.org>
+ */
 
+#ifndef MIDI_WALKER_HH
+#define MIDI_WALKER_HH
 
+#include "proto.hh"
+#include "plist.hh"
+#include "pcursor.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<Performer*> perf_p_list_;
-    
-    Link_array<Performer_group_performer> group_l_arr_;
-    Link_array<Performer> 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<Moment, Midi_note_off*>
 {
-    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);
-    }
+    bool ignore_b_;
+    Midi_note_event();
 };
 
-class Voice_performer_group_performer : public Performer_group_performer {
-
-};
+int compare (Midi_note_event const& left, Midi_note_event const& right);
 
-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()  ))
-};
-
-class Voice_performer : 
-       public Performer_group_performer, public Interpreter 
+/**
+  walk audio and output midi
+  */
+class Midi_walker : public PCursor<Audio_item*> 
 {
-    
-};
+public:
+    Midi_walker (Audio_staff* audio_staff_l, Midi_track* midi_track_l);
+    ~Midi_walker();
 
-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_ );
-    }
-};
+    void process();
 
-#endif
+private:
+    void do_start_note (Midi_note* note_p);
+    void do_stop_notes (Moment now_mom);
+    void output_event (Moment now_mom, Midi_item* l);
 
-#endif // MIDIWALKER_HH
+    Midi_track* track_l_;
+    PQueue<Midi_note_event> stop_note_queue;
+    Moment last_mom_;
+};
 
 
+#endif // MIDI_WALKER_HH