- node->add_child ("ContentChannels")->add_child_text (lexical_cast<string> (_content_channels));
-
- for (int c = 0; c < _content_channels; ++c) {
- for (int d = 0; d < MAX_AUDIO_CHANNELS; ++d) {
- xmlpp::Element* t = node->add_child ("Gain");
- t->set_attribute ("Content", lexical_cast<string> (c));
- t->set_attribute ("DCP", lexical_cast<string> (d));
- t->add_child_text (lexical_cast<string> (get (c, static_cast<dcp::Channel> (d))));
+ node->add_child ("InputChannels")->add_child_text (raw_convert<string> (_input_channels));
+ node->add_child ("OutputChannels")->add_child_text (raw_convert<string> (_output_channels));
+
+ for (int c = 0; c < _input_channels; ++c) {
+ for (int d = 0; d < _output_channels; ++d) {
+ auto t = node->add_child ("Gain");
+ t->set_attribute ("Input", raw_convert<string> (c));
+ t->set_attribute ("Output", raw_convert<string> (d));
+ t->add_child_text (raw_convert<string> (get (c, d)));
+ }
+ }
+}
+
+
+/** @return a string which is unique for a given AudioMapping configuration, for
+ * differentiation between different AudioMappings.
+ */
+string
+AudioMapping::digest () const
+{
+ Digester digester;
+ digester.add (_input_channels);
+ digester.add (_output_channels);
+ for (int i = 0; i < _input_channels; ++i) {
+ for (int j = 0; j < _output_channels; ++j) {
+ digester.add (_gain[i][j]);
+ }
+ }
+
+ return digester.get ();
+}
+
+
+list<int>
+AudioMapping::mapped_output_channels () const
+{
+ static float const minus_96_db = 0.000015849;
+
+ list<int> mapped;
+
+ for (auto const& i: _gain) {
+ for (auto j: dcp::used_audio_channels()) {
+ if (abs(i[static_cast<int>(j)]) > minus_96_db) {
+ mapped.push_back (static_cast<int>(j));
+ }
+ }
+ }
+
+ mapped.sort ();
+ mapped.unique ();
+
+ return mapped;
+}
+
+
+void
+AudioMapping::unmap_all ()
+{
+ for (auto& i: _gain) {
+ for (auto& j: i) {
+ j = 0;