Merge branch 'master' of https://github.com/nmains/ardour
[ardour.git] / libs / ardour / filter.cc
index 88a6e1d253a3b636c5942b9de07e55b5b79adf7e..b085ec946b3d09305d52b3b8871e8a05a29f1e30 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2004-2007 Paul Davis 
+    Copyright (C) 2004-2007 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <cerrno>
 
 #include "pbd/basename.h"
-#include "ardour/sndfilesource.h"
-#include "ardour/smf_source.h"
-#include "ardour/session.h"
-#include "ardour/region.h"
+
+#include "ardour/analyser.h"
+#include "ardour/audiofilesource.h"
+#include "ardour/audioregion.h"
 #include "ardour/filter.h"
+#include "ardour/region.h"
 #include "ardour/region_factory.h"
+#include "ardour/session.h"
+#include "ardour/smf_source.h"
 #include "ardour/source_factory.h"
-#include "ardour/analyser.h"
-#include "ardour/audioregion.h"
 
 #include "i18n.h"
 
@@ -62,7 +63,7 @@ Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, s
                                PBD::basename_nosuffix (names[i]), string (""));
 
                if (path.length() == 0) {
-                       error << string_compose (_("filter: error creating name for new file based on %1"), region->name()) 
+                       error << string_compose (_("filter: error creating name for new file based on %1"), region->name())
                              << endmsg;
                        return -1;
                }
@@ -70,9 +71,8 @@ Filter::make_new_sources (boost::shared_ptr<Region> region, SourceList& nsrcs, s
                try {
                        nsrcs.push_back (boost::dynamic_pointer_cast<Source> (
                                SourceFactory::createWritable (region->data_type(), session,
-                                       path, true,
-                                       false, session.frame_rate())));
-               } 
+                                                              path, false, session.frame_rate())));
+               }
 
                catch (failed_constructor& err) {
                        error << string_compose (_("filter: error creating new file %1 (%2)"), path, strerror (errno)) << endmsg;
@@ -102,36 +102,47 @@ Filter::finish (boost::shared_ptr<Region> region, SourceList& nsrcs, string regi
                        afs->update_header (region->position(), *now, xnow);
                        afs->mark_immutable ();
                }
-               
+
                boost::shared_ptr<SMFSource> smfs = boost::dynamic_pointer_cast<SMFSource>(*si);
                if (smfs) {
                        smfs->set_timeline_position (region->position());
                        smfs->flush ();
                }
-               
+
                /* now that there is data there, requeue the file for analysis */
-               
+
                Analyser::queue_source_for_analysis (*si, false);
        }
 
        /* create a new region */
 
        if (region_name.empty()) {
-               region_name = session.new_region_name (region->name());
+               region_name = RegionFactory::new_region_name (region->name());
        }
        results.clear ();
 
-       boost::shared_ptr<Region> r = RegionFactory::create (nsrcs, 0, region->length(), region_name, 0, 
-                                                            Region::Flag (Region::WholeFile|Region::DefaultFlags));
-       r->set_position (region->position(), 0);
+       PropertyList plist;
+
+       plist.add (Properties::start, 0);
+       plist.add (Properties::length, region->length());
+       plist.add (Properties::name, region_name);
+       plist.add (Properties::whole_file, true);
+       plist.add (Properties::position, region->position());
+
+       boost::shared_ptr<Region> r = RegionFactory::create (nsrcs, plist);
 
        boost::shared_ptr<AudioRegion> audio_region = boost::dynamic_pointer_cast<AudioRegion> (region);
        boost::shared_ptr<AudioRegion> audio_r = boost::dynamic_pointer_cast<AudioRegion> (r);
        if (audio_region && audio_r) {
                audio_r->set_scale_amplitude (audio_region->scale_amplitude());
+               audio_r->set_fade_in_active (audio_region->fade_in_active ());
+               audio_r->set_fade_in (audio_region->fade_in ());
+               audio_r->set_fade_out_active (audio_region->fade_out_active ());
+               audio_r->set_fade_out (audio_region->fade_out ());
+               *(audio_r->envelope()) = *(audio_region->envelope ());
        }
        results.push_back (r);
-       
+
        return 0;
 }