From e0c07e230631ce39e371a89853854345a52c2817 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 3 Jan 2022 23:51:33 +0100 Subject: [PATCH] Add ImportAsTrigger mode This is like ImportAsTrack, except the imported region is not added to the timeline, but the first trigger slot. --- gtk2_ardour/editing_syms.h | 1 + gtk2_ardour/editor_audio_import.cc | 18 +++++++++++++----- gtk2_ardour/enums.cc | 1 + gtk2_ardour/sfdb_ui.cc | 3 +++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/editing_syms.h b/gtk2_ardour/editing_syms.h index bc5331c4c7..4f3f9afd25 100644 --- a/gtk2_ardour/editing_syms.h +++ b/gtk2_ardour/editing_syms.h @@ -86,6 +86,7 @@ DISPLAYCONTROL(ShowWaveformsRecording) IMPORTMODE(ImportAsRegion) IMPORTMODE(ImportToTrack) IMPORTMODE(ImportAsTrack) +IMPORTMODE(ImportAsTrigger) // if this is changed, remember to update the string table in sfdb_ui.cc IMPORTPOSITION(ImportAtTimestamp) diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index ead7711304..199e85d791 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -1085,6 +1085,8 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, break; } + case ImportAsTrigger: + /* fallthrough */ case ImportAsTrack: { if (!existing_track) { @@ -1137,11 +1139,17 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, } } - boost::shared_ptr playlist = existing_track->playlist(); - boost::shared_ptr copy (RegionFactory::create (region, true)); - playlist->clear_changes (); - playlist->add_region (copy, pos); - _session->add_command (new StatefulDiffCommand (playlist)); + if (mode == ImportAsTrigger) { + boost::shared_ptr copy (RegionFactory::create (region, true)); + /* TODO handle ImportSerializeFiles, pos > 0, use next free trigger-slot */ + existing_track->triggerbox ()->set_from_selection (0, copy); + } else { + boost::shared_ptr playlist = existing_track->playlist(); + boost::shared_ptr copy (RegionFactory::create (region, true)); + playlist->clear_changes (); + playlist->add_region (copy, pos); + _session->add_command (new StatefulDiffCommand (playlist)); + } break; } diff --git a/gtk2_ardour/enums.cc b/gtk2_ardour/enums.cc index 222addca6a..a8ee70f724 100644 --- a/gtk2_ardour/enums.cc +++ b/gtk2_ardour/enums.cc @@ -80,6 +80,7 @@ setup_gtk_ardour_enums () REGISTER_ENUM (ImportAsTrack); REGISTER_ENUM (ImportToTrack); REGISTER_ENUM (ImportAsRegion); + REGISTER_ENUM (ImportAsTrigger); REGISTER (import_mode); REGISTER_ENUM (EditAtPlayhead); diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 2f30cd2c43..254f247323 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -142,6 +142,9 @@ importmode2string (ImportMode mode) return _("to selected tracks"); case ImportAsRegion: return _("to source list"); + case ImportAsTrigger: + /* TODO: n/a */ + break; } abort(); /*NOTREACHED*/ return _("as new tracks");