You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
976B

  1. #include <assert.h>
  2. #include <vector>
  3. #include "FrequencyShifter.h"
  4. #include "TestComposite.h"
  5. using Shifter = FrequencyShifter<TestComposite>;
  6. // just test the can compile, etc..
  7. static void test0()
  8. {
  9. Shifter fs;
  10. fs.setSampleRate(44100);
  11. fs.init();
  12. fs.step();
  13. }
  14. // test for signal
  15. static void test1()
  16. {
  17. Shifter fs;
  18. fs.setSampleRate(44100);
  19. fs.init();
  20. fs.inputs[Shifter::AUDIO_INPUT].value = 0;
  21. // with no input, should have no output
  22. for (int i = 0; i < 50; ++i) {
  23. fs.step();
  24. assert(fs.outputs[Shifter::SIN_OUTPUT].value == 0);
  25. }
  26. fs.inputs[Shifter::AUDIO_INPUT].value = 1;
  27. // this should produce output
  28. for (int i = 0; i < 50; ++i) {
  29. fs.step();
  30. assert(!AudioMath::closeTo(fs.outputs[Shifter::SIN_OUTPUT].value, 0, .00001));
  31. assert(!AudioMath::closeTo(fs.outputs[Shifter::COS_OUTPUT].value, 0, .00001));
  32. }
  33. }
  34. void testFrequencyShifter()
  35. {
  36. test0();
  37. test1();
  38. }