lynx_test_ext.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. /* A CLAP effect for LYNX's CLAP extension and timing tests (round 190jg, BUILD-LIST 18):
  2. * Windows: zig cc -shared -O2 -target x86_64-windows-gnu -Ithird_party/clap/include tools/testplugin/lynx_test_ext.c \
  3. * -o "LYNX Test Ext.clap"
  4. * Linux / macOS: cc -shared -fPIC -O2 -Ithird_party/clap/include tools/testplugin/lynx_test_ext.c -lpthread -o "LYNX Test Ext.clap"
  5. * then: LYNX --clapext "LYNX Test Ext.clap" report.txt; LYNX --automationtimingtest "LYNX Test Ext.clap" report.txt
  6. * Sound: it ignores its input and outputs its "Level" parameter (id 7, 0..1) as a constant (DC) on both channels,
  7. * taking each CLAP_EVENT_PARAM_VALUE at its own sample (the event's time): a step of the automation shows in the output
  8. * at the sample the host put it.
  9. * It also uses / offers, and writes down in the file named by the environment variable LYNX_TEST_EXT_LOG:
  10. * thread-pool on its 10th process call it asks the host to run 8 tasks ("pool ok=1 tasks=8 threads=<n>")
  11. * tail 4800 samples; voice-info: 3 voices of 16, overlapping notes
  12. * render the mode the host sets ("render offline" / "render realtime")
  13. * state-context a state saved for a preset / a duplicate / the project ("save context=<n>", "load context=<n>")
  14. * remote-controls one page "Test / Main": Level, Width, then empty knobs
  15. * preset-discovery + preset-load: three presets inside the plugin ("Low" 0.25, "Mid" 0.5, "High" 0.75)
  16. * and the parameter events it received ("P <time> <value> n=<frames>", the first 400), and (round 190sj) the transport's
  17. * tempo each time it changes ("T <tempo> <playing>", "T none <playing>" when the host gives no transport).
  18. */
  19. #include <clap/clap.h>
  20. #include <stdatomic.h>
  21. #include <stdint.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #if defined(_WIN32)
  26. #include <windows.h>
  27. #else
  28. #include <pthread.h>
  29. #endif
  30. #define LEVEL_ID 7
  31. #define WIDTH_ID 9
  32. static const char* const features[] = { CLAP_PLUGIN_FEATURE_AUDIO_EFFECT, CLAP_PLUGIN_FEATURE_UTILITY, NULL };
  33. static const clap_plugin_descriptor_t descriptor = {
  34. CLAP_VERSION_INIT, "org.lynx.test-ext", "LYNX Test Ext", "LYNX", "https://github.com/Ka1-S/LYNX-SHARE", "", "", "1.0.0",
  35. "CLAP extension and timing tests", features
  36. };
  37. static FILE* log_file (void)
  38. {
  39. static FILE* f = NULL;
  40. static int opened = 0;
  41. if (! opened)
  42. {
  43. opened = 1;
  44. #if defined(_WIN32)
  45. char path[1024] = { 0 };
  46. if (GetEnvironmentVariableA ("LYNX_TEST_EXT_LOG", path, sizeof (path)) > 0)
  47. f = fopen (path, "a");
  48. #else
  49. const char* path = getenv ("LYNX_TEST_EXT_LOG");
  50. if (path != NULL)
  51. f = fopen (path, "a");
  52. #endif
  53. }
  54. return f;
  55. }
  56. static void say (const char* text)
  57. {
  58. FILE* f = log_file();
  59. if (f != NULL)
  60. {
  61. fputs (text, f);
  62. fflush (f);
  63. }
  64. }
  65. typedef struct
  66. {
  67. clap_plugin_t plugin;
  68. const clap_host_t* host;
  69. double level, width;
  70. double lastTempo; /* round 190sj: the last tempo logged */
  71. int lastPlaying;
  72. int calls, logged;
  73. atomic_int tasks;
  74. atomic_ullong threadIds[8];
  75. } Ext;
  76. static Ext* self_of (const clap_plugin_t* p) { return (Ext*) p->plugin_data; }
  77. static unsigned long long thread_id (void)
  78. {
  79. #if defined(_WIN32)
  80. return (unsigned long long) GetCurrentThreadId();
  81. #else
  82. return (unsigned long long) (uintptr_t) pthread_self();
  83. #endif
  84. }
  85. /* audio ports */
  86. /* round 190rk: a second port each way (a "Sidechain" input, an "Aux" output), as FabFilter's effects have: the host
  87. * must give process() one buffer per declared port (it gave the main ones only, and they read past the array) */
  88. static uint32_t ports_count (const clap_plugin_t* p, bool in) { (void) p; (void) in; return 2; }
  89. static bool ports_get (const clap_plugin_t* p, uint32_t index, bool in, clap_audio_port_info_t* info)
  90. {
  91. (void) p;
  92. if (index > 1) return false;
  93. memset (info, 0, sizeof (*info));
  94. info->id = (in ? 0 : 1) + 10 * index;
  95. strcpy (info->name, index == 1 ? (in ? "Sidechain" : "Aux") : (in ? "In" : "Out"));
  96. info->flags = index == 0 ? CLAP_AUDIO_PORT_IS_MAIN : 0;
  97. info->channel_count = 2;
  98. info->port_type = CLAP_PORT_STEREO;
  99. info->in_place_pair = CLAP_INVALID_ID;
  100. return true;
  101. }
  102. static const clap_plugin_audio_ports_t audio_ports = { ports_count, ports_get };
  103. /* params */
  104. static uint32_t params_count (const clap_plugin_t* p) { (void) p; return 2; }
  105. static bool params_info (const clap_plugin_t* p, uint32_t index, clap_param_info_t* info)
  106. {
  107. (void) p;
  108. if (index > 1) return false;
  109. memset (info, 0, sizeof (*info));
  110. info->id = index == 0 ? LEVEL_ID : WIDTH_ID;
  111. info->flags = CLAP_PARAM_IS_AUTOMATABLE;
  112. strcpy (info->name, index == 0 ? "Level" : "Width");
  113. info->min_value = 0.0;
  114. info->max_value = 1.0;
  115. info->default_value = 0.5;
  116. return true;
  117. }
  118. static bool params_value (const clap_plugin_t* p, clap_id id, double* value)
  119. {
  120. Ext* e = self_of (p);
  121. if (id == LEVEL_ID) { *value = e->level; return true; }
  122. if (id == WIDTH_ID) { *value = e->width; return true; }
  123. return false;
  124. }
  125. static bool params_to_text (const clap_plugin_t* p, clap_id id, double v, char* out, uint32_t size)
  126. {
  127. (void) p; (void) id;
  128. snprintf (out, size, "%.3f", v);
  129. return true;
  130. }
  131. static bool params_from_text (const clap_plugin_t* p, clap_id id, const char* text, double* v)
  132. {
  133. (void) p; (void) id;
  134. *v = atof (text);
  135. return true;
  136. }
  137. static void apply_event (Ext* e, const clap_event_header_t* h, uint32_t frames)
  138. {
  139. if (h->space_id != CLAP_CORE_EVENT_SPACE_ID || h->type != CLAP_EVENT_PARAM_VALUE) return;
  140. const clap_event_param_value_t* v = (const clap_event_param_value_t*) h;
  141. if (v->param_id == LEVEL_ID)
  142. {
  143. e->level = v->value;
  144. if (e->logged < 400)
  145. {
  146. char line[96];
  147. snprintf (line, sizeof (line), "P %u %.6f n=%u\n", (unsigned) h->time, v->value, (unsigned) frames);
  148. say (line);
  149. ++e->logged;
  150. }
  151. }
  152. else if (v->param_id == WIDTH_ID)
  153. e->width = v->value;
  154. }
  155. static void params_flush (const clap_plugin_t* p, const clap_input_events_t* in, const clap_output_events_t* out)
  156. {
  157. (void) out;
  158. for (uint32_t i = 0; i < in->size (in); ++i)
  159. apply_event (self_of (p), in->get (in, i), 0);
  160. }
  161. static const clap_plugin_params_t params = { params_count, params_info, params_value, params_to_text, params_from_text, params_flush };
  162. /* state + state-context */
  163. static bool write_state (Ext* e, const clap_ostream_t* s, uint32_t context)
  164. {
  165. unsigned char data[12];
  166. float level = (float) e->level, width = (float) e->width;
  167. memcpy (data, "LXE", 3);
  168. data[3] = (unsigned char) context;
  169. memcpy (data + 4, &level, 4);
  170. memcpy (data + 8, &width, 4);
  171. return s->write (s, data, sizeof (data)) == (int64_t) sizeof (data);
  172. }
  173. static bool read_state (Ext* e, const clap_istream_t* s, uint32_t* context)
  174. {
  175. unsigned char data[12];
  176. if (s->read (s, data, sizeof (data)) != (int64_t) sizeof (data) || memcmp (data, "LXE", 3) != 0) return false;
  177. float level, width;
  178. memcpy (&level, data + 4, 4);
  179. memcpy (&width, data + 8, 4);
  180. e->level = level;
  181. e->width = width;
  182. *context = data[3];
  183. return true;
  184. }
  185. static bool state_save (const clap_plugin_t* p, const clap_ostream_t* s) { say ("save context=0\n"); return write_state (self_of (p), s, 0); }
  186. static bool state_load (const clap_plugin_t* p, const clap_istream_t* s)
  187. {
  188. uint32_t saved = 0;
  189. say ("load context=0\n");
  190. return read_state (self_of (p), s, &saved);
  191. }
  192. static const clap_plugin_state_t state = { state_save, state_load };
  193. static bool context_save (const clap_plugin_t* p, const clap_ostream_t* s, uint32_t context)
  194. {
  195. char line[48];
  196. snprintf (line, sizeof (line), "save context=%u\n", (unsigned) context);
  197. say (line);
  198. return write_state (self_of (p), s, context);
  199. }
  200. static bool context_load (const clap_plugin_t* p, const clap_istream_t* s, uint32_t context)
  201. {
  202. uint32_t saved = 0;
  203. char line[64];
  204. const bool ok = read_state (self_of (p), s, &saved);
  205. snprintf (line, sizeof (line), "load context=%u saved_with=%u\n", (unsigned) context, (unsigned) saved);
  206. say (line);
  207. return ok;
  208. }
  209. static const clap_plugin_state_context_t state_context = { context_save, context_load };
  210. /* latency 0, tail, render, voice info */
  211. static uint32_t latency_get (const clap_plugin_t* p) { (void) p; return 0; }
  212. static const clap_plugin_latency_t latency = { latency_get };
  213. static uint32_t tail_get (const clap_plugin_t* p) { (void) p; return 4800; }
  214. static const clap_plugin_tail_t tail = { tail_get };
  215. static bool render_hard (const clap_plugin_t* p) { (void) p; return false; }
  216. static bool render_set (const clap_plugin_t* p, clap_plugin_render_mode mode)
  217. {
  218. (void) p;
  219. say (mode == CLAP_RENDER_OFFLINE ? "render offline\n" : "render realtime\n");
  220. return true;
  221. }
  222. static const clap_plugin_render_t render = { render_hard, render_set };
  223. static bool voice_get (const clap_plugin_t* p, clap_voice_info_t* info)
  224. {
  225. (void) p;
  226. info->voice_count = 3;
  227. info->voice_capacity = 16;
  228. info->flags = CLAP_VOICE_INFO_SUPPORTS_OVERLAPPING_NOTES;
  229. return true;
  230. }
  231. static const clap_plugin_voice_info_t voice_info = { voice_get };
  232. /* thread pool */
  233. static void pool_exec (const clap_plugin_t* p, uint32_t task)
  234. {
  235. Ext* e = self_of (p);
  236. atomic_fetch_add (&e->tasks, 1);
  237. if (task < 8) atomic_store (&e->threadIds[task], thread_id());
  238. volatile double x = 0.0; /* a little work so the tasks overlap */
  239. for (int i = 0; i < 20000; ++i) x += (double) i * 1e-9;
  240. }
  241. static const clap_plugin_thread_pool_t thread_pool = { pool_exec };
  242. /* remote controls */
  243. static uint32_t remote_count (const clap_plugin_t* p) { (void) p; return 1; }
  244. static bool remote_get (const clap_plugin_t* p, uint32_t index, clap_remote_controls_page_t* page)
  245. {
  246. (void) p;
  247. if (index != 0) return false;
  248. memset (page, 0, sizeof (*page));
  249. strcpy (page->section_name, "Test");
  250. strcpy (page->page_name, "Main");
  251. page->page_id = 1;
  252. for (int k = 0; k < CLAP_REMOTE_CONTROLS_COUNT; ++k) page->param_ids[k] = CLAP_INVALID_ID;
  253. page->param_ids[0] = WIDTH_ID; /* (the page's own order: Width first, then Level) */
  254. page->param_ids[1] = LEVEL_ID;
  255. return true;
  256. }
  257. static const clap_plugin_remote_controls_t remote_controls = { remote_count, remote_get };
  258. /* preset load */
  259. static bool preset_load (const clap_plugin_t* p, uint32_t kind, const char* location, const char* key)
  260. {
  261. Ext* e = self_of (p);
  262. (void) location;
  263. if (kind != CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN || key == NULL) return false;
  264. double v = strcmp (key, "low") == 0 ? 0.25 : strcmp (key, "mid") == 0 ? 0.5 : strcmp (key, "high") == 0 ? 0.75 : -1.0;
  265. if (v < 0.0) return false;
  266. e->level = v;
  267. char line[64];
  268. snprintf (line, sizeof (line), "preset %s level=%.2f\n", key, v);
  269. say (line);
  270. const clap_host_preset_load_t* host = (const clap_host_preset_load_t*) e->host->get_extension (e->host, CLAP_EXT_PRESET_LOAD);
  271. if (host != NULL) host->loaded (e->host, kind, location, key);
  272. return true;
  273. }
  274. static const clap_plugin_preset_load_t preset_load_ext = { preset_load };
  275. /* plugin */
  276. static bool p_init (const clap_plugin_t* p) { (void) p; return true; }
  277. static void p_destroy (const clap_plugin_t* p) { free (self_of (p)); }
  278. static bool p_activate (const clap_plugin_t* p, double r, uint32_t a, uint32_t b) { (void) p; (void) r; (void) a; (void) b; return true; }
  279. static void p_deactivate (const clap_plugin_t* p) { (void) p; }
  280. static bool p_start (const clap_plugin_t* p) { (void) p; return true; }
  281. static void p_stop (const clap_plugin_t* p) { (void) p; }
  282. static void p_reset (const clap_plugin_t* p) { (void) p; }
  283. static clap_process_status p_process (const clap_plugin_t* p, const clap_process_t* proc)
  284. {
  285. Ext* e = self_of (p);
  286. const uint32_t n = proc->frames_count;
  287. const uint32_t events = proc->in_events->size (proc->in_events);
  288. uint32_t next = 0;
  289. float* l = proc->audio_outputs_count > 0 && proc->audio_outputs[0].channel_count > 0 ? proc->audio_outputs[0].data32[0] : NULL;
  290. float* r = proc->audio_outputs_count > 0 && proc->audio_outputs[0].channel_count > 1 ? proc->audio_outputs[0].data32[1] : NULL;
  291. for (uint32_t i = 0; i < n; ++i)
  292. {
  293. while (next < events)
  294. {
  295. const clap_event_header_t* h = proc->in_events->get (proc->in_events, next);
  296. if (h->time > i) break;
  297. apply_event (e, h, n);
  298. ++next;
  299. }
  300. if (l != NULL) l[i] = (float) e->level;
  301. if (r != NULL) r[i] = (float) e->level;
  302. }
  303. for (; next < events; ++next)
  304. apply_event (e, proc->in_events->get (proc->in_events, next), n);
  305. /* round 190sj: the tempo the host's transport says, each time it changes ("T <tempo> <playing>"; "T none" without one) */
  306. {
  307. const double tempo = proc->transport != NULL && (proc->transport->flags & CLAP_TRANSPORT_HAS_TEMPO) ? proc->transport->tempo : -1.0;
  308. const int playing = proc->transport != NULL && (proc->transport->flags & CLAP_TRANSPORT_IS_PLAYING) ? 1 : 0;
  309. if (e->calls == 0 || tempo != e->lastTempo || playing != e->lastPlaying)
  310. {
  311. char line[64];
  312. if (tempo < 0.0) snprintf (line, sizeof (line), "T none %d\n", playing);
  313. else snprintf (line, sizeof (line), "T %.3f %d\n", tempo, playing);
  314. say (line);
  315. e->lastTempo = tempo;
  316. e->lastPlaying = playing;
  317. }
  318. }
  319. if (e->calls == 4)
  320. {
  321. /* round 190rk: what the host passed (one buffer per port; a transport) */
  322. char line[160];
  323. int writable = proc->audio_outputs_count > 1 && proc->audio_outputs[1].channel_count > 0 && proc->audio_outputs[1].data32 != NULL
  324. && proc->audio_outputs[1].data32[0] != NULL;
  325. if (writable) proc->audio_outputs[1].data32[0][0] = 0.0f;
  326. snprintf (line, sizeof (line), "ports in=%u out=%u side_channels=%u aux_writable=%d transport=%d\n", proc->audio_inputs_count,
  327. proc->audio_outputs_count, proc->audio_inputs_count > 1 ? proc->audio_inputs[1].channel_count : 0u, writable,
  328. proc->transport != NULL ? 1 : 0);
  329. say (line);
  330. }
  331. if (++e->calls == 10)
  332. {
  333. const clap_host_thread_pool_t* pool = (const clap_host_thread_pool_t*) e->host->get_extension (e->host, CLAP_EXT_THREAD_POOL);
  334. atomic_store (&e->tasks, 0);
  335. for (int k = 0; k < 8; ++k) atomic_store (&e->threadIds[k], 0ULL);
  336. const bool ok = pool != NULL && pool->request_exec (e->host, 8);
  337. int threads = 0;
  338. for (int a = 0; a < 8; ++a)
  339. {
  340. const unsigned long long id = atomic_load (&e->threadIds[a]);
  341. int seen = 0;
  342. for (int b = 0; b < a; ++b) seen = seen || atomic_load (&e->threadIds[b]) == id;
  343. if (id != 0 && ! seen) ++threads;
  344. }
  345. char line[96];
  346. snprintf (line, sizeof (line), "pool ok=%d tasks=%d threads=%d\n", ok ? 1 : 0, atomic_load (&e->tasks), threads);
  347. say (line);
  348. }
  349. return CLAP_PROCESS_CONTINUE;
  350. }
  351. static const void* p_extension (const clap_plugin_t* p, const char* id)
  352. {
  353. (void) p;
  354. if (strcmp (id, CLAP_EXT_AUDIO_PORTS) == 0) return &audio_ports;
  355. if (strcmp (id, CLAP_EXT_PARAMS) == 0) return &params;
  356. if (strcmp (id, CLAP_EXT_STATE) == 0) return &state;
  357. if (strcmp (id, CLAP_EXT_STATE_CONTEXT) == 0) return &state_context;
  358. if (strcmp (id, CLAP_EXT_LATENCY) == 0) return &latency;
  359. if (strcmp (id, CLAP_EXT_TAIL) == 0) return &tail;
  360. if (strcmp (id, CLAP_EXT_RENDER) == 0) return &render;
  361. if (strcmp (id, CLAP_EXT_VOICE_INFO) == 0) return &voice_info;
  362. if (strcmp (id, CLAP_EXT_THREAD_POOL) == 0) return &thread_pool;
  363. if (strcmp (id, CLAP_EXT_REMOTE_CONTROLS) == 0) return &remote_controls;
  364. if (strcmp (id, CLAP_EXT_PRESET_LOAD) == 0) return &preset_load_ext;
  365. return NULL;
  366. }
  367. static void p_main_thread (const clap_plugin_t* p) { (void) p; }
  368. static uint32_t f_count (const clap_plugin_factory_t* f) { (void) f; return 1; }
  369. static const clap_plugin_descriptor_t* f_descriptor (const clap_plugin_factory_t* f, uint32_t i) { (void) f; return i == 0 ? &descriptor : NULL; }
  370. static const clap_plugin_t* f_create (const clap_plugin_factory_t* f, const clap_host_t* host, const char* id)
  371. {
  372. (void) f;
  373. if (strcmp (id, descriptor.id) != 0) return NULL;
  374. Ext* e = (Ext*) calloc (1, sizeof (Ext));
  375. e->host = host;
  376. e->level = 0.5;
  377. e->width = 0.5;
  378. clap_plugin_t* p = &e->plugin;
  379. p->desc = &descriptor;
  380. p->plugin_data = e;
  381. p->init = p_init; p->destroy = p_destroy; p->activate = p_activate; p->deactivate = p_deactivate;
  382. p->start_processing = p_start; p->stop_processing = p_stop; p->reset = p_reset; p->process = p_process;
  383. p->get_extension = p_extension; p->on_main_thread = p_main_thread;
  384. return p;
  385. }
  386. static const clap_plugin_factory_t factory = { f_count, f_descriptor, f_create };
  387. /* preset discovery: one provider with three presets inside the plugin */
  388. static const clap_preset_discovery_provider_descriptor_t provider_descriptor = { CLAP_VERSION_INIT, "org.lynx.test-ext.presets", "LYNX Test Ext presets", "LYNX" };
  389. static bool prov_init (const clap_preset_discovery_provider_t* p)
  390. {
  391. const clap_preset_discovery_indexer_t* indexer = (const clap_preset_discovery_indexer_t*) p->provider_data;
  392. const clap_preset_discovery_location_t location = { CLAP_PRESET_DISCOVERY_IS_FACTORY_CONTENT, "Factory", CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN, NULL };
  393. return indexer->declare_location (indexer, &location);
  394. }
  395. static void prov_destroy (const clap_preset_discovery_provider_t* p) { free ((void*) p); }
  396. static bool prov_metadata (const clap_preset_discovery_provider_t* p, uint32_t kind, const char* location, const clap_preset_discovery_metadata_receiver_t* r)
  397. {
  398. (void) p; (void) location;
  399. if (kind != CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN) return false;
  400. static const char* const names[3] = { "Low", "Mid", "High" };
  401. static const char* const keys[3] = { "low", "mid", "high" };
  402. const clap_universal_plugin_id_t id = { "clap", "org.lynx.test-ext" };
  403. for (int i = 0; i < 3; ++i)
  404. if (r->begin_preset (r, names[i], keys[i]))
  405. r->add_plugin_id (r, &id);
  406. return true;
  407. }
  408. static const void* prov_extension (const clap_preset_discovery_provider_t* p, const char* id) { (void) p; (void) id; return NULL; }
  409. static uint32_t d_count (const clap_preset_discovery_factory_t* f) { (void) f; return 1; }
  410. static const clap_preset_discovery_provider_descriptor_t* d_descriptor (const clap_preset_discovery_factory_t* f, uint32_t i)
  411. {
  412. (void) f;
  413. return i == 0 ? &provider_descriptor : NULL;
  414. }
  415. static const clap_preset_discovery_provider_t* d_create (const clap_preset_discovery_factory_t* f, const clap_preset_discovery_indexer_t* indexer, const char* id)
  416. {
  417. (void) f;
  418. if (strcmp (id, provider_descriptor.id) != 0) return NULL;
  419. clap_preset_discovery_provider_t* p = (clap_preset_discovery_provider_t*) calloc (1, sizeof (*p));
  420. p->desc = &provider_descriptor;
  421. p->provider_data = (void*) indexer;
  422. p->init = prov_init;
  423. p->destroy = prov_destroy;
  424. p->get_metadata = prov_metadata;
  425. p->get_extension = prov_extension;
  426. return p;
  427. }
  428. static const clap_preset_discovery_factory_t discovery = { d_count, d_descriptor, d_create };
  429. static bool e_init (const char* path) { (void) path; return true; }
  430. static void e_deinit (void) {}
  431. static const void* e_factory (const char* id)
  432. {
  433. if (strcmp (id, CLAP_PLUGIN_FACTORY_ID) == 0) return &factory;
  434. if (strcmp (id, CLAP_PRESET_DISCOVERY_FACTORY_ID) == 0) return &discovery;
  435. return NULL;
  436. }
  437. CLAP_EXPORT const clap_plugin_entry_t clap_entry = { CLAP_VERSION_INIT, e_init, e_deinit, e_factory };