13
0

when creating new sources for a non-realtime Filter process, add option to use the same SR as the initial sources

This commit is contained in:
Paul Davis 2015-05-12 10:25:13 -04:00
parent f116455280
commit 4a27a8b531
2 changed files with 18 additions and 5 deletions

View File

@ -43,7 +43,7 @@ class LIBARDOUR_API Filter {
protected:
Filter (ARDOUR::Session& s) : session(s) {}
int make_new_sources (boost::shared_ptr<ARDOUR::Region>, ARDOUR::SourceList&, std::string suffix = "");
int make_new_sources (boost::shared_ptr<ARDOUR::Region>, ARDOUR::SourceList&, std::string suffix = "", bool use_session_sample_rate = true);
int finish (boost::shared_ptr<ARDOUR::Region>, ARDOUR::SourceList&, std::string region_name = "");
ARDOUR::Session& session;

View File

@ -39,7 +39,7 @@ using namespace ARDOUR;
using namespace PBD;
int
Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, string suffix)
Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, std::string suffix, bool use_session_sample_rate)
{
vector<string> names = region->master_source_names();
assert (region->n_channels() <= names.size());
@ -70,9 +70,22 @@ Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, s
}
try {
framecnt_t sample_rate;
if (use_session_sample_rate) {
sample_rate = session.frame_rate();
} else {
boost::shared_ptr<AudioRegion> aregion = boost::dynamic_pointer_cast<AudioRegion>(region);
if (aregion) {
sample_rate = aregion->audio_source()->sample_rate();
} else {
return -1;
}
}
nsrcs.push_back (boost::dynamic_pointer_cast<Source> (
SourceFactory::createWritable (region->data_type(), session,
path, false, session.frame_rate())));
path, false, sample_rate)));
}
catch (failed_constructor& err) {