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.3KB

11 years ago
10 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
10 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2012-2014 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, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
  39. {
  40. const NativeHostDescriptor* const host = handlePtr->host;
  41. for (uint32_t i=0; i < midiEventCount; ++i)
  42. host->write_midi_event(host->handle, &midiEvents[i]);
  43. return;
  44. // unused
  45. (void)inBuffer;
  46. (void)outBuffer;
  47. (void)frames;
  48. }
  49. #undef handlePtr
  50. // -----------------------------------------------------------------------
  51. static const NativePluginDescriptor midithroughDesc = {
  52. .category = PLUGIN_CATEGORY_UTILITY,
  53. .hints = PLUGIN_IS_RTSAFE,
  54. .supports = PLUGIN_SUPPORTS_EVERYTHING,
  55. .audioIns = 0,
  56. .audioOuts = 0,
  57. .midiIns = 1,
  58. .midiOuts = 1,
  59. .paramIns = 0,
  60. .paramOuts = 0,
  61. .name = "MIDI Through",
  62. .label = "midithrough",
  63. .maker = "falkTX",
  64. .copyright = "GNU GPL v2+",
  65. .instantiate = midithrough_instantiate,
  66. .cleanup = midithrough_cleanup,
  67. .get_parameter_count = NULL,
  68. .get_parameter_info = NULL,
  69. .get_parameter_value = NULL,
  70. .get_parameter_text = NULL,
  71. .get_midi_program_count = NULL,
  72. .get_midi_program_info = NULL,
  73. .set_parameter_value = NULL,
  74. .set_midi_program = NULL,
  75. .set_custom_data = NULL,
  76. .ui_show = NULL,
  77. .ui_idle = NULL,
  78. .ui_set_parameter_value = NULL,
  79. .ui_set_midi_program = NULL,
  80. .ui_set_custom_data = NULL,
  81. .activate = NULL,
  82. .deactivate = NULL,
  83. .process = midithrough_process,
  84. .get_state = NULL,
  85. .set_state = NULL,
  86. .dispatcher = NULL
  87. };
  88. // -----------------------------------------------------------------------
  89. void carla_register_native_plugin_midithrough(void);
  90. void carla_register_native_plugin_midithrough(void)
  91. {
  92. carla_register_native_plugin(&midithroughDesc);
  93. }
  94. // -----------------------------------------------------------------------