|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-08 17:34:58
|
Module: editor
Branch: master
Commit: d84cce3f86a2f45d229e0d0eedd2770cdd942aa1
Author: Lasse Karkkainen <tro...@tr...>
Date: Tue Feb 8 18:34:16 2011 +0100
Avoid unnecessary copying of data that slows down the analysis towards the end.
---
pitch.hh | 1 +
pitchvis.cc | 9 +++------
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/pitch.hh b/pitch.hh
index d8c78a5..b10ee57 100644
--- a/pitch.hh
+++ b/pitch.hh
@@ -88,6 +88,7 @@ public:
}
unsigned processSize() const; ///< The number of samples required by process()
unsigned processStep() const; ///< The number of samples to increment the input position after each call to process()
+ double getTime() const { return m_moments.empty() ? 0.0 : m_moments.back().time(); }
private:
double m_rate;
std::string m_id;
diff --git a/pitchvis.cc b/pitchvis.cc
index 92bcaea..5decce9 100644
--- a/pitchvis.cc
+++ b/pitchvis.cc
@@ -48,12 +48,9 @@ void PitchVis::run()
// Update progress and check for quit flag
QMutexLocker locker(&mutex);
if (cancelled) return;
- Analyzer::Moments const& moments = analyzers[0].getMoments();
- if (!moments.empty()) {
- double t = moments.back().time();
- position = t;
- duration = std::max(duration, t + 0.01);
- }
+ double t = analyzers[0].getTime();
+ position = t;
+ duration = std::max(duration, t + 0.01);
}
}
// DEBUG: std::ofstream("audio.raw", std::ios::binary).write(reinterpret_cast<char*>(&data[0]), data.size() * sizeof(float));
|