summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-11-08 15:40:54 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-11-08 15:40:54 +0000
commit5932ec19c4c2b00edcfc6068c637b39c007c904f (patch)
tree54c94cd6137c51735bd5238fb68450fe9ba81355
parentd0176c23e384a2bb963dcc75a8300caf2852d3d7 (diff)
add operator=() to Curve; add AudioRegion::copy_settings() for replicating region settings after generating a new region via an AudioFilter; add new ReadOps* for reading an audioregion with and without various "internal processing" applied (fades, scaling, automation); add new "Discovering Plugins" boot time message
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4109 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/audioregion.h13
-rw-r--r--libs/ardour/ardour/curve.h1
-rw-r--r--libs/ardour/audiofilter.cc13
-rw-r--r--libs/ardour/audioregion.cc104
-rw-r--r--libs/ardour/automation_event.cc5
-rw-r--r--libs/ardour/curve.cc11
-rw-r--r--libs/ardour/plugin_manager.cc2
-rw-r--r--libs/ardour/reverse.cc4
8 files changed, 102 insertions, 51 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 614211ffeb..4d4d8eecd8 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -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);
diff --git a/libs/ardour/ardour/curve.h b/libs/ardour/ardour/curve.h
index 5b725f4720..affcc41e8b 100644
--- a/libs/ardour/ardour/curve.h
+++ b/libs/ardour/ardour/curve.h
@@ -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);
diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc
index 102e2024e0..04eea471ec 100644
--- a/libs/ardour/audiofilter.cc
+++ b/libs/ardour/audiofilter.cc
@@ -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;
}
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index ecb2f9b4b3..4dd42214f3 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -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;
}
diff --git a/libs/ardour/automation_event.cc b/libs/ardour/automation_event.cc
index 2815d4be50..3e257d2b7a 100644
--- a/libs/ardour/automation_event.cc
+++ b/libs/ardour/automation_event.cc
@@ -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 ();
}
diff --git a/libs/ardour/curve.cc b/libs/ardour/curve.cc
index c576c55d45..f2ab337cb8 100644
--- a/libs/ardour/curve.cc
+++ b/libs/ardour/curve.cc
@@ -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 ()
{
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc
index d45040f5de..1e4adeba6e 100644
--- a/libs/ardour/plugin_manager.cc
+++ b/libs/ardour/plugin_manager.cc
@@ -126,6 +126,8 @@ PluginManager::PluginManager ()
_lv2_world = new LV2World();
#endif
+ BootMessage (_("Discovering Plugins"));
+
refresh ();
}
diff --git a/libs/ardour/reverse.cc b/libs/ardour/reverse.cc
index fc58e161aa..2e78f25c22 100644
--- a/libs/ardour/reverse.cc
+++ b/libs/ardour/reverse.cc
@@ -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;
}