From ce7a5e1c9fa3edf2d9cc66875505e402a0aaa6f6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 18 Feb 2010 13:59:49 +0000 Subject: the Properties & 64bit region commit git-svn-id: svn://localhost/ardour2/branches/3.0@6695 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/ardour.h | 11 +- libs/ardour/ardour/audioplaylist.h | 4 +- libs/ardour/ardour/audioregion.h | 121 ++++++++------- libs/ardour/ardour/audiosource.h | 49 ++++--- libs/ardour/ardour/crossfade.h | 40 ++--- libs/ardour/ardour/debug.h | 3 +- libs/ardour/ardour/diskstream.h | 6 +- libs/ardour/ardour/location.h | 2 +- libs/ardour/ardour/midi_model.h | 2 +- libs/ardour/ardour/midi_playlist.h | 2 +- libs/ardour/ardour/midi_region.h | 60 ++++---- libs/ardour/ardour/playlist.h | 82 +++++------ libs/ardour/ardour/readable.h | 4 +- libs/ardour/ardour/region.h | 267 ++++++++++++++++++---------------- libs/ardour/ardour/region_factory.h | 40 ++--- libs/ardour/ardour/route_group.h | 91 ++++++------ libs/ardour/ardour/session.h | 4 +- libs/ardour/ardour/session_object.h | 17 ++- libs/ardour/ardour/silentfilesource.h | 12 +- libs/ardour/ardour/sndfilesource.h | 29 ++-- libs/ardour/ardour/source.h | 6 +- libs/ardour/ardour/tempo.h | 2 +- libs/ardour/ardour/types.h | 5 + 23 files changed, 462 insertions(+), 397 deletions(-) (limited to 'libs/ardour/ardour') diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 403cf21007..f608db5b7e 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -65,12 +65,11 @@ namespace ARDOUR { return (microseconds_t) jack_get_time(); } - extern PBD::Change StartChanged; - extern PBD::Change LengthChanged; - extern PBD::Change PositionChanged; - extern PBD::Change NameChanged; - extern PBD::Change BoundsChanged; - extern PBD::Change FlagsChanged; + extern PBD::PropertyChange StartChanged; + extern PBD::PropertyChange LengthChanged; + extern PBD::PropertyChange PositionChanged; + extern PBD::PropertyChange NameChanged; + extern PBD::PropertyChange BoundsChanged; static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */ diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index ce7c8aa335..b5df4cfabb 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -79,8 +79,8 @@ class AudioPlaylist : public ARDOUR::Playlist XMLNode& state (bool full_state); void dump () const; - bool region_changed (PBD::Change, boost::shared_ptr); - void crossfade_changed (PBD::Change); + bool region_changed (PBD::PropertyChange, boost::shared_ptr); + void crossfade_changed (PBD::PropertyChange); void add_crossfade (boost::shared_ptr); void source_offset_changed (boost::shared_ptr region); diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 3f1e4cf9e3..711c8030bd 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -34,24 +34,37 @@ class XMLNode; + namespace ARDOUR { +namespace Properties { + extern PBD::PropertyDescriptor envelope_active; + extern PBD::PropertyDescriptor default_fade_in; + extern PBD::PropertyDescriptor default_fade_out; + extern PBD::PropertyDescriptor fade_in_active; + extern PBD::PropertyDescriptor fade_out_active; + extern PBD::PropertyDescriptor scale_amplitude; +} + class Route; class Playlist; class Session; class Filter; class AudioSource; + class AudioRegion : public Region { public: - static PBD::Change FadeInChanged; - static PBD::Change FadeOutChanged; - static PBD::Change FadeInActiveChanged; - static PBD::Change FadeOutActiveChanged; - static PBD::Change EnvelopeActiveChanged; - static PBD::Change ScaleAmplitudeChanged; - static PBD::Change EnvelopeChanged; + static void make_property_quarks (); + + static PBD::PropertyChange FadeInChanged; + static PBD::PropertyChange FadeOutChanged; + static PBD::PropertyChange FadeInActiveChanged; + static PBD::PropertyChange FadeOutActiveChanged; + static PBD::PropertyChange EnvelopeActiveChanged; + static PBD::PropertyChange ScaleAmplitudeChanged; + static PBD::PropertyChange EnvelopeChanged; ~AudioRegion(); @@ -68,9 +81,9 @@ class AudioRegion : public Region void normalize_to (float target_in_dB = 0.0f); - bool envelope_active () const { return _flags & Region::EnvelopeActive; } - bool fade_in_active () const { return _flags & Region::FadeIn; } - bool fade_out_active () const { return _flags & Region::FadeOut; } + bool envelope_active () const { return _envelope_active; } + bool fade_in_active () const { return _fade_in_active; } + bool fade_out_active () const { return _fade_out_active; } boost::shared_ptr fade_in() { return _fade_in; } boost::shared_ptr fade_out() { return _fade_out; } @@ -90,26 +103,26 @@ class AudioRegion : public Region ReadOpsFades = 0x8 }; - virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const; - virtual nframes_t read_with_ops (Sample*, sframes_t pos, nframes_t cnt, int channel, ReadOps rops) const; - virtual nframes64_t readable_length() const { return length(); } - - virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, - sframes_t position, - nframes_t cnt, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; - - virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, - sframes_t position, nframes_t cnt, uint32_t chan_n=0) const; - - virtual nframes_t read_raw_internal (Sample*, sframes_t, nframes_t, int channel) const; + virtual framecnt_t read (Sample*, framepos_t pos, framecnt_t cnt, int channel) const; + virtual framecnt_t read_with_ops (Sample*, framepos_t pos, framecnt_t cnt, int channel, ReadOps rops) const; + virtual framecnt_t readable_length() const { return length(); } + + virtual framecnt_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, + framepos_t position, + framecnt_t cnt, + uint32_t chan_n = 0, + framecnt_t read_frames = 0, + framecnt_t skip_frames = 0) const; + + virtual framecnt_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, + framepos_t position, framecnt_t cnt, uint32_t chan_n=0) const; + + virtual framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int channel) const; XMLNode& state (bool); - int set_state (const XMLNode&, int version); + int set_state (const XMLNode&, int version); - static void set_default_fade (float steepness, nframes_t len); + static void set_default_fade (float steepness, framecnt_t len); bool fade_in_is_default () const; bool fade_out_is_default () const; @@ -123,14 +136,14 @@ class AudioRegion : public Region void set_fade_in_active (bool yn); void set_fade_in_shape (FadeShape); - void set_fade_in_length (nframes_t); - void set_fade_in (FadeShape, nframes_t); + void set_fade_in_length (framecnt_t); + void set_fade_in (FadeShape, framecnt_t); void set_fade_in (boost::shared_ptr); void set_fade_out_active (bool yn); void set_fade_out_shape (FadeShape); - void set_fade_out_length (nframes_t); - void set_fade_out (FadeShape, nframes_t); + void set_fade_out_length (framecnt_t); + void set_fade_out (FadeShape, framecnt_t); void set_fade_out (boost::shared_ptr); void set_envelope_active (bool yn); @@ -162,22 +175,31 @@ class AudioRegion : public Region void resume_fade_out (); int get_transients (AnalysisFeatureList&, bool force_new = false); - std::list > find_silence (Sample, nframes_t) const; + std::list > find_silence (Sample, framecnt_t) const; private: friend class RegionFactory; friend class Crossfade; - AudioRegion (boost::shared_ptr, nframes_t start, nframes_t length); - AudioRegion (boost::shared_ptr, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - AudioRegion (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - AudioRegion (boost::shared_ptr, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - AudioRegion (boost::shared_ptr, const SourceList&, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - AudioRegion (boost::shared_ptr); + AudioRegion (boost::shared_ptr); + AudioRegion (const SourceList &); + AudioRegion (boost::shared_ptr, frameoffset_t offset = 0, bool offset_relative = true); + AudioRegion (boost::shared_ptr, const SourceList&); AudioRegion (boost::shared_ptr, const XMLNode&); AudioRegion (SourceList &, const XMLNode&); private: + PBD::Property _envelope_active; + PBD::Property _default_fade_in; + PBD::Property _default_fade_out; + PBD::Property _fade_in_active; + PBD::Property _fade_out_active; + PBD::Property _scale_amplitude; + + void register_properties (); + PBD::PropertyChange set_property (const PBD::PropertyBase& prop); + void post_set (); + void init (); void set_default_fades (); void set_default_fade_in (); @@ -186,13 +208,13 @@ class AudioRegion : public Region void recompute_gain_at_end (); void recompute_gain_at_start (); - nframes_t _read_at (const SourceList&, nframes_t limit, - Sample *buf, Sample *mixdown_buffer, float *gain_buffer, - sframes_t position, nframes_t cnt, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0, - ReadOps readops = ReadOps (~0)) const; + framecnt_t _read_at (const SourceList&, framecnt_t limit, + Sample *buf, Sample *mixdown_buffer, float *gain_buffer, + framepos_t position, framecnt_t cnt, + uint32_t chan_n = 0, + framecnt_t read_frames = 0, + framecnt_t skip_frames = 0, + ReadOps readops = ReadOps (~0)) const; void recompute_at_start (); void recompute_at_end (); @@ -210,16 +232,15 @@ class AudioRegion : public Region boost::shared_ptr _fade_in; boost::shared_ptr _fade_out; boost::shared_ptr _envelope; - gain_t _scale_amplitude; - uint32_t _fade_in_disabled; - uint32_t _fade_out_disabled; + uint32_t _fade_in_suspended; + uint32_t _fade_out_suspended; protected: /* default constructor for derived (compound) types */ - AudioRegion (Session& s, nframes_t, nframes_t, std::string name); + AudioRegion (Session& s, framepos_t, framecnt_t, std::string name); - int set_live_state (const XMLNode&, int version, PBD::Change&, bool send); + int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 45f62fc7b9..c39dbdfd8c 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -45,16 +45,16 @@ class AudioSource : virtual public Source, AudioSource (Session&, const XMLNode&); virtual ~AudioSource (); - nframes64_t readable_length() const { return _length; } - uint32_t n_channels() const { return 1; } + framecnt_t readable_length() const { return _length; } + uint32_t n_channels() const { return 1; } - sframes_t length (sframes_t pos) const; - void update_length (sframes_t pos, sframes_t cnt); + framecnt_t length (framepos_t pos) const; + void update_length (framepos_t pos, framecnt_t cnt); - virtual nframes_t available_peaks (double zoom) const; + virtual framecnt_t available_peaks (double zoom) const; - virtual nframes_t read (Sample *dst, sframes_t start, nframes_t cnt, int channel=0) const; - virtual nframes_t write (Sample *src, nframes_t cnt); + virtual framecnt_t read (Sample *dst, framepos_t start, framecnt_t cnt, int channel=0) const; + virtual framecnt_t write (Sample *src, framecnt_t cnt); virtual float sample_rate () const = 0; @@ -68,14 +68,14 @@ class AudioSource : virtual public Source, uint32_t read_data_count() const { return _read_data_count; } uint32_t write_data_count() const { return _write_data_count; } - int read_peaks (PeakData *peaks, nframes_t npeaks, - sframes_t start, nframes_t cnt, double samples_per_visual_peak) const; + int read_peaks (PeakData *peaks, framecnt_t npeaks, + framepos_t start, framecnt_t cnt, double samples_per_visual_peak) const; int build_peaks (); bool peaks_ready (boost::function callWhenReady, PBD::Connection& connection_created_if_not_ready, PBD::EventLoop* event_loop) const; mutable PBD::Signal0 PeaksReady; - mutable PBD::Signal2 PeakRangeReady; + mutable PBD::Signal2 PeakRangeReady; XMLNode& get_state (); int set_state (const XMLNode&, int version); @@ -104,7 +104,7 @@ class AudioSource : virtual public Source, static bool _build_missing_peakfiles; static bool _build_peakfiles; - sframes_t _length; + framecnt_t _length; bool _peaks_built; mutable Glib::Mutex _peaks_ready_lock; Glib::ustring peakpath; @@ -115,31 +115,32 @@ class AudioSource : virtual public Source, int initialize_peakfile (bool newfile, Glib::ustring path); int build_peaks_from_scratch (); - int compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt, + int compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt, bool force, bool intermediate_peaks_ready_signal); void truncate_peakfile(); mutable off_t _peak_byte_max; // modified in compute_and_write_peak() - virtual nframes_t read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const = 0; - virtual nframes_t write_unlocked (Sample *dst, nframes_t cnt) = 0; + virtual framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const = 0; + virtual framecnt_t write_unlocked (Sample *dst, framecnt_t cnt) = 0; virtual Glib::ustring peak_path(Glib::ustring audio_path) = 0; virtual Glib::ustring find_broken_peakfile (Glib::ustring missing_peak_path, Glib::ustring audio_path) = 0; virtual int read_peaks_with_fpp (PeakData *peaks, - nframes_t npeaks, sframes_t start, nframes_t cnt, - double samples_per_visual_peak, nframes_t fpp) const; - - int compute_and_write_peaks (Sample* buf, sframes_t first_frame, nframes_t cnt, - bool force, bool intermediate_peaks_ready_signal, nframes_t frames_per_peak); + framecnt_t npeaks, framepos_t start, framecnt_t cnt, + double samples_per_visual_peak, framecnt_t fpp) const; + + int compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt, + bool force, bool intermediate_peaks_ready_signal, + framecnt_t frames_per_peak); private: - int peakfile; - nframes_t peak_leftover_cnt; - nframes_t peak_leftover_size; - Sample* peak_leftovers; - nframes_t peak_leftover_frame; + int peakfile; + framecnt_t peak_leftover_cnt; + framecnt_t peak_leftover_size; + Sample* peak_leftovers; + framepos_t peak_leftover_frame; }; } diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index 148b501e51..15b9b3d2a7 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -50,9 +50,9 @@ class Crossfade : public ARDOUR::AudioRegion /* constructor for "fixed" xfades at each end of an internal overlap */ Crossfade (boost::shared_ptr in, boost::shared_ptr out, - nframes_t position, - nframes_t initial_length, - AnchorPoint); + framepos_t position, + framecnt_t initial_length, + AnchorPoint); /* constructor for xfade between two regions that are overlapped in any way except the "internal" case. @@ -79,11 +79,11 @@ class Crossfade : public ARDOUR::AudioRegion boost::shared_ptr in() const { return _in; } boost::shared_ptr out() const { return _out; } - nframes_t read_at (Sample *buf, Sample *mixdown_buffer, - float *gain_buffer, sframes_t position, nframes_t cnt, - uint32_t chan_n, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; + framecnt_t read_at (Sample *buf, Sample *mixdown_buffer, + float *gain_buffer, framepos_t position, framecnt_t cnt, + uint32_t chan_n, + framecnt_t read_frames = 0, + framecnt_t skip_frames = 0) const; bool refresh (); @@ -103,18 +103,18 @@ class Crossfade : public ARDOUR::AudioRegion return (_in == a && _out == b) || (_in == b && _out == a); } - nframes_t overlap_length() const; + framecnt_t overlap_length() const; PBD::Signal1 > Invalidated; - PBD::Signal1 StateChanged; + PBD::Signal1 StateChanged; - bool covers (nframes_t frame) const { + bool covers (framecnt_t frame) const { return _position <= frame && frame < _position + _length; } - OverlapType coverage (nframes_t start, nframes_t end) const; + OverlapType coverage (framepos_t start, framepos_t end) const; - static void set_buffer_size (nframes_t); + static void set_buffer_size (framecnt_t); bool active () const { return _active; } void set_active (bool yn); @@ -126,24 +126,24 @@ class Crossfade : public ARDOUR::AudioRegion AutomationList& fade_in() { return _fade_in; } AutomationList& fade_out() { return _fade_out; } - nframes_t set_xfade_length (nframes_t); + framecnt_t set_xfade_length (framecnt_t); bool is_dependent() const { return true; } bool depends_on (boost::shared_ptr other) const { return other == _in || other == _out; } - static nframes_t short_xfade_length() { return _short_xfade_length; } - static void set_short_xfade_length (nframes_t n); + static framecnt_t short_xfade_length() { return _short_xfade_length; } + static void set_short_xfade_length (framecnt_t n); - static PBD::Change ActiveChanged; - static PBD::Change FollowOverlapChanged; + static PBD::PropertyChange ActiveChanged; + static PBD::PropertyChange FollowOverlapChanged; private: friend struct CrossfadeComparePtr; friend class AudioPlaylist; - static nframes_t _short_xfade_length; + static framecnt_t _short_xfade_length; boost::shared_ptr _in; boost::shared_ptr _out; @@ -167,7 +167,7 @@ class Crossfade : public ARDOUR::AudioRegion bool update (); protected: - nframes_t read_raw_internal (Sample*, sframes_t, nframes_t, int) const; + framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int) const; }; diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h index 24c6e9915f..b7ee4c328c 100644 --- a/libs/ardour/ardour/debug.h +++ b/libs/ardour/ardour/debug.h @@ -52,7 +52,8 @@ namespace ARDOUR { SessionEvents = 0x800, MidiIO = 0x1000, MackieControl = 0x2000, - MidiClock = 0x4000 + MidiClock = 0x4000, + Properties = 0x8000 }; } diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index 0c1bbd54d8..90bcf4067a 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -141,7 +141,7 @@ class Diskstream : public SessionObject void remove_region_from_last_capture (boost::weak_ptr wregion); void move_processor_automation (boost::weak_ptr, - std::list< Evoral::RangeMove > const &); + std::list > const &); PBD::Signal0 RecordEnableChanged; PBD::Signal0 SpeedChanged; @@ -206,9 +206,9 @@ class Diskstream : public SessionObject /* XXX fix this redundancy ... */ - virtual void playlist_changed (PBD::Change); + virtual void playlist_changed (PBD::PropertyChange); virtual void playlist_deleted (boost::weak_ptr); - virtual void playlist_ranges_moved (std::list< Evoral::RangeMove > const &); + virtual void playlist_ranges_moved (std::list< Evoral::RangeMove > const &); virtual void transport_stopped (struct tm&, time_t, bool abort) = 0; virtual void transport_looped (nframes_t transport_frame) = 0; diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 6cec906d28..d93ffeec4a 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -179,7 +179,7 @@ class Locations : public PBD::StatefulDestructible PBD::Signal0 changed; PBD::Signal1 added; PBD::Signal1 removed; - PBD::Signal1 StateChanged; + PBD::Signal1 StateChanged; template void apply (T& obj, void (T::*method)(LocationList&)) { Glib::Mutex::Lock lm (lock); diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 3cf64da6ea..77f5798898 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -90,7 +90,7 @@ public: }; - /** Change note properties. + /** PropertyChange note properties. * More efficient than DeltaCommand and has the important property that * it leaves the objects in the MidiModel (Notes) the same, thus * enabling selection and other state to persist across command diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index 32196206e2..46aea9f0b4 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -74,7 +74,7 @@ protected: private: void dump () const; - bool region_changed (PBD::Change, boost::shared_ptr); + bool region_changed (PBD::PropertyChange, boost::shared_ptr); NoteMode _note_mode; diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 7309058b8e..d892e5837f 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -53,29 +53,29 @@ class MidiRegion : public Region boost::shared_ptr midi_source (uint32_t n=0) const; /* Stub Readable interface */ - virtual nframes_t read (Sample*, sframes_t /*pos*/, nframes_t /*cnt*/, int /*channel*/) const { return 0; } - virtual sframes_t readable_length() const { return length(); } - - nframes_t read_at (Evoral::EventSink& dst, - sframes_t position, - nframes_t dur, - uint32_t chan_n = 0, - NoteMode mode = Sustained, - MidiStateTracker* tracker = 0) const; - - nframes_t master_read_at (MidiRingBuffer& dst, - sframes_t position, - nframes_t dur, - uint32_t chan_n = 0, - NoteMode mode = Sustained) const; + virtual framecnt_t read (Sample*, framepos_t /*pos*/, framecnt_t /*cnt*/, int /*channel*/) const { return 0; } + virtual framecnt_t readable_length() const { return length(); } + + framecnt_t read_at (Evoral::EventSink& dst, + framepos_t position, + framecnt_t dur, + uint32_t chan_n = 0, + NoteMode mode = Sustained, + MidiStateTracker* tracker = 0) const; + + framepos_t master_read_at (MidiRingBuffer& dst, + framepos_t position, + framecnt_t dur, + uint32_t chan_n = 0, + NoteMode mode = Sustained) const; XMLNode& state (bool); int set_state (const XMLNode&, int version); - + int separate_by_channel (ARDOUR::Session&, std::vector< boost::shared_ptr >&) const; /* automation */ - + boost::shared_ptr control(const Evoral::Parameter& id, bool create=false) { return model()->control(id, create); @@ -96,32 +96,26 @@ class MidiRegion : public Region private: friend class RegionFactory; - MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length); - MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - MidiRegion (const SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - MidiRegion (boost::shared_ptr); + MidiRegion (boost::shared_ptr); + MidiRegion (const SourceList&); + MidiRegion (boost::shared_ptr, frameoffset_t offset = 0, bool offset_relative = true); MidiRegion (boost::shared_ptr, const XMLNode&); MidiRegion (const SourceList &, const XMLNode&); private: - nframes_t _read_at (const SourceList&, Evoral::EventSink& dst, - sframes_t position, - nframes_t dur, - uint32_t chan_n = 0, - NoteMode mode = Sustained, - MidiStateTracker* tracker = 0) const; + framecnt_t _read_at (const SourceList&, Evoral::EventSink& dst, + framepos_t position, + framecnt_t dur, + uint32_t chan_n = 0, + NoteMode mode = Sustained, + MidiStateTracker* tracker = 0) const; void recompute_at_start (); void recompute_at_end (); - void set_position_internal (nframes_t pos, bool allow_bbt_recompute); + void set_position_internal (framepos_t pos, bool allow_bbt_recompute); void switch_source(boost::shared_ptr source); - - protected: - - int set_live_state (const XMLNode&, int version, PBD::Change&, bool send); }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 404fc61d2d..9cd02dec1e 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -58,7 +58,7 @@ class Playlist : public SessionObject Playlist (Session&, const XMLNode&, DataType type, bool hidden = false); Playlist (Session&, std::string name, DataType type, bool hidden = false); Playlist (boost::shared_ptr, std::string name, bool hidden = false); - Playlist (boost::shared_ptr, nframes_t start, nframes_t cnt, std::string name, bool hidden = false); + Playlist (boost::shared_ptr, framepos_t start, framecnt_t cnt, std::string name, bool hidden = false); virtual ~Playlist (); @@ -81,7 +81,7 @@ class Playlist : public SessionObject bool hidden() const { return _hidden; } bool empty() const; uint32_t n_regions() const; - nframes_t get_maximum_extent () const; + framecnt_t get_maximum_extent () const; layer_t top_layer() const; EditMode get_edit_mode() const { return _edit_mode; } @@ -89,39 +89,39 @@ class Playlist : public SessionObject /* Editing operations */ - void add_region (boost::shared_ptr, nframes_t position, float times = 1, bool auto_partition = false); + void add_region (boost::shared_ptr, framepos_t position, float times = 1, bool auto_partition = false); 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 >&); - void replace_region (boost::shared_ptr old, boost::shared_ptr newr, nframes_t pos); - void split_region (boost::shared_ptr, nframes_t position); - void split (nframes64_t at); - void shift (nframes64_t at, nframes64_t distance, bool move_intersected, bool ignore_music_glue); - void partition (nframes_t start, nframes_t end, bool cut = false); - void duplicate (boost::shared_ptr, nframes_t position, float times); - void nudge_after (nframes_t start, nframes_t distance, bool forwards); + void replace_region (boost::shared_ptr old, boost::shared_ptr newr, framepos_t pos); + void split_region (boost::shared_ptr, framepos_t position); + void split (framepos_t at); + void shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue); + void partition (framepos_t start, framepos_t end, bool cut = false); + void duplicate (boost::shared_ptr, framepos_t position, float times); + void nudge_after (framepos_t start, framecnt_t distance, bool forwards); void shuffle (boost::shared_ptr, int dir); void update_after_tempo_map_change (); boost::shared_ptr cut (std::list&, bool result_is_hidden = true); boost::shared_ptr copy (std::list&, bool result_is_hidden = true); - int paste (boost::shared_ptr, nframes_t position, float times); + int paste (boost::shared_ptr, framepos_t position, float times); const RegionList& region_list () const { return regions; } - RegionList* regions_at (nframes_t frame); - RegionList* regions_touched (nframes_t start, nframes_t end); - RegionList* regions_to_read (nframes_t start, nframes_t end); + RegionList* regions_at (framepos_t frame); + RegionList* regions_touched (framepos_t start, framepos_t end); + RegionList* regions_to_read (framepos_t start, framepos_t end); boost::shared_ptr find_region (const PBD::ID&) const; - boost::shared_ptr top_region_at (nframes_t frame); - boost::shared_ptr top_unmuted_region_at (nframes_t frame); - boost::shared_ptr find_next_region (nframes_t frame, RegionPoint point, int dir); - nframes64_t find_next_region_boundary (nframes64_t frame, int dir); + boost::shared_ptr top_region_at (framepos_t frame); + boost::shared_ptr top_unmuted_region_at (framepos_t frame); + boost::shared_ptr find_next_region (framepos_t frame, RegionPoint point, int dir); + framepos_t find_next_region_boundary (framepos_t frame, int dir); bool region_is_shuffle_constrained (boost::shared_ptr); - bool has_region_at (nframes64_t const) const; + bool has_region_at (framepos_t const) const; - nframes64_t find_next_transient (nframes64_t position, int dir); + framepos_t find_next_transient (framepos_t position, int dir); void foreach_region (boost::function)>); @@ -136,7 +136,7 @@ class Playlist : public SessionObject PBD::Signal0 NameChanged; PBD::Signal0 LengthChanged; PBD::Signal0 LayeringChanged; - PBD::Signal1 > const &> RangesMoved; + PBD::Signal1 > const &> RangesMoved; static std::string bump_name (std::string old_name, Session&); @@ -205,7 +205,7 @@ class Playlist : public SessionObject bool pending_contents_change; bool pending_layering; bool pending_length; - std::list< Evoral::RangeMove > pending_range_moves; + std::list< Evoral::RangeMove > pending_range_moves; bool save_on_thaw; std::string last_save_reason; uint32_t in_set_state; @@ -223,7 +223,7 @@ class Playlist : public SessionObject uint32_t _read_data_count; PBD::ID _orig_diskstream_id; uint64_t layer_op_counter; - nframes_t freeze_length; + framecnt_t freeze_length; bool auto_partition; /** true if relayering should be done using region's current layers and their `pending explicit relayer' @@ -249,25 +249,25 @@ class Playlist : public SessionObject void notify_length_changed (); void notify_layering_changed (); void notify_contents_changed (); - void notify_state_changed (PBD::Change); + void notify_state_changed (PBD::PropertyChange); void notify_region_moved (boost::shared_ptr); void mark_session_dirty(); - void region_changed_proxy (PBD::Change, boost::weak_ptr); - virtual bool region_changed (PBD::Change, boost::shared_ptr); + void region_changed_proxy (PBD::PropertyChange, boost::weak_ptr); + virtual bool region_changed (PBD::PropertyChange, boost::shared_ptr); - void region_bounds_changed (PBD::Change, boost::shared_ptr); + void region_bounds_changed (PBD::PropertyChange, boost::shared_ptr); void region_deleted (boost::shared_ptr); void sort_regions (); - void possibly_splice (nframes_t at, nframes64_t distance, boost::shared_ptr exclude = boost::shared_ptr()); - void possibly_splice_unlocked(nframes_t at, nframes64_t distance, boost::shared_ptr exclude = boost::shared_ptr()); + void possibly_splice (framepos_t at, framecnt_t distance, boost::shared_ptr exclude = boost::shared_ptr()); + void possibly_splice_unlocked(framepos_t at, framecnt_t distance, boost::shared_ptr exclude = boost::shared_ptr()); - void core_splice (nframes_t at, nframes64_t distance, boost::shared_ptr exclude); - void splice_locked (nframes_t at, nframes64_t distance, boost::shared_ptr exclude); - void splice_unlocked (nframes_t at, nframes64_t distance, boost::shared_ptr exclude); + void core_splice (framepos_t at, framecnt_t distance, boost::shared_ptr exclude); + void splice_locked (framepos_t at, framecnt_t distance, boost::shared_ptr exclude); + void splice_unlocked (framepos_t at, framecnt_t distance, boost::shared_ptr exclude); virtual void finalize_split_region (boost::shared_ptr /*original*/, boost::shared_ptr /*left*/, boost::shared_ptr /*right*/) {} @@ -279,19 +279,19 @@ class Playlist : public SessionObject boost::shared_ptr region_by_id (PBD::ID); - bool add_region_internal (boost::shared_ptr, nframes_t position); + bool add_region_internal (boost::shared_ptr, framepos_t position); int remove_region_internal (boost::shared_ptr); - RegionList *find_regions_at (nframes_t frame); + RegionList *find_regions_at (framepos_t frame); void copy_regions (RegionList&) const; - void partition_internal (nframes_t start, nframes_t end, bool cutting, RegionList& thawlist); + void partition_internal (framepos_t start, framepos_t end, bool cutting, RegionList& thawlist); - nframes_t _get_maximum_extent() const; + framecnt_t _get_maximum_extent() const; - boost::shared_ptr cut_copy (boost::shared_ptr (Playlist::*pmf)(nframes_t, nframes_t, bool), - std::list& ranges, bool result_is_hidden); - boost::shared_ptr cut (nframes_t start, nframes_t cnt, bool result_is_hidden); - boost::shared_ptr copy (nframes_t start, nframes_t cnt, bool result_is_hidden); + boost::shared_ptr cut_copy (boost::shared_ptr (Playlist::*pmf)(framepos_t, framecnt_t, bool), + std::list& ranges, bool result_is_hidden); + boost::shared_ptr cut (framepos_t start, framecnt_t cnt, bool result_is_hidden); + boost::shared_ptr copy (framepos_t start, framecnt_t cnt, bool result_is_hidden); int move_region_to_layer (layer_t, boost::shared_ptr r, int dir); void relayer (); @@ -301,7 +301,7 @@ class Playlist : public SessionObject void timestamp_layer_op (boost::shared_ptr); - void _split_region (boost::shared_ptr, nframes_t position); + void _split_region (boost::shared_ptr, framepos_t position); }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/readable.h b/libs/ardour/ardour/readable.h index 1ca6a7dbb2..d927cbe4af 100644 --- a/libs/ardour/ardour/readable.h +++ b/libs/ardour/ardour/readable.h @@ -10,8 +10,8 @@ class Readable { Readable () {} virtual ~Readable() {} - virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const = 0; - virtual sframes_t readable_length() const = 0; + virtual framecnt_t read (Sample*, framepos_t pos, framecnt_t cnt, int channel) const = 0; + virtual framecnt_t readable_length() const = 0; virtual uint32_t n_channels () const = 0; }; diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 9c78285a09..60ccf66984 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -36,8 +36,33 @@ class XMLNode; + namespace ARDOUR { +namespace Properties { + extern PBD::PropertyDescriptor muted; + extern PBD::PropertyDescriptor opaque; + extern PBD::PropertyDescriptor locked; + extern PBD::PropertyDescriptor automatic; + extern PBD::PropertyDescriptor whole_file; + extern PBD::PropertyDescriptor import; + extern PBD::PropertyDescriptor external; + extern PBD::PropertyDescriptor sync_marked; + extern PBD::PropertyDescriptor left_of_split; + extern PBD::PropertyDescriptor right_of_split; + extern PBD::PropertyDescriptor hidden; + extern PBD::PropertyDescriptor position_locked; + extern PBD::PropertyDescriptor start; + extern PBD::PropertyDescriptor length; + extern PBD::PropertyDescriptor position; + extern PBD::PropertyDescriptor sync_position; + extern PBD::PropertyDescriptor layer; + extern PBD::PropertyDescriptor ancestral_start; + extern PBD::PropertyDescriptor ancestral_length; + extern PBD::PropertyDescriptor stretch; + extern PBD::PropertyDescriptor shift; +}; + class Playlist; class Filter; class ExportSpecification; @@ -48,6 +73,7 @@ enum RegionEditState { EditChangesID = 2 }; + class Region : public SessionObject , public boost::enable_shared_from_this @@ -56,106 +82,82 @@ class Region public: typedef std::vector > SourceList; - enum Flag { - Muted = 0x1, - Opaque = 0x2, - EnvelopeActive = 0x4, - DefaultFadeIn = 0x8, - DefaultFadeOut = 0x10, - Locked = 0x20, - Automatic = 0x40, - WholeFile = 0x80, - FadeIn = 0x100, - FadeOut = 0x200, - Copied = 0x400, - Import = 0x800, - External = 0x1000, - SyncMarked = 0x2000, - LeftOfSplit = 0x4000, - RightOfSplit = 0x8000, - Hidden = 0x10000, - DoNotSendPropertyChanges = 0x20000, - PositionLocked = 0x40000, - // - range_guarantoor = USHRT_MAX - }; - + static void make_property_quarks (); + enum PositionLockStyle { AudioTime, MusicTime }; - static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut); - - static PBD::Change FadeChanged; - static PBD::Change SyncOffsetChanged; - static PBD::Change MuteChanged; - static PBD::Change OpacityChanged; - static PBD::Change LockChanged; - static PBD::Change LayerChanged; - static PBD::Change HiddenChanged; + static PBD::PropertyChange FadeChanged; + static PBD::PropertyChange SyncOffsetChanged; + static PBD::PropertyChange MuteChanged; + static PBD::PropertyChange OpacityChanged; + static PBD::PropertyChange LockChanged; + static PBD::PropertyChange LayerChanged; + static PBD::PropertyChange HiddenChanged; - PBD::Signal1 StateChanged; + PBD::Signal1 StateChanged; static PBD::Signal1 > RegionPropertyChanged; - void unlock_property_changes () { _flags = Flag (_flags & ~DoNotSendPropertyChanges); } - void block_property_changes () { _flags = Flag (_flags | DoNotSendPropertyChanges); } + void unlock_property_changes () { _no_property_changes = false; } + void block_property_changes () { _no_property_changes = true; } + virtual ~Region(); - + /** Note: changing the name of a Region does not constitute an edit */ bool set_name (const std::string& str); const DataType& data_type() const { return _type; } /** How the region parameters play together: - *
-	 * |------------------------------------------------------------------- track
-	 *                    |..........[------------------].....| region
-	 * |-----------------------------| _position
-	 *                               |------------------| _length
-	 *                    |----------| _start
-	 * 
+ * + * POSITION: first frame of the region along the timeline + * START: first frame of the region within its source(s) + * LENGTH: number of frames the region represents */ - nframes_t position () const { return _position; } - nframes_t start () const { return _start; } - nframes_t length() const { return _length; } - layer_t layer () const { return _layer; } + sframes_t position () const { return _position; } + sframes_t start () const { return _start; } + framecnt_t length() const { return _length; } + layer_t layer () const { return _layer; } - sframes_t source_length(uint32_t n) const; + framecnt_t source_length(uint32_t n) const; /* these two are valid ONLY during a StateChanged signal handler */ - nframes_t last_position() const { return _last_position; } - nframes_t last_length() const { return _last_length; } + sframes_t last_position() const { return _last_position; } + framecnt_t last_length() const { return _last_length; } - nframes64_t ancestral_start () const { return _ancestral_start; } - nframes64_t ancestral_length () const { return _ancestral_length; } + sframes_t ancestral_start () const { return _ancestral_start; } + framecnt_t ancestral_length () const { return _ancestral_length; } float stretch() const { return _stretch; } float shift() const { return _shift; } void set_ancestral_data (nframes64_t start, nframes64_t length, float stretch, float shift); - nframes_t sync_offset(int& dir) const; - nframes_t sync_position() const; - nframes_t sync_point () const; - - nframes_t adjust_to_sync (nframes_t) const; + frameoffset_t sync_offset(int& dir) const; + framepos_t sync_position() const; + framepos_t sync_point () const; + + framepos_t adjust_to_sync (framepos_t) const; /* first_frame() is an alias; last_frame() just hides some math */ - nframes_t first_frame() const { return _position; } - nframes_t last_frame() const { return _position + _length - 1; } - - Flag flags() const { return _flags; } - bool hidden() const { return _flags & Hidden; } - bool muted() const { return _flags & Muted; } - bool opaque () const { return _flags & Opaque; } - bool locked() const { return _flags & Locked; } - bool position_locked() const { return _flags & PositionLocked; } - bool automatic() const { return _flags & Automatic; } - bool whole_file() const { return _flags & WholeFile ; } - bool captured() const { return !(_flags & (Region::Flag (Region::Import|Region::External))); } - bool can_move() const { return !(_flags & (Locked|PositionLocked)); } + framepos_t first_frame() const { return _position; } + framepos_t last_frame() const { return _position + _length - 1; } + + bool hidden() const { return _hidden; } + bool muted() const { return _muted; } + bool opaque () const { return _opaque; } + bool locked() const { return _locked; } + bool position_locked() const { return _position_locked; } + bool automatic() const { return _automatic; } + bool whole_file() const { return _whole_file; } + bool captured() const { return !(_import || _external); } + bool can_move() const { return !_position_locked; } + bool sync_marked() const { return _sync_marked; } + bool external() const { return _external; } + bool import() const { return _import; } PositionLockStyle positional_lock_style() const { return _positional_lock_style; } void set_position_lock_style (PositionLockStyle ps); @@ -164,11 +166,11 @@ class Region void freeze (); void thaw (); - bool covers (nframes_t frame) const { + bool covers (framepos_t frame) const { return first_frame() <= frame && frame <= last_frame(); } - OverlapType coverage (nframes_t start, nframes_t end) const { + OverlapType coverage (framepos_t start, framepos_t end) const { return ARDOUR::coverage (first_frame(), last_frame(), start, end); } @@ -181,21 +183,21 @@ class Region /* EDITING OPERATIONS */ - void set_length (nframes_t, void *src); - void set_start (nframes_t, void *src); - void set_position (nframes_t, void *src); - void set_position_on_top (nframes_t, void *src); - void special_set_position (nframes_t); + void set_length (framecnt_t, void *src); + void set_start (framepos_t, void *src); + void set_position (framepos_t, void *src); + void set_position_on_top (framepos_t, void *src); + void special_set_position (framepos_t); void update_position_after_tempo_map_change (); - void nudge_position (nframes64_t, void *src); + void nudge_position (frameoffset_t, void *src); bool at_natural_position () const; void move_to_natural_position (void *src); - void trim_start (nframes_t new_position, void *src); - void trim_front (nframes_t new_position, void *src); - void trim_end (nframes_t new_position, void *src); - void trim_to (nframes_t position, nframes_t length, void *src); + void trim_start (framepos_t new_position, void *src); + void trim_front (framepos_t new_position, void *src); + void trim_end (framepos_t new_position, void *src); + void trim_to (framepos_t position, framecnt_t length, void *src); void set_layer (layer_t l); /* ONLY Playlist can call this */ void raise (); @@ -203,17 +205,19 @@ class Region void raise_to_top (); void lower_to_bottom (); - void set_sync_position (nframes_t n); + void set_sync_position (framepos_t n); void clear_sync_position (); void set_hidden (bool yn); void set_muted (bool yn); + void set_whole_file (bool yn); + void set_automatic (bool yn); void set_opaque (bool yn); void set_locked (bool yn); void set_position_locked (bool yn); int apply (Filter&); - virtual uint32_t read_data_count() const { return _read_data_count; } + virtual uint64_t read_data_count() const { return _read_data_count; } boost::shared_ptr playlist() const { return _playlist.lock(); } virtual void set_playlist (boost::weak_ptr); @@ -242,7 +246,6 @@ class Region XMLNode& get_state (); virtual XMLNode& state (bool); virtual int set_state (const XMLNode&, int version); - virtual int set_live_state (const XMLNode&, int version, PBD::Change&, bool send); virtual boost::shared_ptr get_parent() const; @@ -278,62 +281,77 @@ class Region protected: friend class RegionFactory; - Region (boost::shared_ptr src, nframes_t start, nframes_t length, - const std::string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags); - Region (const SourceList& srcs, nframes_t start, nframes_t length, - const std::string& name, DataType type, layer_t = 0, Flag flags = DefaultFlags); - - Region (boost::shared_ptr, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Flag flags = DefaultFlags); - Region (boost::shared_ptr, nframes_t length, const std::string& name, layer_t = 0, Flag flags = DefaultFlags); + /** Construct a region from a single source */ + Region (boost::shared_ptr src); + /** Construct a region from multiple sources*/ + Region (const SourceList& srcs); + /** Construct a region from another region, at an offset within that region */ + Region (boost::shared_ptr, frameoffset_t start_offset = 0, bool start_relative = true); + /** Construct a region as a copy of another region, but with different sources */ + Region (boost::shared_ptr, const SourceList&); + /** normal Region copy constructor */ Region (boost::shared_ptr); + + /** Construct a region from 1 source and XML state */ Region (boost::shared_ptr src, const XMLNode&); + /** Construct a region from multiple sources and XML state */ Region (const SourceList& srcs, const XMLNode&); - Region (Session& s, nframes_t start, nframes_t length, const std::string& name, DataType, layer_t = 0, Flag flags = DefaultFlags); + /** Constructor for derived types only */ + Region (Session& s, framepos_t start, framecnt_t length, const std::string& name, DataType); protected: - void copy_stuff (boost::shared_ptr, nframes_t start, nframes_t length, const std::string& name, layer_t, Flag flags); - - XMLNode& get_short_state (); /* used only by Session */ - - void send_change (PBD::Change); + void send_change (PBD::PropertyChange); - void trim_to_internal (nframes_t position, nframes_t length, void *src); - virtual void set_position_internal (nframes_t pos, bool allow_bbt_recompute); + void trim_to_internal (framepos_t position, framecnt_t length, void *src); + virtual void set_position_internal (framepos_t pos, bool allow_bbt_recompute); - bool copied() const { return _flags & Copied; } void maybe_uncopy (); void first_edit (); - bool verify_start (nframes_t); - bool verify_start_and_length (nframes_t, nframes_t&); - bool verify_start_mutable (nframes_t&_start); - bool verify_length (nframes_t); + bool verify_start (framepos_t); + bool verify_start_and_length (framepos_t, framecnt_t&); + bool verify_start_mutable (framepos_t&_start); + bool verify_length (framecnt_t); virtual void recompute_at_start () = 0; virtual void recompute_at_end () = 0; - + DataType _type; - PBD::EnumState _flags; - PBD::State _start; - PBD::State _length; - nframes_t _last_length; - PBD::State _position; - nframes_t _last_position; + bool _no_property_changes; + + PBD::Property _muted; + PBD::Property _opaque; + PBD::Property _locked; + PBD::Property _automatic; + PBD::Property _whole_file; + PBD::Property _import; + PBD::Property _external; + PBD::Property _sync_marked; + PBD::Property _left_of_split; + PBD::Property _right_of_split; + PBD::Property _hidden; + PBD::Property _position_locked; + PBD::Property _start; + PBD::Property _length; + PBD::Property _position; + PBD::Property _sync_position; + PBD::Property _layer; + PBD::Property _ancestral_start; + PBD::Property _ancestral_length; + PBD::Property _stretch; + PBD::Property _shift; + + framecnt_t _last_length; + framepos_t _last_position; PositionLockStyle _positional_lock_style; - PBD::State _sync_position; - PBD::State _layer; mutable RegionEditState _first_edit; int _frozen; - PBD::State _ancestral_start; - PBD::State _ancestral_length; - PBD::State _stretch; - PBD::State _shift; BBT_Time _bbt_time; AnalysisFeatureList _transients; bool _valid_transients; - mutable uint32_t _read_data_count; ///< modified in read() - PBD::Change _pending_changed; + mutable uint64_t _read_data_count; ///< modified in read() + PBD::PropertyChange _pending_changed; uint64_t _last_layer_op; ///< timestamp Glib::Mutex _lock; SourceList _sources; @@ -345,9 +363,12 @@ class Region boost::weak_ptr _playlist; -private: + virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); - void register_states (); + PBD::PropertyChange set_property (const PBD::PropertyBase&); + void register_properties (); + +private: void use_sources (SourceList const &); }; diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h index 64d3417287..16e48828d4 100644 --- a/libs/ardour/ardour/region_factory.h +++ b/libs/ardour/ardour/region_factory.h @@ -44,29 +44,35 @@ class RegionFactory { /** This is emitted only when a new id is assigned. Therefore, in a pure Region copy, it will not be emitted. - It must be emitted by derived classes, not Region + It must be emitted using a derived instance of Region, not Region itself, to permit dynamic_cast<> to be used to infer the type of Region. */ static PBD::Signal1 > CheckNewRegion; - static boost::shared_ptr create (boost::shared_ptr); - - /* note: both of the first two should use const shared_ptr as well, but - gcc 4.1 doesn't seem to be able to disambiguate them if they do. - */ - - static boost::shared_ptr create (boost::shared_ptr, nframes_t start, - nframes_t length, const std::string& name, - layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); - static boost::shared_ptr create (boost::shared_ptr, nframes_t start, - nframes_t length, const std::string& name, - layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); - static boost::shared_ptr create (boost::shared_ptr, const SourceList&, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); - static boost::shared_ptr create (boost::shared_ptr, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); - static boost::shared_ptr create (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); + /** create a "pure copy" of Region @param other */ + static boost::shared_ptr create (boost::shared_ptr other); + + /** create a region from a single Source */ + static boost::shared_ptr create (boost::shared_ptr, + const PBD::PropertyList&, bool announce = true); + /** create a region from a multiple sources */ + static boost::shared_ptr create (const SourceList &, + const PBD::PropertyList&, bool announce = true); + /** create a copy of @other starting at zero within @param other's sources */ + static boost::shared_ptr create (boost::shared_ptr other, + const PBD::PropertyList&, bool announce = true); + /** create a copy of @other starting at @param offset within @param other */ + static boost::shared_ptr create (boost::shared_ptr, frameoffset_t offset, + const PBD::PropertyList&, bool announce = true); + /** create a "copy" of @param other but using a different set of sources @param srcs */ + static boost::shared_ptr create (boost::shared_ptr other, const SourceList& srcs, + const PBD::PropertyList&, bool announce = true); + + /** create a region with no sources, using XML state */ static boost::shared_ptr create (Session&, XMLNode&, bool); - static boost::shared_ptr create (SourceList &, const XMLNode&); + /** create a region with specified sources @param srcs and XML state */ + static boost::shared_ptr create (SourceList& srcs, const XMLNode&); private: static std::map > region_map; diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index 48b5cb52db..820295b54a 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -24,46 +24,52 @@ #include #include #include -#include "pbd/signals.h" +#include "pbd/signals.h" #include "pbd/stateful.h" #include "pbd/signals.h" #include "ardour/types.h" +#include "ardour/session_object.h" namespace ARDOUR { +namespace Properties { + extern PBD::PropertyDescriptor relative; + extern PBD::PropertyDescriptor active; + extern PBD::PropertyDescriptor gain; + extern PBD::PropertyDescriptor mute; + extern PBD::PropertyDescriptor solo; + extern PBD::PropertyDescriptor recenable; + extern PBD::PropertyDescriptor select; + extern PBD::PropertyDescriptor edit; + /* we use this, but its declared in region.cc */ + extern PBD::PropertyDescriptor hidden; +}; + class Route; class Track; class AudioTrack; class Session; -class RouteGroup : public PBD::Stateful, public PBD::ScopedConnectionList { -public: - enum Flag { - Relative = 0x1, - Active = 0x2, - Hidden = 0x4 - }; - - enum Property { - Gain = 0x1, - Mute = 0x2, - Solo = 0x4, - RecEnable = 0x8, - Select = 0x10, - Edit = 0x20 - }; - - RouteGroup (Session& s, const std::string &n, Flag f = Flag(0), Property p = Property(0)); +class RouteGroup : public SessionObject +{ + public: + static void make_property_quarks(); + + RouteGroup (Session& s, const std::string &n); ~RouteGroup (); - const std::string& name() { return _name; } - void set_name (std::string str); + bool is_active () const { return _active.val(); } + bool is_relative () const { return _relative.val(); } + bool is_hidden () const { return _hidden.val(); } + bool is_gain () const { return _gain.val(); } + bool is_mute () const { return _mute.val(); } + bool is_solo () const { return _solo.val(); } + bool is_recenable () const { return _recenable.val(); } + bool is_select () const { return _select.val(); } + bool is_edit () const { return _edit.val(); } - bool is_active () const { return _flags & Active; } - bool is_relative () const { return _flags & Relative; } - bool is_hidden () const { return _flags & Hidden; } bool empty() const {return routes->empty();} size_t size() const { return routes->size();} @@ -74,20 +80,14 @@ public: void set_relative (bool yn, void *src); void set_hidden (bool yn, void *src); - bool property (Property p) const { - return ((_properties & p) == p); - } - - bool active_property (Property p) const { - return is_active() && property (p); - } + void set_gain (bool yn); + void set_mute (bool yn); + void set_solo (bool yn); + void set_recenable (bool yn); + void set_select (bool yn); + void set_edit (bool yn); - void set_property (Property p, bool v) { - _properties = (Property) (_properties & ~p); - if (v) { - _properties = (Property) (_properties | p); - } - } + bool enabled_property (PBD::PropertyID); int add (boost::shared_ptr); int remove (boost::shared_ptr); @@ -131,17 +131,26 @@ public: PBD::Signal0 changed; PBD::Signal1 FlagsChanged; + static PBD::PropertyChange FlagsChange; + static PBD::PropertyChange PropertiesChange; + XMLNode& get_state (); int set_state (const XMLNode&, int version); private: - Session& _session; boost::shared_ptr routes; boost::shared_ptr subgroup_bus; - std::string _name; - Flag _flags; - Property _properties; + + PBD::Property _relative; + PBD::Property _active; + PBD::Property _hidden; + PBD::Property _gain; + PBD::Property _mute; + PBD::Property _solo; + PBD::Property _recenable; + PBD::Property _select; + PBD::Property _edit; void remove_when_going_away (boost::weak_ptr); int set_state_2X (const XMLNode&, int); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 06d5337b86..154c5d0078 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1210,7 +1210,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void xrun_recovery (); TempoMap *_tempo_map; - void tempo_map_changed (PBD::Change); + void tempo_map_changed (PBD::PropertyChange); /* edit/mix groups */ @@ -1257,7 +1257,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi RegionList regions; void add_region (boost::shared_ptr); - void region_changed (PBD::Change, boost::weak_ptr); + void region_changed (PBD::PropertyChange, boost::weak_ptr); void remove_region (boost::weak_ptr); int load_regions (const XMLNode& node); diff --git a/libs/ardour/ardour/session_object.h b/libs/ardour/ardour/session_object.h index 069badcb6a..1f81cf6fd2 100644 --- a/libs/ardour/ardour/session_object.h +++ b/libs/ardour/ardour/session_object.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2000-2010 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 @@ -24,12 +24,17 @@ #include "pbd/statefuldestructible.h" #include "pbd/signals.h" +#include "ardour/ardour.h" #include "ardour/session_handle.h" #include "i18n.h" namespace ARDOUR { +namespace Properties { + extern PBD::PropertyDescriptor name; +} + class Session; /** A named object associated with a Session. Objects derived from this class are @@ -39,16 +44,20 @@ class Session; class SessionObject : public SessionHandleRef, public PBD::StatefulDestructible { public: + static void make_property_quarks (); + SessionObject (Session& session, const std::string& name) : SessionHandleRef (session) - , _name (X_("name"), PBD::Change (0), name) + , _name (Properties::name, PBD::PropertyChange (0), name) { - add_state (_name); + add_property (_name); } Session& session() const { return _session; } std::string name() const { return _name; } + PBD::PropertyChange set_property (const PBD::PropertyBase& prop); + virtual bool set_name (const std::string& str) { if (_name != str) { _name = str; @@ -60,7 +69,7 @@ class SessionObject : public SessionHandleRef, public PBD::StatefulDestructible PBD::Signal0 NameChanged; protected: - PBD::State _name; + PBD::Property _name; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index ec7f1c4d0b..9b20f6f1b0 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -39,7 +39,7 @@ public: protected: friend class SourceFactory; - SilentFileSource (Session& s, const XMLNode& x, nframes_t len, float srate) + SilentFileSource (Session& s, const XMLNode& x, framecnt_t len, float srate) : Source (s, x) , AudioFileSource (s, x, false) , _sample_rate(srate) @@ -47,17 +47,17 @@ protected: _length = len; } - nframes_t read_unlocked (Sample *dst, sframes_t /*start*/, nframes_t cnt) const { + framecnt_t read_unlocked (Sample *dst, framepos_t /*start*/, framecnt_t cnt) const { memset (dst, 0, sizeof (Sample) * cnt); return cnt; } - nframes_t write_unlocked (Sample */*dst*/, nframes_t /*cnt*/) { return 0; } - + framecnt_t write_unlocked (Sample */*dst*/, framecnt_t /*cnt*/) { return 0; } + void set_header_timeline_position () {} - int read_peaks_with_fpp (PeakData *peaks, nframes_t npeaks, sframes_t /*start*/, nframes_t /*cnt*/, - double /*samples_per_unit*/, nframes_t /*fpp*/) const { + int read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t /*start*/, framecnt_t /*cnt*/, + double /*samples_per_unit*/, framecnt_t /*fpp*/) const { memset (peaks, 0, sizeof (PeakData) * npeaks); return 0; } diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index 95829769f6..19dcb13536 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -65,10 +65,9 @@ class SndFileSource : public AudioFileSource { protected: void set_header_timeline_position (); - nframes_t read_unlocked (Sample *dst, sframes_t start, nframes_t cnt) const; - nframes_t write_unlocked (Sample *dst, nframes_t cnt); - - nframes_t write_float (Sample* data, sframes_t pos, nframes_t cnt); + framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const; + framecnt_t write_unlocked (Sample *dst, framecnt_t cnt); + framecnt_t write_float (Sample* data, framepos_t pos, framecnt_t cnt); private: SNDFILE *sf; @@ -77,26 +76,26 @@ class SndFileSource : public AudioFileSource { void init_sndfile (); int open(); - int setup_broadcast_info (sframes_t when, struct tm&, time_t); + int setup_broadcast_info (framepos_t when, struct tm&, time_t); /* destructive */ - static nframes_t xfade_frames; + static framecnt_t xfade_frames; static gain_t* out_coefficient; static gain_t* in_coefficient; bool _capture_start; bool _capture_end; - sframes_t capture_start_frame; - sframes_t file_pos; // unit is frames - nframes_t xfade_out_count; - nframes_t xfade_in_count; + framepos_t capture_start_frame; + framepos_t file_pos; // unit is frames + framecnt_t xfade_out_count; + framecnt_t xfade_in_count; Sample* xfade_buf; - - nframes_t crossfade (Sample* data, nframes_t cnt, int dir); - void set_timeline_position (int64_t); - nframes_t destructive_write_unlocked (Sample *dst, nframes_t cnt); - nframes_t nondestructive_write_unlocked (Sample *dst, nframes_t cnt); + + framecnt_t crossfade (Sample* data, framecnt_t cnt, int dir); + void set_timeline_position (framepos_t); + framecnt_t destructive_write_unlocked (Sample *dst, framecnt_t cnt); + framecnt_t nondestructive_write_unlocked (Sample *dst, framecnt_t cnt); void handle_header_position_change (); PBD::ScopedConnection header_position_connection; }; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index b91d8f129c..83366bbb78 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -59,12 +59,12 @@ class Source : public SessionObject time_t timestamp() const { return _timestamp; } void stamp (time_t when) { _timestamp = when; } - virtual sframes_t length (sframes_t pos) const = 0; - virtual void update_length (sframes_t pos, sframes_t cnt) = 0; + virtual framecnt_t length (framepos_t pos) const = 0; + virtual void update_length (framepos_t pos, framecnt_t cnt) = 0; virtual const Glib::ustring& path() const = 0; - virtual nframes64_t natural_position() const { return 0; } + virtual framepos_t natural_position() const { return 0; } void mark_for_remove(); diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index d85247bec4..5c2d3d6918 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -258,7 +258,7 @@ class TempoMap : public PBD::StatefulDestructible nframes_t frame_rate () const { return _frame_rate; } - PBD::Signal1 StateChanged; + PBD::Signal1 StateChanged; private: static Tempo _default_tempo; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index e8a8120591..4380662540 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -63,6 +63,11 @@ namespace ARDOUR { * don't want to pay for extremely long session times they don't need... */ typedef int64_t sframes_t; + typedef int64_t framepos_t; + /* any offset from a framepos_t, measured in audio frames */ + typedef int64_t frameoffset_t; + /* any count of audio frames */ + typedef int64_t framecnt_t; enum IOChange { NoChange = 0, -- cgit v1.2.3