diff options
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 23 |
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; +} |
