}
}
- leftmost_frame = (nframes64_t) floor (_horizontal_position * frames_per_unit);
-
ZoomChanged (); /* EMIT_SIGNAL */
//reset_scrolling_region ();
VisualChange::Type p = pending_visual_change.pending;
pending_visual_change.pending = (VisualChange::Type) 0;
- double last_time_origin = _horizontal_position;
+ double last_time_origin = horizontal_position ();
if (p & VisualChange::ZoomLevel) {
set_frames_per_unit (pending_visual_change.frames_per_unit);
vertical_adjustment.set_value (pending_visual_change.y_origin);
}
- if (last_time_origin == _horizontal_position) {
+ if (last_time_origin == horizontal_position ()) {
/* changed signal not emitted */
update_fixed_rulers ();
redisplay_tempo (true);
Gtk::Table edit_packer;
Gtk::Adjustment vertical_adjustment;
- double _horizontal_position;
Gtk::Layout controls_layout;
bool control_layout_scroll (GdkEventScroll* ev);
double last_trackview_group_vertical_offset;
void tie_vertical_scrolling ();
void set_horizontal_position (double);
+ double horizontal_position () const;
void scroll_canvas_vertically ();
struct VisualChange {
void
Editor::set_horizontal_position (double p)
{
- _horizontal_position = p;
-
/* horizontal scrolling only */
double x1, y1, x2, y2, x_delta;
_master_group->get_bounds (x1, y1, x2, y2);
- x_delta = - (x1 + _horizontal_position);
+ x_delta = - (x1 + p);
_master_group->move (x_delta, 0);
timebar_group->move (x_delta, 0);
time_line_group->move (x_delta, 0);
cursor_group->move (x_delta, 0);
- leftmost_frame = (nframes64_t) floor (_horizontal_position * frames_per_unit);
+ leftmost_frame = (nframes64_t) floor (p * frames_per_unit);
update_fixed_rulers ();
redisplay_tempo (true);
track_canvas->update_now ();
}
}
+
+double
+Editor::horizontal_position () const
+{
+ return frame_to_unit (leftmost_frame);
+}
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
rv->get_canvas_frame()->i2w (ix1, iy1);
- if (-x_delta > ix1 + _editor->_horizontal_position) {
+ if (-x_delta > ix1 + _editor->horizontal_position()) {
x_delta = 0;
*pending_region_position = _last_frame_position;
break;
break;
}
- if (event->button.x >= _editor->_horizontal_position + _editor->_canvas_width) {
+ if (event->button.x >= _editor->horizontal_position() + _editor->_canvas_width) {
_editor->start_canvas_autoscroll (1, 0);
}
}
}
- if (event->button.x >= _editor->_horizontal_position + _editor->_canvas_width) {
+ if (event->button.x >= _editor->horizontal_position() + _editor->_canvas_width) {
_editor->start_canvas_autoscroll (1, 0);
}
}
track_canvas->window_to_world (x, y, worldx, worldy);
- worldx += _horizontal_position;
+ worldx += horizontal_position();
worldy += vertical_adjustment.get_value();
ev.type = GDK_BUTTON_PRESS;
if (xpos >= 0 && ypos >=0) {
set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
} else {
- set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset - _horizontal_position, _drags->current_pointer_y() + offset - vertical_adjustment.get_value() + canvas_timebars_vsize);
+ set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset - horizontal_position(), _drags->current_pointer_y() + offset - vertical_adjustment.get_value() + canvas_timebars_vsize);
}
show_verbose_canvas_cursor ();
}
}
void
-Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y) {
+Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y)
+{
double wx, wy;
double cx, cy;
nframes_t where;
RouteTimeAxisView *source_rtv = 0;
track_canvas->window_to_world (x, y, wx, wy);
- wx += _horizontal_position;
+ wx += horizontal_position ();
wy += vertical_adjustment.get_value();
GdkEvent event;
max_height = max (max_height, t);
}
- _x_scale = static_cast<double> (_width) / (_end - _start);
+ if (_end != _start) {
+ _x_scale = static_cast<double> (_width) / (_end - _start);
+ } else {
+ _x_scale = 1;
+ }
_y_scale = static_cast<double> (_height) / h;
/* tallest a region should ever be in the summary, in pixels */
bool hidden() const { return _hidden; }
bool empty() const;
uint32_t n_regions() const;
- framecnt_t get_maximum_extent () const;
+ std::pair<framecnt_t, framecnt_t> get_extent () const;
layer_t top_layer() const;
EditMode get_edit_mode() const { return _edit_mode; }
void copy_regions (RegionList&) const;
void partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist);
- framecnt_t _get_maximum_extent() const;
+ std::pair<framecnt_t, framecnt_t> _get_extent() const;
boost::shared_ptr<Playlist> cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(framepos_t, framecnt_t, bool),
std::list<AudioRange>& ranges, bool result_is_hidden);
PBD::Signal0<void> TransportStateChange; /* generic */
PBD::Signal1<void,nframes64_t> PositionChanged; /* sent after any non-sequential motion */
- PBD::Signal0<void> DurationChanged;
PBD::Signal1<void,nframes64_t> Xrun;
PBD::Signal0<void> TransportLooped;
bool get_play_loop () const { return play_loop; }
nframes_t last_transport_start() const { return _last_roll_location; }
- void goto_end () { request_locate (_session_range_location->end(), false);}
- void goto_start () { request_locate (_session_range_location->start(), false); }
- void set_session_start (nframes_t start) { _session_range_location->set_start(start); }
- void set_session_end (nframes_t end) { _session_range_location->set_end(end); config.set_end_marker_is_free (false); }
+ void goto_end ();
+ void goto_start ();
+ void set_session_start (nframes_t);
+ void set_session_end (nframes_t);
void use_rf_shuttle_speed ();
void allow_auto_play (bool yn);
void request_transport_speed (double speed);
int wipe ();
- nframes_t get_maximum_extent () const;
- nframes_t current_end_frame() const { return _session_range_location->end(); }
- nframes_t current_start_frame() const { return _session_range_location->start(); }
+ std::pair<nframes_t, nframes_t> get_extent () const;
+ nframes_t current_end_frame () const;
+ nframes_t current_start_frame () const;
/// "actual" sample rate of session, set by current audioengine rate, pullup/down etc.
nframes_t frame_rate() const { return _current_frame_rate; }
/// "native" sample rate of session, regardless of current audioengine rate, pullup/down etc
void update_latency_compensation (bool, bool);
private:
- int create (const std::string& mix_template, nframes_t initial_length, BusProfile*);
+ int create (const std::string& mix_template, BusProfile*);
void destroy ();
- nframes_t compute_initial_length ();
-
enum SubState {
PendingDeclickIn = 0x1,
PendingDeclickOut = 0x2,
int transport_sub_state;
mutable gint _record_status;
volatile nframes64_t _transport_frame;
- Location* _session_range_location;
+ Location* _session_range_location; ///< session range, or 0 if there is nothing in the session yet
Slave* _slave;
bool _silent;
void first_stage_init (std::string path, std::string snapshot_name);
int second_stage_init ();
- void find_current_end ();
+ void update_session_range_location_marker ();
void remove_empty_sounds ();
void setup_midi_control ();
/** temporary list of Diskstreams used only during load of 2.X sessions */
std::list<boost::shared_ptr<Diskstream> > _diskstreams_2X;
+
+ void add_session_range_location (nframes_t, nframes_t);
};
} // namespace ARDOUR
CONFIG_VARIABLE_SPECIAL(Glib::ustring, raid_path, "raid-path", "", path_expand)
CONFIG_VARIABLE (std::string, bwf_country_code, "bwf-country-code", "US")
CONFIG_VARIABLE (std::string, bwf_organization_code, "bwf-organization-code", "US")
-CONFIG_VARIABLE (bool, end_marker_is_free, "end-marker-is-free", true)
CONFIG_VARIABLE (LayerModel, layer_model, "layer-model", MoveAddHigher)
CONFIG_VARIABLE (std::string, auditioner_output_left, "auditioner-output-left", "default")
CONFIG_VARIABLE (std::string, auditioner_output_right, "auditioner-output-right", "default")
#ifdef __APPLE__
snprintf (buf, sizeof (buf), "%u-%u-%d.peak", stat_mount.st_ino, stat_file.st_ino, _channel);
#else
- snprintf (buf, sizeof (buf), "%ld-%ld-%d.peak", stat_mount.st_ino, stat_file.st_ino, _channel);
+ snprintf (buf, sizeof (buf), "%lld-%lld-%d.peak", stat_mount.st_ino, stat_file.st_ino, _channel);
#endif
ustring res = peak_dir;
Glib::Mutex::Lock lm (lock);
_diskstream->seek (0);
- length = _diskstream->playlist()->get_maximum_extent();
+ length = _diskstream->playlist()->get_extent().second;
current_frame = 0;
/* force a panner reset now that we have all channels */
void
Locations::add (Location *loc, bool make_current)
{
+ assert (loc);
+
{
Glib::Mutex::Lock lm (lock);
locations.push_back (loc);
Playlist::delay_notifications ()
{
g_atomic_int_inc (&block_notifications);
- freeze_length = _get_maximum_extent();
+ freeze_length = _get_extent().second;
}
void
if (!pending_bounds.empty() || !pending_removes.empty() || !pending_adds.empty()) {
regions_changed = true;
if (!pending_length) {
- old_length = _get_maximum_extent ();
+ old_length = _get_extent ().second;
check_length = true;
}
}
}
if (check_length) {
- if (old_length != _get_maximum_extent()) {
+ if (old_length != _get_extent().second) {
pending_length = true;
// cerr << _name << " length has changed\n";
}
}
- if (pending_length || (freeze_length != _get_maximum_extent())) {
+ if (pending_length || (freeze_length != _get_extent().second)) {
pending_length = false;
// cerr << _name << " sends LengthChanged\n";
LengthChanged(); /* EMIT SIGNAL */
framecnt_t old_length = 0;
if (!holding_state()) {
- old_length = _get_maximum_extent();
+ old_length = _get_extent().second;
}
if (!first_set_state) {
check_dependents (region, false);
- if (old_length != _get_maximum_extent()) {
+ if (old_length != _get_extent().second) {
notify_length_changed ();
}
}
int ret = -1;
if (!holding_state()) {
- old_length = _get_maximum_extent();
+ old_length = _get_extent().second;
}
if (!in_set_state) {
relayer ();
remove_dependents (region);
- if (old_length != _get_maximum_extent()) {
+ if (old_length != _get_extent().second) {
notify_length_changed ();
}
}
new_name += '.';
new_name += buf;
- cnt = min (_get_maximum_extent() - start, cnt);
+ cnt = min (_get_extent().second - start, cnt);
return PlaylistFactory::create (shared_from_this(), start, cnt, new_name, result_is_hidden);
}
RegionLock rl1 (this);
RegionLock rl2 (other.get());
- framecnt_t old_length = _get_maximum_extent();
+ framecnt_t const old_length = _get_extent().second;
int itimes = (int) floor (times);
framepos_t pos = position;
- framecnt_t shift = other->_get_maximum_extent();
+ framecnt_t const shift = other->_get_extent().second;
layer_t top_layer = regions.size();
while (itimes--) {
/* XXX shall we handle fractional cases at some point? */
- if (old_length != _get_maximum_extent()) {
+ if (old_length != _get_extent().second) {
notify_length_changed ();
}
return regions.size();
}
-framecnt_t
-Playlist::get_maximum_extent () const
+pair<framecnt_t, framecnt_t>
+Playlist::get_extent () const
{
RegionLock rlock (const_cast<Playlist *>(this), false);
- return _get_maximum_extent ();
+ return _get_extent ();
}
-framecnt_t
-Playlist::_get_maximum_extent () const
+pair<framecnt_t, framecnt_t>
+Playlist::_get_extent () const
{
- RegionList::const_iterator i;
- framecnt_t max_extent = 0;
- framepos_t end = 0;
+ pair<framecnt_t, framecnt_t> ext (max_frames, 0);
- for (i = regions.begin(); i != regions.end(); ++i) {
- if ((end = (*i)->position() + (*i)->length()) > max_extent) {
- max_extent = end;
+ for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+ pair<framecnt_t, framecnt_t> const e ((*i)->position(), (*i)->position() + (*i)->length());
+ if (e.first < ext.first) {
+ ext.first = e.first;
+ }
+ if (e.second > ext.second) {
+ ext.second = e.second;
}
}
- return max_extent;
+ return ext;
}
string
_is_new = !Glib::file_test (_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
if (_is_new) {
- if (create (mix_template, compute_initial_length(), bus_profile)) {
+ if (create (mix_template, bus_profile)) {
destroy ();
throw failed_constructor ();
}
void
Session::playlist_length_changed ()
{
- /* we can't just increase session_range_location->end() if pl->get_maximum_extent()
- if larger. if the playlist used to be the longest playlist,
- and its now shorter, we have to decrease session_range_location->end(). hence,
- we have to iterate over all diskstreams and check the
- playlists currently in use.
- */
- find_current_end ();
+ update_session_range_location_marker ();
}
void
playlist->LengthChanged.connect_same_thread (*this, boost::bind (&Session::playlist_length_changed, this));
}
- /* see comment in playlist_length_changed () */
- find_current_end ();
+ update_session_range_location_marker ();
}
bool
}
update_route_solo_state ();
- find_current_end ();
+ update_session_range_location_marker ();
// We need to disconnect the route's inputs and outputs
return shared_ptr<Route> ((Route*) 0);
}
+/** If either end of the session range location marker lies inside the current
+ * session extent, move it to the corresponding session extent.
+ */
void
-Session::find_current_end ()
+Session::update_session_range_location_marker ()
{
if (_state_of_the_state & Loading) {
return;
}
- nframes_t max = get_maximum_extent ();
+ pair<nframes_t, nframes_t> const ext = get_extent ();
- if (max > _session_range_location->end()) {
- _session_range_location->set_end (max);
- set_dirty();
- DurationChanged(); /* EMIT SIGNAL */
+ if (_session_range_location == 0) {
+ /* we don't have a session range yet; use this one (provided it is valid) */
+ if (ext.first != max_frames) {
+ add_session_range_location (ext.first, ext.second);
+ }
+ } else {
+ /* update the existing session range */
+ if (ext.first < _session_range_location->start()) {
+ _session_range_location->set_start (ext.first);
+ set_dirty ();
+ }
+
+ if (ext.second > _session_range_location->end()) {
+ _session_range_location->set_end (ext.second);
+ set_dirty ();
+ }
+
}
}
-nframes_t
-Session::get_maximum_extent () const
+/** @return Extent of the session's contents; if the session is empty, the first value of
+ * the pair will equal max_frames.
+ */
+pair<nframes_t, nframes_t>
+Session::get_extent () const
{
- nframes_t max = 0;
- nframes_t me;
+ pair<nframes_t, nframes_t> ext (max_frames, 0);
boost::shared_ptr<RouteList> rl = routes.reader ();
for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
if (!tr || tr->destructive()) {
- //ignore tape tracks when getting max extents
+ // ignore tape tracks when getting extents
continue;
}
-
- boost::shared_ptr<Playlist> pl = tr->playlist();
- if ((me = pl->get_maximum_extent()) > max) {
- max = me;
+
+ pair<nframes_t, nframes_t> e = tr->playlist()->get_extent ();
+ if (e.first < ext.first) {
+ ext.first = e.first;
+ }
+ if (e.second > ext.second) {
+ ext.second = e.second;
}
}
- return max;
+ return ext;
}
/* Region management */
automation_lists[al->id()] = al;
}
-nframes_t
-Session::compute_initial_length ()
-{
- return _engine.frame_rate() * 60 * 5;
-}
-
void
Session::sync_order_keys (std::string const & base)
{
return rl;
}
+
+void
+Session::goto_end ()
+{
+ if (_session_range_location) {
+ request_locate (_session_range_location->end(), false);
+ } else {
+ request_locate (0, false);
+ }
+}
+
+void
+Session::goto_start ()
+{
+ if (_session_range_location) {
+ request_locate (_session_range_location->start(), false);
+ } else {
+ request_locate (0, false);
+ }
+}
+
+void
+Session::set_session_start (nframes_t start)
+{
+ if (_session_range_location) {
+ _session_range_location->set_start (start);
+ } else {
+ add_session_range_location (start, start);
+ }
+}
+
+void
+Session::set_session_end (nframes_t end)
+{
+ if (_session_range_location) {
+ _session_range_location->set_end (end);
+ } else {
+ add_session_range_location (end, end);
+ }
+}
+
+nframes_t
+Session::current_start_frame () const
+{
+ return _session_range_location ? _session_range_location->start() : 0;
+}
+
+nframes_t
+Session::current_end_frame () const
+{
+ return _session_range_location ? _session_range_location->end() : 0;
+}
+
+void
+Session::add_session_range_location (nframes_t start, nframes_t end)
+{
+ _session_range_location = new Location (start, end, _("session"), Location::IsSessionRange);
+ _locations.add (_session_range_location);
+}
transport_sub_state = 0;
_transport_frame = 0;
_requested_return_frame = -1;
- _session_range_location = new Location (0, 0, _("session"), Location::IsSessionRange);
+ _session_range_location = 0;
g_atomic_int_set (&_record_status, Disabled);
loop_changing = false;
play_loop = false;
ControlProtocolManager::instance().set_session (this);
- config.set_end_marker_is_free (_is_new);
-
_state_of_the_state = Clean;
DirtyChanged (); /* EMIT SIGNAL */
}
int
-Session::create (const string& mix_template, nframes_t initial_length, BusProfile* bus_profile)
+Session::create (const string& mix_template, BusProfile* bus_profile)
{
if (g_mkdir_with_parents (_path.c_str(), 0755) < 0) {
/* set initial start + end point */
- _session_range_location->set (0, initial_length);
- _locations.add (_session_range_location);
-
_state_of_the_state = Clean;
/* set up Master Out and Control Out if necessary */
// with the default start and end, and get the state for that.
Locations loc;
Location* range = new Location (0, 0, _("session"), Location::IsSessionRange);
- range->set (0, compute_initial_length ());
+ range->set (max_frames, 0);
loc.add (range);
node->add_child_nocopy (loc.get_state());
}
set_auto_punch_location (location);
}
- if ((location = _locations.session_range_location()) == 0) {
- _locations.add (_session_range_location);
- } else {
+ if ((location = _locations.session_range_location()) != 0) {
delete _session_range_location;
_session_range_location = location;
}
- AudioFileSource::set_header_position_offset (_session_range_location->start());
+ if (_session_range_location) {
+ AudioFileSource::set_header_position_offset (_session_range_location->start());
+ }
if ((child = find_named_node (node, "Sources")) == 0) {
error << _("Session: XML state has no sources section") << endmsg;
if (did_record) {
begin_reversible_command ("capture");
-
- Location* loc = _locations.session_range_location();
- bool change_end = false;
-
- if (_transport_frame < loc->end()) {
-
- /* stopped recording before current end */
-
- if (config.get_end_marker_is_free()) {
-
- /* first capture for this session, move end back to where we are */
-
- change_end = true;
- }
-
- } else if (_transport_frame > loc->end()) {
-
- /* stopped recording after the current end, extend it */
-
- change_end = true;
- }
-
- if (change_end) {
- XMLNode &before = loc->get_state();
- loc->set_end(_transport_frame);
- XMLNode &after = loc->get_state();
- add_command (new MementoCommand<Location>(*loc, &before, &after));
- }
-
- config.set_end_marker_is_free (false);
_have_captured = true;
}
save_state (_current_snapshot_name);
}
- if (ptw & PostTransportDuration) {
- DurationChanged (); /* EMIT SIGNAL */
- }
-
if (ptw & PostTransportStop) {
_play_range = false;
play_loop = false;