Ardour  9.0-pre0-380-gbbdb6b0e63
m2device.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _ardour_surfaces_maschine2hardware_h_
20 #define _ardour_surfaces_maschine2hardware_h_
21 
22 #include <hidapi.h>
23 #include <cairomm/refptr.h>
24 #include <cairomm/surface.h>
25 #include "pbd/signals.h"
26 
27 #include <cmath>
28 
29 namespace ArdourSurface {
30 
31 class M2Contols;
32 
39 class M2Device
40 {
41  public:
43  : _splashcnt (0)
44  , _blink_counter (0)
45  , _blink_shade (0.f)
46  {}
47  virtual ~M2Device () {}
48 
49  virtual void clear (bool splash = false) {
50  if (splash) {
51  _splashcnt = 0;
52  } else {
54  }
55  _blink_counter = 0;
56  _blink_shade = 0.f;
57  }
58 
59  virtual void read (hid_device*, M2Contols*) = 0;
60  virtual void write (hid_device*, M2Contols*) = 0;
61  virtual Cairo::RefPtr<Cairo::ImageSurface> surface () = 0;
62 
64 
65  protected:
66  void bump_blink () {
67  _blink_counter = (_blink_counter + 1) % 12;
68  _blink_shade = std::fabsf (1.f - _blink_counter / 6.f);
69  }
70 
71  uint32_t _splashcnt;
72  static const uint32_t _splashtime = 25 * 3;
73  unsigned int _blink_counter;
74  float _blink_shade;
75 };
76 
77 } /* namespace */
78 #endif /* _ardour_surfaces_maschine2_h_*/
virtual void read(hid_device *, M2Contols *)=0
PBD::Signal< bool()> vblank
Definition: m2device.h:63
unsigned int _blink_counter
Definition: m2device.h:73
virtual Cairo::RefPtr< Cairo::ImageSurface > surface()=0
virtual void clear(bool splash=false)
Definition: m2device.h:49
static const uint32_t _splashtime
Definition: m2device.h:72
virtual void write(hid_device *, M2Contols *)=0