Ardour  8.7-14-g57a6773833
us2400/controls.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
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 __us2400_controls_h__
20 #define __us2400_controls_h__
21 
22 #include <map>
23 #include <vector>
24 #include <string>
25 #include <stdint.h>
26 
27 #include "pbd/controllable.h"
28 #include "pbd/signals.h"
29 
31 #include "midi_byte_array.h"
32 
33 namespace ARDOUR {
34  class AutomationControl;
35 }
36 
37 namespace Temporal {
38  class timepos_t;
39 }
40 
41 namespace ArdourSurface {
42 
43 namespace US2400 {
44 
45 class Strip;
46 class Group;
47 class Surface;
48 
49 class Control {
50 public:
51  Control (int id, std::string name, Group& group);
52  virtual ~Control() {}
53 
54  int id() const { return _id; }
55  const std::string & name() const { return _name; }
56  Group & group() const { return _group; }
57 
58  bool in_use () const;
59  void set_in_use (bool);
60 
61  // Keep track of the timeout so it can be updated with more incoming events
62  sigc::connection in_use_connection;
63 
64  virtual MidiByteArray zero() = 0;
65 
70 
71  std::shared_ptr<ARDOUR::AutomationControl> control () const { return normal_ac; }
72  virtual void set_control (std::shared_ptr<ARDOUR::AutomationControl>);
73  virtual void reset_control () { normal_ac.reset(); }
74 
75  virtual void mark_dirty() = 0;
76 
77  float get_value ();
79 
80  virtual void start_touch (Temporal::timepos_t const & when);
81  virtual void stop_touch (Temporal::timepos_t const & when);
82 
83  protected:
84  std::shared_ptr<ARDOUR::AutomationControl> normal_ac;
85 
86  private:
87  int _id; /* possibly device-dependent ID */
88  std::string _name;
90  bool _in_use;
91 };
92 
93 }
94 }
95 
96 std::ostream & operator << (std::ostream & os, const ArdourSurface::US2400::Control & control);
97 
98 #endif /* __us2400_controls_h__ */
virtual void set_control(std::shared_ptr< ARDOUR::AutomationControl >)
void set_value(float val, PBD::Controllable::GroupControlDisposition gcd=PBD::Controllable::UseGroup)
virtual void start_touch(Temporal::timepos_t const &when)
const std::string & name() const
std::shared_ptr< ARDOUR::AutomationControl > normal_ac
virtual void stop_touch(Temporal::timepos_t const &when)
virtual MidiByteArray zero()=0
std::shared_ptr< ARDOUR::AutomationControl > control() const
Control(int id, std::string name, Group &group)
sigc::connection in_use_connection
Temporal::timepos_t timepos_t
DebugBits US2400
std::ostream & operator<<(std::ostream &os, const ArdourSurface::US2400::Control &control)