summaryrefslogtreecommitdiff
path: root/src/lib/playlist.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-06 23:57:46 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-06 23:57:46 +0100
commitc921cfe23b593d7c367ad76094308c5f08037374 (patch)
treed010137615eb3817e57edaf0b0753ef924569965 /src/lib/playlist.cc
parent8750efb9e072cf3b42e6c3c29521c7031c0b5dfd (diff)
Various work on audio channel mapping.
Diffstat (limited to 'src/lib/playlist.cc')
-rw-r--r--src/lib/playlist.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index e0220ef6f..3f7905fa9 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -30,6 +30,7 @@
using std::list;
using std::cout;
using std::vector;
+using std::min;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
@@ -224,3 +225,47 @@ Playlist::content_changed (weak_ptr<Content> c, int p)
{
ContentChanged (c, p);
}
+
+AudioMapping
+Playlist::default_audio_mapping () const
+{
+ AudioMapping m;
+
+ switch (_audio_from) {
+ case AUDIO_NONE:
+ break;
+ case AUDIO_FFMPEG:
+ if (_ffmpeg->audio_channels() == 1) {
+ /* Map mono sources to centre */
+ m.add (AudioMapping::Channel (_ffmpeg, 0), libdcp::CENTRE);
+ } else {
+ int const N = min (_ffmpeg->audio_channels (), MAX_AUDIO_CHANNELS);
+ /* Otherwise just start with a 1:1 mapping */
+ for (int i = 0; i < N; ++i) {
+ m.add (AudioMapping::Channel (_ffmpeg, i), (libdcp::Channel) i);
+ }
+ }
+ break;
+
+ case AUDIO_SNDFILE:
+ {
+ int n = 0;
+ for (list<shared_ptr<const SndfileContent> >::const_iterator i = _sndfile.begin(); i != _sndfile.end(); ++i) {
+ cout << "sndfile " << (*i)->audio_channels() << "\n";
+ for (int j = 0; j < (*i)->audio_channels(); ++j) {
+ m.add (AudioMapping::Channel (*i, j), (libdcp::Channel) n);
+ ++n;
+ if (n >= MAX_AUDIO_CHANNELS) {
+ break;
+ }
+ }
+ if (n >= MAX_AUDIO_CHANNELS) {
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ return m;
+}