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.

122 lines
3.0KB

  1. /*
  2. * DISTRHO Notes Plugin
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.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 GNU General Public License see the GPL.txt file
  16. */
  17. #include "DistrhoPluginNotes.hpp"
  18. #include <cmath>
  19. START_NAMESPACE_DISTRHO
  20. // -------------------------------------------------
  21. DistrhoPluginNotes::DistrhoPluginNotes()
  22. : Plugin(1, 0, 103) // 1 parameter, 0 programs, 103 states
  23. {
  24. fCurPage = 0;
  25. }
  26. DistrhoPluginNotes::~DistrhoPluginNotes()
  27. {
  28. }
  29. // -------------------------------------------------
  30. // Init
  31. void DistrhoPluginNotes::d_initParameter(uint32_t index, Parameter& parameter)
  32. {
  33. if (index != 0)
  34. return;
  35. parameter.hints = PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER;
  36. parameter.name = "Page";
  37. parameter.symbol = "page";
  38. parameter.ranges.def = 1;
  39. parameter.ranges.min = 1;
  40. parameter.ranges.max = 100;
  41. parameter.ranges.step = 1;
  42. parameter.ranges.stepSmall = 1;
  43. parameter.ranges.stepLarge = 10;
  44. }
  45. void DistrhoPluginNotes::d_initStateKey(uint32_t index, d_string& stateKey)
  46. {
  47. switch (index)
  48. {
  49. case 0:
  50. stateKey = "readOnly";
  51. break;
  52. case 1 ... 100:
  53. stateKey = "pageText #" + d_string(index);
  54. break;
  55. case 101:
  56. stateKey = "guiWidth";
  57. break;
  58. case 102:
  59. stateKey = "guiHeight";
  60. break;
  61. }
  62. }
  63. // -------------------------------------------------
  64. // Internal data
  65. float DistrhoPluginNotes::d_parameterValue(uint32_t index)
  66. {
  67. if (index != 0)
  68. return 0.0f;
  69. return fCurPage;
  70. }
  71. void DistrhoPluginNotes::d_setParameterValue(uint32_t index, float value)
  72. {
  73. if (index != 0)
  74. return;
  75. fCurPage = int(value);
  76. }
  77. void DistrhoPluginNotes::d_setState(const char*, const char*)
  78. {
  79. // do nothing, used only for UI state
  80. }
  81. // -------------------------------------------------
  82. // Process
  83. void DistrhoPluginNotes::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*)
  84. {
  85. float* in1 = inputs[0];
  86. float* in2 = inputs[1];
  87. float* out1 = outputs[0];
  88. float* out2 = outputs[1];
  89. std::memcpy(out1, in1, sizeof(float)*frames);
  90. std::memcpy(out2, in2, sizeof(float)*frames);
  91. }
  92. // -------------------------------------------------
  93. Plugin* createPlugin()
  94. {
  95. return new DistrhoPluginNotes();
  96. }
  97. // -------------------------------------------------
  98. END_NAMESPACE_DISTRHO