DPF with Max Gen
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.

97 lines
3.0KB

  1. /*
  2. * DPF Max Gen
  3. * Copyright (C) 2015-2022 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 "DistrhoPluginMaxGen.hpp"
  17. #include "gen_exported.cpp"
  18. namespace gen = gen_exported;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoPluginMaxGen::DistrhoPluginMaxGen()
  22. : Plugin(gen::num_params(), 0, 0), // 0 programs, 0 states
  23. fGenState((CommonState*)gen::create(getSampleRate(), getBufferSize()))
  24. {
  25. gen::reset(fGenState);
  26. }
  27. DistrhoPluginMaxGen::~DistrhoPluginMaxGen()
  28. {
  29. gen::destroy(fGenState);
  30. }
  31. // -----------------------------------------------------------------------
  32. // Init
  33. void DistrhoPluginMaxGen::initAudioPort(bool input, uint32_t index, AudioPort& port)
  34. {
  35. port.groupId = input ? kPortGroupMono : kPortGroupStereo;
  36. Plugin::initAudioPort(input, index, port);
  37. }
  38. void DistrhoPluginMaxGen::initParameter(uint32_t index, Parameter& parameter)
  39. {
  40. ParamInfo& info(fGenState->params[index]);
  41. parameter.hints = kParameterIsAutomatable;
  42. parameter.name = info.name;
  43. parameter.symbol = info.name;
  44. parameter.unit = info.units;
  45. parameter.ranges.def = info.defaultvalue;
  46. parameter.ranges.min = info.outputmin;
  47. parameter.ranges.max = info.outputmax;
  48. }
  49. // -----------------------------------------------------------------------
  50. // Internal data
  51. float DistrhoPluginMaxGen::getParameterValue(uint32_t index) const
  52. {
  53. t_param value = 0.0f;
  54. gen::getparameter(fGenState, index, &value);
  55. return value;
  56. }
  57. void DistrhoPluginMaxGen::setParameterValue(uint32_t index, float value)
  58. {
  59. gen::setparameter(fGenState, index, value, nullptr);
  60. }
  61. // -----------------------------------------------------------------------
  62. // Process
  63. void DistrhoPluginMaxGen::run(const float** inputs, float** outputs, uint32_t frames)
  64. {
  65. gen::perform(fGenState, (float**)inputs, gen::gen_kernel_numins, outputs, gen::gen_kernel_numouts, frames);
  66. }
  67. // -----------------------------------------------------------------------
  68. Plugin* createPlugin()
  69. {
  70. return new DistrhoPluginMaxGen();
  71. }
  72. // -----------------------------------------------------------------------
  73. END_NAMESPACE_DISTRHO
  74. #include "gen_dsp/genlib.cpp"