diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-16 01:01:59 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-21 00:52:07 +0200 |
| commit | 191adfe030803a49588afc4b9087da27654d946b (patch) | |
| tree | a64625a3e4eb19cd2c9f7baea4eb22ad0c4ef050 /src/lib/audio_analyser.h | |
| parent | e5ad3fb4402d7df52c346408cbacbf68af4fa05a (diff) | |
Split audio analysis code off from the job.
Diffstat (limited to 'src/lib/audio_analyser.h')
| -rw-r--r-- | src/lib/audio_analyser.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/lib/audio_analyser.h b/src/lib/audio_analyser.h new file mode 100644 index 000000000..e47ab94b4 --- /dev/null +++ b/src/lib/audio_analyser.h @@ -0,0 +1,81 @@ +/* + Copyright (C) 2021 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "audio_analysis.h" +#include "dcpomatic_time.h" +#include "types.h" +#include <leqm_nrt.h> +#include <boost/scoped_ptr.hpp> +#include <memory> + + +class AudioAnalysis; +class AudioBuffers; +class AudioFilterGraph; +class AudioPoint; +class Film; +class Filter; +class Playlist; + + +class AudioAnalyser +{ +public: + AudioAnalyser (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, bool from_zero, std::function<void (float)> set_progress); + ~AudioAnalyser (); + + AudioAnalyser (AudioAnalyser const&) = delete; + AudioAnalyser& operator= (AudioAnalyser const&) = delete; + + void analyse (std::shared_ptr<const AudioBuffers>, dcpomatic::DCPTime time); + + dcpomatic::DCPTime start () const { + return _start; + } + + void finish (); + + AudioAnalysis get () const { + return _analysis; + } + +private: + std::shared_ptr<const Film> _film; + std::shared_ptr<const Playlist> _playlist; + + std::function<void (float)> _set_progress; + + dcpomatic::DCPTime _start; +#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG + std::shared_ptr<AudioFilterGraph> _ebur128; +#endif + std::vector<Filter const *> _filters; + Frame _samples_per_point = 1; + + boost::scoped_ptr<leqm_nrt::Calculator> _leqm; + Frame _done = 0; + float* _sample_peak = nullptr; + Frame* _sample_peak_frame = nullptr; + AudioPoint* _current = nullptr; + + AudioAnalysis _analysis; +}; + |
