From defcd16931ab6b8003dec54e8a27b5125ba6d595 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 25 May 2024 16:45:57 +0200 Subject: [PATCH] T: limit import to stereo (and constrain import options) Trax only has mono and stereo tracks (no surround panner). In theory we could allow "sequence files", and "merge files", channels > 2 are simply ignored. However it seems prudent to hide those options, at least for the time being. --- gtk2_ardour/editor_audio_import.cc | 33 ++++++++++++++++++++++++++++++ gtk2_ardour/sfdb_ui.cc | 10 +++++++++ 2 files changed, 43 insertions(+) diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index e9f6fde871..6ab634e88f 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -611,6 +611,21 @@ Editor::import_sndfiles (vector paths, import_status.track = track; import_status.replace = replace; +#ifdef LIVETRAX + if (disposition == ImportDistinctFiles) { + for (auto const & path : import_status.paths) { + SoundFileInfo finfo; + string error_msg; + if (AudioFileSource::get_soundfile_info (path, finfo, error_msg)) { + if (finfo.channels > 2) { + disposition = ImportDistinctChannels; + import_status.target_regions = -1; + } + } + } + } +#endif + CursorContext::Handle cursor_ctx = CursorContext::create(*this, _cursors->wait); gdk_flush (); @@ -748,6 +763,13 @@ Editor::embed_sndfiles (vector paths, } } +#ifdef LIVETRAX + if (finfo.channels > 2 && disposition == ImportDistinctFiles) { + disposition = ImportDistinctChannels; + target_regions = -1; + } +#endif + for (int n = 0; n < finfo.channels; ++n) { try { @@ -806,6 +828,8 @@ Editor::add_sources (vector paths, bool use_timestamp; vector track_names; + printf ("Editor::add_sources %ld %ld [%d %d] %d %d\n", paths.size(), sources.size(), disposition, mode, target_regions, target_tracks); + use_timestamp = (pos == timepos_t::max (pos.time_domain())); // kludge (for MIDI we're abusing "channel" for "track" here) @@ -955,6 +979,10 @@ Editor::add_sources (vector paths, input_chan = 2; } #endif +#ifdef LIVETRAX + /* Trax allows at most 2 channels. This handles edge-cases (sequence files, merge files) */ + input_chan = std::min (input_chan, 2); +#endif if (Config->get_output_auto_connect() & AutoConnectMaster) { output_chan = (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan); @@ -1051,6 +1079,11 @@ Editor::finish_bringing_in_material (std::shared_ptr region, std::shared_ptr ar = std::dynamic_pointer_cast(region); std::shared_ptr mr = std::dynamic_pointer_cast(region); +#ifdef LIVETRAX + assert (in_chans < 3); + assert (out_chans < 3); +#endif + switch (mode) { case ImportAsRegion: /* relax, its been done */ diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index c9a9c8757c..978c378f89 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -1636,7 +1636,9 @@ SoundFileOmega::reset_options () } action_strings.push_back (importmode2string (ImportAsTrack)); +#ifndef LIVETRAX action_strings.push_back (importmode2string (ImportAsRegion)); +#endif existing_choice = action_combo.get_active_text(); @@ -1676,6 +1678,7 @@ SoundFileOmega::reset_options () channel_strings.push_back (_("one track per channel")); } +#ifndef LIVETRAX if (paths.size() > 1) { /* tape tracks are a single region per track, so we cannot sequence multiple files. @@ -1687,6 +1690,7 @@ SoundFileOmega::reset_options () } } +#endif } else { channel_strings.push_back (_("one region per file")); @@ -1695,11 +1699,13 @@ SoundFileOmega::reset_options () channel_strings.push_back (_("one region per channel")); } +#ifndef LIVETRAX if (paths.size() > 1) { if (same_size) { channel_strings.push_back (_("all files in one region")); } } +#endif } resetting_ourselves = true; @@ -2035,14 +2041,18 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s, str.clear (); str.push_back (_("one track per file")); str.push_back (_("one track per channel")); +#ifndef LIVETRAX str.push_back (_("sequence files")); str.push_back (_("all files in one region")); +#endif set_popdown_strings (channel_combo, str); str.clear (); str.push_back (importmode2string (ImportAsTrack)); str.push_back (importmode2string (ImportToTrack)); +#ifndef LIVETRAX str.push_back (importmode2string (ImportAsRegion)); +#endif set_popdown_strings (action_combo, str); action_combo.set_active_text (importmode2string(mode_hint));