Adapt for libdcp use of enum class.
[dcpomatic.git] / src / lib / audio_mapping.cc
index 0f330dc2b8ba3acef6c44febec62e199a6b85970..7734d168afb3040a28b4cca27076e6f62e4ee94b 100644 (file)
@@ -134,7 +134,7 @@ AudioMapping::make_default (AudioProcessor const * processor, optional<boost::fi
 
                        if (!guessed) {
                                /* If we have no idea, just put it on centre */
-                               set (0, static_cast<int>(dcp::CENTRE), 1);
+                               set (0, static_cast<int>(dcp::Channel::CENTRE), 1);
                        }
                } else {
                        /* 1:1 mapping */
@@ -156,14 +156,14 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version)
        if (state_version <= 5) {
                /* Old-style: on/off mapping */
                for (auto i: node->node_children ("Map")) {
-                       set (i->number_child<int>("ContentIndex"), static_cast<dcp::Channel>(i->number_child<int>("DCP")), 1);
+                       set (i->number_child<int>("ContentIndex"), i->number_child<int>("DCP"), 1);
                }
        } else {
                for (auto i: node->node_children("Gain")) {
                        if (state_version < 32) {
                                set (
                                        i->number_attribute<int>("Content"),
-                                       static_cast<dcp::Channel>(i->number_attribute<int>("DCP")),
+                                       i->number_attribute<int>("DCP"),
                                        raw_convert<float>(i->content())
                                        );
                        } else {
@@ -177,6 +177,21 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version)
        }
 }
 
+
+void
+AudioMapping::set (dcp::Channel input_channel, int output_channel, float g)
+{
+       set (static_cast<int>(input_channel), output_channel, g);
+}
+
+
+void
+AudioMapping::set (int input_channel, dcp::Channel output_channel, float g)
+{
+       set (input_channel, static_cast<int>(output_channel), g);
+}
+
+
 void
 AudioMapping::set (int input_channel, int output_channel, float g)
 {
@@ -185,6 +200,14 @@ AudioMapping::set (int input_channel, int output_channel, float g)
        _gain[input_channel][output_channel] = g;
 }
 
+
+float
+AudioMapping::get (int input_channel, dcp::Channel output_channel) const
+{
+       return get (input_channel, static_cast<int>(output_channel));
+}
+
+
 float
 AudioMapping::get (int input_channel, int output_channel) const
 {
@@ -236,8 +259,8 @@ AudioMapping::mapped_output_channels () const
 
        for (auto const& i: _gain) {
                for (auto j: dcp::used_audio_channels()) {
-                       if (abs(i[j]) > minus_96_db) {
-                               mapped.push_back (j);
+                       if (abs(i[static_cast<int>(j)]) > minus_96_db) {
+                               mapped.push_back (static_cast<int>(j));
                        }
                }
        }