13
0

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.
This commit is contained in:
Robin Gareus 2024-05-25 16:45:57 +02:00
parent 26ce571baf
commit defcd16931
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 43 additions and 0 deletions

View File

@ -611,6 +611,21 @@ Editor::import_sndfiles (vector<string> 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<string> 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<string> paths,
bool use_timestamp;
vector<string> 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<string> 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<uint32_t> (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> region,
std::shared_ptr<AudioRegion> ar = std::dynamic_pointer_cast<AudioRegion>(region);
std::shared_ptr<MidiRegion> mr = std::dynamic_pointer_cast<MidiRegion>(region);
#ifdef LIVETRAX
assert (in_chans < 3);
assert (out_chans < 3);
#endif
switch (mode) {
case ImportAsRegion:
/* relax, its been done */

View File

@ -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));