diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 8c24f42998..d0e6b9ad76 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -1818,18 +1818,12 @@ AudioClock::build_ops_menu () ops_menu = new Menu; MenuList& ops_items = ops_menu->items(); ops_menu->set_name ("ArdourContextMenu"); - - Menu *mode_menu = manage (new Menu); - MenuList& mode_items = mode_menu->items(); - mode_menu->set_name ("ArdourContextMenu"); - mode_items.push_back (MenuElem (_("Timecode"), bind (mem_fun(*this, &AudioClock::set_mode), SMPTE))); - mode_items.push_back (MenuElem (_("Bars:Beats"), bind (mem_fun(*this, &AudioClock::set_mode), BBT))); - mode_items.push_back (MenuElem (_("Minutes:Seconds"), bind (mem_fun(*this, &AudioClock::set_mode), MinSec))); - mode_items.push_back (MenuElem (_("Audio Frames"), bind (mem_fun(*this, &AudioClock::set_mode), Frames))); - mode_items.push_back (MenuElem (_("Off"), bind (mem_fun(*this, &AudioClock::set_mode), Off))); - - ops_items.push_back (MenuElem (_("Mode"), *mode_menu)); + ops_items.push_back (MenuElem (_("Timecode"), bind (mem_fun(*this, &AudioClock::set_mode), SMPTE))); + ops_items.push_back (MenuElem (_("Bars:Beats"), bind (mem_fun(*this, &AudioClock::set_mode), BBT))); + ops_items.push_back (MenuElem (_("Minutes:Seconds"), bind (mem_fun(*this, &AudioClock::set_mode), MinSec))); + ops_items.push_back (MenuElem (_("Audio Frames"), bind (mem_fun(*this, &AudioClock::set_mode), Frames))); + ops_items.push_back (MenuElem (_("Off"), bind (mem_fun(*this, &AudioClock::set_mode), Off))); } void diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 4ca3ad38b9..09510e8d42 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -348,9 +348,11 @@ AudioStreamView::add_crossfade (boost::shared_ptr crossfade) } void -AudioStreamView::remove_crossfade (boost::shared_ptr xfade) +AudioStreamView::remove_crossfade (boost::shared_ptr r) { - ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), xfade)); + ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::remove_crossfade), r)); + + boost::shared_ptr xfade = boost::dynamic_pointer_cast (r); for (list::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { if ((*i)->crossfade == xfade) { diff --git a/gtk2_ardour/audio_streamview.h b/gtk2_ardour/audio_streamview.h index fc707e97e7..0f51889ca2 100644 --- a/gtk2_ardour/audio_streamview.h +++ b/gtk2_ardour/audio_streamview.h @@ -95,7 +95,7 @@ class AudioStreamView : public StreamView void add_crossfade (boost::shared_ptr); void add_crossfade_weak (boost::weak_ptr); - void remove_crossfade (boost::shared_ptr); + void remove_crossfade (boost::shared_ptr); void color_handler (ColorID id, uint32_t val); diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc index 26d61035ba..ae63f8c6fa 100644 --- a/gtk2_ardour/crossfade_edit.cc +++ b/gtk2_ardour/crossfade_edit.cc @@ -882,6 +882,15 @@ CrossfadeEditor::build_presets () p->push_back (PresetPoint (1, 1)); fade_in_presets->push_back (p); + p = new Preset ("crossfade_in_default"); + p->push_back (PresetPoint (0, 0)); + p->push_back (PresetPoint (0.1, 0.01)); + p->push_back (PresetPoint (0.2, 0.03)); + p->push_back (PresetPoint (0.8, 0.97)); + p->push_back (PresetPoint (0.9, 0.99)); + p->push_back (PresetPoint (1, 1)); + fade_in_presets->push_back (p); + /* FADE OUT */ // p = new Preset ("hiout.xpm"); @@ -932,6 +941,15 @@ CrossfadeEditor::build_presets () p->push_back (PresetPoint (0, 1)); p->push_back (PresetPoint (1, 0)); fade_out_presets->push_back (p); + + p = new Preset ("crossfade_out_default"); + p->push_back (PresetPoint (0, 1)); + p->push_back (PresetPoint (0.1, 0.99)); + p->push_back (PresetPoint (0.2, 0.97)); + p->push_back (PresetPoint (0.8, 0.03)); + p->push_back (PresetPoint (0.9, 0.01)); + p->push_back (PresetPoint (1, 0)); + fade_out_presets->push_back (p); } void diff --git a/gtk2_ardour/icons/crossfade_in_default.svg b/gtk2_ardour/icons/crossfade_in_default.svg new file mode 100644 index 0000000000..35e4080aeb --- /dev/null +++ b/gtk2_ardour/icons/crossfade_in_default.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtk2_ardour/icons/crossfade_out_default.svg b/gtk2_ardour/icons/crossfade_out_default.svg new file mode 100644 index 0000000000..d2852eee50 --- /dev/null +++ b/gtk2_ardour/icons/crossfade_out_default.svg @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index 39f41d5d1c..4acbc9ad51 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -75,7 +75,7 @@ class AudioPlaylist : public ARDOUR::Playlist Crossfades _crossfades; Crossfades _pending_xfade_adds; - void crossfade_invalidated (boost::shared_ptr); + void crossfade_invalidated (boost::shared_ptr); XMLNode& state (bool full_state); void dump () const; diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index ccc0d82f2a..f844d45ef1 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -77,14 +77,14 @@ class AudioRegion : public Region virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, nframes_t position, nframes_t cnt, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; + uint32_t chan_n = 0) const; virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf, nframes_t position, nframes_t cnt, uint32_t chan_n=0) const; + virtual nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const; + XMLNode& state (bool); int set_state (const XMLNode&); @@ -137,11 +137,11 @@ class AudioRegion : public Region AudioRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); AudioRegion (SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); AudioRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); - AudioRegion (boost::shared_ptr); AudioRegion (boost::shared_ptr, const XMLNode&); AudioRegion (SourceList &, const XMLNode&); private: + void init (); void set_default_fades (); void set_default_fade_in (); void set_default_fade_out (); @@ -150,10 +150,8 @@ class AudioRegion : public Region void recompute_gain_at_start (); nframes_t _read_at (const SourceList&, Sample *buf, Sample *mixdown_buffer, - float *gain_buffer, nframes_t position, nframes_t cnt, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; + float *gain_buffer, nframes_t position, nframes_t cnt, + uint32_t chan_n = 0) const; void recompute_at_start (); void recompute_at_end (); @@ -174,6 +172,11 @@ class AudioRegion : public Region uint32_t _fade_out_disabled; protected: + /* default constructor for derived (compound) types */ + + AudioRegion (nframes_t, nframes_t, std::string name); + AudioRegion (boost::shared_ptr); + int set_live_state (const XMLNode&, Change&, bool send); virtual bool verify_start (nframes_t); @@ -182,8 +185,6 @@ class AudioRegion : public Region virtual bool verify_length (nframes_t); /*virtual void recompute_at_start () = 0; virtual void recompute_at_end () = 0;*/ - - virtual nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const; }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/automation_event.h b/libs/ardour/ardour/automation_event.h index 007bad7259..5a9792c11d 100644 --- a/libs/ardour/ardour/automation_event.h +++ b/libs/ardour/ardour/automation_event.h @@ -199,7 +199,7 @@ class AutomationList : public PBD::StatefulDestructible std::pair range; }; - LookupCache lookup_cache; + mutable LookupCache lookup_cache; AutoState _state; AutoStyle _style; diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index 7346e645fb..61a30f1c0f 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -23,7 +23,6 @@ #include #include #include -#include #include @@ -40,7 +39,7 @@ namespace ARDOUR { class AudioRegion; class Playlist; -class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_from_this +class Crossfade : public ARDOUR::AudioRegion { public: @@ -66,7 +65,7 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ /* copy constructor to copy a crossfade with new regions. used (for example) when a playlist copy is made */ - Crossfade (const Crossfade &, boost::shared_ptr, boost::shared_ptr); + Crossfade (boost::shared_ptr, boost::shared_ptr, boost::shared_ptr); /* the usual XML constructor */ @@ -82,10 +81,8 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ boost::shared_ptr out() const { return _out; } nframes_t read_at (Sample *buf, Sample *mixdown_buffer, - float *gain_buffer, nframes_t position, nframes_t cnt, - uint32_t chan_n, - nframes_t read_frames = 0, - nframes_t skip_frames = 0); + float *gain_buffer, nframes_t position, nframes_t cnt, + uint32_t chan_n) const; bool refresh (); @@ -105,13 +102,11 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ return (_in == a && _out == b) || (_in == b && _out == a); } - nframes_t length() const { return _length; } nframes_t overlap_length() const; - nframes_t position() const { return _position; } void invalidate(); - sigc::signal > Invalidated; + sigc::signal > Invalidated; sigc::signal StateChanged; bool covers (nframes_t frame) const { @@ -133,6 +128,11 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ Curve& fade_out() { return _fade_out; } nframes_t set_length (nframes_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); @@ -151,14 +151,14 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ bool _active; bool _in_update; OverlapType overlap_type; - nframes_t _length; - nframes_t _position; AnchorPoint _anchor_point; bool _follow_overlap; bool _fixed; int32_t layer_relation; - Curve _fade_in; - Curve _fade_out; + + + mutable Curve _fade_in; + mutable Curve _fade_out; static Sample* crossfade_buffer_out; static Sample* crossfade_buffer_in; @@ -166,6 +166,9 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_ void initialize (); int compute (boost::shared_ptr, boost::shared_ptr, CrossfadeModel); bool update (); + + protected: + nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const; }; diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 200599541e..2b783a92a8 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -51,11 +51,9 @@ class MidiRegion : public Region boost::shared_ptr midi_source (uint32_t n=0) const; nframes_t read_at (MidiRingBuffer& dst, - nframes_t position, - nframes_t dur, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; + nframes_t position, + nframes_t dur, + uint32_t chan_n = 0) const; nframes_t master_read_at (MidiRingBuffer& dst, nframes_t position, @@ -85,11 +83,9 @@ class MidiRegion : public Region private: nframes_t _read_at (const SourceList&, MidiRingBuffer& dst, - nframes_t position, - nframes_t dur, - uint32_t chan_n = 0, - nframes_t read_frames = 0, - nframes_t skip_frames = 0) const; + nframes_t position, + nframes_t dur, + uint32_t chan_n = 0) const; void recompute_at_start (); void recompute_at_end (); diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 64d4ee1d83..c3aac3dfa8 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -177,7 +177,9 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro uint32_t n_channels() const { return _sources.size(); } std::vector master_source_names(); - + + const SourceList& sources() const { return _sources; } + const SourceList& master_sources() const { return _master_sources; } /* serialization */ @@ -191,6 +193,9 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro uint64_t last_layer_op() const { return _last_layer_op; } void set_last_layer_op (uint64_t when); + virtual bool is_dependent() const { return false; } + virtual bool depends_on (boost::shared_ptr other) const { return false; } + protected: friend class RegionFactory; @@ -204,6 +209,10 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro Region (boost::shared_ptr src, const XMLNode&); Region (SourceList& srcs, const XMLNode&); + /* this one is for derived types of derived types */ + + Region (nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags); + protected: XMLNode& get_short_state (); /* used only by Session */ @@ -221,9 +230,7 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro virtual bool verify_length (nframes_t); virtual void recompute_at_start () = 0; virtual void recompute_at_end () = 0; - - PBD::ID _id; string _name; DataType _type; Flag _flags; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 929101fe6d..246384689e 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -79,7 +79,7 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr other, stri if ((*xfades)->out() == ar2) { boost::shared_ptrin = boost::dynamic_pointer_cast(*in_n); boost::shared_ptrout = boost::dynamic_pointer_cast(*out_n); - boost::shared_ptr new_fade = boost::shared_ptr (new Crossfade (*(*xfades), in, out)); + boost::shared_ptr new_fade = boost::shared_ptr (new Crossfade (*xfades, in, out)); add_crossfade(new_fade); break; } @@ -125,8 +125,6 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf { nframes_t ret = cnt; nframes_t end; - nframes_t read_frames; - nframes_t skip_frames; /* optimizing this memset() away involves a lot of conditionals that may well cause more of a hit due to cache misses @@ -151,8 +149,6 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf end = start + cnt - 1; - read_frames = 0; - skip_frames = 0; _read_data_count = 0; map > > relevant_regions; @@ -191,7 +187,7 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf for (vector >::iterator i = r.begin(); i != r.end(); ++i) { boost::shared_ptr ar = boost::dynamic_pointer_cast(*i); assert(ar); - ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n, read_frames, skip_frames); + ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n); _read_data_count += ar->read_data_count(); } @@ -309,19 +305,19 @@ AudioPlaylist::finalize_split_region (boost::shared_ptr o, boost::shared if ((*x)->_in == orig) { if (! (*x)->covers(right->position())) { - fade = boost::shared_ptr (new Crossfade (**x, left, (*x)->_out)); + fade = boost::shared_ptr (new Crossfade (*x, left, (*x)->_out)); } else { // Overlap, the crossfade is copied on the left side of the right region instead - fade = boost::shared_ptr (new Crossfade (**x, right, (*x)->_out)); + fade = boost::shared_ptr (new Crossfade (*x, right, (*x)->_out)); } } if ((*x)->_out == orig) { if (! (*x)->covers(right->position())) { - fade = boost::shared_ptr (new Crossfade (**x, (*x)->_in, right)); + fade = boost::shared_ptr (new Crossfade (*x, (*x)->_in, right)); } else { // Overlap, the crossfade is copied on the right side of the left region instead - fade = boost::shared_ptr (new Crossfade (**x, (*x)->_in, left)); + fade = boost::shared_ptr (new Crossfade (*x, (*x)->_in, left)); } } @@ -478,9 +474,10 @@ void AudioPlaylist::notify_crossfade_added (boost::shared_ptr x) } void -AudioPlaylist::crossfade_invalidated (boost::shared_ptr xfade) +AudioPlaylist::crossfade_invalidated (boost::shared_ptr r) { Crossfades::iterator i; + boost::shared_ptr xfade = boost::dynamic_pointer_cast (r); xfade->in()->resume_fade_in (); xfade->out()->resume_fade_out (); diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 09fe669867..55a1879726 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -59,6 +59,27 @@ Change AudioRegion::EnvelopeActiveChanged = ARDOUR::new_change(); Change AudioRegion::ScaleAmplitudeChanged = ARDOUR::new_change(); Change AudioRegion::EnvelopeChanged = ARDOUR::new_change(); +void +AudioRegion::init () +{ + _scale_amplitude = 1.0; + + set_default_fades (); + set_default_envelope (); + + listen_to_my_curves (); +} + +/* constructor for use by derived types only */ +AudioRegion::AudioRegion (nframes_t start, nframes_t length, string name) + : Region (start, length, name, DataType::AUDIO), + _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) +{ + init (); +} + /** 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)), @@ -71,12 +92,7 @@ AudioRegion::AudioRegion (boost::shared_ptr src, nframes_t start, n afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed)); } - _scale_amplitude = 1.0; - - set_default_fades (); - set_default_envelope (); - - listen_to_my_curves (); + init (); } /* Basic AudioRegion constructor (one channel) */ @@ -91,12 +107,7 @@ AudioRegion::AudioRegion (boost::shared_ptr src, nframes_t start, n afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed)); } - _scale_amplitude = 1.0; - - set_default_fades (); - set_default_envelope (); - - listen_to_my_curves (); + init (); } /* Basic AudioRegion constructor (many channels) */ @@ -106,12 +117,7 @@ AudioRegion::AudioRegion (SourceList& srcs, nframes_t start, nframes_t length, c , _fade_out (0.0, 2.0, 1.0, false) , _envelope (0.0, 2.0, 1.0, false) { - _scale_amplitude = 1.0; - - set_default_fades (); - set_default_envelope (); - - listen_to_my_curves (); + init (); } @@ -308,24 +314,21 @@ AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nfra } ARDOUR::nframes_t -AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position, - nframes_t cnt, - uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const +AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position, nframes_t cnt, uint32_t chan_n) const { - return _read_at (_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames); + return _read_at (_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n); } ARDOUR::nframes_t AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position, nframes_t cnt, uint32_t chan_n) const { - return _read_at (_master_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0); + return _read_at (_master_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n); } ARDOUR::nframes_t AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buffer, float *gain_buffer, - nframes_t position, nframes_t cnt, - uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const + nframes_t position, nframes_t cnt, uint32_t chan_n) const { // cerr << _name << "._read_at(" << position << ") - " << _position << endl; diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index f142d57628..847741832d 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include "i18n.h" #include @@ -76,26 +77,26 @@ Crossfade::Crossfade (boost::shared_ptr in, boost::shared_ptr