Ardour  8.7-15-gadf511264b
frontier/tranzport/tranzport_control_protocol.h
Go to the documentation of this file.
1 
2 #ifndef ardour_tranzport_control_protocol_h
3 #define ardour_tranzport_control_protocol_h
4 
5 #include <vector>
6 
7 #include <sys/time.h>
8 #include <pthread.h>
9 #include <usb.h>
10 
11 #include <glibmm/threads.h>
12 
13 #include "ardour/types.h"
14 
16 
18 {
19  public:
22 
23  int set_active (bool yn);
24 
25  static bool probe ();
26 
27  XMLNode& get_state () const;
28  int set_state (const XMLNode&);
29 
30  private:
31  static const int VENDORID = 0x165b;
32  static const int PRODUCTID = 0x8101;
33  static const int READ_ENDPOINT = 0x81;
34  static const int WRITE_ENDPOINT = 0x02;
35  const static int STATUS_OFFLINE = 0xff;
36  const static int STATUS_ONLINE = 0x01;
37  const static uint8_t WheelDirectionThreshold = 0x3f;
38 
39  enum LightID {
47  };
48 
49  enum ButtonID {
50  ButtonBattery = 0x00004000,
51  ButtonBacklight = 0x00008000,
52  ButtonTrackLeft = 0x04000000,
53  ButtonTrackRight = 0x40000000,
54  ButtonTrackRec = 0x00040000,
55  ButtonTrackMute = 0x00400000,
56  ButtonTrackSolo = 0x00000400,
57  ButtonUndo = 0x80000000,
58  ButtonIn = 0x02000000,
59  ButtonOut = 0x20000000,
60  ButtonPunch = 0x00800000,
61  ButtonLoop = 0x00080000,
62  ButtonPrev = 0x00020000,
63  ButtonAdd = 0x00200000,
64  ButtonNext = 0x00000200,
65  ButtonRewind = 0x01000000,
66  ButtonFastForward = 0x10000000,
67  ButtonStop = 0x00010000,
68  ButtonPlay = 0x00100000,
69  ButtonRecord = 0x00000100,
70  ButtonShift = 0x08000000
71  };
72 
78  };
79 
80  enum WheelMode {
84  };
85 
86  // FIXME - look at gtk2_ardour for snap settings
87 
96  };
97 
98  enum DisplayMode {
106  };
107 
108  enum BlingMode {
115  };
116 
117  pthread_t thread;
118  uint32_t buttonmask;
119  uint32_t timeout;
120  uint32_t inflight;
121  uint8_t _datawheel;
122  uint8_t _device_status;
129  usb_dev_handle* udev;
130 
132 
133  Glib::Threads::Mutex update_lock;
134 
135  bool screen_invalid[2][20];
136  char screen_current[2][20];
137  char screen_pending[2][20];
138  char screen_flash[2][20];
139 
140  bool lights_invalid[7];
141  bool lights_current[7];
142  bool lights_pending[7];
143  bool lights_flash[7];
144 
145  uint32_t last_bars;
146  uint32_t last_beats;
147  uint32_t last_ticks;
148 
150  uint32_t last_hrs;
151  uint32_t last_mins;
152  uint32_t last_secs;
153  uint32_t last_samples;
156  uint32_t last_meter_fill;
159 
160  Glib::Mutex io_lock;
161 
162  int open ();
163  int read (uint8_t *buf,uint32_t timeout_override = 0);
164  int write (uint8_t* cmd, uint32_t timeout_override = 0);
165  int write_noretry (uint8_t* cmd, uint32_t timeout_override = 0);
166  int close ();
167  int save(char *name = "default");
168  int load(char *name = "default");
169  void print (int row, int col, const char* text);
170  void print_noretry (int row, int col, const char* text);
171 
172  int rtpriority_set(int priority = 52);
173  int rtpriority_unset(int priority = 0);
174 
175  int open_core (struct usb_device*);
176 
177  static void* _monitor_work (void* arg);
178  void* monitor_work ();
179 
180  int process (uint8_t *);
182  void invalidate();
183  int flush();
184  // bool isuptodate(); // think on this. It seems futile to update more than 30/sec
185 
186  // A screen is a cache of what should be on the lcd
187 
188  void screen_init();
192  void screen_clear();
193  // bool screen_isuptodate(); // think on this -
194 
195  // Commands to write to the lcd
196 
197  int lcd_init();
198  bool lcd_damage();
200 
201  bool lcd_damage(int row, int col = 0, int length = 20);
202  bool lcd_isdamaged(int row, int col = 0, int length = 20);
203 
204  int lcd_flush();
205  int lcd_write(uint8_t* cmd, uint32_t timeout_override = 0); // pedantic alias for write
206  void lcd_fill (uint8_t fill_char);
207  void lcd_clear ();
208  void lcd_print (int row, int col, const char* text);
209  void lcd_print_noretry (int row, int col, const char* text);
210 
211  // Commands to write to the lights
212  // FIXME - on some devices lights can have intensity and colors
213 
214  void lights_init();
217  void light_validate(LightID light);
220  int lights_write(uint8_t* cmd,uint32_t timeout_override = 0); // pedantic alias to write
221 
222  // a cache of what should be lit
223 
224  void lights_off ();
225  void lights_on ();
226  int light_set(LightID, bool offon = true);
229 
230  // some modes for the lights, should probably be renamed
231 
236 
242 
244  void normal_update ();
245 
249  void show_bbt (samplepos_t where);
250  void show_smpte (samplepos_t where);
252  void show_gain ();
253  void show_pan ();
254  void show_meter ();
255 
256  void datawheel ();
257  void scrub ();
258  void scroll ();
259  void shuttle ();
260  void config ();
261 
264 
266  void next_track ();
267  void prev_track ();
268  void step_gain_up ();
269  void step_gain_down ();
270  void step_pan_right ();
271  void step_pan_left ();
272 
273 
274  void button_event_battery_press (bool shifted);
275  void button_event_battery_release (bool shifted);
276  void button_event_backlight_press (bool shifted);
277  void button_event_backlight_release (bool shifted);
278  void button_event_trackleft_press (bool shifted);
279  void button_event_trackleft_release (bool shifted);
280  void button_event_trackright_press (bool shifted);
281  void button_event_trackright_release (bool shifted);
282  void button_event_trackrec_press (bool shifted);
283  void button_event_trackrec_release (bool shifted);
284  void button_event_trackmute_press (bool shifted);
285  void button_event_trackmute_release (bool shifted);
286  void button_event_tracksolo_press (bool shifted);
287  void button_event_tracksolo_release (bool shifted);
288  void button_event_undo_press (bool shifted);
289  void button_event_undo_release (bool shifted);
290  void button_event_in_press (bool shifted);
291  void button_event_in_release (bool shifted);
292  void button_event_out_press (bool shifted);
293  void button_event_out_release (bool shifted);
294  void button_event_punch_press (bool shifted);
295  void button_event_punch_release (bool shifted);
296  void button_event_loop_press (bool shifted);
297  void button_event_loop_release (bool shifted);
298  void button_event_prev_press (bool shifted);
299  void button_event_prev_release (bool shifted);
300  void button_event_add_press (bool shifted);
301  void button_event_add_release (bool shifted);
302  void button_event_next_press (bool shifted);
303  void button_event_next_release (bool shifted);
304  void button_event_rewind_press (bool shifted);
305  void button_event_rewind_release (bool shifted);
306  void button_event_fastforward_press (bool shifted);
307  void button_event_fastforward_release (bool shifted);
308  void button_event_stop_press (bool shifted);
309  void button_event_stop_release (bool shifted);
310  void button_event_play_press (bool shifted);
311  void button_event_play_release (bool shifted);
312  void button_event_record_press (bool shifted);
313  void button_event_record_release (bool shifted);
314 
315  // new api
316  void button_event_mute (bool pressed, bool shifted);
317 };
318 
319 
320 #endif // ardour_tranzport_control_protocol_h
virtual std::string name() const
bool lcd_damage(int row, int col=0, int length=20)
void lcd_fill(uint8_t fill_char)
int set_state(const XMLNode &)
void button_event_mute(bool pressed, bool shifted)
void button_event_backlight_release(bool shifted)
void button_event_add_release(bool shifted)
void button_event_out_release(bool shifted)
int light_set(LightID, bool offon=true)
void button_event_play_release(bool shifted)
void button_event_record_press(bool shifted)
void button_event_loop_release(bool shifted)
void button_event_in_release(bool shifted)
void button_event_next_release(bool shifted)
void lcd_print(int row, int col, const char *text)
void button_event_undo_press(bool shifted)
void button_event_trackmute_press(bool shifted)
void button_event_punch_press(bool shifted)
bool lcd_isdamaged(int row, int col=0, int length=20)
int load(char *name="default")
void button_event_trackright_release(bool shifted)
int lights_write(uint8_t *cmd, uint32_t timeout_override=0)
void button_event_trackmute_release(bool shifted)
void button_event_trackleft_release(bool shifted)
void button_event_undo_release(bool shifted)
void button_event_stop_press(bool shifted)
void print(int row, int col, const char *text)
void button_event_stop_release(bool shifted)
void show_smpte(samplepos_t where)
void button_event_fastforward_press(bool shifted)
void button_event_trackright_press(bool shifted)
void set_current_track(ARDOUR::Route *)
int rtpriority_unset(int priority=0)
void button_event_prev_release(bool shifted)
void button_event_trackrec_press(bool shifted)
int write_noretry(uint8_t *cmd, uint32_t timeout_override=0)
void light_validate(LightID light)
void button_event_punch_release(bool shifted)
int open_core(struct usb_device *)
void button_event_next_press(bool shifted)
void button_event_play_press(bool shifted)
int save(char *name="default")
int rtpriority_set(int priority=52)
void button_event_trackrec_release(bool shifted)
void button_event_tracksolo_release(bool shifted)
void button_event_rewind_release(bool shifted)
void lcd_print_noretry(int row, int col, const char *text)
void button_event_battery_press(bool shifted)
void print_noretry(int row, int col, const char *text)
XMLNode & get_state() const
TranzportControlProtocol(ARDOUR::Session &)
void button_event_backlight_press(bool shifted)
void light_invalidate(LightID light)
void button_event_fastforward_release(bool shifted)
int write(uint8_t *cmd, uint32_t timeout_override=0)
void show_bbt(samplepos_t where)
void button_event_battery_release(bool shifted)
void button_event_in_press(bool shifted)
int lcd_write(uint8_t *cmd, uint32_t timeout_override=0)
void button_event_out_press(bool shifted)
void button_event_tracksolo_press(bool shifted)
void button_event_record_release(bool shifted)
int process(uint8_t *)
virtual ~TranzportControlProtocol()
void button_event_trackleft_press(bool shifted)
void button_event_loop_press(bool shifted)
void button_event_rewind_press(bool shifted)
static void * _monitor_work(void *arg)
void button_event_add_press(bool shifted)
int read(uint8_t *buf, uint32_t timeout_override=0)
void button_event_prev_press(bool shifted)
Definition: xml++.h:114
PBD::PropertyDescriptor< timecnt_t > length
Temporal::samplepos_t samplepos_t