}
static std::string
-get_non_existent_filename (DataType type, const bool allow_replacing, const std::string& destdir, const std::string& basename, uint channel, uint channels)
+get_non_existent_filename (HeaderFormat hf, DataType type, const bool allow_replacing, const std::string& destdir, const std::string& basename, uint channel, uint channels)
{
char buf[PATH_MAX+1];
bool goodfile = false;
string base(basename);
- const char* ext = (type == DataType::AUDIO) ? "wav" : "mid";
+ string ext = native_header_format_extension (hf, type);
do {
if (type == DataType::AUDIO && channels == 2) {
if (channel == 0) {
- snprintf (buf, sizeof(buf), "%s-L.wav", base.c_str());
+ snprintf (buf, sizeof(buf), "%s-L%s", base.c_str(), ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s-R.wav", base.c_str());
+ snprintf (buf, sizeof(buf), "%s-R%s", base.c_str(), ext.c_str());
}
} else if (channels > 1) {
- snprintf (buf, sizeof(buf), "%s-c%d.%s", base.c_str(), channel, ext);
+ snprintf (buf, sizeof(buf), "%s-c%d%s", base.c_str(), channel, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s.%s", base.c_str(), ext);
+ snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str());
}
}
static vector<string>
-get_paths_for_new_sources (const bool allow_replacing, const string& import_file_path, const string& session_dir, uint channels)
+get_paths_for_new_sources (HeaderFormat hf, const bool allow_replacing, const string& import_file_path, const string& session_dir, uint channels)
{
vector<string> new_paths;
const string basename = basename_nosuffix (import_file_path);
? sdir.midi_path().to_string() : sdir.sound_path().to_string();
filepath += '/';
- filepath += get_non_existent_filename (type, allow_replacing, filepath, basename, n, channels);
+ filepath += get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels);
new_paths.push_back (filepath);
}
}
}
- vector<string> new_paths = get_paths_for_new_sources (status.replace_existing_source, *p,
+ vector<string> new_paths = get_paths_for_new_sources (config.get_native_file_header_format(),
+ status.replace_existing_source, *p,
get_best_session_directory_for_new_source (),
channels);
Sources newfiles;
path += prefix;
path += '-';
path += new_legalized;
- path += ".wav"; /* XXX gag me with a spoon */
+ path += native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
path = Glib::build_filename (dir, path);
char buf[PATH_MAX+1];
const uint32_t limit = 10000;
string legalized;
+ string ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
buf[0] = '\0';
legalized = legalize_for_path (base);
if (destructive) {
if (nchan < 2) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav",
- spath.c_str(), cnt, legalized.c_str());
+ snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
+ spath.c_str(), cnt, legalized.c_str(), ext.c_str());
} else if (nchan == 2) {
if (chan == 0) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%L.wav",
- spath.c_str(), cnt, legalized.c_str());
+ snprintf (buf, sizeof(buf), "%s/T%04d-%s%%L%s",
+ spath.c_str(), cnt, legalized.c_str(), ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%R.wav",
- spath.c_str(), cnt, legalized.c_str());
+ snprintf (buf, sizeof(buf), "%s/T%04d-%s%%R%s",
+ spath.c_str(), cnt, legalized.c_str(), ext.c_str());
}
} else if (nchan < 26) {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s%%%c.wav",
- spath.c_str(), cnt, legalized.c_str(), 'a' + chan);
+ snprintf (buf, sizeof(buf), "%s/T%04d-%s%%%c%s",
+ spath.c_str(), cnt, legalized.c_str(), 'a' + chan, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav",
- spath.c_str(), cnt, legalized.c_str());
+ snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
+ spath.c_str(), cnt, legalized.c_str(), ext.c_str());
}
} else {
spath += legalized;
if (nchan < 2) {
- snprintf (buf, sizeof(buf), "%s-%u.wav", spath.c_str(), cnt);
+ snprintf (buf, sizeof(buf), "%s-%u%s", spath.c_str(), cnt, ext.c_str());
} else if (nchan == 2) {
if (chan == 0) {
- snprintf (buf, sizeof(buf), "%s-%u%%L.wav", spath.c_str(), cnt);
+ snprintf (buf, sizeof(buf), "%s-%u%%L%s", spath.c_str(), cnt, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s-%u%%R.wav", spath.c_str(), cnt);
+ snprintf (buf, sizeof(buf), "%s-%u%%R%s", spath.c_str(), cnt, ext.c_str());
}
} else if (nchan < 26) {
- snprintf (buf, sizeof(buf), "%s-%u%%%c.wav", spath.c_str(), cnt, 'a' + chan);
+ snprintf (buf, sizeof(buf), "%s-%u%%%c%s", spath.c_str(), cnt, 'a' + chan, ext.c_str());
} else {
- snprintf (buf, sizeof(buf), "%s-%u.wav", spath.c_str(), cnt);
+ snprintf (buf, sizeof(buf), "%s-%u%s", spath.c_str(), cnt, ext.c_str());
}
}
SessionDirectory sdir(get_best_session_directory_for_new_source ());
const string sound_dir = sdir.sound_path().to_string();
nframes_t len = end - start;
+ string ext;
if (end <= start) {
error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
goto out;
}
+ ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
+
for (uint32_t chan_n=0; chan_n < nchans.n_audio(); ++chan_n) {
for (x = 0; x < 99999; ++x) {
- snprintf (buf, sizeof(buf), "%s/%s-%d-bounce-%" PRIu32 ".wav", sound_dir.c_str(), playlist->name().c_str(), chan_n, x+1);
+ snprintf (buf, sizeof(buf), "%s/%s-%d-bounce-%" PRIu32 "%s", sound_dir.c_str(), playlist->name().c_str(), chan_n, x+1, ext.c_str());
if (access (buf, F_OK) != 0) {
break;
}