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.

119 lines
3.0KB

  1. /*
  2. * Carla Native Plugins
  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 "CarlaNative.h"
  18. #include "CarlaMIDI.h"
  19. #include <stdlib.h>
  20. typedef struct _MidiThroughHandle {
  21. HostDescriptor* host;
  22. } MidiThroughHandle;
  23. static PluginHandle midiThrough_instantiate(const PluginDescriptor* _this_, HostDescriptor* host)
  24. {
  25. MidiThroughHandle* const handle = (MidiThroughHandle*)malloc(sizeof(MidiThroughHandle));
  26. if (handle != NULL)
  27. {
  28. handle->host = host;
  29. return handle;
  30. }
  31. return NULL;
  32. // unused
  33. (void)_this_;
  34. }
  35. static void midiThrough_cleanup(PluginHandle handle)
  36. {
  37. free((MidiThroughHandle*)handle);
  38. }
  39. static void midiThrough_process(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents)
  40. {
  41. HostDescriptor* const host = ((MidiThroughHandle*)handle)->host;
  42. for (uint32_t i=0; i < midiEventCount; i++)
  43. host->write_midi_event(host->handle, &midiEvents[i]);
  44. return;
  45. // unused
  46. (void)inBuffer;
  47. (void)outBuffer;
  48. (void)frames;
  49. }
  50. // -----------------------------------------------------------------------
  51. static const PluginDescriptor midiThroughDesc = {
  52. .category = PLUGIN_CATEGORY_NONE,
  53. .hints = PLUGIN_IS_RTSAFE,
  54. .audioIns = 0,
  55. .audioOuts = 0,
  56. .midiIns = 1,
  57. .midiOuts = 1,
  58. .parameterIns = 0,
  59. .parameterOuts = 0,
  60. .name = "MIDI Through",
  61. .label = "midiThrough",
  62. .maker = "falkTX",
  63. .copyright = "GNU GPL v2+",
  64. .instantiate = midiThrough_instantiate,
  65. .cleanup = midiThrough_cleanup,
  66. .get_parameter_count = NULL,
  67. .get_parameter_info = NULL,
  68. .get_parameter_value = NULL,
  69. .get_parameter_text = NULL,
  70. .get_midi_program_count = NULL,
  71. .get_midi_program_info = NULL,
  72. .set_parameter_value = NULL,
  73. .set_midi_program = NULL,
  74. .set_custom_data = NULL,
  75. .ui_show = NULL,
  76. .ui_idle = NULL,
  77. .ui_set_parameter_value = NULL,
  78. .ui_set_midi_program = NULL,
  79. .ui_set_custom_data = NULL,
  80. .activate = NULL,
  81. .deactivate = NULL,
  82. .process = midiThrough_process,
  83. .get_state = NULL,
  84. .set_state = NULL,
  85. .dispatcher = NULL
  86. };
  87. // -----------------------------------------------------------------------
  88. void carla_register_native_plugin_midiThrough()
  89. {
  90. carla_register_native_plugin(&midiThroughDesc);
  91. }
  92. // -----------------------------------------------------------------------