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.

95 lines
2.6KB

  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.hpp"
  18. #include <cstring>
  19. class MidiSplitPlugin : public PluginDescriptorClass
  20. {
  21. public:
  22. MidiSplitPlugin(const HostDescriptor* const host)
  23. : PluginDescriptorClass(host)
  24. {
  25. }
  26. ~MidiSplitPlugin()
  27. {
  28. }
  29. protected:
  30. // -------------------------------------------------------------------
  31. // Plugin process calls
  32. void process(float**, float**, const uint32_t, const uint32_t midiEventCount, const MidiEvent* const midiEvents)
  33. {
  34. for (uint32_t i=0; i < midiEventCount; i++)
  35. {
  36. memcpy(&m_midiEvent, &midiEvents[i], sizeof(MidiEvent));
  37. const uint8_t status = m_midiEvent.data[0] & 0xF0;
  38. const uint8_t channel = status & 0x0F;
  39. CARLA_ASSERT(channel < 16);
  40. if (channel >= 16)
  41. continue;
  42. m_midiEvent.port = channel;
  43. m_midiEvent.data[0] = status;
  44. writeMidiEvent(&m_midiEvent);
  45. }
  46. }
  47. // -------------------------------------------------------------------
  48. private:
  49. MidiEvent m_midiEvent;
  50. PluginDescriptorClassEND(MidiSplitPlugin)
  51. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MidiSplitPlugin)
  52. };
  53. // -----------------------------------------------------------------------
  54. static const PluginDescriptor midiSplitDesc = {
  55. /* category */ PLUGIN_CATEGORY_UTILITY,
  56. /* hints */ PLUGIN_IS_RTSAFE,
  57. /* audioIns */ 0,
  58. /* audioOuts */ 0,
  59. /* midiIns */ 1,
  60. /* midiOuts */ 16,
  61. /* paramIns */ 0,
  62. /* paramOuts */ 0,
  63. /* name */ "MIDI Split",
  64. /* label */ "midiSplit",
  65. /* maker */ "falkTX",
  66. /* copyright */ "GNU GPL v2+",
  67. PluginDescriptorFILL(MidiSplitPlugin)
  68. };
  69. // -----------------------------------------------------------------------
  70. void carla_register_native_plugin_midiSplit()
  71. {
  72. carla_register_native_plugin(&midiSplitDesc);
  73. }
  74. // -----------------------------------------------------------------------