diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index cb16cb3c5e..ebf15513a2 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -299,7 +299,7 @@ public: RouteList new_route_from_template (uint32_t how_many, PresentationInfo::order_t insert_at, const std::string& template_path, const std::string& name, PlaylistDisposition pd = NewPlaylist); RouteList new_route_from_template (uint32_t how_many, PresentationInfo::order_t insert_at, XMLNode&, const std::string& name, PlaylistDisposition pd = NewPlaylist); std::vector get_paths_for_new_sources (bool allow_replacing, const std::string& import_file_path, - uint32_t channels, std::vector const & smf_track_names); + uint32_t channels, std::vector const & smf_track_names, bool use_smf_file_names); int bring_all_sources_into_session (boost::function callback); diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 13103f0584..5e20adc914 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -854,6 +854,7 @@ enum PlaylistDisposition { enum MidiTrackNameSource { SMFTrackNumber, SMFTrackName, + SMFFileAndTrackName, SMFInstrumentName }; diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 2759179990..640aa7ee64 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -144,7 +144,7 @@ open_importable_source (const string& path, samplecnt_t samplerate, ARDOUR::SrcQ vector Session::get_paths_for_new_sources (bool /*allow_replacing*/, const string& import_file_path, uint32_t channels, - vector const & smf_names) + vector const & smf_names, bool use_smf_file_names) { vector new_paths; @@ -159,8 +159,12 @@ Session::get_paths_for_new_sources (bool /*allow_replacing*/, const string& impo case DataType::MIDI: if (channels > 1) { assert (smf_names.size() == channels); - string mchn_name = string_compose ("%1.%2", basename, smf_names[n]); - filepath = new_midi_source_path (mchn_name); + if (use_smf_file_names) { + string mchn_name = string_compose ("%1.%2", basename, smf_names[n]); + filepath = new_midi_source_path (mchn_name); + } else { + filepath = new_midi_source_path (smf_names[n]); + } } else { filepath = new_midi_source_path (basename); } @@ -552,7 +556,7 @@ Session::deinterlace_midi_region (std::shared_ptr mr) for (int i = 0; i<16; i++) { smf_names.push_back(string_compose("-ch%1", i+1)); } - vector new_paths = get_paths_for_new_sources (false, source_path, 16, smf_names); + vector new_paths = get_paths_for_new_sources (false, source_path, 16, smf_names, true); /* create source files and write 1 channel of midi data to each of them */ if (create_mono_sources_for_writing (new_paths, *this, sample_rate(), newfiles, 0, false)) { @@ -635,6 +639,7 @@ Session::import_files (ImportStatus& status) std::shared_ptr smfs; uint32_t num_channels = 0; vector smf_names; + bool smf_keep_filename = false; status.sources.clear (); @@ -689,6 +694,9 @@ Session::import_files (ImportStatus& status) } } break; + case SMFFileAndTrackName: + smf_keep_filename = true; + /*FALLTHRU*/ case SMFTrackName: if (status.split_midi_channels) { vector temp; @@ -728,7 +736,7 @@ Session::import_files (ImportStatus& status) continue; } - vector new_paths = get_paths_for_new_sources (status.replace_existing_source, *p, num_channels, smf_names); + vector new_paths = get_paths_for_new_sources (status.replace_existing_source, *p, num_channels, smf_names, smf_keep_filename); Sources newfiles; samplepos_t natural_position = source ? source->natural_position() : 0; diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 73af0af10d..5a6dc3b772 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -2571,6 +2571,7 @@ LuaBindings::common (lua_State* L) .beginNamespace ("MidiTrackNameSource") .addConst ("SMFTrackNumber", ARDOUR::MidiTrackNameSource(SMFTrackNumber)) .addConst ("SMFTrackName", ARDOUR::MidiTrackNameSource(SMFTrackName)) + .addConst ("SMFFileAndTrackName", ARDOUR::MidiTrackNameSource(SMFFileAndTrackName)) .addConst ("SMFInstrumentName", ARDOUR::MidiTrackNameSource(SMFInstrumentName)) .endNamespace ()