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.

66 lines
2.1KB

  1. /*
  2. ==============================================================================
  3. This file was auto-generated!
  4. ==============================================================================
  5. */
  6. #pragma once
  7. #include "../JuceLibraryCode/JuceHeader.h"
  8. //==============================================================================
  9. /*
  10. This component lives inside our window, and this is where you should put all
  11. your controls and content.
  12. */
  13. class MainContentComponent : public Component, private Slider::Listener
  14. {
  15. public:
  16. //==============================================================================
  17. MainContentComponent()
  18. {
  19. setSize (200, 200);
  20. rotaryKnob.setRange (0.0, 1.0);
  21. rotaryKnob.setSliderStyle (Slider::RotaryVerticalDrag);
  22. rotaryKnob.setTextBoxStyle (Slider::TextBoxBelow, true, 150, 25);
  23. rotaryKnob.setBounds (10, 10, 180, 180);
  24. addAndMakeVisible (rotaryKnob);
  25. rotaryKnob.addListener (this);
  26. // specify here where to send OSC messages to: host URL and UDP port number
  27. if (! sender.connect ("127.0.0.1", 9001))
  28. showConnectionErrorMessage ("Error: could not connect to UDP port 9001.");
  29. }
  30. private:
  31. //==============================================================================
  32. void sliderValueChanged (Slider* slider) override
  33. {
  34. if (slider == &rotaryKnob)
  35. {
  36. // create and send an OSC message with an address and a float value:
  37. if (! sender.send ("/juce/rotaryknob", (float) rotaryKnob.getValue()))
  38. showConnectionErrorMessage ("Error: could not send OSC message.");
  39. }
  40. }
  41. void showConnectionErrorMessage (const String& messageText)
  42. {
  43. AlertWindow::showMessageBoxAsync (
  44. AlertWindow::WarningIcon,
  45. "Connection error",
  46. messageText,
  47. "OK");
  48. }
  49. //==============================================================================
  50. Slider rotaryKnob;
  51. OSCSender sender;
  52. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  53. };