add delta-time option to MIDI tracer window. note that its not incredibly accurate...
[ardour.git] / gtk2_ardour / midi_tracer.h
1 #ifndef __ardour_gtk_midi_tracer_h__
2 #define __ardour_gtk_midi_tracer_h__
3
4 #include <gtkmm/textview.h>
5 #include <gtkmm/scrolledwindow.h>
6 #include <gtkmm/togglebutton.h>
7 #include <gtkmm/adjustment.h>
8 #include <gtkmm/spinbutton.h>
9 #include <gtkmm/label.h>
10 #include <gtkmm/comboboxtext.h>
11 #include <gtkmm/box.h>
12
13 #include "pbd/signals.h"
14 #include "pbd/ringbuffer.h"
15 #include "pbd/pool.h"
16 #include "midi++/types.h"
17 #include "ardour_window.h"
18
19 namespace MIDI {
20         class Parser;
21 }
22
23 class MidiTracer : public ArdourWindow
24 {
25   public:
26         MidiTracer ();
27         ~MidiTracer();
28
29   private:
30         MIDI::Parser* parser;
31         Gtk::TextView text;
32         Gtk::ScrolledWindow scroller;
33         Gtk::Adjustment line_count_adjustment;
34         Gtk::SpinButton line_count_spinner;
35         Gtk::Label line_count_label;
36         Gtk::HBox line_count_box;
37         struct timeval _last_receipt;
38         
39         bool autoscroll;
40         bool show_hex;
41         bool collect;
42         bool show_delta_time;
43
44         /** Incremented when an update is requested, decremented when one is handled; hence
45          *  equal to 0 when an update is not queued.  May temporarily be negative if a
46          *  update is handled before it was noted that it had just been queued.
47          */
48         volatile gint _update_queued;
49
50         RingBuffer<char *> fifo;
51         Pool buffer_pool;
52         static const size_t buffer_size = 256;
53
54         void tracer (MIDI::Parser&, MIDI::byte*, size_t);
55         void update ();
56
57         Gtk::CheckButton autoscroll_button;
58         Gtk::CheckButton base_button;
59         Gtk::CheckButton collect_button;
60         Gtk::CheckButton delta_time_button;
61         Gtk::ComboBoxText _port_combo;
62
63         void base_toggle ();
64         void autoscroll_toggle ();
65         void collect_toggle ();
66         void delta_toggle ();
67
68         void port_changed ();
69         void ports_changed ();
70         void disconnect ();
71         PBD::ScopedConnection _parser_connection;
72         PBD::ScopedConnection _manager_connection;
73 };
74
75 #endif /* __ardour_gtk_midi_tracer_h__ */