X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fupmixer_a.cc;h=e6ec09c6a9530b2166b50ce3762eed10fdc05f94;hp=1edc0104db5337b6583addc9f396f354e48481ab;hb=b9842263a402b5ce1d2f85a1346ca11a419f816e;hpb=9a2dca23967ff404dab1a36ec3fb9075d5e8e66e diff --git a/src/lib/upmixer_a.cc b/src/lib/upmixer_a.cc index 1edc0104d..e6ec09c6a 100644 --- a/src/lib/upmixer_a.cc +++ b/src/lib/upmixer_a.cc @@ -71,7 +71,7 @@ UpmixerA::clone (int sampling_rate) const } shared_ptr -UpmixerA::run (shared_ptr in) +UpmixerA::run (shared_ptr in, int channels) { /* Input L and R */ shared_ptr in_L = in->channel (0); @@ -83,20 +83,25 @@ UpmixerA::run (shared_ptr in) in_LR->apply_gain (0.5); /* Run filters */ - shared_ptr L = _left.run (in_L); - shared_ptr R = _right.run (in_R); - shared_ptr C = _centre.run (in_LR); - shared_ptr Lfe = _lfe.run (in_LR); - shared_ptr Ls = _ls.run (in_L); - shared_ptr Rs = _rs.run (in_R); - - shared_ptr out (new AudioBuffers (6, in->frames ())); - out->copy_channel_from (L.get(), 0, 0); - out->copy_channel_from (R.get(), 0, 1); - out->copy_channel_from (C.get(), 0, 2); - out->copy_channel_from (Lfe.get(), 0, 3); - out->copy_channel_from (Ls.get(), 0, 4); - out->copy_channel_from (Rs.get(), 0, 5); + vector > all_out; + all_out.push_back (_left.run (in_L)); + all_out.push_back (_right.run (in_R)); + all_out.push_back (_centre.run (in_LR)); + all_out.push_back (_lfe.run (in_LR)); + all_out.push_back (_ls.run (in_L)); + all_out.push_back (_rs.run (in_R)); + + shared_ptr out (new AudioBuffers (channels, in->frames ())); + int const N = min (channels, 6); + + for (int i = 0; i < N; ++i) { + out->copy_channel_from (all_out[i].get(), 0, i); + } + + for (int i = N; i < channels; ++i) { + out->make_silent (i); + } + return out; }