From 8af0757b61990767f2a85e68f535a5af9976fd79 Mon Sep 17 00:00:00 2001 From: Taybin Rutkin Date: Sat, 24 Sep 2005 19:13:41 +0000 Subject: libardour added. git-svn-id: svn://localhost/trunk/ardour2@17 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/audiofilter.cc | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 libs/ardour/audiofilter.cc (limited to 'libs/ardour/audiofilter.cc') diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc new file mode 100644 index 0000000000..ab4728495f --- /dev/null +++ b/libs/ardour/audiofilter.cc @@ -0,0 +1,87 @@ +/* + Copyright (C) 2004 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id$ +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include "i18n.h" + +using namespace ARDOUR; + +int +AudioFilter::make_new_sources (AudioRegion& region, AudioRegion::SourceList& nsrcs) +{ + vector names = region.master_source_names(); + + for (uint32_t i = 0; i < region.n_channels(); ++i) { + + string path = session.path_from_region_name (PBD::basename_nosuffix (names[i]), string ("")); + + if (path.length() == 0) { + error << compose (_("audiofilter: error creating name for new audio file based on %1"), region.name()) + << endmsg; + return -1; + } + + try { + nsrcs.push_back (new FileSource (path, session.frame_rate())); + } + + catch (failed_constructor& err) { + error << compose (_("audiofilter: error creating new audio file %1 (%2)"), path, strerror (errno)) << endmsg; + return -1; + } + } + + return 0; +} + +int +AudioFilter::finish (AudioRegion& region, AudioRegion::SourceList& nsrcs) +{ + string region_name; + + /* update headers on new sources */ + + time_t xnow; + struct tm* now; + + time (&xnow); + now = localtime (&xnow); + + for (AudioRegion::SourceList::iterator si = nsrcs.begin(); si != nsrcs.end(); ++si) { + dynamic_cast((*si))->update_header (session.transport_frame(), *now, xnow); + } + + /* create a new region */ + + region_name = session.new_region_name (region.name()); + results.clear (); + results.push_back (new AudioRegion (nsrcs, 0, region.length(), region_name, 0, + Region::Flag (Region::WholeFile|Region::DefaultFlags))); + + return 0; +} -- cgit v1.2.3