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.

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