summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-06 23:42:07 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-06 23:42:07 +0000
commit2dd0b9321c87838e9f2276c02f5942daac2b836e (patch)
tree662e7204c0d3a3eea3183a9407a6b46871d0d152 /libs/ardour
parentfacf6168681010134085145b5b480d864d780cd4 (diff)
modified fix from carl for region copy-moves-original-to-start bug; change verbose canvas cursor color to be more distinct and readable; fix naming issues with imported files containing ':'; make sure [N] channels count shows up for whole files in region list; fix #1575, a subtle and nasty bug; improve positioning of verbose canvas cursor for ruler drags (but has a wierd side effect
git-svn-id: svn://localhost/ardour2/trunk@1675 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/audiofilesource.h3
-rw-r--r--libs/ardour/ardour/sndfilesource.h2
-rw-r--r--libs/ardour/audiofilesource.cc117
-rw-r--r--libs/ardour/panner.cc19
-rw-r--r--libs/ardour/sndfilesource.cc6
5 files changed, 89 insertions, 58 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 6bc9ec4207..dce06c1ca0 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -81,6 +81,7 @@ class AudioFileSource : public AudioSource {
virtual void mark_capture_start (nframes_t) {}
virtual void mark_capture_end () {}
virtual void clear_capture_marks() {}
+ virtual bool one_of_several_channels () const { return false; }
virtual int update_header (nframes_t when, struct tm&, time_t) = 0;
virtual int flush_header () = 0;
@@ -161,7 +162,7 @@ class AudioFileSource : public AudioSource {
virtual void set_timeline_position (int64_t pos);
virtual void set_header_timeline_position () = 0;
- bool find (Glib::ustring& path, bool must_exist, bool& is_new);
+ bool find (Glib::ustring& path, bool must_exist, bool& is_new, uint16_t& chan);
bool removable() const;
bool writable() const { return _flags & Writable; }
};
diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h
index 2fc3872887..916e9da49e 100644
--- a/libs/ardour/ardour/sndfilesource.h
+++ b/libs/ardour/ardour/sndfilesource.h
@@ -56,6 +56,8 @@ class SndFileSource : public AudioFileSource {
bool set_destructive (bool yn);
+ bool one_of_several_channels () const;
+
static void setup_standard_crossfades (nframes_t sample_rate);
static const AudioFileSource::Flag default_writable_flags;
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 929cfc8083..3a02c4c4b0 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -93,15 +93,17 @@ AudioFileSource::AudioFileSource (Session& s, ustring path, Flag flags, SampleFo
AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist)
: AudioSource (s, node), _flags (Flag (Writable|CanRename))
- /* _channel is set in set_state() */
+ /* _channel is set in set_state() or init() */
{
/* constructor used for existing internal-to-session files. file must exist */
if (set_state (node)) {
throw failed_constructor ();
}
+
+ string foo = _name;
- if (init (_name, must_exist)) {
+ if (init (foo, must_exist)) {
throw failed_constructor ();
}
}
@@ -136,7 +138,7 @@ AudioFileSource::init (ustring pathstr, bool must_exist)
_peaks_built = false;
file_is_new = false;
- if (!find (pathstr, must_exist, is_new)) {
+ if (!find (pathstr, must_exist, is_new, _channel)) {
throw non_existent_source ();
}
@@ -361,42 +363,13 @@ AudioFileSource::move_to_trash (const ustring& trash_dir_name)
}
bool
-AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew)
+AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew, uint16_t& chan)
{
ustring::size_type pos;
bool ret = false;
isnew = false;
- /* i (paul) made a nasty design error by using ':' as a special character in
- Ardour 0.99 .. this hack tries to make things sort of work.
- */
-
- if ((pos = pathstr.find_last_of (':')) != ustring::npos) {
- if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS)) {
- /* its a real file, no problem */
-
- } else {
-
- if (must_exist) {
-
- /* older session using file:channel syntax */
-
- warning << string_compose (_("This older session references an embedded\n\
-non-mono audio file:\n\n%1\n\n \
-The session file may be edited or the file must be removed before it can be used."),
- short_path (pathstr, 48))
- << endmsg;
- return false;
-
- } else {
-
- /* new derived file (e.g. for timefx) being created in a newer session */
-
- }
- }
- }
-
if (pathstr[0] != '/') {
/* non-absolute pathname: find pathstr in search path */
@@ -421,12 +394,60 @@ The session file may be edited or the file must be removed before it can be used
if (fullpath[fullpath.length()-1] != '/') {
fullpath += '/';
}
+
fullpath += pathstr;
+
+ /* i (paul) made a nasty design error by using ':' as a special character in
+ Ardour 0.99 .. this hack tries to make things sort of work.
+ */
- if (access (fullpath.c_str(), R_OK) == 0) {
- keeppath = fullpath;
- ++cnt;
- }
+ if ((pos = pathstr.find_last_of (':')) != ustring::npos) {
+
+ if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+
+ /* its a real file, no problem */
+
+ keeppath = fullpath;
+ ++cnt;
+
+ } else {
+
+ if (must_exist) {
+
+ /* might be an older session using file:channel syntax. see if the version
+ without the :suffix exists
+ */
+
+ ustring shorter = pathstr.substr (0, pos);
+ fullpath = *i;
+
+ if (fullpath[fullpath.length()-1] != '/') {
+ fullpath += '/';
+ }
+
+ fullpath += shorter;
+
+ if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+ chan = atoi (pathstr.substr (pos+1));
+ pathstr = shorter;
+ keeppath = fullpath;
+ ++cnt;
+ }
+
+ } else {
+
+ /* new derived file (e.g. for timefx) being created in a newer session */
+
+ }
+ }
+
+ } else {
+
+ if (Glib::file_test (fullpath, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+ keeppath = fullpath;
+ ++cnt;
+ }
+ }
}
if (cnt > 1) {
@@ -443,7 +464,7 @@ The session file may be edited or the file must be removed before it can be used
isnew = true;
}
}
-
+
_name = pathstr;
_path = keeppath;
ret = true;
@@ -451,18 +472,31 @@ The session file may be edited or the file must be removed before it can be used
} else {
/* external files and/or very very old style sessions include full paths */
+
+ /* ugh, handle ':' situation */
+
+ if ((pos = pathstr.find_last_of (':')) != ustring::npos) {
+
+ ustring shorter = pathstr.substr (0, pos);
+
+ if (Glib::file_test (shorter, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+ chan = atoi (pathstr.substr (pos+1));
+ pathstr = shorter;
+ }
+ }
_path = pathstr;
+
if (is_embedded()) {
_name = pathstr;
} else {
_name = pathstr.substr (pathstr.find_last_of ('/') + 1);
}
-
- if (access (_path.c_str(), R_OK) != 0) {
- /* file does not exist or we cannot read it */
+ if (!Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
+ /* file does not exist or we cannot read it */
+
if (must_exist) {
error << string_compose(_("Filesource: cannot find required file (%1): %2"), _path, strerror (errno)) << endmsg;
goto out;
@@ -483,6 +517,7 @@ The session file may be edited or the file must be removed before it can be used
/* already exists */
ret = true;
+
}
}
diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc
index deb131e6fc..563d4e90d4 100644
--- a/libs/ardour/panner.cc
+++ b/libs/ardour/panner.cc
@@ -653,10 +653,7 @@ Multi2dPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nfram
}
pan = left * gain_coeff;
-
- for (; n < nframes; ++n) {
- dst[n] += src[n] * pan;
- }
+ Session::mix_buffers_with_gain(dst+n,src+n,nframes-n,pan);
} else {
@@ -666,20 +663,10 @@ Multi2dPanner::distribute (Sample* src, Sample** obufs, gain_t gain_coeff, nfram
if ((pan *= gain_coeff) != 1.0f) {
if (pan != 0.0f) {
-
- for (nframes_t n = 0; n < nframes; ++n) {
- dst[n] += src[n] * pan;
- }
-
+ Session::mix_buffers_with_gain(dst,src,nframes,pan);
}
-
-
} else {
-
- for (nframes_t n = 0; n < nframes; ++n) {
- dst[n] += src[n];
- }
-
+ Session::mix_buffers_no_gain(dst,src,nframes);
}
#endif
#ifdef CAN_INTERP
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc
index 8aecbc3cdc..24647030ab 100644
--- a/libs/ardour/sndfilesource.cc
+++ b/libs/ardour/sndfilesource.cc
@@ -894,3 +894,9 @@ SndFileSource::get_timecode_info (SNDFILE* sf, SF_BROADCAST_INFO* binfo, bool& e
ret |= (uint32_t) binfo->time_reference_low;
return ret;
}
+
+bool
+SndFileSource::one_of_several_channels () const
+{
+ return _info.channels > 1;
+}