- _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ()));
- _analysis->write (content->audio_analysis_path ());
-
- set_progress (1);
- set_state (FINISHED_OK);
-}
-
-void
-AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b)
-{
- for (int i = 0; i < b->frames(); ++i) {
- for (int j = 0; j < b->channels(); ++j) {
- float s = b->data(j)[i];
- if (fabsf (s) < 10e-7) {
- /* SafeStringStream can't serialise and recover inf or -inf, so prevent such
- values by replacing with this (140dB down) */
- s = 10e-7;
- }
- _current[j][AudioPoint::RMS] += pow (s, 2);
- _current[j][AudioPoint::PEAK] = max (_current[j][AudioPoint::PEAK], fabsf (s));
-
- float const as = fabs (s);
-
- _current[j][AudioPoint::PEAK] = max (_current[j][AudioPoint::PEAK], as);
-
- if (as > _overall_peak) {
- _overall_peak = as;
- _overall_peak_frame = _done + i;
- }
-
- if ((_done % _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 ();
- }