summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-01 23:37:55 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-01 23:37:55 +0100
commit4bf5a8794cf1ed6411e085b35c11777c3508f82e (patch)
tree2e0390a371a9fe828307b6d11313726299f232e3 /src/lib
parent92b6430402753a572c33d594ba0745a4e461edf4 (diff)
Restore short-cutting of analysis gain updates.
If we have an analysis of one piece of content and the gain changes we don't re-run the analysis, instead applying a suitable `correction' in the UI.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/analyse_audio_job.cc10
-rw-r--r--src/lib/audio_analysis.cc5
-rw-r--r--src/lib/audio_analysis.h13
-rw-r--r--src/lib/film.cc10
4 files changed, 37 insertions, 1 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc
index 1cec15c2a..2f48d12a9 100644
--- a/src/lib/analyse_audio_job.cc
+++ b/src/lib/analyse_audio_job.cc
@@ -89,6 +89,16 @@ AnalyseAudioJob::run ()
}
_analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ()));
+
+ if (_playlist->content().size() == 1) {
+ /* If there was only one piece of content in this analysis we may later need to know what its
+ gain was when we analysed it.
+ */
+ shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (_playlist->content().front ());
+ DCPOMATIC_ASSERT (ac);
+ _analysis->set_analysis_gain (ac->audio_gain ());
+ }
+
_analysis->write (_film->audio_analysis_path (_playlist));
set_progress (1);
diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc
index 7e1dc6e78..127def807 100644
--- a/src/lib/audio_analysis.cc
+++ b/src/lib/audio_analysis.cc
@@ -102,6 +102,7 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
_peak = f.number_child<float> ("Peak");
_peak_time = DCPTime (f.number_child<DCPTime::Type> ("PeakTime"));
+ _analysis_gain = f.optional_number_child<double> ("AnalysisGain");
}
void
@@ -149,5 +150,9 @@ AudioAnalysis::write (boost::filesystem::path filename)
root->add_child("PeakTime")->add_child_text (raw_convert<string> (_peak_time.get().get ()));
}
+ if (_analysis_gain) {
+ root->add_child("AnalysisGain")->add_child_text (raw_convert<string> (_analysis_gain.get ()));
+ }
+
doc->write_to_file_formatted (filename.string ());
}
diff --git a/src/lib/audio_analysis.h b/src/lib/audio_analysis.h
index 2411b4316..478b0e532 100644
--- a/src/lib/audio_analysis.h
+++ b/src/lib/audio_analysis.h
@@ -75,12 +75,25 @@ public:
return _peak_time;
}
+ boost::optional<double> analysis_gain () const {
+ return _analysis_gain;
+ }
+
+ void set_analysis_gain (double gain) {
+ _analysis_gain = gain;
+ }
+
void write (boost::filesystem::path);
private:
std::vector<std::vector<AudioPoint> > _data;
boost::optional<float> _peak;
boost::optional<DCPTime> _peak_time;
+ /** If this analysis was run on a single piece of
+ * content we store its gain in dB when the analysis
+ * happened.
+ */
+ boost::optional<double> _analysis_gain;
};
#endif
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 5310ef71f..e19b309f7 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -241,7 +241,15 @@ Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
digester.add (ac->digest ());
digester.add (ac->audio_mapping().digest ());
- digester.add (ac->audio_gain ());
+ if (playlist->content().size() != 1) {
+ /* Analyses should be considered equal regardless of gain
+ if they were made from just one piece of content. This
+ is because we can fake any gain change in a single-content
+ analysis at the plotting stage rather than having to
+ recompute it.
+ */
+ digester.add (ac->audio_gain ());
+ }
}
if (audio_processor ()) {