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.

36 lines
772B

  1. #include <engine/Port.hpp>
  2. namespace rack {
  3. namespace engine {
  4. void Port::process(float deltaTime) {
  5. // Set plug lights
  6. if (channels == 0) {
  7. plugLights[0].setBrightness(0.f);
  8. plugLights[1].setBrightness(0.f);
  9. plugLights[2].setBrightness(0.f);
  10. }
  11. else if (channels == 1) {
  12. float v = getVoltage() / 10.f;
  13. plugLights[0].setSmoothBrightness(v, deltaTime);
  14. plugLights[1].setSmoothBrightness(-v, deltaTime);
  15. plugLights[2].setBrightness(0.f);
  16. }
  17. else {
  18. float v2 = 0.f;
  19. for (int c = 0; c < channels; c++) {
  20. v2 += std::pow(getVoltage(c), 2);
  21. }
  22. float v = std::sqrt(v2) / 10.f;
  23. plugLights[0].setBrightness(0.f);
  24. plugLights[1].setBrightness(0.f);
  25. plugLights[2].setSmoothBrightness(v, deltaTime);
  26. }
  27. }
  28. } // namespace engine
  29. } // namespace rack