surfaces: first round of conversion to use timeline types

This commit is contained in:
Paul Davis
2020-09-21 14:28:23 -06:00
parent cdb1972928
commit 086e48796c
23 changed files with 98 additions and 83 deletions

View File

@@ -309,7 +309,7 @@ CC121::button_press_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
if (_current_stripable) {
boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
if (gain) {
samplepos_t now = session->engine().sample_time();
timepos_t now (session->engine().sample_time());
gain->start_touch (now);
}
}
@@ -352,15 +352,15 @@ CC121::button_release_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
switch (id) {
case FaderTouch:
fader_is_touched = false;
if (_current_stripable) {
boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
if (gain) {
samplepos_t now = session->engine().sample_time();
gain->stop_touch (now);
}
}
break;
fader_is_touched = false;
if (_current_stripable) {
boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
if (gain) {
timepos_t now (session->engine().sample_time());
gain->stop_touch (now);
}
}
break;
default:
break;
}

View File

@@ -240,7 +240,7 @@ CC121::set_controllable (boost::shared_ptr<AutomationControl> ac, float delta)
if (!ac || delta == 0) {
return;
}
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
ac->set_interface ((ac->internal_to_interface (ac->get_value(), true) + delta), true);
}

View File

@@ -559,11 +559,10 @@ ContourDesignControlProtocol::handle_button_release (unsigned short btn)
void
ContourDesignControlProtocol::prev_marker_keep_rolling ()
{
samplepos_t pos = session->locations()->first_mark_before (session->transport_sample());
timepos_t pos = session->locations()->first_mark_before (timepos_t (session->transport_sample()));
if (pos >= 0) {
session->request_locate (pos);
if (pos.positive() || pos.zero()) {
session->request_locate (pos.samples());
} else {
session->goto_start ();
}
@@ -572,10 +571,10 @@ ContourDesignControlProtocol::prev_marker_keep_rolling ()
void
ContourDesignControlProtocol::next_marker_keep_rolling ()
{
samplepos_t pos = session->locations()->first_mark_after (session->transport_sample());
timepos_t pos = session->locations()->first_mark_after (timepos_t (session->transport_sample()));
if (pos >= 0) {
session->request_locate (pos);
if (pos.positive() || pos.zero()) {
session->request_locate (pos.samples());
} else {
session->goto_end();
}

View File

@@ -113,7 +113,7 @@ BasicUI::loop_toggle ()
}
void
BasicUI::loop_location (samplepos_t start, samplepos_t end)
BasicUI::loop_location (timepos_t const & start, timepos_t const & end)
{
Location* tll;
if ((tll = session->locations()->auto_loop_location()) == 0) {
@@ -147,7 +147,7 @@ BasicUI::goto_end ()
void
BasicUI::add_marker (const std::string& markername)
{
samplepos_t where = session->audible_sample();
timepos_t where (session->audible_sample());
Location *location = new Location (*session, where, where, markername, Location::IsMark);
session->begin_reversible_command (_("add marker"));
XMLNode &before = session->locations()->get_state();
@@ -167,7 +167,7 @@ BasicUI::remove_marker_at_playhead ()
//find location(s) at this time
Locations::LocationList locs;
session->locations()->find_all_between (session->audible_sample(), session->audible_sample()+1, locs, Location::Flags(0));
session->locations()->find_all_between (timepos_t (session->audible_sample()), timepos_t (session->audible_sample()+1), locs, Location::Flags(0));
for (Locations::LocationList::iterator i = locs.begin(); i != locs.end(); ++i) {
if ((*i)->is_mark()) {
session->locations()->remove (*i);
@@ -420,10 +420,10 @@ BasicUI::save_state ()
void
BasicUI::prev_marker ()
{
samplepos_t pos = session->locations()->first_mark_before (session->transport_sample());
timepos_t pos = session->locations()->first_mark_before (timepos_t (session->transport_sample()));
if (pos >= 0) {
session->request_locate (pos);
session->request_locate (pos.samples());
} else {
session->goto_start ();
}
@@ -432,10 +432,10 @@ BasicUI::prev_marker ()
void
BasicUI::next_marker ()
{
samplepos_t pos = session->locations()->first_mark_after (session->transport_sample());
timepos_t pos = session->locations()->first_mark_after (timepos_t (session->transport_sample()));
if (pos >= 0) {
session->request_locate (pos);
session->request_locate (pos.samples());
} else {
session->goto_end();
}
@@ -679,7 +679,7 @@ BasicUI::toggle_roll (bool roll_out_of_bounded_mode)
} else { /* not rolling */
if (session->get_play_loop() && Config->get_loop_is_mode()) {
session->request_locate (session->locations()->auto_loop_location()->start(), MustRoll);
session->request_locate (session->locations()->auto_loop_location()->start().samples(), MustRoll);
} else {
session->request_roll (TRS_UI);
}
@@ -794,7 +794,7 @@ BasicUI::goto_nth_marker (int n)
for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
if (n == 0) {
session->request_locate ((*i)->start());
session->request_locate ((*i)->start().samples());
break;
}
--n;

View File

@@ -28,6 +28,8 @@
#include "pbd/signals.h"
#include "temporal/timeline.h"
#include "ardour/types.h"
#include "ardour/presentation_info.h"
@@ -57,7 +59,7 @@ class LIBCONTROLCP_API BasicUI {
/* transport control */
void loop_toggle ();
void loop_location (samplepos_t start, samplepos_t end);
void loop_location (Temporal::timepos_t const & start, Temporal::timepos_t const & end);
void access_action ( std::string action_path );
static PBD::Signal2<void,std::string,std::string> AccessAction;
void goto_zero ();

View File

@@ -367,7 +367,7 @@ FaderPort::button_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
if (_current_stripable) {
boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
if (gain) {
samplepos_t now = session->engine().sample_time();
timepos_t now = timepos_t (session->engine().sample_time());
if (tb->value) {
gain->start_touch (now);
} else {

View File

@@ -345,7 +345,7 @@ FaderPort8::button_solo_clear ()
if (!ac) {
continue;
}
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
cl->push_back (ac);
}
if (!cl->empty()) {
@@ -370,7 +370,7 @@ FaderPort8::button_mute_clear ()
continue;
}
cl->push_back (ac);
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
}
if (!cl->empty()) {
session->set_controls (cl, 1.0, PBD::Controllable::NoGroup);
@@ -410,7 +410,7 @@ FaderPort8::handle_encoder_pan (int steps)
ac = s->pan_azimuth_control ();
}
if (ac) {
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
if (steps == 0) {
ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
} else {
@@ -434,7 +434,7 @@ FaderPort8::handle_encoder_link (int steps)
}
double v = ac->internal_to_interface (ac->get_value(), true);
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
if (steps == 0) {
ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
@@ -554,7 +554,7 @@ FaderPort8::button_encoder ()
ac = session->master_out()->gain_control ();
}
if (ac) {
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
ac->set_value (ac->normal(), PBD::Controllable::NoGroup);
}
}
@@ -571,7 +571,7 @@ FaderPort8::button_encoder ()
* the current position and we're not rolling.
*/
samplepos_t where = session->audible_sample();
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (where, session->sample_rate() / 100.0)) {
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (timepos_t (where), timecnt_t (session->sample_rate() / 100.0))) {
return;
}
@@ -636,7 +636,7 @@ FaderPort8::encoder_navigate (bool neg, int steps)
if (ac) {
double v = ac->internal_to_interface (ac->get_value());
v = std::max (0.0, std::min (1.0, v + steps * (neg ? -.01 : .01)));
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
ac->set_value (ac->interface_to_internal(v), PBD::Controllable::NoGroup);
}
}

View File

@@ -1718,7 +1718,7 @@ FaderPort8::select_strip (boost::weak_ptr<Stripable> ws)
if (s == first_selected_stripable () && !shift_mod ()) {
if (_ctrls.fader_mode () == ModeTrack) {
boost::shared_ptr<AutomationControl> ac = s->gain_control ();
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
ac->set_value (ac->normal (), PBD::Controllable::UseGroup);
}
return;

View File

@@ -356,10 +356,11 @@ FP8Strip::midi_touch (bool t)
if (!ac) {
return false;
}
timepos_t now (ac->session().transport_sample());
if (t) {
ac->start_touch (ac->session().transport_sample());
ac->start_touch (now);
} else {
ac->stop_touch (ac->session().transport_sample());
ac->stop_touch (now);
}
return true;
}
@@ -375,7 +376,7 @@ FP8Strip::midi_fader (float val)
if (!ac) {
return false;
}
ac->start_touch (ac->session().transport_sample());
ac->start_touch (timepos_t (ac->session().transport_sample()));
ac->set_value (ac->interface_to_internal (val), group_mode ());
return true;
}
@@ -400,7 +401,7 @@ FP8Strip::set_mute (bool on)
if (!_mute_ctrl) {
return;
}
_mute_ctrl->start_touch (_mute_ctrl->session().transport_sample());
_mute_ctrl->start_touch (timepos_t (_mute_ctrl->session().transport_sample()));
_mute_ctrl->set_value (on ? 1.0 : 0.0, group_mode ());
}
@@ -410,7 +411,7 @@ FP8Strip::set_solo (bool on)
if (!_solo_ctrl) {
return;
}
_solo_ctrl->start_touch (_solo_ctrl->session().transport_sample());
_solo_ctrl->start_touch (timepos_t (_solo_ctrl->session().transport_sample()));
PBD::Controllable::GroupControlDisposition gcd = group_mode ();
Session& s = const_cast<Session&> (_solo_ctrl->session());
s.set_control (_solo_ctrl, on ? 1.0 : 0.0, gcd);
@@ -433,7 +434,7 @@ FP8Strip::set_select ()
assert (!_x_select_ctrl);
_select_plugin_functor ();
} else if (_x_select_ctrl) {
_x_select_ctrl->start_touch (_x_select_ctrl->session().transport_sample());
_x_select_ctrl->start_touch (timepos_t (_x_select_ctrl->session().transport_sample()));
const bool on = !select_button ().is_active();
_x_select_ctrl->set_value (on ? 1.0 : 0.0, group_mode ());
}

View File

@@ -1611,7 +1611,7 @@ GenericMidiControlProtocol::maybe_start_touch (boost::shared_ptr<Controllable> c
{
boost::shared_ptr<AutomationControl> actl = boost::dynamic_pointer_cast<AutomationControl> (controllable);
if (actl) {
actl->start_touch (session->audible_sample ());
actl->start_touch (timepos_t (session->audible_sample ()));
}
}

View File

@@ -97,18 +97,18 @@ Control::get_value ()
}
void
Control::start_touch (double when)
Control::start_touch (Temporal::timepos_t const & when)
{
if (normal_ac) {
return normal_ac->start_touch (when);
normal_ac->start_touch (when);
}
}
void
Control::stop_touch (double when)
Control::stop_touch (Temporal::timepos_t const & when)
{
if (normal_ac) {
return normal_ac->stop_touch (when);
normal_ac->stop_touch (when);
}
}

View File

@@ -32,6 +32,8 @@
#include "pbd/controllable.h"
#include "pbd/signals.h"
#include "temporal/timeline.h"
#include "mackie_control_exception.h"
#include "midi_byte_array.h"
@@ -75,8 +77,8 @@ public:
float get_value ();
void set_value (float val, PBD::Controllable::GroupControlDisposition gcd = PBD::Controllable::UseGroup);
virtual void start_touch (double when);
virtual void stop_touch (double when);
virtual void start_touch (Temporal::timepos_t const & when);
virtual void stop_touch (Temporal::timepos_t const & when);
protected:
boost::shared_ptr<ARDOUR::AutomationControl> normal_ac;

View File

@@ -485,7 +485,7 @@ MackieControlProtocol::marker_release (Button &)
samplepos_t where = session->audible_sample();
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (where, session->sample_rate() / 100.0)) {
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (timepos_t (where), timecnt_t (session->sample_rate() / 100.0))) {
return off;
}
@@ -865,10 +865,8 @@ MackieControlProtocol::master_fader_touch_press (Mackie::Button &)
Fader* master_fader = _master_surface->master_fader();
boost::shared_ptr<AutomationControl> ac = master_fader->control ();
master_fader->set_in_use (true);
master_fader->start_touch (transport_sample());
master_fader->start_touch (timepos_t (transport_sample()));
}
return none;
}
@@ -881,7 +879,8 @@ MackieControlProtocol::master_fader_touch_release (Mackie::Button &)
Fader* master_fader = _master_surface->master_fader();
master_fader->set_in_use (false);
master_fader->stop_touch (transport_sample());
master_fader->stop_touch (timepos_t (transport_sample()));
}
return none;
}

View File

@@ -597,7 +597,7 @@ Strip::fader_touch_event (Button&, ButtonState bs)
boost::shared_ptr<AutomationControl> ac = _fader->control ();
_fader->set_in_use (true);
_fader->start_touch (_surface->mcp().transport_sample());
_fader->start_touch (timepos_t (_surface->mcp().transport_sample()));
if (ac) {
do_parameter_display (ac->desc(), ac->get_value());
@@ -606,7 +606,7 @@ Strip::fader_touch_event (Button&, ButtonState bs)
} else {
_fader->set_in_use (false);
_fader->stop_touch (_surface->mcp().transport_sample());
_fader->stop_touch (timepos_t (_surface->mcp().transport_sample()));
}
}
@@ -749,10 +749,12 @@ Strip::do_parameter_display (ARDOUR::ParameterDescriptor const& desc, float val,
void
Strip::handle_fader_touch (Fader& fader, bool touch_on)
{
timepos_t now (_surface->mcp().transport_sample());
if (touch_on) {
fader.start_touch (_surface->mcp().transport_sample());
fader.start_touch (now);
} else {
fader.stop_touch (_surface->mcp().transport_sample());
fader.stop_touch (now);
}
}

View File

@@ -42,6 +42,8 @@
#include <pbd/file_utils.h>
#include <pbd/failed_constructor.h>
#include "temporal/timeline.h"
#include "ardour/amp.h"
#include "ardour/session.h"
#include "ardour/route.h"
@@ -3141,7 +3143,7 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg)
for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
if ((*l)->is_mark ()) {
if (strcmp (&argv[0]->s, (*l)->name().c_str()) == 0) {
session->request_locate ((*l)->start (), MustStop);
session->request_locate ((*l)->start_sample (), MustStop);
return 0;
} else if ((*l)->start () == session->transport_sample()) {
cur_mark = (*l);
@@ -3170,7 +3172,7 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg)
// get Locations that are marks
for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
if ((*l)->is_mark ()) {
lm.push_back (LocationMarker((*l)->name(), (*l)->start ()));
lm.push_back (LocationMarker((*l)->name(), (*l)->start_sample ()));
}
}
// sort them by position
@@ -3497,7 +3499,6 @@ OSC::select_parse (const char *path, const char* types, lo_arg **argv, int argc,
}
return ret;
}
@@ -5927,7 +5928,7 @@ OSC::periodic (void)
if (!(*x).second) {
boost::shared_ptr<ARDOUR::AutomationControl> ctrl = (*x).first;
// turn touch off
ctrl->stop_touch (ctrl->session().transport_sample());
ctrl->stop_touch (timepos_t (ctrl->session().transport_sample()));
_touch_timeout.erase (x++);
} else {
x++;

View File

@@ -431,12 +431,12 @@ OSCGlobalObserver::marks_changed ()
// get Locations that are marks
for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
if ((*l)->is_session_range ()) {
lm.push_back (LocationMarker(_("start"), (*l)->start ()));
lm.push_back (LocationMarker(_("end"), (*l)->end ()));
lm.push_back (LocationMarker(_("start"), (*l)->start_sample ()));
lm.push_back (LocationMarker(_("end"), (*l)->end_sample ()));
continue;
}
if ((*l)->is_mark ()) {
lm.push_back (LocationMarker((*l)->name(), (*l)->start ()));
lm.push_back (LocationMarker((*l)->name(), (*l)->start_sample ()));
}
}
// sort them by position

