WebSockets: add transport roll support to surface

This commit is contained in:
Luciano Iam 2020-04-18 12:39:18 +02:00 committed by Robin Gareus
parent 656cd9c8a7
commit 0e664b1556
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
7 changed files with 51 additions and 2 deletions

View file

@ -19,6 +19,12 @@
#include "component.h" #include "component.h"
#include "ardour_websockets.h" #include "ardour_websockets.h"
BasicUI&
SurfaceComponent::basic_ui () const
{
return _surface;
}
PBD::EventLoop* PBD::EventLoop*
SurfaceComponent::event_loop () const SurfaceComponent::event_loop () const
{ {

View file

@ -19,6 +19,8 @@
#ifndef _ardour_surface_websockets_component_h_ #ifndef _ardour_surface_websockets_component_h_
#define _ardour_surface_websockets_component_h_ #define _ardour_surface_websockets_component_h_
#include "control_protocol/basic_ui.h"
#include <glibmm.h> #include <glibmm.h>
#include "ardour/session.h" #include "ardour/session.h"
@ -51,6 +53,7 @@ public:
return 0; return 0;
} }
BasicUI& basic_ui () const;
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;

View file

@ -53,6 +53,7 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
void void
WebsocketsDispatcher::update_all_nodes (Client client) WebsocketsDispatcher::update_all_nodes (Client client)
{ {
update (client, Node::transport_roll, globals ().transport_roll ());
update (client, Node::tempo, globals ().tempo ()); update (client, Node::tempo, globals ().tempo ());
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) { for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {

View file

@ -29,6 +29,20 @@
using namespace ARDOUR; using namespace ARDOUR;
struct TransportObserver {
void operator() (ArdourFeedback* p)
{
p->update_all (Node::transport_roll, p->globals ().transport_roll ());
}
};
struct RecordStateObserver {
void operator() (ArdourFeedback* p)
{
// TO DO
}
};
struct TempoObserver { struct TempoObserver {
void operator() (ArdourFeedback* p) void operator() (ArdourFeedback* p)
{ {
@ -162,7 +176,12 @@ ArdourFeedback::poll () const
void void
ArdourFeedback::observe_globals () ArdourFeedback::observe_globals ()
{ {
session ().tempo_map ().PropertyChanged.connect (_signal_connections, MISSING_INVALIDATOR, ARDOUR::Session& sess = session ();
sess.TransportStateChange.connect (_signal_connections, MISSING_INVALIDATOR,
boost::bind<void> (TransportObserver (), this), event_loop ());
sess.RecordStateChanged.connect (_signal_connections, MISSING_INVALIDATOR,
boost::bind<void> (RecordStateObserver (), this), event_loop ());
sess.tempo_map ().PropertyChanged.connect (_signal_connections, MISSING_INVALIDATOR,
boost::bind<void> (TempoObserver (), this), event_loop ()); boost::bind<void> (TempoObserver (), this), event_loop ());
} }

View file

@ -22,6 +22,21 @@
using namespace ARDOUR; using namespace ARDOUR;
bool
ArdourGlobals::transport_roll () const
{
return static_cast<bool>(basic_ui ().transport_rolling ());
}
void
ArdourGlobals::set_transport_roll (bool value)
{
if ((value && !transport_roll ()) || (!value && transport_roll ())) {
// this call is equivalent to hitting the spacebar
basic_ui ().toggle_roll ();
}
}
double double
ArdourGlobals::tempo () const ArdourGlobals::tempo () const
{ {

View file

@ -28,6 +28,9 @@ public:
: SurfaceComponent (surface){}; : SurfaceComponent (surface){};
virtual ~ArdourGlobals (){}; virtual ~ArdourGlobals (){};
bool transport_roll () const;
void set_transport_roll (bool);
double tempo () const; double tempo () const;
void set_tempo (double); void set_tempo (double);
}; };

View file

@ -32,6 +32,8 @@
namespace Node namespace Node
{ {
const std::string tempo = "tempo"; const std::string tempo = "tempo";
const std::string transport_roll = "transport_roll";
const std::string record_state = "record_state";
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";
const std::string strip_gain = "strip_gain"; const std::string strip_gain = "strip_gain";