KXStudio Website https://kx.studio/
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.

lv2_programs.h 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. LV2 Programs Extension
  3. Copyright 2012 Filipe Coelho <falktx@falktx.com>
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted, provided that the above
  6. copyright notice and this permission notice appear in all copies.
  7. THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. /**
  16. @file lv2_programs.h
  17. C header for the LV2 programs extension <http://kxstudio.sf.net/ns/lv2ext/programs>.
  18. */
  19. #ifndef LV2_PROGRAMS_H
  20. #define LV2_PROGRAMS_H
  21. #include "lv2/lv2plug.in/ns/lv2core/lv2.h"
  22. #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
  23. #define LV2_PROGRAMS_URI "http://kxstudio.sf.net/ns/lv2ext/programs"
  24. #define LV2_PROGRAMS_PREFIX LV2_PROGRAMS_URI "#"
  25. #define LV2_PROGRAMS__Host LV2_PROGRAMS_PREFIX "Host"
  26. #define LV2_PROGRAMS__Interface LV2_PROGRAMS_PREFIX "Interface"
  27. #define LV2_PROGRAMS__UIInterface LV2_PROGRAMS_PREFIX "UIInterface"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. typedef void* LV2_Programs_Handle;
  32. typedef struct _LV2_Program_Descriptor {
  33. /** Bank number for this program. Note that this extension does not
  34. support MIDI-style separation of bank LSB and MSB values. There is
  35. no restriction on the set of available banks: the numbers do not
  36. need to be contiguous, there does not need to be a bank 0, etc. */
  37. uint32_t bank;
  38. /** Program number (unique within its bank) for this program. There is
  39. no restriction on the set of available programs: the numbers do not
  40. need to be contiguous, there does not need to be a program 0, etc. */
  41. uint32_t program;
  42. /** Name of the program. */
  43. const char * name;
  44. } LV2_Program_Descriptor;
  45. /**
  46. Programs extension, plugin data.
  47. When the plugin's extension_data is called with argument LV2_PROGRAMS__Interface,
  48. the plugin MUST return an LV2_Programs_Instance structure, which remains valid
  49. for the lifetime of the plugin.
  50. */
  51. typedef struct _LV2_Programs_Interface {
  52. /**
  53. * get_program()
  54. *
  55. * This member is a function pointer that provides a description
  56. * of a program (named preset sound) available on this plugin.
  57. *
  58. * The index argument is an index into the plugin's list of
  59. * programs, not a program number as represented by the Program
  60. * field of the LV2_Program_Descriptor. (This distinction is
  61. * needed to support plugins that use non-contiguous program or
  62. * bank numbers.)
  63. *
  64. * This function returns a LV2_Program_Descriptor pointer that is
  65. * guaranteed to be valid only until the next call to get_program
  66. * or deactivate, on the same plugin instance. This function must
  67. * return NULL if passed an index argument out of range, so that
  68. * the host can use it to query the number of programs as well as
  69. * their properties.
  70. */
  71. const LV2_Program_Descriptor *(*get_program)(LV2_Handle handle,
  72. uint32_t index);
  73. /**
  74. * select_program()
  75. *
  76. * This member is a function pointer that selects a new program
  77. * for this plugin. The program change should take effect
  78. * immediately at the start of the next run() call. (This
  79. * means that a host providing the capability of changing programs
  80. * between any two notes on a track must vary the block size so as
  81. * to place the program change at the right place. A host that
  82. * wanted to avoid this would probably just instantiate a plugin
  83. * for each program.)
  84. *
  85. * Plugins should ignore a select_program() call with an invalid
  86. * bank or program.
  87. *
  88. * A plugin is not required to select any particular default
  89. * program on activate(): it's the host's duty to set a program
  90. * explicitly.
  91. *
  92. * A plugin is permitted to re-write the values of its input
  93. * control ports when select_program is called. The host should
  94. * re-read the input control port values and update its own
  95. * records appropriately. (This is the only circumstance in which
  96. * a LV2 plugin is allowed to modify its own control-input ports.)
  97. */
  98. void (*select_program)(LV2_Handle handle,
  99. uint32_t bank,
  100. uint32_t program);
  101. } LV2_Programs_Interface;
  102. /**
  103. Programs extension, UI data.
  104. When the UI's extension_data is called with argument LV2_PROGRAMS__UIInterface,
  105. the UI MUST return an LV2_Programs_UI_Interface structure, which remains valid
  106. for the lifetime of the UI.
  107. */
  108. typedef struct _LV2_Programs_UI_Interface {
  109. /**
  110. * select_program()
  111. *
  112. * This is exactly the same as select_program in LV2_Programs_Instance,
  113. * but this struct relates to the UI instead of the plugin.
  114. *
  115. * When called, UIs should update their state to match the selected program.
  116. */
  117. void (*select_program)(LV2UI_Handle handle,
  118. uint32_t bank,
  119. uint32_t program);
  120. } LV2_Programs_UI_Interface;
  121. /**
  122. Feature data for LV2_PROGRAMS__Host.
  123. */
  124. typedef struct _LV2_Programs_Host {
  125. /**
  126. * Opaque host data.
  127. */
  128. LV2_Programs_Handle handle;
  129. /**
  130. * program_changed()
  131. *
  132. * Tell the host to reload a plugin's program.
  133. * Parameter handle MUST be the 'handle' member of this struct.
  134. * Parameter index is program index to change.
  135. * When index is -1, host should reload all the programs.
  136. *
  137. * The plugin MUST NEVER call this function on a RT context or during run().
  138. *
  139. * NOTE: This call is to inform the host about a program's bank, program or name change.
  140. * It DOES NOT change the current selected program.
  141. */
  142. void (*program_changed)(LV2_Programs_Handle handle,
  143. int32_t index);
  144. } LV2_Programs_Host;
  145. #ifdef __cplusplus
  146. } /* extern "C" */
  147. #endif
  148. #endif /* LV2_PROGRAMS_H */