summaryrefslogtreecommitdiff
path: root/src/wx/hints_dialog.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-25 23:49:02 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-25 23:49:02 +0100
commitd0a8ad99117ef265561e1b6d4cfee2704cbbbb03 (patch)
treebbc1d3ce02a082ea1c24da7641458d4121f495c5 /src/wx/hints_dialog.cc
parent761b1587bab3870584833e4299156dfea6d70f63 (diff)
Hint on high audio levels (part of #822).
Diffstat (limited to 'src/wx/hints_dialog.cc')
-rw-r--r--src/wx/hints_dialog.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc
index a2eefd39f..72ab0eef4 100644
--- a/src/wx/hints_dialog.cc
+++ b/src/wx/hints_dialog.cc
@@ -25,10 +25,12 @@
#include "lib/subtitle_content.h"
#include "lib/font.h"
#include "lib/content.h"
+#include "lib/audio_analysis.h"
#include <wx/richtext/richtextctrl.h>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
+using std::max;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
@@ -172,6 +174,24 @@ HintsDialog::film_changed ()
_text->Newline ();
}
+ boost::filesystem::path path = film->audio_analysis_path (film->playlist ());
+ if (boost::filesystem::exists (path)) {
+ shared_ptr<AudioAnalysis> an (new AudioAnalysis (path));
+ if (an->sample_peak() || an->true_peak()) {
+ float const peak = max (an->sample_peak().get_value_or(0), an->true_peak().get_value_or(0));
+ float const peak_dB = 20 * log10 (peak) + an->gain_correction (film->playlist ());
+ if (peak_dB > -3 && peak_dB < -0.5) {
+ hint = true;
+ _text->WriteText (_("Your audio level is very high. You should reduce the gain of your audio content."));
+ _text->Newline ();
+ } else if (peak_dB > -0.5) {
+ hint = true;
+ _text->WriteText (_("Your audio level is very close to clipping. You should reduce the gain of your audio content."));
+ _text->Newline ();
+ }
+ }
+ }
+
_text->EndSymbolBullet ();
if (!hint) {