DISTRHO Plugin Framework
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.

115 lines
3.3KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "DistrhoPluginInternal.hpp"
  17. START_NAMESPACE_DISTRHO
  18. /* ------------------------------------------------------------------------------------------------------------
  19. * Static data, see DistrhoPluginInternal.hpp */
  20. uint32_t d_lastBufferSize = 0;
  21. double d_lastSampleRate = 0.0;
  22. /* ------------------------------------------------------------------------------------------------------------
  23. * Static fallback data, see DistrhoPluginInternal.hpp */
  24. const d_string PluginExporter::sFallbackString;
  25. const ParameterRanges PluginExporter::sFallbackRanges;
  26. /* ------------------------------------------------------------------------------------------------------------
  27. * Plugin */
  28. Plugin::Plugin(const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount)
  29. : pData(new PrivateData())
  30. {
  31. if (parameterCount > 0)
  32. {
  33. pData->parameterCount = parameterCount;
  34. pData->parameters = new Parameter[parameterCount];
  35. }
  36. #if DISTRHO_PLUGIN_WANT_PROGRAMS
  37. if (programCount > 0)
  38. {
  39. pData->programCount = programCount;
  40. pData->programNames = new d_string[programCount];
  41. }
  42. #else
  43. DISTRHO_SAFE_ASSERT(programCount == 0);
  44. #endif
  45. #if DISTRHO_PLUGIN_WANT_STATE
  46. if (stateCount > 0)
  47. {
  48. pData->stateCount = stateCount;
  49. pData->stateKeys = new d_string[stateCount];
  50. }
  51. #else
  52. DISTRHO_SAFE_ASSERT(stateCount == 0);
  53. #endif
  54. }
  55. Plugin::~Plugin()
  56. {
  57. delete pData;
  58. }
  59. /* ------------------------------------------------------------------------------------------------------------
  60. * Host state */
  61. uint32_t Plugin::d_getBufferSize() const noexcept
  62. {
  63. return pData->bufferSize;
  64. }
  65. double Plugin::d_getSampleRate() const noexcept
  66. {
  67. return pData->sampleRate;
  68. }
  69. #if DISTRHO_PLUGIN_WANT_TIMEPOS
  70. const TimePos& Plugin::d_getTimePos() const noexcept
  71. {
  72. return pData->timePos;
  73. }
  74. #endif
  75. #if DISTRHO_PLUGIN_WANT_LATENCY
  76. void Plugin::d_setLatency(const uint32_t frames) noexcept
  77. {
  78. pData->latency = frames;
  79. }
  80. #endif
  81. #if DISTRHO_PLUGIN_HAS_MIDI_OUTPUT
  82. bool Plugin::d_writeMidiEvent(const MidiEvent& /*midiEvent*/) noexcept
  83. {
  84. // TODO
  85. return false;
  86. }
  87. #endif
  88. /* ------------------------------------------------------------------------------------------------------------
  89. * Callbacks (optional) */
  90. void Plugin::d_bufferSizeChanged(uint32_t) {}
  91. void Plugin::d_sampleRateChanged(double) {}
  92. // -----------------------------------------------------------------------------------------------------------
  93. END_NAMESPACE_DISTRHO