Some basics of AudioMapping.
[dcpomatic.git] / src / lib / sndfile_content.cc
index 539b0dfb586a4926c47e4e1f3e6678966e254ad9..963abb58e0f63d3dc12e4f91859cc296a5b5f63f 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
@@ -48,6 +50,7 @@ SndfileContent::SndfileContent (shared_ptr<const cxml::Node> node)
        _audio_channels = node->number_child<int> ("AudioChannels");
        _audio_length = node->number_child<ContentAudioFrame> ("AudioLength");
        _audio_frame_rate = node->number_child<int> ("AudioFrameRate");
+       _mapping = AudioMapping (node->node_child ("Mapping"));
 }
 
 string
@@ -68,7 +71,7 @@ SndfileContent::information () const
        s << String::compose (
                _("%1 channels, %2kHz, %3 samples"),
                audio_channels(),
-               audio_frame_rate() / 1000.0,
+               content_audio_frame_rate() / 1000.0,
                audio_length()
                );
        
@@ -103,6 +106,7 @@ SndfileContent::examine (shared_ptr<Film> film, shared_ptr<Job> job, bool quick)
                _audio_channels = dec.audio_channels ();
                _audio_length = dec.audio_length ();
                _audio_frame_rate = dec.audio_frame_rate ();
+               _mapping = AudioMapping (_audio_channels);
        }
 
        signal_changed (AudioContentProperty::AUDIO_CHANNELS);
@@ -118,5 +122,18 @@ SndfileContent::as_xml (xmlpp::Node* node) const
        node->add_child("AudioChannels")->add_child_text (lexical_cast<string> (_audio_channels));
        node->add_child("AudioLength")->add_child_text (lexical_cast<string> (_audio_length));
        node->add_child("AudioFrameRate")->add_child_text (lexical_cast<string> (_audio_frame_rate));
+       _mapping.as_xml (node->add_child("Mapping"));
+}
+
+int
+SndfileContent::output_audio_frame_rate (shared_ptr<const Film>) const
+{
+       /* Resample to a DCI-approved sample rate */
+       return dcp_audio_frame_rate (content_audio_frame_rate ());
 }
 
+Time
+SndfileContent::length (shared_ptr<const Film> film) const
+{
+       return film->audio_frames_to_time (audio_length ());
+}