WebSockets: output position time in seconds
This commit is contained in:
parent
bfbb15011c
commit
dc97bf3ff0
|
@ -31,6 +31,8 @@ using namespace ARDOUR;
|
||||||
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 (transport_roll)
|
||||||
|
NODE_METHOD_PAIR (record_state)
|
||||||
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)
|
||||||
|
@ -53,9 +55,10 @@ WebsocketsDispatcher::dispatch (Client client, const NodeStateMessage& msg)
|
||||||
void
|
void
|
||||||
WebsocketsDispatcher::update_all_nodes (Client client)
|
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::transport_roll, globals ().transport_roll ());
|
||||||
update (client, Node::record_state, globals ().record_state ());
|
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) {
|
for (uint32_t strip_n = 0; strip_n < strips ().strip_count (); ++strip_n) {
|
||||||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||||
|
@ -135,6 +138,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
|
void
|
||||||
WebsocketsDispatcher::strip_gain_handler (Client client, const NodeStateMessage& msg)
|
WebsocketsDispatcher::strip_gain_handler (Client client, const NodeStateMessage& msg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,6 +42,8 @@ private:
|
||||||
static NodeMethodMap _node_to_method;
|
static NodeMethodMap _node_to_method;
|
||||||
|
|
||||||
void tempo_handler (Client, const NodeStateMessage&);
|
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_gain_handler (Client, const NodeStateMessage&);
|
||||||
void strip_pan_handler (Client, const NodeStateMessage&);
|
void strip_pan_handler (Client, const NodeStateMessage&);
|
||||||
void strip_mute_handler (Client, const NodeStateMessage&);
|
void strip_mute_handler (Client, const NodeStateMessage&);
|
||||||
|
|
|
@ -162,6 +162,8 @@ ArdourFeedback::update_all (std::string node, uint32_t strip_n, uint32_t plugin_
|
||||||
bool
|
bool
|
||||||
ArdourFeedback::poll () const
|
ArdourFeedback::poll () const
|
||||||
{
|
{
|
||||||
|
update_all (Node::position_time, globals ().position_time ());
|
||||||
|
|
||||||
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) {
|
||||||
// meters
|
// meters
|
||||||
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
boost::shared_ptr<Stripable> strip = strips ().nth_strip (strip_n);
|
||||||
|
|
|
@ -22,6 +22,30 @@
|
||||||
|
|
||||||
using namespace ARDOUR;
|
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
|
bool
|
||||||
ArdourGlobals::transport_roll () const
|
ArdourGlobals::transport_roll () const
|
||||||
{
|
{
|
||||||
|
@ -50,19 +74,3 @@ ArdourGlobals::set_record_state (bool value)
|
||||||
basic_ui ().rec_enable_toggle ();
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,14 +28,16 @@ public:
|
||||||
: SurfaceComponent (surface){};
|
: SurfaceComponent (surface){};
|
||||||
virtual ~ArdourGlobals (){};
|
virtual ~ArdourGlobals (){};
|
||||||
|
|
||||||
|
double tempo () const;
|
||||||
|
void set_tempo (double);
|
||||||
|
|
||||||
|
double position_time () const;
|
||||||
|
|
||||||
bool transport_roll () const;
|
bool transport_roll () const;
|
||||||
void set_transport_roll (bool);
|
void set_transport_roll (bool);
|
||||||
|
|
||||||
bool record_state () const;
|
bool record_state () const;
|
||||||
void set_record_state (bool);
|
void set_record_state (bool);
|
||||||
|
|
||||||
double tempo () const;
|
|
||||||
void set_tempo (double);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ardour_surface_websockets_globals_h_
|
#endif // _ardour_surface_websockets_globals_h_
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
namespace Node
|
namespace Node
|
||||||
{
|
{
|
||||||
const std::string tempo = "tempo";
|
const std::string tempo = "tempo";
|
||||||
|
const std::string position_time = "position_time";
|
||||||
const std::string transport_roll = "transport_roll";
|
const std::string transport_roll = "transport_roll";
|
||||||
const std::string record_state = "record_state";
|
const std::string record_state = "record_state";
|
||||||
const std::string strip_description = "strip_description";
|
const std::string strip_description = "strip_description";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user