View File

@@ -437,10 +437,11 @@ MixLayout::strip_vpot_touch (int n, bool touching)
if (stripable[n]) {
boost::shared_ptr<AutomationControl> ac = stripable[n]->gain_control();
if (ac) {
const timepos_t now (session.audible_sample());
if (touching) {
ac->start_touch (session.audible_sample());
ac->start_touch (now);
} else {
ac->stop_touch (session.audible_sample());
ac->stop_touch (now);
}
}
}

View File

@@ -1078,10 +1078,11 @@ Push2::other_vpot_touch (int n, bool touching)
if (master) {
boost::shared_ptr<AutomationControl> ac = master->gain_control();
if (ac) {
const timepos_t now (session->audible_sample());
if (touching) {
ac->start_touch (session->audible_sample());
ac->start_touch (now);
} else {
ac->stop_touch (session->audible_sample());
ac->stop_touch (now);
}
}
}

View File

@@ -572,10 +572,11 @@ TrackMixLayout::strip_vpot_touch (int n, bool touching)
{
boost::shared_ptr<AutomationControl> ac = knobs[n]->controllable();
if (ac) {
const timepos_t now (session.audible_sample());
if (touching) {
ac->start_touch (session.audible_sample());
ac->start_touch (now);
} else {
ac->stop_touch (session.audible_sample());
ac->stop_touch (now);
}
}
}

View File

@@ -97,7 +97,7 @@ Control::get_value ()
}
void
Control::start_touch (double when)
Control::start_touch (Temporal::timepos_t const & when)
{
if (normal_ac) {
return normal_ac->start_touch (when);
@@ -105,7 +105,7 @@ Control::start_touch (double when)
}
void
Control::stop_touch (double when)
Control::stop_touch (Temporal::timepos_t const & when)
{
if (normal_ac) {
return normal_ac->stop_touch (when);

View File

@@ -36,6 +36,10 @@ namespace ARDOUR {
class AutomationControl;
}
namespace Temporal {
class timepos_t;
}
namespace ArdourSurface {
namespace US2400 {
@@ -75,8 +79,8 @@ public:
float get_value ();
void set_value (float val, PBD::Controllable::GroupControlDisposition gcd = PBD::Controllable::UseGroup);
virtual void start_touch (double when);
virtual void stop_touch (double when);
virtual void start_touch (Temporal::timepos_t const & when);
virtual void stop_touch (Temporal::timepos_t const & when);
protected:
boost::shared_ptr<ARDOUR::AutomationControl> normal_ac;

View File

@@ -458,7 +458,7 @@ US2400Protocol::marker_release (Button &)
samplepos_t where = session->audible_sample();
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (where, session->sample_rate() / 100.0)) {
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (timepos_t (where), timecnt_t (session->sample_rate() / 100.0))) {
return off;
}
@@ -851,7 +851,7 @@ US2400Protocol::master_fader_touch_press (US2400::Button &)
boost::shared_ptr<AutomationControl> ac = master_fader->control ();
master_fader->set_in_use (true);
master_fader->start_touch (transport_sample());
master_fader->start_touch (timepos_t (transport_sample()));
return none;
}
@@ -863,7 +863,7 @@ US2400Protocol::master_fader_touch_release (US2400::Button &)
Fader* master_fader = _master_surface->master_fader();
master_fader->set_in_use (false);
master_fader->stop_touch (transport_sample());
master_fader->stop_touch (timepos_t (transport_sample()));
return none;
}

View File

@@ -32,6 +32,8 @@
#include "pbd/compose.h"
#include "pbd/convert.h"
#include "temporal/timeline.h"
#include "ardour/amp.h"
#include "ardour/bundle.h"
#include "ardour/debug.h"
@@ -427,12 +429,12 @@ Strip::fader_touch_event (Button&, ButtonState bs)
boost::shared_ptr<AutomationControl> ac = _fader->control ();
_fader->set_in_use (true);
_fader->start_touch (_surface->mcp().transport_sample());
_fader->start_touch (timepos_t (_surface->mcp().transport_sample()));
} else {
_fader->set_in_use (false);
_fader->stop_touch (_surface->mcp().transport_sample());
_fader->stop_touch (timepos_t (_surface->mcp().transport_sample()));
}
}
@@ -508,9 +510,9 @@ void
Strip::handle_fader_touch (Fader& fader, bool touch_on)
{
if (touch_on) {
fader.start_touch (_surface->mcp().transport_sample());
fader.start_touch (timepos_t (_surface->mcp().transport_sample()));
} else {
fader.stop_touch (_surface->mcp().transport_sample());
fader.stop_touch (timepos_t (_surface->mcp().transport_sample()));
}
}