implement remover_marker, jump_by_bars, and jump_by_seconds

This commit is contained in:
Ben Loftis
2016-01-15 16:40:46 -06:00
committed by Robin Gareus
parent 5a55ac582d
commit f0d9295dd6
4 changed files with 79 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
#include "ardour/session.h"
#include "ardour/location.h"
#include "ardour/tempo.h"
#include "control_protocol/basic_ui.h"
@@ -124,6 +125,34 @@ BasicUI::add_marker (const std::string& markername)
session->commit_reversible_command ();
}
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 ()
{
@@ -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 ()
{

View File

@@ -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 ();

View File

@@ -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);

View File

@@ -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); \