add operator=() to Curve; add AudioRegion::copy_settings() for replicating region...
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 8 Nov 2008 15:40:54 +0000 (15:40 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 8 Nov 2008 15:40:54 +0000 (15:40 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4109 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audioregion.h
libs/ardour/ardour/curve.h
libs/ardour/audiofilter.cc
libs/ardour/audioregion.cc
libs/ardour/automation_event.cc
libs/ardour/curve.cc
libs/ardour/plugin_manager.cc
libs/ardour/reverse.cc

index 614211ffebbb5a8bba6acde341f17b77328a884a..4d4d8eecd8479ccd6a6805597bf92dc844b1fcac 100644 (file)
@@ -55,6 +55,8 @@ class AudioRegion : public Region
 
        ~AudioRegion();
 
+       void copy_settings (boost::shared_ptr<const AudioRegion>);
+
        bool source_equivalent (boost::shared_ptr<const Region>) const;
 
        bool speed_mismatch (float) const;
@@ -86,8 +88,17 @@ class AudioRegion : public Region
                        uint32_t chan_n=0, double samples_per_unit= 1.0) const;
 
        /* Readable interface */
+
+       enum ReadOps {
+               ReadOpsNone = 0x0,
+               ReadOpsOwnAutomation = 0x1,
+               ReadOpsOwnScaling = 0x2,
+               ReadOpsCount = 0x4,
+               ReadOpsFades = 0x8
+       };
        
        virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const;
+       virtual nframes64_t read_with_ops (Sample*, nframes64_t pos, nframes64_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,
@@ -176,7 +187,7 @@ class AudioRegion : public Region
                            uint32_t chan_n = 0,
                            nframes_t read_frames = 0,
                            nframes_t skip_frames = 0,
-                           bool raw = false) const;
+                           ReadOps readops = ReadOps (~0)) const;
 
        bool verify_start (nframes_t position);
        bool verify_length (nframes_t& length);
index 5b725f47208f73f51f6478a3a0fa974237926088..affcc41e8be2c0d45daac561ffba1e829231b0b2 100644 (file)
@@ -51,6 +51,7 @@ class Curve : public AutomationList
        Curve (const Curve& other);
        Curve (const Curve& other, double start, double end);
        Curve (const XMLNode&);
+       Curve& operator= (const Curve& other);
 
        bool rt_safe_get_vector (double x0, double x1, float *arg, int64_t veclen);
        void get_vector (double x0, double x1, float *arg, int64_t veclen);
index 102e2024e03ed52492d99e7116b06602fefc8d32..04eea471ec9eee108912f7e938da26d92d030bea 100644 (file)
@@ -118,9 +118,18 @@ AudioFilter::finish (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs, s
        if (region_name.empty()) {
                region_name = session.new_region_name (region->name());
        }
+
        results.clear ();
-       results.push_back (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (nsrcs, 0, nsrcs.front()->length(), region_name, 0, 
-                                                                                           Region::Flag (Region::WholeFile|Region::DefaultFlags))));
+
+       boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (
+               RegionFactory::create (nsrcs, 0, nsrcs.front()->length(), region_name, 0, 
+                                      Region::Flag (Region::WholeFile|Region::DefaultFlags)));
+
+       /* reset relevant stuff */
+
+       ar->copy_settings (region);
+
+       results.push_back (ar);
        
        return 0;
 }
index ecb2f9b4b349c36243efd51749d418064abfb0a4..4dd42214f3ce16810949a59912fe85ab408d2156 100644 (file)
@@ -212,7 +212,8 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
        : Region (other),
          _fade_in (other->_fade_in),
          _fade_out (other->_fade_out),
-         _envelope (other->_envelope) 
+         _envelope (other->_envelope)
+         
 {
        /* Pure copy constructor */
 
@@ -240,12 +241,9 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other)
                }
        }
 
-       _scale_amplitude = other->_scale_amplitude;
-       _envelope = other->_envelope;
-
        _fade_in_disabled = 0;
        _fade_out_disabled = 0;
-       
+
        listen_to_my_curves ();
        listen_to_my_sources ();
 }
@@ -349,6 +347,22 @@ AudioRegion::listen_to_my_curves ()
        _fade_out.StateChanged.connect (mem_fun (*this, &AudioRegion::fade_out_changed));
 }
 
+void
+AudioRegion::copy_settings (boost::shared_ptr<const AudioRegion> other)
+{
+       _fade_in = other->_fade_in;
+       _fade_out = other->_fade_out;
+       _envelope = other->_envelope; 
+       _flags = other->_flags;
+       _scale_amplitude = other->_scale_amplitude;
+       _fade_in_disabled = other->_fade_in_disabled;
+       _fade_out_disabled = other->_fade_out_disabled;
+
+       if (_length != other->length()) {
+               _envelope.extend_to (_length);
+       }
+}
+
 bool
 AudioRegion::verify_length (nframes_t& len)
 {
@@ -388,6 +402,7 @@ AudioRegion::verify_start_and_length (nframes_t new_start, nframes_t& new_length
 
        return true;
 }
+
 bool
 AudioRegion::verify_start (nframes_t pos)
 {
@@ -461,7 +476,13 @@ nframes64_t
 AudioRegion::read (Sample* buf, nframes64_t position, nframes64_t cnt, int channel) const
 {
        /* raw read, no fades, no gain, nada */
-       return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, true);
+       return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, ReadOps (0));
+}
+
+nframes64_t
+AudioRegion::read_with_ops (Sample* buf, nframes64_t position, nframes64_t cnt, int channel, ReadOps rops) const
+{
+       return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, rops);
 }
 
 nframes_t
