summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2018-10-07 16:34:10 +1100
committerDamien Zammit <damien@zamaudio.com>2018-10-07 16:55:02 +1100
commitb614606f6938768de48f6ca8efb23a678f317283 (patch)
treea376f7c4bc0a6a9e2da14b58627ad42263df2cee
parent66a4c975d8f9998a76a540a91e30b93aa1c587d6 (diff)
PT import: Insert regions with references to missing sourcesptimport-refactor
When sample rate of PT session matches Ardour's, we can insert valid regions with references to missing sources since no resampling of these files will be required. This is not possible when sample rates mismatch, so we only do this when rates are the same.
-rw-r--r--libs/ardour/import_pt.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/libs/ardour/import_pt.cc b/libs/ardour/import_pt.cc
index 0725b0b370..6a56bb9451 100644
--- a/libs/ardour/import_pt.cc
+++ b/libs/ardour/import_pt.cc
@@ -230,21 +230,29 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status)
just_one_src.clear();
ok = import_sndfile_as_region (fullpath, SrcBest, pos, just_one_src, status);
} else {
- /* ptformat does not know the length of sources so we cannot do this:
- XMLNode srcxml (X_("Source"));
- srcxml.set_property ("name", a->filename);
- srcxml.set_property ("type", "audio");
- srcxml.set_property ("id", PBD::ID ().to_s ());
- boost::shared_ptr<Source> source = SourceFactory::createSilent (this, srcxml, a->length, sample_rate ());
- p.index1 = a->index;
- p.id = source->id ();
- ptfwavpair.push_back (p);
- imported.push_back (source);
- */
-
- /* Out of options */
onefailed = true;
- warning << string_compose (_("PT Import : MISSING `%1`"), fullpath) << endmsg;
+
+ /* ptformat knows length of sources *in PT sample rate*
+ * BUT if ardour user later resolves missing file,
+ * it won't be resampled, so we can only do this
+ * when sample rates are matching
+ */
+ if (sample_rate () == ptf.sessionrate) {
+ /* Insert reference to missing source */
+ samplecnt_t sourcelen = w->length;
+ XMLNode srcxml (X_("Source"));
+ srcxml.set_property ("name", w->filename);
+ srcxml.set_property ("type", "audio");
+ srcxml.set_property ("id", PBD::ID ().to_s ());
+ boost::shared_ptr<Source> source = SourceFactory::createSilent (*this, srcxml, sourcelen, sample_rate ());
+ p.index1 = w->index;
+ p.id = source->id ();
+ ptfwavpair.push_back (p);
+ imported.push_back (source);
+ warning << string_compose (_("PT Import : MISSING `%1`, inserting ref to missing source"), fullpath) << endmsg;
+ } else {
+ warning << string_compose (_("PT Import : MISSING `%1`, please check Audio Files"), fullpath) << endmsg;
+ }
}
}
if (ok) {
@@ -253,9 +261,6 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status)
ptfwavpair.push_back (p);
imported.push_back (just_one_src.back ());
- } else {
- onefailed = true;
- warning << string_compose (_("PT Import : FAILED `%1`"), fullpath) << endmsg;
}
}