X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fanalyse_audio_job.cc;h=079fe884e762f76980f1b08799f659363ed9ef8b;hb=a71a3b3d0f8545e44af75ded10dfda4a382158f2;hp=fc0abe0a3b5914fa953d1c06247e1f60d20759da;hpb=1f8b45c7fd49714628009f5ed2161fbaa2b4d729;p=dcpomatic.git diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index fc0abe0a3..079fe884e 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -66,10 +66,8 @@ AnalyseAudioJob::run () shared_ptr playlist (new Playlist); playlist->add (content); shared_ptr player (new Player (_film, playlist)); - player->disable_video (); + player->set_ignore_video (); - player->Audio.connect (bind (&AnalyseAudioJob::audio, this, _1, _2)); - int64_t const len = _film->length().frames (_film->audio_frame_rate()); _samples_per_point = max (int64_t (1), len / _num_points); @@ -77,8 +75,10 @@ AnalyseAudioJob::run () _analysis.reset (new AudioAnalysis (_film->audio_channels ())); _done = 0; - while (!player->pass ()) { - set_progress (double (_done) / len); + DCPTime const block = DCPTime::from_seconds (1.0 / 8); + for (DCPTime t; t < _film->length(); t += block) { + analyse (player->get_audio (t, block, false)); + set_progress (t.seconds() / _film->length().seconds()); } _analysis->write (content->audio_analysis_path ()); @@ -88,13 +88,13 @@ AnalyseAudioJob::run () } void -AnalyseAudioJob::audio (shared_ptr b, DCPTime) +AnalyseAudioJob::analyse (shared_ptr 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) { - /* stringstream can't serialise and recover inf or -inf, so prevent such + /* SafeStringStream can't serialise and recover inf or -inf, so prevent such values by replacing with this (140dB down) */ s = 10e-7; }