mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-10 15:36:24 +01:00
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
This commit is contained in:
parent
d0176c23e3
commit
5932ec19c4
8 changed files with 108 additions and 57 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
} else if (_scale_amplitude != 1.0f) {
|
||||
Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
|
||||
}
|
||||
|
||||
merge:
|
||||
|
||||
if (!opaque()) {
|
||||
|
||||
/* gack. the things we do for users.
|
||||
*/
|
||||
|
||||
buf += buf_offset;
|
||||
|
||||
for (nframes_t n = 0; n < to_read; ++n) {
|
||||
buf[n] += mixdown_buffer[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Regular gain curves and scaling */
|
||||
|
||||
if ((rops & ReadOpsOwnAutomation) && envelope_active()) {
|
||||
_envelope.get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
|
||||
|
||||
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 ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
|
||||
Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
|
||||
}
|
||||
|
||||
if (!opaque()) {
|
||||
|
||||
/* gack. the things we do for users.
|
||||
*/
|
||||
|
||||
buf += buf_offset;
|
||||
|
||||
for (nframes_t n = 0; n < to_read; ++n) {
|
||||
buf[n] += mixdown_buffer[n];
|
||||
}
|
||||
}
|
||||
|
||||
return to_read;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ PluginManager::PluginManager ()
|
|||
_lv2_world = new LV2World();
|
||||
#endif
|
||||
|
||||
BootMessage (_("Discovering Plugins"));
|
||||
|
||||
refresh ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue