+ ret = add_sources (paths, sources, pos, mode, target_regions, target_tracks, track, true);
+
+ out:
+ track_canvas->get_window()->set_cursor (*current_canvas_cursor);
+ return ret;
+}
+
+int
+Editor::add_sources (vector<Glib::ustring> paths, SourceList& sources, nframes64_t& pos, ImportMode mode,
+ int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool add_channel_suffix)
+{
+ vector<boost::shared_ptr<Region> > regions;
+ ustring region_name;
+ uint32_t input_chan = 0;
+ uint32_t output_chan = 0;
+
+ if (pos == -1) { // "use timestamp"
+ if (sources[0]->natural_position() != 0) {
+ pos = sources[0]->natural_position();
+ } else {
+ pos = get_preferred_edit_position ();
+ }
+ }
+
+ // kludge (for MIDI we're abusing "channel" for "track" here)
+ if (paths.front().rfind(".mid") != Glib::ustring::npos)
+ target_regions = -1;
+
+ if (target_regions == 1) {
+
+ /* take all the sources we have and package them up as a region */
+
+ region_name = region_name_from_path (paths.front(), (sources.size() > 1), false);
+
+ regions.push_back (RegionFactory::create (sources, 0, sources[0]->length(), region_name, 0,
+ Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)));
+
+ } else if (target_regions == -1 || target_regions > 1) {
+
+ /* take each source and create a region for each one */
+
+ SourceList just_one;
+ SourceList::iterator x;
+ uint32_t n;
+
+ for (n = 0, x = sources.begin(); x != sources.end(); ++x, ++n) {
+
+ just_one.clear ();
+ just_one.push_back (*x);
+
+ region_name = region_name_from_path ((*x)->path(), false, false, sources.size(), n);
+
+ regions.push_back (RegionFactory::create (just_one, 0, (*x)->length(), region_name, 0,
+ Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External)));
+
+ }
+ }
+
+ if (target_regions == 1) {
+ input_chan = regions.front()->n_channels();
+ } else {
+ if (target_tracks == 1) {
+ input_chan = regions.size();
+ } else {
+ input_chan = 1;
+ }
+ }