summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-08-26 23:23:08 +0100
committerCarl Hetherington <cth@carlh.net>2015-08-26 23:23:08 +0100
commit022f799739ce0bc2776c85b08d4974239c6ffd66 (patch)
tree0e975a1f0b223e5217bc786f7d630ec3c276639a /src
parentd44e39b0f03a4e90aab6fca20bd2819a39b42e69 (diff)
Another small analysis optimisation, and (I think) a bug fix to peak location.
Diffstat (limited to 'src')
-rw-r--r--src/lib/analyse_audio_job.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc
index 164c57b14..b45af646d 100644
--- a/src/lib/analyse_audio_job.cc
+++ b/src/lib/analyse_audio_job.cc
@@ -119,9 +119,10 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b)
int const frames = b->frames ();
int const channels = b->channels ();
- for (int i = 0; i < frames; ++i) {
- for (int j = 0; j < channels; ++j) {
- float s = b->data(j)[i];
+ for (int j = 0; j < channels; ++j) {
+ float* data = b->data(j);
+ for (int i = 0; i < frames; ++i) {
+ float s = data[i];
float as = fabsf (s);
if (as < 10e-7) {
/* SafeStringStream can't serialise and recover inf or -inf, so prevent such
@@ -136,13 +137,13 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b)
_overall_peak_frame = _done + i;
}
- if ((_done % _samples_per_point) == 0) {
+ if (((_done + i) % _samples_per_point) == 0) {
_current[j][AudioPoint::RMS] = sqrt (_current[j][AudioPoint::RMS] / _samples_per_point);
_analysis->add_point (j, _current[j]);
_current[j] = AudioPoint ();
}
}
-
- ++_done;
}
+
+ _done += frames;
}