2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/element_importer.h"
26 #include "pbd/convert.h"
27 #include "ardour/session.h"
32 using namespace ARDOUR;
34 sigc::signal <std::pair<bool, string>, string, string> ElementImporter::Rename;
35 sigc::signal <bool, string> ElementImporter::Prompt;
37 ElementImporter::ElementImporter (XMLTree const & source, ARDOUR::Session & session) :
45 prop = source.root()->property ("sample-rate");
47 std::istringstream iss (prop->value());
52 ElementImporter::~ElementImporter ()
57 ElementImporter::move ()
59 if (!_queued) { return; }
64 ElementImporter::prepare_move ()
69 _queued = _prepare_move ();
74 ElementImporter::cancel_move ()
76 if (!_queued) { return; }
81 ElementImporter::smpte_to_string(SMPTE::Time & time) const
83 std::ostringstream oss;
84 oss << std::setfill('0') << std::right <<
88 time.minutes << ":" <<
90 time.seconds << ":" <<
98 ElementImporter::rate_convert_samples (nframes_t samples) const
100 if (sample_rate == session.frame_rate()) {
104 // +0.5 for proper rounding
105 return static_cast<nframes_t> (samples * (static_cast<double> (session.nominal_frame_rate()) / sample_rate) + 0.5);
109 ElementImporter::rate_convert_samples (string const & samples) const
111 return to_string (rate_convert_samples (atoi (samples)), std::dec);