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.

midi-through.c 3.4KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2012-2019 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 doc/GPL.txt file.
  16. */
  17. #include "CarlaNative.h"
  18. #include "CarlaMIDI.h"
  19. #include <stdlib.h>
  20. // -----------------------------------------------------------------------
  21. typedef struct {
  22. const NativeHostDescriptor* host;
  23. } MidiThroughHandle;
  24. // -----------------------------------------------------------------------
  25. static NativePluginHandle midithrough_instantiate(const NativeHostDescriptor* host)
  26. {
  27. MidiThroughHandle* const handle = (MidiThroughHandle*)malloc(sizeof(MidiThroughHandle));
  28. if (handle == NULL)
  29. return NULL;
  30. handle->host = host;
  31. return handle;
  32. }
  33. #define handlePtr ((MidiThroughHandle*)handle)
  34. static void midithrough_cleanup(NativePluginHandle handle)
  35. {
  36. free(handlePtr);
  37. }
  38. static void midithrough_process(NativePluginHandle handle,
  39. const float** inBuffer, float** outBuffer, uint32_t frames,
  40. const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
  41. {
  42. const NativeHostDescriptor* const host = handlePtr->host;
  43. for (uint32_t i=0; i < midiEventCount; ++i)
  44. host->write_midi_event(host->handle, &midiEvents[i]);
  45. return;
  46. // unused
  47. (void)inBuffer;
  48. (void)outBuffer;
  49. (void)frames;
  50. }
  51. #undef handlePtr
  52. // -----------------------------------------------------------------------
  53. static const NativePluginDescriptor midithroughDesc = {
  54. .category = NATIVE_PLUGIN_CATEGORY_UTILITY,
  55. .hints = NATIVE_PLUGIN_IS_RTSAFE,
  56. .supports = NATIVE_PLUGIN_SUPPORTS_EVERYTHING,
  57. .audioIns = 0,
  58. .audioOuts = 0,
  59. .cvIns = 0,
  60. .cvOuts = 0,
  61. .midiIns = 1,
  62. .midiOuts = 1,
  63. .paramIns = 0,
  64. .paramOuts = 0,
  65. .name = "MIDI Through",
  66. .label = "midithrough",
  67. .maker = "falkTX",
  68. .copyright = "GNU GPL v2+",
  69. .instantiate = midithrough_instantiate,
  70. .cleanup = midithrough_cleanup,
  71. .get_parameter_count = NULL,
  72. .get_parameter_info = NULL,
  73. .get_parameter_value = NULL,
  74. .get_midi_program_count = NULL,
  75. .get_midi_program_info = NULL,
  76. .set_parameter_value = NULL,
  77. .set_midi_program = NULL,
  78. .set_custom_data = NULL,
  79. .ui_show = NULL,
  80. .ui_idle = NULL,
  81. .ui_set_parameter_value = NULL,
  82. .ui_set_midi_program = NULL,
  83. .ui_set_custom_data = NULL,
  84. .activate = NULL,
  85. .deactivate = NULL,
  86. .process = midithrough_process,
  87. .get_state = NULL,
  88. .set_state = NULL,
  89. .dispatcher = NULL,
  90. .render_inline_display = NULL
  91. };
  92. // -----------------------------------------------------------------------
  93. void carla_register_native_plugin_midithrough(void);
  94. void carla_register_native_plugin_midithrough(void)
  95. {
  96. carla_register_native_plugin(&midithroughDesc);
  97. }
  98. // -----------------------------------------------------------------------