diff --git a/ardour.rc.in b/ardour.rc.in
index 6488d0ed82..735b19c233 100644
--- a/ardour.rc.in
+++ b/ardour.rc.in
@@ -21,6 +21,9 @@
+
+
+
diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc
index f88b04ae1d..bef35c572c 100644
--- a/gtk2_ardour/audio_streamview.cc
+++ b/gtk2_ardour/audio_streamview.cc
@@ -253,7 +253,7 @@ AudioStreamView::add_crossfade (Crossfade *crossfade)
/* first see if we already have a CrossfadeView for this Crossfade */
for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
- if (&(*i)->crossfade == crossfade) {
+ if ((*i)->crossfade == *crossfade) {
if (!crossfades_visible) {
(*i)->hide();
} else {
@@ -287,7 +287,7 @@ AudioStreamView::add_crossfade (Crossfade *crossfade)
crossfade->Invalidated.connect (mem_fun (*this, &AudioStreamView::remove_crossfade));
crossfade_views.push_back (cv);
- if (!crossfades_visible) {
+ if (!Config->get_xfades_visible() || !crossfades_visible) {
cv->hide ();
}
}
@@ -312,7 +312,6 @@ AudioStreamView::redisplay_diskstream ()
list::iterator i, tmp;
list::iterator xi, tmpx;
-
for (i = region_views.begin(); i != region_views.end(); ++i) {
(*i)->set_valid (false);
}
@@ -326,6 +325,7 @@ AudioStreamView::redisplay_diskstream ()
if (_trackview.is_audio_track()) {
_trackview.get_diskstream()->playlist()->foreach_region (static_cast(this), &StreamView::add_region_view);
+
AudioPlaylist* apl = dynamic_cast(_trackview.get_diskstream()->playlist());
if (apl)
apl->foreach_crossfade (this, &AudioStreamView::add_crossfade);
@@ -357,7 +357,9 @@ AudioStreamView::redisplay_diskstream ()
/* now fix layering */
- playlist_modified ();
+ for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ region_layered (*i);
+ }
}
void
diff --git a/gtk2_ardour/crossfade_view.cc b/gtk2_ardour/crossfade_view.cc
index baf0f2a346..42a1a47227 100644
--- a/gtk2_ardour/crossfade_view.cc
+++ b/gtk2_ardour/crossfade_view.cc
@@ -127,6 +127,10 @@ CrossfadeView::crossfade_changed (Change what_changed)
set_duration (crossfade.overlap_length(), this);
need_redraw_curves = true;
}
+
+ if (what_changed & Crossfade::FollowOverlapChanged) {
+ need_redraw_curves = true;
+ }
if (what_changed & Crossfade::ActiveChanged) {
/* calls redraw_curves */
@@ -142,9 +146,15 @@ CrossfadeView::redraw_curves ()
Points* points;
int32_t npoints;
float* vec;
-
double h;
+ if (!crossfade.following_overlap()) {
+ /* curves should not be visible */
+ fade_in->hide ();
+ fade_out->hide ();
+ return;
+ }
+
/*
At "height - 3.0" the bottom of the crossfade touches the name highlight or the bottom of the track (if the
track is either Small or Smaller.
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 9924a2a929..b3e2285714 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -1691,7 +1691,7 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr
become selected.
*/
- region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, region));
+ region_menu->signal_map_event().connect (bind (mem_fun(*this, &Editor::set_selected_regionview_from_map_event), sv, boost::weak_ptr(region)));
items.push_back (MenuElem (_("Popup region editor"), mem_fun(*this, &Editor::edit_region)));
items.push_back (MenuElem (_("Raise to top layer"), mem_fun(*this, &Editor::raise_region_to_top)));
@@ -3074,9 +3074,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
switch (clicked_regionview->region()->coverage (first_frame, last_frame)) {
case OverlapNone:
- cerr << "no overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
-
if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
last_frame = clicked_regionview->region()->last_frame();
@@ -3087,9 +3084,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
break;
case OverlapExternal:
- cerr << "external overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
-
if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
last_frame = clicked_regionview->region()->last_frame();
@@ -3100,9 +3094,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
break;
case OverlapInternal:
- cerr << "internal overlap, first = " << first_frame << " last = " << last_frame << " region = "
- << clicked_regionview->region()->first_frame() << " .. " << clicked_regionview->region()->last_frame() << endl;
-
if (last_frame < clicked_regionview->region()->first_frame()) {
first_frame = last_frame;
last_frame = clicked_regionview->region()->last_frame();
@@ -3207,9 +3198,15 @@ Editor::set_selected_regionview_from_region_list (boost::shared_ptr regi
}
bool
-Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::shared_ptr r)
+Editor::set_selected_regionview_from_map_event (GdkEventAny* ev, StreamView* sv, boost::weak_ptr weak_r)
{
RegionView* rv;
+ boost::shared_ptr r (weak_r.lock());
+
+ if (!r) {
+ return true;
+ }
+
boost::shared_ptr ar;
if ((ar = boost::dynamic_pointer_cast (r)) == 0) {
@@ -3533,15 +3530,15 @@ Editor::zoom_focus_selection_done ()
string choice = zoom_focus_selector.get_active_text();
ZoomFocus focus_type = ZoomFocusLeft;
- if (choice == _("Focus Left")) {
+ if (choice == _("Left")) {
focus_type = ZoomFocusLeft;
- } else if (choice == _("Focus Right")) {
+ } else if (choice == _("Right")) {
focus_type = ZoomFocusRight;
- } else if (choice == _("Focus Center")) {
+ } else if (choice == _("Center")) {
focus_type = ZoomFocusCenter;
- } else if (choice == _("Focus Playhead")) {
+ } else if (choice == _("Playhead")) {
focus_type = ZoomFocusPlayhead;
- } else if (choice == _("Focus Edit Cursor")) {
+ } else if (choice == _("Edit Cursor")) {
focus_type = ZoomFocusEdit;
}
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index c26248c1e7..e604053254 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -441,7 +441,7 @@ class Editor : public PublicEditor
bool set_selected_regionview_from_click (bool press, Selection::Operation op = Selection::Set, bool no_track_remove=false);
void set_selected_regionview_from_region_list (boost::shared_ptr region, Selection::Operation op = Selection::Set);
- bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::shared_ptr);
+ bool set_selected_regionview_from_map_event (GdkEventAny*, StreamView*, boost::weak_ptr);
void collect_new_region_view (RegionView *);
Gtk::Menu track_context_menu;
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 6fb8950047..0485f4cc8a 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -782,13 +782,13 @@ Editor::toggle_auto_xfade ()
void
Editor::toggle_xfades_active ()
{
- ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_crossfades_active, &Configuration::get_crossfades_active);
+ ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_xfades_active, &Configuration::get_xfades_active);
}
void
Editor::toggle_xfade_visibility ()
{
- ActionManager::toggle_config_state ("Editor", "toggle-xfades-visibility", &Configuration::set_crossfades_visible, &Configuration::get_crossfades_visible);
+ ActionManager::toggle_config_state ("Editor", "toggle-xfades-visibility", &Configuration::set_xfades_visible, &Configuration::get_xfades_visible);
}
void
@@ -811,12 +811,14 @@ Editor::parameter_changed (const char* parameter_name)
update_just_smpte ();
} else if (PARAM_IS ("video-pullup")) {
update_video_pullup ();
- } else if (PARAM_IS ("crossfades-active")) {
- ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_crossfades_active);
- } else if (PARAM_IS ("crossfades-visible")) {
- ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_crossfades_visible);
+ } else if (PARAM_IS ("xfades-active")) {
+ ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_xfades_active);
+ } else if (PARAM_IS ("xfades-visible")) {
+ ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible);
} else if (PARAM_IS ("auto-xfade")) {
ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade);
+ } else if (PARAM_IS ("xfade-model")) {
+ update_crossfade_model ();
} else if (PARAM_IS ("edit-mode")) {
edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
}
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index ae76025cc6..e3954f00de 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -4833,7 +4833,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos)
// playlist is frozen, so we have to update manually
- playlist->StateChanged (Change (~0)); /* EMIT SIGNAL */
+ playlist->Modified(); /* EMIT SIGNAL */
}
gint
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 6a96b57795..7122d4663c 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2910,14 +2910,26 @@ Editor::cut_copy_points (CutCopyOp op)
}
}
+struct PlaylistState {
+ Playlist* playlist;
+ XMLNode* before;
+};
+
+struct lt_playlist {
+ bool operator () (const PlaylistState& a, const PlaylistState& b) {
+ return a.playlist < b.playlist;
+ }
+};
+
void
Editor::cut_copy_regions (CutCopyOp op)
{
typedef std::map PlaylistMapping;
PlaylistMapping pmap;
nframes_t first_position = max_frames;
- set freezelist;
- pair::iterator,bool> insert_result;
+
+ set freezelist;
+ pair::iterator,bool> insert_result;
for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
first_position = min ((*x)->region()->position(), first_position);
@@ -2925,10 +2937,15 @@ Editor::cut_copy_regions (CutCopyOp op)
if (op == Cut || op == Clear) {
AudioPlaylist *pl = dynamic_cast((*x)->region()->playlist());
if (pl) {
- insert_result = freezelist.insert (pl);
+
+ PlaylistState before;
+ before.playlist = pl;
+ before.before = &pl->get_state();
+
+ insert_result = freezelist.insert (before);
+
if (insert_result.second) {
pl->freeze ();
- session->add_command (new MementoCommand(*pl, &pl->get_state(), 0));
}
}
}
@@ -2990,9 +3007,9 @@ Editor::cut_copy_regions (CutCopyOp op)
cut_buffer->set (foo);
}
- for (set::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
- (*pl)->thaw ();
- session->add_command (new MementoCommand(*(*pl), 0, &(*pl)->get_state()));
+ for (set::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
+ (*pl).playlist->thaw ();
+ session->add_command (new MementoCommand(*(*pl).playlist, (*pl).before, &(*pl).playlist->get_state()));
}
}
@@ -3323,7 +3340,7 @@ Editor::normalize_region ()
continue;
XMLNode &before = arv->region()->get_state();
arv->audio_region()->normalize_to (0.0f);
- session->add_command (new MementoCommand(*(arv->region().get()), &before, &arv->region()->get_state()));
+ // session->add_command (new MementoCommand(*(arv->region().get()), &before, &arv->region()->get_state()));
}
commit_reversible_command ();
diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc
index d718cc9802..1b3879024a 100644
--- a/gtk2_ardour/midi_streamview.cc
+++ b/gtk2_ardour/midi_streamview.cc
@@ -142,7 +142,9 @@ MidiStreamView::redisplay_diskstream ()
/* now fix layering */
- playlist_modified ();
+ for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ region_layered (*i);
+ }
}
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index e0d976c233..eb96791d28 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -244,9 +244,6 @@ RouteTimeAxisView::set_playlist (Playlist *newplaylist)
assert(pl);
modified_connection.disconnect ();
- state_changed_connection.disconnect ();
-
- state_changed_connection = pl->StateChanged.connect (mem_fun(*this, &RouteTimeAxisView::playlist_state_changed));
modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
}
diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h
index 65d82506b8..1eb0cea00b 100644
--- a/gtk2_ardour/route_time_axis.h
+++ b/gtk2_ardour/route_time_axis.h
@@ -248,7 +248,6 @@ protected:
vector redirect_automation_curves;
sigc::connection modified_connection;
- sigc::connection state_changed_connection;
};
#endif /* __ardour_route_time_axis_h__ */
diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc
index 0b06858536..191a9ffb54 100644
--- a/gtk2_ardour/streamview.cc
+++ b/gtk2_ardour/streamview.cc
@@ -207,9 +207,7 @@ StreamView::playlist_modified ()
{
ENSURE_GUI_THREAD (mem_fun (*this, &StreamView::playlist_modified));
- for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
- region_layered (*i);
- }
+ redisplay_diskstream ();
}
void
@@ -232,20 +230,9 @@ StreamView::playlist_changed (boost::shared_ptr ds)
/* catch changes */
- playlist_connections.push_back (ds->playlist()->RegionAdded.connect (mem_fun (*this, &StreamView::add_region_view)));
- playlist_connections.push_back (ds->playlist()->RegionRemoved.connect (mem_fun (*this, &StreamView::remove_region_view)));
- playlist_connections.push_back (ds->playlist()->StateChanged.connect (mem_fun (*this, &StreamView::playlist_state_changed)));
playlist_connections.push_back (ds->playlist()->Modified.connect (mem_fun (*this, &StreamView::playlist_modified)));
}
-void
-StreamView::playlist_state_changed (Change ignored)
-{
- ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_state_changed), ignored));
-
- redisplay_diskstream ();
-}
-
void
StreamView::diskstream_changed ()
{
diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h
index 3774fd4dbb..39c04aea7f 100644
--- a/gtk2_ardour/streamview.h
+++ b/gtk2_ardour/streamview.h
@@ -116,7 +116,6 @@ protected:
virtual void redisplay_diskstream () = 0;
void diskstream_changed ();
- void playlist_state_changed (ARDOUR::Change);
virtual void playlist_changed (boost::shared_ptr);
virtual void playlist_modified ();
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 6184a45302..af5f5cdb60 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -81,8 +81,6 @@ class AudioFileSource : public AudioSource {
void mark_take (string);
string take_id() const { return _take_id; }
- static void set_bwf_country_code (string x);
- static void set_bwf_organization_code (string x);
static void set_bwf_serial_number (int);
static void set_search_path (string);
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h
index 341b08930c..383ec73531 100644
--- a/libs/ardour/ardour/audioplaylist.h
+++ b/libs/ardour/ardour/audioplaylist.h
@@ -38,19 +38,6 @@ class AudioPlaylist : public ARDOUR::Playlist
{
public:
typedef std::list Crossfades;
-
- private:
-
- struct State : public ARDOUR::StateManager::State {
- RegionList regions;
- std::list region_states;
-
- Crossfades crossfades;
- std::list crossfade_states;
-
- State (std::string why) : ARDOUR::StateManager::State (why) {}
- ~State ();
- };
public:
AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
@@ -58,35 +45,21 @@ class AudioPlaylist : public ARDOUR::Playlist
AudioPlaylist (const AudioPlaylist&, string name, bool hidden = false);
AudioPlaylist (const AudioPlaylist&, nframes_t start, nframes_t cnt, string name, bool hidden = false);
- void clear (bool with_save = true);
+ void clear (bool with_signals=true);
nframes_t read (Sample *dst, Sample *mixdown, float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n=0);
int set_state (const XMLNode&);
- UndoAction get_memento() const;
sigc::signal NewCrossfade;
template void foreach_crossfade (T *t, void (T::*func)(Crossfade *));
void crossfades_at (nframes_t frame, Crossfades&);
- template void apply_to_history (T& obj, void (T::*method)(const ARDOUR::StateManager::StateMap&, state_id_t)) {
- RegionLock rlock (this);
- (obj.*method) (states, _current_state_id);
- }
-
bool destroy_region (boost::shared_ptr);
- void drop_all_states ();
-
protected:
- /* state management */
-
- StateManager::State* state_factory (std::string) const;
- Change restore_state (StateManager::State&);
- void send_state_change (Change);
-
/* playlist "callbacks" */
void notify_crossfade_added (Crossfade *);
void flush_notifications ();
@@ -101,7 +74,7 @@ class AudioPlaylist : public ARDOUR::Playlist
~AudioPlaylist (); /* public should use unref() */
private:
- Crossfades _crossfades;
+ Crossfades _crossfades; /* xfades currently in use */
Crossfades _pending_xfade_adds;
void crossfade_invalidated (Crossfade*);
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 3ac62da2ca..e14cfd0180 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -42,18 +42,6 @@ class Session;
class AudioFilter;
class AudioSource;
-struct AudioRegionState : public RegionState
-{
- AudioRegionState (std::string why);
-
- Curve _fade_in;
- Curve _fade_out;
- Curve _envelope;
- gain_t _scale_amplitude;
- uint32_t _fade_in_disabled;
- uint32_t _fade_out_disabled;
-};
-
class AudioRegion : public Region
{
public:
@@ -125,8 +113,6 @@ class AudioRegion : public Region
int separate_by_channel (ARDOUR::Session&, vector&) const;
- UndoAction get_memento() const;
-
/* filter */
int apply (AudioFilter&);
@@ -159,9 +145,6 @@ class AudioRegion : public Region
void set_default_fade_out ();
void set_default_envelope ();
- StateManager::State* state_factory (std::string why) const;
- Change restore_state (StateManager::State&);
-
void recompute_gain_at_end ();
void recompute_gain_at_start ();
@@ -185,6 +168,9 @@ class AudioRegion : public Region
gain_t _scale_amplitude;
uint32_t _fade_in_disabled;
uint32_t _fade_out_disabled;
+
+ protected:
+ int set_live_state (const XMLNode&, Change&, bool send);
};
} /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h
index 7301b31d8a..fe65e9d433 100644
--- a/libs/ardour/ardour/configuration_vars.h
+++ b/libs/ardour/ardour/configuration_vars.h
@@ -45,11 +45,11 @@ CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", true)
/* crossfades */
-CONFIG_VARIABLE (CrossfadeModel, xfade_model, "xfade-model", ShortCrossfade)
+CONFIG_VARIABLE (CrossfadeModel, xfade_model, "xfade-model", FullCrossfade)
CONFIG_VARIABLE (bool, auto_xfade, "auto-xfade", true)
CONFIG_VARIABLE (float, short_xfade_seconds, "short-xfade-seconds", 0.015)
-CONFIG_VARIABLE (bool, crossfades_active, "crossfades-active", false)
-CONFIG_VARIABLE (bool, crossfades_visible, "crossfades-visible", false)
+CONFIG_VARIABLE (bool, xfades_active, "xfades-active", true)
+CONFIG_VARIABLE (bool, xfades_visible, "xfades-visible", true)
CONFIG_VARIABLE (uint32_t, destructive_xfade_msecs, "destructive-xfade-msecs", 2)
/* editing related */
@@ -121,6 +121,11 @@ CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture",
CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false)
CONFIG_VARIABLE (bool, use_vst, "use-vst", true)
+/* BWAV */
+
+CONFIG_VARIABLE (string, bwf_country_code, "bwf-country-code", "US")
+CONFIG_VARIABLE (string, bwf_organization_code, "bwf-organization-code", "US")
+
/* these variables have custom set() methods (e.g. path globbing) */
CONFIG_VARIABLE_SPECIAL(std::string, raid_path, "raid-path", "", path_expand)
diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h
index 7fd7323b36..d29ba47056 100644
--- a/libs/ardour/ardour/crossfade.h
+++ b/libs/ardour/ardour/crossfade.h
@@ -33,7 +33,6 @@
#include
#include
#include
-#include
#include
namespace ARDOUR {
@@ -41,19 +40,7 @@ namespace ARDOUR {
class AudioRegion;
class Playlist;
-struct CrossfadeState : public StateManager::State {
- CrossfadeState (std::string reason) : StateManager::State (reason) {}
-
- UndoAction fade_in_memento;
- UndoAction fade_out_memento;
- nframes_t position;
- nframes_t length;
- AnchorPoint anchor_point;
- bool follow_overlap;
- bool active;
-};
-
-class Crossfade : public PBD::StatefulDestructible, public StateManager
+class Crossfade : public PBD::StatefulDestructible
{
public:
@@ -121,7 +108,10 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
nframes_t overlap_length() const;
nframes_t position() const { return _position; }
+ void invalidate();
+
sigc::signal Invalidated;
+ sigc::signal StateChanged;
bool covers (nframes_t frame) const {
return _position <= frame && frame < _position + _length;
@@ -129,8 +119,6 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
OverlapType coverage (nframes_t start, nframes_t end) const;
- UndoAction get_memento() const;
-
static void set_buffer_size (nframes_t);
bool active () const { return _active; }
@@ -149,6 +137,7 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
static void set_short_xfade_length (nframes_t n);
static Change ActiveChanged;
+ static Change FollowOverlapChanged;
private:
friend struct CrossfadeComparePtr;
@@ -172,15 +161,11 @@ class Crossfade : public PBD::StatefulDestructible, public StateManager
static Sample* crossfade_buffer_out;
static Sample* crossfade_buffer_in;
- void initialize (bool savestate=true);
+ void initialize ();
int compute (boost::shared_ptr, boost::shared_ptr, CrossfadeModel);
bool update (bool force);
- StateManager::State* state_factory (std::string why) const;
- Change restore_state (StateManager::State&);
-
void member_changed (ARDOUR::Change);
-
};
diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h
index 36793b70ea..6f89d23404 100644
--- a/libs/ardour/ardour/midi_playlist.h
+++ b/libs/ardour/ardour/midi_playlist.h
@@ -37,18 +37,6 @@ class MidiRingBuffer;
class MidiPlaylist : public ARDOUR::Playlist
{
-private:
-
- struct State : public ARDOUR::StateManager::State
- {
- RegionList regions;
- std::list region_states;
-
- State (std::string why) : ARDOUR::StateManager::State (why)
- {}
- ~State ();
- };
-
public:
MidiPlaylist (Session&, const XMLNode&, bool hidden = false);
MidiPlaylist (Session&, string name, bool hidden = false);
@@ -56,31 +44,16 @@ public:
MidiPlaylist (const MidiPlaylist&, jack_nframes_t start, jack_nframes_t cnt,
string name, bool hidden = false);
- jack_nframes_t read (MidiRingBuffer& buf,
- jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0);
+ nframes_t read (MidiRingBuffer& buf,
+ jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n=0);
int set_state (const XMLNode&);
UndoAction get_memento() const;
- template
- void apply_to_history (T& obj, void (T::*method)(const ARDOUR::StateManager::StateMap&, state_id_t))
- {
- RegionLock rlock (this);
- (obj.*method) (states, _current_state_id);
- }
-
bool destroy_region (boost::shared_ptr);
- void drop_all_states ();
-
protected:
- /* state management */
-
- StateManager::State* state_factory (std::string) const;
- Change restore_state (StateManager::State&);
- void send_state_change (Change);
-
/* playlist "callbacks" */
void flush_notifications ();
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index d7b13ef684..93b30f42ef 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -40,7 +40,6 @@
#include
#include
#include
-#include
#include
namespace ARDOUR {
@@ -48,7 +47,7 @@ namespace ARDOUR {
class Session;
class Region;
-class Playlist : public StateManager, public PBD::StatefulDestructible {
+class Playlist : public PBD::StatefulDestructible {
public:
typedef list > RegionList;
@@ -57,9 +56,8 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
Playlist (const Playlist&, string name, bool hidden = false);
Playlist (const Playlist&, nframes_t start, nframes_t cnt, string name, bool hidden = false);
- virtual void clear (bool with_save = true);
+ virtual void clear (bool with_signals=true);
virtual void dump () const;
- virtual UndoAction get_memento() const = 0;
void ref();
void unref();
@@ -83,7 +81,7 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
/* Editing operations */
- void add_region (boost::shared_ptr, nframes_t position, float times = 1, bool with_save = true);
+ void add_region (boost::shared_ptr, nframes_t position, float times = 1);
void remove_region (boost::shared_ptr);
void get_equivalent_regions (boost::shared_ptr, std::vector >&);
void get_region_list_equivalent_regions (boost::shared_ptr, std::vector >&);
@@ -114,8 +112,6 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
int set_state (const XMLNode&);
XMLNode& get_template ();
- sigc::signal > RegionAdded;
- sigc::signal > RegionRemoved;
sigc::signal InUse;
sigc::signal Modified;
sigc::signal NameChanged;
@@ -172,20 +168,21 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
friend class RegionLock;
RegionList regions; /* the current list of regions in the playlist */
+ std::set > all_regions; /* all regions ever added to this playlist */
string _name;
Session& _session;
DataType _type;
mutable gint block_notifications;
mutable gint ignore_state_changes;
mutable Glib::Mutex region_lock;
- RegionList pending_removals;
- RegionList pending_adds;
+ std::set > pending_adds;
+ std::set > pending_removes;
RegionList pending_bounds;
bool pending_modified;
bool pending_length;
bool save_on_thaw;
string last_save_reason;
- bool in_set_state;
+ uint32_t in_set_state;
bool _hidden;
bool _splicing;
bool _nudging;
@@ -248,10 +245,7 @@ class Playlist : public StateManager, public PBD::StatefulDestructible {
virtual XMLNode& state (bool);
- /* override state_manager::save_state so we can check in_set_state() */
-
- void save_state (std::string why);
- void maybe_save_state (std::string why);
+ boost::shared_ptr region_by_id (PBD::ID);
void add_region_internal (boost::shared_ptr, nframes_t position, bool delay_sort = false);
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index 96663f79c8..627e556cad 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -29,7 +29,6 @@
#include
#include
-#include
#include
class XMLNode;
@@ -44,21 +43,7 @@ enum RegionEditState {
EditChangesID = 2
};
-struct RegionState : public StateManager::State
-{
- RegionState (std::string why) : StateManager::State (why) {}
-
- nframes_t _start;
- nframes_t _length;
- nframes_t _position;
- uint32_t _flags;
- nframes_t _sync_position;
- layer_t _layer;
- string _name;
- mutable RegionEditState _first_edit;
-};
-
-class Region : public PBD::StatefulDestructible, public StateManager, public boost::enable_shared_from_this
+class Region : public PBD::StatefulDestructible, public boost::enable_shared_from_this
{
public:
typedef std::vector > SourceList;
@@ -96,6 +81,8 @@ class Region : public PBD::StatefulDestructible, public StateManager, public boo
static Change LayerChanged;
static Change HiddenChanged;
+ sigc::signal StateChanged;
+
virtual ~Region();
/* Note: changing the name of a Region does not constitute an edit */
@@ -181,8 +168,6 @@ class Region : public PBD::StatefulDestructible, public StateManager, public boo
ARDOUR::Playlist* playlist() const { return _playlist; }
- virtual UndoAction get_memento() const = 0;
-
void set_playlist (ARDOUR::Playlist*);
void source_deleted (boost::shared_ptr);
@@ -198,6 +183,7 @@ class Region : public PBD::StatefulDestructible, public StateManager, public boo
XMLNode& get_state ();
virtual XMLNode& state (bool);
virtual int set_state (const XMLNode&);
+ virtual int set_live_state (const XMLNode&, Change&, bool send);
boost::shared_ptr get_parent();
@@ -220,15 +206,8 @@ class Region : public PBD::StatefulDestructible, public StateManager, public boo
protected:
XMLNode& get_short_state (); /* used only by Session */
- /* state management */
-
void send_change (Change);
- /* derived classes need these during their own state management calls */
-
- void store_state (RegionState&) const;
- Change restore_and_return_flags (RegionState&);
-
void trim_to_internal (nframes_t position, nframes_t length, void *src);
bool copied() const { return _flags & Copied; }
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 7c4052d8ac..94b80df178 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -39,21 +39,15 @@ using namespace sigc;
using namespace std;
using namespace PBD;
-AudioPlaylist::State::~State ()
-{
-}
-
AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden)
: Playlist (session, node, DataType::AUDIO, hidden)
{
const XMLProperty* prop = node.property("type");
assert(!prop || DataType(prop->value()) == DataType::AUDIO);
- in_set_state = true;
+ in_set_state++;
set_state (node);
- in_set_state = false;
-
- save_state (_("initial state"));
+ in_set_state--;
if (!hidden) {
PlaylistCreated (this); /* EMIT SIGNAL */
@@ -63,8 +57,6 @@ AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden
AudioPlaylist::AudioPlaylist (Session& session, string name, bool hidden)
: Playlist (session, name, DataType::AUDIO, hidden)
{
- save_state (_("initial state"));
-
if (!hidden) {
PlaylistCreated (this); /* EMIT SIGNAL */
}
@@ -74,8 +66,6 @@ AudioPlaylist::AudioPlaylist (Session& session, string name, bool hidden)
AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, string name, bool hidden)
: Playlist (other, name, hidden)
{
- save_state (_("initial state"));
-
RegionList::const_iterator in_o = other.regions.begin();
RegionList::iterator in_n = regions.begin();
@@ -121,8 +111,6 @@ AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, string name, bool hidd
AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, nframes_t start, nframes_t cnt, string name, bool hidden)
: Playlist (other, start, cnt, name, hidden)
{
- save_state (_("initial state"));
-
/* this constructor does NOT notify others (session) */
}
@@ -135,27 +123,24 @@ AudioPlaylist::~AudioPlaylist ()
/* drop connections to signals */
notify_callbacks ();
+
- for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ++x) {
- all_xfades.insert (*x);
+ cerr << "deleting crossfades " << _crossfades.size() << endl;
+
+ for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ) {
+ Crossfades::iterator tmp;
+
+ tmp = x;
+ ++tmp;
+
+ delete *x;
+
+ cerr << _crossfades.size() << " to go\n";
+
+ x = tmp;
}
- for (StateMap::iterator i = states.begin(); i != states.end(); ++i) {
-
- AudioPlaylist::State* apstate = dynamic_cast (*i);
-
- for (Crossfades::iterator xf = apstate->crossfades.begin(); xf != apstate->crossfades.end(); ++xf) {
- all_xfades.insert (*xf);
- }
-
- delete apstate;
- }
-
- /* delete every crossfade */
-
- for (set::iterator axf = all_xfades.begin(); axf != all_xfades.end(); ++axf) {
- delete *axf;
- }
+ cerr << "done\n";
}
struct RegionSortByLayer {
@@ -258,6 +243,10 @@ AudioPlaylist::remove_dependents (boost::shared_ptr region)
{
Crossfades::iterator i, tmp;
boost::shared_ptr r = boost::dynamic_pointer_cast (region);
+
+ if (in_set_state) {
+ return;
+ }
if (r == 0) {
fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist")
@@ -269,9 +258,9 @@ AudioPlaylist::remove_dependents (boost::shared_ptr region)
tmp = i;
tmp++;
+
if ((*i)->involves (r)) {
- /* do not delete crossfades */
- _crossfades.erase (i);
+ delete *i;
}
i = tmp;
@@ -386,6 +375,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh)
return;
}
+ cerr << "Check dependents of " << r->name() << endl;
+
if ((region = boost::dynamic_pointer_cast (r)) == 0) {
fatal << _("programming error: non-audio Region tested for overlap in audio playlist")
<< endmsg;
@@ -450,8 +441,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr r, bool norefresh)
add_crossfade (*xfade);
} else {
-
- xfade = new Crossfade (other, region, Config->get_xfade_model(), Config->get_crossfades_active());
+
+ xfade = new Crossfade (other, region, Config->get_xfade_model(), Config->get_xfades_active());
add_crossfade (*xfade);
}
}
@@ -473,7 +464,10 @@ AudioPlaylist::add_crossfade (Crossfade& xfade)
{
Crossfades::iterator ci;
+ cerr << "adding xfade involving " << xfade.in()->name() << " and " << xfade.out()->name() << endl;
+
for (ci = _crossfades.begin(); ci != _crossfades.end(); ++ci) {
+ cerr << "\tcompare to " << (*ci)->in()->name() << " and " << (*ci)->out()->name() << endl;
if (*(*ci) == xfade) { // Crossfade::operator==()
break;
}
@@ -520,9 +514,10 @@ AudioPlaylist::set_state (const XMLNode& node)
XMLNodeList nlist;
XMLNodeConstIterator niter;
- if (!in_set_state) {
- Playlist::set_state (node);
- }
+ in_set_state++;
+ freeze ();
+
+ Playlist::set_state (node);
nlist = node.children();
@@ -530,155 +525,49 @@ AudioPlaylist::set_state (const XMLNode& node)
child = *niter;
- if (child->name() == "Crossfade") {
-
- Crossfade *xfade;
-
- try {
- xfade = new Crossfade (*((const Playlist *)this), *child);
- }
-
- catch (failed_constructor& err) {
- // cout << string_compose (_("could not create crossfade object in playlist %1"),
- // _name)
- // << endl;
- continue;
- }
-
- Crossfades::iterator ci;
-
- for (ci = _crossfades.begin(); ci != _crossfades.end(); ++ci) {
- if (*(*ci) == *xfade) {
- break;
- }
- }
-
- if (ci == _crossfades.end()) {
- _crossfades.push_back (xfade);
- xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated));
- xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed));
- NewCrossfade(xfade);
- } else {
- delete xfade;
- }
+ if (child->name() != "Crossfade") {
+ continue;
}
+ try {
+ Crossfade* xfade = new Crossfade (*((const Playlist *)this), *child);
+ _crossfades.push_back (xfade);
+ xfade->Invalidated.connect (mem_fun (*this, &AudioPlaylist::crossfade_invalidated));
+ xfade->StateChanged.connect (mem_fun (*this, &AudioPlaylist::crossfade_changed));
+ NewCrossfade(xfade);
+ }
+
+ catch (failed_constructor& err) {
+ // cout << string_compose (_("could not create crossfade object in playlist %1"),
+ // _name)
+ // << endl;
+ continue;
+ }
}
+ thaw ();
+ in_set_state++;
+
return 0;
}
void
-AudioPlaylist::drop_all_states ()
+AudioPlaylist::clear (bool with_signals)
{
- set all_xfades;
- set > all_regions;
+ for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ) {
- /* find every region we've ever used, and add it to the set of
- all regions. same for xfades;
- */
+ Crossfades::iterator tmp;
+ tmp = i;
+ ++tmp;
- for (StateMap::iterator i = states.begin(); i != states.end(); ++i) {
-
- AudioPlaylist::State* apstate = dynamic_cast (*i);
+ delete *i;
- for (RegionList::iterator r = apstate->regions.begin(); r != apstate->regions.end(); ++r) {
- all_regions.insert (*r);
- }
-
- for (Crossfades::iterator xf = apstate->crossfades.begin(); xf != apstate->crossfades.end(); ++xf) {
- all_xfades.insert (*xf);
- }
+ i = tmp;
}
- /* now remove from the "all" lists every region that is in the current list. */
-
- for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
- set >::iterator x = all_regions.find (*i);
- if (x != all_regions.end()) {
- all_regions.erase (x);
- }
- }
-
- /* ditto for every crossfade */
-
- for (list::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
- set::iterator x = all_xfades.find (*i);
- if (x != all_xfades.end()) {
- all_xfades.erase (x);
- }
- }
-
- /* delete every crossfade that is left (ditto as per regions) */
-
- for (set::iterator axf = all_xfades.begin(); axf != all_xfades.end(); ++axf) {
- delete *axf;
- }
-
- /* Now do the generic thing ... */
-
- StateManager::drop_all_states ();
-}
-
-StateManager::State*
-AudioPlaylist::state_factory (std::string why) const
-{
- State* state = new State (why);
-
- state->regions = regions;
- state->region_states.clear ();
- for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- state->region_states.push_back ((*i)->get_memento());
- }
-
- state->crossfades = _crossfades;
- state->crossfade_states.clear ();
- for (Crossfades::const_iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
- state->crossfade_states.push_back ((*i)->get_memento());
- }
- return state;
-}
-
-Change
-AudioPlaylist::restore_state (StateManager::State& state)
-{
- {
- RegionLock rlock (this);
- State* apstate = dynamic_cast (&state);
-
- in_set_state = true;
-
- regions = apstate->regions;
-
- for (list::iterator s = apstate->region_states.begin(); s != apstate->region_states.end(); ++s) {
- (*s) ();
- }
-
- _crossfades = apstate->crossfades;
-
- for (list::iterator s = apstate->crossfade_states.begin(); s != apstate->crossfade_states.end(); ++s) {
- (*s) ();
- }
-
- in_set_state = false;
- }
-
- notify_length_changed ();
- return Change (~0);
-}
-
-UndoAction
-AudioPlaylist::get_memento () const
-{
- return sigc::bind (mem_fun (*(const_cast (this)), &StateManager::use_state), _current_state_id);
-}
-
-void
-AudioPlaylist::clear (bool with_save)
-{
_crossfades.clear ();
- Playlist::clear (with_save);
+ Playlist::clear (with_signals);
}
XMLNode&
@@ -779,52 +668,6 @@ AudioPlaylist::destroy_region (boost::shared_ptr region)
c = ctmp;
}
- for (StateMap::iterator s = states.begin(); s != states.end(); ) {
- StateMap::iterator tmp;
-
- tmp = s;
- ++tmp;
-
- State* astate = dynamic_cast (*s);
-
- for (c = astate->crossfades.begin(); c != astate->crossfades.end(); ) {
-
- ctmp = c;
- ++ctmp;
-
- if ((*c)->involves (r)) {
- unique_xfades.insert (*c);
- _crossfades.erase (c);
- }
-
- c = ctmp;
- }
-
- list::iterator rsi, rsitmp;
- RegionList::iterator ri, ritmp;
-
- for (ri = astate->regions.begin(), rsi = astate->region_states.begin();
- ri != astate->regions.end() && rsi != astate->region_states.end();) {
-
-
- ritmp = ri;
- ++ritmp;
-
- rsitmp = rsi;
- ++rsitmp;
-
- if (region == (*ri)) {
- astate->regions.erase (ri);
- astate->region_states.erase (rsi);
- }
-
- ri = ritmp;
- rsi = rsitmp;
- }
-
- s = tmp;
- }
-
for (set::iterator c = unique_xfades.begin(); c != unique_xfades.end(); ++c) {
delete *c;
}
@@ -850,8 +693,6 @@ AudioPlaylist::crossfade_changed (Change ignored)
that occured.
*/
- maybe_save_state (_("xfade change"));
-
notify_modified ();
}
@@ -873,8 +714,6 @@ AudioPlaylist::region_changed (Change what_changed, boost::shared_ptr re
parent_wants_notify = Playlist::region_changed (what_changed, region);
- maybe_save_state (_("region modified"));
-
if ((parent_wants_notify || (what_changed & our_interests))) {
notify_modified ();
}
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 0ba2904f57..3078521466 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -59,10 +59,6 @@ string AudioFileSource::search_path;
sigc::signal AudioFileSource::HeaderPositionOffsetChanged;
uint64_t AudioFileSource::header_position_offset = 0;
-/* XXX turn this into a Config option */
-char AudioFileSource::bwf_country_code[3] = "US";
-/* XXX turn this into a Config option */
-char AudioFileSource::bwf_organization_code[4] = "LAS";
/* XXX maybe this too */
char AudioFileSource::bwf_serial_number[13] = "000000000000";
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index d7724f3a39..31776d7be5 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -58,14 +58,6 @@ Change AudioRegion::EnvelopeActiveChanged = ARDOUR::new_change();
Change AudioRegion::ScaleAmplitudeChanged = ARDOUR::new_change();
Change AudioRegion::EnvelopeChanged = ARDOUR::new_change();
-AudioRegionState::AudioRegionState (string why)
- : RegionState (why)
- , _fade_in (0.0, 2.0, 1.0, false)
- , _fade_out (0.0, 2.0, 1.0, false)
- , _envelope (0.0, 2.0, 1.0, false)
-{
-}
-
/** Basic AudioRegion constructor (one channel) */
AudioRegion::AudioRegion (boost::shared_ptr src, nframes_t start, nframes_t length)
: Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::AUDIO, 0, Region::Flag(Region::DefaultFlags|Region::External)),
@@ -83,8 +75,6 @@ AudioRegion::AudioRegion (boost::shared_ptr src, nframes_t start, n
set_default_fades ();
set_default_envelope ();
- save_state ("initial state");
-
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
}
@@ -104,7 +94,6 @@ AudioRegion::AudioRegion (boost::shared_ptr src, nframes_t start, n
set_default_fades ();
set_default_envelope ();
- save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
}
@@ -120,7 +109,6 @@ AudioRegion::AudioRegion (SourceList& srcs, nframes_t start, nframes_t length, c
set_default_fades ();
set_default_envelope ();
- save_state ("initial state");
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
}
@@ -160,8 +148,6 @@ AudioRegion::AudioRegion (boost::shared_ptr other, nframes_t
_scale_amplitude = other->_scale_amplitude;
- save_state ("initial state");
-
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
assert(_type == DataType::AUDIO);
@@ -179,8 +165,6 @@ AudioRegion::AudioRegion (boost::shared_ptr other)
_fade_in_disabled = 0;
_fade_out_disabled = 0;
- save_state ("initial state");
-
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
assert(_type == DataType::AUDIO);
@@ -203,8 +187,6 @@ AudioRegion::AudioRegion (boost::shared_ptr src, const XMLNode& nod
throw failed_constructor();
}
- save_state ("initial state");
-
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
assert(_type == DataType::AUDIO);
@@ -223,8 +205,6 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
throw failed_constructor();
}
- save_state ("initial state");
-
_envelope.StateChanged.connect (mem_fun (*this, &AudioRegion::envelope_changed));
assert(_type == DataType::AUDIO);
@@ -232,92 +212,11 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
AudioRegion::~AudioRegion ()
{
+ cerr << "====== " << _name << " DESTRUCTOR @ " << this << endl;
notify_callbacks ();
GoingAway (); /* EMIT SIGNAL */
}
-StateManager::State*
-AudioRegion::state_factory (std::string why) const
-{
- AudioRegionState* state = new AudioRegionState (why);
-
- Region::store_state (*state);
-
- state->_fade_in = _fade_in;
- state->_fade_out = _fade_out;
- state->_envelope = _envelope;
- state->_scale_amplitude = _scale_amplitude;
- state->_fade_in_disabled = _fade_in_disabled;
- state->_fade_out_disabled = _fade_out_disabled;
-
- return state;
-}
-
-Change
-AudioRegion::restore_state (StateManager::State& sstate)
-{
- AudioRegionState* state = dynamic_cast (&sstate);
-
- Change what_changed = Region::restore_and_return_flags (*state);
-
- if (_flags != Flag (state->_flags)) {
-
- uint32_t old_flags = _flags;
-
- _flags = Flag (state->_flags);
-
- if ((old_flags ^ state->_flags) & EnvelopeActive) {
- what_changed = Change (what_changed|EnvelopeActiveChanged);
- }
- }
-
- if (!(_fade_in == state->_fade_in)) {
- _fade_in = state->_fade_in;
- what_changed = Change (what_changed|FadeInChanged);
- }
-
- if (!(_fade_out == state->_fade_out)) {
- _fade_out = state->_fade_out;
- what_changed = Change (what_changed|FadeOutChanged);
- }
-
- if (_scale_amplitude != state->_scale_amplitude) {
- _scale_amplitude = state->_scale_amplitude;
- what_changed = Change (what_changed|ScaleAmplitudeChanged);
- }
-
- if (_fade_in_disabled != state->_fade_in_disabled) {
- if (_fade_in_disabled == 0 && state->_fade_in_disabled) {
- set_fade_in_active (false);
- } else if (_fade_in_disabled && state->_fade_in_disabled == 0) {
- set_fade_in_active (true);
- }
- _fade_in_disabled = state->_fade_in_disabled;
- }
-
- if (_fade_out_disabled != state->_fade_out_disabled) {
- if (_fade_out_disabled == 0 && state->_fade_out_disabled) {
- set_fade_out_active (false);
- } else if (_fade_out_disabled && state->_fade_out_disabled == 0) {
- set_fade_out_active (true);
- }
- _fade_out_disabled = state->_fade_out_disabled;
- }
-
- /* XXX need a way to test stored state versus current for envelopes */
-
- _envelope = state->_envelope;
- what_changed = Change (what_changed);
-
- return what_changed;
-}
-
-UndoAction
-AudioRegion::get_memento() const
-{
- return sigc::bind (mem_fun (*(const_cast (this)), &StateManager::use_state), _current_state_id);
-}
-
void
AudioRegion::set_envelope_active (bool yn)
{
@@ -330,11 +229,7 @@ AudioRegion::set_envelope_active (bool yn)
snprintf (buf, sizeof (buf), "envelope off");
_flags = Flag (_flags & ~EnvelopeActive);
}
- if (!_frozen) {
- save_state (buf);
- }
send_change (EnvelopeActiveChanged);
-
}
}
@@ -555,6 +450,8 @@ AudioRegion::state (bool full)
} else {
_fade_in.store_state (*child);
}
+
+ child->add_property (X_("active"), _fade_in_disabled ? X_("no") : X_("yes"));
child = node.add_child (X_("FadeOut"));
@@ -563,6 +460,8 @@ AudioRegion::state (bool full)
} else {
_fade_out.store_state (*child);
}
+
+ child->add_property (X_("active"), _fade_out_disabled ? X_("no") : X_("yes"));
}
child = node.add_child ("Envelope");
@@ -585,6 +484,7 @@ AudioRegion::state (bool full)
} else {
_envelope.store_state (*child);
}
+
} else {
child->add_property ("default", "yes");
}
@@ -597,14 +497,16 @@ AudioRegion::state (bool full)
}
int
-AudioRegion::set_state (const XMLNode& node)
+AudioRegion::set_live_state (const XMLNode& node, Change& what_changed, bool send)
{
const XMLNodeList& nlist = node.children();
const XMLProperty *prop;
LocaleGuard lg (X_("POSIX"));
- Region::set_state (node);
+ Region::set_live_state (node, what_changed, false);
+ uint32_t old_flags = _flags;
+
if ((prop = node.property ("flags")) != 0) {
_flags = Flag (strtol (prop->value().c_str(), (char **) 0, 16));
@@ -612,6 +514,16 @@ AudioRegion::set_state (const XMLNode& node)
_flags = Flag (_flags & ~Region::RightOfSplit);
}
+ if ((old_flags ^ _flags) & Muted) {
+ what_changed = Change (what_changed|MuteChanged);
+ }
+ if ((old_flags ^ _flags) & Opaque) {
+ what_changed = Change (what_changed|OpacityChanged);
+ }
+ if ((old_flags ^ _flags) & Locked) {
+ what_changed = Change (what_changed|LockChanged);
+ }
+
if ((prop = node.property ("scale-gain")) != 0) {
_scale_amplitude = atof (prop->value().c_str());
} else {
@@ -647,7 +559,6 @@ AudioRegion::set_state (const XMLNode& node)
if ((prop = child->property ("default")) != 0 || (prop = child->property ("steepness")) != 0) {
set_default_fade_in ();
} else {
-
_fade_in.load_state (*child);
}
@@ -663,9 +574,24 @@ AudioRegion::set_state (const XMLNode& node)
}
}
+ if (send) {
+ send_change (what_changed);
+ }
+
return 0;
}
+int
+AudioRegion::set_state (const XMLNode& node)
+{
+ /* Region::set_state() calls the virtual set_live_state(),
+ which will get us back to AudioRegion::set_live_state()
+ to handle the relevant stuff.
+ */
+
+ return Region::set_state (node);
+}
+
void
AudioRegion::set_fade_in_shape (FadeShape shape)
{
@@ -735,10 +661,6 @@ AudioRegion::set_fade_in (FadeShape shape, nframes_t len)
_fade_in.thaw ();
_fade_in_shape = shape;
- if (!_frozen) {
- save_state (_("fade in change"));
- }
-
send_change (FadeInChanged);
}
@@ -797,10 +719,6 @@ AudioRegion::set_fade_out (FadeShape shape, nframes_t len)
_fade_out.thaw ();
_fade_out_shape = shape;
- if (!_frozen) {
- save_state (_("fade in change"));
- }
-
send_change (FadeOutChanged);
}
@@ -811,13 +729,6 @@ AudioRegion::set_fade_in_length (nframes_t len)
if (changed) {
_flags = Flag (_flags & ~DefaultFadeIn);
-
- if (!_frozen) {
- char buf[64];
- snprintf (buf, sizeof (buf), "fade in length changed to %u", len);
- save_state (buf);
- }
-
send_change (FadeInChanged);
}
}
@@ -829,12 +740,6 @@ AudioRegion::set_fade_out_length (nframes_t len)
if (changed) {
_flags = Flag (_flags & ~DefaultFadeOut);
-
- if (!_frozen) {
- char buf[64];
- snprintf (buf, sizeof (buf), "fade out length changed to %u", len);
- save_state (buf);
- }
}
send_change (FadeOutChanged);
@@ -970,7 +875,8 @@ AudioRegion::separate_by_channel (Session& session, vector& v) con
int
AudioRegion::apply (AudioFilter& filter)
{
- return filter.run (boost::shared_ptr (this));
+ boost::shared_ptr ar = boost::dynamic_pointer_cast (shared_from_this());
+ return filter.run (ar);
}
int
@@ -1110,12 +1016,6 @@ AudioRegion::normalize_to (float target_dB)
_scale_amplitude = target/maxamp;
- if (!_frozen) {
- char buf[64];
- snprintf (buf, sizeof (buf), _("normalized to %.2fdB"), target_dB);
- save_state (buf);
- }
-
/* tell the diskstream we're in */
if (_playlist) {
@@ -1130,7 +1030,6 @@ AudioRegion::normalize_to (float target_dB)
void
AudioRegion::envelope_changed (Change ignored)
{
- save_state (_("envelope change"));
send_change (EnvelopeChanged);
}
diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc
index 3887e5ecc7..34cf5637b6 100644
--- a/libs/ardour/auditioner.cc
+++ b/libs/ardour/auditioner.cc
@@ -80,7 +80,7 @@ Auditioner::prepare_playlist ()
AudioPlaylist* const apl = dynamic_cast(_diskstream->playlist());
assert(apl);
- apl->clear (false);
+ apl->clear ();
return *apl;
}
@@ -128,8 +128,8 @@ Auditioner::audition_region (boost::shared_ptr region)
boost::shared_ptr the_region (boost::dynamic_pointer_cast (RegionFactory::create (region)));
the_region->set_position (0, this);
- _diskstream->playlist()->clear (false);
- _diskstream->playlist()->add_region (the_region, 0, 1, false);
+ _diskstream->playlist()->clear ();
+ _diskstream->playlist()->add_region (the_region, 0, 1);
while (_diskstream->n_channels().get(DataType::AUDIO) < the_region->n_channels()) {
audio_diskstream()->add_channel ();
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc
index 32a9e2b533..739ea1cc0e 100644
--- a/libs/ardour/crossfade.cc
+++ b/libs/ardour/crossfade.cc
@@ -37,6 +37,7 @@ using namespace PBD;
nframes_t Crossfade::_short_xfade_length = 0;
Change Crossfade::ActiveChanged = new_change();
+Change Crossfade::FollowOverlapChanged = new_change();
/* XXX if and when we ever implement parallel processing of the process()
callback, these will need to be handled on a per-thread basis.
@@ -82,8 +83,16 @@ Crossfade::Crossfade (boost::shared_ptr in, boost::shared_ptr