13
0

WebSockets: code refactor

Terminology used by server and client was starting to diverge.

C++ classes ArdourStrips and ArdourGlobals classes have been
renamed to ArdourMixer and ArdourTransport respectively.

State node values for transport functionality have been simplified
and prefixed with 'transport_' to match what was done for strips.
This commit is contained in:
Luciano Iam 2020-05-30 19:08:27 +02:00 committed by Robin Gareus
parent ae4df127ad
commit a26a9018fd
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
17 changed files with 147 additions and 165 deletions

View File

@ -37,14 +37,14 @@ using namespace ArdourSurface;
ArdourWebsockets::ArdourWebsockets (Session& s)
: ControlProtocol (s, X_ (surface_name))
, AbstractUI<ArdourWebsocketsUIRequest> (name ())
, _strips (*this)
, _globals (*this)
, _mixer (*this)
, _transport (*this)
, _feedback (*this)
, _server (*this)
, _dispatcher (*this)
{
_components.push_back (&_strips);
_components.push_back (&_globals);
_components.push_back (&_mixer);
_components.push_back (&_transport);
_components.push_back (&_server);
_components.push_back (&_feedback);
_components.push_back (&_dispatcher);

View File

@ -35,9 +35,9 @@
#include "component.h"
#include "dispatcher.h"
#include "feedback.h"
#include "globals.h"
#include "transport.h"
#include "server.h"
#include "strips.h"
#include "mixer.h"
namespace ArdourSurface
{
@ -65,13 +65,13 @@ public:
{
return *session;
}
ArdourStrips& strips_component ()
ArdourMixer& mixer_component ()
{
return _strips;
return _mixer;
}
ArdourGlobals& globals_component ()
ArdourTransport& transport_component ()
{
return _globals;
return _transport;
}
WebsocketsServer& server_component ()
{
@ -93,8 +93,8 @@ protected:
void do_request (ArdourWebsocketsUIRequest*);
private:
ArdourStrips _strips;
ArdourGlobals _globals;
ArdourMixer _mixer;
ArdourTransport _transport;
ArdourFeedback _feedback;
WebsocketsServer _server;
WebsocketsDispatcher _dispatcher;

View File

@ -43,16 +43,16 @@ SurfaceComponent::session () const
return _surface.ardour_session ();
}
ArdourStrips&
SurfaceComponent::strips () const
ArdourMixer&
SurfaceComponent::mixer () const
{
return _surface.strips_component ();
return _surface.mixer_component ();
}
ArdourGlobals&
SurfaceComponent::globals () const
ArdourTransport&
SurfaceComponent::transport () const
{
return _surface.globals_component ();
return _surface.transport_component ();
}
WebsocketsServer&

View File

@ -31,8 +31,8 @@ namespace ArdourSurface
class ArdourWebsockets;
}
class ArdourStrips;
class ArdourGlobals;
class ArdourMixer;
class ArdourTransport;
class WebsocketsServer;
class WebsocketsDispatcher;
@ -57,8 +57,8 @@ public:
PBD::EventLoop* event_loop () const;
Glib::RefPtr<Glib::MainLoop> main_loop () const;
ARDOUR::Session& session () const;
ArdourStrips& strips () const;
ArdourGlobals& globals () const;
ArdourMixer& mixer () const;
ArdourTransport& transport () const;
WebsocketsServer& server () const;
WebsocketsDispatcher& dispatcher () const;

View File

@ -30,9 +30,9 @@ using namespace ARDOUR;
WebsocketsDispatcher::NodeMethodMap
WebsocketsDispatcher::_node_to_method = boost::assign::map_list_of
NODE_METHOD_PAIR (tempo)
NODE_METHOD_PAIR (transport_tempo)
NODE_METHOD_PAIR (transport_roll)
NODE_METHOD_PAIR (record_state)
NODE_METHOD_PAIR (transport_record)
NODE_METHOD_PAIR (strip_gain)
NODE_METHOD_PAIR (strip_pan)
NODE_METHOD_PAIR (strip_mute)
@ -55,8 +55,8 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
void
WebsocketsDispatcher::update_all_nodes (Client client)
{
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
for (uint32_t strip_n = 0; strip_n < mixer ().strip_count (); ++strip_n) {
boost::shared_ptr<Stripable> strip = mixer ().nth_strip (strip_n);
bool is_vca = strip->presentation_info ().flags () & ARDOUR::PresentationInfo::VCA;
@ -68,8 +68,8 @@ WebsocketsDispatcher::update_all_nodes (Client client)
update (client, Node::strip_description, strip_addr, strip_desc);
update (client, Node::strip_gain, strip_n, strips ().strip_gain (strip_n));
update (client, Node::strip_mute, strip_n, strips ().strip_mute (strip_n));
update (client, Node::strip_gain, strip_n, mixer ().strip_gain (strip_n));
update (client, Node::strip_mute, strip_n, mixer ().strip_mute (strip_n));
// Pan and plugins not available in VCAs
if (is_vca) {
@ -81,10 +81,10 @@ WebsocketsDispatcher::update_all_nodes (Client client)
continue;
}
update (client, Node::strip_pan, strip_n, strips ().strip_pan (strip_n));
update (client, Node::strip_pan, strip_n, mixer ().strip_pan (strip_n));
for (uint32_t plugin_n = 0;; ++plugin_n) {
boost::shared_ptr<PluginInsert> insert = strips ()
boost::shared_ptr<PluginInsert> insert = mixer ()
.strip_plugin_insert (strip_n, plugin_n);
if (!insert) {
break;
@ -95,11 +95,11 @@ WebsocketsDispatcher::update_all_nodes (Client client)
static_cast<std::string> (plugin->name ()));
update (client, Node::strip_plugin_enable, strip_n, plugin_n,
strips ().strip_plugin_enabled (strip_n, plugin_n));
mixer ().strip_plugin_enabled (strip_n, plugin_n));
for (uint32_t param_n = 0; param_n < plugin->parameter_count (); ++param_n) {
boost::shared_ptr<AutomationControl> a_ctrl =
strips ().strip_plugin_param_control (strip_n, plugin_n, param_n);
mixer ().strip_plugin_param_control (strip_n, plugin_n, param_n);
if (!a_ctrl) {
continue;
}
@ -130,27 +130,27 @@ WebsocketsDispatcher::update_all_nodes (Client client)
update (client, Node::strip_plugin_param_description, addr, val);
TypedValue value = strips ().strip_plugin_param_value (strip_n, plugin_n, param_n);
TypedValue value = mixer ().strip_plugin_param_value (strip_n, plugin_n, param_n);
update (client, Node::strip_plugin_param_value, strip_n, plugin_n, param_n, value);
}
}
}
update (client, Node::tempo, globals ().tempo ());
update (client, Node::position_time, globals ().position_time ());
update (client, Node::transport_roll, globals ().transport_roll ());
update (client, Node::record_state, globals ().record_state ());
update (client, Node::transport_tempo, transport ().tempo ());
update (client, Node::transport_time, transport ().time ());
update (client, Node::transport_roll, transport ().roll ());
update (client, Node::transport_record, transport ().record ());
}
void
WebsocketsDispatcher::tempo_handler (Client client, const NodeStateMessage& msg)
WebsocketsDispatcher::transport_tempo_handler (Client client, const NodeStateMessage& msg)
{
const NodeState& state = msg.state ();
if (msg.is_write () && (state.n_val () > 0)) {
globals ().set_tempo (state.nth_val (0));
transport ().set_tempo (state.nth_val (0));
} else {
update (client, Node::tempo, globals ().tempo ());
update (client, Node::transport_tempo, transport ().tempo ());
}
}
@ -160,21 +160,21 @@ WebsocketsDispatcher::transport_roll_handler (Client client, const NodeStateMess
const NodeState& state = msg.state ();
if (msg.is_write () && (state.n_val () > 0)) {
globals ().set_transport_roll (state.nth_val (0));
transport ().set_roll (state.nth_val (0));
} else {
update (client, Node::transport_roll, globals ().transport_roll ());
update (client, Node::transport_roll, transport ().roll ());
}
}
void
WebsocketsDispatcher::record_state_handler (Client client, const NodeStateMessage& msg)
WebsocketsDispatcher::transport_record_handler (Client client, const NodeStateMessage& msg)
{
const NodeState& state = msg.state ();
if (msg.is_write () && (state.n_val () > 0)) {
globals ().set_record_state (state.nth_val (0));
transport ().set_record (state.nth_val (0));
} else {
update (client, Node::record_state, globals ().record_state ());
update (client, Node::transport_record, transport ().record ());
}
}
@ -190,9 +190,9 @@ WebsocketsDispatcher::strip_gain_handler (Client client, const NodeStateMessage&
uint32_t strip_id = state.nth_addr (0);
if (msg.is_write () && (state.n_val () > 0)) {
strips ().set_strip_gain (strip_id, state.nth_val (0));
mixer ().set_strip_gain (strip_id, state.nth_val (0));
} else {
update (client, Node::strip_gain, strip_id, strips ().strip_gain (strip_id));
update (client, Node::strip_gain, strip_id, mixer ().strip_gain (strip_id));
}
}
@ -208,9 +208,9 @@ WebsocketsDispatcher::strip_pan_handler (Client client, const NodeStateMessage&
uint32_t strip_id = state.nth_addr (0);
if (msg.is_write () && (state.n_val () > 0)) {
strips ().set_strip_pan (strip_id, state.nth_val (0));
mixer ().set_strip_pan (strip_id, state.nth_val (0));
} else {
update (client, Node::strip_pan, strip_id, strips ().strip_pan (strip_id));
update (client, Node::strip_pan, strip_id, mixer ().strip_pan (strip_id));
}
}
@ -226,9 +226,9 @@ WebsocketsDispatcher::strip_mute_handler (Client client, const NodeStateMessage&
uint32_t strip_id = state.nth_addr (0);
if (msg.is_write () && (state.n_val () > 0)) {
strips ().set_strip_mute (strip_id, state.nth_val (0));
mixer ().set_strip_mute (strip_id, state.nth_val (0));
} else {
update (client, Node::strip_mute, strip_id, strips ().strip_mute (strip_id));
update (client, Node::strip_mute, strip_id, mixer ().strip_mute (strip_id));
}
}
@ -245,10 +245,10 @@ WebsocketsDispatcher::strip_plugin_enable_handler (Client client, const NodeStat
uint32_t plugin_id = state.nth_addr (1);
if (msg.is_write () && (state.n_val () > 0)) {
strips ().set_strip_plugin_enabled (strip_id, plugin_id, state.nth_val (0));
mixer ().set_strip_plugin_enabled (strip_id, plugin_id, state.nth_val (0));
} else {
update (client, Node::strip_plugin_enable, strip_id, plugin_id,
strips ().strip_plugin_enabled (strip_id, plugin_id));
mixer ().strip_plugin_enabled (strip_id, plugin_id));
}
}
@ -266,10 +266,10 @@ WebsocketsDispatcher::strip_plugin_param_value_handler (Client client, const Nod
uint32_t param_id = state.nth_addr (2);
if (msg.is_write () && (state.n_val () > 0)) {
strips ().set_strip_plugin_param_value (strip_id, plugin_id, param_id,
mixer ().set_strip_plugin_param_value (strip_id, plugin_id, param_id,
state.nth_val (0));
} else {
TypedValue value = strips ().strip_plugin_param_value (strip_id, plugin_id, param_id);
TypedValue value = mixer ().strip_plugin_param_value (strip_id, plugin_id, param_id);
update (client, Node::strip_plugin_param_value, strip_id, plugin_id, param_id, value);
}
}

View File

@ -41,9 +41,9 @@ private:
static NodeMethodMap _node_to_method;
void tempo_handler (Client, const NodeStateMessage&);
void transport_tempo_handler (Client, const NodeStateMessage&);
void transport_roll_handler (Client client, const NodeStateMessage&);
void record_state_handler (Client client, const NodeStateMessage&);
void transport_record_handler (Client client, const NodeStateMessage&);
void strip_gain_handler (Client, const NodeStateMessage&);
void strip_pan_handler (Client, const NodeStateMessage&);
void strip_mute_handler (Client, const NodeStateMessage&);

View File

@ -22,10 +22,10 @@
#include "ardour/tempo.h"
#include "feedback.h"
#include "globals.h"
#include "transport.h"
#include "server.h"
#include "state.h"
#include "strips.h"
#include "mixer.h"
// TO DO: make this configurable
#define POLL_INTERVAL_MS 100
@ -35,21 +35,21 @@ using namespace ARDOUR;
struct TransportObserver {
void operator() (ArdourFeedback* p)
{
p->update_all (Node::transport_roll, p->globals ().transport_roll ());
p->update_all (Node::transport_roll, p->transport ().roll ());
}
};
struct RecordStateObserver {
void operator() (ArdourFeedback* p)
{
p->update_all (Node::record_state, p->globals ().record_state ());
p->update_all (Node::transport_record, p->transport ().record ());
}
};
struct TempoObserver {
void operator() (ArdourFeedback* p)
{
p->update_all (Node::tempo, p->globals ().tempo ());
p->update_all (Node::transport_tempo, p->transport ().tempo ());
}
};
@ -57,21 +57,21 @@ struct StripGainObserver {
void operator() (ArdourFeedback* p, uint32_t strip_n)
{
// 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->mixer ().strip_gain (strip_n));
}
};
struct StripPanObserver {
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->mixer ().strip_pan (strip_n));
}
};
struct StripMuteObserver {
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->mixer ().strip_mute (strip_n));
}
};
@ -79,7 +79,7 @@ struct PluginBypassObserver {
void operator() (ArdourFeedback* p, uint32_t strip_n, uint32_t plugin_n)
{
p->update_all (Node::strip_plugin_enable, strip_n, plugin_n,
p->strips ().strip_plugin_enabled (strip_n, plugin_n));
p->mixer ().strip_plugin_enabled (strip_n, plugin_n));
}
};
@ -92,15 +92,15 @@ struct PluginParamValueObserver {
return;
}
p->update_all (Node::strip_plugin_param_value, strip_n, plugin_n, param_n,
ArdourStrips::plugin_param_value (control));
ArdourMixer::plugin_param_value (control));
}
};
int
ArdourFeedback::start ()
{
observe_globals ();
observe_strips ();
observe_transport ();
observe_mixer ();
// some things need polling like the strip meters
Glib::RefPtr<Glib::TimeoutSource> periodic_timeout = Glib::TimeoutSource::create (POLL_INTERVAL_MS);
@ -165,11 +165,11 @@ ArdourFeedback::update_all (std::string node, uint32_t strip_n, uint32_t plugin_
bool
ArdourFeedback::poll () const
{
update_all (Node::position_time, globals ().position_time ());
update_all (Node::transport_time, transport ().time ());
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
for (uint32_t strip_n = 0; strip_n < mixer ().strip_count (); ++strip_n) {
// meters
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
boost::shared_ptr<Stripable> strip = mixer ().nth_strip (strip_n);
boost::shared_ptr<PeakMeter> meter = strip->peak_meter ();
float db = meter ? meter->meter_level (0, MeterMCP) : -193;
update_all (Node::strip_meter, strip_n, static_cast<double> (db));
@ -179,7 +179,7 @@ ArdourFeedback::poll () const
}
void
ArdourFeedback::observe_globals ()
ArdourFeedback::observe_transport ()
{
ARDOUR::Session& sess = session ();
sess.TransportStateChange.connect (_signal_connections, MISSING_INVALIDATOR,
@ -191,10 +191,10 @@ ArdourFeedback::observe_globals ()
}
void
ArdourFeedback::observe_strips ()
ArdourFeedback::observe_mixer ()
{
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
for (uint32_t strip_n = 0; strip_n < mixer ().strip_count (); ++strip_n) {
boost::shared_ptr<Stripable> strip = mixer ().nth_strip (strip_n);
strip->gain_control ()->Changed.connect (_signal_connections, MISSING_INVALIDATOR,
boost::bind<void> (StripGainObserver (), this, strip_n), event_loop ());
@ -215,7 +215,7 @@ void
ArdourFeedback::observe_strip_plugins (uint32_t strip_n, boost::shared_ptr<ARDOUR::Stripable> strip)
{
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 = mixer ().strip_plugin_insert (strip_n, plugin_n);
if (!insert) {
break;
}
@ -240,7 +240,7 @@ ArdourFeedback::observe_strip_plugin_param_values (uint32_t strip_n,
boost::shared_ptr<Plugin> plugin = insert->plugin ();
for (uint32_t param_n = 0; param_n < plugin->parameter_count (); ++param_n) {
boost::shared_ptr<AutomationControl> control = strips ().strip_plugin_param_control (
boost::shared_ptr<AutomationControl> control = mixer ().strip_plugin_param_control (
strip_n, plugin_n, param_n);
if (!control) {

View File

@ -47,8 +47,8 @@ private:
bool poll () const;
void observe_globals ();
void observe_strips ();
void observe_transport ();
void observe_mixer ();
void observe_strip_plugins (uint32_t, boost::shared_ptr<ARDOUR::Stripable>);
void observe_strip_plugin_param_values (uint32_t, uint32_t,
boost::shared_ptr<ARDOUR::PluginInsert>);

View File

@ -21,12 +21,12 @@
#include "ardour/session.h"
#include "pbd/controllable.h"
#include "strips.h"
#include "mixer.h"
using namespace ARDOUR;
int
ArdourStrips::start ()
ArdourMixer::start ()
{
/* take an indexed snapshot of current strips */
StripableList strips;
@ -40,14 +40,14 @@ ArdourStrips::start ()
}
int
ArdourStrips::stop ()
ArdourMixer::stop ()
{
_strips.clear ();
return 0;
}
double
ArdourStrips::to_db (double k)
ArdourMixer::to_db (double k)
{
if (k == 0) {
return -std::numeric_limits<double>::infinity ();
@ -59,7 +59,7 @@ ArdourStrips::to_db (double k)
}
double
ArdourStrips::from_db (double db)
ArdourMixer::from_db (double db)
{
if (db < -192) {
return 0;
@ -71,19 +71,19 @@ ArdourStrips::from_db (double db)
}
double
ArdourStrips::strip_gain (uint32_t strip_n) const
ArdourMixer::strip_gain (uint32_t strip_n) const
{
return to_db (nth_strip (strip_n)->gain_control ()->get_value ());
}
void
ArdourStrips::set_strip_gain (uint32_t strip_n, double db)
ArdourMixer::set_strip_gain (uint32_t strip_n, double db)
{
nth_strip (strip_n)->gain_control ()->set_value (from_db (db), PBD::Controllable::NoGroup);
}
double
ArdourStrips::strip_pan (uint32_t strip_n) const
ArdourMixer::strip_pan (uint32_t strip_n) const
{
boost::shared_ptr<AutomationControl> ac = nth_strip (strip_n)->pan_azimuth_control ();
if (!ac) {
@ -95,7 +95,7 @@ ArdourStrips::strip_pan (uint32_t strip_n) const
}
void
ArdourStrips::set_strip_pan (uint32_t strip_n, double value)
ArdourMixer::set_strip_pan (uint32_t strip_n, double value)
{
boost::shared_ptr<AutomationControl> ac = nth_strip (strip_n)->pan_azimuth_control ();
if (!ac) {
@ -107,38 +107,38 @@ ArdourStrips::set_strip_pan (uint32_t strip_n, double value)
}
bool
ArdourStrips::strip_mute (uint32_t strip_n) const
ArdourMixer::strip_mute (uint32_t strip_n) const
{
return nth_strip (strip_n)->mute_control ()->muted ();
}
void
ArdourStrips::set_strip_mute (uint32_t strip_n, bool mute)
ArdourMixer::set_strip_mute (uint32_t strip_n, bool mute)
{
nth_strip (strip_n)->mute_control ()->set_value (mute ? 1.0 : 0.0, PBD::Controllable::NoGroup);
}
bool
ArdourStrips::strip_plugin_enabled (uint32_t strip_n, uint32_t plugin_n) const
ArdourMixer::strip_plugin_enabled (uint32_t strip_n, uint32_t plugin_n) const
{
return strip_plugin_insert (strip_n, plugin_n)->enabled ();
}
void
ArdourStrips::set_strip_plugin_enabled (uint32_t strip_n, uint32_t plugin_n, bool enabled)
ArdourMixer::set_strip_plugin_enabled (uint32_t strip_n, uint32_t plugin_n, bool enabled)
{
strip_plugin_insert (strip_n, plugin_n)->enable (enabled);
}
TypedValue
ArdourStrips::strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
ArdourMixer::strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
uint32_t param_n) const
{
return plugin_param_value (strip_plugin_param_control (strip_n, plugin_n, param_n));
}
void
ArdourStrips::set_strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
ArdourMixer::set_strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
uint32_t param_n, TypedValue value)
{
boost::shared_ptr<AutomationControl> control = strip_plugin_param_control (
@ -161,13 +161,13 @@ ArdourStrips::set_strip_plugin_param_value (uint32_t strip_n, uint32_t plugin_n,
}
uint32_t
ArdourStrips::strip_count () const
ArdourMixer::strip_count () const
{
return _strips.size ();
}
boost::shared_ptr<Stripable>
ArdourStrips::nth_strip (uint32_t strip_n) const
ArdourMixer::nth_strip (uint32_t strip_n) const
{
if (strip_n < _strips.size ()) {
return _strips[strip_n];
@ -177,7 +177,7 @@ ArdourStrips::nth_strip (uint32_t strip_n) const
}
TypedValue
ArdourStrips::plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl> control)
ArdourMixer::plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl> control)
{
TypedValue value = TypedValue ();
@ -197,7 +197,7 @@ ArdourStrips::plugin_param_value (boost::shared_ptr<ARDOUR::AutomationControl> c
}
boost::shared_ptr<PluginInsert>
ArdourStrips::strip_plugin_insert (uint32_t strip_n, uint32_t plugin_n) const
ArdourMixer::strip_plugin_insert (uint32_t strip_n, uint32_t plugin_n) const
{
boost::shared_ptr<Stripable> strip = nth_strip (strip_n);
@ -222,7 +222,7 @@ ArdourStrips::strip_plugin_insert (uint32_t strip_n, uint32_t plugin_n) const
}
boost::shared_ptr<AutomationControl>
ArdourStrips::strip_plugin_param_control (uint32_t strip_n, uint32_t plugin_n,
ArdourMixer::strip_plugin_param_control (uint32_t strip_n, uint32_t plugin_n,
uint32_t param_n) const
{
boost::shared_ptr<PluginInsert> insert = strip_plugin_insert (strip_n, plugin_n);

View File

@ -16,18 +16,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _ardour_surface_websockets_strips_h_
#define _ardour_surface_websockets_strips_h_
#ifndef _ardour_surface_websockets_mixer_h_
#define _ardour_surface_websockets_mixer_h_
#include "component.h"
#include "typed_value.h"
class ArdourStrips : public SurfaceComponent
class ArdourMixer : public SurfaceComponent
{
public:
ArdourStrips (ArdourSurface::ArdourWebsockets& surface)
ArdourMixer (ArdourSurface::ArdourWebsockets& surface)
: SurfaceComponent (surface){};
virtual ~ArdourStrips (){};
virtual ~ArdourMixer (){};
int start ();
int stop ();
@ -65,4 +65,4 @@ private:
StripableVector _strips;
};
#endif // _ardour_surface_websockets_strips_h_
#endif // _ardour_surface_websockets_mixer_h_

View File

@ -31,10 +31,10 @@
namespace Node
{
const std::string tempo = "tempo";
const std::string position_time = "position_time";
const std::string transport_tempo = "transport_tempo";
const std::string transport_time = "transport_time";
const std::string transport_roll = "transport_roll";
const std::string record_state = "record_state";
const std::string transport_record = "transport_record";
const std::string strip_description = "strip_description";
const std::string strip_meter = "strip_meter";
const std::string strip_gain = "strip_gain";

View File

@ -18,19 +18,19 @@
#include "ardour/tempo.h"
#include "globals.h"
#include "transport.h"
using namespace ARDOUR;
double
ArdourGlobals::tempo () const
ArdourTransport::tempo () const
{
Tempo tempo = session ().tempo_map ().tempo_at_sample (0);
return tempo.note_type () * tempo.pulses_per_minute ();
}
void
ArdourGlobals::set_tempo (double bpm)
ArdourTransport::set_tempo (double bpm)
{
bpm = max (0.01, bpm);
TempoMap& tempo_map = session ().tempo_map ();
@ -39,7 +39,7 @@ ArdourGlobals::set_tempo (double bpm)
}
double
ArdourGlobals::position_time () const
ArdourTransport::time () const
{
samplepos_t t = session ().transport_sample ();
samplecnt_t f = session ().sample_rate ();
@ -47,30 +47,30 @@ ArdourGlobals::position_time () const
}
bool
ArdourGlobals::transport_roll () const
ArdourTransport::roll () const
{
return basic_ui ().transport_rolling ();
}
void
ArdourGlobals::set_transport_roll (bool value)
ArdourTransport::set_roll (bool value)
{
if ((value && !transport_roll ()) || (!value && transport_roll ())) {
if ((value && !roll ()) || (!value && roll ())) {
// this call is equivalent to hitting the spacebar
basic_ui ().toggle_roll (false);
}
}
bool
ArdourGlobals::record_state () const
ArdourTransport::record () const
{
return session ().get_record_enabled ();
}
void
ArdourGlobals::set_record_state (bool value)
ArdourTransport::set_record (bool value)
{
if ((value && !record_state ()) || (!value && record_state ())) {
if ((value && !record ()) || (!value && record ())) {
basic_ui ().rec_enable_toggle ();
}
}

View File

@ -16,28 +16,28 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _ardour_surface_websockets_globals_h_
#define _ardour_surface_websockets_globals_h_
#ifndef _ardour_surface_websockets_transport_h_
#define _ardour_surface_websockets_transport_h_
#include "component.h"
class ArdourGlobals : public SurfaceComponent
class ArdourTransport : public SurfaceComponent
{
public:
ArdourGlobals (ArdourSurface::ArdourWebsockets& surface)
ArdourTransport (ArdourSurface::ArdourWebsockets& surface)
: SurfaceComponent (surface){};
virtual ~ArdourGlobals (){};
virtual ~ArdourTransport (){};
double tempo () const;
void set_tempo (double);
double position_time () const;
double time () const;
bool transport_roll () const;
void set_transport_roll (bool);
bool roll () const;
void set_roll (bool);
bool record_state () const;
void set_record_state (bool);
bool record () const;
void set_record (bool);
};
#endif // _ardour_surface_websockets_globals_h_
#endif // _ardour_surface_websockets_transport_h_

View File

@ -22,8 +22,8 @@ def build(bld):
message.cc
client.cc
component.cc
strips.cc
globals.cc
mixer.cc
transport.cc
server.cc
feedback.cc
dispatcher.cc

View File

@ -19,10 +19,6 @@
export const JSON_INF = 1.0e+128;
export const StateNode = Object.freeze({
TEMPO: 'tempo',
POSITION_TIME: 'position_time',
TRANSPORT_ROLL: 'transport_roll',
RECORD_STATE: 'record_state',
STRIP_DESCRIPTION: 'strip_description',
STRIP_METER: 'strip_meter',
STRIP_GAIN: 'strip_gain',
@ -31,7 +27,11 @@ export const StateNode = Object.freeze({
STRIP_PLUGIN_DESCRIPTION: 'strip_plugin_description',
STRIP_PLUGIN_ENABLE: 'strip_plugin_enable',
STRIP_PLUGIN_PARAM_DESCRIPTION: 'strip_plugin_param_description',
STRIP_PLUGIN_PARAM_VALUE: 'strip_plugin_param_value'
STRIP_PLUGIN_PARAM_VALUE: 'strip_plugin_param_value',
TRANSPORT_TEMPO: 'transport_tempo',
TRANSPORT_TIME: 'transport_time',
TRANSPORT_ROLL: 'transport_roll',
TRANSPORT_RECORD: 'transport_record'
});
export class Message {

View File

@ -56,31 +56,13 @@ export class Mixer extends RootComponent {
}
return true;
} else {
// all initial strip description messages have been received at this point
if (!this._ready) {
this.updateLocal('ready', true);
}
}
/*
RECORD_STATE signals all mixer initial state has been sent because
it is the last message to arrive immediately after client connection,
see WebsocketsDispatcher::update_all_nodes() in dispatcher.cc
For this to work the mixer component needs to receive incoming
messages before the transport component, otherwise the latter would
consume RECORD_STATE.
Some ideas for a better implementation of mixer readiness detection:
- Implement message bundles like OSC to pack all initial state
updates into a single unit
- Move *_DESCRIPTION messages to single message with val={JSON data},
currently val only supports primitive data types
- Append a termination or mixer ready message in update_all_nodes(),
easiest but the least elegant
*/
if (!this._ready && (node == StateNode.RECORD_STATE)) {
this.updateLocal('ready', true);
}
return false;
}

View File

@ -38,7 +38,7 @@ export class Transport extends RootComponent {
}
set tempo (bpm) {
this.updateRemote('tempo', bpm, StateNode.TEMPO);
this.updateRemote('tempo', bpm, StateNode.TRANSPORT_TEMPO);
}
get roll () {
@ -54,21 +54,21 @@ export class Transport extends RootComponent {
}
set record (value) {
this.updateRemote('record', value, StateNode.RECORD_STATE);
this.updateRemote('record', value, StateNode.TRANSPORT_RECORD);
}
handle (node, addr, val) {
switch (node) {
case StateNode.TEMPO:
case StateNode.TRANSPORT_TEMPO:
this.updateLocal('tempo', val[0]);
break;
case StateNode.POSITION_TIME:
case StateNode.TRANSPORT_TIME:
this.updateLocal('time', val[0]);
break;
case StateNode.TRANSPORT_ROLL:
this.updateLocal('roll', val[0]);
break;
case StateNode.RECORD_STATE:
case StateNode.TRANSPORT_RECORD:
this.updateLocal('record', val[0]);
break;
default: