Set playlist ID when importing to new tracks
This amends730a0954
andb27bb586
. This also restores the original API for do_import() and do_embed() as used by Lua scripts. Note that this uses distinct IDs when importing both audio and MIDI in the same DnD request.
This commit is contained in:
parent
2433b3059f
commit
2b066293fb
|
@ -4343,8 +4343,7 @@ Editor::restore_editing_space ()
|
|||
bool
|
||||
Editor::stamp_new_playlist (string &name, string &pgroup, bool copy)
|
||||
{
|
||||
string gid = Playlist::generate_pgroup_id();
|
||||
pgroup = gid;
|
||||
pgroup = Playlist::generate_pgroup_id ();
|
||||
|
||||
if (name.length()==0) {
|
||||
name = _("Take.1");
|
||||
|
|
|
@ -456,7 +456,6 @@ public:
|
|||
ARDOUR::MidiTrackNameSource mts,
|
||||
ARDOUR::MidiTempoMapDisposition mtd,
|
||||
samplepos_t& pos,
|
||||
std::string pgroup_id,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
|
||||
bool with_markers = false
|
||||
);
|
||||
|
@ -465,7 +464,6 @@ public:
|
|||
Editing::ImportDisposition disposition,
|
||||
Editing::ImportMode mode,
|
||||
samplepos_t& pos,
|
||||
std::string pgroup_id,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
void get_regionview_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);
|
||||
|
@ -1395,6 +1393,7 @@ private:
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
bool replace,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
|
@ -1407,6 +1406,7 @@ private:
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
int add_sources (std::vector<std::string> paths,
|
||||
|
@ -1417,6 +1417,7 @@ private:
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<ARDOUR::Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
bool add_channel_suffix,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
|
||||
|
||||
|
@ -1426,7 +1427,8 @@ private:
|
|||
samplepos_t& pos,
|
||||
Editing::ImportMode mode,
|
||||
boost::shared_ptr<ARDOUR::Track>& existing_track,
|
||||
const std::string& new_track_name,
|
||||
std::string const& new_track_name,
|
||||
std::string const& pgroup_id,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument);
|
||||
|
||||
boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
|
||||
|
|
|
@ -348,7 +348,6 @@ Editor::do_import (vector<string> paths,
|
|||
MidiTrackNameSource midi_track_name_source,
|
||||
MidiTempoMapDisposition smf_tempo_disposition,
|
||||
samplepos_t& pos,
|
||||
string pgroup_id,
|
||||
ARDOUR::PluginInfoPtr instrument,
|
||||
bool with_markers)
|
||||
{
|
||||
|
@ -356,6 +355,7 @@ Editor::do_import (vector<string> paths,
|
|||
vector<string> to_import;
|
||||
int nth = 0;
|
||||
bool use_timestamp = (pos == -1);
|
||||
std::string const& pgroup_id = Playlist::generate_pgroup_id ();
|
||||
|
||||
/* XXX nutempo2: we will import markers using music (beat) time, which
|
||||
will make any imported tempo map irrelevant. Not doing that (in 6.7,
|
||||
|
@ -423,7 +423,7 @@ Editor::do_import (vector<string> paths,
|
|||
|
||||
if (!cancel) {
|
||||
ipw.show ();
|
||||
import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false, instrument);
|
||||
import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, pgroup_id, false, instrument);
|
||||
import_status.clear();
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ Editor::do_import (vector<string> paths,
|
|||
track = get_nth_selected_audio_track (nth++);
|
||||
}
|
||||
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace, instrument);
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, pgroup_id, replace, instrument);
|
||||
import_status.clear();
|
||||
break;
|
||||
|
||||
|
@ -478,7 +478,7 @@ Editor::do_import (vector<string> paths,
|
|||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace, instrument);
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, pgroup_id, replace, instrument);
|
||||
import_status.clear();
|
||||
break;
|
||||
|
||||
|
@ -487,7 +487,7 @@ Editor::do_import (vector<string> paths,
|
|||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace, instrument);
|
||||
import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, pgroup_id, replace, instrument);
|
||||
import_status.clear();
|
||||
break;
|
||||
|
||||
|
@ -498,22 +498,15 @@ Editor::do_import (vector<string> paths,
|
|||
}
|
||||
}
|
||||
|
||||
#if 0 // @ben FIXME
|
||||
/* track is only set if a mono file is imported to an existing track.
|
||||
* track->playlist() crashes.
|
||||
*
|
||||
* I guess this should only be called when importing multi-channel
|
||||
* files to newly created tracks. The new tracks should share
|
||||
* a group ID. This can however not be done here.
|
||||
*/
|
||||
track->playlist()->set_pgroup_id (pgroup_id);
|
||||
#endif
|
||||
|
||||
import_status.all_done = true;
|
||||
}
|
||||
|
||||
void
|
||||
Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, samplepos_t& pos, string pgroup_id, ARDOUR::PluginInfoPtr instrument)
|
||||
Editor::do_embed (vector<string> paths,
|
||||
ImportDisposition import_as,
|
||||
ImportMode mode,
|
||||
samplepos_t& pos,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<Track> track;
|
||||
bool check_sample_rate = true;
|
||||
|
@ -521,6 +514,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
|||
bool multi = paths.size() > 1;
|
||||
int nth = 0;
|
||||
bool use_timestamp = (pos == -1);
|
||||
std::string const& pgroup_id = Playlist::generate_pgroup_id ();
|
||||
|
||||
switch (import_as) {
|
||||
case Editing::ImportDistinctFiles:
|
||||
|
@ -538,7 +532,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
|||
track = get_nth_selected_audio_track (nth++);
|
||||
}
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track, instrument) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track, pgroup_id, instrument) < -1) {
|
||||
/* error, bail out */
|
||||
return;
|
||||
}
|
||||
|
@ -556,7 +550,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
|||
to_embed.clear ();
|
||||
to_embed.push_back (*a);
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track, instrument) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track, pgroup_id, instrument) < -1) {
|
||||
/* error, bail out */
|
||||
return;
|
||||
}
|
||||
|
@ -564,7 +558,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
|||
break;
|
||||
|
||||
case Editing::ImportMergeFiles:
|
||||
if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
|
||||
if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, pgroup_id, instrument) < -1) {
|
||||
/* error, bail out */
|
||||
return;
|
||||
}
|
||||
|
@ -581,7 +575,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode
|
|||
to_embed.clear ();
|
||||
to_embed.push_back (*a);
|
||||
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, instrument) < -1) {
|
||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track, pgroup_id, instrument) < -1) {
|
||||
/* error, bail out */
|
||||
return;
|
||||
}
|
||||
|
@ -599,6 +593,7 @@ Editor::import_sndfiles (vector<string> paths,
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
bool replace,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
|
@ -650,7 +645,7 @@ Editor::import_sndfiles (vector<string> paths,
|
|||
import_status.mode,
|
||||
import_status.target_regions,
|
||||
import_status.target_tracks,
|
||||
track, false, instrument
|
||||
track, pgroup_id, false, instrument
|
||||
);
|
||||
|
||||
/* update position from results */
|
||||
|
@ -671,6 +666,7 @@ Editor::embed_sndfiles (vector<string> paths,
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<AudioFileSource> source;
|
||||
|
@ -787,7 +783,7 @@ Editor::embed_sndfiles (vector<string> paths,
|
|||
}
|
||||
|
||||
if (!sources.empty()) {
|
||||
return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true, instrument);
|
||||
return add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, pgroup_id, true, instrument);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -802,6 +798,7 @@ Editor::add_sources (vector<string> paths,
|
|||
int target_regions,
|
||||
int target_tracks,
|
||||
boost::shared_ptr<Track>& track,
|
||||
std::string const& pgroup_id,
|
||||
bool /*add_channel_suffix*/,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
|
@ -998,7 +995,7 @@ Editor::add_sources (vector<string> paths,
|
|||
}
|
||||
}
|
||||
|
||||
finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], instrument);
|
||||
finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], pgroup_id, instrument);
|
||||
|
||||
rlen = (*r)->length();
|
||||
|
||||
|
@ -1030,7 +1027,8 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
|
|||
samplepos_t& pos,
|
||||
ImportMode mode,
|
||||
boost::shared_ptr<Track>& existing_track,
|
||||
const string& new_track_name,
|
||||
string const& new_track_name,
|
||||
string const& pgroup_id,
|
||||
ARDOUR::PluginInfoPtr instrument)
|
||||
{
|
||||
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(region);
|
||||
|
@ -1083,10 +1081,11 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
|
|||
if (at.empty()) {
|
||||
return -1;
|
||||
}
|
||||
if (Config->get_strict_io ()) {
|
||||
for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
|
||||
if (Config->get_strict_io ()) {
|
||||
(*i)->set_strict_io (true);
|
||||
}
|
||||
(*i)->playlist()->set_pgroup_id (pgroup_id);
|
||||
}
|
||||
|
||||
existing_track = at.front();
|
||||
|
@ -1105,7 +1104,13 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
|
|||
return -1;
|
||||
}
|
||||
|
||||
// TODO set strict_io from preferences
|
||||
for (list<boost::shared_ptr<MidiTrack> >::iterator i = mt.begin(); i != mt.end(); ++i) {
|
||||
if (Config->get_strict_io ()) {
|
||||
(*i)->set_strict_io (true);
|
||||
}
|
||||
(*i)->playlist()->set_pgroup_id (pgroup_id);
|
||||
}
|
||||
|
||||
existing_track = mt.front();
|
||||
}
|
||||
|
||||
|
|
|
@ -417,21 +417,19 @@ Editor::drop_paths_part_two (const vector<string>& paths, samplepos_t sample, do
|
|||
}
|
||||
}
|
||||
|
||||
string gid = Playlist::generate_pgroup_id();
|
||||
|
||||
std::pair<TimeAxisView*, int> const tvp = trackview_by_y_position (ypos, false);
|
||||
if (tvp.first == 0) {
|
||||
|
||||
/* drop onto canvas background: create new tracks */
|
||||
|
||||
InstrumentSelector is; // instantiation builds instrument-list and sets default.
|
||||
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, sample, gid, is.selected_instrument(), false);
|
||||
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, sample, is.selected_instrument(), false);
|
||||
|
||||
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
||||
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample, gid);
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample);
|
||||
} else {
|
||||
do_embed (audio_paths, Editing::ImportDistinctFiles, ImportAsTrack, sample, gid);
|
||||
do_embed (audio_paths, Editing::ImportDistinctFiles, ImportAsTrack, sample);
|
||||
}
|
||||
|
||||
} else if ((tv = dynamic_cast<RouteTimeAxisView*> (tvp.first)) != 0) {
|
||||
|
@ -443,13 +441,13 @@ Editor::drop_paths_part_two (const vector<string>& paths, samplepos_t sample, do
|
|||
selection->set (tv);
|
||||
|
||||
do_import (midi_paths, Editing::ImportSerializeFiles, ImportToTrack,
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample, gid);
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample);
|
||||
|
||||
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
|
||||
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample, gid, boost::shared_ptr<PluginInfo>(), false);
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, sample, boost::shared_ptr<PluginInfo>(), false);
|
||||
} else {
|
||||
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, sample, gid);
|
||||
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1026,17 +1026,15 @@ EditorRegions::drag_data_received (const RefPtr<Gdk::DragContext>& context,
|
|||
return;
|
||||
}
|
||||
|
||||
string gid = Playlist::generate_pgroup_id();
|
||||
|
||||
if (_editor->convert_drop_to_paths (paths, context, x, y, data, info, dtime) == 0) {
|
||||
samplepos_t pos = 0;
|
||||
bool copy = ((context->get_actions () & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY);
|
||||
|
||||
if (UIConfiguration::instance ().get_only_copy_imported_files () || copy) {
|
||||
_editor->do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion,
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, pos, gid);
|
||||
SrcBest, SMFTrackName, SMFTempoIgnore, pos);
|
||||
} else {
|
||||
_editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos, gid);
|
||||
_editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos);
|
||||
}
|
||||
context->drag_finish (true, false, dtime);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,8 @@ Editor::embed_audio_from_video (std::string path, samplepos_t n, bool lock_posit
|
|||
ipw.show ();
|
||||
|
||||
boost::shared_ptr<ARDOUR::Track> track;
|
||||
bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0);
|
||||
std::string const& gid = ARDOUR::Playlist::generate_pgroup_id ();
|
||||
bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, gid, false) == 0);
|
||||
if (ok && track) {
|
||||
if (lock_position_to_video) {
|
||||
boost::shared_ptr<ARDOUR::Playlist> pl = track->playlist();
|
||||
|
|
|
@ -261,11 +261,10 @@ public:
|
|||
|
||||
/** Import existing media */
|
||||
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality,
|
||||
ARDOUR::MidiTrackNameSource, ARDOUR::MidiTempoMapDisposition, samplepos_t&, std::string pgroup_id,
|
||||
ARDOUR::MidiTrackNameSource, ARDOUR::MidiTempoMapDisposition, samplepos_t&,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
|
||||
bool with_markers = false) = 0;
|
||||
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,
|
||||
samplepos_t&, std::string pgroup_id,
|
||||
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, samplepos_t&,
|
||||
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
|
||||
|
||||
/** Open main export dialog */
|
||||
|
|
|
@ -2098,12 +2098,10 @@ SoundFileOmega::do_something (int action)
|
|||
|
||||
_import_active = true;
|
||||
|
||||
string gid = Playlist::generate_pgroup_id();
|
||||
|
||||
if (copy_files_btn.get_active()) {
|
||||
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, gid, instrument, with_midi_markers);
|
||||
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument, with_midi_markers);
|
||||
} else {
|
||||
PublicEditor::instance().do_embed (paths, chns, mode, where, gid, instrument);
|
||||
PublicEditor::instance().do_embed (paths, chns, mode, where, instrument);
|
||||
}
|
||||
|
||||
_import_active = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user