GUI support for type-0/1 SMF import (display channel/track count)
authorRobin Gareus <robin@gareus.org>
Wed, 5 Oct 2016 19:01:21 +0000 (21:01 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 5 Oct 2016 19:01:21 +0000 (21:01 +0200)
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
gtk2_ardour/sfdb_ui.cc

index 237fb6776d99d36940340b8f34e22501a55142bc..6f9443026d2dfcdd0dcd4701f0d5b93bf40d3b8d 100644 (file)
@@ -484,6 +484,7 @@ Editor::import_sndfiles (vector<string>            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;
index f94c584019393c7c1fb29f38912e317ca5c7336b..b2f96ed8a648c90db821f5e980ba2bb89d25e408 100644 (file)
@@ -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<string> 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<string>& 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