/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
+/** @file src/lib/audio_mapping.h
+ * @brief AudioMapping class.
+ */
+
#ifndef DCPOMATIC_AUDIO_MAPPING_H
#define DCPOMATIC_AUDIO_MAPPING_H
-#include <list>
-#include <string>
-#include <libdcp/types.h>
+#include <vector>
#include <boost/shared_ptr.hpp>
-#include "audio_content.h"
+#include <dcp/types.h>
+#include <libcxml/cxml.h>
+
+namespace xmlpp {
+ class Node;
+}
+namespace cxml {
+ class Node;
+}
+
+/** @class AudioMapping.
+ * @brief 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:
- void as_xml (xmlpp::Node *) const;
- void set_from_xml (ContentList const &, boost::shared_ptr<const cxml::Node>);
+ AudioMapping ();
+ AudioMapping (int channels);
+ AudioMapping (cxml::ConstNodePtr, int);
+
+ /* Default copy constructor is fine */
- struct Channel {
- Channel (boost::weak_ptr<const AudioContent> c, int i)
- : content (c)
- , index (i)
- {}
-
- boost::weak_ptr<const AudioContent> content;
- int index;
- };
-
- void add (Channel, libdcp::Channel);
-
- int dcp_channels () const;
- std::list<Channel> dcp_to_content (libdcp::Channel) const;
- std::list<std::pair<Channel, libdcp::Channel> > content_to_dcp () const {
- return _content_to_dcp;
- }
+ void as_xml (xmlpp::Node *) const;
- std::list<Channel> content_channels () const;
- std::list<libdcp::Channel> content_to_dcp (Channel) const;
+ void make_default ();
+ void set (int, dcp::Channel, float);
+ float get (int, dcp::Channel) const;
+
+ int content_channels () const {
+ return _content_channels;
+ }
+
+ std::string digest () const;
+
private:
- std::list<std::pair<Channel, libdcp::Channel> > _content_to_dcp;
+ void setup (int);
+
+ int _content_channels;
+ std::vector<std::vector<float> > _gain;
};
-extern bool operator== (AudioMapping::Channel const &, AudioMapping::Channel const &);
-
#endif