Merge master.
[dcpomatic.git] / src / lib / audio_mapping.h
index 8804bde06174f8e9669a02a81ff207ecbd76310a..26087bfffa8f9e04924170444eea908640b6bced 100644 (file)
 
 */
 
+#ifndef DCPOMATIC_AUDIO_MAPPING_H
+#define DCPOMATIC_AUDIO_MAPPING_H
+
 #include <vector>
-#include <map>
-#include <boost/optional.hpp>
 #include <libdcp/types.h>
+#include <boost/shared_ptr.hpp>
 
-class AudioMapping
-{
-public:
-       virtual boost::optional<libdcp::Channel> source_to_dcp (int c) const = 0;
-       virtual boost::optional<int> dcp_to_source (libdcp::Channel c) const = 0;
-};
+namespace xmlpp {
+       class Node;
+}
+
+namespace cxml {
+       class Node;
+}
 
-class AutomaticAudioMapping : public AudioMapping
+/** A many-to-many mapping from some content channels to DCP channels.
+ *  The number of content channels is set on construction and fixed,
+ *  and then each of those content channels are mapped to each DCP channel
+ *  by a linear gain.
+ */
+class AudioMapping
 {
 public:
-       AutomaticAudioMapping (int);
+       AudioMapping ();
+       AudioMapping (int);
+       AudioMapping (boost::shared_ptr<const cxml::Node>, int);
 
-       boost::optional<libdcp::Channel> source_to_dcp (int c) const;
-       boost::optional<int> dcp_to_source (libdcp::Channel c) const;
-       int dcp_channels () const;
+       /* Default copy constructor is fine */
        
-private:
-       int _source_channels;
-};
+       void as_xml (xmlpp::Node *) const;
 
-class ConfiguredAudioMapping : public AudioMapping
-{
-public:
-       boost::optional<libdcp::Channel> source_to_dcp (int c) const;
-       boost::optional<int> dcp_to_source (libdcp::Channel c) const;
+       void make_default ();
+
+       void set (int, libdcp::Channel, float);
+       float get (int, libdcp::Channel) const;
 
+       int content_channels () const {
+               return _content_channels;
+       }
+       
 private:
-       std::map<int, libdcp::Channel> _source_to_dcp;
+       void setup (int);
+       
+       int _content_channels;
+       std::vector<std::vector<float> > _gain;
 };
+
+#endif