From 675759c16756e82bf65797921b21b366ca238182 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Fri, 21 Jun 2019 22:09:04 +1000 Subject: [PATCH] Update references to ptfformat -> ptformat && fix api calls --- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_pt_import.cc | 2 +- gtk2_ardour/pt_import_selector.cc | 31 +++++++++++++++++++++---------- gtk2_ardour/pt_import_selector.h | 2 +- libs/ardour/import_pt.cc | 26 +++++++++++++------------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index b7c3d7e2c5..a96738b932 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -61,7 +61,7 @@ #include "selection_memento.h" #include "tempo_curve.h" -#include "ptformat/ptfformat.h" +#include "ptformat/ptformat.h" namespace Gtkmm2ext { class Bindings; diff --git a/gtk2_ardour/editor_pt_import.cc b/gtk2_ardour/editor_pt_import.cc index 12b6484b78..d81a03f3cf 100644 --- a/gtk2_ardour/editor_pt_import.cc +++ b/gtk2_ardour/editor_pt_import.cc @@ -44,7 +44,7 @@ #include "ardour/session.h" #include "pbd/memento_command.h" -#include "ptformat/ptfformat.h" +#include "ptformat/ptformat.h" #include "ardour_ui.h" #include "cursor_context.h" diff --git a/gtk2_ardour/pt_import_selector.cc b/gtk2_ardour/pt_import_selector.cc index 3446383f2f..9756fc967f 100644 --- a/gtk2_ardour/pt_import_selector.cc +++ b/gtk2_ardour/pt_import_selector.cc @@ -27,7 +27,7 @@ #include "pbd/i18n.h" #include "pbd/file_utils.h" -#include "ptformat/ptfformat.h" +#include "ptformat/ptformat.h" #include "ardour/session_handle.h" @@ -111,24 +111,35 @@ void PTImportSelector::update_ptf() { if (ptimport_ptf_chooser.get_filename ().size () > 0) { + int err = 0; std::string path = ptimport_ptf_chooser.get_filename (); bool ok = Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK) && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR); if (ok) { - if (_ptf->load (path, _session_rate) == -1) { + err = _ptf->load (path, _session_rate); + if (err == -1) { + ptimport_info_text.get_buffer ()->set_text ("Cannot decrypt PT session\n"); + ptimport_import_button.set_sensitive(false); + } else if (err == -2) { ptimport_info_text.get_buffer ()->set_text ("Cannot detect PT session\n"); ptimport_import_button.set_sensitive(false); + } else if (err == -3) { + ptimport_info_text.get_buffer ()->set_text ("Incompatible PT version\n"); + ptimport_import_button.set_sensitive(false); + } else if (err == -4) { + ptimport_info_text.get_buffer ()->set_text ("Cannot parse PT session\n"); + ptimport_import_button.set_sensitive(false); } else { std::string ptinfo = string_compose (_("PT Session [ VALID ]\n\nSession Info:\n\n\nPT 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\n"), - (int)_ptf->version, - _ptf->sessionrate, - _ptf->audiofiles.size (), - _ptf->regions.size (), - _ptf->tracks.size (), - _ptf->midiregions.size (), - _ptf->miditracks.size () + (int)_ptf->version (), + _ptf->sessionrate (), + _ptf->audiofiles ().size (), + _ptf->regions ().size (), + _ptf->tracks ().size (), + _ptf->midiregions ().size (), + _ptf->miditracks ().size () ); - if (_session_rate != _ptf->sessionrate) { + if (_session_rate != _ptf->sessionrate ()) { ptinfo = string_compose (_("%1WARNING:\n\nSample rate mismatch,\nwill be resampling\n"), ptinfo); } ptimport_info_text.get_buffer ()->set_text (ptinfo); diff --git a/gtk2_ardour/pt_import_selector.h b/gtk2_ardour/pt_import_selector.h index 278a046619..54a9aac96f 100644 --- a/gtk2_ardour/pt_import_selector.h +++ b/gtk2_ardour/pt_import_selector.h @@ -27,7 +27,7 @@ #include #include -#include "ptformat/ptfformat.h" +#include "ptformat/ptformat.h" #include "ardour_dialog.h" #include "ardour/session.h" diff --git a/libs/ardour/import_pt.cc b/libs/ardour/import_pt.cc index d668326a7e..bcd6c00b8e 100644 --- a/libs/ardour/import_pt.cc +++ b/libs/ardour/import_pt.cc @@ -48,7 +48,7 @@ #include "ardour/session.h" #include "pbd/memento_command.h" -#include "ptformat/ptfformat.h" +#include "ptformat/ptformat.h" #include "pbd/i18n.h" @@ -201,7 +201,7 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) vector ptfwavpair; vector ptfregpair; - vector::iterator w; + vector::const_iterator w; SourceList just_one_src; SourceList imported; @@ -213,18 +213,18 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK); - for (w = ptf.audiofiles.begin (); w != ptf.audiofiles.end () && !status.cancel; ++w) { + for (w = ptf.audiofiles ().begin (); w != ptf.audiofiles ().end () && !status.cancel; ++w) { ptflookup_t p; ok = false; /* Try audio file */ - fullpath = Glib::build_filename (Glib::path_get_dirname (ptf.path), "Audio Files"); + fullpath = Glib::build_filename (Glib::path_get_dirname (ptf.path ()), "Audio Files"); fullpath = Glib::build_filename (fullpath, w->filename); if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS)) { just_one_src.clear(); ok = import_sndfile_as_region (fullpath, SrcBest, pos, just_one_src, status); } else { /* Try fade file */ - fullpath = Glib::build_filename (Glib::path_get_dirname (ptf.path), "Fade Files"); + fullpath = Glib::build_filename (Glib::path_get_dirname (ptf.path ()), "Fade Files"); fullpath = Glib::build_filename (fullpath, w->filename); if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS)) { just_one_src.clear(); @@ -237,7 +237,7 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) * it won't be resampled, so we can only do this * when sample rates are matching */ - if (sample_rate () == ptf.sessionrate) { + if (sample_rate () == ptf.sessionrate ()) { /* Insert reference to missing source */ samplecnt_t sourcelen = w->length; XMLNode srcxml (X_("Source")); @@ -276,8 +276,8 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) lx.acquire(); save_state(""); - for (vector::iterator a = ptf.regions.begin (); - a != ptf.regions.end (); ++a) { + for (vector::const_iterator a = ptf.regions ().begin (); + a != ptf.regions ().end (); ++a) { for (vector::iterator p = ptfwavpair.begin (); p != ptfwavpair.end (); ++p) { if ((p->index1 == a->wave.index) && (strcmp (a->wave.filename.c_str (), "") != 0)) { @@ -310,7 +310,7 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) } } - for (vector::iterator a = ptf.tracks.begin (); a != ptf.tracks.end (); ++a) { + for (vector::const_iterator a = ptf.tracks ().begin (); a != ptf.tracks ().end (); ++a) { for (vector::iterator p = ptfregpair.begin (); p != ptfregpair.end (); ++p) { @@ -384,7 +384,7 @@ Session::import_pt (PTFFormat& ptf, ImportStatus& status) trymidi: status.paths.clear(); - status.paths.push_back(ptf.path); + status.paths.push_back(ptf.path ()); status.current = 1; status.total = 1; status.freeze = false; @@ -396,7 +396,7 @@ trymidi: vector uniquetr; - for (vector::iterator a = ptf.miditracks.begin (); a != ptf.miditracks.end (); ++a) { + for (vector::const_iterator a = ptf.miditracks ().begin (); a != ptf.miditracks ().end (); ++a) { bool found = false; for (vector::iterator b = uniquetr.begin (); b != uniquetr.end (); ++b) { if (b->trname == a->name) { @@ -429,7 +429,7 @@ trymidi: } /* MIDI - Add midi regions one-by-one to corresponding midi tracks */ - for (vector::iterator a = ptf.miditracks.begin (); a != ptf.miditracks.end (); ++a) { + for (vector::const_iterator a = ptf.miditracks ().begin (); a != ptf.miditracks ().end (); ++a) { boost::shared_ptr midi_track = midi_tracks[a->index]; assert (midi_track); @@ -453,7 +453,7 @@ trymidi: MidiModel::NoteDiffCommand *midicmd; midicmd = mm->new_note_diff_command ("Import ProTools MIDI"); - for (vector::iterator j = a->reg.midi.begin (); j != a->reg.midi.end (); ++j) { + for (vector::const_iterator j = a->reg.midi.begin (); j != a->reg.midi.end (); ++j) { //printf(" : MIDI : pos=%f len=%f\n", (float)j->pos / 960000., (float)j->length / 960000.); Temporal::Beats start = (Temporal::Beats)(j->pos / 960000.); Temporal::Beats len = (Temporal::Beats)(j->length / 960000.);