Collection of tools useful for audio production
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.

91 lines
2.5KB

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