21 #include "libardour-config.h"
35 #include <sys/types.h>
45 #include <glibmm/miscutils.h>
46 #include <glibmm/fileutils.h>
56 #include "ardour/utils.h"
68 string::size_type pos;
78 while ((pos = legal.find_first_of (illegal_chars, pos)) != string::npos) {
79 legal.replace (pos, 1,
"_");
83 return string (legal);
138 string::size_type pos;
139 string legal_chars =
"abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
149 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
150 legal.replace (pos, 1,
"_");
154 return string (legal);
160 string::size_type delim;
163 if ((delim = name.find_last_of (delimiter)) == string::npos) {
165 newname += delimiter;
169 const char *last_element = name.c_str() + delim + 1;
170 for (
size_t i = 0; i < strlen(last_element); i++) {
171 if (!isdigit(last_element[i])) {
178 int32_t version = strtol (name.c_str()+delim+1, (
char **)NULL, 10);
180 if (isnumber == 0 || errno != 0) {
183 newname += delimiter;
188 snprintf (buf,
sizeof(buf),
"%d", version+1);
190 newname = name.substr (0, delim+1);
202 size_t pos = name.length();
204 bool have_number =
false;
205 while (pos > 0 && isdigit(name.at(--pos))) {
212 int32_t seq = strtol (name.c_str() + num, (
char **)NULL, 10);
214 snprintf (buf,
sizeof(buf),
"%d", seq + 1);
215 newname = name.substr (0, num);
234 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
249 string::const_iterator p = s.begin();
250 string::const_iterator p2 = s2.begin();
252 while (p != s.end() && p2 != s2.end()) {
253 if (toupper(*p) != toupper(*p2)) {
254 return (toupper(*p) < toupper(*p2)) ? -1 : 1;
260 return (s2.size() == s.size()) ? 0 : (s.size() < s2.size()) ? -1 : 1;
266 const char *cstr1 = s1.c_str();
267 const char *cstr2 = s2.c_str();
268 gchar *cstr1folded = NULL;
269 gchar *cstr2folded = NULL;
272 if (!g_utf8_validate (cstr1, -1, NULL) ||
273 !g_utf8_validate (cstr2, -1, NULL)) {
275 return g_ascii_strcasecmp (cstr1, cstr2);
278 cstr1folded = g_utf8_casefold (cstr1, -1);
279 cstr2folded = g_utf8_casefold (cstr2, -1);
281 if (cstr1folded && cstr2folded) {
282 retval = strcmp (cstr1folded, cstr2folded);
285 retval = g_ascii_strcasecmp (cstr1, cstr2);
289 g_free (cstr1folded);
293 g_free (cstr2folded);
302 int fd = open (path.c_str(), O_RDWR|O_CREAT, 0660);
315 if (strip_channels) {
319 string::size_type len = path.length();
321 if (len > 3 && (path[len-2] ==
'%' || path[len-2] ==
'?' || path[len-2] ==
'.') &&
322 (path[len-1] ==
'R' || path[len-1] ==
'L' || (islower (path[len-1])))) {
324 path = path.substr (0, path.length() - 2);
328 if (add_channel_suffix) {
333 path += (char) (
'a' + this_one);
335 path += (char) (this_one == 0 ?
'L' :
'R');
345 string::size_type pos;
349 if ((pos = path.find_last_of (G_DIR_SEPARATOR)) != string::npos) {
350 path = path.substr(pos+1);
355 if ((pos = path.find_last_of (
'.')) != string::npos) {
356 path = path.substr (0, pos);
359 string::size_type len = path.length();
363 if (len > 3 && (path[len-2] ==
'%' || path[len-2] ==
'?' || path[len-2] ==
'.') &&
364 (path[len-1] ==
'R' || path[len-1] ==
'L' || (islower (path[len-1])))) {
366 pair_base = path.substr (0, len-2);
376 ARDOUR::CFStringRefToStdString(CFStringRef stringRef)
379 CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) ,
380 kCFStringEncodingUTF8);
381 char *buf =
new char[size];
385 if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingUTF8)) {
398 step = 1.0/(nframes-1);
402 for (
framecnt_t i = 1; i < nframes - 1; ++i) {
403 in[i] = in[i-1] + step;
408 const float pan_law_attenuation = -3.0f;
409 const float scale = 2.0f - 4.0f * powf (10.0
f,pan_law_attenuation/20.0
f);
413 float outVal = 1 - inVal;
414 out[n] = outVal * (scale * outVal + 1.0f - scale);
415 in[n] = inVal * (scale * inVal + 1.0f - scale);
422 if (str ==
_(
"Splice")) {
424 }
else if (str ==
_(
"Slide")) {
426 }
else if (str ==
_(
"Ripple")) {
428 }
else if (str ==
_(
"Lock")) {
458 if (str ==
_(
"MIDI Timecode") || str ==
_(
"MTC")) {
462 if (str ==
_(
"MIDI Clock")) {
466 if (str ==
_(
"JACK")) {
490 return _(
"MIDI Timecode");
497 return _(
"MIDI Clock");
569 if (str ==
X_(
"Off")) {
571 }
else if (str ==
X_(
"Play")) {
573 }
else if (str ==
X_(
"Write")) {
575 }
else if (str ==
X_(
"Touch")) {
611 if (str ==
X_(
"Absolute")) {
613 }
else if (str ==
X_(
"Trim")) {
629 return X_(
"Absolute");
644 return (yn ?
"yes" :
"no");
680 struct dirent* dentry;
685 if ((dead = ::opendir (dir.c_str())) == 0) {
690 while ((dentry = ::readdir (dead)) != 0) {
694 if ((dentry->d_name[0] ==
'.' && dentry->d_name[1] ==
'\0') ||
695 (dentry->d_name[2] ==
'\0' && dentry->d_name[0] ==
'.' && dentry->d_name[1] ==
'.')) {
699 string fullpath = Glib::build_filename (dir, dentry->d_name);
701 if (::stat (fullpath.c_str(), &statbuf)) {
705 if (!S_ISREG (statbuf.st_mode)) {
727 int pu =
Config->get_processor_usage ();
728 uint32_t num_threads = max (num_cpu - 1, 2);
735 num_threads = num_cpu + pu;
738 }
else if (pu == 0) {
743 num_threads = num_cpu;
749 num_threads = min (num_cpu, pu);
LIBARDOUR_API ARDOUR::MeterFalloff meter_falloff_from_float(float)
#define METER_FALLOFF_FAST
LIBPBD_API Transmitter fatal
static double gain_to_slider_position(ARDOUR::gain_t g)
LIBARDOUR_API bool path_is_paired(std::string path, std::string &pair_base)
LIBARDOUR_API void compute_equal_power_fades(ARDOUR::framecnt_t nframes, float *in, float *out)
LIBPBD_API void stacktrace(std::ostream &out, int levels=0)
LIBARDOUR_API std::string legalize_for_uri(const std::string &str)
LIBARDOUR_API std::string legalize_for_path(const std::string &str)
LIBARDOUR_API double slider_position_to_gain_with_max(double g, double max_gain=2.0)
const std::string & name() const
LIBARDOUR_API const char * sync_source_to_string(ARDOUR::SyncSource src, bool sh=false)
LIBPBD_API Transmitter error
AutoStyle string_to_auto_style(std::string)
const XMLNodeList & children(const std::string &str=std::string()) const
std::ostream & endmsg(std::ostream &ostr)
LIBARDOUR_API uint32_t how_many_dsp_threads()
LIBARDOUR_API int touch_file(std::string path)
std::list< XMLNode * > XMLNodeList
#define METER_FALLOFF_MODERATE
LIBARDOUR_API bool matching_unsuffixed_filename_exists_in(const std::string &dir, const std::string &name)
LIBARDOUR_API ARDOUR::EditMode string_to_edit_mode(std::string)
static string replace_chars(const string &str, const string &illegal_chars)
LIBARDOUR_API std::string legalize_for_path_2X(const std::string &str)
LIBARDOUR_API RCConfiguration * Config
std::string auto_state_to_string(AutoState)
#define METER_FALLOFF_OFF
#define METER_FALLOFF_FASTEST
LIBARDOUR_API ARDOUR::SyncSource string_to_sync_source(std::string str)
LIBARDOUR_API int cmp_nocase_utf8(const std::string &s1, const std::string &s2)
LIBARDOUR_API XMLNode * find_named_node(const XMLNode &node, std::string name)
uint32_t hardware_concurrency()
LIBARDOUR_API int cmp_nocase(const std::string &s, const std::string &s2)
#define METER_FALLOFF_SLOW
LIBARDOUR_API std::string bump_name_number(const std::string &s)
LIBARDOUR_API std::string bump_name_once(const std::string &s, char delimiter)
#define METER_FALLOFF_SLOWISH
LIBPBD_API Glib::ustring basename_nosuffix(Glib::ustring)
#define METER_FALLOFF_FASTER
LIBARDOUR_API double gain_to_slider_position_with_max(double g, double max_gain=2.0)
#define METER_FALLOFF_SLOWEST
LIBARDOUR_API std::string legalize_for_universal_path(const std::string &str)
LIBARDOUR_API const char * edit_mode_to_string(ARDOUR::EditMode)
std::string auto_style_to_string(AutoStyle)
LIBARDOUR_API std::string bool_as_string(bool)
LIBARDOUR_API float meter_falloff_to_float(ARDOUR::MeterFalloff)
AutoState string_to_auto_state(std::string)
XMLNodeList::const_iterator XMLNodeConstIterator
#define METER_FALLOFF_MEDIUM
LIBARDOUR_API std::string region_name_from_path(std::string path, bool strip_channels, bool add_channel_suffix=false, uint32_t total=0, uint32_t this_one=0)
std::string string_compose(const std::string &fmt, const T1 &o1)
static ARDOUR::gain_t slider_position_to_gain(double pos)
LIBARDOUR_API const char * native_header_format_extension(ARDOUR::HeaderFormat, const ARDOUR::DataType &type)