src/media/audio/audio_core/mixer/test/mixer_bitwise_tests.cc
// Do we correctly mix stereo to mono, when channels sum to exactly zero
Do we correctly mix stereo to mono, when channels sum to exactly zero
Do we correctly mix stereo to mono when channels sum to exactly zero
TEST(PassThru, StereoToMono_Cancel) {
  int16_t source[] = {32767, -32767, -23130, 23130, 0, 0, 1, -1, -13107, 13107, 3855, -3855};
  float accum[6];
  auto mixer = SelectMixer(fuchsia::media::AudioSampleFormat::SIGNED_16, 2, 48000, 1, 48000,
                           Resampler::SampleAndHold);
  DoMix(mixer.get(), source, accum, false, std::size(accum));
  EXPECT_THAT(accum, Each(FloatEq(0.0f)));
  std::memset(accum, 0, std::size(accum) * sizeof(float));
  mixer = SelectMixer(fuchsia::media::AudioSampleFormat::SIGNED_16, 2, 48000, 1, 48000,
                      Resampler::LinearInterpolation);
  DoMix(mixer.get(), source, accum, false, std::size(accum));
  EXPECT_THAT(accum, Each(FloatEq(0.0f)));
}
TEST ( PassThru , StereoToMono_Cancel ) { int16_t source [ ] = { 32767 , -32767 , -23130 , 23130 , 0 , 0 , 1 , -1 , -13107 , 13107 , 3855 , -3855 } ; float accum [ 6 ] ; auto mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: SIGNED_16 , 2 , 48000 , 1 , 48000 , Resampler :: SampleAndHold ) ; DoMix ( mixer . get ( ) , source , accum , false , std :: size ( accum ) ) ; EXPECT_THAT ( accum , Each ( FloatEq ( 0.0f ) ) ) ; std :: memset ( accum , 0 , std :: size ( accum ) * sizeof ( float ) ) ; mixer = SelectMixer ( fuchsia :: media :: AudioSampleFormat :: SIGNED_16 , 2 , 48000 , 1 , 48000 , Resampler :: LinearInterpolation ) ; DoMix ( mixer . get ( ) , source , accum , false , std :: size ( accum ) ) ; EXPECT_THAT ( accum , Each ( FloatEq ( 0.0f ) ) ) ; }
Do we correctly mix stereo to mono, when channels sum to exactly zero
Do we correctly mix stereo to mono when channels sum to exactly zero
// Now try with the other resampler