- vector<ptflookup_t> ptfwavpair;
- vector<ptflookup_t> ptfregpair;
-
- if (ptf.load(ptpath, _session->frame_rate()) == -1) {
- MessageDialog msg (_("Doesn't seem to be a valid PT session file"));
- msg.run ();
- return;
- } else {
- MessageDialog msg (string_compose (_("PT v%1 Session @ %2Hz\n\n%3 audio files\n%4 regions\n%5 active regions\n\nContinue..."), (int)ptf.version, ptf.sessionrate, ptf.audiofiles.size(), ptf.regions.size(), ptf.tracks.size()));
- msg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-
- int result = msg.run ();
- if (result != Gtk::RESPONSE_OK) {
- return;
- }
- }
- current_interthread_info = &import_status;
- import_status.current = 1;
- import_status.total = ptf.audiofiles.size ();
- import_status.all_done = false;
-
- ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
-
- SourceList just_one;
- SourceList imported;
-
- for (vector<PTFFormat::wav_t>::iterator a = ptf.audiofiles.begin(); a != ptf.audiofiles.end(); ++a) {
- ptflookup_t p;
-
- fullpath = Glib::build_filename (Glib::path_get_dirname(ptpath), "Audio Files");
- fullpath = Glib::build_filename (fullpath, a->filename);
- to_import.clear ();
- to_import.push_back (fullpath);
- ipw.show ();
- ok = import_sndfiles (to_import, Editing::ImportDistinctFiles, Editing::ImportAsRegion, quality, pos, 1, -1, track, false, instrument);
- if (!import_status.sources.empty()) {
- p.index1 = a->index;
- p.id = import_status.sources.back()->id();
-
- ptfwavpair.push_back(p);
- imported.push_back(import_status.sources.back());
- } else {
- onefailed = true;
- }
- }
-
- if (onefailed) {
- MessageDialog msg (_("Failed to load one or more of the audio files, but continuing to attempt import."));
- msg.run ();
- } else {
- MessageDialog msg (_("Success! Import should complete soon."));
- msg.run ();
- }
-
- for (vector<PTFFormat::region_t>::iterator a = ptf.regions.begin();
- a != ptf.regions.end(); ++a) {
- for (vector<ptflookup_t>::iterator p = ptfwavpair.begin();
- p != ptfwavpair.end(); ++p) {
- if (p->index1 == a->wave.index) {
- for (SourceList::iterator x = imported.begin();
- x != imported.end(); ++x) {
- if ((*x)->id() == p->id) {
- // Matched an uncreated ptf region to ardour region
- ptflookup_t rp;
- PropertyList plist;
-
- plist.add (ARDOUR::Properties::start, a->sampleoffset);
- plist.add (ARDOUR::Properties::position, 0);
- plist.add (ARDOUR::Properties::length, a->length);
- plist.add (ARDOUR::Properties::name, a->name);
- plist.add (ARDOUR::Properties::layer, 0);
- plist.add (ARDOUR::Properties::whole_file, false);
- plist.add (ARDOUR::Properties::external, true);
-
- just_one.clear();
- just_one.push_back(*x);
-
- boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
- regions.push_back(r);
-
- rp.id = regions.back()->id();
- rp.index1 = a->index;
- ptfregpair.push_back(rp);
- }
- }