summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-06-01 14:23:56 +0100
committerCarl Hetherington <cth@carlh.net>2017-06-01 14:23:56 +0100
commit3c86d70cf46ca11212ae2e2f4d711db0f478c2f5 (patch)
tree5b160eca7b1569eeecb8203b39bb98b97e1fa617 /src/lib/util.cc
parent769ce034cbb2f95f01dba3d22f7bd554ecb14f3e (diff)
Re-add missing audio mapping in butler for preview.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 0ce538cdf..4ffe3bd12 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -36,6 +36,7 @@
#include "digester.h"
#include "audio_processor.h"
#include "compose.hpp"
+#include "audio_buffers.h"
#include <dcp/locale_convert.h>
#include <dcp/util.h>
#include <dcp/raw_convert.h>
@@ -735,3 +736,25 @@ audio_channel_types (list<int> mapped, int channels)
return make_pair (non_lfe, lfe);
}
+
+shared_ptr<AudioBuffers>
+remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map)
+{
+ shared_ptr<AudioBuffers> mapped (new AudioBuffers (output_channels, input->frames()));
+ mapped->make_silent ();
+
+ for (int i = 0; i < map.input_channels(); ++i) {
+ for (int j = 0; j < mapped->channels(); ++j) {
+ if (map.get (i, static_cast<dcp::Channel> (j)) > 0) {
+ mapped->accumulate_channel (
+ input.get(),
+ i,
+ static_cast<dcp::Channel> (j),
+ map.get (i, static_cast<dcp::Channel> (j))
+ );
+ }
+ }
+ }
+
+ return mapped;
+}