summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-02-12 02:51:51 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-02-12 02:51:51 +0000
commita1955a82e81816161f5b7dbf460a694e902237b0 (patch)
tree3c576a733aed52ff02a8fdc9786838bdea7758d2 /libs/ardour
parent7999372faccab884b4e652da83702d7ec252e14b (diff)
AU GUIs basically working, though unfinished; push up dialog for massive split operations (still in progress); fix problem where peakfile is slightly older than audio data even though it is ready to use (debugging output still present); move sync-menu code to libs/gtkmm2ext for linkage reasons; prevent flush_pending() calls from "top menu" items on OS X from locking the GUI; try to make adding lots of regions (e.g. from split-at-points) scale a bit better; SAE version has no timecode mode for audio clocks
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3038 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/analyser.cc2
-rw-r--r--libs/ardour/ardour/session.h3
-rw-r--r--libs/ardour/audiofilter.cc5
-rw-r--r--libs/ardour/audioregion.cc11
-rw-r--r--libs/ardour/audiosource.cc21
-rw-r--r--libs/ardour/import.cc8
-rw-r--r--libs/ardour/session.cc114
7 files changed, 121 insertions, 43 deletions
diff --git a/libs/ardour/analyser.cc b/libs/ardour/analyser.cc
index 7ddb5428e9..5768ce0005 100644
--- a/libs/ardour/analyser.cc
+++ b/libs/ardour/analyser.cc
@@ -108,6 +108,8 @@ Analyser::analyse_audio_file_source (boost::shared_ptr<AudioFileSource> src)
TransientDetector td (src->sample_rate());
+ cerr << "analyzing " << src->name () << endl;
+
if (td.run (src->get_transients_path(), src.get(), 0, results) == 0) {
src->set_been_analysed (true);
} else {
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index c61137b4f3..9ad291662d 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -554,7 +554,10 @@ class Session : public PBD::StatefulDestructible
/* region info */
+ void add_regions (std::vector<boost::shared_ptr<Region> >&);
+
sigc::signal<void,boost::weak_ptr<AudioRegion> > AudioRegionAdded;
+ sigc::signal<void,std::vector<boost::weak_ptr<AudioRegion> >& > AudioRegionsAdded;
sigc::signal<void,boost::weak_ptr<AudioRegion> > AudioRegionRemoved;
int region_name (string& result, string base = string(""), bool newlevel = false) const;
diff --git a/libs/ardour/audiofilter.cc b/libs/ardour/audiofilter.cc
index 88a93b4f01..6560cb892e 100644
--- a/libs/ardour/audiofilter.cc
+++ b/libs/ardour/audiofilter.cc
@@ -27,6 +27,7 @@
#include <ardour/audiofilter.h>
#include <ardour/region_factory.h>
#include <ardour/source_factory.h>
+#include <ardour/analyser.h>
#include "i18n.h"
@@ -104,6 +105,10 @@ AudioFilter::finish (boost::shared_ptr<AudioRegion> region, SourceList& nsrcs, s
afs->update_header (region->position(), *now, xnow);
afs->mark_immutable ();
}
+
+ /* now that there is data there, requeue the file for analysis */
+
+ Analyser::queue_source_for_analysis (*si, false);
}
/* create a new region */
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 4f9e70e334..bcb36ab85a 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -1576,6 +1576,8 @@ AudioRegion::get_transients (AnalysisFeatureList& results, bool force_new)
return 0;
}
+ cerr << "startup analysis of " << _name << endl;
+
TransientDetector t (pl->session().frame_rate());
bool existing_results = !results.empty();
@@ -1588,10 +1590,14 @@ AudioRegion::get_transients (AnalysisFeatureList& results, bool force_new)
t.reset ();
+ cerr << "working on channel " << i << endl;
+
if (t.run ("", this, i, these_results)) {
return -1;
}
+ cerr << "done\n";
+
/* translate all transients to give absolute position */
for (AnalysisFeatureList::iterator i = these_results.begin(); i != these_results.end(); ++i) {
@@ -1617,6 +1623,11 @@ AudioRegion::get_transients (AnalysisFeatureList& results, bool force_new)
/* make sure ours are clean too */
TransientDetector::cleanup_transients (_transients, pl->session().frame_rate(), 3.0);
+
+ } else {
+
+ TransientDetector::cleanup_transients (_transients, pl->session().frame_rate(), 3.0);
+ results = _transients;
}
valid_transients = true;
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index cc1b7f4a05..7c8801845a 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -70,6 +70,7 @@ AudioSource::AudioSource (Session& s, ustring name)
AudioSource::AudioSource (Session& s, const XMLNode& node)
: Source (s, node)
{
+
_peaks_built = false;
_peak_byte_max = 0;
peakfile = -1;
@@ -141,6 +142,8 @@ AudioSource::peaks_ready (sigc::slot<void> the_slot, sigc::connection& conn) con
connect the slot while still holding the lock.
*/
+ cerr << _name << " @ " << this << " peaks built = " << _peaks_built << endl;
+
if (!(ret = _peaks_built)) {
conn = PeaksReady.connect (the_slot);
}
@@ -213,7 +216,7 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path)
/* we found it in the peaks dir, so check it out */
- if (statbuf.st_size == 0) {
+ if (statbuf.st_size == 0 || (statbuf.st_size < ((length() / _FPP) * sizeof (PeakData)))) {
// empty
_peaks_built = false;
} else {
@@ -221,12 +224,22 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path)
struct stat stat_file;
int err = stat (audio_path.c_str(), &stat_file);
- if (!err && stat_file.st_mtime > statbuf.st_mtime){
+ if (err) {
_peaks_built = false;
_peak_byte_max = 0;
} else {
- _peaks_built = true;
- _peak_byte_max = statbuf.st_size;
+
+ /* allow 6 seconds slop on checking peak vs. file times because of various
+ disk action "races"
+ */
+
+ if (stat_file.st_mtime > statbuf.st_mtime && (stat_file.st_mtime - statbuf.st_mtime > 6)) {
+ _peaks_built = false;
+ _peak_byte_max = 0;
+ } else {
+ _peaks_built = true;
+ _peak_byte_max = statbuf.st_size;
+ }
}
}
}
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index e7cb136a4e..3c3e63be90 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -46,6 +46,7 @@
#include <ardour/region_factory.h>
#include <ardour/source_factory.h>
#include <ardour/resampled_source.h>
+#include <ardour/analyser.h>
#include "i18n.h"
@@ -285,11 +286,14 @@ Session::import_audiofiles (import_status& status)
/* flush the final length(s) to the header(s) */
- for (AudioSources::iterator x = all_new_sources.begin();
- x != all_new_sources.end(); ++x)
+ for (AudioSources::iterator x = all_new_sources.begin(); x != all_new_sources.end(); ++x)
{
(*x)->update_header(0, *now, xnow);
(*x)->done_with_peakfile_writes ();
+
+ /* now that there is data there, requeue the file for analysis */
+
+ Analyser::queue_source_for_analysis (boost::static_pointer_cast<Source>(*x), false);
}
/* save state so that we don't lose these new Sources */
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 1f2ba8d61b..454a710236 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -2568,6 +2568,14 @@ Session::region_name (string& result, string base, bool newlevel) const
void
Session::add_region (boost::shared_ptr<Region> region)
{
+ vector<boost::shared_ptr<Region> > v;
+ v.push_back (region);
+ add_regions (v);
+}
+
+void
+Session::add_regions (vector<boost::shared_ptr<Region> >& new_regions)
+{
boost::shared_ptr<AudioRegion> ar;
boost::shared_ptr<AudioRegion> oar;
bool added = false;
@@ -2575,45 +2583,52 @@ Session::add_region (boost::shared_ptr<Region> region)
{
Glib::Mutex::Lock lm (region_lock);
- if (region == 0) {
- error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg;
- } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
-
- AudioRegionList::iterator x;
-
- for (x = audio_regions.begin(); x != audio_regions.end(); ++x) {
-
- oar = boost::dynamic_pointer_cast<AudioRegion> (x->second);
-
- if (ar->region_list_equivalent (oar)) {
- break;
- }
- }
-
- if (x == audio_regions.end()) {
-
- pair<AudioRegionList::key_type,AudioRegionList::mapped_type> entry;
-
- entry.first = region->id();
- entry.second = ar;
+ for (vector<boost::shared_ptr<Region> >::iterator ii = new_regions.begin(); ii != new_regions.end(); ++ii) {
+
+ boost::shared_ptr<Region> region = *ii;
+
+ if (region == 0) {
- pair<AudioRegionList::iterator,bool> x = audio_regions.insert (entry);
+ error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg;
+ } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
- if (!x.second) {
- return;
+ AudioRegionList::iterator x;
+
+ for (x = audio_regions.begin(); x != audio_regions.end(); ++x) {
+
+ oar = boost::dynamic_pointer_cast<AudioRegion> (x->second);
+
+ if (ar->region_list_equivalent (oar)) {
+ break;
+ }
}
+
+ if (x == audio_regions.end()) {
+
+ pair<AudioRegionList::key_type,AudioRegionList::mapped_type> entry;
+
+ entry.first = region->id();
+ entry.second = ar;
+
+ pair<AudioRegionList::iterator,bool> x = audio_regions.insert (entry);
+
+
+ if (!x.second) {
+ return;
+ }
+
+ added = true;
+ }
- added = true;
- }
-
- } else {
-
- fatal << _("programming error: ")
- << X_("unknown region type passed to Session::add_region()")
- << endmsg;
- /*NOTREACHED*/
-
+ } else {
+
+ fatal << _("programming error: ")
+ << X_("unknown region type passed to Session::add_region()")
+ << endmsg;
+ /*NOTREACHED*/
+
+ }
}
}
@@ -2624,9 +2639,34 @@ Session::add_region (boost::shared_ptr<Region> region)
set_dirty();
if (added) {
- region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region)));
- region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region)));
- AudioRegionAdded (ar); /* EMIT SIGNAL */
+
+ vector<boost::weak_ptr<AudioRegion> > v;
+ boost::shared_ptr<AudioRegion> first_ar;
+
+ for (vector<boost::shared_ptr<Region> >::iterator ii = new_regions.begin(); ii != new_regions.end(); ++ii) {
+
+ boost::shared_ptr<Region> region = *ii;
+ boost::shared_ptr<AudioRegion> ar;
+
+ if (region == 0) {
+
+ error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg;
+
+ } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
+ v.push_back (ar);
+
+ if (!first_ar) {
+ first_ar = ar;
+ }
+ }
+
+ region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region)));
+ region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region)));
+ }
+
+ if (!v.empty()) {
+ AudioRegionsAdded (v); /* EMIT SIGNAL */
+ }
}
}