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.

52 lines
902B

  1. #pragma once
  2. #include "common.hpp"
  3. #include "engine/Light.hpp"
  4. namespace rack {
  5. static const int PORT_MAX_CHANNELS = 16;
  6. struct Port {
  7. /** Voltage of the port */
  8. union {
  9. /** Accessing this directly is deprecated.
  10. Use getVoltage() and setVoltage() instead
  11. */
  12. float value;
  13. float values[PORT_MAX_CHANNELS] = {};
  14. };
  15. /** Number of polyphonic channels
  16. May be 0 to PORT_MAX_CHANNELS.
  17. */
  18. int channels = 1;
  19. /** Whether a cable is plugged in */
  20. bool active = false;
  21. Light plugLights[2];
  22. float getVoltage(int channel = 0) {
  23. return values[channel];
  24. }
  25. void setVoltage(float voltage, int channel = 0) {
  26. values[channel] = voltage;
  27. }
  28. void setChannels(int channels) {
  29. // Set higher channel values to 0
  30. for (int c = channels; c < this->channels; c++) {
  31. values[c] = 0.f;
  32. }
  33. this->channels = channels;
  34. }
  35. int getChannels() {
  36. return channels;
  37. }
  38. };
  39. } // namespace rack