The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

100 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. static Block::UID getBlockUIDFromSerialNumber (const uint8* serial) noexcept
  18. {
  19. Block::UID n = {};
  20. for (int i = 0; i < (int) sizeof (BlocksProtocol::BlockSerialNumber); ++i)
  21. n += n * 127 + serial[i];
  22. return n;
  23. }
  24. static Block::UID getBlockUIDFromSerialNumber (const BlocksProtocol::BlockSerialNumber& serial) noexcept
  25. {
  26. return getBlockUIDFromSerialNumber (serial.serial);
  27. }
  28. static Block::UID getBlockUIDFromSerialNumber (const juce::String& serial) noexcept
  29. {
  30. if (serial.length() < (int) sizeof (BlocksProtocol::BlockSerialNumber))
  31. {
  32. jassertfalse;
  33. return getBlockUIDFromSerialNumber (serial.paddedRight ('0', sizeof (BlocksProtocol::BlockSerialNumber)));
  34. }
  35. return getBlockUIDFromSerialNumber ((const uint8*) serial.toRawUTF8());
  36. }
  37. Block::Block (const juce::String& serial)
  38. : serialNumber (serial), uid (getBlockUIDFromSerialNumber (serial))
  39. {
  40. }
  41. Block::~Block() {}
  42. void Block::addDataInputPortListener (DataInputPortListener* listener) { dataInputPortListeners.add (listener); }
  43. void Block::removeDataInputPortListener (DataInputPortListener* listener) { dataInputPortListeners.remove (listener); }
  44. bool Block::ConnectionPort::operator== (const ConnectionPort& other) const noexcept { return edge == other.edge && index == other.index; }
  45. bool Block::ConnectionPort::operator!= (const ConnectionPort& other) const noexcept { return ! operator== (other); }
  46. //==============================================================================
  47. TouchSurface::TouchSurface (Block& b) : block (b) {}
  48. TouchSurface::~TouchSurface() {}
  49. TouchSurface::Listener::~Listener() {}
  50. void TouchSurface::addListener (Listener* l) { listeners.add (l); }
  51. void TouchSurface::removeListener (Listener* l) { listeners.remove (l); }
  52. //==============================================================================
  53. ControlButton::ControlButton (Block& b) : block (b) {}
  54. ControlButton::~ControlButton() {}
  55. ControlButton::Listener::~Listener() {}
  56. void ControlButton::addListener (Listener* l) { listeners.add (l); }
  57. void ControlButton::removeListener (Listener* l) { listeners.remove (l); }
  58. //==============================================================================
  59. LEDGrid::LEDGrid (Block& b) : block (b) {}
  60. LEDGrid::~LEDGrid() {}
  61. LEDGrid::Program::Program (LEDGrid& l) : ledGrid (l) {}
  62. LEDGrid::Program::~Program() {}
  63. LEDGrid::Renderer::~Renderer() {}
  64. //==============================================================================
  65. LEDRow::LEDRow (Block& b) : block (b) {}
  66. LEDRow::~LEDRow() {}
  67. //==============================================================================
  68. StatusLight::StatusLight (Block& b) : block (b) {}
  69. StatusLight::~StatusLight() {}