summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-04-16 16:32:22 +0000
committerCarl Hetherington <carl@carlh.net>2012-04-16 16:32:22 +0000
commita2897ecef6da6a458aa1de8c2d9973a1e809dca2 (patch)
tree189e34b829823fc73d11fba249f283e00336d44d /libs/ardour/ardour
parent02c498a8fa1c2e47988a256321bdcf5e9e869de1 (diff)
Fairly major change to the way in which crossfades are handled;
they are now done with region fades, rather than separate objects. After this commit, Ardour will try to convert your session files to the new crossfade format, but will make a backup in your session folder first. If you have works in progress using Ardour 3 it is ***STRONGLY RECOMMENDED*** that you back up session files before updating to this commit. git-svn-id: svn://localhost/ardour2/branches/3.0@11986 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/audioplaylist.h68
-rw-r--r--libs/ardour/ardour/audioregion.h13
-rw-r--r--libs/ardour/ardour/crossfade.h180
-rw-r--r--libs/ardour/ardour/crossfade_binder.h52
-rw-r--r--libs/ardour/ardour/diskstream.h6
-rw-r--r--libs/ardour/ardour/midi_playlist.h6
-rw-r--r--libs/ardour/ardour/playlist.h19
-rw-r--r--libs/ardour/ardour/region.h18
-rw-r--r--libs/ardour/ardour/types.h20
9 files changed, 44 insertions, 338 deletions
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h
index fea70aade7..39efd2505d 100644
--- a/libs/ardour/ardour/audioplaylist.h
+++ b/libs/ardour/ardour/audioplaylist.h
@@ -33,96 +33,32 @@ class Region;
class AudioRegion;
class Source;
-namespace Properties {
- /* fake the type, since crossfades are handled by SequenceProperty which doesn't
- care about such things.
- */
- extern PBD::PropertyDescriptor<bool> crossfades;
-}
-
class AudioPlaylist;
-class CrossfadeListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Crossfade> > >
-{
-public:
- CrossfadeListProperty (AudioPlaylist &);
-
- void get_content_as_xml (boost::shared_ptr<Crossfade>, XMLNode &) const;
- boost::shared_ptr<Crossfade> get_content_from_xml (XMLNode const &) const;
-
-private:
- CrossfadeListProperty* clone () const;
- CrossfadeListProperty* create () const;
-
- /* copy construction only by ourselves */
- CrossfadeListProperty (CrossfadeListProperty const & p);
-
- friend class AudioPlaylist;
- /* we live and die with our playlist, no lifetime management needed */
- AudioPlaylist& _playlist;
-};
-
-
class AudioPlaylist : public ARDOUR::Playlist
{
public:
- typedef std::list<boost::shared_ptr<Crossfade> > Crossfades;
- static void make_property_quarks ();
-
AudioPlaylist (Session&, const XMLNode&, bool hidden = false);
AudioPlaylist (Session&, std::string name, bool hidden = false);
AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, std::string name, bool hidden = false);
AudioPlaylist (boost::shared_ptr<const AudioPlaylist>, framepos_t start, framecnt_t cnt, std::string name, bool hidden = false);
- ~AudioPlaylist ();
-
- void clear (bool with_signals=true);
-
framecnt_t read (Sample *dst, Sample *mixdown, float *gain_buffer, framepos_t start, framecnt_t cnt, uint32_t chan_n=0);
- int set_state (const XMLNode&, int version);
-
- PBD::Signal1<void,boost::shared_ptr<Crossfade> > NewCrossfade;
-
- void foreach_crossfade (boost::function<void (boost::shared_ptr<Crossfade>)>);
- void crossfades_at (framepos_t frame, Crossfades&);
-
bool destroy_region (boost::shared_ptr<Region>);
- void update (const CrossfadeListProperty::ChangeRecord &);
-
- boost::shared_ptr<Crossfade> find_crossfade (const PBD::ID &) const;
- void get_equivalent_crossfades (boost::shared_ptr<Crossfade>, std::vector<boost::shared_ptr<Crossfade> > &);
-
protected:
- /* playlist "callbacks" */
- void notify_crossfade_added (boost::shared_ptr<Crossfade>);
- void flush_notifications (bool);
-
- void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
-
- void refresh_dependents (boost::shared_ptr<Region> region);
- void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
- void remove_dependents (boost::shared_ptr<Region> region);
- void copy_dependents (const std::vector<TwoRegions>&, Playlist*) const;
+ void check_crossfades (Evoral::Range<framepos_t>);
void pre_combine (std::vector<boost::shared_ptr<Region> >&);
void post_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
private:
- CrossfadeListProperty _crossfades;
- Crossfades _pending_xfade_adds;
-
- void crossfade_invalidated (boost::shared_ptr<Region>);
- XMLNode& state (bool full_state);
+ int set_state (const XMLNode&, int version);
void dump () const;
-
bool region_changed (const PBD::PropertyChange&, boost::shared_ptr<Region>);
- void crossfade_changed (const PBD::PropertyChange&);
- void add_crossfade (boost::shared_ptr<Crossfade>);
-
void source_offset_changed (boost::shared_ptr<AudioRegion> region);
};
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 077f90c95a..7236cd69a9 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -34,7 +34,8 @@
#include "ardour/region.h"
class XMLNode;
-
+class AudioRegionTest;
+class PlaylistReadTest;
namespace ARDOUR {
@@ -92,6 +93,8 @@ class AudioRegion : public Region
boost::shared_ptr<AutomationList> fade_out() { return _fade_out; }
boost::shared_ptr<AutomationList> envelope() { return _envelope; }
+ Evoral::Range<framepos_t> body_range () const;
+
virtual framecnt_t read_peaks (PeakData *buf, framecnt_t npeaks,
framecnt_t offset, framecnt_t cnt,
uint32_t chan_n=0, double samples_per_unit= 1.0) const;
@@ -137,6 +140,9 @@ class AudioRegion : public Region
void set_fade_out (FadeShape, framecnt_t);
void set_fade_out (boost::shared_ptr<AutomationList>);
+ void set_default_fade_in ();
+ void set_default_fade_out ();
+
void set_envelope_active (bool yn);
void set_default_envelope ();
@@ -182,6 +188,9 @@ class AudioRegion : public Region
AudioRegion (SourceList &);
private:
+ friend class ::AudioRegionTest;
+ friend class ::PlaylistReadTest;
+
PBD::Property<bool> _envelope_active;
PBD::Property<bool> _default_fade_in;
PBD::Property<bool> _default_fade_out;
@@ -195,8 +204,6 @@ class AudioRegion : public Region
void init ();
void set_default_fades ();
- void set_default_fade_in ();
- void set_default_fade_out ();
void recompute_gain_at_end ();
void recompute_gain_at_start ();
diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h
deleted file mode 100644
index 1c7075eb7d..0000000000
--- a/libs/ardour/ardour/crossfade.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- Copyright (C) 2000 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __ardour_overlap_h__
-#define __ardour_overlap_h__
-
-#include <vector>
-#include <algorithm>
-#include <boost/shared_ptr.hpp>
-
-
-#include "pbd/undo.h"
-#include "pbd/statefuldestructible.h"
-
-#include "ardour/ardour.h"
-#include "ardour/audioregion.h"
-#include "evoral/Curve.hpp"
-
-namespace ARDOUR {
- namespace Properties {
- /* "active" is defined elsewhere but we use it with crossfade also */
- extern PBD::PropertyDescriptor<bool> active;
- extern PBD::PropertyDescriptor<bool> follow_overlap;
- }
-
-enum AnchorPoint {
- StartOfIn,
- EndOfIn,
- EndOfOut
-};
-
-class Playlist;
-
-class Crossfade : public ARDOUR::AudioRegion
-{
- public:
-
- class NoCrossfadeHere: std::exception {
- public:
- virtual const char *what() const throw() { return "no crossfade should be constructed here"; }
- };
-
- /* constructor for "fixed" xfades at each end of an internal overlap */
-
- Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out,
- framecnt_t initial_length,
- AnchorPoint);
-
- /* constructor for xfade between two regions that are overlapped in any way
- except the "internal" case.
- */
-
- Crossfade (boost::shared_ptr<ARDOUR::AudioRegion> in, boost::shared_ptr<ARDOUR::AudioRegion> out, CrossfadeModel, bool active);
-
-
- /* copy constructor to copy a crossfade with new regions. used (for example)
- when a playlist copy is made
- */
- Crossfade (boost::shared_ptr<Crossfade>, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
-
- /* the usual XML constructor */
-
- Crossfade (const Playlist&, XMLNode const &);
- virtual ~Crossfade();
-
- static void make_property_quarks ();
-
- XMLNode& get_state (void);
- int set_state (const XMLNode&, int version);
-
- boost::shared_ptr<ARDOUR::AudioRegion> in() const { return _in; }
- boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
-
- framecnt_t read_at (Sample *buf, Sample *mixdown_buffer,
- float *gain_buffer, framepos_t position, framecnt_t cnt,
- uint32_t chan_n) const;
-
- bool refresh ();
-
- uint32_t upper_layer () const {
- return std::max (_in->layer(), _out->layer());
- }
-
- uint32_t lower_layer () const {
- return std::min (_in->layer(), _out->layer());
- }
-
- bool involves (boost::shared_ptr<ARDOUR::AudioRegion> region) const {
- return _in == region || _out == region;
- }
-
- bool involves (boost::shared_ptr<ARDOUR::AudioRegion> a, boost::shared_ptr<ARDOUR::AudioRegion> b) const {
- return (_in == a && _out == b) || (_in == b && _out == a);
- }
-
- framecnt_t overlap_length() const;
-
- PBD::Signal1<void,boost::shared_ptr<Region> > Invalidated;
-
- OverlapType coverage (framepos_t start, framepos_t end) const;
-
- static void set_buffer_size (framecnt_t);
-
- bool active () const { return _active; }
- void set_active (bool yn);
-
- bool following_overlap() const { return _follow_overlap; }
- bool can_follow_overlap() const;
- void set_follow_overlap (bool yn);
-
- AutomationList& fade_in() { return _fade_in; }
- AutomationList& fade_out() { return _fade_out; }
-
- framecnt_t set_xfade_length (framecnt_t);
-
- bool is_dependent() const { return true; }
- bool depends_on (boost::shared_ptr<Region> other) const {
- return other == _in || other == _out;
- }
-
- static framecnt_t short_xfade_length() { return _short_xfade_length; }
- static void set_short_xfade_length (framecnt_t n);
-
- /** emitted when the actual fade curves change, as opposed to one of the Stateful properties */
- PBD::Signal0<void> FadesChanged;
-
- private:
- friend struct CrossfadeComparePtr;
- friend class AudioPlaylist;
-
- static framecnt_t _short_xfade_length;
-
- boost::shared_ptr<ARDOUR::AudioRegion> _in;
- boost::shared_ptr<ARDOUR::AudioRegion> _out;
- PBD::Property<bool> _active;
- PBD::Property<bool> _follow_overlap;
- bool _in_update;
- OverlapType overlap_type;
- AnchorPoint _anchor_point;
- bool _fixed;
- int32_t layer_relation;
-
-
- mutable AutomationList _fade_in;
- mutable AutomationList _fade_out;
-
- static Sample* crossfade_buffer_out;
- static Sample* crossfade_buffer_in;
-
- void initialize ();
- void register_properties ();
- int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
- bool update ();
-
- bool operator== (const ARDOUR::Crossfade&);
-
- protected:
- framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int) const;
-};
-
-
-} // namespace ARDOUR
-
-#endif /* __ardour_overlap_h__ */
diff --git a/libs/ardour/ardour/crossfade_binder.h b/libs/ardour/ardour/crossfade_binder.h
deleted file mode 100644
index 1adfdde545..0000000000
--- a/libs/ardour/ardour/crossfade_binder.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) 2011 Paul Davis
- Author: Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "pbd/id.h"
-#include "pbd/memento_command.h"
-
-class XMLNode;
-
-namespace ARDOUR {
-
-class Crossfade;
-class Playlist;
-class SessionPlaylists;
-
-/** A MementoCommandBinder for Crossfades; required because the undo record
- * may contain details of crossfades that have subsequently been deleted.
- * This class allows recovery of a crossfade from an ID once it has been
- * recreated by a previous undo step.
- */
-class CrossfadeBinder : public MementoCommandBinder<ARDOUR::Crossfade>
-{
-public:
- CrossfadeBinder (boost::shared_ptr<ARDOUR::SessionPlaylists>, PBD::ID);
- CrossfadeBinder (XMLNode *, boost::shared_ptr<SessionPlaylists>);
-
- ARDOUR::Crossfade* get () const;
- std::string type_name () const;
- void add_state (XMLNode *);
-
-private:
- boost::shared_ptr<ARDOUR::SessionPlaylists> _playlists;
- PBD::ID _id;
-};
-
-}
diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h
index fb2327324d..bbc3a85dbe 100644
--- a/libs/ardour/ardour/diskstream.h
+++ b/libs/ardour/ardour/diskstream.h
@@ -243,8 +243,10 @@ class Diskstream : public SessionObject, public PublicDiskstream
virtual void use_destructive_playlist () {}
virtual void prepare_to_stop (framepos_t pos);
- void calculate_record_range(OverlapType ot, framepos_t transport_frame, framecnt_t nframes,
- framecnt_t& rec_nframes, framecnt_t& rec_offset);
+ void calculate_record_range (
+ Evoral::OverlapType ot, framepos_t transport_frame, framecnt_t nframes,
+ framecnt_t& rec_nframes, framecnt_t& rec_offset
+ );
static framecnt_t disk_io_chunk_frames;
std::vector<CaptureInfo*> capture_info;
diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h
index 339e07faa1..543e1b353f 100644
--- a/libs/ardour/ardour/midi_playlist.h
+++ b/libs/ardour/ardour/midi_playlist.h
@@ -63,12 +63,6 @@ public:
protected:
- /* playlist "callbacks" */
-
- void finalize_split_region (boost::shared_ptr<Region> original, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
-
- void check_dependents (boost::shared_ptr<Region> region, bool norefresh);
- void refresh_dependents (boost::shared_ptr<Region> region);
void remove_dependents (boost::shared_ptr<Region> region);
private:
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index d315daacaf..3648ceda8f 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -153,7 +153,8 @@ public:
boost::shared_ptr<RegionList> regions_at (framepos_t frame);
uint32_t count_regions_at (framepos_t) const;
boost::shared_ptr<RegionList> regions_touched (framepos_t start, framepos_t end);
- boost::shared_ptr<RegionList> regions_to_read (framepos_t start, framepos_t end);
+ boost::shared_ptr<RegionList> regions_with_start_within (Evoral::Range<framepos_t>);
+ boost::shared_ptr<RegionList> regions_with_end_within (Evoral::Range<framepos_t>);
uint32_t region_use_count (boost::shared_ptr<Region>) const;
boost::shared_ptr<Region> find_region (const PBD::ID&) const;
boost::shared_ptr<Region> top_region_at (framepos_t frame);
@@ -170,7 +171,7 @@ public:
void foreach_region (boost::function<void (boost::shared_ptr<Region>)>);
XMLNode& get_state ();
- int set_state (const XMLNode&, int version);
+ virtual int set_state (const XMLNode&, int version);
XMLNode& get_template ();
PBD::Signal1<void,bool> InUse;
@@ -322,10 +323,7 @@ public:
void splice_locked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude);
void splice_unlocked (framepos_t at, framecnt_t distance, boost::shared_ptr<Region> exclude);
- virtual void finalize_split_region (boost::shared_ptr<Region> /*original*/, boost::shared_ptr<Region> /*left*/, boost::shared_ptr<Region> /*right*/) {}
-
- virtual void check_dependents (boost::shared_ptr<Region> /*region*/, bool /*norefresh*/) {}
- virtual void refresh_dependents (boost::shared_ptr<Region> /*region*/) {}
+ virtual void check_crossfades (Evoral::Range<framepos_t>) {}
virtual void remove_dependents (boost::shared_ptr<Region> /*region*/) {}
virtual XMLNode& state (bool);
@@ -351,14 +349,6 @@ public:
void _split_region (boost::shared_ptr<Region>, framepos_t position);
typedef std::pair<boost::shared_ptr<Region>, boost::shared_ptr<Region> > TwoRegions;
- virtual void copy_dependents (const std::vector<TwoRegions>&, Playlist*) const { }
-
- struct RegionInfo {
- boost::shared_ptr<Region> region;
- framepos_t position;
- framecnt_t length;
- framepos_t start;
- };
/* this is called before we create a new compound region */
virtual void pre_combine (std::vector<boost::shared_ptr<Region> >&) {}
@@ -372,6 +362,7 @@ public:
private:
void setup_layering_indices (RegionList const &) const;
+ void coalesce_and_check_crossfades (std::list<Evoral::Range<framepos_t> >);
boost::shared_ptr<RegionList> find_regions_at (framepos_t);
};
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index a238ff9038..788a8d90c9 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -141,6 +141,14 @@ class Region
framepos_t first_frame () const { return _position; }
framepos_t last_frame () const { return _position + _length - 1; }
+ Evoral::Range<framepos_t> last_range () const {
+ return Evoral::Range<framepos_t> (_last_position, _last_position + _last_length - 1);
+ }
+
+ Evoral::Range<framepos_t> range () const {
+ return Evoral::Range<framepos_t> (first_frame(), last_frame());
+ }
+
bool hidden () const { return _hidden; }
bool muted () const { return _muted; }
bool opaque () const { return _opaque; }
@@ -168,8 +176,14 @@ class Region
return first_frame() <= frame && frame <= last_frame();
}
- OverlapType coverage (framepos_t start, framepos_t end) const {
- return ARDOUR::coverage (first_frame(), last_frame(), start, end);
+ /** @return coverage of this region with the given range;
+ * OverlapInternal: the range is internal to this region.
+ * OverlapStart: the range overlaps the start of this region.
+ * OverlapEnd: the range overlaps the end of this region.
+ * OverlapExternal: the range overlaps all of this region.
+ */
+ Evoral::OverlapType coverage (framepos_t start, framepos_t end) const {
+ return Evoral::coverage (first_frame(), last_frame(), start, end);
}
bool equivalent (boost::shared_ptr<const Region>) const;
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index 3ebf5478e6..b3c1666dbb 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -36,6 +36,8 @@
#include "pbd/id.h"
+#include "evoral/Range.hpp"
+
#include "ardour/chan_count.h"
#include <map>
@@ -101,17 +103,6 @@ namespace ARDOUR {
ARDOUR::ChanCount after;
};
- enum OverlapType {
- OverlapNone, // no overlap
- OverlapInternal, // the overlap is 100% with the object
- OverlapStart, // overlap covers start, but ends within
- OverlapEnd, // overlap begins within and covers end
- OverlapExternal // overlap extends to (at least) begin+end
- };
-
- ARDOUR::OverlapType coverage (framepos_t sa, framepos_t ea,
- framepos_t sb, framepos_t eb);
-
/* policies for inserting/pasting material where overlaps
might be an issue.
*/
@@ -278,6 +269,9 @@ namespace ARDOUR {
}
};
+ /* XXX: slightly unfortunate that there is this and Evoral::Range<>,
+ but this has a uint32_t id which Evoral::Range<> does not.
+ */
struct AudioRange {
framepos_t start;
framepos_t end;
@@ -295,8 +289,8 @@ namespace ARDOUR {
return start == other.start && end == other.end;
}
- OverlapType coverage (framepos_t s, framepos_t e) const {
- return ARDOUR::coverage (start, end, s, e);
+ Evoral::OverlapType coverage (framepos_t s, framepos_t e) const {
+ return Evoral::coverage (start, end, s, e);
}
};