shithub: aubio

Download patch

ref: 8a4ccf72ab817cfb478ffcc00d89f4b96d6d69dc
parent: ca993258e0a7bf00048cdfeb1fc417b937f26e1a
author: Paul Brossier <piem@piem.org>
date: Fri Nov 16 16:12:45 EST 2018

[source] [avcodec] downmix signal manually

--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -310,8 +310,7 @@
   if ( (multi != s->multi) || (s->avr == NULL) ) {
     int err;
     int64_t input_layout = av_get_default_channel_layout(s->input_channels);
-    uint_t output_channels = multi ? s->input_channels : 1;
-    int64_t output_layout = av_get_default_channel_layout(output_channels);
+    int64_t output_layout = av_get_default_channel_layout(s->input_channels);
 #ifdef HAVE_AVRESAMPLE
     AVAudioResampleContext *avr = avresample_alloc_context();
     AVAudioResampleContext *oldavr = s->avr;
@@ -503,7 +502,12 @@
   while (total_wrote < s->hop_size) {
     end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote);
     for (i = 0; i < end; i++) {
-      read_data->data[i + total_wrote] = s->output[i + s->read_index];
+      read_data->data[i + total_wrote] = 0.;
+      for (j = 0; j < s->input_channels; j++) {
+        read_data->data[i + total_wrote] +=
+          s->output[(i + s->read_index) * s->input_channels + j];
+      }
+      read_data->data[i + total_wrote] *= 1./s->input_channels;
     }
     total_wrote += end;
     if (total_wrote < s->hop_size) {