diff --git a/libs/ardour/ardour/filter.h b/libs/ardour/ardour/filter.h index 2b6476c49f..e80d1fcfd5 100644 --- a/libs/ardour/ardour/filter.h +++ b/libs/ardour/ardour/filter.h @@ -43,7 +43,7 @@ class LIBARDOUR_API Filter { protected: Filter (ARDOUR::Session& s) : session(s) {} - int make_new_sources (boost::shared_ptr, ARDOUR::SourceList&, std::string suffix = ""); + int make_new_sources (boost::shared_ptr, ARDOUR::SourceList&, std::string suffix = "", bool use_session_sample_rate = true); int finish (boost::shared_ptr, ARDOUR::SourceList&, std::string region_name = ""); ARDOUR::Session& session; diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index d782db96f2..382e6d9d86 100644 --- a/libs/ardour/filter.cc +++ b/libs/ardour/filter.cc @@ -39,7 +39,7 @@ using namespace ARDOUR; using namespace PBD; int -Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, string suffix) +Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, std::string suffix, bool use_session_sample_rate) { vector names = region->master_source_names(); assert (region->n_channels() <= names.size()); @@ -70,11 +70,24 @@ Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, s } try { + framecnt_t sample_rate; + if (use_session_sample_rate) { + sample_rate = session.frame_rate(); + } else { + boost::shared_ptr aregion = boost::dynamic_pointer_cast(region); + + if (aregion) { + sample_rate = aregion->audio_source()->sample_rate(); + } else { + return -1; + } + } + nsrcs.push_back (boost::dynamic_pointer_cast ( - SourceFactory::createWritable (region->data_type(), session, - path, false, session.frame_rate()))); + SourceFactory::createWritable (region->data_type(), session, + path, false, sample_rate))); } - + catch (failed_constructor& err) { error << string_compose (_("filter: error creating new file %1 (%2)"), path, strerror (errno)) << endmsg; return -1;