barelymusician/dsp/polyphonic_voice_test.cpp
// Tests that the number of voices that is played by the polyphonic voice is
// capped at maximum allowed number of voices.
Tests that the number of voices that is played by the polyphonic voice is
capped at maximum allowed number of voices.
Tests that the number of voices that is played by the polyphonic voice is capped at maximum allowed number of voices .
TEST(PolyphonicVoiceTest, MaxVoices) {
  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);
  double previous_output = 0.0;
  for (int i = 0; i < kNumVoices; ++i) {
    polyphonic_voice.Start(static_cast<double>(i));
    const double output = polyphonic_voice.Next(kChannel);
    EXPECT_DOUBLE_EQ(output - previous_output, kOutput);
    previous_output = output;
  }
  polyphonic_voice.Start(static_cast<double>(kNumVoices));
  EXPECT_DOUBLE_EQ(polyphonic_voice.Next(kChannel), previous_output);
}
TEST ( PolyphonicVoiceTest , MaxVoices ) { 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 ) ; double previous_output = 0.0 ; for ( int i = 0 ; i < kNumVoices ; ++ i ) { polyphonic_voice . Start ( static_cast < double > ( i ) ) ; const double output = polyphonic_voice . Next ( kChannel ) ; EXPECT_DOUBLE_EQ ( output - previous_output , kOutput ) ; previous_output = output ; } polyphonic_voice . Start ( static_cast < double > ( kNumVoices ) ) ; EXPECT_DOUBLE_EQ ( polyphonic_voice . Next ( kChannel ) , previous_output ) ; }
Tests that the number of voices that is played by the polyphonic voice is
capped at maximum allowed number of voices.
Tests that the number of voices that is played by the polyphonic voice is capped at maximum allowed number of voices .