summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-07-27 00:02:03 +1000
committernick_m <mainsbridge@gmail.com>2016-07-27 00:02:03 +1000
commit0272d757681106db4a2f8e1885b4a4e5f8009f1a (patch)
tree5dce0a528dc34d0f2f10292ac9e1e8e36de63888
parentca7d4447de2c453958c9961fc3413514e8de245e (diff)
downloadardour-origin/musical_ranges.zip
ardour-origin/musical_ranges.tar.gz
ardour-origin/musical_ranges.tar.bz2
Initial stab at making musical position useful for ranges.origin/musical_ranges
- ranges may be glued to bars and beats. - use exact beat for locations. - adds 'start_beat' and 'end_beat' to Location xml (may change in the future, as locations only require one position).
-rw-r--r--gtk2_ardour/ardour_ui.cc2
-rw-r--r--gtk2_ardour/editor.cc4
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_drag.cc28
-rw-r--r--gtk2_ardour/editor_markers.cc22
-rw-r--r--gtk2_ardour/editor_ops.cc54
-rw-r--r--gtk2_ardour/location_ui.cc10
-rw-r--r--libs/ardour/ardour/location.h18
-rw-r--r--libs/ardour/location.cc100
-rw-r--r--libs/ardour/midi_scene_changer.cc2
-rw-r--r--libs/ardour/session.cc6
-rw-r--r--libs/ardour/session_state.cc4
12 files changed, 140 insertions, 112 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index d667120..be1e38f 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -4651,7 +4651,7 @@ void
ARDOUR_UI::create_xrun_marker (framepos_t where)
{
if (_session) {
- Location *location = new Location (*_session, where, where, _("xrun"), Location::IsMark);
+ Location *location = new Location (*_session, where, where, _("xrun"), Location::IsMark, 0);
_session->locations()->add (location);
}
}
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 757b767..7228dc1 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -4735,7 +4735,7 @@ Editor::set_loop_range (framepos_t start, framepos_t end, string cmd)
Location* tll;
if ((tll = transport_loop_location()) == 0) {
- Location* loc = new Location (*_session, start, end, _("Loop"), Location::IsAutoLoop);
+ Location* loc = new Location (*_session, start, end, _("Loop"), Location::IsAutoLoop, get_grid_music_divisions(0));
XMLNode &before = _session->locations()->get_state();
_session->locations()->add (loc, true);
_session->set_auto_loop_location (loc);
@@ -4762,7 +4762,7 @@ Editor::set_punch_range (framepos_t start, framepos_t end, string cmd)
Location* tpl;
if ((tpl = transport_punch_location()) == 0) {
- Location* loc = new Location (*_session, start, end, _("Punch"), Location::IsAutoPunch);
+ Location* loc = new Location (*_session, start, end, _("Punch"), Location::IsAutoPunch, get_grid_music_divisions(0));
XMLNode &before = _session->locations()->get_state();
_session->locations()->add (loc, true);
_session->set_auto_punch_location (loc);
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index d45545b..f399113 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1682,7 +1682,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
void tempo_or_meter_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*);
- void build_range_marker_menu (bool, bool);
+ void build_range_marker_menu (ARDOUR::Location *, bool, bool);
void build_marker_menu (ARDOUR::Location *);
void build_tempo_marker_menu (TempoMarker *, bool);
void build_meter_marker_menu (MeterMarker *, bool);
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 6fa3cb0..4e4e2f2 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -4114,7 +4114,7 @@ MarkerDrag::motion (GdkEvent* event, bool)
/* now move it */
- copy_location->set_start (copy_location->start() + f_delta);
+ copy_location->set_start (copy_location->start() + f_delta, false, true, _editor->get_grid_music_divisions(event->button.state));
} else {
@@ -4124,27 +4124,27 @@ MarkerDrag::motion (GdkEvent* event, bool)
if (is_start) { // start-of-range marker
if (move_both || (*x).move_both) {
- copy_location->set_start (new_start);
- copy_location->set_end (new_end);
+ copy_location->set_start (new_start, false, true, _editor->get_grid_music_divisions(event->button.state));
+ copy_location->set_end (new_end, false, true, _editor->get_grid_music_divisions(event->button.state));
} else if (new_start < copy_location->end()) {
- copy_location->set_start (new_start);
+ copy_location->set_start (new_start, false, true, _editor->get_grid_music_divisions(event->button.state));
} else if (newframe > 0) {
//_editor->snap_to (next, RoundUpAlways, true);
- copy_location->set_end (next);
- copy_location->set_start (newframe);
+ copy_location->set_end (next, false, true, _editor->get_grid_music_divisions(event->button.state));
+ copy_location->set_start (newframe, false, true, _editor->get_grid_music_divisions(event->button.state));
}
} else { // end marker
if (move_both || (*x).move_both) {
- copy_location->set_end (new_end);
- copy_location->set_start (new_start);
+ copy_location->set_end (new_end, _editor->get_grid_music_divisions(event->button.state));
+ copy_location->set_start (new_start, false, true, _editor->get_grid_music_divisions(event->button.state));
} else if (new_end > copy_location->start()) {
- copy_location->set_end (new_end);
+ copy_location->set_end (new_end, false, true, _editor->get_grid_music_divisions(event->button.state));
} else if (newframe > 0) {
//_editor->snap_to (next, RoundDownAlways, true);
- copy_location->set_start (next);
- copy_location->set_end (newframe);
+ copy_location->set_start (next, false, true, _editor->get_grid_music_divisions(event->button.state));
+ copy_location->set_end (newframe, false, true, _editor->get_grid_music_divisions(event->button.state));
}
}
}
@@ -4239,9 +4239,9 @@ MarkerDrag::finished (GdkEvent* event, bool movement_occurred)
in_command = true;
}
if (location->is_mark()) {
- location->set_start (((*x).location)->start());
+ location->set_start (((*x).location)->start(), false, true, _editor->get_grid_music_divisions(event->button.state));
} else {
- location->set (((*x).location)->start(), ((*x).location)->end());
+ location->set (((*x).location)->start(), ((*x).location)->end(), true, _editor->get_grid_music_divisions(event->button.state));
}
if (location->is_session_range()) {
@@ -5433,7 +5433,7 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
}
newloc = new Location (
*_editor->session(), _editor->temp_location->start(), _editor->temp_location->end(), rangename, (Location::Flags) flags
- );
+ , _editor->get_grid_music_divisions (event->button.state));
_editor->session()->locations()->add (newloc, true);
XMLNode &after = _editor->session()->locations()->get_state();
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index d204049..70967df 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -646,7 +646,7 @@ Editor::mouse_add_new_marker (framepos_t where, bool is_cd)
if (!choose_new_marker_name(markername)) {
return;
}
- Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags);
+ Location *location = new Location (*_session, where, where, markername, (Location::Flags) flags, get_grid_music_divisions (0));
begin_reversible_command (_("add marker"));
XMLNode &before = _session->locations()->get_state();
@@ -839,7 +839,7 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
if (loc == transport_loop_location() || loc == transport_punch_location() || loc->is_session_range ()) {
if (transport_marker_menu == 0) {
- build_range_marker_menu (loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range());
+ build_range_marker_menu (loc, loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range());
}
marker_menu_item = item;
@@ -869,7 +869,7 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item)
} else if (loc->is_range_marker()) {
if (range_marker_menu == 0) {
- build_range_marker_menu (false, false);
+ build_range_marker_menu (loc, false, false);
}
marker_menu_item = item;
range_marker_menu->popup (1, ev->time);
@@ -927,7 +927,7 @@ Editor::build_marker_menu (Location* loc)
}
void
-Editor::build_range_marker_menu (bool loop_or_punch, bool session)
+Editor::build_range_marker_menu (Location* loc, bool loop_or_punch, bool session)
{
using namespace Menu_Helpers;
@@ -953,6 +953,14 @@ Editor::build_range_marker_menu (bool loop_or_punch, bool session)
items.push_back (MenuElem (_("Zoom to Range"), sigc::mem_fun (*this, &Editor::marker_menu_zoom_to_range)));
items.push_back (SeparatorElem());
+ items.push_back (CheckMenuElem (_("Glue to Bars and Beats")));
+ Gtk::CheckMenuItem* glue_item = static_cast<Gtk::CheckMenuItem*> (&items.back());
+ if (loc->position_lock_style() == MusicTime) {
+ glue_item->set_active ();
+ }
+ glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue));
+
+ items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range)));
items.push_back (SeparatorElem());
@@ -1217,13 +1225,13 @@ Editor::marker_menu_set_from_playhead ()
if ((l = find_location_from_marker (marker, is_start)) != 0) {
if (l->is_mark()) {
- l->set_start (_session->audible_frame ());
+ l->set_start (_session->audible_frame (), false, true, get_grid_music_divisions(0));
}
else {
if (is_start) {
- l->set_start (_session->audible_frame ());
+ l->set_start (_session->audible_frame (), false, true, get_grid_music_divisions(0));
} else {
- l->set_end (_session->audible_frame ());
+ l->set_end (_session->audible_frame (), false, true, get_grid_music_divisions(0));
}
}
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 5419ce9..287d68a 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -419,9 +419,9 @@ Editor::nudge_forward (bool next, bool force_playhead)
distance = next_distance;
}
if (max_framepos - distance > loc->start() + loc->length()) {
- loc->set_start (loc->start() + distance);
+ loc->set_start (loc->start() + distance, false, true, get_grid_music_divisions(0));
} else {
- loc->set_start (max_framepos - loc->length());
+ loc->set_start (max_framepos - loc->length(), false, true, get_grid_music_divisions(0));
}
} else {
distance = get_nudge_distance (loc->end(), next_distance);
@@ -429,9 +429,9 @@ Editor::nudge_forward (bool next, bool force_playhead)
distance = next_distance;
}
if (max_framepos - distance > loc->end()) {
- loc->set_end (loc->end() + distance);
+ loc->set_end (loc->end() + distance, false, true, get_grid_music_divisions(0));
} else {
- loc->set_end (max_framepos);
+ loc->set_end (max_framepos, false, true, get_grid_music_divisions(0));
}
if (loc->is_session_range()) {
_session->set_end_is_free (false);
@@ -511,9 +511,9 @@ Editor::nudge_backward (bool next, bool force_playhead)
distance = next_distance;
}
if (distance < loc->start()) {
- loc->set_start (loc->start() - distance);
+ loc->set_start (loc->start() - distance, false, true, get_grid_music_divisions(0));
} else {
- loc->set_start (0);
+ loc->set_start (0, false, true, get_grid_music_divisions(0));
}
} else {
distance = get_nudge_distance (loc->end(), next_distance);
@@ -523,9 +523,9 @@ Editor::nudge_backward (bool next, bool force_playhead)
}
if (distance < loc->end() - loc->length()) {
- loc->set_end (loc->end() - distance);
+ loc->set_end (loc->end() - distance, false, true, get_grid_music_divisions(0));
} else {
- loc->set_end (loc->length());
+ loc->set_end (loc->length(), false, true, get_grid_music_divisions(0));
}
if (loc->is_session_range()) {
_session->set_end_is_free (false);
@@ -1139,7 +1139,7 @@ Editor::selected_marker_to_region_boundary (bool with_selection, int32_t dir)
return;
}
- loc->move_to (target);
+ loc->move_to (target, 0);
}
void
@@ -1216,7 +1216,7 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir)
pos = track_frame_to_session_frame(pos, speed);
- loc->move_to (pos);
+ loc->move_to (pos, 0);
}
void
@@ -1263,7 +1263,7 @@ Editor::selected_marker_to_selection_start ()
return;
}
- loc->move_to (pos);
+ loc->move_to (pos, 0);
}
void
@@ -1298,7 +1298,7 @@ Editor::selected_marker_to_selection_end ()
return;
}
- loc->move_to (pos);
+ loc->move_to (pos, 0);
}
void
@@ -1358,10 +1358,10 @@ Editor::cursor_align (bool playhead_to_edit)
Location* loc = find_location_from_marker (*i, ignored);
if (loc->is_mark()) {
- loc->set_start (playhead_cursor->current_frame ());
+ loc->set_start (playhead_cursor->current_frame (), false, true, get_grid_music_divisions(0));
} else {
loc->set (playhead_cursor->current_frame (),
- playhead_cursor->current_frame () + loc->length());
+ playhead_cursor->current_frame () + loc->length(), true, get_grid_music_divisions(0));
}
}
}
@@ -2159,7 +2159,7 @@ Editor::add_location_from_selection ()
framepos_t end = selection->time[clicked_selection].end;
_session->locations()->next_available_name(rangename,"selection");
- Location *location = new Location (*_session, start, end, rangename, Location::IsRangeMarker);
+ Location *location = new Location (*_session, start, end, rangename, Location::IsRangeMarker, get_grid_music_divisions(0));
begin_reversible_command (_("add marker"));
@@ -2182,7 +2182,7 @@ Editor::add_location_mark (framepos_t where)
if (!choose_new_marker_name(markername)) {
return;
}
- Location *location = new Location (*_session, where, where, markername, Location::IsMark);
+ Location *location = new Location (*_session, where, where, markername, Location::IsMark, get_grid_music_divisions (0));
begin_reversible_command (_("add marker"));
XMLNode &before = _session->locations()->get_state();
@@ -2294,7 +2294,7 @@ Editor::add_locations_from_region ()
boost::shared_ptr<Region> region = (*i)->region ();
- Location *location = new Location (*_session, region->position(), region->last_frame(), region->name(), Location::IsRangeMarker);
+ Location *location = new Location (*_session, region->position(), region->last_frame(), region->name(), Location::IsRangeMarker, 0);
_session->locations()->add (location, true);
commit = true;
@@ -2335,7 +2335,7 @@ Editor::add_location_from_region ()
}
// single range spanning all selected
- Location *location = new Location (*_session, selection->regions.start(), selection->regions.end_frame(), markername, Location::IsRangeMarker);
+ Location *location = new Location (*_session, selection->regions.start(), selection->regions.end_frame(), markername, Location::IsRangeMarker, 0);
_session->locations()->add (location, true);
begin_reversible_command (_("add marker"));
@@ -2390,7 +2390,7 @@ Editor::set_mark ()
return;
}
- _session->locations()->add (new Location (*_session, pos, 0, markername, Location::IsMark), true);
+ _session->locations()->add (new Location (*_session, pos, 0, markername, Location::IsMark, 0), true);
}
void
@@ -6105,7 +6105,7 @@ Editor::set_edit_point ()
Location* loc = find_location_from_marker (selection->markers.front(), ignored);
if (loc) {
- loc->move_to (where);
+ loc->move_to (where, get_grid_music_divisions(0));
}
}
}
@@ -7356,9 +7356,9 @@ Editor::insert_time (
if ((*i)->start() >= pos) {
// move end first, in case we're moving by more than the length of the range
if (!(*i)->is_mark()) {
- (*i)->set_end ((*i)->end() + frames);
+ (*i)->set_end ((*i)->end() + frames, false, true, get_grid_music_divisions(0));
}
- (*i)->set_start ((*i)->start() + frames);
+ (*i)->set_start ((*i)->start() + frames, false, true, get_grid_music_divisions(0));
moved = true;
}
@@ -7500,20 +7500,20 @@ Editor::remove_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
// if we're removing more time than the length of the range
if ((*i)->start() >= pos && (*i)->start() < pos+frames) {
// start is within cut
- (*i)->set_start (pos); // bring the start marker to the beginning of the cut
+ (*i)->set_start (pos, false, true, get_grid_music_divisions(0)); // bring the start marker to the beginning of the cut
moved = true;
} else if ((*i)->start() >= pos+frames) {
// start (and thus entire range) lies beyond end of cut
- (*i)->set_start ((*i)->start() - frames); // slip the start marker back
+ (*i)->set_start ((*i)->start() - frames, false, true, get_grid_music_divisions(0)); // slip the start marker back
moved = true;
}
if ((*i)->end() >= pos && (*i)->end() < pos+frames) {
// end is inside cut
- (*i)->set_end (pos); // bring the end to the cut
+ (*i)->set_end (pos, false, true, get_grid_music_divisions(0)); // bring the end to the cut
moved = true;
} else if ((*i)->end() >= pos+frames) {
// end is beyond end of cut
- (*i)->set_end ((*i)->end() - frames); // slip the end marker back
+ (*i)->set_end ((*i)->end() - frames, false, true, get_grid_music_divisions(0)); // slip the end marker back
moved = true;
}
@@ -7522,7 +7522,7 @@ Editor::remove_time (framepos_t pos, framecnt_t frames, InsertTimeOption opt,
loc_kill_list.push_back(*i);
moved = true;
} else if ((*i)->start() >= pos) {
- (*i)->set_start ((*i)->start() -frames);
+ (*i)->set_start ((*i)->start() -frames, false, true, get_grid_music_divisions(0));
moved = true;
}
diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc
index 76111a4..e39200d 100644
--- a/gtk2_ardour/location_ui.cc
+++ b/gtk2_ardour/location_ui.cc
@@ -416,10 +416,10 @@ LocationEditRow::to_playhead_button_pressed (LocationPart part)
switch (part) {
case LocStart:
- location->set_start (_session->transport_frame ());
+ location->set_start (_session->transport_frame (), false, true, PublicEditor::instance().get_grid_music_divisions (0));
break;
case LocEnd:
- location->set_end (_session->transport_frame ());
+ location->set_end (_session->transport_frame (), false, true, PublicEditor::instance().get_grid_music_divisions (0));
if (location->is_session_range()) {
_session->set_end_is_free (false);
}
@@ -463,16 +463,16 @@ LocationEditRow::clock_changed (LocationPart part)
switch (part) {
case LocStart:
- location->set_start (start_clock.current_time());
+ location->set_start (start_clock.current_time(), false, true, PublicEditor::instance().get_grid_music_divisions (0));
break;
case LocEnd:
- location->set_end (end_clock.current_time());
+ location->set_end (end_clock.current_time(), false, true, PublicEditor::instance().get_grid_music_divisions (0));
if (location->is_session_range()) {
_session->set_end_is_free (false);
}
break;
case LocLength:
- location->set_end (location->start() + length_clock.current_duration());
+ location->set_end (location->start() + length_clock.current_duration(), false, true, PublicEditor::instance().get_grid_music_divisions (0));
if (location->is_session_range()) {
_session->set_end_is_free (false);
}
diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h
index d31e9dc..5e26640 100644
--- a/libs/ardour/ardour/location.h
+++ b/libs/ardour/ardour/location.h
@@ -58,7 +58,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest
};
Location (Session &);
- Location (Session &, framepos_t, framepos_t, const std::string &, Flags bits = Flags(0));
+ Location (Session &, framepos_t, framepos_t, const std::string &, Flags bits = Flags(0), const uint32_t sub_num = 0);
Location (const Location& other);
Location (Session &, const XMLNode&);
Location* operator= (const Location& other);
@@ -73,11 +73,11 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest
framepos_t end() const { return _end; }
framecnt_t length() const { return _end - _start; }
- int set_start (framepos_t s, bool force = false, bool allow_bbt_recompute = true);
- int set_end (framepos_t e, bool force = false, bool allow_bbt_recompute = true);
- int set (framepos_t start, framepos_t end, bool allow_bbt_recompute = true);
+ int set_start (framepos_t s, bool force = false, bool allow_beat_recompute = true, const uint32_t sub_num = 0);
+ int set_end (framepos_t e, bool force = false, bool allow_beat_recompute = true, const uint32_t sub_num = 0);
+ int set (framepos_t start, framepos_t end, bool allow_beat_recompute = true, const uint32_t sub_num = 0);
- int move_to (framepos_t pos);
+ int move_to (framepos_t pos, const uint32_t sub_num);
const std::string& name() const { return _name; }
void set_name (const std::string &str);
@@ -143,7 +143,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest
PositionLockStyle position_lock_style() const { return _position_lock_style; }
void set_position_lock_style (PositionLockStyle ps);
- void recompute_frames_from_bbt ();
+ void recompute_frames_from_beat ();
static PBD::Signal0<void> scene_changed; /* for use by backend scene change management, class level */
PBD::Signal0<void> SceneChangeChanged; /* for use by objects interested in this object */
@@ -151,9 +151,9 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest
private:
std::string _name;
framepos_t _start;
- double _bbt_start;
+ double _start_beat;
framepos_t _end;
- double _bbt_end;
+ double _end_beat;
Flags _flags;
bool _locked;
PositionLockStyle _position_lock_style;
@@ -161,7 +161,7 @@ class LIBARDOUR_API Location : public SessionHandleRef, public PBD::StatefulDest
void set_mark (bool yn);
bool set_flag_internal (bool yn, Flags flag);
- void recompute_bbt_from_frames ();
+ void recompute_beat_from_frames (const uint32_t sub_num);
};
/** A collection of session locations including unique dedicated locations (loop, punch, etc) */
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index 0a48b43..d1fe653 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -54,7 +54,9 @@ PBD::Signal1<void,Location*> Location::changed;
Location::Location (Session& s)
: SessionHandleRef (s)
, _start (0)
+ , _start_beat (0.0)
, _end (0)
+ , _end_beat (0.0)
, _flags (Flags (0))
, _locked (false)
, _position_lock_style (AudioTime)
@@ -64,7 +66,7 @@ Location::Location (Session& s)
}
/** Construct a new Location, giving it the position lock style determined by glue-new-markers-to-bars-and-beats */
-Location::Location (Session& s, framepos_t sample_start, framepos_t sample_end, const std::string &name, Flags bits)
+Location::Location (Session& s, framepos_t sample_start, framepos_t sample_end, const std::string &name, Flags bits, const uint32_t sub_num)
: SessionHandleRef (s)
, _name (name)
, _start (sample_start)
@@ -74,7 +76,7 @@ Location::Location (Session& s, framepos_t sample_start, framepos_t sample_end,
, _position_lock_style (s.config.get_glue_new_markers_to_bars_and_beats() ? MusicTime : AudioTime)
{
- recompute_bbt_from_frames ();
+ recompute_beat_from_frames (sub_num);
assert (_start >= 0);
assert (_end >= 0);
@@ -85,9 +87,9 @@ Location::Location (const Location& other)
, StatefulDestructible()
, _name (other._name)
, _start (other._start)
- , _bbt_start (other._bbt_start)
+ , _start_beat (other._start_beat)
, _end (other._end)
- , _bbt_end (other._bbt_end)
+ , _end_beat (other._end_beat)
, _flags (other._flags)
, _position_lock_style (other._position_lock_style)
@@ -125,8 +127,8 @@ Location::operator== (const Location& other)
if (_name != other._name ||
_start != other._start ||
_end != other._end ||
- _bbt_start != other._bbt_start ||
- _bbt_end != other._bbt_end ||
+ _start_beat != other._start_beat ||
+ _end_beat != other._end_beat ||
_flags != other._flags ||
_position_lock_style != other._position_lock_style) {
return false;
@@ -143,9 +145,9 @@ Location::operator= (const Location& other)
_name = other._name;
_start = other._start;
- _bbt_start = other._bbt_start;
+ _start_beat = other._start_beat;
_end = other._end;
- _bbt_end = other._bbt_end;
+ _end_beat = other._end_beat;
_flags = other._flags;
_position_lock_style = other._position_lock_style;
@@ -178,10 +180,10 @@ Location::set_name (const std::string& str)
/** Set start position.
* @param s New start.
* @param force true to force setting, even if the given new start is after the current end.
- * @param allow_bbt_recompute True to recompute BBT start time from the new given start time.
+ * @param allow_beat_recompute True to recompute BEAT start time from the new given start time.
*/
int
-Location::set_start (framepos_t s, bool force, bool allow_bbt_recompute)
+Location::set_start (framepos_t s, bool force, bool allow_beat_recompute, const uint32_t sub_num)
{
if (s < 0) {
return -1;
@@ -201,8 +203,8 @@ Location::set_start (framepos_t s, bool force, bool allow_bbt_recompute)
if (_start != s) {
_start = s;
_end = s;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
start_changed (this); /* EMIT SIGNAL */
@@ -235,8 +237,8 @@ Location::set_start (framepos_t s, bool force, bool allow_bbt_recompute)
framepos_t const old = _start;
_start = s;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
start_changed (this); /* EMIT SIGNAL */
StartChanged (); /* EMIT SIGNAL */
@@ -255,10 +257,10 @@ Location::set_start (framepos_t s, bool force, bool allow_bbt_recompute)
/** Set end position.
* @param s New end.
* @param force true to force setting, even if the given new end is before the current start.
- * @param allow_bbt_recompute True to recompute BBT end time from the new given end time.
+ * @param allow_beat_recompute True to recompute BEAT end time from the new given end time.
*/
int
-Location::set_end (framepos_t e, bool force, bool allow_bbt_recompute)
+Location::set_end (framepos_t e, bool force, bool allow_beat_recompute, const uint32_t sub_num)
{
if (e < 0) {
return -1;
@@ -278,8 +280,8 @@ Location::set_end (framepos_t e, bool force, bool allow_bbt_recompute)
if (_start != e) {
_start = e;
_end = e;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
//start_changed (this); /* EMIT SIGNAL */
//StartChanged (); /* EMIT SIGNAL */
@@ -303,8 +305,8 @@ Location::set_end (framepos_t e, bool force, bool allow_bbt_recompute)
framepos_t const old = _end;
_end = e;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
end_changed(this); /* EMIT SIGNAL */
@@ -321,7 +323,7 @@ Location::set_end (framepos_t e, bool force, bool allow_bbt_recompute)
}
int
-Location::set (framepos_t s, framepos_t e, bool allow_bbt_recompute)
+Location::set (framepos_t s, framepos_t e, bool allow_beat_recompute, const uint32_t sub_num)
{
if (s < 0 || e < 0) {
return -1;
@@ -341,8 +343,8 @@ Location::set (framepos_t s, framepos_t e, bool allow_bbt_recompute)
_start = s;
_end = s;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
start_change = true;
@@ -364,8 +366,8 @@ Location::set (framepos_t s, framepos_t e, bool allow_bbt_recompute)
framepos_t const old = _start;
_start = s;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
start_change = true;
@@ -382,8 +384,8 @@ Location::set (framepos_t s, framepos_t e, bool allow_bbt_recompute)
framepos_t const old = _end;
_end = e;
- if (allow_bbt_recompute) {
- recompute_bbt_from_frames ();
+ if (allow_beat_recompute) {
+ recompute_beat_from_frames (sub_num);
}
end_change = true;
@@ -411,7 +413,7 @@ Location::set (framepos_t s, framepos_t e, bool allow_bbt_recompute)
}
int
-Location::move_to (framepos_t pos)
+Location::move_to (framepos_t pos, const uint32_t sub_num)
{
if (pos < 0) {
return -1;
@@ -424,7 +426,7 @@ Location::move_to (framepos_t pos)
if (_start != pos) {
_start = pos;
_end = _start + length();
- recompute_bbt_from_frames ();
+ recompute_beat_from_frames (sub_num);
changed (this); /* EMIT SIGNAL */
Changed (); /* EMIT SIGNAL */
@@ -580,6 +582,14 @@ Location::get_state ()
node->add_property ("start", buf);
snprintf (buf, sizeof (buf), "%" PRId64, end());
node->add_property ("end", buf);
+
+ if (position_lock_style() == MusicTime) {
+ snprintf (buf, sizeof (buf), "%lf", _start_beat);
+ node->add_property ("start-beat", buf);
+ snprintf (buf, sizeof (buf), "%lf", _end_beat);
+ node->add_property ("end-beat", buf);
+ }
+
node->add_property ("flags", enum_2_string (_flags));
node->add_property ("locked", (_locked ? "yes" : "no"));
node->add_property ("position-lock-style", enum_2_string (_position_lock_style));
@@ -637,6 +647,14 @@ Location::set_state (const XMLNode& node, int version)
sscanf (prop->value().c_str(), "%" PRId64, &_end);
+ if ((prop = node.property ("start-beat")) != 0) {
+ sscanf (prop->value().c_str(), "%lf", &_start_beat);
+ }
+
+ if ((prop = node.property ("end-beat")) != 0) {
+ sscanf (prop->value().c_str(), "%lf", &_end_beat);
+ }
+
if ((prop = node.property ("flags")) == 0) {
error << _("XML node for Location has no flags information") << endmsg;
return -1;
@@ -689,7 +707,9 @@ Location::set_state (const XMLNode& node, int version)
_scene_change = SceneChange::factory (*scene_child, version);
}
- recompute_bbt_from_frames ();
+ if (position_lock_style() == AudioTime) {
+ recompute_beat_from_frames (0);
+ }
changed (this); /* EMIT SIGNAL */
Changed (); /* EMIT SIGNAL */
@@ -709,32 +729,32 @@ Location::set_position_lock_style (PositionLockStyle ps)
_position_lock_style = ps;
- recompute_bbt_from_frames ();
+ if (ps == MusicTime) {
+ recompute_beat_from_frames (0);
+ }
position_lock_style_changed (this); /* EMIT SIGNAL */
PositionLockStyleChanged (); /* EMIT SIGNAL */
}
void
-Location::recompute_bbt_from_frames ()
+Location::recompute_beat_from_frames (const uint32_t sub_num)
{
- if (_position_lock_style != MusicTime) {
- return;
- }
+ /* always set the beat - even if we're in AudioTime */
- _bbt_start = _session.tempo_map().beat_at_frame (_start);
- _bbt_end = _session.tempo_map().beat_at_frame (_end);
+ _start_beat = _session.tempo_map().exact_beat_at_frame (_start, sub_num);
+ _end_beat = _session.tempo_map().exact_beat_at_frame (_end, sub_num);
}
void
-Location::recompute_frames_from_bbt ()
+Location::recompute_frames_from_beat ()
{
if (_position_lock_style != MusicTime) {
return;
}
TempoMap& map (_session.tempo_map());
- set (map.frame_at_beat (_bbt_start), map.frame_at_beat (_bbt_end), false);
+ set (map.frame_at_beat (_start_beat), map.frame_at_beat (_end_beat), false);
}
void
@@ -1056,7 +1076,7 @@ Locations::set_state (const XMLNode& node, int version)
Location* session_range_location = 0;
if (version < 3000) {
- session_range_location = new Location (_session, 0, 0, _("session"), Location::IsSessionRange);
+ session_range_location = new Location (_session, 0, 0, _("session"), Location::IsSessionRange, 0);
new_locations.push_back (session_range_location);
}
diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc
index 07eb549..6447006 100644
--- a/libs/ardour/midi_scene_changer.cc
+++ b/libs/ardour/midi_scene_changer.cc
@@ -314,7 +314,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program
return;
}
- loc = new Location (_session, time, time, new_name, Location::IsMark);
+ loc = new Location (_session, time, time, new_name, Location::IsMark, 0);
new_mark = true;
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 99efc1c..16ea5e7 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1664,7 +1664,7 @@ Session::set_session_extents (framepos_t start, framepos_t end)
Location* existing;
if ((existing = _locations->session_range_location()) == 0) {
//if there is no existing session, we need to make a new session location (should never happen)
- existing = new Location (*this, 0, 0, _("session"), Location::IsSessionRange);
+ existing = new Location (*this, 0, 0, _("session"), Location::IsSessionRange, 0);
}
if (end <= start) {
@@ -5550,7 +5550,7 @@ void
Session::update_locations_after_tempo_map_change (const Locations::LocationList& loc)
{
for (Locations::LocationList::const_iterator i = loc.begin(); i != loc.end(); ++i) {
- (*i)->recompute_frames_from_bbt ();
+ (*i)->recompute_frames_from_beat ();
}
}
@@ -6300,7 +6300,7 @@ Session::current_end_frame () const
void
Session::set_session_range_location (framepos_t start, framepos_t end)
{
- _session_range_location = new Location (*this, start, end, _("session"), Location::IsSessionRange);
+ _session_range_location = new Location (*this, start, end, _("session"), Location::IsSessionRange, 0);
_locations->add (_session_range_location);
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 76cf2d3..54b2b68 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -623,7 +623,7 @@ Session::create (const string& session_template, BusProfile* bus_profile)
/* Initial loop location, from absolute zero, length 10 seconds */
- Location* loc = new Location (*this, 0, 10.0 * _engine.sample_rate(), _("Loop"), Location::IsAutoLoop);
+ Location* loc = new Location (*this, 0, 10.0 * _engine.sample_rate(), _("Loop"), Location::IsAutoLoop, 0);
_locations->add (loc, true);
set_auto_loop_location (loc);
}
@@ -1202,7 +1202,7 @@ Session::state (bool full_state)
Locations loc (*this);
// for a template, just create a new Locations, populate it
// with the default start and end, and get the state for that.
- Location* range = new Location (*this, 0, 0, _("session"), Location::IsSessionRange);
+ Location* range = new Location (*this, 0, 0, _("session"), Location::IsSessionRange, 0);
range->set (max_framepos, 0);
loc.add (range);
XMLNode& locations_state = loc.get_state();