barelymusician/dsp/polyphonic_voice_test.cpp
// Tests that voice initialization callback produces the expected output.
Tests that voice initialization callback produces the expected output.
Tests that voice initialization callback produces the expected output .
TEST(PolyphonicVoiceTest, StartVoiceWithInit) {
  FakeVoice base_voice;
  base_voice.SetOutput(kOutput);
  PolyphonicVoice<FakeVoice> polyphonic_voice(std::move(base_voice));
  polyphonic_voice.Resize(kNumVoices);
  EXPECT_DOUBLE_EQ(polyphonic_voice.Next(kChannel), 0.0);
  for (int i = 0; i < kNumVoices; ++i) {
    const double pitch = static_cast<double>(i + 1);
    polyphonic_voice.Start(
        pitch, [pitch](FakeVoice* voice) { voice->SetOutput(pitch); });
    EXPECT_DOUBLE_EQ(polyphonic_voice.Next(kChannel), pitch);
    polyphonic_voice.Stop(pitch);
  }
}
TEST ( PolyphonicVoiceTest , StartVoiceWithInit ) { FakeVoice base_voice ; base_voice . SetOutput ( kOutput ) ; PolyphonicVoice < FakeVoice > polyphonic_voice ( std :: move ( base_voice ) ) ; polyphonic_voice . Resize ( kNumVoices ) ; EXPECT_DOUBLE_EQ ( polyphonic_voice . Next ( kChannel ) , 0.0 ) ; for ( int i = 0 ; i < kNumVoices ; ++ i ) { const double pitch = static_cast < double > ( i + 1 ) ; polyphonic_voice . Start ( pitch , [ pitch ] ( FakeVoice * voice ) { voice -> SetOutput ( pitch ) ; } ) ; EXPECT_DOUBLE_EQ ( polyphonic_voice . Next ( kChannel ) , pitch ) ; polyphonic_voice . Stop ( pitch ) ; } }
Tests that voice initialization callback produces the expected output.
Tests that voice initialization callback produces the expected output .