Audio plugin host https://kx.studio/carla
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.

102 lines
2.3KB

  1. /*
  2. * DISTHRO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the license see the GPL.txt file
  16. */
  17. #include "DistrhoUIInternal.h"
  18. START_NAMESPACE_DISTRHO
  19. // -------------------------------------------------
  20. double d_lastUiSampleRate = 0.0;
  21. // -------------------------------------------------
  22. UI::UI()
  23. {
  24. data = new UIPrivateData;
  25. #if (defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2))
  26. data->parameterOffset = DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
  27. # if DISTRHO_PLUGIN_WANT_LATENCY
  28. data->parameterOffset += 1;
  29. # endif
  30. data->parameterOffset += 1; // sample-rate
  31. #endif
  32. #ifdef DISTRHO_UI_QT4
  33. data->widget = (Qt4UI*)this;
  34. #endif
  35. }
  36. UI::~UI()
  37. {
  38. delete data;
  39. }
  40. // -------------------------------------------------
  41. // Host DSP State
  42. double UI::d_sampleRate() const
  43. {
  44. return data->sampleRate;
  45. }
  46. void UI::d_setParameterValue(uint32_t index, float value)
  47. {
  48. data->setParamCallback(index + data->parameterOffset, value);
  49. }
  50. #if DISTRHO_PLUGIN_WANT_STATE
  51. void UI::d_setState(const char* key, const char* value)
  52. {
  53. data->setStateCallback(key, value);
  54. }
  55. #endif
  56. // -------------------------------------------------
  57. // Host UI State
  58. void UI::d_uiEditParameter(uint32_t index, bool started)
  59. {
  60. data->uiEditParamCallback(index, started);
  61. }
  62. #if DISTRHO_PLUGIN_IS_SYNTH
  63. void UI::d_uiSendNote(bool onOff, uint8_t channel, uint8_t note, uint8_t velocity)
  64. {
  65. data->uiSendNoteCallback(onOff, channel, note, velocity);
  66. }
  67. #endif
  68. void UI::d_uiResize(unsigned int width, unsigned int height)
  69. {
  70. data->uiResizeCallback(width, height);
  71. }
  72. // -------------------------------------------------
  73. // DSP Callbacks
  74. #if DISTRHO_PLUGIN_IS_SYNTH
  75. void UI::d_uiNoteReceived(bool, uint8_t, uint8_t, uint8_t)
  76. {
  77. }
  78. #endif
  79. // -------------------------------------------------
  80. END_NAMESPACE_DISTRHO