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.

146 lines
3.1KB

  1. /*
  2. * travesty, pure C VST3-compatible interface
  3. * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include "base.h"
  18. #include "align_push.h"
  19. /**
  20. * note events
  21. */
  22. struct v3_event_note_on {
  23. int16_t channel;
  24. int16_t pitch; // MIDI note number
  25. float tuning;
  26. float velocity;
  27. int32_t length;
  28. int32_t note_id;
  29. };
  30. struct v3_event_note_off {
  31. int16_t channel;
  32. int16_t pitch; // MIDI note number
  33. float velocity;
  34. int32_t note_id;
  35. float tuning;
  36. };
  37. struct v3_event_data {
  38. uint32_t size;
  39. uint32_t type;
  40. const uint8_t* bytes;
  41. };
  42. struct v3_event_poly_pressure {
  43. int16_t channel;
  44. int16_t pitch;
  45. float pressure;
  46. int32_t note_id;
  47. };
  48. struct v3_event_chord {
  49. int16_t root;
  50. int16_t bass_note;
  51. int16_t mask;
  52. uint16_t text_len;
  53. const int16_t* text;
  54. };
  55. struct v3_event_scale {
  56. int16_t root;
  57. int16_t mask;
  58. uint16_t text_len;
  59. const int16_t* text;
  60. };
  61. struct v3_event_legacy_midi_cc_out {
  62. uint8_t cc_number;
  63. int8_t channel;
  64. int8_t value;
  65. int8_t value2;
  66. };
  67. struct v3_event_note_expression_value {
  68. uint32_t type_id;
  69. int32_t note_id;
  70. double value;
  71. };
  72. struct v3_event_note_expression_text {
  73. int32_t note_id;
  74. uint32_t text_len;
  75. const int16_t* text;
  76. };
  77. /**
  78. * event
  79. */
  80. enum v3_event_flags {
  81. V3_EVENT_IS_LIVE = 1 << 0
  82. };
  83. enum v3_event_type {
  84. V3_EVENT_NOTE_ON = 0,
  85. V3_EVENT_NOTE_OFF = 1,
  86. V3_EVENT_DATA = 2,
  87. V3_EVENT_POLY_PRESSURE = 3,
  88. V3_EVENT_NOTE_EXP_VALUE = 4,
  89. V3_EVENT_NOTE_EXP_TEXT = 5,
  90. V3_EVENT_CHORD = 6,
  91. V3_EVENT_SCALE = 7,
  92. V3_EVENT_LEGACY_MIDI_CC_OUT = 65535
  93. };
  94. struct v3_event {
  95. int32_t bus_index;
  96. int32_t sample_offset;
  97. double ppq_position;
  98. uint16_t flags;
  99. uint16_t type;
  100. union {
  101. struct v3_event_note_on note_on;
  102. struct v3_event_note_off note_off;
  103. struct v3_event_data data;
  104. struct v3_event_poly_pressure poly_pressure;
  105. struct v3_event_chord chord;
  106. struct v3_event_scale scale;
  107. struct v3_event_legacy_midi_cc_out midi_cc_out;
  108. struct v3_event_note_expression_value note_exp_value;
  109. struct v3_event_note_expression_text note_exp_text;
  110. };
  111. };
  112. /**
  113. * event list
  114. */
  115. struct v3_event_list {
  116. struct v3_funknown;
  117. uint32_t (V3_API* get_event_count)(void* self);
  118. v3_result (V3_API* get_event)(void* self, int32_t idx, struct v3_event* event);
  119. v3_result (V3_API* add_event)(void* self, struct v3_event* event);
  120. };
  121. static constexpr const v3_tuid v3_event_list_iid =
  122. V3_ID(0x3A2C4214, 0x346349FE, 0xB2C4F397, 0xB9695A44);
  123. #include "align_pop.h"