Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ddafe428 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge changes Ie85b6511,I4df65431

* changes:
  lvmtest: Add mono mode for audio effect testing.
  libeffects: Updated test script for higher frequencies and effects
parents 79a4c0aa b144b4b6
Loading
Loading
Loading
Loading
+61 −22
Original line number Diff line number Diff line
@@ -20,30 +20,69 @@ adb root && adb wait-for-device remount
# location of test files
testdir="/data/local/tmp/lvmTest"

#flags="-bE -tE -eqE -csE"
flags="-csE -tE -eqE"


echo "========================================"
echo "testing lvm"
adb shell mkdir $testdir
adb shell mkdir -p $testdir
adb push $ANDROID_BUILD_TOP/cts/tests/tests/media/res/raw/sinesweepraw.raw $testdir
adb push $OUT/testcases/lvmtest/arm64/lvmtest $testdir

# run multichannel effects at different channel counts, saving only the stereo channel pair.
adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_1.raw\
                          -ch:1 -fs:44100 $flags
adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_2.raw\
                           -ch:2 -fs:44100 $flags
adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_4.raw\
                           -ch:4 -fs:44100 $flags
adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_6.raw\
                           -ch:6 -fs:44100 $flags
adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw -o:$testdir/sinesweep_8.raw\
                           -ch:8 -fs:44100 $flags

# two channel files should be identical to higher channel computation (first 2 channels).
adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_2.raw
adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_4.raw
adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_6.raw
adb shell cmp $testdir/sinesweep_2.raw $testdir/sinesweep_8.raw
flags_arr=(
    "-csE"
    "-eqE"
    "-tE"
    "-csE -tE -eqE"
    "-bE"
    "-csE -tE"
    "-csE -eqE" "-tE -eqE"
    "-csE -tE -bE -eqE"
)

fs_arr=(
    8000
    11025
    12000
    16000
    22050
    24000
    32000
    44100
    48000
    88200
    96000
    176400
    192000
)

ch_arr=(
    1
    2
    4
    6
    8
)

# run multichannel effects at different configs, saving only the stereo channel
# pair.
for flags in "${flags_arr[@]}"
do
    for fs in ${fs_arr[*]}
    do
        for ch in ${ch_arr[*]}
        do
            adb shell $testdir/lvmtest -i:$testdir/sinesweepraw.raw \
                -o:$testdir/sinesweep_$((ch))_$((fs)).raw -ch:$ch -fs:$fs $flags

            # two channel files should be identical to higher channel
            # computation (first 2 channels).
            # Do not compare cases where -bE is in flags (due to mono computation)
            if [[ $flags != *"-bE"* ]] && [ "$ch" -gt 2 ]
            then
                adb shell cmp $testdir/sinesweep_2_$((fs)).raw \
                    $testdir/sinesweep_$((ch))_$((fs)).raw
            fi

        done
    done
done

adb shell rm -r $testdir
+14 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ struct lvmConfigParams_t {
  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 @@ void printUsage() {
  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 @@ int lvmMainProcess(lvmConfigParams_t *plvmConfigParams, FILE *finp, FILE *fout)
    }
    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 @@ int main(int argc, const char *argv[]) {
             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) {