summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorLuciano Iam <lucianito@gmail.com>2020-04-18 14:56:46 +0200
committerRobin Gareus <robin@gareus.org>2020-04-20 22:59:16 +0200
commitdc97bf3ff0b28eb0b532e45049eaf328a5288b88 (patch)
tree190e737ad98638742c039e681c0093bc51aa32cf /libs/surfaces
parentbfbb15011c07aab847fe2592c2884b6bc27aafb8 (diff)
WebSockets: output position time in seconds
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/websockets/dispatcher.cc29
-rw-r--r--libs/surfaces/websockets/dispatcher.h2
-rw-r--r--libs/surfaces/websockets/feedback.cc2
-rw-r--r--libs/surfaces/websockets/globals.cc40
-rw-r--r--libs/surfaces/websockets/globals.h8
-rw-r--r--libs/surfaces/websockets/state.h1
6 files changed, 62 insertions, 20 deletions
diff --git a/libs/surfaces/websockets/dispatcher.cc b/libs/surfaces/websockets/dispatcher.cc
index f9e8fabc40..15c502476d 100644
--- a/libs/surfaces/websockets/dispatcher.cc
+++ b/libs/surfaces/websockets/dispatcher.cc
@@ -31,6 +31,8 @@ using namespace ARDOUR;
WebsocketsDispatcher::NodeMethodMap
WebsocketsDispatcher::_node_to_method = boost::assign::map_list_of
NODE_METHOD_PAIR (tempo)
+ NODE_METHOD_PAIR (transport_roll)
+ NODE_METHOD_PAIR (record_state)
NODE_METHOD_PAIR (strip_gain)
NODE_METHOD_PAIR (strip_pan)
NODE_METHOD_PAIR (strip_mute)
@@ -53,9 +55,10 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
void
WebsocketsDispatcher::update_all_nodes (Client client)
{
+ 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::tempo, globals ().tempo ());
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
@@ -136,6 +139,30 @@ WebsocketsDispatcher::tempo_handler (Client client, const NodeStateMessage& msg)
}
void
+WebsocketsDispatcher::transport_roll_handler (Client client, const NodeStateMessage& msg)
+{
+ const NodeState& state = msg.state ();
+
+ if (msg.is_write () && (state.n_val () > 0)) {
+ globals ().set_transport_roll (state.nth_val (0));
+ } else {
+ update (client, Node::transport_roll, globals ().transport_roll ());
+ }
+}
+
+void
+WebsocketsDispatcher::record_state_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));
+ } else {
+ update (client, Node::record_state, globals ().record_state ());
+ }
+}
+
+void
WebsocketsDispatcher::strip_gain_handler (Client client, const NodeStateMessage& msg)
{
const NodeState& state = msg.state ();
diff --git a/libs/surfaces/websockets/dispatcher.h b/libs/surfaces/websockets/dispatcher.h
index 7eed5120f1..93f6a556dc 100644
--- a/libs/surfaces/websockets/dispatcher.h
+++ b/libs/surfaces/websockets/dispatcher.h
@@ -42,6 +42,8 @@ private:
static NodeMethodMap _node_to_method;
void tempo_handler (Client, const NodeStateMessage&);
+ void transport_roll_handler (Client client, const NodeStateMessage&);
+ void record_state_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&);
diff --git a/libs/surfaces/websockets/feedback.cc b/libs/surfaces/websockets/feedback.cc
index 582bf8b9f2..8441a785d2 100644
--- a/libs/surfaces/websockets/feedback.cc
+++ b/libs/surfaces/websockets/feedback.cc
@@ -162,6 +162,8 @@ 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 ());
+
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
// meters
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
diff --git a/libs/surfaces/websockets/globals.cc b/libs/surfaces/websockets/globals.cc
index 3dd90cadd9..3113fcfb3a 100644
--- a/libs/surfaces/websockets/globals.cc
+++ b/libs/surfaces/websockets/globals.cc
@@ -22,6 +22,30 @@
using namespace ARDOUR;
+double
+ArdourGlobals::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)
+{
+ bpm = max (0.01, bpm);
+ TempoMap& tempo_map = session ().tempo_map ();
+ Tempo tempo (bpm, tempo_map.tempo_at_sample (0).note_type (), bpm);
+ tempo_map.add_tempo (tempo, 0.0, 0, AudioTime);
+}
+
+double
+ArdourGlobals::position_time () const
+{
+ samplepos_t t = session ().transport_sample ();
+ samplecnt_t f = session ().sample_rate ();
+ return static_cast<double>(t) / static_cast<double>(f);
+}
+
bool
ArdourGlobals::transport_roll () const
{
@@ -50,19 +74,3 @@ ArdourGlobals::set_record_state (bool value)
basic_ui ().rec_enable_toggle ();
}
}
-
-double
-ArdourGlobals::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)
-{
- bpm = max (0.01, bpm);
- TempoMap& tempo_map = session ().tempo_map ();
- Tempo tempo (bpm, tempo_map.tempo_at_sample (0).note_type (), bpm);
- tempo_map.add_tempo (tempo, 0.0, 0, AudioTime);
-}
diff --git a/libs/surfaces/websockets/globals.h b/libs/surfaces/websockets/globals.h
index 8c3e5a2009..9b42245bf0 100644
--- a/libs/surfaces/websockets/globals.h
+++ b/libs/surfaces/websockets/globals.h
@@ -28,14 +28,16 @@ public:
: SurfaceComponent (surface){};
virtual ~ArdourGlobals (){};
+ double tempo () const;
+ void set_tempo (double);
+
+ double position_time () const;
+
bool transport_roll () const;
void set_transport_roll (bool);
bool record_state () const;
void set_record_state (bool);
-
- double tempo () const;
- void set_tempo (double);
};
#endif // _ardour_surface_websockets_globals_h_
diff --git a/libs/surfaces/websockets/state.h b/libs/surfaces/websockets/state.h
index 046cfebb3e..614bb15123 100644
--- a/libs/surfaces/websockets/state.h
+++ b/libs/surfaces/websockets/state.h
@@ -32,6 +32,7 @@
namespace Node
{
const std::string tempo = "tempo";
+ const std::string position_time = "position_time";
const std::string transport_roll = "transport_roll";
const std::string record_state = "record_state";
const std::string strip_description = "strip_description";