summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-04-27 14:29:44 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-04-27 14:29:44 +0000
commit91fc0c70bc40754e35ecd7c61d6b7078a9dfa86d (patch)
tree0145f780bdcc2a2307bc0e1acc2cfb71215213cb
parent3ee778075051a53705a159a0ff5cfbcb8cafb060 (diff)
reduce stack space requirements for export and normalization
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@7003 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/audioregion.cc13
-rw-r--r--libs/ardour/automation_event.cc12
2 files changed, 18 insertions, 7 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 301e605a3e..c329a26b1c 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -21,9 +21,10 @@
#include <climits>
#include <cfloat>
#include <algorithm>
-
#include <set>
+#include <boost/scoped_array.hpp>
+
#include <sigc++/bind.h>
#include <sigc++/class_slot.h>
@@ -1330,11 +1331,11 @@ AudioRegion::exportme (Session& session, AudioExportSpecification& spec)
} else {
- Sample buf[blocksize];
+ boost::scoped_array<Sample> buf (new Sample[blocksize]);
for (uint32_t chan = 0; chan < spec.channels; ++chan) {
- if (sources[chan]->read (buf, _start + spec.pos, to_read) != to_read) {
+ if (sources[chan]->read (buf.get(), _start + spec.pos, to_read) != to_read) {
goto out;
}
@@ -1402,7 +1403,7 @@ void
AudioRegion::normalize_to (float target_dB)
{
const nframes_t blocksize = 64 * 1024;
- Sample buf[blocksize];
+ boost::scoped_array<Sample> buf (new Sample[blocksize]);
nframes_t fpos;
nframes_t fend;
nframes_t to_read;
@@ -1431,11 +1432,11 @@ AudioRegion::normalize_to (float target_dB)
/* read it in */
- if (source (n)->read (buf, fpos, to_read) != to_read) {
+ if (source (n)->read (buf.get(), fpos, to_read) != to_read) {
return;
}
- maxamp = Session::compute_peak (buf, to_read, maxamp);
+ maxamp = Session::compute_peak (buf.get(), to_read, maxamp);
}
fpos += to_read;
diff --git a/libs/ardour/automation_event.cc b/libs/ardour/automation_event.cc
index cd683a2cab..28b7dde050 100644
--- a/libs/ardour/automation_event.cc
+++ b/libs/ardour/automation_event.cc
@@ -346,6 +346,8 @@ AutomationList::merge_nascent (double when)
return;
}
+ cerr << "We have " << nascent.size() << " NI's to merge\n";
+
for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
NascentInfo* ninfo = *n;
@@ -368,17 +370,22 @@ AutomationList::merge_nascent (double when)
if (!preexisting) {
+ cerr << "no prexisting - merge\n";
events = nascent_events;
} else if (ninfo->end_time < events.front()->when) {
/* all points in nascent are before the first existing point */
+
+ cerr << "all before first, prepend\n";
events.insert (events.begin(), nascent_events.begin(), nascent_events.end());
} else if (ninfo->start_time > events.back()->when) {
/* all points in nascent are after the last existing point */
+
+ cerr << "all after last, append\n";
events.insert (events.end(), nascent_events.begin(), nascent_events.end());
@@ -413,13 +420,16 @@ AutomationList::merge_nascent (double when)
if (range_begin != events.begin()) {
/* clamp point before */
+ cerr << "Add pre-clamp\n";
events.insert (range_begin, point_factory (ninfo->start_time, unlocked_eval (ninfo->start_time)));
}
-
+
+ cerr << "merge into event list\n";
events.insert (range_begin, nascent_events.begin(), nascent_events.end());
if (range_end != events.end()) {
/* clamp point after */
+ cerr << "Add post-clamp\n";
events.insert (range_begin, point_factory (ninfo->end_time, end_value));
}