-
-void
-AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b)
-{
- int const frames = b->frames ();
- int const channels = b->channels ();
-
- 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
- values by replacing with this (140dB down) */
- s = as = 10e-7;
- }
- _current[j][AudioPoint::RMS] += pow (s, 2);
- _current[j][AudioPoint::PEAK] = max (_current[j][AudioPoint::PEAK], as);
-
- if (as > _overall_peak) {
- _overall_peak = as;
- _overall_peak_frame = _done + i;
- }
-
- 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 += frames;
-}