Hand-apply bbfb370d7de28ec1e8f307865cc6253bb5d4366e from master; quicker digest calcu...
[dcpomatic.git] / src / lib / audio_content.cc
index d02728b00018f5ed6d8bc023698b6fe4a94c7536..9909e3a08564552da416db3cfc9d6b60ebae9d1d 100644 (file)
@@ -17,8 +17,6 @@
 
 */
 
-#include <libcxml/cxml.h>
-#include <dcp/raw_convert.h>
 #include "audio_content.h"
 #include "analyse_audio_job.h"
 #include "job_manager.h"
 #include "config.h"
 #include "frame_rate_change.h"
 #include "audio_processor.h"
+#include <libcxml/cxml.h>
+#include <dcp/raw_convert.h>
 
 #include "i18n.h"
 
 using std::string;
 using std::cout;
 using std::vector;
+using std::stringstream;
+using std::fixed;
+using std::setprecision;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using dcp::raw_convert;
@@ -87,7 +90,7 @@ AudioContent::AudioContent (shared_ptr<const Film> f, vector<shared_ptr<Content>
        : Content (f, c)
 {
        shared_ptr<AudioContent> ref = dynamic_pointer_cast<AudioContent> (c[0]);
-       assert (ref);
+       DCPOMATIC_ASSERT (ref);
        
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c[i]);
@@ -160,7 +163,7 @@ boost::signals2::connection
 AudioContent::analyse_audio (boost::function<void()> finished)
 {
        shared_ptr<const Film> film = _film.lock ();
-       assert (film);
+       DCPOMATIC_ASSERT (film);
        
        shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, dynamic_pointer_cast<AudioContent> (shared_from_this())));
        boost::signals2::connection c = job->Finished.connect (finished);
@@ -207,7 +210,7 @@ int
 AudioContent::resampled_audio_frame_rate () const
 {
        shared_ptr<const Film> film = _film.lock ();
-       assert (film);
+       DCPOMATIC_ASSERT (film);
        
        /* Resample to a DCI-approved sample rate */
        double t = dcp_audio_frame_rate (audio_frame_rate ());
@@ -236,3 +239,22 @@ AudioContent::processed_audio_channels () const
        return audio_processor()->out_channels (audio_channels ());
 }
 
+string
+AudioContent::processing_description () const
+{
+       stringstream d;
+       
+       if (audio_frame_rate() != resampled_audio_frame_rate ()) {
+               stringstream from;
+               from << fixed << setprecision(3) << (audio_frame_rate() / 1000.0);
+               stringstream to;
+               to << fixed << setprecision(3) << (resampled_audio_frame_rate() / 1000.0);
+
+               d << String::compose (_("Audio will be resampled from %1kHz to %2kHz."), from.str(), to.str());
+       } else {
+               d << _("Audio will not be resampled.");
+       }
+
+       return d.str ();
+}
+