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.

61 lines
1.0KB

  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. float values[PORT_MAX_CHANNELS] = {};
  10. /** DEPRECATED. Use getVoltage() and setVoltage() instead. */
  11. float value;
  12. };
  13. /** Number of polyphonic channels
  14. May be 0 to PORT_MAX_CHANNELS.
  15. */
  16. union {
  17. uint8_t channels = 1;
  18. /** DEPRECATED. Use isActive() instead. */
  19. bool active;
  20. };
  21. /** For rendering plug lights on cables
  22. Green for positive, red for negative, and blue for polyphonic
  23. */
  24. Light plugLights[3];
  25. float getVoltage(int channel = 0) {
  26. return values[channel];
  27. }
  28. void setVoltage(float voltage, int channel = 0) {
  29. values[channel] = voltage;
  30. }
  31. void setChannels(int channels) {
  32. // Set higher channel values to 0
  33. for (int c = channels; c < this->channels; c++) {
  34. values[c] = 0.f;
  35. }
  36. this->channels = channels;
  37. }
  38. int getChannels() {
  39. return channels;
  40. }
  41. bool isActive() {
  42. return channels;
  43. }
  44. void step();
  45. };
  46. } // namespace rack