Ardour  8.7-14-g57a6773833
maschine2.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_maschine2_h_
20 #define _ardour_surfaces_maschine2_h_
21 
22 #ifdef PLATFORM_WINDOWS
23 #include <windows.h>
24 #endif
25 
26 #include <hidapi.h>
27 
28 #define ABSTRACT_UI_EXPORTS
29 #include "pbd/abstract_ui.h"
30 #include "ardour/types.h"
31 #include "ardour/port.h"
33 
34 namespace MIDI {
35  class Port;
36 }
37 
38 namespace ArdourSurface {
39 
40 class M2Contols;
41 class M2Device;
42 class Maschine2Canvas;
43 class Maschine2Layout;
44 
45 class Maschine2Exception : public std::exception
46 {
47  public:
48  Maschine2Exception (const std::string& msg) : _msg (msg) { }
49  virtual ~Maschine2Exception () throw () {}
50  const char* what () const throw () { return _msg.c_str (); }
51  private:
52  std::string _msg;
53 };
54 
55 struct Maschine2Request : public BaseUI::BaseRequestObject {
56  public:
59 };
60 
61 class Maschine2: public ARDOUR::ControlProtocol, public AbstractUI<Maschine2Request>
62 {
63  public:
66 
67  static bool available ();
68 
69 #if 0
70  bool has_editor () const { return false; }
71  void* get_gui () const;
72  void tear_down_gui ();
73 #endif
74 
75  int set_active (bool yn);
76  XMLNode& get_state () const;
77  int set_state (const XMLNode & node, int version);
78 
79  Maschine2Canvas* canvas () const { return _canvas; }
81 
82  typedef enum {
85  Studio
87 
89 
90  private:
92 
93  int start ();
94  int stop ();
95 
96  void thread_init ();
97  void run_event_loop ();
98  void stop_event_loop ();
99 
100  sigc::connection read_connection;
101  sigc::connection write_connection;
102 
103  bool dev_write ();
104  bool dev_read ();
105 
106  hid_device* _handle;
110 
112 
115 
118 
119 
120  /* Master Mode */
121  enum MasterMode {
124  MST_TEMPO
126 
129 
130  /* PAD Port */
131  std::shared_ptr<ARDOUR::Port> _midi_out;
133 
134  /* callbacks */
138  void notify_parameter_changed (std::string);
142 
143  void button_play ();
144  void button_record ();
145  void button_loop ();
147  void button_rewind ();
148 
149  void button_action (const std::string&, const std::string&);
150 
153  void button_snap_changed (bool);
154 
155  void encoder_master (int);
156  void button_encoder ();
157 
158  void pad_event (unsigned int, float, bool);
159  void pad_change (unsigned int, float);
160 };
161 
162 } /* namespace */
163 #endif /* _ardour_surfaces_maschine2_h_*/
virtual bool has_editor() const
virtual void * get_gui() const
virtual void tear_down_gui()
Maschine2Exception(const std::string &msg)
Definition: maschine2.h:48
const char * what() const
Definition: maschine2.h:50
void pad_change(unsigned int, float)
enum ArdourSurface::Maschine2::MasterMode _master_state
void do_request(Maschine2Request *)
void notify_parameter_changed(std::string)
sigc::connection read_connection
Definition: maschine2.h:100
Maschine2Layout * current_layout() const
PBD::ScopedConnectionList button_connections
Definition: maschine2.h:114
Maschine2(ARDOUR::Session &)
int set_state(const XMLNode &node, int version)
void button_action(const std::string &, const std::string &)
XMLNode & get_state() const
Maschine2Canvas * canvas() const
Definition: maschine2.h:79
void stripable_selection_changed()
Definition: maschine2.h:117
sigc::connection write_connection
Definition: maschine2.h:101
void handle_master_change(enum MasterMode)
MIDI::Port * _output_port
Definition: maschine2.h:132
hid_device * _handle
Definition: maschine2.h:106
Maschine2Type _maschine_type
Definition: maschine2.h:111
PBD::ScopedConnectionList session_connections
Definition: maschine2.h:113
std::shared_ptr< ARDOUR::Port > _midi_out
Definition: maschine2.h:131
Maschine2Canvas * _canvas
Definition: maschine2.h:109
void pad_event(unsigned int, float, bool)
void button_snap_changed(bool)
Definition: xml++.h:114