- if (!Glib::file_test (ptpath, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
- Gtk::MessageDialog msg (string_compose (_("%1: this is only the directory/folder name, not the filename.\n"), ptpath));
- msg.run ();
- continue;
- }
- }
-
- if (ptpath.length ()) {
- do_ptimport (ptpath, SrcBest);
- break;
- }
-
- if (result == Gtk::RESPONSE_CANCEL) {
- break;
- }
- }
-}
-
-struct midipair {
- midipair (uint16_t idx, string n)
- : ptfindex (idx)
- , trname (n)
- {}
- uint16_t ptfindex;
- string trname;
-};
-
-void
-Editor::do_ptimport (std::string ptpath,
- SrcQuality quality)
-{
- vector<boost::shared_ptr<Region> > regions;
- boost::shared_ptr<ARDOUR::Track> track;
- ARDOUR::PluginInfoPtr instrument;
- vector<string> to_import;
- string fullpath;
- bool ok = false;
- bool onefailed = false;
- PTFFormat ptf;
- samplepos_t pos = -1;
- uint32_t srate = _session->sample_rate ();
-
- vector<ptflookup_t> ptfwavpair;
- vector<ptflookup_t> ptfregpair;
-
- if (ptf.load (ptpath, srate) == -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 audio regions\n%5 active audio regions\n%6 midi regions\n%7 active midi regions\n\nContinue..."), (int)ptf.version, ptf.sessionrate, ptf.audiofiles.size (), ptf.regions.size () - ptf.midiregions.size (), ptf.tracks.size (), ptf.midiregions.size (), ptf.miditracks.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) && (strcmp (a->wave.filename.c_str (), "") != 0)) {
- 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;