mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 17:46:34 +01:00
first part of using appropriate .ext extensions for the current chosen native file header format
git-svn-id: svn://localhost/ardour2/branches/3.0@7468 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
448eb1acdd
commit
a1bbbcb41b
8 changed files with 68 additions and 31 deletions
|
|
@ -54,7 +54,7 @@ namespace ARDOUR {
|
||||||
int cleanup ();
|
int cleanup ();
|
||||||
bool no_auto_connect ();
|
bool no_auto_connect ();
|
||||||
void make_property_quarks ();
|
void make_property_quarks ();
|
||||||
|
|
||||||
extern PBD::PropertyChange bounds_change;
|
extern PBD::PropertyChange bounds_change;
|
||||||
|
|
||||||
std::string get_ardour_revision ();
|
std::string get_ardour_revision ();
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||||
|
|
||||||
Glib::ustring peak_path (Glib::ustring) const;
|
Glib::ustring peak_path (Glib::ustring) const;
|
||||||
|
|
||||||
static std::string change_source_path_by_name (std::string oldpath, std::string oldname, std::string newname, bool destructive);
|
std::string change_source_path_by_name (std::string oldpath, std::string oldname, std::string newname, bool destructive);
|
||||||
|
|
||||||
std::string peak_path_from_audio_path (std::string) const;
|
std::string peak_path_from_audio_path (std::string) const;
|
||||||
std::string new_audio_source_name (const std::string&, uint32_t nchans, uint32_t chan, bool destructive);
|
std::string new_audio_source_name (const std::string&, uint32_t nchans, uint32_t chan, bool destructive);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@
|
||||||
|
|
||||||
bool string_is_affirmative (const std::string&);
|
bool string_is_affirmative (const std::string&);
|
||||||
|
|
||||||
#include "ardour.h"
|
#include "ardour/ardour.h"
|
||||||
|
#include "ardour/data_type.h"
|
||||||
|
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
|
|
@ -103,6 +104,8 @@ float meter_falloff_to_float (ARDOUR::MeterFalloff);
|
||||||
ARDOUR::MeterFalloff meter_falloff_from_float (float);
|
ARDOUR::MeterFalloff meter_falloff_from_float (float);
|
||||||
float meter_falloff_to_db_per_sec (float);
|
float meter_falloff_to_db_per_sec (float);
|
||||||
|
|
||||||
|
const char* native_header_format_extension (ARDOUR::HeaderFormat, const ARDOUR::DataType& type);
|
||||||
|
|
||||||
#if defined(HAVE_COREAUDIO) || defined(HAVE_AUDIOUNITS)
|
#if defined(HAVE_COREAUDIO) || defined(HAVE_AUDIOUNITS)
|
||||||
std::string CFStringRefToStdString(CFStringRef stringRef);
|
std::string CFStringRefToStdString(CFStringRef stringRef);
|
||||||
#endif // HAVE_COREAUDIO
|
#endif // HAVE_COREAUDIO
|
||||||
|
|
|
||||||
|
|
@ -383,7 +383,7 @@ FileSource::set_source_name (const ustring& newname, bool destructive)
|
||||||
{
|
{
|
||||||
Glib::Mutex::Lock lm (_lock);
|
Glib::Mutex::Lock lm (_lock);
|
||||||
ustring oldpath = _path;
|
ustring oldpath = _path;
|
||||||
ustring newpath = Session::change_source_path_by_name (oldpath, _name, newname, destructive);
|
ustring newpath = _session.change_source_path_by_name (oldpath, _name, newname, destructive);
|
||||||
|
|
||||||
if (newpath.empty()) {
|
if (newpath.empty()) {
|
||||||
error << string_compose (_("programming error: %1"), "cannot generate a changed file path") << endmsg;
|
error << string_compose (_("programming error: %1"), "cannot generate a changed file path") << endmsg;
|
||||||
|
|
|
||||||
|
|
@ -117,25 +117,25 @@ open_importable_source (const string& path, nframes_t samplerate, ARDOUR::SrcQua
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string
|
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];
|
char buf[PATH_MAX+1];
|
||||||
bool goodfile = false;
|
bool goodfile = false;
|
||||||
string base(basename);
|
string base(basename);
|
||||||
const char* ext = (type == DataType::AUDIO) ? "wav" : "mid";
|
string ext = native_header_format_extension (hf, type);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (type == DataType::AUDIO && channels == 2) {
|
if (type == DataType::AUDIO && channels == 2) {
|
||||||
if (channel == 0) {
|
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 {
|
} 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) {
|
} 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 {
|
} else {
|
||||||
snprintf (buf, sizeof(buf), "%s.%s", base.c_str(), ext);
|
snprintf (buf, sizeof(buf), "%s%s", base.c_str(), ext.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ get_non_existent_filename (DataType type, const bool allow_replacing, const std:
|
||||||
}
|
}
|
||||||
|
|
||||||
static vector<string>
|
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;
|
vector<string> new_paths;
|
||||||
const string basename = basename_nosuffix (import_file_path);
|
const string basename = basename_nosuffix (import_file_path);
|
||||||
|
|
@ -175,7 +175,7 @@ get_paths_for_new_sources (const bool allow_replacing, const string& import_file
|
||||||
? sdir.midi_path().to_string() : sdir.sound_path().to_string();
|
? sdir.midi_path().to_string() : sdir.sound_path().to_string();
|
||||||
|
|
||||||
filepath += '/';
|
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);
|
new_paths.push_back (filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -478,7 +478,8 @@ Session::import_audiofiles (ImportStatus& status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (),
|
get_best_session_directory_for_new_source (),
|
||||||
channels);
|
channels);
|
||||||
Sources newfiles;
|
Sources newfiles;
|
||||||
|
|
|
||||||
|
|
@ -2695,7 +2695,7 @@ Session::change_source_path_by_name (string path, string oldname, string newname
|
||||||
path += prefix;
|
path += prefix;
|
||||||
path += '-';
|
path += '-';
|
||||||
path += new_legalized;
|
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);
|
path = Glib::build_filename (dir, path);
|
||||||
|
|
||||||
|
|
@ -2805,6 +2805,7 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
|
||||||
char buf[PATH_MAX+1];
|
char buf[PATH_MAX+1];
|
||||||
const uint32_t limit = 10000;
|
const uint32_t limit = 10000;
|
||||||
string legalized;
|
string legalized;
|
||||||
|
string ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
legalized = legalize_for_path (base);
|
legalized = legalize_for_path (base);
|
||||||
|
|
@ -2824,22 +2825,22 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
|
||||||
if (destructive) {
|
if (destructive) {
|
||||||
|
|
||||||
if (nchan < 2) {
|
if (nchan < 2) {
|
||||||
snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav",
|
snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
|
||||||
spath.c_str(), cnt, legalized.c_str());
|
spath.c_str(), cnt, legalized.c_str(), ext.c_str());
|
||||||
} else if (nchan == 2) {
|
} else if (nchan == 2) {
|
||||||
if (chan == 0) {
|
if (chan == 0) {
|
||||||
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%L.wav",
|
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%L%s",
|
||||||
spath.c_str(), cnt, legalized.c_str());
|
spath.c_str(), cnt, legalized.c_str(), ext.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%R.wav",
|
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%R%s",
|
||||||
spath.c_str(), cnt, legalized.c_str());
|
spath.c_str(), cnt, legalized.c_str(), ext.c_str());
|
||||||
}
|
}
|
||||||
} else if (nchan < 26) {
|
} else if (nchan < 26) {
|
||||||
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%%c.wav",
|
snprintf (buf, sizeof(buf), "%s/T%04d-%s%%%c%s",
|
||||||
spath.c_str(), cnt, legalized.c_str(), 'a' + chan);
|
spath.c_str(), cnt, legalized.c_str(), 'a' + chan, ext.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf (buf, sizeof(buf), "%s/T%04d-%s.wav",
|
snprintf (buf, sizeof(buf), "%s/T%04d-%s%s",
|
||||||
spath.c_str(), cnt, legalized.c_str());
|
spath.c_str(), cnt, legalized.c_str(), ext.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2848,17 +2849,17 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
|
||||||
spath += legalized;
|
spath += legalized;
|
||||||
|
|
||||||
if (nchan < 2) {
|
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) {
|
} else if (nchan == 2) {
|
||||||
if (chan == 0) {
|
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 {
|
} 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) {
|
} 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 {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3468,6 +3469,7 @@ Session::write_one_track (AudioTrack& track, nframes_t start, nframes_t end,
|
||||||
SessionDirectory sdir(get_best_session_directory_for_new_source ());
|
SessionDirectory sdir(get_best_session_directory_for_new_source ());
|
||||||
const string sound_dir = sdir.sound_path().to_string();
|
const string sound_dir = sdir.sound_path().to_string();
|
||||||
nframes_t len = end - start;
|
nframes_t len = end - start;
|
||||||
|
string ext;
|
||||||
|
|
||||||
if (end <= start) {
|
if (end <= start) {
|
||||||
error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
|
error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
|
||||||
|
|
@ -3493,10 +3495,12 @@ Session::write_one_track (AudioTrack& track, nframes_t start, nframes_t end,
|
||||||
goto out;
|
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 (uint32_t chan_n=0; chan_n < nchans.n_audio(); ++chan_n) {
|
||||||
|
|
||||||
for (x = 0; x < 99999; ++x) {
|
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) {
|
if (access (buf, F_OK) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1832,7 +1832,7 @@ Session::path_from_region_name (DataType type, string name, string identifier)
|
||||||
sys::path source_dir = ((type == DataType::AUDIO)
|
sys::path source_dir = ((type == DataType::AUDIO)
|
||||||
? sdir.sound_path() : sdir.midi_path());
|
? sdir.sound_path() : sdir.midi_path());
|
||||||
|
|
||||||
string ext = ((type == DataType::AUDIO) ? ".wav" : ".mid");
|
string ext = native_header_format_extension (config.get_native_file_header_format(), type);
|
||||||
|
|
||||||
for (n = 0; n < 999999; ++n) {
|
for (n = 0; n < 999999; ++n) {
|
||||||
if (identifier.length()) {
|
if (identifier.length()) {
|
||||||
|
|
|
||||||
|
|
@ -509,6 +509,35 @@ string_is_affirmative (const std::string& str)
|
||||||
return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length()));
|
return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
native_header_format_extension (HeaderFormat hf, const DataType& type)
|
||||||
|
{
|
||||||
|
if (type == DataType::MIDI) {
|
||||||
|
return ".mid";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (hf) {
|
||||||
|
case BWF:
|
||||||
|
return ".wav";
|
||||||
|
case WAVE:
|
||||||
|
return ".wav";
|
||||||
|
case WAVE64:
|
||||||
|
return ".w64";
|
||||||
|
case CAF:
|
||||||
|
return ".caf";
|
||||||
|
case AIFF:
|
||||||
|
return ".aif";
|
||||||
|
case iXML:
|
||||||
|
return ".ixml";
|
||||||
|
case RF64:
|
||||||
|
return ".rf64";
|
||||||
|
}
|
||||||
|
|
||||||
|
fatal << string_compose (_("programming error: unknown native header format: %1"), hf);
|
||||||
|
/*NOTREACHED*/
|
||||||
|
return ".wav";
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void c_stacktrace() { stacktrace (cerr); }
|
void c_stacktrace() { stacktrace (cerr); }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue