diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 119ea3bc51..2145b24352 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -47,6 +47,7 @@ #include "ardour/region_factory.h" #include "ardour/source_factory.h" #include "ardour/session.h" +#include "ardour/smf_source.h" #include "pbd/memento_command.h" #include "ardour_ui.h" @@ -726,8 +727,9 @@ Editor::add_sources (vector paths, SourceList& sources, nframes64 } // kludge (for MIDI we're abusing "channel" for "track" here) - if (paths.front().rfind(".mid") != Glib::ustring::npos) + if (SMFSource::safe_midi_file_extension (paths.front())) { target_regions = -1; + } if (target_regions == 1) { diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 0f57ea0144..021e456bb4 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -169,8 +169,7 @@ get_paths_for_new_sources (const bool allow_replacing, const string& import_file for (uint n = 0; n < channels; ++n) { - const DataType type = (import_file_path.rfind(".mid") != string::npos) - ? DataType::MIDI : DataType::AUDIO; + const DataType type = SMFSource::safe_midi_file_extension (import_file_path) ? DataType::MIDI : DataType::AUDIO; std::string filepath = (type == DataType::MIDI) ? sdir.midi_path().to_string() : sdir.sound_path().to_string(); @@ -213,8 +212,7 @@ create_mono_sources_for_writing (const vector& new_paths, Session& sess, try { - const DataType type = ((*i).rfind(".mid") != string::npos) - ? DataType::MIDI : DataType::AUDIO; + const DataType type = SMFSource::safe_midi_file_extension (*i) ? DataType::MIDI : DataType::AUDIO; source = SourceFactory::createWritable (type, sess, @@ -453,8 +451,7 @@ Session::import_audiofiles (ImportStatus& status) { boost::shared_ptr source; std::auto_ptr smf_reader; - const DataType type = ((*p).rfind(".mid") != string::npos) ? - DataType::MIDI : DataType::AUDIO; + const DataType type = SMFSource::safe_midi_file_extension (*p) ? DataType::MIDI : DataType::AUDIO; if (type == DataType::AUDIO) { try {