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.

120 lines
3.4KB

  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 doc/GPL.txt file.
  16. */
  17. #include "CarlaNative.h"
  18. #include "CarlaMIDI.h"
  19. // -----------------------------------------------------------------------
  20. static NativePluginHandle midiSplit_instantiate(const NativeHostDescriptor* host)
  21. {
  22. // use HostDescriptor as PluginHandle
  23. return (NativePluginHandle)host;
  24. }
  25. static void midiSplit_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount)
  26. {
  27. const NativeHostDescriptor* const host = (const NativeHostDescriptor*)handle;
  28. NativeMidiEvent tmpEvent;
  29. for (uint32_t i=0; i < midiEventCount; ++i)
  30. {
  31. const NativeMidiEvent* const midiEvent = &midiEvents[i];
  32. const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent->data);
  33. const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data);
  34. if (channel >= MAX_MIDI_CHANNELS)
  35. continue;
  36. tmpEvent.port = channel;
  37. tmpEvent.time = midiEvent->time;
  38. tmpEvent.data[0] = status;
  39. tmpEvent.data[1] = midiEvent->data[1];
  40. tmpEvent.data[2] = midiEvent->data[2];
  41. tmpEvent.data[3] = midiEvent->data[3];
  42. tmpEvent.size = midiEvent->size;
  43. host->write_midi_event(host->handle, &tmpEvent);
  44. }
  45. return;
  46. // unused
  47. (void)inBuffer;
  48. (void)outBuffer;
  49. (void)frames;
  50. }
  51. // -----------------------------------------------------------------------
  52. static const NativePluginDescriptor midiSplitDesc = {
  53. .category = PLUGIN_CATEGORY_UTILITY,
  54. .hints = PLUGIN_IS_RTSAFE,
  55. .supports = PLUGIN_SUPPORTS_EVERYTHING,
  56. .audioIns = 0,
  57. .audioOuts = 0,
  58. .midiIns = 1,
  59. .midiOuts = 16,
  60. .paramIns = 0,
  61. .paramOuts = 0,
  62. .name = "MIDI Split",
  63. .label = "midiSplit",
  64. .maker = "falkTX",
  65. .copyright = "GNU GPL v2+",
  66. .instantiate = midiSplit_instantiate,
  67. .cleanup = NULL,
  68. .get_parameter_count = NULL,
  69. .get_parameter_info = NULL,
  70. .get_parameter_value = NULL,
  71. .get_parameter_text = NULL,
  72. .get_midi_program_count = NULL,
  73. .get_midi_program_info = NULL,
  74. .set_parameter_value = NULL,
  75. .set_midi_program = NULL,
  76. .set_custom_data = NULL,
  77. .ui_show = NULL,
  78. .ui_idle = NULL,
  79. .ui_set_parameter_value = NULL,
  80. .ui_set_midi_program = NULL,
  81. .ui_set_custom_data = NULL,
  82. .activate = NULL,
  83. .deactivate = NULL,
  84. .process = midiSplit_process,
  85. .get_state = NULL,
  86. .set_state = NULL,
  87. .dispatcher = NULL
  88. };
  89. // -----------------------------------------------------------------------
  90. void carla_register_native_plugin_midiSplit()
  91. {
  92. carla_register_native_plugin(&midiSplitDesc);
  93. }
  94. // -----------------------------------------------------------------------