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/surfaces/control_protocol | |
parent | 5a55ac582dceeebdee48f66bce954bd86847abd8 (diff) |
implement remover_marker, jump_by_bars, and jump_by_seconds
Diffstat (limited to 'libs/surfaces/control_protocol')
-rw-r--r-- | libs/surfaces/control_protocol/basic_ui.cc | 59 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/control_protocol/basic_ui.h | 7 |
2 files changed, 66 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 (); |