diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2016-01-15 16:40:46 -0600 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-01-18 18:24:14 +0100 |
commit | f0d9295dd65731bcf4eda2a9999cca4859377a42 (patch) | |
tree | 7baebcba8af33a3fe53ac75c9e7339efd8b5db3f /libs | |
parent | 5a55ac582dceeebdee48f66bce954bd86847abd8 (diff) |
implement remover_marker, jump_by_bars, and jump_by_seconds
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/control_protocol/basic_ui.cc | 59 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/control_protocol/basic_ui.h | 7 | ||||
-rw-r--r-- | libs/surfaces/osc/osc.cc | 9 | ||||
-rw-r--r-- | libs/surfaces/osc/osc.h | 4 |
4 files changed, 79 insertions, 0 deletions
diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 8580d1b495..100b925ecd 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -23,6 +23,7 @@ #include "ardour/session.h" #include "ardour/location.h" +#include "ardour/tempo.h" #include "control_protocol/basic_ui.h" @@ -125,6 +126,34 @@ BasicUI::add_marker (const std::string& markername) } void +BasicUI::remove_marker_at_playhead () +{ + if (session) { + //set up for undo + XMLNode &before = session->locations()->get_state(); + bool removed = false; + + //find location(s) at this time + Locations::LocationList locs; + session->locations()->find_all_between (session->audible_frame(), session->audible_frame()+1, locs, Location::Flags(0)); + for (Locations::LocationList::iterator i = locs.begin(); i != locs.end(); ++i) { + if ((*i)->is_mark()) { + session->locations()->remove (*i); + removed = true; + } + } + + //store undo + if (removed) { + session->begin_reversible_command (_("remove marker")); + XMLNode &after = session->locations()->get_state(); + session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after)); + session->commit_reversible_command (); + } + } +} + +void BasicUI::rewind () { session->request_transport_speed (session->transport_speed() - 1.5); @@ -286,6 +315,36 @@ BasicUI::locate (framepos_t where, bool roll_after_locate) session->request_locate (where, roll_after_locate); } +void +BasicUI::jump_by_seconds (double secs) +{ + framepos_t current = session->transport_frame(); + double s = (double) current / (double) session->nominal_frame_rate(); + + s+= secs; + if (s < 0) current = 0; + s = s * session->nominal_frame_rate(); + + session->request_locate ( floor(s) ); +} + +void +BasicUI::jump_by_bars (double bars) +{ + Timecode::BBT_Time bbt; + TempoMap& tmap (session->tempo_map()); + tmap.bbt_time (session->transport_frame(), bbt); + + bars += bbt.bars; + if (bars < 0) bars = 0; + + AnyTime any; + any.type = AnyTime::BBT; + any.bbt.bars = bars; + + session->request_locate ( session->convert_to_frames (any) ); +} + bool BasicUI::locating () { diff --git a/libs/surfaces/control_protocol/control_protocol/basic_ui.h b/libs/surfaces/control_protocol/control_protocol/basic_ui.h index d11fa3bdeb..2f30c9929e 100644 --- a/libs/surfaces/control_protocol/control_protocol/basic_ui.h +++ b/libs/surfaces/control_protocol/control_protocol/basic_ui.h @@ -43,6 +43,10 @@ class LIBCONTROLCP_API BasicUI { virtual ~BasicUI (); void add_marker (const std::string& = std::string()); + void remove_marker_at_playhead (); + +// void mark_in(); +// void mark_out(); void register_thread (std::string name); @@ -62,6 +66,9 @@ class LIBCONTROLCP_API BasicUI { void set_transport_speed (double speed); double get_transport_speed (); + void jump_by_seconds( double sec ); + void jump_by_bars(double bars); + ARDOUR::framepos_t transport_frame (); void locate (ARDOUR::framepos_t frame, bool play = false); bool locating (); diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 328acc7222..c91d0b4206 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -336,6 +336,7 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/routes/list", "", routes_list); REGISTER_CALLBACK (serv, "/ardour/add_marker", "", add_marker); + REGISTER_CALLBACK (serv, "/ardour/remove_marker", "", remove_marker_at_playhead); REGISTER_CALLBACK (serv, "/ardour/access_action", "s", access_action); REGISTER_CALLBACK (serv, "/ardour/loop_toggle", "", loop_toggle); REGISTER_CALLBACK (serv, "/ardour/loop_location", "ii", loop_location); @@ -359,6 +360,9 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/ardour/toggle_punch_out", "", toggle_punch_out); REGISTER_CALLBACK (serv, "/ardour/rec_enable_toggle", "", rec_enable_toggle); REGISTER_CALLBACK (serv, "/ardour/toggle_all_rec_enables", "", toggle_all_rec_enables); + REGISTER_CALLBACK (serv, "/ardour/jump_bars", "f", jump_by_bars); + REGISTER_CALLBACK (serv, "/ardour/jump_seconds", "f", jump_by_seconds); + /* * NOTE: these messages are provided for (arguably broken) apps @@ -372,6 +376,7 @@ OSC::register_callbacks() */ REGISTER_CALLBACK (serv, "/ardour/pushbutton/loop_toggle", "f", loop_toggle); REGISTER_CALLBACK (serv, "/ardour/pushbutton/add_marker", "f", add_marker); + REGISTER_CALLBACK (serv, "/ardour/pushbutton/remove_marker", "f", remove_marker_at_playhead); REGISTER_CALLBACK (serv, "/ardour/pushbutton/goto_start", "f", goto_start); REGISTER_CALLBACK (serv, "/ardour/pushbutton/goto_end", "f", goto_end); REGISTER_CALLBACK (serv, "/ardour/pushbutton/rewind", "f", rewind); @@ -388,6 +393,10 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/ardour/pushbutton/rec_enable_toggle", "f", rec_enable_toggle); REGISTER_CALLBACK (serv, "/ardour/pushbutton/toggle_all_rec_enables", "f", toggle_all_rec_enables); + //ToDo +// REGISTER_CALLBACK (serv, "/ardour/pushbutton/mark_in", "f", mark_in); +// REGISTER_CALLBACK (serv, "/ardour/pushbutton/mark_out", "f", mark_out); + REGISTER_CALLBACK (serv, "/ardour/routes/mute", "ii", route_mute); REGISTER_CALLBACK (serv, "/ardour/routes/solo", "ii", route_solo); REGISTER_CALLBACK (serv, "/ardour/routes/recenable", "ii", route_recenable); diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index 7f14a2e95e..72e6b3ef3e 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -175,6 +175,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> } PATH_CALLBACK(add_marker); + PATH_CALLBACK(remove_marker_at_playhead); PATH_CALLBACK(loop_toggle); PATH_CALLBACK(goto_start); PATH_CALLBACK(goto_end); @@ -207,6 +208,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> PATH_CALLBACK1(set_transport_speed,f,); PATH_CALLBACK1(access_action,s,&); + PATH_CALLBACK1(jump_by_bars,f,); + PATH_CALLBACK1(jump_by_seconds,f,); + #define PATH_CALLBACK2(name,arg1type,arg2type) \ static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \ return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \ |