Select active channels on opening audio analysis (#802).
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Apr 2016 13:29:08 +0000 (14:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Apr 2016 13:29:31 +0000 (14:29 +0100)
ChangeLog
src/lib/film.cc
src/lib/film.h
src/wx/audio_dialog.cc
src/wx/audio_dialog.h

index b867e7943618d2ba2c6a699acaa914e65b9b2179..f279abba4e8513ea098ccccb10cd829bad4d3f02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-04-22  c.hetherington  <cth@carlh.net>
 
+       * Select active channels on opening audio analysis (#802).
+
        * Disallow KDM until times from being before from times (#821).
 
        * Warn when loading certificates from files that have
index 1775f7c7f94e2a3efa0ecffe851f363f9ff32580..b80962ead59c47a5bb11f64f5aefae34192d66a9 100644 (file)
@@ -493,6 +493,32 @@ Film::file (boost::filesystem::path f) const
        return p;
 }
 
+list<int>
+Film::mapped_audio_channels () const
+{
+       list<int> mapped;
+
+       if (audio_processor ()) {
+               /* Processors are mapped 1:1 to DCP outputs so we can work out mappings from there */
+               for (int i = 0; i < audio_processor()->out_channels(); ++i) {
+                       mapped.push_back (i);
+               }
+       } else {
+               BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+                       shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i);
+                       if (ac) {
+                               list<int> c = ac->audio_mapping().mapped_output_channels ();
+                               copy (c.begin(), c.end(), back_inserter (mapped));
+                       }
+               }
+
+               mapped.sort ();
+               mapped.unique ();
+       }
+
+       return mapped;
+}
+
 /** @return a ISDCF-compliant name for a DCP of this film */
 string
 Film::isdcf_name (bool if_created_now) const
@@ -646,46 +672,21 @@ Film::isdcf_name (bool if_created_now) const
                }
        }
 
-       /* Find all mapped channels */
+       /* Count mapped audio channels */
 
        int non_lfe = 0;
        int lfe = 0;
 
-       if (audio_processor ()) {
-               /* Processors are mapped 1:1 to DCP outputs so we can guess the number of LFE/
-                  non-LFE from the channel counts.
-               */
-               non_lfe = audio_processor()->out_channels ();
-               if (non_lfe >= 4) {
-                       --non_lfe;
-                       ++lfe;
-               }
-       } else {
-               list<int> mapped;
-               BOOST_FOREACH (shared_ptr<Content> i, content ()) {
-                       shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (i);
-                       if (ac) {
-                               list<int> c = ac->audio_mapping().mapped_output_channels ();
-                               copy (c.begin(), c.end(), back_inserter (mapped));
-                       }
+       BOOST_FOREACH (int i, mapped_audio_channels ()) {
+               if (i >= audio_channels()) {
+                       /* This channel is mapped but is not included in the DCP */
+                       continue;
                }
 
-               mapped.sort ();
-               mapped.unique ();
-
-               /* Count them */
-
-               for (list<int>::const_iterator i = mapped.begin(); i != mapped.end(); ++i) {
-                       if (*i >= audio_channels()) {
-                               /* This channel is mapped but is not included in the DCP */
-                               continue;
-                       }
-
-                       if (static_cast<dcp::Channel> (*i) == dcp::LFE) {
-                               ++lfe;
-                       } else {
-                               ++non_lfe;
-                       }
+               if (static_cast<dcp::Channel> (i) == dcp::LFE) {
+                       ++lfe;
+               } else {
+                       ++non_lfe;
                }
        }
 
index b8e31a4205650c08a4fd8775948f93ffca773aa7..4ad905758b2dca65dc5333f0103990304913b0c5 100644 (file)
@@ -154,6 +154,8 @@ public:
 
        std::list<DCPTimePeriod> reels () const;
 
+       std::list<int> mapped_audio_channels () const;
+
        /** Identifiers for the parts of our state;
            used for signalling changes.
        */
index 2117963f62569e0ad9e06f653f8065e544651495..20185bf8f6dca8c33552818fe2b4b25e2c15140c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
 #include "lib/job_manager.h"
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
+#include <boost/foreach.hpp>
 #include <iostream>
 
 using std::cout;
+using std::list;
 using boost::shared_ptr;
 using boost::bind;
 using boost::optional;
@@ -40,6 +42,7 @@ using boost::dynamic_pointer_cast;
 AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<AudioContent> content)
        : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
        , _film (film)
+       , _content (content)
        , _channels (film->audio_channels ())
        , _plot (0)
 {
@@ -168,9 +171,24 @@ AudioDialog::try_to_load_analysis ()
                ++i;
        }
 
-       if (i == _channels && _channel_checkbox[0]) {
-               _channel_checkbox[0]->SetValue (true);
-               _plot->set_channel_visible (0, true);
+       if (i == _channels) {
+               /* Nothing checked; check mapped ones */
+
+               list<int> mapped;
+               shared_ptr<AudioContent> content = _content.lock ();
+
+               if (content) {
+                       mapped = content->audio_mapping().mapped_output_channels ();
+               } else {
+                       mapped = film->mapped_audio_channels ();
+               }
+
+               BOOST_FOREACH (int i, mapped) {
+                       if (_channel_checkbox[i]) {
+                               _channel_checkbox[i]->SetValue (true);
+                               _plot->set_channel_visible (i, true);
+                       }
+               }
        }
 
        i = 0;
index 0f791dc160b0df41571c69378cc774195e3af919..8320171ce9e96dff9cafdb5b1b8944fd8d537b38 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
@@ -45,6 +45,7 @@ private:
 
        boost::shared_ptr<AudioAnalysis> _analysis;
        boost::weak_ptr<Film> _film;
+       boost::weak_ptr<AudioContent> _content;
        int _channels;
        boost::shared_ptr<const Playlist> _playlist;
        AudioPlot* _plot;