13
0
livetrax/libs/surfaces/websockets/mixer.h

138 lines
3.3 KiB
C
Raw Normal View History

2020-02-20 07:12:36 -05:00
/*
* Copyright (C) 2020 Luciano Iam <oss@lucianoiam.com>
2020-02-20 07:12:36 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _ardour_surface_websockets_mixer_h_
#define _ardour_surface_websockets_mixer_h_
2020-02-20 07:12:36 -05:00
2020-08-29 16:41:47 -04:00
#include <glibmm/threads.h>
2020-02-20 07:12:36 -05:00
#include "component.h"
#include "typed_value.h"
namespace ArdourSurface {
class ArdourMixerNotFoundException : public std::runtime_error
{
2020-08-30 15:15:33 -04:00
public:
ArdourMixerNotFoundException (std::string const & what)
: std::runtime_error (what)
2020-08-30 15:15:33 -04:00
, _what (what)
{}
~ArdourMixerNotFoundException() throw() {}
const char* what() const throw() { return _what.c_str(); }
2020-08-30 15:15:33 -04:00
private:
std::string _what;
};
class ArdourMixerPlugin : public PBD::ScopedConnectionList
2020-02-20 07:12:36 -05:00
{
public:
ArdourMixerPlugin (boost::shared_ptr<ARDOUR::PluginInsert>);
2020-08-29 16:41:47 -04:00
~ArdourMixerPlugin ();
2020-02-20 07:12:36 -05:00
2020-09-05 07:12:04 -04:00
boost::shared_ptr<ARDOUR::PluginInsert> insert () const;
bool enabled () const;
void set_enabled (bool);
2020-08-29 16:41:47 -04:00
uint32_t param_count () const;
TypedValue param_value (uint32_t);
void set_param_value (uint32_t, TypedValue);
boost::shared_ptr<ARDOUR::AutomationControl> param_control (uint32_t) const;
static TypedValue param_value (boost::shared_ptr<ARDOUR::AutomationControl>);
private:
2020-09-05 07:12:04 -04:00
boost::shared_ptr<ARDOUR::PluginInsert> _insert;
};
class ArdourMixerStrip : public PBD::ScopedConnectionList
{
public:
2020-08-29 16:41:47 -04:00
ArdourMixerStrip (boost::shared_ptr<ARDOUR::Stripable>, PBD::EventLoop*);
~ArdourMixerStrip ();
2020-09-05 07:12:04 -04:00
boost::shared_ptr<ARDOUR::Stripable> stripable () const;
typedef std::map<uint32_t, boost::shared_ptr<ArdourMixerPlugin> > PluginMap;
PluginMap& plugins ();
ArdourMixerPlugin& plugin (uint32_t);
double gain () const;
void set_gain (double);
2020-02-20 07:12:36 -05:00
bool has_pan () const;
double pan () const;
void set_pan (double);
2020-02-20 07:12:36 -05:00
bool mute () const;
void set_mute (bool);
2020-02-20 07:12:36 -05:00
std::string name () const;
2020-02-20 07:12:36 -05:00
float meter_level_db () const;
2020-02-20 07:12:36 -05:00
static double to_db (double);
static double from_db (double);
2020-02-20 07:12:36 -05:00
2020-09-05 07:12:04 -04:00
static int to_velocity (double);
static double from_velocity (int);
private:
2020-09-05 07:12:04 -04:00
boost::shared_ptr<ARDOUR::Stripable> _stripable;
PluginMap _plugins;
2020-02-20 07:12:36 -05:00
2020-09-05 07:12:04 -04:00
bool is_midi () const;
void on_drop_plugin (uint32_t);
};
2020-02-20 07:12:36 -05:00
class ArdourMixer : public SurfaceComponent
{
public:
ArdourMixer (ArdourSurface::ArdourWebsockets& surface)
: SurfaceComponent (surface){};
virtual ~ArdourMixer (){};
int start ();
int stop ();
2020-02-20 07:12:36 -05:00
typedef std::map<uint32_t, boost::shared_ptr<ArdourMixerStrip> > StripMap;
StripMap& strips ();
ArdourMixerStrip& strip (uint32_t);
void on_drop_strip (uint32_t);
2020-02-20 07:12:36 -05:00
2020-08-29 16:41:47 -04:00
Glib::Threads::Mutex& mutex ();
private:
2020-08-29 16:41:47 -04:00
StripMap _strips;
Glib::Threads::Mutex _mutex;
2020-02-20 07:12:36 -05:00
};
} // namespace ArdourSurface
#endif // _ardour_surface_websockets_mixer_h_