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.

43 lines
885B

  1. #include "asserts.h"
  2. #include "GMR.h"
  3. #include "TestComposite.h"
  4. #include <set>
  5. using G = GMR<TestComposite>;
  6. // test that we get triggers out
  7. static void test0()
  8. {
  9. G gmr;
  10. std::set<float> data;
  11. gmr.setSampleRate(44100);
  12. gmr.init();
  13. for (int i = 0; i < 10; ++i) {
  14. gmr.inputs[G::CLOCK_INPUT].value = 0;
  15. for (int i = 0; i < 100; ++i) {
  16. gmr.step();
  17. float out = gmr.outputs[G::TRIGGER_OUTPUT].value;
  18. data.insert(out);
  19. }
  20. gmr.inputs[G::CLOCK_INPUT].value = 10;
  21. for (int i = 0; i < 100; ++i) {
  22. gmr.step();
  23. float out = gmr.outputs[G::TRIGGER_OUTPUT].value;
  24. data.insert(out);
  25. }
  26. }
  27. assert(data.find(cGateOutHi) != data.end());
  28. assert(data.find(cGateOutLow) != data.end());
  29. assertEQ(data.size(), 2);
  30. }
  31. void testGMR()
  32. {
  33. test0();
  34. }