Hint on high audio levels (part of #822).
authorCarl Hetherington <cth@carlh.net>
Wed, 25 May 2016 22:49:02 +0000 (23:49 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 25 May 2016 22:49:02 +0000 (23:49 +0100)
ChangeLog
src/wx/hints_dialog.cc

index 8756166b4794fe17c26adafc42cf9a0ccb28ef01..aa661e3371c9c00c26ebd77c6cca8c8637d4dd3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-05-25  Carl Hetherington  <cth@carlh.net>
 
+       * Add hint about excessive audio level (part of #822).
+
        * Updated nl_NL translation from Rob van Nieuwkerk.
 
 2016-05-25  c.hetherington  <cth@carlh.net>
index a2eefd39fc87658350e2995f207ad84daebc9519..72ab0eef41f84e6e7fbac6772bf1eee7895768b0 100644 (file)
 #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) {