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.

1410 lines
47KB

  1. /*
  2. * Carla LinuxSampler 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 doc/GPL.txt file.
  16. */
  17. /* TODO
  18. * - implement buffer size changes
  19. * - implement sample rate changes
  20. * - call outDev->ReconnectAll() after changing buffer size or sample rate
  21. * - use CARLA_SAFE_ASSERT_RETURN with err
  22. */
  23. #include "CarlaPluginInternal.hpp"
  24. #ifdef WANT_LINUXSAMPLER
  25. #include "linuxsampler/EngineFactory.h"
  26. #include <linuxsampler/Sampler.h>
  27. #include <QtCore/QFileInfo>
  28. #include <QtCore/QStringList>
  29. namespace LinuxSampler {
  30. using CarlaBackend::CarlaEngine;
  31. using CarlaBackend::CarlaPlugin;
  32. // -----------------------------------------------------------------------
  33. // LinuxSampler static values
  34. static const float kVolumeMax = 3.16227766f; // +10 dB
  35. static const float kVolumeMin = 0.0f; // -inf dB
  36. // -----------------------------------------------------------------------
  37. // LinuxSampler AudioOutputDevice Plugin
  38. class AudioOutputDevicePlugin : public AudioOutputDevice
  39. {
  40. public:
  41. AudioOutputDevicePlugin(const CarlaEngine* const engine, const CarlaPlugin* const plugin, const bool uses16Outs)
  42. : AudioOutputDevice(std::map<String, DeviceCreationParameter*>()),
  43. fEngine(engine),
  44. fPlugin(plugin)
  45. {
  46. CARLA_ASSERT(engine != nullptr);
  47. CARLA_ASSERT(plugin != nullptr);
  48. AcquireChannels(uses16Outs ? 32 : 2);
  49. }
  50. ~AudioOutputDevicePlugin() override {}
  51. // -------------------------------------------------------------------
  52. // LinuxSampler virtual methods
  53. void Play() override
  54. {
  55. }
  56. bool IsPlaying() override
  57. {
  58. return (fEngine->isRunning() && fPlugin->isEnabled());
  59. }
  60. void Stop() override
  61. {
  62. }
  63. uint MaxSamplesPerCycle() override
  64. {
  65. return fEngine->getBufferSize();
  66. }
  67. uint SampleRate() override
  68. {
  69. return uint(fEngine->getSampleRate());
  70. }
  71. String Driver() override
  72. {
  73. return "AudioOutputDevicePlugin";
  74. }
  75. AudioChannel* CreateChannel(uint channelNr) override
  76. {
  77. return new AudioChannel(channelNr, nullptr, 0);
  78. }
  79. // -------------------------------------------------------------------
  80. // Give public access to the RenderAudio call
  81. int Render(const uint samples)
  82. {
  83. return RenderAudio(samples);
  84. }
  85. // -------------------------------------------------------------------
  86. private:
  87. const CarlaEngine* const fEngine;
  88. const CarlaPlugin* const fPlugin;
  89. };
  90. // -----------------------------------------------------------------------
  91. // LinuxSampler MidiInputPort Plugin
  92. class MidiInputPortPlugin : public MidiInputPort
  93. {
  94. public:
  95. MidiInputPortPlugin(MidiInputDevice* const device, const int portNumber)
  96. : MidiInputPort(device, portNumber)
  97. {
  98. }
  99. ~MidiInputPortPlugin() override {}
  100. };
  101. // -----------------------------------------------------------------------
  102. // LinuxSampler MidiInputDevice Plugin
  103. class MidiInputDevicePlugin : public MidiInputDevice
  104. {
  105. public:
  106. MidiInputDevicePlugin(Sampler* const sampler)
  107. : MidiInputDevice(std::map<String, DeviceCreationParameter*>(), sampler)
  108. {
  109. }
  110. // -------------------------------------------------------------------
  111. // LinuxSampler virtual methods
  112. void Listen() override
  113. {
  114. }
  115. void StopListen() override
  116. {
  117. }
  118. String Driver() override
  119. {
  120. return "MidiInputDevicePlugin";
  121. }
  122. MidiInputPort* CreateMidiPort() override
  123. {
  124. return new MidiInputPortPlugin(this, int(Ports.size()));
  125. }
  126. MidiInputPortPlugin* CreateMidiPortPlugin()
  127. {
  128. return new MidiInputPortPlugin(this, int(Ports.size()));
  129. }
  130. };
  131. } // namespace LinuxSampler
  132. // -----------------------------------------------------------------------
  133. CARLA_BACKEND_START_NAMESPACE
  134. #if 0
  135. }
  136. #endif
  137. class LinuxSamplerPlugin : public CarlaPlugin
  138. {
  139. public:
  140. LinuxSamplerPlugin(CarlaEngine* const engine, const unsigned int id, const char* const format, const bool use16Outs)
  141. : CarlaPlugin(engine, id),
  142. fUses16Outs(use16Outs),
  143. fFormat(carla_strdup(format)),
  144. fLabel(nullptr),
  145. fMaker(nullptr),
  146. fRealName(nullptr),
  147. fEngine(nullptr),
  148. fAudioOutputDevice(nullptr),
  149. fMidiInputDevice(nullptr),
  150. fMidiInputPort(nullptr),
  151. fInstrument(nullptr)
  152. {
  153. carla_debug("LinuxSamplerPlugin::LinuxSamplerPlugin(%p, %i, %s, %s)", engine, id, format, bool2str(use16Outs));
  154. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  155. {
  156. fCurMidiProgs[0] = 0;
  157. fSamplerChannels[i] = nullptr;
  158. fEngineChannels[i] = nullptr;
  159. }
  160. }
  161. ~LinuxSamplerPlugin() override
  162. {
  163. carla_debug("LinuxSamplerPlugin::~LinuxSamplerPlugin()");
  164. pData->singleMutex.lock();
  165. pData->masterMutex.lock();
  166. if (pData->client != nullptr && pData->client->isActive())
  167. pData->client->deactivate();
  168. if (pData->active)
  169. {
  170. deactivate();
  171. pData->active = false;
  172. }
  173. if (fEngine != nullptr)
  174. {
  175. if (fMidiInputDevice != nullptr)
  176. {
  177. if (fMidiInputPort != nullptr)
  178. {
  179. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  180. {
  181. if (fSamplerChannels[i] != nullptr)
  182. {
  183. if (fEngineChannels[i] != nullptr)
  184. {
  185. fMidiInputPort->Disconnect(fEngineChannels[i]);
  186. fEngineChannels[i]->DisconnectAudioOutputDevice();
  187. fEngineChannels[i] = nullptr;
  188. }
  189. fSampler.RemoveSamplerChannel(fSamplerChannels[i]);
  190. fSamplerChannels[i] = nullptr;
  191. }
  192. }
  193. delete fMidiInputPort;
  194. fMidiInputPort = nullptr;
  195. }
  196. delete fMidiInputDevice;
  197. fMidiInputDevice = nullptr;
  198. }
  199. if (fAudioOutputDevice != nullptr)
  200. {
  201. delete fAudioOutputDevice;
  202. fAudioOutputDevice = nullptr;
  203. }
  204. fInstrument = nullptr;
  205. LinuxSampler::EngineFactory::Destroy(fEngine);
  206. fEngine = nullptr;
  207. }
  208. fInstrumentIds.clear();
  209. if (fFormat != nullptr)
  210. {
  211. delete[] fFormat;
  212. fFormat = nullptr;
  213. }
  214. if (fLabel != nullptr)
  215. {
  216. delete[] fLabel;
  217. fLabel = nullptr;
  218. }
  219. if (fMaker != nullptr)
  220. {
  221. delete[] fMaker;
  222. fMaker = nullptr;
  223. }
  224. if (fRealName != nullptr)
  225. {
  226. delete[] fRealName;
  227. fRealName = nullptr;
  228. }
  229. clearBuffers();
  230. }
  231. // -------------------------------------------------------------------
  232. // Information (base)
  233. PluginType getType() const noexcept override
  234. {
  235. return getPluginTypeFromString(fFormat);
  236. }
  237. PluginCategory getCategory() const override
  238. {
  239. return PLUGIN_CATEGORY_SYNTH;
  240. }
  241. // -------------------------------------------------------------------
  242. // Information (count)
  243. // nothing
  244. // -------------------------------------------------------------------
  245. // Information (current data)
  246. // nothing
  247. // -------------------------------------------------------------------
  248. // Information (per-plugin data)
  249. unsigned int getOptionsAvailable() const override
  250. {
  251. unsigned int options = 0x0;
  252. options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
  253. options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES;
  254. options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
  255. options |= PLUGIN_OPTION_SEND_PITCHBEND;
  256. options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
  257. return options;
  258. }
  259. void getLabel(char* const strBuf) const override
  260. {
  261. if (fLabel != nullptr)
  262. std::strncpy(strBuf, fLabel, STR_MAX);
  263. else
  264. CarlaPlugin::getLabel(strBuf);
  265. }
  266. void getMaker(char* const strBuf) const override
  267. {
  268. if (fMaker != nullptr)
  269. std::strncpy(strBuf, fMaker, STR_MAX);
  270. else
  271. CarlaPlugin::getMaker(strBuf);
  272. }
  273. void getCopyright(char* const strBuf) const override
  274. {
  275. getMaker(strBuf);
  276. }
  277. void getRealName(char* const strBuf) const override
  278. {
  279. if (fRealName != nullptr)
  280. std::strncpy(strBuf, fRealName, STR_MAX);
  281. else
  282. CarlaPlugin::getRealName(strBuf);
  283. }
  284. // -------------------------------------------------------------------
  285. // Set data (state)
  286. void prepareForSave() override
  287. {
  288. char strBuf[STR_MAX+1];
  289. std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i", fCurMidiProgs[0], fCurMidiProgs[1], fCurMidiProgs[2], fCurMidiProgs[3],
  290. fCurMidiProgs[4], fCurMidiProgs[5], fCurMidiProgs[6], fCurMidiProgs[7],
  291. fCurMidiProgs[8], fCurMidiProgs[9], fCurMidiProgs[10], fCurMidiProgs[11],
  292. fCurMidiProgs[12], fCurMidiProgs[13], fCurMidiProgs[14], fCurMidiProgs[15]);
  293. CarlaPlugin::setCustomData(CUSTOM_DATA_TYPE_STRING, "midiPrograms", strBuf, false);
  294. }
  295. // -------------------------------------------------------------------
  296. // Set data (internal stuff)
  297. void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) override
  298. {
  299. if (channel < MAX_MIDI_CHANNELS)
  300. pData->midiprog.current = fCurMidiProgs[channel];
  301. CarlaPlugin::setCtrlChannel(channel, sendOsc, sendCallback);
  302. }
  303. // -------------------------------------------------------------------
  304. // Set data (plugin-specific stuff)
  305. void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui) override
  306. {
  307. CARLA_SAFE_ASSERT_RETURN(type != nullptr && type[0] != '\0',);
  308. CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
  309. CARLA_SAFE_ASSERT_RETURN(value != nullptr && value[0] != '\0',);
  310. carla_debug("LinuxSamplerPlugin::setCustomData(%s, \"%s\", \"%s\", %s)", type, key, value, bool2str(sendGui));
  311. if (std::strcmp(type, CUSTOM_DATA_TYPE_STRING) != 0)
  312. return carla_stderr2("LinuxSamplerPlugin::setCustomData(\"%s\", \"%s\", \"%s\", %s) - type is not string", type, key, value, bool2str(sendGui));
  313. if (std::strcmp(key, "midiPrograms") != 0)
  314. return carla_stderr2("LinuxSamplerPlugin::setCustomData(\"%s\", \"%s\", \"%s\", %s) - type is not string", type, key, value, bool2str(sendGui));
  315. if (fUses16Outs)
  316. {
  317. QStringList midiProgramList(QString(value).split(":", QString::SkipEmptyParts));
  318. if (midiProgramList.count() == MAX_MIDI_CHANNELS)
  319. {
  320. uint i = 0;
  321. foreach (const QString& midiProg, midiProgramList)
  322. {
  323. CARLA_SAFE_ASSERT_BREAK(i < MAX_MIDI_CHANNELS);
  324. bool ok;
  325. uint index = midiProg.toUInt(&ok);
  326. if (ok && index < pData->midiprog.count)
  327. {
  328. const uint32_t bank = pData->midiprog.data[index].bank;
  329. const uint32_t program = pData->midiprog.data[index].program;
  330. const uint32_t rIndex = bank*128 + program;
  331. /*if (pData->engine->isOffline())
  332. {
  333. fEngineChannels[i]->PrepareLoadInstrument(pData->filename, rIndex);
  334. fEngineChannels[i]->LoadInstrument();
  335. }
  336. else*/
  337. {
  338. fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], fEngineChannels[i]);
  339. }
  340. fCurMidiProgs[i] = index;
  341. if (pData->ctrlChannel == static_cast<int32_t>(i))
  342. {
  343. pData->midiprog.current = index;
  344. pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr);
  345. }
  346. }
  347. ++i;
  348. }
  349. CARLA_SAFE_ASSERT(i == MAX_MIDI_CHANNELS);
  350. }
  351. }
  352. CarlaPlugin::setCustomData(type, key, value, sendGui);
  353. }
  354. void setMidiProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override
  355. {
  356. CARLA_SAFE_ASSERT_RETURN(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count),);
  357. if (index >= 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
  358. {
  359. const uint32_t bank = pData->midiprog.data[index].bank;
  360. const uint32_t program = pData->midiprog.data[index].program;
  361. const uint32_t rIndex = bank*128 + program;
  362. LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[pData->ctrlChannel]);
  363. const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback));
  364. /*if (pData->engine->isOffline())
  365. {
  366. engineChannel->PrepareLoadInstrument(pData->filename, rIndex);
  367. engineChannel->LoadInstrument();
  368. }
  369. else*/
  370. {
  371. fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], engineChannel);
  372. }
  373. fCurMidiProgs[pData->ctrlChannel] = index;
  374. }
  375. CarlaPlugin::setMidiProgram(index, sendGui, sendOsc, sendCallback);
  376. }
  377. // -------------------------------------------------------------------
  378. // Set ui stuff
  379. // nothing
  380. // -------------------------------------------------------------------
  381. // Plugin state
  382. void reload() override
  383. {
  384. CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr,);
  385. CARLA_SAFE_ASSERT_RETURN(fInstrument != nullptr,);
  386. carla_debug("LinuxSamplerPlugin::reload() - start");
  387. const EngineProcessMode processMode(pData->engine->getProccessMode());
  388. // Safely disable plugin for reload
  389. const ScopedDisabler sd(this);
  390. if (pData->active)
  391. deactivate();
  392. clearBuffers();
  393. uint32_t aOuts;
  394. aOuts = fUses16Outs ? 32 : 2;
  395. pData->audioOut.createNew(aOuts);
  396. const int portNameSize(pData->engine->getMaxPortNameSize());
  397. CarlaString portName;
  398. // ---------------------------------------
  399. // Audio Outputs
  400. if (fUses16Outs)
  401. {
  402. for (int i=0; i < 32; ++i)
  403. {
  404. portName.clear();
  405. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  406. {
  407. portName = pData->name;
  408. portName += ":";
  409. }
  410. portName += "out-";
  411. if ((i+2)/2 < 9)
  412. portName += "0";
  413. portName += CarlaString((i+2)/2);
  414. if (i % 2 == 0)
  415. portName += "L";
  416. else
  417. portName += "R";
  418. portName.truncate(portNameSize);
  419. pData->audioOut.ports[i].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false);
  420. pData->audioOut.ports[i].rindex = i;
  421. }
  422. }
  423. else
  424. {
  425. // out-left
  426. portName.clear();
  427. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  428. {
  429. portName = pData->name;
  430. portName += ":";
  431. }
  432. portName += "out-left";
  433. portName.truncate(portNameSize);
  434. pData->audioOut.ports[0].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false);
  435. pData->audioOut.ports[0].rindex = 0;
  436. // out-right
  437. portName.clear();
  438. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  439. {
  440. portName = pData->name;
  441. portName += ":";
  442. }
  443. portName += "out-right";
  444. portName.truncate(portNameSize);
  445. pData->audioOut.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false);
  446. pData->audioOut.ports[1].rindex = 1;
  447. }
  448. // ---------------------------------------
  449. // Event Input
  450. {
  451. portName.clear();
  452. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  453. {
  454. portName = pData->name;
  455. portName += ":";
  456. }
  457. portName += "events-in";
  458. portName.truncate(portNameSize);
  459. pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true);
  460. }
  461. // ---------------------------------------
  462. // plugin hints
  463. pData->hints = 0x0;
  464. pData->hints |= PLUGIN_IS_SYNTH;
  465. pData->hints |= PLUGIN_CAN_VOLUME;
  466. if (! fUses16Outs)
  467. pData->hints |= PLUGIN_CAN_BALANCE;
  468. // extra plugin hints
  469. pData->extraHints = 0x0;
  470. pData->extraHints |= PLUGIN_EXTRA_HINT_HAS_MIDI_IN;
  471. if (! fUses16Outs)
  472. pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK;
  473. bufferSizeChanged(pData->engine->getBufferSize());
  474. reloadPrograms(true);
  475. if (pData->active)
  476. activate();
  477. carla_debug("LinuxSamplerPlugin::reload() - end");
  478. }
  479. void reloadPrograms(bool init) override
  480. {
  481. carla_debug("LinuxSamplerPlugin::reloadPrograms(%s)", bool2str(init));
  482. // Delete old programs
  483. pData->midiprog.clear();
  484. // Query new programs
  485. uint32_t count = uint32_t(fInstrumentIds.size());
  486. // sound kits must always have at least 1 midi-program
  487. CARLA_SAFE_ASSERT_RETURN(count > 0,);
  488. pData->midiprog.createNew(count);
  489. // Update data
  490. LinuxSampler::InstrumentManager::instrument_info_t info;
  491. for (uint32_t i=0; i < pData->midiprog.count; ++i)
  492. {
  493. pData->midiprog.data[i].bank = i / 128;
  494. pData->midiprog.data[i].program = i % 128;
  495. try {
  496. info = fInstrument->GetInstrumentInfo(fInstrumentIds[i]);
  497. }
  498. catch (const LinuxSampler::InstrumentManagerException&)
  499. {
  500. continue;
  501. }
  502. pData->midiprog.data[i].name = carla_strdup(info.InstrumentName.c_str());
  503. }
  504. #ifndef BUILD_BRIDGE
  505. // Update OSC Names
  506. if (pData->engine->isOscControlRegistered())
  507. {
  508. pData->engine->oscSend_control_set_midi_program_count(pData->id, count);
  509. for (uint32_t i=0; i < count; ++i)
  510. pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
  511. }
  512. #endif
  513. if (init)
  514. {
  515. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  516. {
  517. CARLA_SAFE_ASSERT_CONTINUE(fEngineChannels[i] != nullptr);
  518. /*fEngineChannels[i]->PrepareLoadInstrument(pData->filename, 0);
  519. fEngineChannels[i]->LoadInstrument();*/
  520. fInstrument->LoadInstrumentInBackground(fInstrumentIds[0], fEngineChannels[i]);
  521. fCurMidiProgs[i] = 0;
  522. }
  523. pData->midiprog.current = 0;
  524. }
  525. else
  526. {
  527. pData->engine->callback(ENGINE_CALLBACK_RELOAD_PROGRAMS, pData->id, 0, 0, 0.0f, nullptr);
  528. }
  529. }
  530. // -------------------------------------------------------------------
  531. // Plugin processing
  532. #if 0
  533. void activate() override
  534. {
  535. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  536. {
  537. if (fAudioOutputDevices[i] != nullptr)
  538. fAudioOutputDevices[i]->Play();
  539. }
  540. }
  541. void deactivate() override
  542. {
  543. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  544. {
  545. if (fAudioOutputDevices[i] != nullptr)
  546. fAudioOutputDevices[i]->Stop();
  547. }
  548. }
  549. #endif
  550. void process(float** const, float** const outBuffer, const uint32_t frames) override
  551. {
  552. // --------------------------------------------------------------------------------------------------------
  553. // Check if active
  554. if (! pData->active)
  555. {
  556. // disable any output sound
  557. for (uint32_t i=0; i < pData->audioOut.count; ++i)
  558. FLOAT_CLEAR(outBuffer[i], frames);
  559. return;
  560. }
  561. // --------------------------------------------------------------------------------------------------------
  562. // Check if needs reset
  563. if (pData->needsReset)
  564. {
  565. if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  566. {
  567. for (uint i=0; i < MAX_MIDI_CHANNELS; ++i)
  568. {
  569. fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, i);
  570. fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, i);
  571. }
  572. }
  573. else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
  574. {
  575. for (uint8_t i=0; i < MAX_MIDI_NOTE; ++i)
  576. fMidiInputPort->DispatchNoteOff(i, 0, uint(pData->ctrlChannel));
  577. }
  578. pData->needsReset = false;
  579. }
  580. // --------------------------------------------------------------------------------------------------------
  581. // Event Input and Processing
  582. {
  583. // ----------------------------------------------------------------------------------------------------
  584. // MIDI Input (External)
  585. if (pData->extNotes.mutex.tryLock())
  586. {
  587. while (! pData->extNotes.data.isEmpty())
  588. {
  589. const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));
  590. CARLA_SAFE_ASSERT_CONTINUE(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);
  591. if (note.velo > 0)
  592. fMidiInputPort->DispatchNoteOn(note.note, note.velo, note.channel);
  593. else
  594. fMidiInputPort->DispatchNoteOff(note.note, note.velo, note.channel);
  595. }
  596. pData->extNotes.mutex.unlock();
  597. } // End of MIDI Input (External)
  598. // ----------------------------------------------------------------------------------------------------
  599. // Event Input (System)
  600. bool allNotesOffSent = false;
  601. bool sampleAccurate = (pData->options & PLUGIN_OPTION_FIXED_BUFFERS) == 0;
  602. uint32_t time, nEvents = pData->event.portIn->getEventCount();
  603. uint32_t startTime = 0;
  604. uint32_t timeOffset = 0;
  605. uint32_t nextBankIds[MAX_MIDI_CHANNELS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 };
  606. if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
  607. nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;
  608. for (uint32_t i=0; i < nEvents; ++i)
  609. {
  610. const EngineEvent& event(pData->event.portIn->getEvent(i));
  611. time = event.time;
  612. CARLA_SAFE_ASSERT_CONTINUE(time < frames);
  613. CARLA_SAFE_ASSERT_BREAK(time >= timeOffset);
  614. if (time > timeOffset && sampleAccurate)
  615. {
  616. if (processSingle(outBuffer, time - timeOffset, timeOffset))
  617. {
  618. startTime = 0;
  619. timeOffset = time;
  620. if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
  621. nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;
  622. }
  623. else
  624. startTime += timeOffset;
  625. }
  626. // Control change
  627. switch (event.type)
  628. {
  629. case kEngineEventTypeNull:
  630. break;
  631. case kEngineEventTypeControl:
  632. {
  633. const EngineControlEvent& ctrlEvent = event.ctrl;
  634. switch (ctrlEvent.type)
  635. {
  636. case kEngineControlEventTypeNull:
  637. break;
  638. case kEngineControlEventTypeParameter:
  639. {
  640. #ifndef BUILD_BRIDGE
  641. // Control backend stuff
  642. if (event.channel == pData->ctrlChannel)
  643. {
  644. float value;
  645. if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) != 0)
  646. {
  647. value = ctrlEvent.value;
  648. setDryWet(value, false, false);
  649. pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_DRYWET, 0, value);
  650. }
  651. if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) != 0)
  652. {
  653. value = ctrlEvent.value*127.0f/100.0f;
  654. setVolume(value, false, false);
  655. pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_VOLUME, 0, value);
  656. }
  657. if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) != 0)
  658. {
  659. float left, right;
  660. value = ctrlEvent.value/0.5f - 1.0f;
  661. if (value < 0.0f)
  662. {
  663. left = -1.0f;
  664. right = (value*2.0f)+1.0f;
  665. }
  666. else if (value > 0.0f)
  667. {
  668. left = (value*2.0f)-1.0f;
  669. right = 1.0f;
  670. }
  671. else
  672. {
  673. left = -1.0f;
  674. right = 1.0f;
  675. }
  676. setBalanceLeft(left, false, false);
  677. setBalanceRight(right, false, false);
  678. pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_LEFT, 0, left);
  679. pData->postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_BALANCE_RIGHT, 0, right);
  680. }
  681. }
  682. #endif
  683. // Control plugin parameters
  684. for (uint32_t k=0; k < pData->param.count; ++k)
  685. {
  686. if (pData->param.data[k].midiChannel != event.channel)
  687. continue;
  688. if (pData->param.data[k].midiCC != ctrlEvent.param)
  689. continue;
  690. if (pData->param.data[k].hints != PARAMETER_INPUT)
  691. continue;
  692. if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0)
  693. continue;
  694. float value;
  695. if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN)
  696. {
  697. value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max;
  698. }
  699. else
  700. {
  701. value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value);
  702. if (pData->param.data[k].hints & PARAMETER_IS_INTEGER)
  703. value = std::rint(value);
  704. }
  705. setParameterValue(k, value, false, false, false);
  706. pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 0, value);
  707. }
  708. if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param <= 0x5F)
  709. {
  710. fMidiInputPort->DispatchControlChange(uint8_t(ctrlEvent.param), uint8_t(ctrlEvent.value*127.0f), event.channel, int32_t(sampleAccurate ? startTime : time));
  711. }
  712. break;
  713. }
  714. case kEngineControlEventTypeMidiBank:
  715. if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
  716. nextBankIds[event.channel] = ctrlEvent.param;
  717. break;
  718. case kEngineControlEventTypeMidiProgram:
  719. if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
  720. {
  721. const uint32_t bankId(nextBankIds[event.channel]);
  722. const uint32_t progId(ctrlEvent.param);
  723. const uint32_t rIndex = bankId*128 + progId;
  724. for (uint32_t k=0; k < pData->midiprog.count; ++k)
  725. {
  726. if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId)
  727. {
  728. LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[pData->ctrlChannel]);
  729. /*if (pData->engine->isOffline())
  730. {
  731. engineChannel->PrepareLoadInstrument(pData->filename, rIndex);
  732. engineChannel->LoadInstrument();
  733. }
  734. else*/
  735. {
  736. fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], engineChannel);
  737. }
  738. fCurMidiProgs[event.channel] = k;
  739. if (event.channel == pData->ctrlChannel)
  740. pData->postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f);
  741. break;
  742. }
  743. }
  744. }
  745. break;
  746. case kEngineControlEventTypeAllSoundOff:
  747. if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  748. {
  749. fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, event.channel, sampleAccurate ? startTime : time);
  750. }
  751. break;
  752. case kEngineControlEventTypeAllNotesOff:
  753. if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  754. {
  755. if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
  756. {
  757. allNotesOffSent = true;
  758. sendMidiAllNotesOffToCallback();
  759. }
  760. fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, event.channel, sampleAccurate ? startTime : time);
  761. }
  762. break;
  763. }
  764. break;
  765. }
  766. case kEngineEventTypeMidi:
  767. {
  768. const EngineMidiEvent& midiEvent(event.midi);
  769. uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiEvent.data));
  770. uint8_t channel = event.channel;
  771. // Fix bad note-off
  772. if (MIDI_IS_STATUS_NOTE_ON(status) && midiEvent.data[2] == 0)
  773. status = MIDI_STATUS_NOTE_OFF;
  774. if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status) && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
  775. continue;
  776. if (MIDI_IS_STATUS_CONTROL_CHANGE(status) && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
  777. continue;
  778. if (MIDI_IS_STATUS_CHANNEL_PRESSURE(status) && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
  779. continue;
  780. if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
  781. continue;
  782. // put back channel in data
  783. uint8_t data[EngineMidiEvent::kDataSize];
  784. std::memcpy(data, event.midi.data, EngineMidiEvent::kDataSize);
  785. if (status < 0xF0 && channel < MAX_MIDI_CHANNELS)
  786. data[0] = uint8_t(data[0] + channel);
  787. fMidiInputPort->DispatchRaw(data, sampleAccurate ? startTime : time);
  788. if (status == MIDI_STATUS_NOTE_ON)
  789. pData->postponeRtEvent(kPluginPostRtEventNoteOn, channel, data[1], data[2]);
  790. else if (status == MIDI_STATUS_NOTE_OFF)
  791. pData->postponeRtEvent(kPluginPostRtEventNoteOff, channel,data[1], 0.0f);
  792. break;
  793. }
  794. }
  795. }
  796. pData->postRtEvents.trySplice();
  797. if (frames > timeOffset)
  798. processSingle(outBuffer, frames - timeOffset, timeOffset);
  799. } // End of Event Input and Processing
  800. }
  801. bool processSingle(float** const outBuffer, const uint32_t frames, const uint32_t timeOffset)
  802. {
  803. CARLA_SAFE_ASSERT_RETURN(outBuffer != nullptr, false);
  804. CARLA_SAFE_ASSERT_RETURN(frames > 0, false);
  805. // --------------------------------------------------------------------------------------------------------
  806. // Try lock, silence otherwise
  807. if (pData->engine->isOffline())
  808. {
  809. pData->singleMutex.lock();
  810. }
  811. else if (! pData->singleMutex.tryLock())
  812. {
  813. for (uint32_t i=0; i < pData->audioOut.count; ++i)
  814. {
  815. for (uint32_t k=0; k < frames; ++k)
  816. outBuffer[i][k+timeOffset] = 0.0f;
  817. }
  818. return false;
  819. }
  820. // --------------------------------------------------------------------------------------------------------
  821. // Run plugin
  822. for (uint32_t i=0; i < pData->audioOut.count; ++i)
  823. {
  824. if (LinuxSampler::AudioChannel* const outDev = fAudioOutputDevice->Channel(i))
  825. outDev->SetBuffer(outBuffer[i] + timeOffset);
  826. }
  827. fAudioOutputDevice->Render(frames);
  828. #ifndef BUILD_BRIDGE
  829. // --------------------------------------------------------------------------------------------------------
  830. // Post-processing (dry/wet, volume and balance)
  831. {
  832. const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f;
  833. const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f);
  834. float oldBufLeft[doBalance ? frames : 1];
  835. for (uint32_t i=0; i < pData->audioOut.count; ++i)
  836. {
  837. // Balance
  838. if (doBalance)
  839. {
  840. if (i % 2 == 0)
  841. FLOAT_COPY(oldBufLeft, outBuffer[i], frames);
  842. float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
  843. float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;
  844. for (uint32_t k=0; k < frames; ++k)
  845. {
  846. if (i % 2 == 0)
  847. {
  848. // left
  849. outBuffer[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
  850. outBuffer[i][k] += outBuffer[i+1][k] * (1.0f - balRangeR);
  851. }
  852. else
  853. {
  854. // right
  855. outBuffer[i][k] = outBuffer[i][k] * balRangeR;
  856. outBuffer[i][k] += oldBufLeft[k] * balRangeL;
  857. }
  858. }
  859. }
  860. // Volume
  861. if (doVolume)
  862. {
  863. for (uint32_t k=0; k < frames; ++k)
  864. outBuffer[i][k+timeOffset] *= pData->postProc.volume;
  865. }
  866. }
  867. } // End of Post-processing
  868. #endif
  869. // --------------------------------------------------------------------------------------------------------
  870. pData->singleMutex.unlock();
  871. return true;
  872. }
  873. #ifndef CARLA_OS_WIN // FIXME, need to update linuxsampler win32 build
  874. void bufferSizeChanged(const uint32_t) override
  875. {
  876. CARLA_SAFE_ASSERT_RETURN(fAudioOutputDevice != nullptr,);
  877. fAudioOutputDevice->ReconnectAll();
  878. }
  879. void sampleRateChanged(const double) override
  880. {
  881. CARLA_SAFE_ASSERT_RETURN(fAudioOutputDevice != nullptr,);
  882. fAudioOutputDevice->ReconnectAll();
  883. }
  884. #endif
  885. // -------------------------------------------------------------------
  886. // Plugin buffers
  887. // nothing
  888. // -------------------------------------------------------------------
  889. const void* getExtraStuff() const noexcept override
  890. {
  891. static const char xtrue[] = "true";
  892. static const char xfalse[] = "false";
  893. return fUses16Outs ? xtrue : xfalse;
  894. }
  895. bool init(const char* const filename, const char* const name, const char* const label)
  896. {
  897. CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);
  898. // ---------------------------------------------------------------
  899. // first checks
  900. if (pData->client != nullptr)
  901. {
  902. pData->engine->setLastError("Plugin client is already registered");
  903. return false;
  904. }
  905. if (filename == nullptr || filename[0] == '\0')
  906. {
  907. pData->engine->setLastError("null filename");
  908. return false;
  909. }
  910. if (label == nullptr || label[0] == '\0')
  911. {
  912. pData->engine->setLastError("null label");
  913. return false;
  914. }
  915. // ---------------------------------------------------------------
  916. // Store format
  917. CarlaString cstype(fFormat);
  918. cstype.toLower();
  919. const char* const ctype(cstype.getBuffer());
  920. // ---------------------------------------------------------------
  921. // Create the LinuxSampler Engine
  922. try {
  923. fEngine = LinuxSampler::EngineFactory::Create(ctype);
  924. }
  925. catch (LinuxSampler::Exception& e)
  926. {
  927. pData->engine->setLastError(e.what());
  928. return false;
  929. }
  930. // ---------------------------------------------------------------
  931. // Init LinuxSampler stuff
  932. fAudioOutputDevice = new LinuxSampler::AudioOutputDevicePlugin(pData->engine, this, fUses16Outs);
  933. fMidiInputDevice = new LinuxSampler::MidiInputDevicePlugin(&fSampler);
  934. fMidiInputPort = fMidiInputDevice->CreateMidiPortPlugin();
  935. for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
  936. {
  937. fSamplerChannels[i] = fSampler.AddSamplerChannel();
  938. CARLA_SAFE_ASSERT_CONTINUE(fSamplerChannels[i] != nullptr);
  939. fSamplerChannels[i]->SetEngineType(ctype);
  940. fSamplerChannels[i]->SetAudioOutputDevice(fAudioOutputDevice);
  941. fEngineChannels[i] = fSamplerChannels[i]->GetEngineChannel();
  942. CARLA_SAFE_ASSERT_CONTINUE(fEngineChannels[i] != nullptr);
  943. fEngineChannels[i]->Connect(fAudioOutputDevice);
  944. fEngineChannels[i]->Volume(LinuxSampler::kVolumeMax);
  945. if (fUses16Outs)
  946. {
  947. fEngineChannels[i]->SetOutputChannel(0, i*2);
  948. fEngineChannels[i]->SetOutputChannel(1, i*2 +1);
  949. }
  950. else
  951. {
  952. fEngineChannels[i]->SetOutputChannel(0, 0);
  953. fEngineChannels[i]->SetOutputChannel(1, 1);
  954. }
  955. fMidiInputPort->Connect(fEngineChannels[i], static_cast<LinuxSampler::midi_chan_t>(i));
  956. }
  957. // ---------------------------------------------------------------
  958. // Get the Engine's Instrument Manager
  959. fInstrument = fEngine->GetInstrumentManager();
  960. if (fInstrument == nullptr)
  961. {
  962. pData->engine->setLastError("Failed to get LinuxSampler instrument manager");
  963. return false;
  964. }
  965. // ---------------------------------------------------------------
  966. // Load the Instrument via filename
  967. try {
  968. fInstrumentIds = fInstrument->GetInstrumentFileContent(filename);
  969. }
  970. catch (const LinuxSampler::InstrumentManagerException& e)
  971. {
  972. pData->engine->setLastError(e.what());
  973. return false;
  974. }
  975. // ---------------------------------------------------------------
  976. // Get info
  977. if (fInstrumentIds.size() == 0)
  978. {
  979. pData->engine->setLastError("Failed to find any instruments");
  980. return false;
  981. }
  982. LinuxSampler::InstrumentManager::instrument_info_t info;
  983. try {
  984. info = fInstrument->GetInstrumentInfo(fInstrumentIds[0]);
  985. }
  986. catch (const LinuxSampler::InstrumentManagerException& e)
  987. {
  988. pData->engine->setLastError(e.what());
  989. return false;
  990. }
  991. CarlaString label2(label);
  992. if (fUses16Outs && ! label2.endsWith(" (16 outs)"))
  993. label2 += " (16 outs)";
  994. fLabel = label2.dup();
  995. fMaker = carla_strdup(info.Artists.c_str());
  996. fRealName = carla_strdup(info.InstrumentName.c_str());
  997. pData->filename = carla_strdup(filename);
  998. if (name != nullptr && name[0] != '\0')
  999. pData->name = pData->engine->getUniquePluginName(name);
  1000. else if (fRealName[0] != '\0')
  1001. pData->name = pData->engine->getUniquePluginName(fRealName);
  1002. else
  1003. pData->name = pData->engine->getUniquePluginName(label);
  1004. // ---------------------------------------------------------------
  1005. // register client
  1006. pData->client = pData->engine->addClient(this);
  1007. if (pData->client == nullptr || ! pData->client->isOk())
  1008. {
  1009. pData->engine->setLastError("Failed to register plugin client");
  1010. return false;
  1011. }
  1012. // ---------------------------------------------------------------
  1013. // load plugin settings
  1014. {
  1015. // set default options
  1016. pData->options = 0x0;
  1017. pData->options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
  1018. pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
  1019. pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
  1020. pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
  1021. // set identifier string
  1022. CarlaString identifier(fFormat);
  1023. identifier += "/";
  1024. if (const char* const shortname = std::strrchr(filename, OS_SEP))
  1025. identifier += shortname+1;
  1026. else
  1027. identifier += label;
  1028. pData->identifier = identifier.dup();
  1029. // load settings
  1030. pData->options = pData->loadSettings(pData->options, getOptionsAvailable());
  1031. }
  1032. return true;
  1033. }
  1034. // -------------------------------------------------------------------
  1035. private:
  1036. const bool fUses16Outs;
  1037. const char* fFormat;
  1038. const char* fLabel;
  1039. const char* fMaker;
  1040. const char* fRealName;
  1041. int32_t fCurMidiProgs[MAX_MIDI_CHANNELS];
  1042. LinuxSampler::Sampler fSampler;
  1043. LinuxSampler::Engine* fEngine;
  1044. LinuxSampler::SamplerChannel* fSamplerChannels[MAX_MIDI_CHANNELS];
  1045. LinuxSampler::EngineChannel* fEngineChannels[MAX_MIDI_CHANNELS];
  1046. LinuxSampler::AudioOutputDevicePlugin* fAudioOutputDevice;
  1047. LinuxSampler::MidiInputDevicePlugin* fMidiInputDevice;
  1048. LinuxSampler::MidiInputPortPlugin* fMidiInputPort;
  1049. LinuxSampler::InstrumentManager* fInstrument;
  1050. std::vector<LinuxSampler::InstrumentManager::instrument_id_t> fInstrumentIds;
  1051. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerPlugin)
  1052. };
  1053. CARLA_BACKEND_END_NAMESPACE
  1054. #endif // WANT_LINUXSAMPLER
  1055. CARLA_BACKEND_START_NAMESPACE
  1056. CarlaPlugin* CarlaPlugin::newLinuxSampler(const Initializer& init, const char* const format, const bool use16Outs)
  1057. {
  1058. carla_debug("LinuxSamplerPlugin::newLinuxSampler({%p, \"%s\", \"%s\", \"%s\"}, %s, %s)", init.engine, init.filename, init.name, init.label, format, bool2str(use16Outs));
  1059. #ifdef WANT_LINUXSAMPLER
  1060. if (init.engine->getProccessMode() == ENGINE_PROCESS_MODE_CONTINUOUS_RACK && use16Outs)
  1061. {
  1062. init.engine->setLastError("Carla's rack mode can only work with Stereo modules, please choose the 2-channel only sample-library version");
  1063. return nullptr;
  1064. }
  1065. // -------------------------------------------------------------------
  1066. // Check if file exists
  1067. {
  1068. QFileInfo file(init.filename);
  1069. if (! file.exists())
  1070. {
  1071. init.engine->setLastError("Requested file does not exist");
  1072. return nullptr;
  1073. }
  1074. if (! file.isFile())
  1075. {
  1076. init.engine->setLastError("Requested file is not valid");
  1077. return nullptr;
  1078. }
  1079. if (! file.isReadable())
  1080. {
  1081. init.engine->setLastError("Requested file is not readable");
  1082. return nullptr;
  1083. }
  1084. }
  1085. LinuxSamplerPlugin* const plugin(new LinuxSamplerPlugin(init.engine, init.id, format, use16Outs));
  1086. if (! plugin->init(init.filename, init.name, init.label))
  1087. {
  1088. delete plugin;
  1089. return nullptr;
  1090. }
  1091. plugin->reload();
  1092. return plugin;
  1093. #else
  1094. init.engine->setLastError("linuxsampler support not available");
  1095. return nullptr;
  1096. // unused
  1097. (void)format;
  1098. (void)use16Outs;
  1099. #endif
  1100. }
  1101. CARLA_BACKEND_END_NAMESPACE