2 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006 Taybin Rutkin <taybin@taybin.com>
5 * Copyright (C) 2007 Tim Mayberry <mojofunk@gmail.com>
6 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
7 * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
9 * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <sys/types.h>
35 #include "pbd/pthread_utils.h"
36 #include "pbd/basename.h"
37 #include "pbd/shortpath.h"
38 #include "pbd/stateful_diff_command.h"
40 #include "widgets/choice.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/audiofilesource.h"
44 #include "ardour/audioregion.h"
45 #include "ardour/midi_region.h"
46 #include "ardour/midi_track.h"
47 #include "ardour/operations.h"
48 #include "ardour/profile.h"
49 #include "ardour/region_factory.h"
50 #include "ardour/smf_source.h"
51 #include "ardour/source_factory.h"
52 #include "ardour/utils.h"
53 #include "pbd/memento_command.h"
55 #include "ardour_message.h"
56 #include "ardour_ui.h"
57 #include "cursor_context.h"
61 #include "audio_time_axis.h"
62 #include "midi_time_axis.h"
63 #include "session_import_dialog.h"
64 #include "gui_thread.h"
65 #include "interthread_progress_window.h"
66 #include "mouse_cursors.h"
67 #include "editor_cursors.h"
72 using namespace ARDOUR;
75 using namespace Gtkmm2ext;
76 using namespace Editing;
79 /* Functions supporting the incorporation of external (non-captured) audio material into ardour */
82 Editor::add_external_audio_action (ImportMode mode_hint)
85 ArdourMessageDialog msg (_("You can't import or embed an audiofile until you have a session loaded."));
91 sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, 0, 0, true, mode_hint);
93 sfbrowser->set_mode (mode_hint);
96 external_audio_dialog ();
100 Editor::external_audio_dialog ()
102 vector<string> paths;
103 uint32_t audio_track_cnt;
104 uint32_t midi_track_cnt;
107 ArdourMessageDialog msg (_("You can't import or embed an audiofile until you have a session loaded."));
115 for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
116 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*x);
119 if (atv->is_audio_track()) {
124 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(*x);
127 if (mtv->is_midi_track()) {
134 if (sfbrowser == 0) {
135 sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, audio_track_cnt, midi_track_cnt, true);
137 sfbrowser->reset (audio_track_cnt, midi_track_cnt);
140 sfbrowser->show_all ();
144 Editor::session_import_dialog ()
146 SessionImportDialog dialog (_session);
150 typedef std::map<PBD::ID,boost::shared_ptr<ARDOUR::Source> > SourceMap;
153 * Updating is still disabled, see note in libs/ardour/import.cc Session::import_files()
156 * true = show "Update", "Import" and "Skip"
157 * false = show "Import", and "Cancel"
160 * 0 To update an existing source of the same name
161 * 1 To import/embed the file normally (make sure the new name will be unique)
162 * 2 If the user wants to skip this file
165 Editor::check_whether_and_how_to_import(string path, bool all_or_nothing)
167 string wave_name (Glib::path_get_basename(path));
169 bool already_exists = false;
172 if ((existing = _session->count_sources_by_origin (path)) > 0) {
173 already_exists = true;
178 if (already_exists) {
180 if (all_or_nothing) {
181 // updating is still disabled
182 //message = string_compose(_("The session already contains a source file named %1. Do you want to update that file (and thus all regions using the file) or import this file as a new file?"),wave_name);
183 message = string_compose (_("The session already contains a source file named %1. Do you want to import %1 as a new file, or skip it?"), wave_name);
185 message = string_compose (_("The session already contains a source file named %1. Do you want to import %2 as a new source, or skip it?"), wave_name, wave_name);
188 ArdourMessageDialog dialog(message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
190 if (all_or_nothing) {
192 //dialog.add_button("Update", 0);
193 dialog.add_button("Import", 1);
194 dialog.add_button("Skip", 2);
196 dialog.add_button("Import", 1);
197 dialog.add_button("Cancel", 2);
200 //dialog.add_button("Skip all", 4); // All or rest?
202 function = dialog.run ();
209 boost::shared_ptr<AudioTrack>
210 Editor::get_nth_selected_audio_track (int nth) const
212 AudioTimeAxisView* atv;
213 TrackSelection::iterator x;
215 for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
217 atv = dynamic_cast<AudioTimeAxisView*>(*x);
221 } else if (atv->is_audio_track()) {
226 if (x == selection->tracks.end()) {
227 atv = dynamic_cast<AudioTimeAxisView*>(selection->tracks.back());
229 atv = dynamic_cast<AudioTimeAxisView*>(*x);
232 if (!atv || !atv->is_audio_track()) {
233 return boost::shared_ptr<AudioTrack>();
236 return atv->audio_track();
239 boost::shared_ptr<MidiTrack>
240 Editor::get_nth_selected_midi_track (int nth) const
242 MidiTimeAxisView* mtv;
243 TrackSelection::iterator x;
245 for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
247 mtv = dynamic_cast<MidiTimeAxisView*>(*x);
251 } else if (mtv->is_midi_track()) {
256 if (x == selection->tracks.end()) {
257 mtv = dynamic_cast<MidiTimeAxisView*>(selection->tracks.back());
259 mtv = dynamic_cast<MidiTimeAxisView*>(*x);
262 if (!mtv || !mtv->is_midi_track()) {
263 return boost::shared_ptr<MidiTrack>();
266 return mtv->midi_track();
270 Editor::import_smf_tempo_map (Evoral::SMF const & smf, samplepos_t pos)
276 const size_t num_tempos = smf.num_tempos ();
278 if (num_tempos == 0) {
282 const samplecnt_t sample_rate = _session->sample_rate ();
283 TempoMap new_map (sample_rate);
284 Meter last_meter (4.0, 4.0);
285 bool have_initial_meter = false;
287 for (size_t n = 0; n < num_tempos; ++n) {
289 Evoral::SMF::Tempo* t = smf.nth_tempo (n);
292 Tempo tempo (t->tempo(), 32.0 / (double) t->notes_per_note);
293 Meter meter (t->numerator, t->denominator);
294 Timecode::BBT_Time bbt; /* 1|1|0 which is correct for the no-meter case */
296 if (have_initial_meter) {
297 new_map.add_tempo (tempo, t->time_pulses/ (double)smf.ppqn() / 4.0, 0, MusicTime);
298 if (!(meter == last_meter)) {
299 bbt = new_map.bbt_at_quarter_note (t->time_pulses/(double)smf.ppqn());
300 new_map.add_meter (meter, bbt, 0, MusicTime);
304 new_map.replace_meter (new_map.meter_section_at_sample (0), meter, bbt, pos, AudioTime);
305 new_map.replace_tempo (new_map.tempo_section_at_sample (0), tempo, 0.0, pos, AudioTime);
306 have_initial_meter = true;
312 cerr << "@ " << t->time_pulses/(double)smf.ppqn() << " ("
313 << t->time_seconds << ") Add T " << tempo << " M " << meter << endl;
316 cerr << "NEW MAP:\n";
319 _session->tempo_map() = new_map;
323 Editor::do_import (vector<string> paths,
324 ImportDisposition disposition,
327 MidiTrackNameSource midi_track_name_source,
328 MidiTempoMapDisposition smf_tempo_disposition,
330 ARDOUR::PluginInfoPtr instrument)
332 boost::shared_ptr<Track> track;
333 vector<string> to_import;
335 bool use_timestamp = (pos == -1);
337 if (smf_tempo_disposition == SMFTempoUse) {
338 /* Find the first MIDI file with a tempo map, and import it
339 before we do anything else.
342 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
347 if (smf.num_tempos() > 0) {
348 import_smf_tempo_map (smf, pos);
356 current_interthread_info = &import_status;
357 import_status.current = 1;
358 import_status.total = paths.size ();
359 import_status.all_done = false;
360 import_status.midi_track_name_source = midi_track_name_source;
362 ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
366 if (disposition == Editing::ImportMergeFiles) {
368 /* create 1 region from all paths, add to 1 track,
373 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
374 int check = check_whether_and_how_to_import(*a, false);
385 ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false, instrument) == 0);
386 import_status.sources.clear();
391 bool replace = false;
393 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
395 const int check = check_whether_and_how_to_import (*a, true);
402 fatal << "Updating existing sources should be disabled!" << endmsg;
403 abort(); /* NOTREACHED*/
409 fatal << "Illegal return " << check << " from check_whether_and_how_to_import()!" << endmsg;
410 abort(); /* NOTREACHED*/
413 /* have to reset this for every file we handle */
421 switch (disposition) {
422 case Editing::ImportDistinctFiles:
425 to_import.push_back (*a);
427 if (mode == Editing::ImportToTrack) {
428 track = get_nth_selected_audio_track (nth++);
431 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace, instrument) == 0);
432 import_status.sources.clear();
435 case Editing::ImportDistinctChannels:
438 to_import.push_back (*a);
440 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace, instrument) == 0);
441 import_status.sources.clear();
444 case Editing::ImportSerializeFiles:
447 to_import.push_back (*a);
449 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace, instrument) == 0);
450 import_status.sources.clear();
453 case Editing::ImportMergeFiles:
454 // Not entered, handled in earlier if() branch
461 _session->save_state ("");
464 import_status.all_done = true;
468 Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, samplepos_t& pos, ARDOUR::PluginInfoPtr instrument)
470 boost::shared_ptr<Track> track;
471 bool check_sample_rate = true;
473 vector<string> to_embed;
474 bool multi = paths.size() > 1;
476 bool use_timestamp = (pos == -1);
479 case Editing::ImportDistinctFiles:
480 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
482 /* have to reset this for every file we handle */
488 to_embed.push_back (*a);
490 if (mode == Editing::ImportToTrack) {
491 track = get_nth_selected_audio_track (nth++);
494 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track, instrument) < -1) {
500 case Editing::ImportDistinctChannels:
501 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
503 /* have to reset this for every file we handle */
509 to_embed.push_back (*a);
511 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track, instrument) < -1) {
517 case Editing::ImportMergeFiles:
518 if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
523 case Editing::ImportSerializeFiles:
524 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
526 /* have to reset this for every file we handle */
532 to_embed.push_back (*a);
534 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
545 _session->save_state ("");
550 Editor::import_sndfiles (vector<string> paths,
551 ImportDisposition disposition,
557 boost::shared_ptr<Track>& track,
559 ARDOUR::PluginInfoPtr instrument)
561 import_status.paths = paths;
562 import_status.done = false;
563 import_status.cancel = false;
564 import_status.freeze = false;
565 import_status.quality = quality;
566 import_status.replace_existing_source = replace;
567 import_status.split_midi_channels = (disposition == Editing::ImportDistinctChannels);
569 import_status.mode = mode;
570 import_status.pos = pos;
571 import_status.target_tracks = target_tracks;
572 import_status.target_regions = target_regions;
573 import_status.track = track;
574 import_status.replace = replace;
576 CursorContext::Handle cursor_ctx = CursorContext::create(*this, _cursors->wait);
579 /* start import thread for this spec. this will ultimately call Session::import_files()
580 which, if successful, will add the files as regions to the region list. its up to us
581 (the GUI) to direct additional steps after that.
584 pthread_create_and_store ("import", &import_status.thread, _import_thread, this);
585 pthread_detach (import_status.thread);
587 while (!import_status.done && !import_status.cancel) {
588 gtk_main_iteration ();
591 // wait for thread to terminate
592 while (!import_status.done) {
593 gtk_main_iteration ();
598 if (!import_status.cancel && !import_status.sources.empty()) {
599 result = add_sources (
601 import_status.sources,
605 import_status.target_regions,
606 import_status.target_tracks,
607 track, false, instrument
610 /* update position from results */
612 pos = import_status.pos;
619 Editor::embed_sndfiles (vector<string> paths,
621 bool& check_sample_rate,
622 ImportDisposition disposition,
627 boost::shared_ptr<Track>& track,
628 ARDOUR::PluginInfoPtr instrument)
630 boost::shared_ptr<AudioFileSource> source;
635 CursorContext::Handle cursor_ctx = CursorContext::create(*this, _cursors->wait);
638 for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
643 /* note that we temporarily truncated _id at the colon */
645 if (!AudioFileSource::get_soundfile_info (path, finfo, error_msg)) {
646 error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), path, error_msg ) << endmsg;
650 if (!finfo.seekable) {
651 ArdourMessageDialog msg (string_compose (_("%1\nThis audiofile cannot be embedded. It must be imported!"), short_path (path, 40)), false, Gtk::MESSAGE_ERROR);
656 if (check_sample_rate && (finfo.samplerate != (int) _session->sample_rate())) {
657 vector<string> choices;
660 choices.push_back (_("Cancel entire import"));
661 choices.push_back (_("Don't embed it"));
662 choices.push_back (_("Embed all without questions"));
664 ArdourWidgets::Choice rate_choice (
666 string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"),
667 short_path (path, 40)),
671 int resx = rate_choice.run ();
674 case 0: /* stop a multi-file import */
676 case 1: /* don't embed this one */
678 case 2: /* do it, and the rest without asking */
679 check_sample_rate = false;
687 choices.push_back (_("Cancel"));
688 choices.push_back (_("Embed it anyway"));
690 ArdourWidgets::Choice rate_choice (
692 string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
696 int resx = rate_choice.run ();
699 case 0: /* don't import */
709 for (int n = 0; n < finfo.channels; ++n) {
713 /* check if we have this thing embedded already */
715 boost::shared_ptr<Source> s;
717 if ((s = _session->audio_source_by_path_and_channel (path, n)) == 0) {
719 source = boost::dynamic_pointer_cast<AudioFileSource> (
720 SourceFactory::createExternal (DataType::AUDIO, *_session,
722 (mode == ImportAsTapeTrack
723 ? Source::Destructive
727 source = boost::dynamic_pointer_cast<AudioFileSource> (s);
730 sources.push_back(source);
733 catch (failed_constructor& err) {
734 error << string_compose(_("could not open %1"), path) << endmsg;
738 gtk_main_iteration();
742 if (!sources.empty()) {
743 return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true, instrument);
750 Editor::add_sources (vector<string> paths,
753 ImportDisposition disposition,
757 boost::shared_ptr<Track>& track,
758 bool /*add_channel_suffix*/,
759 ARDOUR::PluginInfoPtr instrument)
761 vector<boost::shared_ptr<Region> > regions;
763 uint32_t input_chan = 0;
764 uint32_t output_chan = 0;
766 vector<string> track_names;
768 use_timestamp = (pos == -1);
770 // kludge (for MIDI we're abusing "channel" for "track" here)
771 if (SMFSource::safe_midi_file_extension (paths.front())) {
775 if (target_regions == 1) {
777 /* take all the sources we have and package them up as a region */
779 region_name = region_name_from_path (paths.front(), (sources.size() > 1), false);
781 /* we checked in import_sndfiles() that there were not too many */
783 while (RegionFactory::region_by_name (region_name)) {
784 region_name = bump_name_once (region_name, '.');
789 plist.add (ARDOUR::Properties::start, 0);
790 plist.add (ARDOUR::Properties::length, sources[0]->length (pos));
791 plist.add (ARDOUR::Properties::name, region_name);
792 plist.add (ARDOUR::Properties::layer, 0);
793 plist.add (ARDOUR::Properties::whole_file, true);
794 plist.add (ARDOUR::Properties::external, true);
796 boost::shared_ptr<Region> r = RegionFactory::create (sources, plist);
798 if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
799 boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position(sources[0]->natural_position());
802 regions.push_back (r);
804 /* if we're creating a new track, name it after the cleaned-up
805 * and "merged" region name.
808 track_names.push_back (region_name);
810 } else if (target_regions == -1 || target_regions > 1) {
812 /* take each source and create a region for each one */
815 SourceList::iterator x;
818 for (n = 0, x = sources.begin(); x != sources.end(); ++x, ++n) {
821 just_one.push_back (*x);
823 boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (*x);
825 if (sources.size() > 1 && disposition == ImportDistinctChannels) {
827 /* generate a per-channel region name so that things work as
834 region_name = basename_nosuffix (fs->path());
836 region_name = (*x)->name();
839 if (sources.size() == 2) {
845 } else if (sources.size() > 2) {
846 region_name += string_compose ("-%1", n+1);
849 track_names.push_back (region_name);
853 region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
855 region_name = (*x)->name();
858 if (SMFSource::safe_midi_file_extension (paths.front())) {
859 string track_name = string_compose ("%1-t%2", PBD::basename_nosuffix (fs->path()), (n + 1));
860 track_names.push_back (track_name);
862 track_names.push_back (PBD::basename_nosuffix (paths[n]));
868 /* Fudge region length to ensure it is non-zero; make it 1 beat at 120bpm
869 for want of a better idea. It can't be too small, otherwise if this
870 is a MIDI region the conversion from samples -> beats -> samples will
871 round it back down to 0 again.
873 samplecnt_t len = (*x)->length (pos);
875 len = (60.0 / 120.0) * _session->sample_rate ();
878 plist.add (ARDOUR::Properties::start, 0);
879 plist.add (ARDOUR::Properties::length, len);
880 plist.add (ARDOUR::Properties::name, region_name);
881 plist.add (ARDOUR::Properties::layer, 0);
882 plist.add (ARDOUR::Properties::whole_file, true);
883 plist.add (ARDOUR::Properties::external, true);
885 boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
887 if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
888 boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position((*x)->natural_position());
891 regions.push_back (r);
895 if (target_regions == 1) {
896 input_chan = regions.front()->n_channels();
898 if (target_tracks == 1) {
899 input_chan = regions.size();
905 if (Config->get_output_auto_connect() & AutoConnectMaster) {
906 output_chan = (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan);
908 output_chan = input_chan;
912 samplepos_t rlen = 0;
914 begin_reversible_command (Operations::insert_file);
916 /* we only use tracks names when importing to new tracks, but we
917 * require that one is defined for every region, just to keep
920 assert (regions.size() == track_names.size());
922 for (vector<boost::shared_ptr<Region> >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) {
923 boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*r);
928 /* get timestamp for this region */
930 const boost::shared_ptr<Source> s (ar->sources().front());
931 const boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource> (s);
935 if (as->natural_position() != 0) {
936 pos = as->natural_position();
937 } else if (target_tracks == 1) {
938 /* hmm, no timestamp available, put it after the previous region
941 pos = get_preferred_edit_position ();
946 pos = get_preferred_edit_position ();
949 /* should really get first position in MIDI file, but for now, use edit position*/
950 pos = get_preferred_edit_position ();
954 finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], instrument);
956 rlen = (*r)->length();
958 if (target_tracks != 1) {
961 if (!use_timestamp || !ar) {
962 /* line each one up right after the other */
963 pos += (*r)->length();
968 commit_reversible_command ();
970 /* setup peak file building in another thread */
972 for (SourceList::iterator x = sources.begin(); x != sources.end(); ++x) {
973 SourceFactory::setup_peakfile (*x, true);
980 Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
985 boost::shared_ptr<Track>& existing_track,
986 const string& new_track_name,
987 ARDOUR::PluginInfoPtr instrument)
989 boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
990 boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
994 /* relax, its been done */
999 if (!existing_track) {
1002 existing_track = get_nth_selected_audio_track (0);
1004 existing_track = get_nth_selected_midi_track (0);
1007 if (!existing_track) {
1012 boost::shared_ptr<Playlist> playlist = existing_track->playlist();
1013 boost::shared_ptr<Region> copy (RegionFactory::create (region, region->properties()));
1014 playlist->clear_changes ();
1015 playlist->add_region (copy, pos);
1016 if (Config->get_edit_mode() == Ripple)
1017 playlist->ripple (pos, copy->length(), copy);
1019 _session->add_command (new StatefulDiffCommand (playlist));
1025 if (!existing_track) {
1027 list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Normal));
1032 if (Config->get_strict_io ()) {
1033 for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
1034 (*i)->set_strict_io (true);
1038 existing_track = at.front();
1040 list<boost::shared_ptr<MidiTrack> > mt (
1041 _session->new_midi_track (ChanCount (DataType::MIDI, 1),
1042 ChanCount (DataType::MIDI, 1),
1043 Config->get_strict_io () || Profile->get_mixbus (),
1044 instrument, (Plugin::PresetRecord*) 0,
1048 PresentationInfo::max_order));
1054 // TODO set strict_io from preferences
1055 existing_track = mt.front();
1058 if (!new_track_name.empty()) {
1059 existing_track->set_name (new_track_name);
1061 existing_track->set_name (region->name());
1065 boost::shared_ptr<Playlist> playlist = existing_track->playlist();
1066 boost::shared_ptr<Region> copy (RegionFactory::create (region, true));
1067 playlist->clear_changes ();
1068 playlist->add_region (copy, pos);
1069 _session->add_command (new StatefulDiffCommand (playlist));
1073 case ImportAsTapeTrack:
1079 list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Destructive));
1081 boost::shared_ptr<Playlist> playlist = at.front()->playlist();
1082 boost::shared_ptr<Region> copy (RegionFactory::create (region, true));
1083 playlist->clear_changes ();
1084 playlist->add_region (copy, pos);
1085 _session->add_command (new StatefulDiffCommand (playlist));
1087 if (Config->get_strict_io ()) {
1088 for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
1089 (*i)->set_strict_io (true);
1100 Editor::_import_thread (void *arg)
1102 SessionEvent::create_per_thread_pool ("import events", 64);
1104 Editor *ed = (Editor *) arg;
1105 return ed->import_thread ();
1109 Editor::import_thread ()
1111 _session->import_files (import_status);