From 2a27cc475867612afd261e5bf3b2a1a42b9c75cc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 5 Oct 2016 21:01:21 +0200 Subject: [PATCH] GUI support for type-0/1 SMF import (display channel/track count) This needs further work: Type-1 SMF are always "One [Ardour] track per [MIDI] track" Only type-0 SMF have the option "One [Ardour] track per [MIDI] channel" and "One [Ardour] track per [MIDI] file" This is ambiguous with multi-channel audio or multiple selection, mixed audio+midi and worse with mixed type0/1 .mid selection. This calls for a dedicated dropdown to select MIDI Import Disposition for type-0 SMF. --- gtk2_ardour/editor_audio_import.cc | 1 + gtk2_ardour/sfdb_ui.cc | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 237fb6776d..6f9443026d 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -484,6 +484,7 @@ Editor::import_sndfiles (vector paths, import_status.freeze = false; import_status.quality = quality; import_status.replace_existing_source = replace; + import_status.split_midi_channels = (disposition == Editing::ImportDistinctChannels); import_status.mode = mode; import_status.pos = pos; diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index f94c584019..b2f96ed8a6 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -303,7 +303,15 @@ SoundFileBox::setup_labels (const string& filename) tags_entry.set_sensitive (false); if (ms) { - channels_value.set_text (to_string(ms->num_tracks(), std::dec)); + if (ms->is_type0()) { + channels_value.set_text (to_string(ms->channels().size(), std::dec)); + } else { + if (ms->num_tracks() > 1) { + channels_value.set_text (to_string(ms->num_tracks(), std::dec) + _("(Tracks)")); + } else { + channels_value.set_text (to_string(ms->num_tracks(), std::dec)); + } + } length_clock.set (ms->length(ms->timeline_position())); } else { channels_value.set_text (""); @@ -1428,6 +1436,7 @@ SoundFileOmega::reset_options () vector channel_strings; if (mode == ImportAsTrack || mode == ImportAsTapeTrack || mode == ImportToTrack) { + /// XXX needs special casing for MIDI type-1 files channel_strings.push_back (_("one track per file")); if (selection_includes_multichannel) { @@ -1571,7 +1580,17 @@ SoundFileOmega::check_info (const vector& paths, bool& same_size, bool& Evoral::SMF reader; reader.open(*i); if (reader.num_tracks() > 1) { - multichannel = true; // "channel" == track here... + /* NOTE: we cannot merge midi-tracks. + * they will always be on separate tracks + * "one track per file" is not possible. + */ + //multichannel = true; // "channel" == track here... + } + if (reader.is_type0 () && reader.channels().size() > 1) { + /* for type-0 files, we can split + * "one track per channel" + */ + multichannel = true; } /* XXX we need err = true handling here in case