X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Ffilter.cc;h=36a74da0f50756375ecb5490c85deb39a84c5682;hb=4bdbe77414b956e27f2c1631e67189c70409a3d1;hp=b723de1e56508af42ada0c7c7932e477bf0d4d32;hpb=74bc0c84686c4a85941b98d17179d3209bf9a2a8;p=ardour.git diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index b723de1e56..36a74da0f5 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()); @@ -59,7 +59,9 @@ Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, s } } - string path = session.new_audio_source_path (name, region->n_channels(), i, false, false); + const string path = (region->data_type() == DataType::MIDI) + ? session.new_midi_source_path (name) + : session.new_audio_source_path (name, region->n_channels(), i, false, false); if (path.empty()) { error << string_compose (_("filter: error creating name for new file based on %1"), region->name()) @@ -68,9 +70,22 @@ 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) {