2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <sys/types.h>
29 #include "pbd/pthread_utils.h"
30 #include "pbd/basename.h"
31 #include "pbd/shortpath.h"
32 #include "pbd/stateful_diff_command.h"
34 #include <gtkmm2ext/choice.h>
36 #include "ardour/audio_track.h"
37 #include "ardour/audiofilesource.h"
38 #include "ardour/audioregion.h"
39 #include "ardour/midi_region.h"
40 #include "ardour/midi_track.h"
41 #include "ardour/operations.h"
42 #include "ardour/region_factory.h"
43 #include "ardour/smf_source.h"
44 #include "ardour/source_factory.h"
45 #include "ardour/utils.h"
46 #include "pbd/memento_command.h"
48 #include "ardour_ui.h"
49 #include "cursor_context.h"
53 #include "audio_time_axis.h"
54 #include "midi_time_axis.h"
55 #include "session_import_dialog.h"
56 #include "gui_thread.h"
57 #include "interthread_progress_window.h"
58 #include "mouse_cursors.h"
59 #include "editor_cursors.h"
64 using namespace ARDOUR;
67 using namespace Gtkmm2ext;
68 using namespace Editing;
71 /* Functions supporting the incorporation of external (non-captured) audio material into ardour */
74 Editor::add_external_audio_action (ImportMode mode_hint)
77 MessageDialog msg (_("You can't import or embed an audiofile until you have a session loaded."));
83 sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, 0, 0, true, mode_hint);
85 sfbrowser->set_mode (mode_hint);
88 external_audio_dialog ();
92 Editor::external_audio_dialog ()
95 uint32_t audio_track_cnt;
96 uint32_t midi_track_cnt;
99 MessageDialog msg (_("You can't import or embed an audiofile until you have a session loaded."));
107 for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
108 AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*x);
111 if (atv->is_audio_track()) {
116 MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(*x);
119 if (mtv->is_midi_track()) {
126 if (sfbrowser == 0) {
127 sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, audio_track_cnt, midi_track_cnt, true);
129 sfbrowser->reset (audio_track_cnt, midi_track_cnt);
132 sfbrowser->show_all ();
136 Editor::session_import_dialog ()
138 SessionImportDialog dialog (_session);
142 typedef std::map<PBD::ID,boost::shared_ptr<ARDOUR::Source> > SourceMap;
145 * Updating is still disabled, see note in libs/ardour/import.cc Session::import_files()
148 * true = show "Update", "Import" and "Skip"
149 * false = show "Import", and "Cancel"
152 * 0 To update an existing source of the same name
153 * 1 To import/embed the file normally (make sure the new name will be unique)
154 * 2 If the user wants to skip this file
157 Editor::check_whether_and_how_to_import(string path, bool all_or_nothing)
159 string wave_name (Glib::path_get_basename(path));
161 bool already_exists = false;
164 if ((existing = _session->count_sources_by_origin (path)) > 0) {
165 already_exists = true;
170 if (already_exists) {
172 if (all_or_nothing) {
173 // updating is still disabled
174 //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);
175 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);
177 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);
180 MessageDialog dialog(message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
182 if (all_or_nothing) {
184 //dialog.add_button("Update", 0);
185 dialog.add_button("Import", 1);
186 dialog.add_button("Skip", 2);
188 dialog.add_button("Import", 1);
189 dialog.add_button("Cancel", 2);
192 //dialog.add_button("Skip all", 4); // All or rest?
196 function = dialog.run ();
204 boost::shared_ptr<AudioTrack>
205 Editor::get_nth_selected_audio_track (int nth) const
207 AudioTimeAxisView* atv;
208 TrackSelection::iterator x;
210 for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
212 atv = dynamic_cast<AudioTimeAxisView*>(*x);
216 } else if (atv->is_audio_track()) {
221 if (x == selection->tracks.end()) {
222 atv = dynamic_cast<AudioTimeAxisView*>(selection->tracks.back());
224 atv = dynamic_cast<AudioTimeAxisView*>(*x);
227 if (!atv || !atv->is_audio_track()) {
228 return boost::shared_ptr<AudioTrack>();
231 return atv->audio_track();
234 boost::shared_ptr<MidiTrack>
235 Editor::get_nth_selected_midi_track (int nth) const
237 MidiTimeAxisView* mtv;
238 TrackSelection::iterator x;
240 for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
242 mtv = dynamic_cast<MidiTimeAxisView*>(*x);
246 } else if (mtv->is_midi_track()) {
251 if (x == selection->tracks.end()) {
252 mtv = dynamic_cast<MidiTimeAxisView*>(selection->tracks.back());
254 mtv = dynamic_cast<MidiTimeAxisView*>(*x);
257 if (!mtv || !mtv->is_midi_track()) {
258 return boost::shared_ptr<MidiTrack>();
261 return mtv->midi_track();
265 Editor::import_smf_tempo_map (Evoral::SMF const & smf, framepos_t pos)
271 const size_t num_tempos = smf.num_tempos ();
273 if (num_tempos == 0) {
277 const framecnt_t sample_rate = _session->frame_rate ();
278 TempoMap new_map (sample_rate);
279 Meter last_meter (4.0, 4.0);
280 bool have_initial_meter = false;
282 for (size_t n = 0; n < num_tempos; ++n) {
284 Evoral::SMF::Tempo* t = smf.nth_tempo (n);
287 Tempo tempo (60 * (1000000 / (double) t->microseconds_per_quarter_note), 4.0);
288 Meter meter (t->numerator, t->denominator);
289 Timecode::BBT_Time bbt; /* 1|1|0 which is correct for the no-meter case */
291 if (have_initial_meter) {
292 new_map.add_tempo (tempo, (t->time_pulses/smf.ppqn()) / 4.0, 0, TempoSection::Constant, MusicTime);
293 if (!(meter == last_meter)) {
294 bbt = new_map.bbt_at_quarter_note ((t->time_pulses/smf.ppqn()));
295 new_map.add_meter (meter, t->time_pulses, bbt, 0, MusicTime);
299 new_map.replace_meter (new_map.meter_section_at_frame (0), meter, bbt, pos, AudioTime);
300 new_map.replace_tempo (new_map.tempo_section_at_frame (0), tempo, 0.0, pos, TempoSection::Constant, AudioTime);
301 have_initial_meter = true;
307 cerr << "@ " << t->time_pulses/smf.ppqn() << " ("
308 << t->time_seconds << ") Add T " << tempo << " M " << meter << endl;
311 cerr << "NEW MAP:\n";
314 _session->tempo_map() = new_map;
318 Editor::do_import (vector<string> paths,
319 ImportDisposition disposition,
322 MidiTrackNameSource midi_track_name_source,
323 MidiTempoMapDisposition smf_tempo_disposition,
325 ARDOUR::PluginInfoPtr instrument)
327 boost::shared_ptr<Track> track;
328 vector<string> to_import;
330 bool use_timestamp = (pos == -1);
332 if (smf_tempo_disposition == SMFTempoUse) {
333 /* Find the first MIDI file with a tempo map, and import it
334 before we do anything else.
337 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
342 if (smf.num_tempos() > 0) {
343 import_smf_tempo_map (smf, pos);
351 current_interthread_info = &import_status;
352 import_status.current = 1;
353 import_status.total = paths.size ();
354 import_status.all_done = false;
355 import_status.midi_track_name_source = midi_track_name_source;
357 ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
361 if (disposition == Editing::ImportMergeFiles) {
363 /* create 1 region from all paths, add to 1 track,
368 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
369 int check = check_whether_and_how_to_import(*a, false);
380 ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false, instrument) == 0);
381 import_status.sources.clear();
386 bool replace = false;
388 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
390 const int check = check_whether_and_how_to_import (*a, true);
397 fatal << "Updating existing sources should be disabled!" << endmsg;
398 abort(); /* NOTREACHED*/
404 fatal << "Illegal return " << check << " from check_whether_and_how_to_import()!" << endmsg;
405 abort(); /* NOTREACHED*/
408 /* have to reset this for every file we handle */
416 switch (disposition) {
417 case Editing::ImportDistinctFiles:
420 to_import.push_back (*a);
422 if (mode == Editing::ImportToTrack) {
423 track = get_nth_selected_audio_track (nth++);
426 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace, instrument) == 0);
427 import_status.sources.clear();
430 case Editing::ImportDistinctChannels:
433 to_import.push_back (*a);
435 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace, instrument) == 0);
436 import_status.sources.clear();
439 case Editing::ImportSerializeFiles:
442 to_import.push_back (*a);
444 ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace, instrument) == 0);
445 import_status.sources.clear();
448 case Editing::ImportMergeFiles:
449 // Not entered, handled in earlier if() branch
456 _session->save_state ("");
459 import_status.all_done = true;
463 Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, framepos_t& pos, ARDOUR::PluginInfoPtr instrument)
465 boost::shared_ptr<Track> track;
466 bool check_sample_rate = true;
468 vector<string> to_embed;
469 bool multi = paths.size() > 1;
471 bool use_timestamp = (pos == -1);
474 case Editing::ImportDistinctFiles:
475 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
477 /* have to reset this for every file we handle */
483 to_embed.push_back (*a);
485 if (mode == Editing::ImportToTrack) {
486 track = get_nth_selected_audio_track (nth++);
489 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track, instrument) < -1) {
495 case Editing::ImportDistinctChannels:
496 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
498 /* have to reset this for every file we handle */
504 to_embed.push_back (*a);
506 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track, instrument) < -1) {
512 case Editing::ImportMergeFiles:
513 if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
518 case Editing::ImportSerializeFiles:
519 for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
521 /* have to reset this for every file we handle */
527 to_embed.push_back (*a);
529 if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
540 _session->save_state ("");
545 Editor::import_sndfiles (vector<string> paths,
546 ImportDisposition disposition,
552 boost::shared_ptr<Track>& track,
554 ARDOUR::PluginInfoPtr instrument)
556 import_status.paths = paths;
557 import_status.done = false;
558 import_status.cancel = false;
559 import_status.freeze = false;
560 import_status.quality = quality;
561 import_status.replace_existing_source = replace;
562 import_status.split_midi_channels = (disposition == Editing::ImportDistinctChannels);
564 import_status.mode = mode;
565 import_status.pos = pos;
566 import_status.target_tracks = target_tracks;
567 import_status.target_regions = target_regions;
568 import_status.track = track;
569 import_status.replace = replace;
571 CursorContext::Handle cursor_ctx = CursorContext::create(*this, _cursors->wait);
574 /* start import thread for this spec. this will ultimately call Session::import_files()
575 which, if successful, will add the files as regions to the region list. its up to us
576 (the GUI) to direct additional steps after that.
579 pthread_create_and_store ("import", &import_status.thread, _import_thread, this);
580 pthread_detach (import_status.thread);
582 while (!import_status.done && !import_status.cancel) {
583 gtk_main_iteration ();
586 // wait for thread to terminate
587 while (!import_status.done) {
588 gtk_main_iteration ();
593 if (!import_status.cancel && !import_status.sources.empty()) {
594 result = add_sources (
596 import_status.sources,
600 import_status.target_regions,
601 import_status.target_tracks,
602 track, false, instrument
605 /* update position from results */
607 pos = import_status.pos;
614 Editor::embed_sndfiles (vector<string> paths,
616 bool& check_sample_rate,
617 ImportDisposition disposition,
622 boost::shared_ptr<Track>& track,
623 ARDOUR::PluginInfoPtr instrument)
625 boost::shared_ptr<AudioFileSource> source;
630 CursorContext::Handle cursor_ctx = CursorContext::create(*this, _cursors->wait);
633 for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
638 /* note that we temporarily truncated _id at the colon */
640 if (!AudioFileSource::get_soundfile_info (path, finfo, error_msg)) {
641 error << string_compose(_("Editor: cannot open file \"%1\", (%2)"), path, error_msg ) << endmsg;
645 if (check_sample_rate && (finfo.samplerate != (int) _session->frame_rate())) {
646 vector<string> choices;
649 choices.push_back (_("Cancel entire import"));
650 choices.push_back (_("Don't embed it"));
651 choices.push_back (_("Embed all without questions"));
653 Gtkmm2ext::Choice rate_choice (
655 string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"),
656 short_path (path, 40)),
660 int resx = rate_choice.run ();
663 case 0: /* stop a multi-file import */
665 case 1: /* don't embed this one */
667 case 2: /* do it, and the rest without asking */
668 check_sample_rate = false;
676 choices.push_back (_("Cancel"));
677 choices.push_back (_("Embed it anyway"));
679 Gtkmm2ext::Choice rate_choice (
681 string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
685 int resx = rate_choice.run ();
688 case 0: /* don't import */
698 for (int n = 0; n < finfo.channels; ++n) {
702 /* check if we have this thing embedded already */
704 boost::shared_ptr<Source> s;
706 if ((s = _session->audio_source_by_path_and_channel (path, n)) == 0) {
708 source = boost::dynamic_pointer_cast<AudioFileSource> (
709 SourceFactory::createExternal (DataType::AUDIO, *_session,
711 (mode == ImportAsTapeTrack
712 ? Source::Destructive
716 source = boost::dynamic_pointer_cast<AudioFileSource> (s);
719 sources.push_back(source);
722 catch (failed_constructor& err) {
723 error << string_compose(_("could not open %1"), path) << endmsg;
727 gtk_main_iteration();
731 if (!sources.empty()) {
732 return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true, instrument);
739 Editor::add_sources (vector<string> paths,
742 ImportDisposition disposition,
746 boost::shared_ptr<Track>& track,
747 bool /*add_channel_suffix*/,
748 ARDOUR::PluginInfoPtr instrument)
750 vector<boost::shared_ptr<Region> > regions;
752 uint32_t input_chan = 0;
753 uint32_t output_chan = 0;
755 vector<string> track_names;
757 use_timestamp = (pos == -1);
759 // kludge (for MIDI we're abusing "channel" for "track" here)
760 if (SMFSource::safe_midi_file_extension (paths.front())) {
764 if (target_regions == 1) {
766 /* take all the sources we have and package them up as a region */
768 region_name = region_name_from_path (paths.front(), (sources.size() > 1), false);
770 /* we checked in import_sndfiles() that there were not too many */
772 while (RegionFactory::region_by_name (region_name)) {
773 region_name = bump_name_once (region_name, '.');
778 plist.add (ARDOUR::Properties::start, 0);
779 plist.add (ARDOUR::Properties::length, sources[0]->length (pos));
780 plist.add (ARDOUR::Properties::name, region_name);
781 plist.add (ARDOUR::Properties::layer, 0);
782 plist.add (ARDOUR::Properties::whole_file, true);
783 plist.add (ARDOUR::Properties::external, true);
785 boost::shared_ptr<Region> r = RegionFactory::create (sources, plist);
787 if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
788 boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position(sources[0]->natural_position());
791 regions.push_back (r);
793 /* if we're creating a new track, name it after the cleaned-up
794 * and "merged" region name.
797 track_names.push_back (region_name);
799 } else if (target_regions == -1 || target_regions > 1) {
801 /* take each source and create a region for each one */
804 SourceList::iterator x;
807 for (n = 0, x = sources.begin(); x != sources.end(); ++x, ++n) {
810 just_one.push_back (*x);
812 boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (*x);
814 if (sources.size() > 1 && disposition == ImportDistinctChannels) {
816 /* generate a per-channel region name so that things work as
823 region_name = basename_nosuffix (fs->path());
825 region_name = (*x)->name();
828 if (sources.size() == 2) {
834 } else if (sources.size() > 2) {
835 region_name += string_compose ("-%1", n+1);
838 track_names.push_back (region_name);
842 region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
844 region_name = (*x)->name();
847 if (SMFSource::safe_midi_file_extension (paths.front())) {
848 string track_name = string_compose ("%1-t%2", PBD::basename_nosuffix (fs->path()), (n + 1));
849 track_names.push_back (track_name);
851 track_names.push_back (PBD::basename_nosuffix (paths[n]));
857 /* Fudge region length to ensure it is non-zero; make it 1 beat at 120bpm
858 for want of a better idea. It can't be too small, otherwise if this
859 is a MIDI region the conversion from frames -> beats -> frames will
860 round it back down to 0 again.
862 framecnt_t len = (*x)->length (pos);
864 len = (60.0 / 120.0) * _session->frame_rate ();
867 plist.add (ARDOUR::Properties::start, 0);
868 plist.add (ARDOUR::Properties::length, len);
869 plist.add (ARDOUR::Properties::name, region_name);
870 plist.add (ARDOUR::Properties::layer, 0);
871 plist.add (ARDOUR::Properties::whole_file, true);
872 plist.add (ARDOUR::Properties::external, true);
874 boost::shared_ptr<Region> r = RegionFactory::create (just_one, plist);
876 if (use_timestamp && boost::dynamic_pointer_cast<AudioRegion>(r)) {
877 boost::dynamic_pointer_cast<AudioRegion>(r)->special_set_position((*x)->natural_position());
880 regions.push_back (r);
884 if (target_regions == 1) {
885 input_chan = regions.front()->n_channels();
887 if (target_tracks == 1) {
888 input_chan = regions.size();
894 if (Config->get_output_auto_connect() & AutoConnectMaster) {
895 output_chan = (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan);
897 output_chan = input_chan;
903 begin_reversible_command (Operations::insert_file);
905 /* we only use tracks names when importing to new tracks, but we
906 * require that one is defined for every region, just to keep
909 assert (regions.size() == track_names.size());
911 for (vector<boost::shared_ptr<Region> >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) {
912 boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*r);
917 /* get timestamp for this region */
919 const boost::shared_ptr<Source> s (ar->sources().front());
920 const boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource> (s);
924 if (as->natural_position() != 0) {
925 pos = as->natural_position();
926 } else if (target_tracks == 1) {
927 /* hmm, no timestamp available, put it after the previous region
930 pos = get_preferred_edit_position ();
935 pos = get_preferred_edit_position ();
938 /* should really get first position in MIDI file, but for now, use edit position*/
939 pos = get_preferred_edit_position ();
943 finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], instrument);
945 rlen = (*r)->length();
947 if (target_tracks != 1) {
950 if (!use_timestamp || !ar) {
951 /* line each one up right after the other */
952 pos += (*r)->length();
957 commit_reversible_command ();
959 /* setup peak file building in another thread */
961 for (SourceList::iterator x = sources.begin(); x != sources.end(); ++x) {
962 SourceFactory::setup_peakfile (*x, true);
969 Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
974 boost::shared_ptr<Track>& existing_track,
975 const string& new_track_name,
976 ARDOUR::PluginInfoPtr instrument)
978 boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
979 boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
983 /* relax, its been done */
988 if (!existing_track) {
991 existing_track = get_nth_selected_audio_track (0);
993 existing_track = get_nth_selected_midi_track (0);
996 if (!existing_track) {
1001 boost::shared_ptr<Playlist> playlist = existing_track->playlist();
1002 boost::shared_ptr<Region> copy (RegionFactory::create (region, region->properties()));
1003 playlist->clear_changes ();
1004 playlist->add_region (copy, pos);
1005 if (Config->get_edit_mode() == Ripple)
1006 playlist->ripple (pos, copy->length(), copy);
1008 _session->add_command (new StatefulDiffCommand (playlist));
1014 if (!existing_track) {
1016 list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Normal));
1021 if (Config->get_strict_io ()) {
1022 for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
1023 (*i)->set_strict_io (true);
1027 existing_track = at.front();
1029 list<boost::shared_ptr<MidiTrack> > mt (
1030 _session->new_midi_track (ChanCount (DataType::MIDI, 1),
1031 ChanCount (DataType::MIDI, 1),
1032 instrument, (Plugin::PresetRecord*) 0,
1036 PresentationInfo::max_order));
1041 if (Config->get_strict_io ()) {
1042 for (list<boost::shared_ptr<MidiTrack> >::iterator i = mt.begin(); i != mt.end(); ++i) {
1043 (*i)->set_strict_io (true);
1047 // TODO set strict_io from preferences
1048 existing_track = mt.front();
1051 if (!new_track_name.empty()) {
1052 existing_track->set_name (new_track_name);
1054 existing_track->set_name (region->name());
1058 boost::shared_ptr<Playlist> playlist = existing_track->playlist();
1059 boost::shared_ptr<Region> copy (RegionFactory::create (region, true));
1060 playlist->clear_changes ();
1061 playlist->add_region (copy, pos);
1062 _session->add_command (new StatefulDiffCommand (playlist));
1066 case ImportAsTapeTrack:
1072 list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Destructive));
1074 boost::shared_ptr<Playlist> playlist = at.front()->playlist();
1075 boost::shared_ptr<Region> copy (RegionFactory::create (region, true));
1076 playlist->clear_changes ();
1077 playlist->add_region (copy, pos);
1078 _session->add_command (new StatefulDiffCommand (playlist));
1080 if (Config->get_strict_io ()) {
1081 for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
1082 (*i)->set_strict_io (true);
1093 Editor::_import_thread (void *arg)
1095 SessionEvent::create_per_thread_pool ("import events", 64);
1097 Editor *ed = (Editor *) arg;
1098 return ed->import_thread ();
1102 Editor::import_thread ()
1104 _session->import_files (import_status);