Collection of tools useful for audio production
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.

127 lines
3.2KB

  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2012 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #include "carla_native.h"
  18. #include <stdlib.h>
  19. #include <string.h>
  20. enum ByPassPorts {
  21. PORT_IN1 = 0,
  22. PORT_IN2 = 1,
  23. PORT_OUT1 = 2,
  24. PORT_OUT2 = 3,
  25. PORT_MAX = 4
  26. };
  27. void bypass_init(struct _PluginDescriptor* _this_)
  28. {
  29. _this_->portCount = PORT_MAX;
  30. _this_->ports = malloc(sizeof(PluginPort) * PORT_MAX);
  31. _this_->ports[PORT_IN1].type = PORT_TYPE_AUDIO;
  32. _this_->ports[PORT_IN1].hints = 0;
  33. _this_->ports[PORT_IN1].name = "in1";
  34. _this_->ports[PORT_IN2].type = PORT_TYPE_AUDIO;
  35. _this_->ports[PORT_IN2].hints = 0;
  36. _this_->ports[PORT_IN2].name = "in2";
  37. _this_->ports[PORT_OUT1].type = PORT_TYPE_AUDIO;
  38. _this_->ports[PORT_OUT1].hints = PORT_HINT_IS_OUTPUT;
  39. _this_->ports[PORT_OUT1].name = "out1";
  40. _this_->ports[PORT_OUT2].type = PORT_TYPE_AUDIO;
  41. _this_->ports[PORT_OUT2].hints = PORT_HINT_IS_OUTPUT;
  42. _this_->ports[PORT_OUT2].name = "out2";
  43. }
  44. void bypass_fini(struct _PluginDescriptor* _this_)
  45. {
  46. free(_this_->ports);
  47. _this_->portCount = 0;
  48. _this_->ports = NULL;
  49. }
  50. PluginHandle bypass_instantiate(struct _PluginDescriptor* _this_, HostDescriptor* host)
  51. {
  52. // dummy, return non-NULL
  53. return (PluginHandle)1;
  54. // unused
  55. (void)_this_;
  56. (void)host;
  57. }
  58. void bypass_process(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents)
  59. {
  60. float* input1 = inBuffer[0];
  61. float* input2 = inBuffer[1];
  62. float* output1 = outBuffer[0];
  63. float* output2 = outBuffer[1];
  64. memcpy(output1, input1, sizeof(float)*frames);
  65. memcpy(output2, input2, sizeof(float)*frames);
  66. return;
  67. // unused
  68. (void)handle;
  69. (void)midiEventCount;
  70. (void)midiEvents;
  71. }
  72. static PluginDescriptor bypassDesc = {
  73. .category = PLUGIN_CATEGORY_NONE,
  74. .name = "ByPass",
  75. .label = "bypass",
  76. .maker = "falkTX",
  77. .copyright = "GNU GPL v2+",
  78. .portCount = 0,
  79. .ports = NULL,
  80. .midiProgramCount = 0,
  81. .midiPrograms = NULL,
  82. .instantiate = bypass_instantiate,
  83. .activate = NULL,
  84. .deactivate = NULL,
  85. .cleanup = NULL,
  86. .get_parameter_ranges = NULL,
  87. .get_parameter_value = NULL,
  88. .get_parameter_text = NULL,
  89. .get_parameter_unit = NULL,
  90. .set_parameter_value = NULL,
  91. .set_midi_program = NULL,
  92. .set_custom_data = NULL,
  93. .show_gui = NULL,
  94. .idle_gui = NULL,
  95. .process = bypass_process,
  96. ._singleton = NULL,
  97. ._init = bypass_init,
  98. ._fini = bypass_fini
  99. };
  100. CARLA_REGISTER_NATIVE_PLUGIN(bypass, bypassDesc)