summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-07-18 00:50:15 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-07-18 00:50:15 +0000
commit932cca703eafaaa50d7acf1bc25da487a7b3abba (patch)
tree1be21bf062d518b6f2d649cac79a204b3fc5a87c /libs/ardour
parent9b7e3a892a23bb27a72b915ff3f3e7ac0fd20f0a (diff)
imported files retain BWF timestamp info (nick murtagh) ; logarithm plugin controls can be properly controlled by generic GUI (nick murtagh); properly delete AU plugin *and* GUI (fixes crashing bug for Carbon-GUI based AU's)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5374 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/audiofilesource.h3
-rw-r--r--libs/ardour/ardour/caimportable.h1
-rw-r--r--libs/ardour/ardour/importable_source.h1
-rw-r--r--libs/ardour/ardour/resampled_source.h1
-rw-r--r--libs/ardour/ardour/sndfileimportable.h4
-rw-r--r--libs/ardour/import.cc13
-rw-r--r--libs/ardour/sndfileimportable.cc33
7 files changed, 50 insertions, 6 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h
index 68ee510ed0..e363415362 100644
--- a/libs/ardour/ardour/audiofilesource.h
+++ b/libs/ardour/ardour/audiofilesource.h
@@ -125,6 +125,8 @@ class AudioFileSource : public AudioSource {
bool can_be_analysed() const { return _length > 0; }
+ virtual void set_timeline_position (int64_t pos);
+
static bool find (Glib::ustring path, bool must_exist, bool embedded, bool& is_new, uint16_t& chan,
Glib::ustring& found_path, std::string& found_name);
@@ -164,7 +166,6 @@ class AudioFileSource : public AudioSource {
static uint64_t header_position_offset;
- virtual void set_timeline_position (int64_t pos);
virtual void set_header_timeline_position () = 0;
bool removable() const;
diff --git a/libs/ardour/ardour/caimportable.h b/libs/ardour/ardour/caimportable.h
index dc7f5769ae..17dc708195 100644
--- a/libs/ardour/ardour/caimportable.h
+++ b/libs/ardour/ardour/caimportable.h
@@ -38,6 +38,7 @@ class CAImportableSource : public ImportableSource {
nframes_t length() const;
nframes_t samplerate() const;
void seek (nframes_t pos);
+ nframes_t natural_position() const { return 0; }
protected:
mutable CAAudioFile af;
diff --git a/libs/ardour/ardour/importable_source.h b/libs/ardour/ardour/importable_source.h
index a33cf567e7..32401d6ab3 100644
--- a/libs/ardour/ardour/importable_source.h
+++ b/libs/ardour/ardour/importable_source.h
@@ -36,6 +36,7 @@ public:
virtual nframes_t length() const = 0;
virtual nframes_t samplerate() const = 0;
virtual void seek (nframes_t pos) = 0;
+ virtual nframes_t natural_position() const = 0;
};
}
diff --git a/libs/ardour/ardour/resampled_source.h b/libs/ardour/ardour/resampled_source.h
index 6eca4cda98..513fddbb75 100644
--- a/libs/ardour/ardour/resampled_source.h
+++ b/libs/ardour/ardour/resampled_source.h
@@ -40,6 +40,7 @@ class ResampledImportableSource : public ImportableSource
nframes_t length() const { return source->length(); }
nframes_t samplerate() const { return source->samplerate(); }
void seek (nframes_t pos) { source->seek (pos); }
+ nframes_t natural_position() const { return source->natural_position(); }
static const uint32_t blocksize;
diff --git a/libs/ardour/ardour/sndfileimportable.h b/libs/ardour/ardour/sndfileimportable.h
index 5cd84f4f5f..15eafd5d97 100644
--- a/libs/ardour/ardour/sndfileimportable.h
+++ b/libs/ardour/ardour/sndfileimportable.h
@@ -38,11 +38,13 @@ class SndFileImportableSource : public ImportableSource {
nframes_t length() const;
nframes_t samplerate() const;
void seek (nframes_t pos);
+ nframes_t natural_position() const;
protected:
SF_INFO sf_info;
boost::shared_ptr<SNDFILE> in;
-
+ nframes_t timecode;
+ int64_t get_timecode_info (SNDFILE*, SF_BROADCAST_INFO*, bool&);
};
}
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index b211321026..18747b1beb 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -193,8 +193,11 @@ map_existing_mono_sources (const vector<string>& new_paths, Session& sess,
static bool
create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
- uint samplerate, vector<boost::shared_ptr<AudioFileSource> >& newfiles)
+ uint samplerate, vector<boost::shared_ptr<AudioFileSource> >& newfiles,
+ nframes_t timeline_position)
{
+ boost::shared_ptr<AudioFileSource> afs;
+
for (vector<string>::const_iterator i = new_paths.begin();
i != new_paths.end(); ++i)
{
@@ -215,7 +218,9 @@ create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
return false;
}
- newfiles.push_back(boost::dynamic_pointer_cast<AudioFileSource>(source));
+ afs = boost::dynamic_pointer_cast<AudioFileSource>(source);
+ afs->set_timeline_position(timeline_position);
+ newfiles.push_back(afs);
}
return true;
}
@@ -337,7 +342,7 @@ Session::import_audiofiles (import_status& status)
fatal << "THIS IS NOT IMPLEMENTED YET, IT SHOULD NEVER GET CALLED!!! DYING!" << endl;
status.cancel = !map_existing_mono_sources (new_paths, *this, frame_rate(), newfiles, this);
} else {
- status.cancel = !create_mono_sources_for_writing (new_paths, *this, frame_rate(), newfiles);
+ status.cancel = !create_mono_sources_for_writing (new_paths, *this, frame_rate(), newfiles, source->natural_position());
}
// copy on cancel/failure so that any files that were created will be removed below
@@ -366,7 +371,7 @@ Session::import_audiofiles (import_status& status)
for (AudioSources::iterator x = all_new_sources.begin(); x != all_new_sources.end(); ++x)
{
- (*x)->update_header(0, *now, xnow);
+ (*x)->update_header((*x)->natural_position(), *now, xnow);
(*x)->done_with_peakfile_writes ();
/* now that there is data there, requeue the file for analysis */
diff --git a/libs/ardour/sndfileimportable.cc b/libs/ardour/sndfileimportable.cc
index fc24aaae91..f3bffdb078 100644
--- a/libs/ardour/sndfileimportable.cc
+++ b/libs/ardour/sndfileimportable.cc
@@ -1,16 +1,43 @@
#include <ardour/sndfileimportable.h>
#include <sndfile.h>
#include <iostream>
+#include <cstring>
#include <string.h>
using namespace ARDOUR;
using namespace std;
+/* FIXME: this was copied from sndfilesource.cc, at some point these should be merged */
+int64_t
+SndFileImportableSource::get_timecode_info (SNDFILE* sf, SF_BROADCAST_INFO* binfo, bool& exists)
+{
+ if (sf_command (sf, SFC_GET_BROADCAST_INFO, binfo, sizeof (*binfo)) != SF_TRUE) {
+ exists = false;
+ return 0;
+ }
+
+ exists = true;
+ int64_t ret = (uint32_t) binfo->time_reference_high;
+ ret <<= 32;
+ ret |= (uint32_t) binfo->time_reference_low;
+ return ret;
+}
+
SndFileImportableSource::SndFileImportableSource (const string& path)
{
memset(&sf_info, 0 , sizeof(sf_info));
in.reset( sf_open(path.c_str(), SFM_READ, &sf_info), sf_close);
if (!in) throw failed_constructor();
+
+ SF_BROADCAST_INFO binfo;
+ bool timecode_exists;
+
+ memset (&binfo, 0, sizeof (binfo));
+ timecode = get_timecode_info (in.get(), &binfo, timecode_exists);
+
+ if (!timecode_exists) {
+ timecode = 0;
+ }
}
SndFileImportableSource::~SndFileImportableSource ()
@@ -48,3 +75,9 @@ SndFileImportableSource::seek (nframes_t pos)
{
sf_seek (in.get(), 0, SEEK_SET);
}
+
+nframes_t
+SndFileImportableSource::natural_position () const
+{
+ return timecode;
+}