Back port active_frame_rate_change stuff from v2, removing specification of video...
[dcpomatic.git] / src / lib / audio_content.cc
index 1896c4d5c356ad5105ab952c2e9f0067a2c77931..bf00b672a67d75188de664093ab9d67605fa88f7 100644 (file)
 #include "film.h"
 #include "exceptions.h"
 #include "config.h"
+#include "frame_rate_change.h"
 
 #include "i18n.h"
 
 using std::string;
+using std::cout;
 using std::vector;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
@@ -139,7 +141,7 @@ AudioContent::audio_analysis_path () const
        }
 
        boost::filesystem::path p = film->audio_analysis_dir ();
-       p /= digest ();
+       p /= digest() + "_" + audio_mapping().digest();
        return p;
 }
 
@@ -148,3 +150,28 @@ AudioContent::technical_summary () const
 {
        return String::compose ("audio: channels %1, length %2, raw rate %3, out rate %4", audio_channels(), audio_length(), content_audio_frame_rate(), output_audio_frame_rate());
 }
+
+int
+AudioContent::output_audio_frame_rate () const
+{
+       shared_ptr<const Film> film = _film.lock ();
+       assert (film);
+       
+       /* Resample to a DCI-approved sample rate */
+       double t = dcp_audio_frame_rate (content_audio_frame_rate ());
+
+       FrameRateChange frc = film->active_frame_rate_change (position ());
+
+       /* Compensate if the DCP is being run at a different frame rate
+          to the source; that is, if the video is run such that it will
+          look different in the DCP compared to the source (slower or faster).
+          skip/repeat doesn't come into effect here.
+       */
+
+       if (frc.change_speed) {
+               t /= frc.speed_up;
+       }
+
+       return rint (t);
+}
+