enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / ardour / filter.cc
index d782db96f24a1679903f003713f96b9bff17f602..6ebf23102ab0ff13db88e51a23d299296e2a2acb 100644 (file)
 #include "ardour/smf_source.h"
 #include "ardour/source_factory.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 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())));
+                                                SourceFactory::createWritable (region->data_type(), session,
+                                                                               path, false, sample_rate)));
                }
 
                catch (failed_constructor& err) {