Ardour  9.0-pre0-427-gd2a3450e2f
mixer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Luciano Iam <oss@lucianoiam.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 _ardour_surface_websockets_mixer_h_
20 #define _ardour_surface_websockets_mixer_h_
21 
22 #include <glibmm/threads.h>
23 
24 #include "component.h"
25 #include "typed_value.h"
26 
27 namespace ArdourSurface {
28 
29 class ArdourMixerNotFoundException : public std::runtime_error
30 {
31 public:
32  ArdourMixerNotFoundException (std::string const & what)
33  : std::runtime_error (what)
34  , _what (what)
35  {}
36 
38 
39  const char* what() const throw() { return _what.c_str(); }
40 
41 private:
42  std::string _what;
43 };
44 
46 {
47 public:
48  ArdourMixerPlugin (std::shared_ptr<ARDOUR::PluginInsert>);
50 
51  std::shared_ptr<ARDOUR::PluginInsert> insert () const;
52 
53  bool enabled () const;
54  void set_enabled (bool);
55 
56  uint32_t param_count () const;
57  TypedValue param_value (uint32_t);
58  void set_param_value (uint32_t, TypedValue);
59 
60  std::shared_ptr<ARDOUR::AutomationControl> param_control (uint32_t) const;
61 
62  static TypedValue param_value (std::shared_ptr<ARDOUR::AutomationControl>);
63 
64 private:
65  std::shared_ptr<ARDOUR::PluginInsert> _insert;
66 };
67 
69 {
70 public:
71  ArdourMixerStrip (std::shared_ptr<ARDOUR::Stripable>, PBD::EventLoop*);
73 
74  std::shared_ptr<ARDOUR::Stripable> stripable () const;
75 
76  typedef std::map<uint32_t, std::shared_ptr<ArdourMixerPlugin> > PluginMap;
77 
80 
81  double gain () const;
82  void set_gain (double);
83 
84  bool has_pan () const;
85  double pan () const;
86  void set_pan (double);
87 
88  bool mute () const;
89  void set_mute (bool);
90 
91  std::string name () const;
92 
93  float meter_level_db () const;
94 
95  static double to_db (double);
96  static double from_db (double);
97 
98  static int to_velocity (double);
99  static double from_velocity (int);
100 
101 private:
102  std::shared_ptr<ARDOUR::Stripable> _stripable;
103 
105 
106  bool is_midi () const;
107 
108  void on_drop_plugin (uint32_t);
109 
110 };
111 
113 {
114 public:
116  : SurfaceComponent (surface){};
117  virtual ~ArdourMixer (){};
118 
119  int start ();
120  int stop ();
121 
122  typedef std::map<uint32_t, std::shared_ptr<ArdourMixerStrip> > StripMap;
123 
125  ArdourMixerStrip& strip (uint32_t);
126  void on_drop_strip (uint32_t);
127 
128  Glib::Threads::Mutex& mutex ();
129 
130 private:
132  Glib::Threads::Mutex _mutex;
133 };
134 
135 } // namespace ArdourSurface
136 
137 #endif // _ardour_surface_websockets_mixer_h_
ArdourMixerNotFoundException(std::string const &what)
Definition: mixer.h:32
TypedValue param_value(uint32_t)
ArdourMixerPlugin(std::shared_ptr< ARDOUR::PluginInsert >)
std::shared_ptr< ARDOUR::PluginInsert > _insert
Definition: mixer.h:65
static TypedValue param_value(std::shared_ptr< ARDOUR::AutomationControl >)
std::shared_ptr< ARDOUR::PluginInsert > insert() const
std::shared_ptr< ARDOUR::AutomationControl > param_control(uint32_t) const
void set_param_value(uint32_t, TypedValue)
static double from_db(double)
static double from_velocity(int)
ArdourMixerPlugin & plugin(uint32_t)
std::shared_ptr< ARDOUR::Stripable > _stripable
Definition: mixer.h:102
std::shared_ptr< ARDOUR::Stripable > stripable() const
static int to_velocity(double)
static double to_db(double)
std::map< uint32_t, std::shared_ptr< ArdourMixerPlugin > > PluginMap
Definition: mixer.h:76
ArdourMixerStrip(std::shared_ptr< ARDOUR::Stripable >, PBD::EventLoop *)
Glib::Threads::Mutex _mutex
Definition: mixer.h:132
void on_drop_strip(uint32_t)
ArdourMixer(ArdourSurface::ArdourWebsockets &surface)
Definition: mixer.h:115
ArdourMixerStrip & strip(uint32_t)
std::map< uint32_t, std::shared_ptr< ArdourMixerStrip > > StripMap
Definition: mixer.h:122
virtual ~ArdourMixer()
Definition: mixer.h:117
Glib::Threads::Mutex & mutex()