X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Ffilter.cc;h=8067edf14ec71fc69377d88a6077c24329dfb9dc;hb=20dc91d0adf8bc54acb1bdb7fe6e368255d75e56;hp=208377cc4ab2a4a159dd9292f3f20b694102c794;hpb=5156998e6e2536c9c713974d3ae719a5d2ef5c7f;p=ardour.git diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index 208377cc4a..8067edf14e 100644 --- a/libs/ardour/filter.cc +++ b/libs/ardour/filter.cc @@ -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 @@ -20,40 +20,58 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include "pbd/basename.h" +#include "ardour/sndfilesource.h" +#include "ardour/smf_source.h" +#include "ardour/session.h" +#include "ardour/region.h" +#include "ardour/filter.h" +#include "ardour/region_factory.h" +#include "ardour/source_factory.h" +#include "ardour/analyser.h" +#include "ardour/audioregion.h" #include "i18n.h" +using namespace std; using namespace ARDOUR; using namespace PBD; int -Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs) +Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs, string suffix) { vector names = region->master_source_names(); + assert (region->n_channels() <= names.size()); for (uint32_t i = 0; i < region->n_channels(); ++i) { + string name = PBD::basename_nosuffix (names[i]); + + /* remove any existing version of suffix by assuming it starts + with some kind of "special" character. + */ + + if (!suffix.empty()) { + string::size_type pos = name.find (suffix[0]); + if (pos != string::npos && pos > 2) { + name = name.substr (0, pos - 1); + } + } + string path = session.path_from_region_name (region->data_type(), 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; } try { 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, string(), false, session.frame_rate()))); + } catch (failed_constructor& err) { error << string_compose (_("filter: error creating new file %1 (%2)"), path, strerror (errno)) << endmsg; @@ -65,10 +83,8 @@ Filter::make_new_sources (boost::shared_ptr region, SourceList& nsrcs) } int -Filter::finish (boost::shared_ptr region, SourceList& nsrcs) +Filter::finish (boost::shared_ptr region, SourceList& nsrcs, string region_name) { - string region_name; - /* update headers on new sources */ time_t xnow; @@ -81,24 +97,51 @@ Filter::finish (boost::shared_ptr region, SourceList& nsrcs) for (SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) { boost::shared_ptr afs = boost::dynamic_pointer_cast(*si); if (afs) { + afs->done_with_peakfile_writes (); afs->update_header (region->position(), *now, xnow); afs->mark_immutable (); } - + boost::shared_ptr smfs = boost::dynamic_pointer_cast(*si); if (smfs) { smfs->set_timeline_position (region->position()); - smfs->flush_footer (); + smfs->flush (); } + + /* now that there is data there, requeue the file for analysis */ + + Analyser::queue_source_for_analysis (*si, false); } /* create a new region */ - region_name = session.new_region_name (region->name()); + if (region_name.empty()) { + region_name = RegionFactory::new_region_name (region->name()); + } results.clear (); - results.push_back (RegionFactory::create (nsrcs, 0, region->length(), region_name, 0, - Region::Flag (Region::WholeFile|Region::DefaultFlags))); - + + 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 r = RegionFactory::create (nsrcs, plist); + + boost::shared_ptr audio_region = boost::dynamic_pointer_cast (region); + boost::shared_ptr audio_r = boost::dynamic_pointer_cast (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; }