@@ -470,7 +491,7 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, n
                      uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
 {
        /* regular diskstream/butler read complete with fades etc */
-       return _read_at (sources, _length, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames, false);
+       return _read_at (sources, _length, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
 }
 
 nframes_t
@@ -487,11 +508,12 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
                       uint32_t chan_n, 
                       nframes_t read_frames, 
                       nframes_t skip_frames,
-                      bool raw) const
+                      ReadOps rops) const
 {
        nframes_t internal_offset;
        nframes_t buf_offset;
        nframes_t to_read;
+       bool raw = (rops == ReadOpsNone);
 
        if (muted() && !raw) {
                return 0; /* read nothing */
@@ -523,7 +545,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
                mixdown_buffer += buf_offset;
        }
 
-       if (!raw) {
+       if (rops & ReadOpsCount) {
                _read_data_count = 0;
        }
 
@@ -533,7 +555,7 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
                        return 0; /* "read nothing" */
                }
                
-               if (!raw) {
+               if (rops & ReadOpsCount) {
                        _read_data_count += srcs[chan_n]->read_data_count();
                }
 
@@ -544,18 +566,12 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
                */
 
                memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
-
-               /* no fades required */
-
-               if (!raw) {
-                       goto merge;
-               }
        }
 
-       /* fade in */
-
-       if (!raw) {
+       if (rops & ReadOpsFades) {
        
+               /* fade in */
+
                if ((_flags & FadeIn) && Config->get_use_region_fades()) {
                        
                        nframes_t fade_in_length = (nframes_t) _fade_in.back()->when;
@@ -618,39 +634,37 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
                        } 
                        
                }
+       }
                
-               /* Regular gain curves */
+        /* Regular gain curves and scaling */
+       
+       if ((rops & ReadOpsOwnAutomation) && envelope_active())  {
+               _envelope.get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
                
-               if (envelope_active())  {
-                       _envelope.get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
-                       
-                       if (_scale_amplitude != 1.0f) {
-                               for (nframes_t n = 0; n < to_read; ++n) {
-                                       mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
-                               }
-                       } else {
-                               for (nframes_t n = 0; n < to_read; ++n) {
-                                       mixdown_buffer[n] *= gain_buffer[n];
-                               }
+               if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
+                       for (nframes_t n = 0; n < to_read; ++n) {
+                               mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
+                       }
+               } else {
+                       for (nframes_t n = 0; n < to_read; ++n) {
+                               mixdown_buffer[n] *= gain_buffer[n];
                        }
-               } else if (_scale_amplitude != 1.0f) {
-                       Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
                }
+       } else if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
+               Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
+       }
        
-         merge:
+       if (!opaque()) {
                
-               if (!opaque()) {
-                       
-                       /* gack. the things we do for users.
-                        */
-                       
-                       buf += buf_offset;
+               /* gack. the things we do for users.
+                */
+               
+               buf += buf_offset;
                        
-                       for (nframes_t n = 0; n < to_read; ++n) {
-                               buf[n] += mixdown_buffer[n];
-                       }
-               } 
-       }
+               for (nframes_t n = 0; n < to_read; ++n) {
+                       buf[n] += mixdown_buffer[n];
+               }
+       } 
 
        return to_read;
 }
index 2815d4be503ecda8ab94309f2bc92372b5dc8735..3e257d2b7a6766d5f4a56f2418555669eefc3593 100644 (file)
@@ -185,7 +185,10 @@ AutomationList::operator= (const AutomationList& other)
                max_yval = other.max_yval;
                max_xval = other.max_xval;
                default_value = other.default_value;
-               
+
+               rt_insertion_point = events.end();
+               lookup_cache.range.first = events.end();
+       
                mark_dirty ();
                maybe_signal_changed ();
        }
index c576c55d453b3235fc958e82718cfd1bc4801080..f2ab337cb8e3d079d5cd72e93a79e351b1d4c008 100644 (file)
@@ -69,6 +69,17 @@ Curve::~Curve ()
 {
 }
 
+Curve&
+Curve::operator= (const Curve& other)
+{
+       if (this != &other) {
+               *((AutomationList*)this) = other;
+               min_yval = other.min_yval;
+               max_yval = other.max_yval;
+       }
+       return *this;
+}
+
 void
 Curve::solve ()
 {
index d45040f5deadbb4ce558417fc251655c0682a209..1e4adeba6e570c224115e74ab323148c9242d8b8 100644 (file)
@@ -126,6 +126,8 @@ PluginManager::PluginManager ()
        _lv2_world = new LV2World();
 #endif
 
+       BootMessage (_("Discovering Plugins"));
+
        refresh ();
 }
 
index fc58e161aa0d5fccf315d6ba770065568015a8ce..2e78f25c22eaaa3808d56e6dca5c4ea77a0e01a9 100644 (file)
@@ -77,9 +77,9 @@ Reverse::run (boost::shared_ptr<AudioRegion> region)
 
                for (n = 0, si = nsrcs.begin(); n < region->n_channels(); ++n, ++si) {
 
-                       /* read it in */
+                       /* read it in, with any amplitude scaling */
                        
-                       if (region->source (n)->read (buf, fpos, to_read) != to_read) {
+                       if (region->read (buf, fpos, to_read, n) != to_read) {
                                goto out;
                        }