summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-02-27 17:42:45 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-02-27 17:42:45 +0000
commitb146d1b51b29922fe1c2a251fe90368b961b9ce9 (patch)
treec5e50bf65be50e7230f5f58bdaa431978cf95947
parentbb753424a4524850a8073192030b37da6ce2c73e (diff)
fixes from chris cannam for rb_effect bugs
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3130 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/audioregion.h3
-rw-r--r--libs/ardour/audioregion.cc2
-rw-r--r--libs/ardour/rb_effect.cc38
3 files changed, 19 insertions, 24 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index b2a6b275fa..614211ffeb 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -69,7 +69,8 @@ class AudioRegion : public Region
uint32_t n_channels() const { return sources.size(); }
vector<string> master_source_names();
- void set_master_sources (SourceList&);
+ void set_master_sources (const SourceList&);
+ const SourceList& get_master_sources() const { return master_sources; }
bool envelope_active () const { return _flags & Region::EnvelopeActive; }
bool fade_in_active () const { return _flags & Region::FadeIn; }
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 3e41b4df2f..b6c1a131de 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -1201,7 +1201,7 @@ AudioRegion::master_source_names ()
}
void
-AudioRegion::set_master_sources (SourceList& srcs)
+AudioRegion::set_master_sources (const SourceList& srcs)
{
master_sources = srcs;
}
diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc
index f86248d44d..35e7b1bb75 100644
--- a/libs/ardour/rb_effect.cc
+++ b/libs/ardour/rb_effect.cc
@@ -74,6 +74,9 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region)
nframes_t pos = 0;
int avail = 0;
+ // note: this_time_fraction is a ratio of original length. 1.0 = no change,
+ // 0.5 is half as long, 2.0 is twice as long, etc.
+
double this_time_fraction = tsr.time_fraction * region->stretch ();
double this_pitch_fraction = tsr.pitch_fraction * region->shift ();
@@ -81,14 +84,14 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region)
(RubberBandStretcher::Options) tsr.opts,
this_time_fraction, this_pitch_fraction);
- stretcher.setExpectedInputDuration(region->length());
- stretcher.setDebugLevel(1);
-
tsr.progress = 0.0f;
tsr.done = false;
uint32_t channels = region->n_channels();
- nframes_t duration = region->length();
+ nframes_t duration = region->ancestral_length();
+
+ stretcher.setExpectedInputDuration(duration);
+ stretcher.setDebugLevel(1);
/* the name doesn't need to be super-precise, but allow for 2 fractional
digits just to disambiguate close but not identical FX
@@ -149,8 +152,8 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region)
if (this_read != this_time) {
error << string_compose
- (_("tempoize: error reading data from %1"),
- nsrcs[i]->name()) << endmsg;
+ (_("tempoize: error reading data from %1 at %2 (wanted %3, got %4)"),
+ region->name(), pos + region->position(), this_time, this_read) << endmsg;
goto out;
}
}
@@ -187,8 +190,8 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region)
if (this_read != this_time) {
error << string_compose
- (_("tempoize: error reading data from %1"),
- nsrcs[i]->name()) << endmsg;
+ (_("tempoize: error reading data from %1 at %2 (wanted %3, got %4)"),
+ region->name(), pos + region->position(), this_time, this_read) << endmsg;
goto out;
}
}
@@ -257,21 +260,12 @@ RBEffect::run (boost::shared_ptr<AudioRegion> region)
/* now reset ancestral data for each new region */
for (vector<boost::shared_ptr<AudioRegion> >::iterator x = results.begin(); x != results.end(); ++x) {
- nframes64_t astart = (*x)->ancestral_start();
- nframes64_t alength = (*x)->ancestral_length();
- nframes_t start;
- nframes_t length;
-
- // note: this_time_fraction is a ratio of original length. 1.0 = no change,
- // 0.5 is half as long, 2.0 is twice as long, etc.
-
- float stretch = (*x)->stretch() * (tsr.time_fraction/100.0);
- float shift = (*x)->shift() * tsr.pitch_fraction;
-
- start = (nframes_t) floor (astart + ((astart - (*x)->start()) / stretch));
- length = (nframes_t) floor (alength / stretch);
- (*x)->set_ancestral_data (start, length, stretch, shift);
+ (*x)->set_ancestral_data (region->ancestral_start(),
+ region->ancestral_length(),
+ this_time_fraction,
+ this_pitch_fraction );
+ (*x)->set_master_sources (region->get_master_sources());
}
out: