From d1ffeb7038f1ae98cd09bcbe90eea8d8e2ba5287 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Mon, 22 Dec 2025 15:32:18 +1100 Subject: [PATCH] import_pt: Use new bulk create method for adding tracks #9730 Speeds up imports tremendously. --- libs/ardour/import_pt.cc | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/libs/ardour/import_pt.cc b/libs/ardour/import_pt.cc index ad681e3504..2c779e69de 100644 --- a/libs/ardour/import_pt.cc +++ b/libs/ardour/import_pt.cc @@ -277,11 +277,13 @@ Session::import_pt_rest (PTFFormat& ptf) string fullpath; uint32_t srate = sample_rate (); timepos_t latest = timepos_t (0); + bool ok; vector ptfregpair; SourceList just_one_src; - + RouteList routes; + list > tracks; std::shared_ptr existing_track; uint16_t nth = 0; struct ptflookup utr; @@ -345,24 +347,34 @@ Session::import_pt_rest (PTFFormat& ptf) if (!(existing_track = dynamic_pointer_cast (route_by_name (a->name)))) { /* Create missing track */ DEBUG_TRACE (DEBUG::PTImport, string_compose ("Create tr(%1) '%2'\n", nth, a->name)); - list > at (new_audio_track (1, 2, 0, 1, a->name.c_str(), PresentationInfo::max_order, Normal)); - if (at.empty ()) { - return; - } - existing_track = at.back(); - } - track_map[a->name] = existing_track; - std::shared_ptr playlist = existing_track->playlist(); + ok = new_audio_routes_tracks_bulk (routes, + tracks, + 1, 2, 0, 1, + a->name.c_str (), + PresentationInfo::max_order, + Normal + ); + if (ok) { + existing_track = tracks.back(); + track_map[a->name] = existing_track; + std::shared_ptr playlist = existing_track->playlist(); - PlaylistState before; - before.playlist = playlist; - before.before = &playlist->get_state(); - playlist->clear_changes (); - playlist->freeze (); - playlists.push_back(before); + PlaylistState before; + before.playlist = playlist; + before.before = &playlist->get_state(); + playlist->clear_changes (); + playlist->freeze (); + playlists.push_back(before); + } + } } } + /* Finish bringing in routes */ + if (!routes.empty ()) { + add_routes (routes, true, true, PresentationInfo::max_order); + } + /* Add regions */ for (vector::const_iterator a = ptf.tracks ().begin (); a != ptf.tracks ().end (); ++a) { for (vector::iterator p = ptfregpair.begin ();