fix #5609 (import with 1 track per channel mis-associates tracks + channels)
when using ImportDistinctChannels, correctly name regions so that playlists for each channel/track are also named differently, and thus reloaded properly when the session is reloaded.
This commit is contained in:
parent
59b18de1d3
commit
c222acecaa
|
@ -1215,13 +1215,17 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
bool idle_drop_paths (std::vector<std::string> paths, framepos_t frame, double ypos, bool copy);
|
bool idle_drop_paths (std::vector<std::string> paths, framepos_t frame, double ypos, bool copy);
|
||||||
void drop_paths_part_two (const std::vector<std::string>& paths, framepos_t frame, double ypos, bool copy);
|
void drop_paths_part_two (const std::vector<std::string>& paths, framepos_t frame, double ypos, bool copy);
|
||||||
|
|
||||||
int import_sndfiles (std::vector<std::string> paths, Editing::ImportMode mode, ARDOUR::SrcQuality, framepos_t& pos,
|
int import_sndfiles (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode,
|
||||||
|
ARDOUR::SrcQuality, framepos_t& pos,
|
||||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
|
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
|
||||||
int embed_sndfiles (std::vector<std::string> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
|
int embed_sndfiles (std::vector<std::string> paths, bool multiple_files, bool& check_sample_rate,
|
||||||
|
Editing::ImportDisposition disposition, Editing::ImportMode mode,
|
||||||
framepos_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
|
framepos_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
|
||||||
|
|
||||||
int add_sources (std::vector<std::string> paths, ARDOUR::SourceList& sources, framepos_t& pos, Editing::ImportMode,
|
int add_sources (std::vector<std::string> paths, ARDOUR::SourceList& sources, framepos_t& pos,
|
||||||
|
Editing::ImportDisposition, Editing::ImportMode,
|
||||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
|
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool add_channel_suffix);
|
||||||
|
|
||||||
int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t, framepos_t& pos, Editing::ImportMode mode,
|
int finish_bringing_in_material (boost::shared_ptr<ARDOUR::Region> region, uint32_t, uint32_t, framepos_t& pos, Editing::ImportMode mode,
|
||||||
boost::shared_ptr<ARDOUR::Track>& existing_track);
|
boost::shared_ptr<ARDOUR::Track>& existing_track);
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ Editor::get_nth_selected_midi_track (int nth) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode, SrcQuality quality, framepos_t& pos)
|
Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMode mode, SrcQuality quality, framepos_t& pos)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Track> track;
|
boost::shared_ptr<Track> track;
|
||||||
vector<string> to_import;
|
vector<string> to_import;
|
||||||
|
@ -280,7 +280,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
|
||||||
if (chns == Editing::ImportMergeFiles) {
|
if (disposition == Editing::ImportMergeFiles) {
|
||||||
|
|
||||||
/* create 1 region from all paths, add to 1 track,
|
/* create 1 region from all paths, add to 1 track,
|
||||||
ignore "track"
|
ignore "track"
|
||||||
|
@ -299,7 +299,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
ok = false;
|
ok = false;
|
||||||
} else {
|
} else {
|
||||||
ipw.show ();
|
ipw.show ();
|
||||||
ok = (import_sndfiles (paths, mode, quality, pos, 1, 1, track, false) == 0);
|
ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -334,7 +334,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
|
|
||||||
ipw.show ();
|
ipw.show ();
|
||||||
|
|
||||||
switch (chns) {
|
switch (disposition) {
|
||||||
case Editing::ImportDistinctFiles:
|
case Editing::ImportDistinctFiles:
|
||||||
|
|
||||||
to_import.clear ();
|
to_import.clear ();
|
||||||
|
@ -344,7 +344,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
track = get_nth_selected_audio_track (nth++);
|
track = get_nth_selected_audio_track (nth++);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, -1, track, replace) == 0);
|
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace) == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Editing::ImportDistinctChannels:
|
case Editing::ImportDistinctChannels:
|
||||||
|
@ -352,7 +352,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
to_import.clear ();
|
to_import.clear ();
|
||||||
to_import.push_back (*a);
|
to_import.push_back (*a);
|
||||||
|
|
||||||
ok = (import_sndfiles (to_import, mode, quality, pos, -1, -1, track, replace) == 0);
|
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace) == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Editing::ImportSerializeFiles:
|
case Editing::ImportSerializeFiles:
|
||||||
|
@ -360,7 +360,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
to_import.clear ();
|
to_import.clear ();
|
||||||
to_import.push_back (*a);
|
to_import.push_back (*a);
|
||||||
|
|
||||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, 1, track, replace) == 0);
|
ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace) == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Editing::ImportMergeFiles:
|
case Editing::ImportMergeFiles:
|
||||||
|
@ -378,7 +378,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode, framepos_t& pos)
|
Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, framepos_t& pos)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Track> track;
|
boost::shared_ptr<Track> track;
|
||||||
bool check_sample_rate = true;
|
bool check_sample_rate = true;
|
||||||
|
@ -388,7 +388,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode,
|
||||||
int nth = 0;
|
int nth = 0;
|
||||||
bool use_timestamp = (pos == -1);
|
bool use_timestamp = (pos == -1);
|
||||||
|
|
||||||
switch (chns) {
|
switch (import_as) {
|
||||||
case Editing::ImportDistinctFiles:
|
case Editing::ImportDistinctFiles:
|
||||||
for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
|
for (vector<string>::iterator a = paths.begin(); a != paths.end(); ++a) {
|
||||||
|
|
||||||
|
@ -404,7 +404,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode,
|
||||||
track = get_nth_selected_audio_track (nth++);
|
track = get_nth_selected_audio_track (nth++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, 1, -1, track) < -1) {
|
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, -1, track) < -1) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,14 +421,14 @@ Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode,
|
||||||
to_embed.clear ();
|
to_embed.clear ();
|
||||||
to_embed.push_back (*a);
|
to_embed.push_back (*a);
|
||||||
|
|
||||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, -1, -1, track) < -1) {
|
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, -1, -1, track) < -1) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Editing::ImportMergeFiles:
|
case Editing::ImportMergeFiles:
|
||||||
if (embed_sndfiles (paths, multi, check_sample_rate, mode, pos, 1, 1, track) < -1) {
|
if (embed_sndfiles (paths, multi, check_sample_rate, import_as, mode, pos, 1, 1, track) < -1) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -444,7 +444,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode,
|
||||||
to_embed.clear ();
|
to_embed.clear ();
|
||||||
to_embed.push_back (*a);
|
to_embed.push_back (*a);
|
||||||
|
|
||||||
if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, 1, 1, track) < -1) {
|
if (embed_sndfiles (to_embed, multi, check_sample_rate, import_as, mode, pos, 1, 1, track) < -1) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ Editor::do_embed (vector<string> paths, ImportDisposition chns, ImportMode mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quality, framepos_t& pos,
|
Editor::import_sndfiles (vector<string> paths, ImportDisposition disposition, ImportMode mode, SrcQuality quality, framepos_t& pos,
|
||||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
|
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
|
||||||
{
|
{
|
||||||
import_status.paths = paths;
|
import_status.paths = paths;
|
||||||
|
@ -501,6 +501,7 @@ Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quali
|
||||||
import_status.paths,
|
import_status.paths,
|
||||||
import_status.sources,
|
import_status.sources,
|
||||||
import_status.pos,
|
import_status.pos,
|
||||||
|
disposition,
|
||||||
import_status.mode,
|
import_status.mode,
|
||||||
import_status.target_regions,
|
import_status.target_regions,
|
||||||
import_status.target_tracks,
|
import_status.target_tracks,
|
||||||
|
@ -518,7 +519,8 @@ Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quali
|
||||||
|
|
||||||
int
|
int
|
||||||
Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||||
bool& check_sample_rate, ImportMode mode, framepos_t& pos, int target_regions, int target_tracks,
|
bool& check_sample_rate, ImportDisposition disposition, ImportMode mode,
|
||||||
|
framepos_t& pos, int target_regions, int target_tracks,
|
||||||
boost::shared_ptr<Track>& track)
|
boost::shared_ptr<Track>& track)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<AudioFileSource> source;
|
boost::shared_ptr<AudioFileSource> source;
|
||||||
|
@ -603,6 +605,7 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||||
set_canvas_cursor (_cursors->wait);
|
set_canvas_cursor (_cursors->wait);
|
||||||
|
|
||||||
for (int n = 0; n < finfo.channels; ++n) {
|
for (int n = 0; n < finfo.channels; ++n) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/* check if we have this thing embedded already */
|
/* check if we have this thing embedded already */
|
||||||
|
@ -613,7 +616,7 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||||
|
|
||||||
source = boost::dynamic_pointer_cast<AudioFileSource> (
|
source = boost::dynamic_pointer_cast<AudioFileSource> (
|
||||||
SourceFactory::createExternal (DataType::AUDIO, *_session,
|
SourceFactory::createExternal (DataType::AUDIO, *_session,
|
||||||
path, n,
|
path, n,
|
||||||
(mode == ImportAsTapeTrack
|
(mode == ImportAsTapeTrack
|
||||||
? Source::Destructive
|
? Source::Destructive
|
||||||
: Source::Flag (0)),
|
: Source::Flag (0)),
|
||||||
|
@ -638,7 +641,8 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = add_sources (paths, sources, pos, mode, target_regions, target_tracks, track, true);
|
|
||||||
|
ret = add_sources (paths, sources, pos, disposition, mode, target_regions, target_tracks, track, true);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
set_canvas_cursor (current_canvas_cursor);
|
set_canvas_cursor (current_canvas_cursor);
|
||||||
|
@ -646,7 +650,7 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos, ImportMode mode,
|
Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos, ImportDisposition disposition, ImportMode mode,
|
||||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool /*add_channel_suffix*/)
|
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool /*add_channel_suffix*/)
|
||||||
{
|
{
|
||||||
vector<boost::shared_ptr<Region> > regions;
|
vector<boost::shared_ptr<Region> > regions;
|
||||||
|
@ -654,7 +658,7 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
|
||||||
uint32_t input_chan = 0;
|
uint32_t input_chan = 0;
|
||||||
uint32_t output_chan = 0;
|
uint32_t output_chan = 0;
|
||||||
bool use_timestamp;
|
bool use_timestamp;
|
||||||
|
|
||||||
use_timestamp = (pos == -1);
|
use_timestamp = (pos == -1);
|
||||||
|
|
||||||
// kludge (for MIDI we're abusing "channel" for "track" here)
|
// kludge (for MIDI we're abusing "channel" for "track" here)
|
||||||
|
@ -707,10 +711,43 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
|
||||||
|
|
||||||
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (*x);
|
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (*x);
|
||||||
|
|
||||||
if (fs) {
|
if (sources.size() > 1 && disposition == ImportDistinctChannels) {
|
||||||
region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
|
|
||||||
} else{
|
/* generate a per-channel region name so that things work as
|
||||||
region_name = (*x)->name();
|
* intended
|
||||||
|
*/
|
||||||
|
|
||||||
|
string path;
|
||||||
|
|
||||||
|
if (fs) {
|
||||||
|
region_name = basename_nosuffix (fs->path());
|
||||||
|
} else {
|
||||||
|
region_name = (*x)->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (sources.size()) {
|
||||||
|
/* zero and one channel handled
|
||||||
|
by previous if() condition
|
||||||
|
*/
|
||||||
|
case 2:
|
||||||
|
if (n == 0) {
|
||||||
|
region_name += "-L";
|
||||||
|
} else {
|
||||||
|
region_name += "-R";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
region_name += (char) '-';
|
||||||
|
region_name += (char) ('1' + n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (fs) {
|
||||||
|
region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
|
||||||
|
} else{
|
||||||
|
region_name = (*x)->name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyList plist;
|
PropertyList plist;
|
||||||
|
|
|
@ -96,7 +96,7 @@ Editor::embed_audio_from_video (std::string path, framepos_t n)
|
||||||
ipw.show ();
|
ipw.show ();
|
||||||
|
|
||||||
boost::shared_ptr<ARDOUR::Track> track;
|
boost::shared_ptr<ARDOUR::Track> track;
|
||||||
bool ok = (import_sndfiles (paths, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0);
|
bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0);
|
||||||
if (ok && track) {
|
if (ok && track) {
|
||||||
boost::shared_ptr<ARDOUR::Playlist> pl = track->playlist();
|
boost::shared_ptr<ARDOUR::Playlist> pl = track->playlist();
|
||||||
pl->find_next_region(n, ARDOUR::End, 0)->set_video_locked(true);
|
pl->find_next_region(n, ARDOUR::End, 0)->set_video_locked(true);
|
||||||
|
|
|
@ -342,7 +342,8 @@ SoundFileBox::audition ()
|
||||||
try {
|
try {
|
||||||
afs = boost::dynamic_pointer_cast<AudioFileSource> (
|
afs = boost::dynamic_pointer_cast<AudioFileSource> (
|
||||||
SourceFactory::createExternal (DataType::AUDIO, *_session,
|
SourceFactory::createExternal (DataType::AUDIO, *_session,
|
||||||
path, n, Source::Flag (0), false));
|
path, n,
|
||||||
|
Source::Flag (0), false));
|
||||||
|
|
||||||
srclist.push_back(afs);
|
srclist.push_back(afs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user