lvmtest: Add mono mode for audio effect testing.

This ensures all input audio channels are identical
by replicating the first audio channel of each
audio frame to the other channels.

Test: Use lvmtest with -M
Bug: 121331591
Change-Id: Ie85b6511397a97c9d0f3451328d128048c803ce5
diff --git a/media/libeffects/lvm/tests/lvmtest.cpp b/media/libeffects/lvm/tests/lvmtest.cpp
index 99551cc..43271d2 100644
--- a/media/libeffects/lvm/tests/lvmtest.cpp
+++ b/media/libeffects/lvm/tests/lvmtest.cpp
@@ -76,6 +76,7 @@
   int              samplingFreq    = 44100;
   int              nrChannels      = 2;
   int              fChannels       = 2;
+  bool             monoMode        = false;
   int              bassEffectLevel = 0;
   int              eqPresetLevel   = 0;
   int              frameLength     = 256;
@@ -98,6 +99,8 @@
   printf("\n");
   printf("\n     -ch:<process_channels> (1 through 8)\n\n");
   printf("\n     -fch:<file_channels> (1 through 8)\n\n");
+  printf("\n     -M");
+  printf("\n           Mono mode (force all input audio channels to be identical)");
   printf("\n     -basslvl:<effect_level>");
   printf("\n           A value that ranges between 0 - 15 default 0");
   printf("\n");
@@ -612,6 +615,15 @@
     }
     memcpy_to_float_from_i16(floatIn.data(), in.data(), frameLength * channelCount);
 
+    // Mono mode will replicate the first channel to all other channels.
+    // This ensures all audio channels are identical. This is useful for testing
+    // Bass Boost, which extracts a mono signal for processing.
+    if (plvmConfigParams->monoMode && channelCount > 1) {
+        for (int i = 0; i < frameLength; ++i) {
+            auto *fp = &floatIn[i * channelCount];
+            std::fill(fp + 1, fp + channelCount, *fp); // replicate ch 0
+        }
+    }
 #if 1
     errCode = lvmExecute(floatIn.data(), floatOut.data(), &context, plvmConfigParams);
     if (errCode) {
@@ -677,6 +689,8 @@
              return -1;
            }
            lvmConfigParams.fChannels = fChannels;
+    } else if (!strcmp(argv[i],"-M")) {
+          lvmConfigParams.monoMode = true;
     } else if (!strncmp(argv[i], "-basslvl:", 9)) {
       const int bassEffectLevel = atoi(argv[i] + 9);
       if (bassEffectLevel > 15 || bassEffectLevel < 0) {