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.

1368 lines
47KB

  1. /*
  2. * Carla LADSPA Plugin
  3. * Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or 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 GPL.txt file
  16. */
  17. #include "CarlaPluginInternal.hpp"
  18. #ifdef WANT_LADSPA
  19. #include "CarlaLadspaUtils.hpp"
  20. CARLA_BACKEND_START_NAMESPACE
  21. class LadspaPlugin : public CarlaPlugin
  22. {
  23. public:
  24. LadspaPlugin(CarlaEngine* const engine, const unsigned int id)
  25. : CarlaPlugin(engine, id)
  26. {
  27. carla_debug("LadspaPlugin::LadspaPlugin(%p, %i)", engine, id);
  28. fHandle = nullptr;
  29. fHandle2 = nullptr;
  30. fDescriptor = nullptr;
  31. fRdfDescriptor = nullptr;
  32. fAudioInBuffers = nullptr;
  33. fAudioOutBuffers = nullptr;
  34. fParamBuffers = nullptr;
  35. }
  36. ~LadspaPlugin()
  37. {
  38. carla_debug("LadspaPlugin::~LadspaPlugin()");
  39. if (fDescriptor != nullptr)
  40. {
  41. if (fDescriptor->deactivate != nullptr && kData->activeBefore)
  42. {
  43. if (fHandle != nullptr)
  44. fDescriptor->deactivate(fHandle);
  45. if (fHandle2 != nullptr)
  46. fDescriptor->deactivate(fHandle2);
  47. }
  48. if (fDescriptor->cleanup != nullptr)
  49. {
  50. if (fHandle != nullptr)
  51. fDescriptor->cleanup(fHandle);
  52. if (fHandle2 != nullptr)
  53. fDescriptor->cleanup(fHandle2);
  54. }
  55. fHandle = nullptr;
  56. fHandle2 = nullptr;
  57. fDescriptor = nullptr;
  58. }
  59. if (fRdfDescriptor != nullptr)
  60. {
  61. delete fRdfDescriptor;
  62. fRdfDescriptor = nullptr;
  63. }
  64. deleteBuffers();
  65. }
  66. // -------------------------------------------------------------------
  67. // Information (base)
  68. PluginType type() const
  69. {
  70. return PLUGIN_LADSPA;
  71. }
  72. PluginCategory category() const
  73. {
  74. if (fRdfDescriptor != nullptr)
  75. {
  76. const LADSPA_Properties category = fRdfDescriptor->Type;
  77. // Specific Types
  78. if (category & (LADSPA_PLUGIN_DELAY|LADSPA_PLUGIN_REVERB))
  79. return PLUGIN_CATEGORY_DELAY;
  80. if (category & (LADSPA_PLUGIN_PHASER|LADSPA_PLUGIN_FLANGER|LADSPA_PLUGIN_CHORUS))
  81. return PLUGIN_CATEGORY_MODULATOR;
  82. if (category & (LADSPA_PLUGIN_AMPLIFIER))
  83. return PLUGIN_CATEGORY_DYNAMICS;
  84. if (category & (LADSPA_PLUGIN_UTILITY|LADSPA_PLUGIN_SPECTRAL|LADSPA_PLUGIN_FREQUENCY_METER))
  85. return PLUGIN_CATEGORY_UTILITY;
  86. // Pre-set LADSPA Types
  87. if (LADSPA_IS_PLUGIN_DYNAMICS(category))
  88. return PLUGIN_CATEGORY_DYNAMICS;
  89. if (LADSPA_IS_PLUGIN_AMPLITUDE(category))
  90. return PLUGIN_CATEGORY_MODULATOR;
  91. if (LADSPA_IS_PLUGIN_EQ(category))
  92. return PLUGIN_CATEGORY_EQ;
  93. if (LADSPA_IS_PLUGIN_FILTER(category))
  94. return PLUGIN_CATEGORY_FILTER;
  95. if (LADSPA_IS_PLUGIN_FREQUENCY(category))
  96. return PLUGIN_CATEGORY_UTILITY;
  97. if (LADSPA_IS_PLUGIN_SIMULATOR(category))
  98. return PLUGIN_CATEGORY_OTHER;
  99. if (LADSPA_IS_PLUGIN_TIME(category))
  100. return PLUGIN_CATEGORY_DELAY;
  101. if (LADSPA_IS_PLUGIN_GENERATOR(category))
  102. return PLUGIN_CATEGORY_SYNTH;
  103. }
  104. return getPluginCategoryFromName(fName);
  105. }
  106. long uniqueId() const
  107. {
  108. CARLA_ASSERT(fDescriptor != nullptr);
  109. return (fDescriptor != nullptr) ? fDescriptor->UniqueID : 0;
  110. }
  111. // -------------------------------------------------------------------
  112. // Information (count)
  113. uint32_t parameterScalePointCount(const uint32_t parameterId) const
  114. {
  115. CARLA_ASSERT(parameterId < kData->param.count);
  116. const int32_t rindex = kData->param.data[parameterId].rindex;
  117. if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount))
  118. {
  119. const LADSPA_RDF_Port& port = fRdfDescriptor->Ports[rindex];
  120. return port.ScalePointCount;
  121. }
  122. return 0;
  123. }
  124. // -------------------------------------------------------------------
  125. // Information (per-plugin data)
  126. float getParameterValue(const uint32_t parameterId)
  127. {
  128. CARLA_ASSERT(parameterId < kData->param.count);
  129. return fParamBuffers[parameterId];
  130. }
  131. float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId)
  132. {
  133. CARLA_ASSERT(fRdfDescriptor != nullptr);
  134. CARLA_ASSERT(parameterId < kData->param.count);
  135. CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));
  136. const int32_t rindex = kData->param.data[parameterId].rindex;
  137. if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount))
  138. {
  139. const LADSPA_RDF_Port& port = fRdfDescriptor->Ports[rindex];
  140. if (scalePointId < port.ScalePointCount)
  141. {
  142. const LADSPA_RDF_ScalePoint& scalePoint = port.ScalePoints[scalePointId];
  143. return scalePoint.Value;
  144. }
  145. }
  146. return 0.0f;
  147. }
  148. void getLabel(char* const strBuf)
  149. {
  150. CARLA_ASSERT(fDescriptor != nullptr);
  151. if (fDescriptor != nullptr && fDescriptor->Label != nullptr)
  152. std::strncpy(strBuf, fDescriptor->Label, STR_MAX);
  153. else
  154. CarlaPlugin::getLabel(strBuf);
  155. }
  156. void getMaker(char* const strBuf)
  157. {
  158. CARLA_ASSERT(fDescriptor != nullptr);
  159. if (fRdfDescriptor != nullptr && fRdfDescriptor->Creator != nullptr)
  160. std::strncpy(strBuf, fRdfDescriptor->Creator, STR_MAX);
  161. else if (fDescriptor != nullptr && fDescriptor->Maker != nullptr)
  162. std::strncpy(strBuf, fDescriptor->Maker, STR_MAX);
  163. else
  164. CarlaPlugin::getMaker(strBuf);
  165. }
  166. void getCopyright(char* const strBuf)
  167. {
  168. CARLA_ASSERT(fDescriptor != nullptr);
  169. if (fDescriptor != nullptr && fDescriptor->Copyright != nullptr)
  170. std::strncpy(strBuf, fDescriptor->Copyright, STR_MAX);
  171. else
  172. CarlaPlugin::getCopyright(strBuf);
  173. }
  174. void getRealName(char* const strBuf)
  175. {
  176. CARLA_ASSERT(fDescriptor != nullptr);
  177. if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr)
  178. std::strncpy(strBuf, fRdfDescriptor->Title, STR_MAX);
  179. else if (fDescriptor != nullptr && fDescriptor->Name != nullptr)
  180. std::strncpy(strBuf, fDescriptor->Name, STR_MAX);
  181. else
  182. CarlaPlugin::getRealName(strBuf);
  183. }
  184. void getParameterName(const uint32_t parameterId, char* const strBuf)
  185. {
  186. CARLA_ASSERT(fDescriptor != nullptr);
  187. CARLA_ASSERT(parameterId < kData->param.count);
  188. const int32_t rindex = kData->param.data[parameterId].rindex;
  189. if (fDescriptor != nullptr && rindex < static_cast<int32_t>(fDescriptor->PortCount))
  190. std::strncpy(strBuf, fDescriptor->PortNames[rindex], STR_MAX);
  191. else
  192. CarlaPlugin::getParameterName(parameterId, strBuf);
  193. }
  194. void getParameterSymbol(const uint32_t parameterId, char* const strBuf)
  195. {
  196. CARLA_ASSERT(parameterId < kData->param.count);
  197. const int32_t rindex = kData->param.data[parameterId].rindex;
  198. if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount))
  199. {
  200. const LADSPA_RDF_Port& port = fRdfDescriptor->Ports[rindex];
  201. if (LADSPA_PORT_HAS_LABEL(port.Hints) && port.Label != nullptr)
  202. {
  203. std::strncpy(strBuf, port.Label, STR_MAX);
  204. return;
  205. }
  206. }
  207. CarlaPlugin::getParameterSymbol(parameterId, strBuf);
  208. }
  209. void getParameterUnit(const uint32_t parameterId, char* const strBuf)
  210. {
  211. CARLA_ASSERT(parameterId < kData->param.count);
  212. const int32_t rindex = kData->param.data[parameterId].rindex;
  213. if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount))
  214. {
  215. const LADSPA_RDF_Port& port = fRdfDescriptor->Ports[rindex];
  216. if (LADSPA_PORT_HAS_UNIT(port.Hints))
  217. {
  218. switch (port.Unit)
  219. {
  220. case LADSPA_UNIT_DB:
  221. std::strncpy(strBuf, "dB", STR_MAX);
  222. return;
  223. case LADSPA_UNIT_COEF:
  224. std::strncpy(strBuf, "(coef)", STR_MAX);
  225. return;
  226. case LADSPA_UNIT_HZ:
  227. std::strncpy(strBuf, "Hz", STR_MAX);
  228. return;
  229. case LADSPA_UNIT_S:
  230. std::strncpy(strBuf, "s", STR_MAX);
  231. return;
  232. case LADSPA_UNIT_MS:
  233. std::strncpy(strBuf, "ms", STR_MAX);
  234. return;
  235. case LADSPA_UNIT_MIN:
  236. std::strncpy(strBuf, "min", STR_MAX);
  237. return;
  238. }
  239. }
  240. }
  241. CarlaPlugin::getParameterUnit(parameterId, strBuf);
  242. }
  243. void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf)
  244. {
  245. CARLA_ASSERT(fRdfDescriptor != nullptr);
  246. CARLA_ASSERT(parameterId < kData->param.count);
  247. CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId));
  248. const int32_t rindex = kData->param.data[parameterId].rindex;
  249. if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount))
  250. {
  251. const LADSPA_RDF_Port& port = fRdfDescriptor->Ports[rindex];
  252. if (scalePointId < port.ScalePointCount)
  253. {
  254. const LADSPA_RDF_ScalePoint& scalePoint = port.ScalePoints[scalePointId];
  255. if (scalePoint.Label != nullptr)
  256. {
  257. std::strncpy(strBuf, scalePoint.Label, STR_MAX);
  258. return;
  259. }
  260. }
  261. }
  262. CarlaPlugin::getParameterScalePointLabel(parameterId, scalePointId, strBuf);
  263. }
  264. // -------------------------------------------------------------------
  265. // Set data (plugin-specific stuff)
  266. void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback)
  267. {
  268. CARLA_ASSERT(parameterId < kData->param.count);
  269. const float fixedValue = kData->param.fixValue(parameterId, value);
  270. fParamBuffers[parameterId] = fixedValue;
  271. CarlaPlugin::setParameterValue(parameterId, fixedValue, sendGui, sendOsc, sendCallback);
  272. }
  273. // -------------------------------------------------------------------
  274. // Plugin state
  275. void reload()
  276. {
  277. carla_debug("LadspaPlugin::reload() - start");
  278. CARLA_ASSERT(kData->engine != nullptr);
  279. CARLA_ASSERT(fDescriptor != nullptr);
  280. CARLA_ASSERT(fHandle != nullptr);
  281. const ProcessMode processMode(kData->engine->getProccessMode());
  282. // Safely disable plugin for reload
  283. const ScopedDisabler sd(this);
  284. if (kData->client->isActive())
  285. kData->client->deactivate();
  286. deleteBuffers();
  287. const double sampleRate = kData->engine->getSampleRate();
  288. const unsigned long portCount = fDescriptor->PortCount;
  289. uint32_t aIns, aOuts, params, j;
  290. aIns = aOuts = params = 0;
  291. bool forcedStereoIn, forcedStereoOut;
  292. forcedStereoIn = forcedStereoOut = false;
  293. bool needsCtrlIn, needsCtrlOut;
  294. needsCtrlIn = needsCtrlOut = false;
  295. for (unsigned long i=0; i < portCount; i++)
  296. {
  297. const LADSPA_PortDescriptor portType = fDescriptor->PortDescriptors[i];
  298. if (LADSPA_IS_PORT_AUDIO(portType))
  299. {
  300. if (LADSPA_IS_PORT_INPUT(portType))
  301. aIns += 1;
  302. else if (LADSPA_IS_PORT_OUTPUT(portType))
  303. aOuts += 1;
  304. }
  305. else if (LADSPA_IS_PORT_CONTROL(portType))
  306. params += 1;
  307. }
  308. if ((fOptions & PLUGIN_OPTION_FORCE_STEREO) != 0 && (aIns == 1 || aOuts == 1))
  309. {
  310. if (fHandle2 == nullptr)
  311. fHandle2 = fDescriptor->instantiate(fDescriptor, sampleRate);
  312. if (aIns == 1)
  313. {
  314. aIns = 2;
  315. forcedStereoIn = true;
  316. }
  317. if (aOuts == 1)
  318. {
  319. aOuts = 2;
  320. forcedStereoOut = true;
  321. }
  322. }
  323. if (aIns > 0)
  324. {
  325. kData->audioIn.createNew(aIns);
  326. fAudioInBuffers = new float*[aIns];
  327. for (uint32_t i=0; i < aIns; i++)
  328. fAudioInBuffers[i] = nullptr;
  329. }
  330. if (aOuts > 0)
  331. {
  332. kData->audioOut.createNew(aOuts);
  333. fAudioOutBuffers = new float*[aOuts];
  334. needsCtrlIn = true;
  335. for (uint32_t i=0; i < aOuts; i++)
  336. fAudioOutBuffers[i] = nullptr;
  337. }
  338. if (params > 0)
  339. {
  340. kData->param.createNew(params);
  341. fParamBuffers = new float[params];
  342. }
  343. const int portNameSize = kData->engine->maxPortNameSize();
  344. CarlaString portName;
  345. for (unsigned long i=0, iAudioIn=0, iAudioOut=0, iCtrl=0; i < portCount; i++)
  346. {
  347. const LADSPA_PortDescriptor portType = fDescriptor->PortDescriptors[i];
  348. const LADSPA_PortRangeHint portRangeHints = fDescriptor->PortRangeHints[i];
  349. const bool hasPortRDF = (fRdfDescriptor != nullptr && i < fRdfDescriptor->PortCount);
  350. if (LADSPA_IS_PORT_AUDIO(portType))
  351. {
  352. portName.clear();
  353. if (processMode == PROCESS_MODE_SINGLE_CLIENT)
  354. {
  355. portName = fName;
  356. portName += ":";
  357. }
  358. portName += fDescriptor->PortNames[i];
  359. portName.truncate(portNameSize);
  360. if (LADSPA_IS_PORT_INPUT(portType))
  361. {
  362. j = iAudioIn++;
  363. kData->audioIn.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true);
  364. kData->audioIn.ports[j].rindex = i;
  365. if (forcedStereoIn)
  366. {
  367. portName += "_2";
  368. kData->audioIn.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true);
  369. kData->audioIn.ports[1].rindex = i;
  370. }
  371. }
  372. else if (LADSPA_IS_PORT_OUTPUT(portType))
  373. {
  374. j = iAudioOut++;
  375. kData->audioOut.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false);
  376. kData->audioOut.ports[j].rindex = i;
  377. if (forcedStereoOut)
  378. {
  379. portName += "_2";
  380. kData->audioOut.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false);
  381. kData->audioOut.ports[1].rindex = i;
  382. }
  383. }
  384. else
  385. carla_stderr2("WARNING - Got a broken Port (Audio, but not input or output)");
  386. }
  387. else if (LADSPA_IS_PORT_CONTROL(portType))
  388. {
  389. j = iCtrl++;
  390. kData->param.data[j].index = j;
  391. kData->param.data[j].rindex = i;
  392. kData->param.data[j].hints = 0x0;
  393. kData->param.data[j].midiChannel = 0;
  394. kData->param.data[j].midiCC = -1;
  395. float min, max, def, step, stepSmall, stepLarge;
  396. // min value
  397. if (LADSPA_IS_HINT_BOUNDED_BELOW(portRangeHints.HintDescriptor))
  398. min = portRangeHints.LowerBound;
  399. else
  400. min = 0.0f;
  401. // max value
  402. if (LADSPA_IS_HINT_BOUNDED_ABOVE(portRangeHints.HintDescriptor))
  403. max = portRangeHints.UpperBound;
  404. else
  405. max = 1.0f;
  406. if (min > max)
  407. max = min;
  408. else if (max < min)
  409. min = max;
  410. if (max - min == 0.0f)
  411. {
  412. carla_stderr2("WARNING - Broken plugin parameter '%s': max - min == 0.0f", fDescriptor->PortNames[i]);
  413. max = min + 0.1f;
  414. }
  415. // default value
  416. if (hasPortRDF && LADSPA_PORT_HAS_DEFAULT(fRdfDescriptor->Ports[i].Hints))
  417. def = fRdfDescriptor->Ports[i].Default;
  418. else
  419. def = get_default_ladspa_port_value(portRangeHints.HintDescriptor, min, max);
  420. if (def < min)
  421. def = min;
  422. else if (def > max)
  423. def = max;
  424. if (LADSPA_IS_HINT_SAMPLE_RATE(portRangeHints.HintDescriptor))
  425. {
  426. min *= sampleRate;
  427. max *= sampleRate;
  428. def *= sampleRate;
  429. kData->param.data[j].hints |= PARAMETER_USES_SAMPLERATE;
  430. }
  431. if (LADSPA_IS_HINT_TOGGLED(portRangeHints.HintDescriptor))
  432. {
  433. step = max - min;
  434. stepSmall = step;
  435. stepLarge = step;
  436. kData->param.data[j].hints |= PARAMETER_IS_BOOLEAN;
  437. }
  438. else if (LADSPA_IS_HINT_INTEGER(portRangeHints.HintDescriptor))
  439. {
  440. step = 1.0f;
  441. stepSmall = 1.0f;
  442. stepLarge = 10.0f;
  443. kData->param.data[j].hints |= PARAMETER_IS_INTEGER;
  444. }
  445. else
  446. {
  447. float range = max - min;
  448. step = range/100.0f;
  449. stepSmall = range/1000.0f;
  450. stepLarge = range/10.0f;
  451. }
  452. if (LADSPA_IS_PORT_INPUT(portType))
  453. {
  454. kData->param.data[j].type = PARAMETER_INPUT;
  455. kData->param.data[j].hints |= PARAMETER_IS_ENABLED;
  456. kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE;
  457. needsCtrlIn = true;
  458. }
  459. else if (LADSPA_IS_PORT_OUTPUT(portType))
  460. {
  461. if (std::strcmp(fDescriptor->PortNames[i], "latency") == 0 || std::strcmp(fDescriptor->PortNames[i], "_latency") == 0)
  462. {
  463. min = 0.0f;
  464. max = sampleRate;
  465. def = 0.0f;
  466. step = 1.0f;
  467. stepSmall = 1.0f;
  468. stepLarge = 1.0f;
  469. kData->param.data[j].type = PARAMETER_LATENCY;
  470. kData->param.data[j].hints = 0;
  471. }
  472. else if (std::strcmp(fDescriptor->PortNames[i], "_sample-rate") == 0)
  473. {
  474. def = sampleRate;
  475. step = 1.0f;
  476. stepSmall = 1.0f;
  477. stepLarge = 1.0f;
  478. kData->param.data[j].type = PARAMETER_SAMPLE_RATE;
  479. kData->param.data[j].hints = 0;
  480. }
  481. else
  482. {
  483. kData->param.data[j].type = PARAMETER_OUTPUT;
  484. kData->param.data[j].hints |= PARAMETER_IS_ENABLED;
  485. kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE;
  486. needsCtrlOut = true;
  487. }
  488. }
  489. else
  490. {
  491. kData->param.data[j].type = PARAMETER_UNKNOWN;
  492. carla_stderr2("WARNING - Got a broken Port (Control, but not input or output)");
  493. }
  494. // extra parameter hints
  495. if (LADSPA_IS_HINT_LOGARITHMIC(portRangeHints.HintDescriptor))
  496. kData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC;
  497. // check for scalepoints, require at least 2 to make it useful
  498. if (hasPortRDF && fRdfDescriptor->Ports[i].ScalePointCount > 1)
  499. kData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS;
  500. kData->param.ranges[j].min = min;
  501. kData->param.ranges[j].max = max;
  502. kData->param.ranges[j].def = def;
  503. kData->param.ranges[j].step = step;
  504. kData->param.ranges[j].stepSmall = stepSmall;
  505. kData->param.ranges[j].stepLarge = stepLarge;
  506. // Start parameters in their default values
  507. fParamBuffers[j] = def;
  508. fDescriptor->connect_port(fHandle, i, &fParamBuffers[j]);
  509. if (fHandle2 != nullptr)
  510. fDescriptor->connect_port(fHandle2, i, &fParamBuffers[j]);
  511. }
  512. else
  513. {
  514. // Not Audio or Control
  515. carla_stderr2("ERROR - Got a broken Port (neither Audio or Control)");
  516. fDescriptor->connect_port(fHandle, i, nullptr);
  517. if (fHandle2 != nullptr)
  518. fDescriptor->connect_port(fHandle2, i, nullptr);
  519. }
  520. }
  521. if (needsCtrlIn)
  522. {
  523. portName.clear();
  524. if (processMode == PROCESS_MODE_SINGLE_CLIENT)
  525. {
  526. portName = fName;
  527. portName += ":";
  528. }
  529. portName += "event-in";
  530. portName.truncate(portNameSize);
  531. kData->event.portIn = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true);
  532. }
  533. if (needsCtrlOut)
  534. {
  535. portName.clear();
  536. if (processMode == PROCESS_MODE_SINGLE_CLIENT)
  537. {
  538. portName = fName;
  539. portName += ":";
  540. }
  541. portName += "event-out";
  542. portName.truncate(portNameSize);
  543. kData->event.portOut = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false);
  544. }
  545. // plugin checks
  546. fHints &= ~(PLUGIN_IS_SYNTH | PLUGIN_USES_CHUNKS | PLUGIN_CAN_DRYWET | PLUGIN_CAN_VOLUME | PLUGIN_CAN_BALANCE | PLUGIN_CAN_FORCE_STEREO);
  547. if (aOuts > 0 && (aIns == aOuts || aIns == 1))
  548. fHints |= PLUGIN_CAN_DRYWET;
  549. if (aOuts > 0)
  550. fHints |= PLUGIN_CAN_VOLUME;
  551. if (aOuts >= 2 && aOuts % 2 == 0)
  552. fHints |= PLUGIN_CAN_BALANCE;
  553. if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0))
  554. fHints |= PLUGIN_CAN_FORCE_STEREO;
  555. // plugin options
  556. kData->availOptions &= ~(PLUGIN_OPTION_FIXED_BUFFER | PLUGIN_OPTION_SELF_AUTOMATION | PLUGIN_OPTION_SEND_ALL_SOUND_OFF | PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH | PLUGIN_OPTION_SEND_PITCHBEND);
  557. // always available if needed
  558. kData->availOptions |= PLUGIN_OPTION_FIXED_BUFFER;
  559. kData->availOptions |= PLUGIN_OPTION_SELF_AUTOMATION;
  560. // check latency
  561. if (fHints & PLUGIN_CAN_DRYWET)
  562. {
  563. for (uint32_t i=0; i < kData->param.count; i++)
  564. {
  565. if (kData->param.data[i].type != PARAMETER_LATENCY)
  566. continue;
  567. // we need to pre-run the plugin so it can update its latency control-port
  568. float tmpIn[aIns][2];
  569. float tmpOut[aOuts][2];
  570. for (j=0; j < aIns; j++)
  571. {
  572. tmpIn[j][0] = 0.0f;
  573. tmpIn[j][1] = 0.0f;
  574. fDescriptor->connect_port(fHandle, kData->audioIn.ports[j].rindex, tmpIn[j]);
  575. }
  576. for (j=0; j < aOuts; j++)
  577. {
  578. tmpOut[j][0] = 0.0f;
  579. tmpOut[j][1] = 0.0f;
  580. fDescriptor->connect_port(fHandle, kData->audioOut.ports[j].rindex, tmpOut[j]);
  581. }
  582. if (fDescriptor->activate != nullptr)
  583. fDescriptor->activate(fHandle);
  584. fDescriptor->run(fHandle, 2);
  585. if (fDescriptor->deactivate != nullptr)
  586. fDescriptor->deactivate(fHandle);
  587. const uint32_t latency = std::rint(fParamBuffers[i]);
  588. if (kData->latency != latency)
  589. {
  590. kData->latency = latency;
  591. kData->client->setLatency(latency);
  592. recreateLatencyBuffers();
  593. }
  594. break;
  595. }
  596. }
  597. bufferSizeChanged(kData->engine->getBufferSize());
  598. kData->client->activate();
  599. carla_debug("LadspaPlugin::reload() - end");
  600. }
  601. // -------------------------------------------------------------------
  602. // Plugin processing
  603. void process(float** const inBuffer, float** const outBuffer, const uint32_t frames)
  604. {
  605. uint32_t i, k;
  606. // --------------------------------------------------------------------------------------------------------
  607. // Check if active
  608. if (! kData->active)
  609. {
  610. // disable any output sound
  611. for (i=0; i < kData->audioOut.count; i++)
  612. carla_zeroFloat(outBuffer[i], frames);
  613. if (kData->activeBefore)
  614. {
  615. if (fDescriptor->deactivate != nullptr)
  616. {
  617. fDescriptor->deactivate(fHandle);
  618. if (fHandle2 != nullptr)
  619. fDescriptor->deactivate(fHandle2);
  620. }
  621. }
  622. kData->activeBefore = kData->active;
  623. return;
  624. }
  625. // --------------------------------------------------------------------------------------------------------
  626. // Check if not active before
  627. if (! kData->activeBefore)
  628. {
  629. if (kData->latency > 0)
  630. {
  631. for (i=0; i < kData->audioIn.count; i++)
  632. carla_zeroFloat(kData->latencyBuffers[i], kData->latency);
  633. }
  634. if (fDescriptor->activate != nullptr)
  635. {
  636. fDescriptor->activate(fHandle);
  637. if (fHandle2 != nullptr)
  638. fDescriptor->activate(fHandle2);
  639. }
  640. }
  641. // --------------------------------------------------------------------------------------------------------
  642. // Event Input and Processing
  643. if (kData->event.portIn != nullptr && kData->activeBefore)
  644. {
  645. // ----------------------------------------------------------------------------------------------------
  646. // Event Input (System)
  647. bool sampleAccurate = (fHints & PLUGIN_OPTION_FIXED_BUFFER) == 0;
  648. uint32_t time, nEvents = kData->event.portIn->getEventCount();
  649. uint32_t timeOffset = 0;
  650. for (i=0; i < nEvents; i++)
  651. {
  652. const EngineEvent& event = kData->event.portIn->getEvent(i);
  653. time = event.time;
  654. if (time >= frames)
  655. continue;
  656. CARLA_ASSERT_INT2(time >= timeOffset, time, timeOffset);
  657. if (time > timeOffset && sampleAccurate)
  658. {
  659. processSingle(inBuffer, outBuffer, time - timeOffset, timeOffset);
  660. timeOffset = time;
  661. }
  662. // Control change
  663. switch (event.type)
  664. {
  665. case kEngineEventTypeNull:
  666. break;
  667. case kEngineEventTypeControl:
  668. {
  669. const EngineControlEvent& ctrlEvent = event.ctrl;
  670. switch (ctrlEvent.type)
  671. {
  672. case kEngineControlEventTypeNull:
  673. break;
  674. case kEngineControlEventTypeParameter:
  675. {
  676. // Control backend stuff
  677. if (event.channel == kData->ctrlChannel)
  678. {
  679. double value;
  680. if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (fHints & PLUGIN_CAN_DRYWET) > 0)
  681. {
  682. value = ctrlEvent.value;
  683. setDryWet(value, false, false);
  684. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
  685. continue;
  686. }
  687. if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (fHints & PLUGIN_CAN_VOLUME) > 0)
  688. {
  689. value = ctrlEvent.value*127/100;
  690. setVolume(value, false, false);
  691. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
  692. continue;
  693. }
  694. if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (fHints & PLUGIN_CAN_BALANCE) > 0)
  695. {
  696. double left, right;
  697. value = ctrlEvent.value/0.5 - 1.0;
  698. if (value < 0.0)
  699. {
  700. left = -1.0;
  701. right = (value*2)+1.0;
  702. }
  703. else if (value > 0.0)
  704. {
  705. left = (value*2)-1.0;
  706. right = 1.0;
  707. }
  708. else
  709. {
  710. left = -1.0;
  711. right = 1.0;
  712. }
  713. setBalanceLeft(left, false, false);
  714. setBalanceRight(right, false, false);
  715. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_LEFT, 0, left);
  716. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_RIGHT, 0, right);
  717. continue;
  718. }
  719. }
  720. // Control plugin parameters
  721. for (k=0; k < kData->param.count; k++)
  722. {
  723. if (kData->param.data[k].midiChannel != event.channel)
  724. continue;
  725. if (kData->param.data[k].midiCC != ctrlEvent.param)
  726. continue;
  727. if (kData->param.data[k].type != PARAMETER_INPUT)
  728. continue;
  729. if ((kData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0)
  730. continue;
  731. double value;
  732. if (kData->param.data[k].hints & PARAMETER_IS_BOOLEAN)
  733. {
  734. value = (ctrlEvent.value < 0.5) ? kData->param.ranges[k].min : kData->param.ranges[k].max;
  735. }
  736. else
  737. {
  738. // FIXME - ranges call for this
  739. value = ctrlEvent.value * (kData->param.ranges[k].max - kData->param.ranges[k].min) + kData->param.ranges[k].min;
  740. if (kData->param.data[k].hints & PARAMETER_IS_INTEGER)
  741. value = std::rint(value);
  742. }
  743. setParameterValue(k, value, false, false, false);
  744. postponeRtEvent(kPluginPostRtEventParameterChange, k, 0, value);
  745. }
  746. break;
  747. }
  748. case kEngineControlEventTypeMidiBank:
  749. case kEngineControlEventTypeMidiProgram:
  750. break;
  751. case kEngineControlEventTypeAllSoundOff:
  752. if (event.channel == kData->ctrlChannel)
  753. {
  754. if (fDescriptor->deactivate != nullptr)
  755. {
  756. fDescriptor->deactivate(fHandle);
  757. if (fHandle2 != nullptr)
  758. fDescriptor->deactivate(fHandle2);
  759. }
  760. if (fDescriptor->activate != nullptr)
  761. {
  762. fDescriptor->activate(fHandle);
  763. if (fHandle2 != nullptr)
  764. fDescriptor->activate(fHandle2);
  765. }
  766. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0);
  767. postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0);
  768. }
  769. break;
  770. case kEngineControlEventTypeAllNotesOff:
  771. break;
  772. }
  773. break;
  774. }
  775. case kEngineEventTypeMidi:
  776. // ignored in LADSPA
  777. break;
  778. }
  779. }
  780. kData->postRtEvents.trySplice();
  781. if (frames > timeOffset)
  782. processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset);
  783. } // End of Event Input and Processing
  784. // --------------------------------------------------------------------------------------------------------
  785. // Plugin processing (no events)
  786. else
  787. {
  788. processSingle(inBuffer, outBuffer, frames, 0);
  789. } // End of Plugin processing (no events)
  790. // --------------------------------------------------------------------------------------------------------
  791. // Special Parameters
  792. #if 0
  793. CARLA_PROCESS_CONTINUE_CHECK;
  794. for (k=0; k < param.count; k++)
  795. {
  796. if (param.data[k].type == PARAMETER_LATENCY)
  797. {
  798. // TODO
  799. }
  800. }
  801. CARLA_PROCESS_CONTINUE_CHECK;
  802. #endif
  803. CARLA_PROCESS_CONTINUE_CHECK;
  804. // --------------------------------------------------------------------------------------------------------
  805. // Post-processing (dry/wet, volume and balance)
  806. {
  807. const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) > 0 && kData->postProc.dryWet != 1.0f;
  808. const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) > 0 && kData->postProc.volume != 1.0f;
  809. const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) > 0 && (kData->postProc.balanceLeft != -1.0f || kData->postProc.balanceRight != 1.0f);
  810. float bufValue, oldBufLeft[doBalance ? frames : 1];
  811. for (i=0; i < kData->audioOut.count; i++)
  812. {
  813. // Dry/Wet
  814. if (doDryWet)
  815. {
  816. for (k=0; k < frames; k++)
  817. {
  818. // TODO
  819. //if (k < kData->latency && kData->latency < frames)
  820. // bufValue = (kData->audioIn.count == 1) ? kData->latencyBuffers[0][k] : kData->latencyBuffers[i][k];
  821. //else
  822. // bufValue = (kData->audioIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency];
  823. bufValue = inBuffer[ (kData->audioIn.count == 1) ? 0 : i ][k];
  824. outBuffer[i][k] = (outBuffer[i][k] * kData->postProc.dryWet) + (bufValue * (1.0f - kData->postProc.dryWet));
  825. }
  826. }
  827. // Balance
  828. if (doBalance)
  829. {
  830. if (i % 2 == 0)
  831. carla_copyFloat(oldBufLeft, outBuffer[i], frames);
  832. float balRangeL = (kData->postProc.balanceLeft + 1.0f)/2.0f;
  833. float balRangeR = (kData->postProc.balanceRight + 1.0f)/2.0f;
  834. for (k=0; k < frames; k++)
  835. {
  836. if (i % 2 == 0)
  837. {
  838. // left
  839. outBuffer[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
  840. outBuffer[i][k] += outBuffer[i+1][k] * (1.0f - balRangeR);
  841. }
  842. else
  843. {
  844. // right
  845. outBuffer[i][k] = outBuffer[i][k] * balRangeR;
  846. outBuffer[i][k] += oldBufLeft[k] * balRangeL;
  847. }
  848. }
  849. }
  850. // Volume
  851. if (doVolume)
  852. {
  853. for (k=0; k < frames; k++)
  854. outBuffer[i][k] *= kData->postProc.volume;
  855. }
  856. }
  857. #if 0
  858. // Latency, save values for next callback, TODO
  859. if (kData->latency > 0 && kData->latency < frames)
  860. {
  861. for (i=0; i < kData->audioIn.count; i++)
  862. carla_copyFloat(kData->latencyBuffers[i], inBuffer[i] + (frames - kData->latency), kData->latency);
  863. }
  864. #endif
  865. } // End of Post-processing
  866. CARLA_PROCESS_CONTINUE_CHECK;
  867. // --------------------------------------------------------------------------------------------------------
  868. // Control Output
  869. if (kData->event.portOut != nullptr)
  870. {
  871. float value;
  872. for (k=0; k < kData->param.count; k++)
  873. {
  874. if (kData->param.data[k].type != PARAMETER_OUTPUT)
  875. continue;
  876. kData->param.ranges[k].fixValue(fParamBuffers[k]);
  877. if (kData->param.data[k].midiCC > 0)
  878. {
  879. value = kData->param.ranges[k].normalizeValue(fParamBuffers[k]);
  880. kData->event.portOut->writeControlEvent(0, kData->param.data[k].midiChannel, kEngineControlEventTypeParameter, kData->param.data[k].midiCC, value);
  881. }
  882. }
  883. } // End of Control Output
  884. // --------------------------------------------------------------------------------------------------------
  885. kData->activeBefore = kData->active;
  886. }
  887. void processSingle(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t timeOffset)
  888. {
  889. for (uint32_t i=0; i < kData->audioIn.count; i++)
  890. carla_copyFloat(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames);
  891. for (uint32_t i=0; i < kData->audioOut.count; i++)
  892. carla_zeroFloat(fAudioOutBuffers[i], frames);
  893. fDescriptor->run(fHandle, frames);
  894. if (fHandle2 != nullptr)
  895. fDescriptor->run(fHandle2, frames);
  896. for (uint32_t i=0, k; i < kData->audioOut.count; i++)
  897. {
  898. for (k=0; k < frames; k++)
  899. outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k];
  900. }
  901. }
  902. void bufferSizeChanged(const uint32_t newBufferSize)
  903. {
  904. for (uint32_t i=0; i < kData->audioIn.count; i++)
  905. {
  906. if (fAudioInBuffers[i] != nullptr)
  907. delete[] fAudioInBuffers[i];
  908. fAudioInBuffers[i] = new float[newBufferSize];
  909. }
  910. for (uint32_t i=0; i < kData->audioOut.count; i++)
  911. {
  912. if (fAudioOutBuffers[i] != nullptr)
  913. delete[] fAudioOutBuffers[i];
  914. fAudioOutBuffers[i] = new float[newBufferSize];
  915. }
  916. if (fHandle2 == nullptr)
  917. {
  918. for (uint32_t i=0; i < kData->audioIn.count; i++)
  919. {
  920. CARLA_ASSERT(fAudioInBuffers[i] != nullptr);
  921. fDescriptor->connect_port(fHandle, kData->audioIn.ports[i].rindex, fAudioInBuffers[i]);
  922. }
  923. for (uint32_t i=0; i < kData->audioOut.count; i++)
  924. {
  925. CARLA_ASSERT(fAudioOutBuffers[i] != nullptr);
  926. fDescriptor->connect_port(fHandle, kData->audioOut.ports[i].rindex, fAudioOutBuffers[i]);
  927. }
  928. }
  929. else
  930. {
  931. if (kData->audioIn.count > 0)
  932. {
  933. CARLA_ASSERT(kData->audioIn.count == 2);
  934. CARLA_ASSERT(fAudioInBuffers[0] != nullptr);
  935. CARLA_ASSERT(fAudioInBuffers[1] != nullptr);
  936. fDescriptor->connect_port(fHandle, kData->audioIn.ports[0].rindex, fAudioInBuffers[0]);
  937. fDescriptor->connect_port(fHandle2, kData->audioIn.ports[1].rindex, fAudioInBuffers[1]);
  938. }
  939. if (kData->audioOut.count > 0)
  940. {
  941. CARLA_ASSERT(kData->audioOut.count == 2);
  942. CARLA_ASSERT(fAudioOutBuffers[0] != nullptr);
  943. CARLA_ASSERT(fAudioOutBuffers[1] != nullptr);
  944. fDescriptor->connect_port(fHandle, kData->audioOut.ports[0].rindex, fAudioOutBuffers[0]);
  945. fDescriptor->connect_port(fHandle2, kData->audioOut.ports[1].rindex, fAudioOutBuffers[1]);
  946. }
  947. }
  948. }
  949. // -------------------------------------------------------------------
  950. // Cleanup
  951. void deleteBuffers()
  952. {
  953. carla_debug("LadspaPlugin::deleteBuffers() - start");
  954. if (fAudioInBuffers != nullptr)
  955. {
  956. for (uint32_t i=0; i < kData->audioIn.count; i++)
  957. {
  958. if (fAudioInBuffers[i] != nullptr)
  959. {
  960. delete[] fAudioInBuffers[i];
  961. fAudioInBuffers[i] = nullptr;
  962. }
  963. }
  964. delete[] fAudioInBuffers;
  965. fAudioInBuffers = nullptr;
  966. }
  967. if (fAudioOutBuffers != nullptr)
  968. {
  969. for (uint32_t i=0; i < kData->audioOut.count; i++)
  970. {
  971. if (fAudioOutBuffers[i] != nullptr)
  972. {
  973. delete[] fAudioOutBuffers[i];
  974. fAudioOutBuffers[i] = nullptr;
  975. }
  976. }
  977. delete[] fAudioOutBuffers;
  978. fAudioOutBuffers = nullptr;
  979. }
  980. if (fParamBuffers != nullptr)
  981. {
  982. delete[] fParamBuffers;
  983. fParamBuffers = nullptr;
  984. }
  985. CarlaPlugin::deleteBuffers();
  986. carla_debug("LadspaPlugin::deleteBuffers() - end");
  987. }
  988. // -------------------------------------------------------------------
  989. bool init(const char* const filename, const char* const name, const char* const label, const LADSPA_RDF_Descriptor* const rdfDescriptor)
  990. {
  991. CARLA_ASSERT(kData->engine != nullptr);
  992. CARLA_ASSERT(kData->client == nullptr);
  993. CARLA_ASSERT(filename != nullptr);
  994. CARLA_ASSERT(label != nullptr);
  995. // ---------------------------------------------------------------
  996. // open DLL
  997. if (! libOpen(filename))
  998. {
  999. kData->engine->setLastError(libError(filename));
  1000. return false;
  1001. }
  1002. // ---------------------------------------------------------------
  1003. // get DLL main entry
  1004. const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)libSymbol("ladspa_descriptor");
  1005. if (descFn == nullptr)
  1006. {
  1007. kData->engine->setLastError("Could not find the LASDPA Descriptor in the plugin library");
  1008. return false;
  1009. }
  1010. // ---------------------------------------------------------------
  1011. // get descriptor that matches label
  1012. unsigned long i = 0;
  1013. while ((fDescriptor = descFn(i++)) != nullptr)
  1014. {
  1015. if (fDescriptor->Label != nullptr && std::strcmp(fDescriptor->Label, label) == 0)
  1016. break;
  1017. }
  1018. if (fDescriptor == nullptr)
  1019. {
  1020. kData->engine->setLastError("Could not find the requested plugin label in the plugin library");
  1021. return false;
  1022. }
  1023. // ---------------------------------------------------------------
  1024. // get info
  1025. if (is_ladspa_rdf_descriptor_valid(rdfDescriptor, fDescriptor))
  1026. fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor);
  1027. if (name != nullptr)
  1028. fName = kData->engine->getNewUniquePluginName(name);
  1029. else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr)
  1030. fName = kData->engine->getNewUniquePluginName(fRdfDescriptor->Title);
  1031. else if (fDescriptor->Name != nullptr)
  1032. fName = kData->engine->getNewUniquePluginName(fDescriptor->Name);
  1033. else
  1034. fName = kData->engine->getNewUniquePluginName(fDescriptor->Label);
  1035. fFilename = filename;
  1036. // ---------------------------------------------------------------
  1037. // register client
  1038. kData->client = kData->engine->addClient(this);
  1039. if (kData->client == nullptr || ! kData->client->isOk())
  1040. {
  1041. kData->engine->setLastError("Failed to register plugin client");
  1042. return false;
  1043. }
  1044. // ---------------------------------------------------------------
  1045. // initialize plugin
  1046. fHandle = fDescriptor->instantiate(fDescriptor, kData->engine->getSampleRate());
  1047. if (fHandle == nullptr)
  1048. {
  1049. kData->engine->setLastError("Plugin failed to initialize");
  1050. return false;
  1051. }
  1052. return true;
  1053. }
  1054. private:
  1055. LADSPA_Handle fHandle;
  1056. LADSPA_Handle fHandle2;
  1057. const LADSPA_Descriptor* fDescriptor;
  1058. const LADSPA_RDF_Descriptor* fRdfDescriptor;
  1059. float** fAudioInBuffers;
  1060. float** fAudioOutBuffers;
  1061. float* fParamBuffers;
  1062. };
  1063. CARLA_BACKEND_END_NAMESPACE
  1064. #else // WANT_LADSPA
  1065. # warning Building without LADSPA support
  1066. #endif
  1067. CARLA_BACKEND_START_NAMESPACE
  1068. CarlaPlugin* CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor)
  1069. {
  1070. carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\"}, %p)", init.engine, init.filename, init.name, init.label, rdfDescriptor);
  1071. #ifdef WANT_LADSPA
  1072. LadspaPlugin* const plugin = new LadspaPlugin(init.engine, init.id);
  1073. if (! plugin->init(init.filename, init.name, init.label, rdfDescriptor))
  1074. {
  1075. delete plugin;
  1076. return nullptr;
  1077. }
  1078. plugin->reload();
  1079. if (init.engine->getProccessMode() == PROCESS_MODE_CONTINUOUS_RACK && (plugin->hints() & PLUGIN_CAN_FORCE_STEREO) == 0)
  1080. {
  1081. init.engine->setLastError("Carla's rack mode can only work with Mono or Stereo LADSPA plugins, sorry!");
  1082. delete plugin;
  1083. return nullptr;
  1084. }
  1085. plugin->registerToOscClient();
  1086. return plugin;
  1087. #else
  1088. init.engine->setLastError("LADSPA support not available");
  1089. return nullptr;
  1090. #endif
  1091. }
  1092. CARLA_BACKEND_END_NAMESPACE