mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
NO-OP: Re-indent websockets code
"Always use Tabstops for block-indent (the code must be formatted correctly with "[TAB] = N spaces" for any value of N). Use space only for alignment." - https://ardour.org/styleguide.html
This commit is contained in:
parent
224be91211
commit
5e3480ba8f
23 changed files with 1260 additions and 1217 deletions
|
|
@ -35,7 +35,7 @@ using namespace ArdourSurface;
|
||||||
#include "pbd/abstract_ui.cc" // instantiate template
|
#include "pbd/abstract_ui.cc" // instantiate template
|
||||||
|
|
||||||
ArdourWebsockets::ArdourWebsockets (Session& s)
|
ArdourWebsockets::ArdourWebsockets (Session& s)
|
||||||
: ControlProtocol (s, X_(SURFACE_NAME))
|
: ControlProtocol (s, X_ (SURFACE_NAME))
|
||||||
, AbstractUI<ArdourWebsocketsUIRequest> (name ())
|
, AbstractUI<ArdourWebsocketsUIRequest> (name ())
|
||||||
, _strips (*this)
|
, _strips (*this)
|
||||||
, _globals (*this)
|
, _globals (*this)
|
||||||
|
|
@ -52,7 +52,7 @@ ArdourWebsockets::ArdourWebsockets (Session& s)
|
||||||
|
|
||||||
ArdourWebsockets::~ArdourWebsockets ()
|
ArdourWebsockets::~ArdourWebsockets ()
|
||||||
{
|
{
|
||||||
stop();
|
stop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
@ -105,10 +105,10 @@ ArdourWebsockets::do_request (ArdourWebsocketsUIRequest* req)
|
||||||
int
|
int
|
||||||
ArdourWebsockets::start ()
|
ArdourWebsockets::start ()
|
||||||
{
|
{
|
||||||
// startup the event loop thread
|
/* startup the event loop thread */
|
||||||
BaseUI::run ();
|
BaseUI::run ();
|
||||||
|
|
||||||
for (std::vector<SurfaceComponent *>::iterator it = _components.begin ();
|
for (std::vector<SurfaceComponent*>::iterator it = _components.begin ();
|
||||||
it != _components.end (); ++it) {
|
it != _components.end (); ++it) {
|
||||||
int rc = (*it)->start ();
|
int rc = (*it)->start ();
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
|
@ -122,8 +122,9 @@ ArdourWebsockets::start ()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ArdourWebsockets::stop () {
|
ArdourWebsockets::stop ()
|
||||||
for (std::vector<SurfaceComponent *>::iterator it = _components.begin ();
|
{
|
||||||
|
for (std::vector<SurfaceComponent*>::iterator it = _components.begin ();
|
||||||
it != _components.end (); ++it) {
|
it != _components.end (); ++it) {
|
||||||
(*it)->stop ();
|
(*it)->stop ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,19 +33,19 @@
|
||||||
#include "control_protocol/control_protocol.h"
|
#include "control_protocol/control_protocol.h"
|
||||||
|
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "strips.h"
|
#include "dispatcher.h"
|
||||||
|
#include "feedback.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "feedback.h"
|
#include "strips.h"
|
||||||
#include "dispatcher.h"
|
|
||||||
|
|
||||||
#define SURFACE_NAME "WebSockets Server (Experimental)"
|
#define SURFACE_NAME "WebSockets Server (Experimental)"
|
||||||
#define SURFACE_ID "uri://ardour.org/surfaces/ardour_websockets:0"
|
#define SURFACE_ID "uri://ardour.org/surfaces/ardour_websockets:0"
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface
|
||||||
|
{
|
||||||
struct ArdourWebsocketsUIRequest : public BaseUI::BaseRequestObject {
|
struct ArdourWebsocketsUIRequest : public BaseUI::BaseRequestObject {
|
||||||
public:
|
public:
|
||||||
ArdourWebsocketsUIRequest () {}
|
ArdourWebsocketsUIRequest () {}
|
||||||
~ArdourWebsocketsUIRequest () {}
|
~ArdourWebsocketsUIRequest () {}
|
||||||
};
|
};
|
||||||
|
|
@ -53,8 +53,7 @@ struct ArdourWebsocketsUIRequest : public BaseUI::BaseRequestObject {
|
||||||
class ArdourWebsockets : public ARDOUR::ControlProtocol,
|
class ArdourWebsockets : public ARDOUR::ControlProtocol,
|
||||||
public AbstractUI<ArdourWebsocketsUIRequest>
|
public AbstractUI<ArdourWebsocketsUIRequest>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ArdourWebsockets (ARDOUR::Session&);
|
ArdourWebsockets (ARDOUR::Session&);
|
||||||
virtual ~ArdourWebsockets ();
|
virtual ~ArdourWebsockets ();
|
||||||
|
|
||||||
|
|
@ -62,37 +61,49 @@ class ArdourWebsockets : public ARDOUR::ControlProtocol,
|
||||||
|
|
||||||
int set_active (bool);
|
int set_active (bool);
|
||||||
|
|
||||||
ARDOUR::Session& ardour_session () { return *session; }
|
ARDOUR::Session& ardour_session ()
|
||||||
ArdourStrips& strips_component () { return _strips; }
|
{
|
||||||
ArdourGlobals& globals_component () { return _globals; }
|
return *session;
|
||||||
WebsocketsServer& server_component () { return _server; }
|
}
|
||||||
WebsocketsDispatcher& dispatcher_component () { return _dispatcher; }
|
ArdourStrips& strips_component ()
|
||||||
|
{
|
||||||
|
return _strips;
|
||||||
|
}
|
||||||
|
ArdourGlobals& globals_component ()
|
||||||
|
{
|
||||||
|
return _globals;
|
||||||
|
}
|
||||||
|
WebsocketsServer& server_component ()
|
||||||
|
{
|
||||||
|
return _server;
|
||||||
|
}
|
||||||
|
WebsocketsDispatcher& dispatcher_component ()
|
||||||
|
{
|
||||||
|
return _dispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
// ControlProtocol
|
/* ControlProtocol */
|
||||||
void stripable_selection_changed () {}
|
void stripable_selection_changed () {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/* BaseUI */
|
||||||
// BaseUI
|
|
||||||
void thread_init ();
|
void thread_init ();
|
||||||
|
|
||||||
// AbstractUI
|
/* AbstractUI */
|
||||||
void do_request (ArdourWebsocketsUIRequest*);
|
void do_request (ArdourWebsocketsUIRequest*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ArdourStrips _strips;
|
ArdourStrips _strips;
|
||||||
ArdourGlobals _globals;
|
ArdourGlobals _globals;
|
||||||
ArdourFeedback _feedback;
|
ArdourFeedback _feedback;
|
||||||
WebsocketsServer _server;
|
WebsocketsServer _server;
|
||||||
WebsocketsDispatcher _dispatcher;
|
WebsocketsDispatcher _dispatcher;
|
||||||
std::vector<SurfaceComponent *> _components;
|
std::vector<SurfaceComponent*> _components;
|
||||||
|
|
||||||
int start ();
|
int start ();
|
||||||
int stop ();
|
int stop ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace ArdourSurface
|
||||||
|
|
||||||
#endif // ardour_websockets_h
|
#endif // ardour_websockets_h
|
||||||
|
|
|
||||||
|
|
@ -22,37 +22,41 @@
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "state.h"
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "state.h"
|
||||||
|
|
||||||
typedef struct lws* Client;
|
typedef struct lws* Client;
|
||||||
typedef std::list<NodeStateMessage> ClientOutputBuffer;
|
typedef std::list<NodeStateMessage> ClientOutputBuffer;
|
||||||
|
|
||||||
class ClientContext
|
class ClientContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ClientContext (Client wsi)
|
||||||
|
: _wsi (wsi){};
|
||||||
|
virtual ~ClientContext (){};
|
||||||
|
|
||||||
ClientContext (Client wsi) : _wsi(wsi) {};
|
Client wsi () const
|
||||||
virtual ~ClientContext () {};
|
{
|
||||||
|
return _wsi;
|
||||||
Client wsi () const { return _wsi; }
|
}
|
||||||
|
|
||||||
bool has_state (const NodeState&);
|
bool has_state (const NodeState&);
|
||||||
void update_state (const NodeState&);
|
void update_state (const NodeState&);
|
||||||
|
|
||||||
ClientOutputBuffer& output_buf () { return _output_buf; }
|
ClientOutputBuffer& output_buf ()
|
||||||
|
{
|
||||||
|
return _output_buf;
|
||||||
|
}
|
||||||
|
|
||||||
std::string debug_str ();
|
std::string debug_str ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Client _wsi;
|
Client _wsi;
|
||||||
|
|
||||||
typedef boost::unordered_set<NodeState> ClientState;
|
typedef boost::unordered_set<NodeState> ClientState;
|
||||||
ClientState _state;
|
ClientState _state;
|
||||||
|
|
||||||
ClientOutputBuffer _output_buf;
|
ClientOutputBuffer _output_buf;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // client_context_h
|
#endif // client_context_h
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
PBD::EventLoop*
|
PBD::EventLoop*
|
||||||
SurfaceComponent::event_loop () const
|
SurfaceComponent::event_loop () const
|
||||||
{
|
{
|
||||||
return static_cast<PBD::EventLoop*>(&_surface);
|
return static_cast<PBD::EventLoop*> (&_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::RefPtr<Glib::MainLoop>
|
Glib::RefPtr<Glib::MainLoop>
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "pbd/event_loop.h"
|
#include "pbd/event_loop.h"
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface
|
||||||
class ArdourWebsockets;
|
{
|
||||||
|
class ArdourWebsockets;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArdourStrips;
|
class ArdourStrips;
|
||||||
|
|
@ -35,27 +36,31 @@ class WebsocketsDispatcher;
|
||||||
|
|
||||||
class SurfaceComponent
|
class SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
SurfaceComponent (ArdourSurface::ArdourWebsockets& surface)
|
||||||
|
: _surface (surface){};
|
||||||
|
|
||||||
SurfaceComponent (ArdourSurface::ArdourWebsockets& surface) : _surface (surface) {};
|
virtual ~SurfaceComponent (){};
|
||||||
|
|
||||||
virtual ~SurfaceComponent () {};
|
virtual int start ()
|
||||||
|
{
|
||||||
virtual int start () { return 0; }
|
return 0;
|
||||||
virtual int stop () { return 0; }
|
}
|
||||||
|
virtual int stop ()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
PBD::EventLoop* event_loop () const;
|
PBD::EventLoop* event_loop () const;
|
||||||
Glib::RefPtr<Glib::MainLoop> main_loop() const;
|
Glib::RefPtr<Glib::MainLoop> main_loop () const;
|
||||||
ARDOUR::Session& session () const;
|
ARDOUR::Session& session () const;
|
||||||
ArdourStrips& strips () const;
|
ArdourStrips& strips () const;
|
||||||
ArdourGlobals& globals () const;
|
ArdourGlobals& globals () const;
|
||||||
WebsocketsServer& server () const;
|
WebsocketsServer& server () const;
|
||||||
WebsocketsDispatcher& dispatcher () const;
|
WebsocketsDispatcher& dispatcher () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ArdourSurface::ArdourWebsockets& _surface;
|
ArdourSurface::ArdourWebsockets& _surface;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // surface_component_h
|
#endif // surface_component_h
|
||||||
|
|
|
||||||
|
|
@ -20,23 +20,22 @@
|
||||||
|
|
||||||
#include "ardour/plugin_insert.h"
|
#include "ardour/plugin_insert.h"
|
||||||
|
|
||||||
#include "dispatcher.h"
|
|
||||||
#include "ardour_websockets.h"
|
#include "ardour_websockets.h"
|
||||||
|
#include "dispatcher.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
#define NODE_METHOD_PAIR(x) (Node::x, &WebsocketsDispatcher::x ## _handler)
|
#define NODE_METHOD_PAIR(x) (Node::x, &WebsocketsDispatcher::x##_handler)
|
||||||
|
|
||||||
WebsocketsDispatcher::NodeMethodMap
|
WebsocketsDispatcher::NodeMethodMap
|
||||||
WebsocketsDispatcher::_node_to_method = boost::assign::map_list_of
|
WebsocketsDispatcher::_node_to_method = boost::assign::map_list_of
|
||||||
NODE_METHOD_PAIR(tempo)
|
NODE_METHOD_PAIR (tempo)
|
||||||
NODE_METHOD_PAIR(strip_gain)
|
NODE_METHOD_PAIR (strip_gain)
|
||||||
NODE_METHOD_PAIR(strip_pan)
|
NODE_METHOD_PAIR (strip_pan)
|
||||||
NODE_METHOD_PAIR(strip_mute)
|
NODE_METHOD_PAIR (strip_mute)
|
||||||
NODE_METHOD_PAIR(strip_plugin_enable)
|
NODE_METHOD_PAIR (strip_plugin_enable)
|
||||||
NODE_METHOD_PAIR(strip_plugin_param_value)
|
NODE_METHOD_PAIR (strip_plugin_param_value);
|
||||||
;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
||||||
|
|
@ -46,7 +45,7 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
||||||
try {
|
try {
|
||||||
(this->*it->second) (client, msg);
|
(this->*it->second) (client, msg);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what () << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +67,7 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||||
update (client, Node::strip_pan, strip_n, strips ().strip_pan (strip_n));
|
update (client, Node::strip_pan, strip_n, strips ().strip_pan (strip_n));
|
||||||
update (client, Node::strip_mute, strip_n, strips ().strip_mute (strip_n));
|
update (client, Node::strip_mute, strip_n, strips ().strip_mute (strip_n));
|
||||||
|
|
||||||
for (uint32_t plugin_n = 0 ; ; ++plugin_n) {
|
for (uint32_t plugin_n = 0;; ++plugin_n) {
|
||||||
boost::shared_ptr<PluginInsert> insert = strips ()
|
boost::shared_ptr<PluginInsert> insert = strips ()
|
||||||
.strip_plugin_insert (strip_n, plugin_n);
|
.strip_plugin_insert (strip_n, plugin_n);
|
||||||
if (!insert) {
|
if (!insert) {
|
||||||
|
|
@ -77,7 +76,7 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||||
|
|
||||||
boost::shared_ptr<Plugin> plugin = insert->plugin ();
|
boost::shared_ptr<Plugin> plugin = insert->plugin ();
|
||||||
update (client, Node::strip_plugin_desc, strip_n, plugin_n,
|
update (client, Node::strip_plugin_desc, strip_n, plugin_n,
|
||||||
static_cast<std::string>(plugin->name ()));
|
static_cast<std::string> (plugin->name ()));
|
||||||
|
|
||||||
update (client, Node::strip_plugin_enable, strip_n, plugin_n,
|
update (client, Node::strip_plugin_enable, strip_n, plugin_n,
|
||||||
strips ().strip_plugin_enabled (strip_n, plugin_n));
|
strips ().strip_plugin_enabled (strip_n, plugin_n));
|
||||||
|
|
@ -101,14 +100,14 @@ WebsocketsDispatcher::update_all_nodes (Client client)
|
||||||
ParameterDescriptor pd = a_ctrl->desc ();
|
ParameterDescriptor pd = a_ctrl->desc ();
|
||||||
|
|
||||||
if (pd.toggled) {
|
if (pd.toggled) {
|
||||||
val.push_back (std::string("b"));
|
val.push_back (std::string ("b"));
|
||||||
} else if (pd.enumeration || pd.integer_step) {
|
} else if (pd.enumeration || pd.integer_step) {
|
||||||
val.push_back (std::string("i"));
|
val.push_back (std::string ("i"));
|
||||||
val.push_back (pd.lower);
|
val.push_back (pd.lower);
|
||||||
val.push_back (pd.upper);
|
val.push_back (pd.upper);
|
||||||
val.push_back (pd.integer_step);
|
val.push_back (pd.integer_step);
|
||||||
} else {
|
} else {
|
||||||
val.push_back (std::string("d"));
|
val.push_back (std::string ("d"));
|
||||||
val.push_back (pd.lower);
|
val.push_back (pd.lower);
|
||||||
val.push_back (pd.upper);
|
val.push_back (pd.upper);
|
||||||
val.push_back (pd.logarithmic);
|
val.push_back (pd.logarithmic);
|
||||||
|
|
@ -153,7 +152,7 @@ WebsocketsDispatcher::strip_pan_handler (Client client, const NodeStateMessage&
|
||||||
if (msg.is_write ()) {
|
if (msg.is_write ()) {
|
||||||
strips ().set_strip_pan (strip_id, msg.state ().nth_val (0));
|
strips ().set_strip_pan (strip_id, msg.state ().nth_val (0));
|
||||||
} else {
|
} else {
|
||||||
update (client, Node::strip_pan, strip_id, strips ().strip_pan(strip_id));
|
update (client, Node::strip_pan, strip_id, strips ().strip_pan (strip_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,23 +21,21 @@
|
||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
#include "component.h"
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "component.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
class WebsocketsDispatcher : public SurfaceComponent
|
class WebsocketsDispatcher : public SurfaceComponent
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
public:
|
WebsocketsDispatcher (ArdourSurface::ArdourWebsockets& surface)
|
||||||
|
: SurfaceComponent (surface){};
|
||||||
WebsocketsDispatcher (ArdourSurface::ArdourWebsockets& surface) : SurfaceComponent (surface) {};
|
virtual ~WebsocketsDispatcher (){};
|
||||||
virtual ~WebsocketsDispatcher () {};
|
|
||||||
|
|
||||||
void dispatch (Client, const NodeStateMessage&);
|
void dispatch (Client, const NodeStateMessage&);
|
||||||
void update_all_nodes (Client);
|
void update_all_nodes (Client);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef void (WebsocketsDispatcher::*DispatcherMethod) (Client, const NodeStateMessage&);
|
typedef void (WebsocketsDispatcher::*DispatcherMethod) (Client, const NodeStateMessage&);
|
||||||
typedef boost::unordered_map<std::string, DispatcherMethod> NodeMethodMap;
|
typedef boost::unordered_map<std::string, DispatcherMethod> NodeMethodMap;
|
||||||
|
|
||||||
|
|
@ -55,7 +53,6 @@ class WebsocketsDispatcher : public SurfaceComponent
|
||||||
void update (Client, std::string, uint32_t, uint32_t, TypedValue);
|
void update (Client, std::string, uint32_t, uint32_t, TypedValue);
|
||||||
void update (Client, std::string, uint32_t, uint32_t, uint32_t, TypedValue);
|
void update (Client, std::string, uint32_t, uint32_t, uint32_t, TypedValue);
|
||||||
void update (Client, std::string, const AddressVector&, const ValueVector&);
|
void update (Client, std::string, const AddressVector&, const ValueVector&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // websockets_dispatcher_h
|
#endif // websockets_dispatcher_h
|
||||||
|
|
|
||||||
|
|
@ -16,46 +16,51 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ardour/meter.h"
|
||||||
|
#include "ardour/plugin_insert.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "ardour/tempo.h"
|
#include "ardour/tempo.h"
|
||||||
#include "ardour/plugin_insert.h"
|
|
||||||
#include "ardour/meter.h"
|
|
||||||
|
|
||||||
#include "feedback.h"
|
#include "feedback.h"
|
||||||
#include "strips.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "state.h"
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
#include "state.h"
|
||||||
|
#include "strips.h"
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
struct TempoObserver {
|
struct TempoObserver {
|
||||||
void operator() (ArdourFeedback* p) {
|
void operator() (ArdourFeedback* p)
|
||||||
|
{
|
||||||
p->update_all (Node::tempo, p->globals ().tempo ());
|
p->update_all (Node::tempo, p->globals ().tempo ());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StripGainObserver {
|
struct StripGainObserver {
|
||||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
void operator() (ArdourFeedback* p, uint32_t strip_n)
|
||||||
|
{
|
||||||
// fires multiple times (4x as of ardour 6.0)
|
// fires multiple times (4x as of ardour 6.0)
|
||||||
p->update_all (Node::strip_gain, strip_n, p->strips ().strip_gain (strip_n));
|
p->update_all (Node::strip_gain, strip_n, p->strips ().strip_gain (strip_n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StripPanObserver {
|
struct StripPanObserver {
|
||||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
void operator() (ArdourFeedback* p, uint32_t strip_n)
|
||||||
|
{
|
||||||
p->update_all (Node::strip_pan, strip_n, p->strips ().strip_pan (strip_n));
|
p->update_all (Node::strip_pan, strip_n, p->strips ().strip_pan (strip_n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StripMuteObserver {
|
struct StripMuteObserver {
|
||||||
void operator() (ArdourFeedback* p, uint32_t strip_n) {
|
void operator() (ArdourFeedback* p, uint32_t strip_n)
|
||||||
|
{
|
||||||
p->update_all (Node::strip_mute, strip_n, p->strips ().strip_mute (strip_n));
|
p->update_all (Node::strip_mute, strip_n, p->strips ().strip_mute (strip_n));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PluginBypassObserver {
|
struct PluginBypassObserver {
|
||||||
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n) {
|
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n)
|
||||||
|
{
|
||||||
p->update_all (Node::strip_plugin_enable, strip_n, plugin_n,
|
p->update_all (Node::strip_plugin_enable, strip_n, plugin_n,
|
||||||
p->strips ().strip_plugin_enabled (strip_n, plugin_n));
|
p->strips ().strip_plugin_enabled (strip_n, plugin_n));
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +68,8 @@ struct PluginBypassObserver {
|
||||||
|
|
||||||
struct PluginParamValueObserver {
|
struct PluginParamValueObserver {
|
||||||
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n,
|
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n,
|
||||||
uint32_t param_n, boost::shared_ptr<AutomationControl> control) {
|
uint32_t param_n, boost::shared_ptr<AutomationControl> control)
|
||||||
|
{
|
||||||
p->update_all (Node::strip_plugin_param_value, strip_n, plugin_n, param_n,
|
p->update_all (Node::strip_plugin_param_value, strip_n, plugin_n, param_n,
|
||||||
ArdourStrips::plugin_param_value (control));
|
ArdourStrips::plugin_param_value (control));
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +149,7 @@ ArdourFeedback::poll () const
|
||||||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||||
boost::shared_ptr<PeakMeter> meter = strip->peak_meter ();
|
boost::shared_ptr<PeakMeter> meter = strip->peak_meter ();
|
||||||
float db = meter ? meter->meter_level (0, MeterMCP) : -193;
|
float db = meter ? meter->meter_level (0, MeterMCP) : -193;
|
||||||
update_all (Node::strip_meter, strip_n, static_cast<double>(db));
|
update_all (Node::strip_meter, strip_n, static_cast<double> (db));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -180,7 +186,7 @@ ArdourFeedback::observe_strips ()
|
||||||
void
|
void
|
||||||
ArdourFeedback::observe_strip_plugins (uint32_t strip_n, boost::shared_ptr<ARDOUR::Stripable> strip)
|
ArdourFeedback::observe_strip_plugins (uint32_t strip_n, boost::shared_ptr<ARDOUR::Stripable> strip)
|
||||||
{
|
{
|
||||||
for (uint32_t plugin_n = 0 ; ; ++plugin_n) {
|
for (uint32_t plugin_n = 0;; ++plugin_n) {
|
||||||
boost::shared_ptr<PluginInsert> insert = strips ().strip_plugin_insert (strip_n, plugin_n);
|
boost::shared_ptr<PluginInsert> insert = strips ().strip_plugin_insert (strip_n, plugin_n);
|
||||||
if (!insert) {
|
if (!insert) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -215,6 +221,7 @@ ArdourFeedback::observe_strip_plugin_param_values (uint32_t strip_n,
|
||||||
|
|
||||||
control->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
control->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
|
||||||
boost::bind<void> (PluginParamValueObserver (), this, strip_n, plugin_n, param_n,
|
boost::bind<void> (PluginParamValueObserver (), this, strip_n, plugin_n, param_n,
|
||||||
control), event_loop ());
|
control),
|
||||||
|
event_loop ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,18 @@
|
||||||
#ifndef ardour_feedback_h
|
#ifndef ardour_feedback_h
|
||||||
#define ardour_feedback_h
|
#define ardour_feedback_h
|
||||||
|
|
||||||
#include <glibmm/main.h>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <glibmm/main.h>
|
||||||
|
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
|
|
||||||
class ArdourFeedback : public SurfaceComponent
|
class ArdourFeedback : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ArdourFeedback (ArdourSurface::ArdourWebsockets& surface)
|
||||||
ArdourFeedback (ArdourSurface::ArdourWebsockets& surface) : SurfaceComponent (surface) {};
|
: SurfaceComponent (surface){};
|
||||||
virtual ~ArdourFeedback () {};
|
virtual ~ArdourFeedback (){};
|
||||||
|
|
||||||
int start ();
|
int start ();
|
||||||
int stop ();
|
int stop ();
|
||||||
|
|
@ -40,8 +40,7 @@ class ArdourFeedback : public SurfaceComponent
|
||||||
void update_all (std::string, uint32_t, uint32_t, TypedValue) const;
|
void update_all (std::string, uint32_t, uint32_t, TypedValue) const;
|
||||||
void update_all (std::string, uint32_t, uint32_t, uint32_t, TypedValue) const;
|
void update_all (std::string, uint32_t, uint32_t, uint32_t, TypedValue) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Glib::Threads::Mutex _client_state_lock;
|
Glib::Threads::Mutex _client_state_lock;
|
||||||
PBD::ScopedConnectionList _signal_connections;
|
PBD::ScopedConnectionList _signal_connections;
|
||||||
sigc::connection _periodic_connection;
|
sigc::connection _periodic_connection;
|
||||||
|
|
@ -53,7 +52,6 @@ class ArdourFeedback : public SurfaceComponent
|
||||||
void observe_strip_plugins (uint32_t, boost::shared_ptr<ARDOUR::Stripable>);
|
void observe_strip_plugins (uint32_t, boost::shared_ptr<ARDOUR::Stripable>);
|
||||||
void observe_strip_plugin_param_values (uint32_t, uint32_t,
|
void observe_strip_plugin_param_values (uint32_t, uint32_t,
|
||||||
boost::shared_ptr<ARDOUR::PluginInsert>);
|
boost::shared_ptr<ARDOUR::PluginInsert>);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ardour_feedback_h
|
#endif // ardour_feedback_h
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,13 @@
|
||||||
|
|
||||||
class ArdourGlobals : public SurfaceComponent
|
class ArdourGlobals : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ArdourGlobals (ArdourSurface::ArdourWebsockets& surface)
|
||||||
ArdourGlobals (ArdourSurface::ArdourWebsockets& surface) : SurfaceComponent (surface) {};
|
: SurfaceComponent (surface){};
|
||||||
virtual ~ArdourGlobals () {};
|
virtual ~ArdourGlobals (){};
|
||||||
|
|
||||||
double tempo () const;
|
double tempo () const;
|
||||||
void set_tempo (double);
|
void set_tempo (double);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ardour_globals_h
|
#endif // ardour_globals_h
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ static ControlProtocolDescriptor ardour_websockets_descriptor = {
|
||||||
/*request_buffer_factory */ ardour_websockets_request_buffer_factory
|
/*request_buffer_factory */ ardour_websockets_request_buffer_factory
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () {
|
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor*
|
||||||
|
protocol_descriptor ()
|
||||||
|
{
|
||||||
return &ardour_websockets_descriptor;
|
return &ardour_websockets_descriptor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,18 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
#include <boost/property_tree/ptree.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
// JSON does not support Infinity or NaN
|
// JSON does not support Infinity or NaN
|
||||||
#define XSTR(s) STR(s)
|
#define XSTR(s) STR (s)
|
||||||
#define STR(s) #s
|
#define STR(s) #s
|
||||||
#define JSON_INF 1.0e+128
|
#define JSON_INF 1.0e+128
|
||||||
#define JSON_INF_STR XSTR(JSON_INF)
|
#define JSON_INF_STR XSTR (JSON_INF)
|
||||||
|
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
|
|
@ -42,12 +42,12 @@ NodeStateMessage::NodeStateMessage (const NodeState& state)
|
||||||
_write = state.n_val () > 0;
|
_write = state.n_val () > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeStateMessage::NodeStateMessage (void *buf, size_t len)
|
NodeStateMessage::NodeStateMessage (void* buf, size_t len)
|
||||||
: _valid (false)
|
: _valid (false)
|
||||||
, _write (false)
|
, _write (false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::string s (static_cast<char *>(buf), len);
|
std::string s (static_cast<char*> (buf), len);
|
||||||
|
|
||||||
std::istringstream is (s);
|
std::istringstream is (s);
|
||||||
pt::ptree root;
|
pt::ptree root;
|
||||||
|
|
@ -59,20 +59,19 @@ NodeStateMessage::NodeStateMessage (void *buf, size_t len)
|
||||||
|
|
||||||
for (pt::ptree::iterator it = addr.begin (); it != addr.end (); ++it) {
|
for (pt::ptree::iterator it = addr.begin (); it != addr.end (); ++it) {
|
||||||
// throws if datatype not uint32_t
|
// throws if datatype not uint32_t
|
||||||
_state.add_addr (boost::lexical_cast<uint32_t>(it->second.data ()));
|
_state.add_addr (boost::lexical_cast<uint32_t> (it->second.data ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pt::ptree val = root.get_child ("val", pt::ptree ());
|
pt::ptree val = root.get_child ("val", pt::ptree ());
|
||||||
|
|
||||||
for (pt::ptree::iterator it = val.begin (); it != val.end (); ++it) {
|
for (pt::ptree::iterator it = val.begin (); it != val.end (); ++it) {
|
||||||
|
|
||||||
std::string val = it->second.data ();
|
std::string val = it->second.data ();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_state.add_val (boost::lexical_cast<int>(val));
|
_state.add_val (boost::lexical_cast<int> (val));
|
||||||
} catch (const boost::bad_lexical_cast&) {
|
} catch (const boost::bad_lexical_cast&) {
|
||||||
try {
|
try {
|
||||||
double d = boost::lexical_cast<double>(val);
|
double d = boost::lexical_cast<double> (val);
|
||||||
if (d >= JSON_INF) {
|
if (d >= JSON_INF) {
|
||||||
d = std::numeric_limits<double>::infinity ();
|
d = std::numeric_limits<double>::infinity ();
|
||||||
} else if (d <= -JSON_INF) {
|
} else if (d <= -JSON_INF) {
|
||||||
|
|
@ -105,7 +104,7 @@ NodeStateMessage::NodeStateMessage (void *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
NodeStateMessage::serialize (void *buf, size_t len) const
|
NodeStateMessage::serialize (void* buf, size_t len) const
|
||||||
{
|
{
|
||||||
// boost json writes all values as strings, we do not want that
|
// boost json writes all values as strings, we do not want that
|
||||||
|
|
||||||
|
|
@ -150,13 +149,13 @@ NodeStateMessage::serialize (void *buf, size_t len) const
|
||||||
ss << "null";
|
ss << "null";
|
||||||
break;
|
break;
|
||||||
case TypedValue::Bool:
|
case TypedValue::Bool:
|
||||||
ss << (static_cast<bool>(val) ? "true" : "false");
|
ss << (static_cast<bool> (val) ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
case TypedValue::Int:
|
case TypedValue::Int:
|
||||||
ss << static_cast<int>(val);
|
ss << static_cast<int> (val);
|
||||||
break;
|
break;
|
||||||
case TypedValue::Double: {
|
case TypedValue::Double: {
|
||||||
double d = static_cast<double>(val);
|
double d = static_cast<double> (val);
|
||||||
if (d == std::numeric_limits<double>::infinity ()) {
|
if (d == std::numeric_limits<double>::infinity ()) {
|
||||||
ss << JSON_INF_STR;
|
ss << JSON_INF_STR;
|
||||||
} else if (d == -std::numeric_limits<double>::infinity ()) {
|
} else if (d == -std::numeric_limits<double>::infinity ()) {
|
||||||
|
|
@ -167,7 +166,7 @@ NodeStateMessage::serialize (void *buf, size_t len) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypedValue::String:
|
case TypedValue::String:
|
||||||
ss << '"' << static_cast<std::string>(val) << '"';
|
ss << '"' << static_cast<std::string> (val) << '"';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -180,7 +179,7 @@ NodeStateMessage::serialize (void *buf, size_t len) const
|
||||||
ss << '}';
|
ss << '}';
|
||||||
|
|
||||||
std::string s = ss.str ();
|
std::string s = ss.str ();
|
||||||
const char *cs = s.c_str ();
|
const char* cs = s.c_str ();
|
||||||
size_t cs_sz = strlen (cs);
|
size_t cs_sz = strlen (cs);
|
||||||
|
|
||||||
if (len < cs_sz) {
|
if (len < cs_sz) {
|
||||||
|
|
|
||||||
|
|
@ -23,23 +23,29 @@
|
||||||
|
|
||||||
class NodeStateMessage
|
class NodeStateMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NodeStateMessage (const NodeState& state);
|
NodeStateMessage (const NodeState& state);
|
||||||
NodeStateMessage (void *, size_t);
|
NodeStateMessage (void*, size_t);
|
||||||
|
|
||||||
size_t serialize (void *, size_t) const;
|
size_t serialize (void*, size_t) const;
|
||||||
|
|
||||||
bool is_valid () const { return _valid; }
|
bool is_valid () const
|
||||||
bool is_write () const { return _write; }
|
{
|
||||||
const NodeState& state () const { return _state; }
|
return _valid;
|
||||||
|
}
|
||||||
private:
|
bool is_write () const
|
||||||
|
{
|
||||||
|
return _write;
|
||||||
|
}
|
||||||
|
const NodeState& state () const
|
||||||
|
{
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
bool _valid;
|
bool _valid;
|
||||||
bool _write;
|
bool _write;
|
||||||
NodeState _state;
|
NodeState _state;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // websockets_message_h
|
#endif // websockets_message_h
|
||||||
|
|
|
||||||
|
|
@ -20,22 +20,22 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "server.h"
|
|
||||||
#include "dispatcher.h"
|
#include "dispatcher.h"
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
/* backport from libwebsockets 3.0,
|
/* backport from libwebsockets 3.0,
|
||||||
* allow to compile on GNU/Linux with libwebsockets 2.x
|
* allow to compile on GNU/Linux with libwebsockets 2.x
|
||||||
*/
|
*/
|
||||||
#ifndef PLATFORM_WINDOWS
|
#ifndef PLATFORM_WINDOWS
|
||||||
# ifndef LWS_POLLHUP
|
#ifndef LWS_POLLHUP
|
||||||
# define LWS_POLLHUP (POLLHUP|POLLERR)
|
#define LWS_POLLHUP (POLLHUP | POLLERR)
|
||||||
# endif
|
#endif
|
||||||
# ifndef LWS_POLLIN
|
#ifndef LWS_POLLIN
|
||||||
# define LWS_POLLIN (POLLIN)
|
#define LWS_POLLIN (POLLIN)
|
||||||
# endif
|
#endif
|
||||||
# ifndef LWS_POLLOUT
|
#ifndef LWS_POLLOUT
|
||||||
# define LWS_POLLOUT (POLLOUT)
|
#define LWS_POLLOUT (POLLOUT)
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Glib;
|
using namespace Glib;
|
||||||
|
|
@ -44,9 +44,9 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
||||||
: SurfaceComponent (surface)
|
: SurfaceComponent (surface)
|
||||||
, _lws_context (0)
|
, _lws_context (0)
|
||||||
{
|
{
|
||||||
// keep references to all config for libwebsockets 2
|
/* keep references to all config for libwebsockets 2 */
|
||||||
lws_protocols proto;
|
lws_protocols proto;
|
||||||
memset (&proto, 0, sizeof(lws_protocols));
|
memset (&proto, 0, sizeof (lws_protocols));
|
||||||
proto.name = "lws-ardour";
|
proto.name = "lws-ardour";
|
||||||
proto.callback = WebsocketsServer::lws_callback;
|
proto.callback = WebsocketsServer::lws_callback;
|
||||||
proto.per_session_data_size = 0;
|
proto.per_session_data_size = 0;
|
||||||
|
|
@ -57,9 +57,9 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
||||||
proto.tx_packet_size = 0;
|
proto.tx_packet_size = 0;
|
||||||
#endif
|
#endif
|
||||||
_lws_proto[0] = proto;
|
_lws_proto[0] = proto;
|
||||||
memset (&_lws_proto[1], 0, sizeof(lws_protocols));
|
memset (&_lws_proto[1], 0, sizeof (lws_protocols));
|
||||||
|
|
||||||
memset (&_lws_info, 0, sizeof(lws_context_creation_info));
|
memset (&_lws_info, 0, sizeof (lws_context_creation_info));
|
||||||
_lws_info.port = WEBSOCKET_LISTEN_PORT;
|
_lws_info.port = WEBSOCKET_LISTEN_PORT;
|
||||||
_lws_info.protocols = _lws_proto;
|
_lws_info.protocols = _lws_proto;
|
||||||
_lws_info.uid = -1;
|
_lws_info.uid = -1;
|
||||||
|
|
@ -77,17 +77,19 @@ WebsocketsServer::start ()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add_poll_fd() should have been called once during lws_create_context()
|
/* add_poll_fd() should have been called once during lws_create_context()
|
||||||
// if _fd_ctx is empty then LWS_CALLBACK_ADD_POLL_FD was not called
|
* if _fd_ctx is empty then LWS_CALLBACK_ADD_POLL_FD was not called
|
||||||
// this means libwesockets was not compiled with LWS_WITH_EXTERNAL_POLL
|
* this means libwesockets was not compiled with LWS_WITH_EXTERNAL_POLL
|
||||||
// - macos homebrew libwebsockets: disabled (3.2.2 as of Feb 2020)
|
* - macos homebrew libwebsockets: disabled (3.2.2 as of Feb 2020)
|
||||||
// - linux ubuntu libwebsockets-dev: enabled (2.0.3 as of Feb 2020) but
|
* - linux ubuntu libwebsockets-dev: enabled (2.0.3 as of Feb 2020) but
|
||||||
// #if defined(LWS_WITH_EXTERNAL_POLL) check is not reliable -- constant
|
* #if defined(LWS_WITH_EXTERNAL_POLL) check is not reliable -- constant
|
||||||
// missing from /usr/include/lws_config.h
|
* missing from /usr/include/lws_config.h
|
||||||
|
*/
|
||||||
|
|
||||||
if (_fd_ctx.empty ()) {
|
if (_fd_ctx.empty ()) {
|
||||||
PBD::error << "ArdourWebsockets: check your libwebsockets was compiled"
|
PBD::error << "ArdourWebsockets: check your libwebsockets was compiled"
|
||||||
" with LWS_WITH_EXTERNAL_POLL enabled" << endmsg;
|
" with LWS_WITH_EXTERNAL_POLL enabled"
|
||||||
|
<< endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,7 +126,7 @@ WebsocketsServer::update_client (Client wsi, const NodeState& state, bool force)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force || !it->second.has_state (state)) {
|
if (force || !it->second.has_state (state)) {
|
||||||
// write to client only if state was updated
|
/* write to client only if state was updated */
|
||||||
it->second.update_state (state);
|
it->second.update_state (state);
|
||||||
it->second.output_buf ().push_back (NodeStateMessage (state));
|
it->second.output_buf ().push_back (NodeStateMessage (state));
|
||||||
lws_callback_on_writable (wsi);
|
lws_callback_on_writable (wsi);
|
||||||
|
|
@ -140,9 +142,9 @@ WebsocketsServer::update_all_clients (const NodeState& state, bool force)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebsocketsServer::add_poll_fd (struct lws_pollargs *pa)
|
WebsocketsServer::add_poll_fd (struct lws_pollargs* pa)
|
||||||
{
|
{
|
||||||
// fd can be SOCKET or int depending platform
|
/* fd can be SOCKET or int depending platform */
|
||||||
lws_sockfd_type fd = pa->fd;
|
lws_sockfd_type fd = pa->fd;
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
|
@ -163,13 +165,13 @@ WebsocketsServer::add_poll_fd (struct lws_pollargs *pa)
|
||||||
ctx.lws_pfd = lws_pfd;
|
ctx.lws_pfd = lws_pfd;
|
||||||
ctx.g_channel = g_channel;
|
ctx.g_channel = g_channel;
|
||||||
ctx.rg_iosrc = rg_iosrc;
|
ctx.rg_iosrc = rg_iosrc;
|
||||||
ctx.wg_iosrc = Glib::RefPtr<Glib::IOSource>(0);
|
ctx.wg_iosrc = Glib::RefPtr<Glib::IOSource> (0);
|
||||||
|
|
||||||
_fd_ctx[fd] = ctx;
|
_fd_ctx[fd] = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebsocketsServer::mod_poll_fd (struct lws_pollargs *pa)
|
WebsocketsServer::mod_poll_fd (struct lws_pollargs* pa)
|
||||||
{
|
{
|
||||||
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (pa->fd);
|
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (pa->fd);
|
||||||
if (it == _fd_ctx.end ()) {
|
if (it == _fd_ctx.end ()) {
|
||||||
|
|
@ -179,13 +181,14 @@ WebsocketsServer::mod_poll_fd (struct lws_pollargs *pa)
|
||||||
it->second.lws_pfd.events = pa->events;
|
it->second.lws_pfd.events = pa->events;
|
||||||
|
|
||||||
if (pa->events & LWS_POLLOUT) {
|
if (pa->events & LWS_POLLOUT) {
|
||||||
// libwebsockets wants to write but cannot find a way to update
|
/* libwebsockets wants to write but cannot find a way to update
|
||||||
// an existing glib::iosource event flags using glibmm,
|
* an existing glib::iosource event flags using glibmm,
|
||||||
// create another iosource and set to IO_OUT, it will be destroyed
|
* create another iosource and set to IO_OUT, it will be destroyed
|
||||||
// after clearing POLLOUT (see 'else' body below)
|
* after clearing POLLOUT (see 'else' body below)
|
||||||
|
*/
|
||||||
|
|
||||||
if (it->second.wg_iosrc) {
|
if (it->second.wg_iosrc) {
|
||||||
// already polling for write
|
/* already polling for write */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,13 +199,13 @@ WebsocketsServer::mod_poll_fd (struct lws_pollargs *pa)
|
||||||
} else {
|
} else {
|
||||||
if (it->second.wg_iosrc) {
|
if (it->second.wg_iosrc) {
|
||||||
it->second.wg_iosrc->destroy ();
|
it->second.wg_iosrc->destroy ();
|
||||||
it->second.wg_iosrc = Glib::RefPtr<Glib::IOSource>(0);
|
it->second.wg_iosrc = Glib::RefPtr<Glib::IOSource> (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebsocketsServer::del_poll_fd (struct lws_pollargs *pa)
|
WebsocketsServer::del_poll_fd (struct lws_pollargs* pa)
|
||||||
{
|
{
|
||||||
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (pa->fd);
|
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (pa->fd);
|
||||||
if (it == _fd_ctx.end ()) {
|
if (it == _fd_ctx.end ()) {
|
||||||
|
|
@ -235,7 +238,7 @@ WebsocketsServer::del_client (Client wsi)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebsocketsServer::recv_client (Client wsi, void *buf, size_t len)
|
WebsocketsServer::recv_client (Client wsi, void* buf, size_t len)
|
||||||
{
|
{
|
||||||
NodeStateMessage msg (buf, len);
|
NodeStateMessage msg (buf, len);
|
||||||
if (!msg.is_valid ()) {
|
if (!msg.is_valid ()) {
|
||||||
|
|
@ -251,7 +254,7 @@ WebsocketsServer::recv_client (Client wsi, void *buf, size_t len)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid echo
|
/* avoid echo */
|
||||||
it->second.update_state (msg.state ());
|
it->second.update_state (msg.state ());
|
||||||
|
|
||||||
dispatcher ().dispatch (wsi, msg);
|
dispatcher ().dispatch (wsi, msg);
|
||||||
|
|
@ -270,7 +273,7 @@ WebsocketsServer::write_client (Client wsi)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// one lws_write() call per LWS_CALLBACK_SERVER_WRITEABLE callback
|
/* one lws_write() call per LWS_CALLBACK_SERVER_WRITEABLE callback */
|
||||||
|
|
||||||
NodeStateMessage msg = pending.front ();
|
NodeStateMessage msg = pending.front ();
|
||||||
pending.pop_front ();
|
pending.pop_front ();
|
||||||
|
|
@ -295,7 +298,7 @@ WebsocketsServer::write_client (Client wsi)
|
||||||
bool
|
bool
|
||||||
WebsocketsServer::io_handler (Glib::IOCondition ioc, lws_sockfd_type fd)
|
WebsocketsServer::io_handler (Glib::IOCondition ioc, lws_sockfd_type fd)
|
||||||
{
|
{
|
||||||
// IO_IN=1, IO_PRI=2, IO_ERR=8, IO_HUP=16
|
/* IO_IN=1, IO_PRI=2, IO_ERR=8, IO_HUP=16 */
|
||||||
//printf ("io_handler ioc = %d\n", ioc);
|
//printf ("io_handler ioc = %d\n", ioc);
|
||||||
|
|
||||||
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (fd);
|
LwsPollFdGlibSourceMap::iterator it = _fd_ctx.find (fd);
|
||||||
|
|
@ -303,7 +306,7 @@ WebsocketsServer::io_handler (Glib::IOCondition ioc, lws_sockfd_type fd)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct lws_pollfd *lws_pfd = &it->second.lws_pfd;
|
struct lws_pollfd* lws_pfd = &it->second.lws_pfd;
|
||||||
lws_pfd->revents = ioc_to_events (ioc);
|
lws_pfd->revents = ioc_to_events (ioc);
|
||||||
|
|
||||||
if (lws_service_fd (_lws_context, lws_pfd) < 0) {
|
if (lws_service_fd (_lws_context, lws_pfd) < 0) {
|
||||||
|
|
@ -350,23 +353,23 @@ WebsocketsServer::ioc_to_events (IOCondition ioc)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
WebsocketsServer::lws_callback(struct lws* wsi, enum lws_callback_reasons reason,
|
WebsocketsServer::lws_callback (struct lws* wsi, enum lws_callback_reasons reason,
|
||||||
void *user, void *in, size_t len)
|
void* user, void* in, size_t len)
|
||||||
{
|
{
|
||||||
void *ctx_userdata = lws_context_user (lws_get_context (wsi));
|
void* ctx_userdata = lws_context_user (lws_get_context (wsi));
|
||||||
WebsocketsServer *server = static_cast<WebsocketsServer *>(ctx_userdata);
|
WebsocketsServer* server = static_cast<WebsocketsServer*> (ctx_userdata);
|
||||||
|
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case LWS_CALLBACK_ADD_POLL_FD:
|
case LWS_CALLBACK_ADD_POLL_FD:
|
||||||
server->add_poll_fd (static_cast<struct lws_pollargs *>(in));
|
server->add_poll_fd (static_cast<struct lws_pollargs*> (in));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LWS_CALLBACK_CHANGE_MODE_POLL_FD:
|
case LWS_CALLBACK_CHANGE_MODE_POLL_FD:
|
||||||
server->mod_poll_fd (static_cast<struct lws_pollargs *>(in));
|
server->mod_poll_fd (static_cast<struct lws_pollargs*> (in));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LWS_CALLBACK_DEL_POLL_FD:
|
case LWS_CALLBACK_DEL_POLL_FD:
|
||||||
server->del_poll_fd (static_cast<struct lws_pollargs *>(in));
|
server->del_poll_fd (static_cast<struct lws_pollargs*> (in));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LWS_CALLBACK_ESTABLISHED:
|
case LWS_CALLBACK_ESTABLISHED:
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
#ifndef websockets_server_h
|
#ifndef websockets_server_h
|
||||||
#define websockets_server_h
|
#define websockets_server_h
|
||||||
|
|
||||||
|
#include <boost/unordered_map.hpp>
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <libwebsockets.h>
|
#include <libwebsockets.h>
|
||||||
#include <boost/unordered_map.hpp>
|
|
||||||
|
|
||||||
#if LWS_LIBRARY_VERSION_MAJOR < 3
|
#if LWS_LIBRARY_VERSION_MAJOR < 3
|
||||||
// <libwebsockets.h> includes <uv.h> which in turn includes
|
// <libwebsockets.h> includes <uv.h> which in turn includes
|
||||||
|
|
@ -34,10 +34,10 @@
|
||||||
// version 3 in order to keep things simpler for the end user
|
// version 3 in order to keep things simpler for the end user
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "component.h"
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "state.h"
|
#include "component.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "state.h"
|
||||||
|
|
||||||
#define WEBSOCKET_LISTEN_PORT 9000
|
#define WEBSOCKET_LISTEN_PORT 9000
|
||||||
|
|
||||||
|
|
@ -50,10 +50,9 @@ struct LwsPollFdGlibSource {
|
||||||
|
|
||||||
class WebsocketsServer : public SurfaceComponent
|
class WebsocketsServer : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WebsocketsServer (ArdourSurface::ArdourWebsockets&);
|
WebsocketsServer (ArdourSurface::ArdourWebsockets&);
|
||||||
virtual ~WebsocketsServer () {};
|
virtual ~WebsocketsServer (){};
|
||||||
|
|
||||||
int start ();
|
int start ();
|
||||||
int stop ();
|
int stop ();
|
||||||
|
|
@ -61,11 +60,10 @@ class WebsocketsServer : public SurfaceComponent
|
||||||
void update_client (Client, const NodeState&, bool);
|
void update_client (Client, const NodeState&, bool);
|
||||||
void update_all_clients (const NodeState&, bool);
|
void update_all_clients (const NodeState&, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct lws_protocols _lws_proto[2];
|
struct lws_protocols _lws_proto[2];
|
||||||
struct lws_context_creation_info _lws_info;
|
struct lws_context_creation_info _lws_info;
|
||||||
struct lws_context *_lws_context;
|
struct lws_context* _lws_context;
|
||||||
|
|
||||||
Glib::RefPtr<Glib::IOChannel> _channel;
|
Glib::RefPtr<Glib::IOChannel> _channel;
|
||||||
|
|
||||||
|
|
@ -81,7 +79,7 @@ class WebsocketsServer : public SurfaceComponent
|
||||||
|
|
||||||
void add_client (Client);
|
void add_client (Client);
|
||||||
void del_client (Client);
|
void del_client (Client);
|
||||||
void recv_client (Client, void *buf, size_t len);
|
void recv_client (Client, void* buf, size_t len);
|
||||||
void write_client (Client);
|
void write_client (Client);
|
||||||
|
|
||||||
bool io_handler (Glib::IOCondition, lws_sockfd_type);
|
bool io_handler (Glib::IOCondition, lws_sockfd_type);
|
||||||
|
|
@ -89,8 +87,7 @@ class WebsocketsServer : public SurfaceComponent
|
||||||
Glib::IOCondition events_to_ioc (int);
|
Glib::IOCondition events_to_ioc (int);
|
||||||
int ioc_to_events (Glib::IOCondition);
|
int ioc_to_events (Glib::IOCondition);
|
||||||
|
|
||||||
static int lws_callback(struct lws*, enum lws_callback_reasons, void *, void *, size_t);
|
static int lws_callback (struct lws*, enum lws_callback_reasons, void*, void*, size_t);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // websockets_server_h
|
#endif // websockets_server_h
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,24 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
NodeState::NodeState () { }
|
NodeState::NodeState () {}
|
||||||
|
|
||||||
NodeState::NodeState (std::string node)
|
NodeState::NodeState (std::string node)
|
||||||
: _node (node) { }
|
: _node (node)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NodeState::NodeState (std::string node, AddressVector addr, ValueVector val)
|
NodeState::NodeState (std::string node, AddressVector addr, ValueVector val)
|
||||||
: _node (node)
|
: _node (node)
|
||||||
, _addr (addr)
|
, _addr (addr)
|
||||||
, _val (val) { }
|
, _val (val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
NodeState::debug_str () const
|
NodeState::debug_str () const
|
||||||
|
|
@ -38,7 +42,8 @@ NodeState::debug_str () const
|
||||||
s << "node = " << _node;
|
s << "node = " << _node;
|
||||||
|
|
||||||
if (!_addr.empty ()) {
|
if (!_addr.empty ()) {
|
||||||
s << std::endl << " addr = ";
|
s << std::endl
|
||||||
|
<< " addr = ";
|
||||||
|
|
||||||
for (AddressVector::const_iterator it = _addr.begin (); it != _addr.end (); ++it) {
|
for (AddressVector::const_iterator it = _addr.begin (); it != _addr.end (); ++it) {
|
||||||
s << *it << ";";
|
s << *it << ";";
|
||||||
|
|
@ -46,7 +51,8 @@ NodeState::debug_str () const
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ValueVector::const_iterator it = _val.begin (); it != _val.end (); ++it) {
|
for (ValueVector::const_iterator it = _val.begin (); it != _val.end (); ++it) {
|
||||||
s << std::endl << " val " << it->debug_str ();
|
s << std::endl
|
||||||
|
<< " val " << it->debug_str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.str ();
|
return s.str ();
|
||||||
|
|
@ -55,7 +61,7 @@ NodeState::debug_str () const
|
||||||
int
|
int
|
||||||
NodeState::n_addr () const
|
NodeState::n_addr () const
|
||||||
{
|
{
|
||||||
return static_cast<int>(_addr.size ());
|
return static_cast<int> (_addr.size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
@ -73,7 +79,7 @@ NodeState::add_addr (uint32_t addr)
|
||||||
int
|
int
|
||||||
NodeState::n_val () const
|
NodeState::n_val () const
|
||||||
{
|
{
|
||||||
return static_cast<int>(_val.size ());
|
return static_cast<int> (_val.size ());
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedValue
|
TypedValue
|
||||||
|
|
@ -107,7 +113,8 @@ NodeState::operator== (const NodeState& other) const
|
||||||
return node_addr_hash () == other.node_addr_hash ();
|
return node_addr_hash () == other.node_addr_hash ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t hash_value (const NodeState &state)
|
std::size_t
|
||||||
|
hash_value (const NodeState& state)
|
||||||
{
|
{
|
||||||
return state.node_addr_hash ();
|
return state.node_addr_hash ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,18 @@
|
||||||
#ifndef node_state_h
|
#ifndef node_state_h
|
||||||
#define node_state_h
|
#define node_state_h
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
|
|
||||||
#define ADDR_NONE UINT_MAX
|
#define ADDR_NONE UINT_MAX
|
||||||
|
|
||||||
namespace Node {
|
namespace Node
|
||||||
|
{
|
||||||
const std::string tempo = "tempo";
|
const std::string tempo = "tempo";
|
||||||
const std::string strip_desc = "strip_desc";
|
const std::string strip_desc = "strip_desc";
|
||||||
const std::string strip_meter = "strip_meter";
|
const std::string strip_meter = "strip_meter";
|
||||||
|
|
@ -40,22 +41,24 @@ namespace Node {
|
||||||
const std::string strip_plugin_enable = "strip_plugin_enable";
|
const std::string strip_plugin_enable = "strip_plugin_enable";
|
||||||
const std::string strip_plugin_param_desc = "strip_plugin_param_desc";
|
const std::string strip_plugin_param_desc = "strip_plugin_param_desc";
|
||||||
const std::string strip_plugin_param_value = "strip_plugin_param_value";
|
const std::string strip_plugin_param_value = "strip_plugin_param_value";
|
||||||
}
|
} // namespace Node
|
||||||
|
|
||||||
typedef std::vector<uint32_t> AddressVector;
|
typedef std::vector<uint32_t> AddressVector;
|
||||||
typedef std::vector<TypedValue> ValueVector;
|
typedef std::vector<TypedValue> ValueVector;
|
||||||
|
|
||||||
class NodeState {
|
class NodeState
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NodeState ();
|
NodeState ();
|
||||||
NodeState (std::string);
|
NodeState (std::string);
|
||||||
NodeState (std::string, AddressVector, ValueVector = ValueVector());
|
NodeState (std::string, AddressVector, ValueVector = ValueVector ());
|
||||||
|
|
||||||
std::string debug_str () const;
|
std::string debug_str () const;
|
||||||
|
|
||||||
std::string node () const { return _node; }
|
std::string node () const
|
||||||
|
{
|
||||||
|
return _node;
|
||||||
|
}
|
||||||
|
|
||||||
int n_addr () const;
|
int n_addr () const;
|
||||||
uint32_t nth_addr (int) const;
|
uint32_t nth_addr (int) const;
|
||||||
|
|
@ -69,14 +72,13 @@ class NodeState {
|
||||||
|
|
||||||
bool operator== (const NodeState& other) const;
|
bool operator== (const NodeState& other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _node;
|
std::string _node;
|
||||||
AddressVector _addr;
|
AddressVector _addr;
|
||||||
ValueVector _val;
|
ValueVector _val;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::size_t hash_value (const NodeState&);
|
std::size_t
|
||||||
|
hash_value (const NodeState&);
|
||||||
|
|
||||||
#endif // node_state_h
|
#endif // node_state_h
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ardour/session.h"
|
|
||||||
#include "ardour/plugin_insert.h"
|
|
||||||
#include "ardour/dB.h"
|
#include "ardour/dB.h"
|
||||||
|
#include "ardour/plugin_insert.h"
|
||||||
|
#include "ardour/session.h"
|
||||||
#include "pbd/controllable.h"
|
#include "pbd/controllable.h"
|
||||||
|
|
||||||
#include "strips.h"
|
#include "strips.h"
|
||||||
|
|
@ -28,7 +28,7 @@ using namespace ARDOUR;
|
||||||
int
|
int
|
||||||
ArdourStrips::start ()
|
ArdourStrips::start ()
|
||||||
{
|
{
|
||||||
// take an indexed snapshot of current strips
|
/* take an indexed snapshot of current strips */
|
||||||
StripableList strips;
|
StripableList strips;
|
||||||
session ().get_stripables (strips, PresentationInfo::AllStripables);
|
session ().get_stripables (strips, PresentationInfo::AllStripables);
|
||||||
|
|
||||||
|
|
@ -53,9 +53,9 @@ ArdourStrips::to_db (double k)
|
||||||
return -std::numeric_limits<double>::infinity ();
|
return -std::numeric_limits<double>::infinity ();
|
||||||
}
|
}
|
||||||
|
|
||||||
float db = accurate_coefficient_to_dB (static_cast<float>(k));
|
float db = accurate_coefficient_to_dB (static_cast<float> (k));
|
||||||
|
|
||||||
return static_cast<double>(db);
|
return static_cast<double> (db);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
@ -65,9 +65,9 @@ ArdourStrips::from_db (double db)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float k = dB_to_coefficient (static_cast<float>(db));
|
float k = dB_to_coefficient (static_cast<float> (db));
|
||||||
|
|
||||||
return static_cast<double>(k);
|
return static_cast<double> (k);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
@ -85,7 +85,7 @@ ArdourStrips::set_strip_gain (uint32_t strip_n, double db)
|
||||||
double
|
double
|
||||||
ArdourStrips::strip_pan (uint32_t strip_n) const
|
ArdourStrips::strip_pan (uint32_t strip_n) const
|
||||||
{
|
{
|
||||||
// scale from [0.0 ; 1.0] to [-1.0 ; 1.0]
|
/* scale from [0.0 ; 1.0] to [-1.0 ; 1.0] */
|
||||||
return 2.0 * nth_strip (strip_n)->pan_azimuth_control ()->get_value () - 1.0;
|
return 2.0 * nth_strip (strip_n)->pan_azimuth_control ()->get_value () - 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,11 +143,11 @@ ArdourStrips::set_strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
|
||||||
double dbl_val;
|
double dbl_val;
|
||||||
|
|
||||||
if (pd.toggled) {
|
if (pd.toggled) {
|
||||||
dbl_val = static_cast<double>(static_cast<bool>(value));
|
dbl_val = static_cast<double> (static_cast<bool> (value));
|
||||||
} else if (pd.enumeration || pd.integer_step) {
|
} else if (pd.enumeration || pd.integer_step) {
|
||||||
dbl_val = static_cast<double>(static_cast<int>(value));
|
dbl_val = static_cast<double> (static_cast<int> (value));
|
||||||
} else {
|
} else {
|
||||||
dbl_val = static_cast<double>(value);
|
dbl_val = static_cast<double> (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
control->set_value (dbl_val, PBD::Controllable::NoGroup);
|
control->set_value (dbl_val, PBD::Controllable::NoGroup);
|
||||||
|
|
@ -167,7 +167,7 @@ ArdourStrips::nth_strip (uint32_t strip_n) const
|
||||||
return _strips[strip_n];
|
return _strips[strip_n];
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::shared_ptr<Stripable>();
|
return boost::shared_ptr<Stripable> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedValue
|
TypedValue
|
||||||
|
|
@ -179,9 +179,9 @@ ArdourStrips::plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl> c
|
||||||
ParameterDescriptor pd = control->desc ();
|
ParameterDescriptor pd = control->desc ();
|
||||||
|
|
||||||
if (pd.toggled) {
|
if (pd.toggled) {
|
||||||
value = TypedValue (static_cast<bool>(control->get_value ()));
|
value = TypedValue (static_cast<bool> (control->get_value ()));
|
||||||
} else if (pd.enumeration || pd.integer_step) {
|
} else if (pd.enumeration || pd.integer_step) {
|
||||||
value = TypedValue (static_cast<int>(control->get_value ()));
|
value = TypedValue (static_cast<int> (control->get_value ()));
|
||||||
} else {
|
} else {
|
||||||
value = TypedValue (control->get_value ());
|
value = TypedValue (control->get_value ());
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +206,7 @@ ArdourStrips::strip_plugin_insert (uint32_t strip_n, uint32_t plugin_n) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::shared_ptr<PluginInsert>();
|
return boost::shared_ptr<PluginInsert> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<AutomationControl>
|
boost::shared_ptr<AutomationControl>
|
||||||
|
|
@ -222,10 +222,10 @@ ArdourStrips::strip_plugin_param_control (uint32_t strip_n, uint32_t plugin_n,
|
||||||
|
|
||||||
if (ok && plugin->parameter_is_input (control_id)) {
|
if (ok && plugin->parameter_is_input (control_id)) {
|
||||||
boost::shared_ptr<AutomationControl> control =
|
boost::shared_ptr<AutomationControl> control =
|
||||||
insert->automation_control (Evoral::Parameter(PluginAutomation, 0, control_id));
|
insert->automation_control (Evoral::Parameter (PluginAutomation, 0, control_id));
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::shared_ptr<AutomationControl>();
|
return boost::shared_ptr<AutomationControl> ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
class ArdourStrips : public SurfaceComponent
|
class ArdourStrips : public SurfaceComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ArdourStrips (ArdourSurface::ArdourWebsockets& surface)
|
||||||
ArdourStrips (ArdourSurface::ArdourWebsockets& surface) : SurfaceComponent (surface) {};
|
: SurfaceComponent (surface){};
|
||||||
virtual ~ArdourStrips () {};
|
virtual ~ArdourStrips (){};
|
||||||
|
|
||||||
int start ();
|
int start ();
|
||||||
int stop ();
|
int stop ();
|
||||||
|
|
@ -55,16 +55,14 @@ class ArdourStrips : public SurfaceComponent
|
||||||
|
|
||||||
boost::shared_ptr<ARDOUR::PluginInsert> strip_plugin_insert (uint32_t, uint32_t) const;
|
boost::shared_ptr<ARDOUR::PluginInsert> strip_plugin_insert (uint32_t, uint32_t) const;
|
||||||
|
|
||||||
boost::shared_ptr<ARDOUR::AutomationControl> strip_plugin_param_control(
|
boost::shared_ptr<ARDOUR::AutomationControl> strip_plugin_param_control (
|
||||||
uint32_t, uint32_t, uint32_t) const;
|
uint32_t, uint32_t, uint32_t) const;
|
||||||
|
|
||||||
static TypedValue plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl>);
|
static TypedValue plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > StripableVector;
|
typedef std::vector<boost::shared_ptr<ARDOUR::Stripable> > StripableVector;
|
||||||
StripableVector _strips;
|
StripableVector _strips;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ardour_strips_h
|
#endif // ardour_strips_h
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
#include "typed_value.h"
|
#include "typed_value.h"
|
||||||
|
|
||||||
|
|
@ -29,35 +29,44 @@ TypedValue::TypedValue ()
|
||||||
: _type (Empty)
|
: _type (Empty)
|
||||||
, _b (false)
|
, _b (false)
|
||||||
, _i (0)
|
, _i (0)
|
||||||
, _d (0) { }
|
, _d (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TypedValue::TypedValue (bool value)
|
TypedValue::TypedValue (bool value)
|
||||||
: _type (Bool)
|
: _type (Bool)
|
||||||
, _b (value)
|
, _b (value)
|
||||||
, _i (0)
|
, _i (0)
|
||||||
, _d (0) { }
|
, _d (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TypedValue::TypedValue (int value)
|
TypedValue::TypedValue (int value)
|
||||||
: _type (Int)
|
: _type (Int)
|
||||||
, _b (false)
|
, _b (false)
|
||||||
, _i (value)
|
, _i (value)
|
||||||
, _d (0) { }
|
, _d (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TypedValue::TypedValue (double value)
|
TypedValue::TypedValue (double value)
|
||||||
: _type (Double)
|
: _type (Double)
|
||||||
, _b (false)
|
, _b (false)
|
||||||
, _i (0)
|
, _i (0)
|
||||||
, _d (value) { }
|
, _d (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TypedValue::TypedValue (std::string value)
|
TypedValue::TypedValue (std::string value)
|
||||||
: _type (String)
|
: _type (String)
|
||||||
, _b (false)
|
, _b (false)
|
||||||
, _i (0)
|
, _i (0)
|
||||||
, _d (0)
|
, _d (0)
|
||||||
, _s (value) { }
|
, _s (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
TypedValue::operator
|
TypedValue::operator bool () const
|
||||||
bool () const
|
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case Bool:
|
case Bool:
|
||||||
|
|
@ -73,8 +82,7 @@ bool () const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedValue::operator
|
TypedValue::operator int () const
|
||||||
int () const
|
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case Int:
|
case Int:
|
||||||
|
|
@ -82,7 +90,7 @@ int () const
|
||||||
case Bool:
|
case Bool:
|
||||||
return _b ? 1 : 0;
|
return _b ? 1 : 0;
|
||||||
case Double:
|
case Double:
|
||||||
return static_cast<int>(_d);
|
return static_cast<int> (_d);
|
||||||
case String:
|
case String:
|
||||||
try {
|
try {
|
||||||
return boost::lexical_cast<int> (_s);
|
return boost::lexical_cast<int> (_s);
|
||||||
|
|
@ -94,8 +102,7 @@ int () const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedValue::operator
|
TypedValue::operator double () const
|
||||||
double () const
|
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case Double:
|
case Double:
|
||||||
|
|
@ -103,7 +110,7 @@ double () const
|
||||||
case Bool:
|
case Bool:
|
||||||
return _b ? 1.f : 0;
|
return _b ? 1.f : 0;
|
||||||
case Int:
|
case Int:
|
||||||
return static_cast<double>(_i);
|
return static_cast<double> (_i);
|
||||||
case String:
|
case String:
|
||||||
try {
|
try {
|
||||||
return boost::lexical_cast<double> (_s);
|
return boost::lexical_cast<double> (_s);
|
||||||
|
|
@ -115,8 +122,7 @@ double () const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedValue::operator
|
TypedValue::operator std::string () const
|
||||||
std::string () const
|
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case String:
|
case String:
|
||||||
|
|
@ -136,13 +142,14 @@ bool
|
||||||
TypedValue::operator== (const TypedValue& other) const
|
TypedValue::operator== (const TypedValue& other) const
|
||||||
{
|
{
|
||||||
if (_type != other._type) {
|
if (_type != other._type) {
|
||||||
// make an exception when comparing doubles and ints
|
/* make an exception when comparing doubles and ints
|
||||||
// for example browser json implementations will send
|
* for example browser json implementations will send
|
||||||
// 1 instead of 1.0 removing any type hint
|
* 1 instead of 1.0 removing any type hint
|
||||||
|
*/
|
||||||
if ((_type == Int) && (other._type == Double)) {
|
if ((_type == Int) && (other._type == Double)) {
|
||||||
return fabs (static_cast<double>(_i) - other._d) < DBL_TOLERANCE;
|
return fabs (static_cast<double> (_i) - other._d) < DBL_TOLERANCE;
|
||||||
} else if ((_type == Double) && (other._type == Int)) {
|
} else if ((_type == Double) && (other._type == Int)) {
|
||||||
return fabs (_d - static_cast<double>(other._i)) < DBL_TOLERANCE;
|
return fabs (_d - static_cast<double> (other._i)) < DBL_TOLERANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -155,9 +162,7 @@ TypedValue::operator== (const TypedValue& other) const
|
||||||
return _i == other._i;
|
return _i == other._i;
|
||||||
case Double: {
|
case Double: {
|
||||||
double inf = std::numeric_limits<double>::infinity ();
|
double inf = std::numeric_limits<double>::infinity ();
|
||||||
return ((_d == inf) && (other._d == inf))
|
return ((_d == inf) && (other._d == inf)) || ((_d == -inf) && (other._d == -inf)) || (fabs (_d - other._d) < DBL_TOLERANCE);
|
||||||
|| ((_d == -inf) && (other._d == -inf))
|
|
||||||
|| (fabs (_d - other._d) < DBL_TOLERANCE);
|
|
||||||
}
|
}
|
||||||
case String:
|
case String:
|
||||||
return _s == other._s;
|
return _s == other._s;
|
||||||
|
|
@ -177,7 +182,7 @@ TypedValue::debug_str () const
|
||||||
{
|
{
|
||||||
char s[256];
|
char s[256];
|
||||||
|
|
||||||
sprintf(s, "type = %d; b = %d; i = %d; d = %f; s = \"%s\"",
|
sprintf (s, "type = %d; b = %d; i = %d; d = %f; s = \"%s\"",
|
||||||
_type, _b, _i, _d, _s.c_str ());
|
_type, _b, _i, _d, _s.c_str ());
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@
|
||||||
|
|
||||||
class TypedValue
|
class TypedValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
Empty,
|
Empty,
|
||||||
Bool,
|
Bool,
|
||||||
|
|
@ -39,8 +38,14 @@ class TypedValue
|
||||||
TypedValue (double);
|
TypedValue (double);
|
||||||
TypedValue (std::string);
|
TypedValue (std::string);
|
||||||
|
|
||||||
bool empty () const { return _type == Empty; };
|
bool empty () const
|
||||||
Type type () const { return _type; };
|
{
|
||||||
|
return _type == Empty;
|
||||||
|
};
|
||||||
|
Type type () const
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
};
|
||||||
|
|
||||||
operator bool () const;
|
operator bool () const;
|
||||||
operator int () const;
|
operator int () const;
|
||||||
|
|
@ -52,14 +57,12 @@ class TypedValue
|
||||||
|
|
||||||
std::string debug_str () const;
|
std::string debug_str () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Type _type;
|
Type _type;
|
||||||
bool _b;
|
bool _b;
|
||||||
int _i;
|
int _i;
|
||||||
double _d;
|
double _d;
|
||||||
std::string _s;
|
std::string _s;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // typed_value_h
|
#endif // typed_value_h
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue