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.

796 lines
26KB

  1. /*
  2. * Carla SFZero Plugin
  3. * Copyright (C) 2018 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. #include "CarlaPluginInternal.hpp"
  18. #include "CarlaEngine.hpp"
  19. #include "sfzero/SFZero.h"
  20. #include "water/buffers/AudioSampleBuffer.h"
  21. #include "water/files/File.h"
  22. #include "water/midi/MidiMessage.h"
  23. using water::AudioSampleBuffer;
  24. using water::File;
  25. using water::MidiMessage;
  26. using water::String;
  27. // -----------------------------------------------------------------------
  28. CARLA_BACKEND_START_NAMESPACE
  29. // -------------------------------------------------------------------------------------------------------------------
  30. // Fallback data
  31. static const ExternalMidiNote kExternalMidiNoteFallback = { -1, 0, 0 };
  32. static void loadingIdleCallbackFunction(void* ptr)
  33. {
  34. ((CarlaEngine*)ptr)->callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
  35. }
  36. // -------------------------------------------------------------------------------------------------------------------
  37. class CarlaPluginSFZero : public CarlaPlugin
  38. {
  39. public:
  40. CarlaPluginSFZero(CarlaEngine* const engine, const uint id)
  41. : CarlaPlugin(engine, id),
  42. fSynth(),
  43. fNumVoices(0.0f),
  44. fLabel(nullptr),
  45. fRealName(nullptr)
  46. {
  47. carla_debug("CarlaPluginSFZero::CarlaPluginSFZero(%p, %i)", engine, id);
  48. }
  49. ~CarlaPluginSFZero() override
  50. {
  51. carla_debug("CarlaPluginSFZero::~CarlaPluginSFZero()");
  52. pData->singleMutex.lock();
  53. pData->masterMutex.lock();
  54. if (pData->client != nullptr && pData->client->isActive())
  55. pData->client->deactivate();
  56. if (pData->active)
  57. {
  58. deactivate();
  59. pData->active = false;
  60. }
  61. if (fLabel != nullptr)
  62. {
  63. delete[] fLabel;
  64. fLabel = nullptr;
  65. }
  66. if (fRealName != nullptr)
  67. {
  68. delete[] fRealName;
  69. fRealName = nullptr;
  70. }
  71. clearBuffers();
  72. }
  73. // -------------------------------------------------------------------
  74. // Information (base)
  75. PluginType getType() const noexcept override
  76. {
  77. return PLUGIN_SFZ;
  78. }
  79. PluginCategory getCategory() const noexcept override
  80. {
  81. return PLUGIN_CATEGORY_SYNTH;
  82. }
  83. // -------------------------------------------------------------------
  84. // Information (count)
  85. // nothing
  86. // -------------------------------------------------------------------
  87. // Information (current data)
  88. // nothing
  89. // -------------------------------------------------------------------
  90. // Information (per-plugin data)
  91. uint getOptionsAvailable() const noexcept override
  92. {
  93. uint options = 0x0;
  94. options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES;
  95. options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
  96. options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
  97. options |= PLUGIN_OPTION_SEND_PITCHBEND;
  98. options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
  99. return options;
  100. }
  101. float getParameterValue(const uint32_t parameterId) const noexcept override
  102. {
  103. CARLA_SAFE_ASSERT_RETURN(parameterId == 0, 0.0f);
  104. return fNumVoices;
  105. }
  106. void getLabel(char* const strBuf) const noexcept override
  107. {
  108. if (fLabel != nullptr)
  109. {
  110. std::strncpy(strBuf, fLabel, STR_MAX);
  111. return;
  112. }
  113. CarlaPlugin::getLabel(strBuf);
  114. }
  115. void getMaker(char* const strBuf) const noexcept override
  116. {
  117. std::strncpy(strBuf, "SFZero engine", STR_MAX);
  118. }
  119. void getCopyright(char* const strBuf) const noexcept override
  120. {
  121. std::strncpy(strBuf, "ISC", STR_MAX);
  122. }
  123. void getRealName(char* const strBuf) const noexcept override
  124. {
  125. if (fRealName != nullptr)
  126. {
  127. std::strncpy(strBuf, fRealName, STR_MAX);
  128. return;
  129. }
  130. CarlaPlugin::getRealName(strBuf);
  131. }
  132. void getParameterName(const uint32_t parameterId, char* const strBuf) const noexcept override
  133. {
  134. CARLA_SAFE_ASSERT_RETURN(parameterId == 0,);
  135. std::strncpy(strBuf, "Voice Count", STR_MAX);
  136. }
  137. // -------------------------------------------------------------------
  138. // Set data (state)
  139. // nothing
  140. // -------------------------------------------------------------------
  141. // Set data (internal stuff)
  142. // nothing
  143. // -------------------------------------------------------------------
  144. // Set data (plugin-specific stuff)
  145. // nothing
  146. // -------------------------------------------------------------------
  147. // Set ui stuff
  148. // nothing
  149. // -------------------------------------------------------------------
  150. // Plugin state
  151. void reload() override
  152. {
  153. CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr,);
  154. carla_debug("CarlaPluginSFZero::reload() - start");
  155. const EngineProcessMode processMode(pData->engine->getProccessMode());
  156. // Safely disable plugin for reload
  157. const ScopedDisabler sd(this);
  158. if (pData->active)
  159. deactivate();
  160. clearBuffers();
  161. pData->audioOut.createNew(2);
  162. pData->param.createNew(1, false);
  163. const uint portNameSize(pData->engine->getMaxPortNameSize());
  164. CarlaString portName;
  165. // ---------------------------------------
  166. // Audio Outputs
  167. // out-left
  168. portName.clear();
  169. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  170. {
  171. portName = pData->name;
  172. portName += ":";
  173. }
  174. portName += "out-left";
  175. portName.truncate(portNameSize);
  176. pData->audioOut.ports[0].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false, 0);
  177. pData->audioOut.ports[0].rindex = 0;
  178. // out-right
  179. portName.clear();
  180. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  181. {
  182. portName = pData->name;
  183. portName += ":";
  184. }
  185. portName += "out-right";
  186. portName.truncate(portNameSize);
  187. pData->audioOut.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false, 1);
  188. pData->audioOut.ports[1].rindex = 1;
  189. // ---------------------------------------
  190. // Event Input
  191. portName.clear();
  192. if (processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
  193. {
  194. portName = pData->name;
  195. portName += ":";
  196. }
  197. portName += "events-in";
  198. portName.truncate(portNameSize);
  199. pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true, 0);
  200. // ---------------------------------------
  201. // Parameters
  202. pData->param.data[0].type = PARAMETER_OUTPUT;
  203. pData->param.data[0].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER;
  204. pData->param.data[0].index = 0;
  205. pData->param.data[0].rindex = 0;
  206. pData->param.ranges[0].min = 0.0f;
  207. pData->param.ranges[0].max = 128;
  208. pData->param.ranges[0].def = 0.0f;
  209. pData->param.ranges[0].step = 1.0f;
  210. pData->param.ranges[0].stepSmall = 1.0f;
  211. pData->param.ranges[0].stepLarge = 1.0f;
  212. // ---------------------------------------
  213. // plugin hints
  214. pData->hints = 0x0;
  215. pData->hints |= PLUGIN_IS_SYNTH;
  216. pData->hints |= PLUGIN_CAN_VOLUME;
  217. pData->hints |= PLUGIN_CAN_BALANCE;
  218. // extra plugin hints
  219. pData->extraHints = 0x0;
  220. pData->extraHints |= PLUGIN_EXTRA_HINT_HAS_MIDI_IN;
  221. pData->extraHints |= PLUGIN_EXTRA_HINT_CAN_RUN_RACK;
  222. bufferSizeChanged(pData->engine->getBufferSize());
  223. reloadPrograms(true);
  224. if (pData->active)
  225. activate();
  226. carla_debug("CarlaPluginSFZero::reload() - end");
  227. }
  228. // -------------------------------------------------------------------
  229. // Plugin processing
  230. void process(const float** const, float** const audioOut, const float** const, float** const, const uint32_t frames) override
  231. {
  232. // --------------------------------------------------------------------------------------------------------
  233. // Check if active
  234. if (! pData->active)
  235. {
  236. // disable any output sound
  237. for (uint32_t i=0; i < pData->audioOut.count; ++i)
  238. carla_zeroFloats(audioOut[i], frames);
  239. fNumVoices = 0.0f;
  240. return;
  241. }
  242. // --------------------------------------------------------------------------------------------------------
  243. // Check if needs reset
  244. if (pData->needsReset)
  245. {
  246. fSynth.allNotesOff(0, false);
  247. pData->needsReset = false;
  248. }
  249. // --------------------------------------------------------------------------------------------------------
  250. // Event Input and Processing
  251. {
  252. // ----------------------------------------------------------------------------------------------------
  253. // Setup audio buffer
  254. AudioSampleBuffer audioOutBuffer(audioOut, 2, frames);
  255. // ----------------------------------------------------------------------------------------------------
  256. // MIDI Input (External)
  257. if (pData->extNotes.mutex.tryLock())
  258. {
  259. for (RtLinkedList<ExternalMidiNote>::Itenerator it = pData->extNotes.data.begin2(); it.valid(); it.next())
  260. {
  261. const ExternalMidiNote& note(it.getValue(kExternalMidiNoteFallback));
  262. CARLA_SAFE_ASSERT_CONTINUE(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);
  263. if (note.velo > 0)
  264. fSynth.noteOn(note.channel+1, note.note, static_cast<float>(note.velo)/127.0f);
  265. else
  266. fSynth.noteOff(note.channel+1, note.note, static_cast<float>(note.velo)/127.0f, true);
  267. }
  268. pData->extNotes.data.clear();
  269. pData->extNotes.mutex.unlock();
  270. } // End of MIDI Input (External)
  271. // ----------------------------------------------------------------------------------------------------
  272. // Event Input (System)
  273. #ifndef BUILD_BRIDGE
  274. bool allNotesOffSent = false;
  275. #endif
  276. uint32_t timeOffset = 0;
  277. for (uint32_t i=0, numEvents=pData->event.portIn->getEventCount(); i < numEvents; ++i)
  278. {
  279. const EngineEvent& event(pData->event.portIn->getEvent(i));
  280. uint32_t eventTime = event.time;
  281. CARLA_SAFE_ASSERT_CONTINUE(eventTime < frames);
  282. if (eventTime < timeOffset)
  283. {
  284. carla_stderr2("Timing error, eventTime:%u < timeOffset:%u for '%s'",
  285. eventTime, timeOffset, pData->name);
  286. eventTime = timeOffset;
  287. }
  288. else if (eventTime > timeOffset)
  289. {
  290. if (processSingle(audioOutBuffer, eventTime - timeOffset, timeOffset))
  291. timeOffset = eventTime;
  292. }
  293. // Control change
  294. switch (event.type)
  295. {
  296. case kEngineEventTypeNull:
  297. break;
  298. case kEngineEventTypeControl:
  299. {
  300. const EngineControlEvent& ctrlEvent = event.ctrl;
  301. switch (ctrlEvent.type)
  302. {
  303. case kEngineControlEventTypeNull:
  304. break;
  305. case kEngineControlEventTypeParameter:
  306. {
  307. #ifndef BUILD_BRIDGE
  308. // Control backend stuff
  309. if (event.channel == pData->ctrlChannel)
  310. {
  311. float value;
  312. if (MIDI_IS_CONTROL_BREATH_CONTROLLER(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_DRYWET) != 0)
  313. {
  314. value = ctrlEvent.value;
  315. setDryWetRT(value);
  316. }
  317. if (MIDI_IS_CONTROL_CHANNEL_VOLUME(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_VOLUME) != 0)
  318. {
  319. value = ctrlEvent.value*127.0f/100.0f;
  320. setVolumeRT(value);
  321. }
  322. if (MIDI_IS_CONTROL_BALANCE(ctrlEvent.param) && (pData->hints & PLUGIN_CAN_BALANCE) != 0)
  323. {
  324. float left, right;
  325. value = ctrlEvent.value/0.5f - 1.0f;
  326. if (value < 0.0f)
  327. {
  328. left = -1.0f;
  329. right = (value*2.0f)+1.0f;
  330. }
  331. else if (value > 0.0f)
  332. {
  333. left = (value*2.0f)-1.0f;
  334. right = 1.0f;
  335. }
  336. else
  337. {
  338. left = -1.0f;
  339. right = 1.0f;
  340. }
  341. setBalanceLeftRT(left);
  342. setBalanceRightRT(right);
  343. }
  344. }
  345. #endif
  346. // Control plugin parameters
  347. for (uint32_t k=0; k < pData->param.count; ++k)
  348. {
  349. if (pData->param.data[k].midiChannel != event.channel)
  350. continue;
  351. if (pData->param.data[k].midiCC != ctrlEvent.param)
  352. continue;
  353. if (pData->param.data[k].hints != PARAMETER_INPUT)
  354. continue;
  355. if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0)
  356. continue;
  357. float value;
  358. if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN)
  359. {
  360. value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max;
  361. }
  362. else
  363. {
  364. value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value);
  365. if (pData->param.data[k].hints & PARAMETER_IS_INTEGER)
  366. value = std::rint(value);
  367. }
  368. setParameterValueRT(k, value);
  369. }
  370. if ((pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) != 0 && ctrlEvent.param < MAX_MIDI_CONTROL)
  371. {
  372. fSynth.handleController(event.channel+1, ctrlEvent.param, int(ctrlEvent.value*127.0f));
  373. }
  374. break;
  375. }
  376. case kEngineControlEventTypeMidiBank:
  377. case kEngineControlEventTypeMidiProgram:
  378. case kEngineControlEventTypeAllSoundOff:
  379. break;
  380. case kEngineControlEventTypeAllNotesOff:
  381. if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
  382. {
  383. #ifndef BUILD_BRIDGE
  384. if (event.channel == pData->ctrlChannel && ! allNotesOffSent)
  385. {
  386. allNotesOffSent = true;
  387. sendMidiAllNotesOffToCallback();
  388. }
  389. #endif
  390. fSynth.allNotesOff(event.channel+1, true);
  391. }
  392. break;
  393. }
  394. break;
  395. }
  396. case kEngineEventTypeMidi: {
  397. const EngineMidiEvent& midiEvent(event.midi);
  398. const uint8_t* const midiData(midiEvent.size > EngineMidiEvent::kDataSize ? midiEvent.dataExt : midiEvent.data);
  399. uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiData));
  400. if (status == MIDI_STATUS_CHANNEL_PRESSURE && (pData->options & PLUGIN_OPTION_SEND_CHANNEL_PRESSURE) == 0)
  401. continue;
  402. if (status == MIDI_STATUS_CONTROL_CHANGE && (pData->options & PLUGIN_OPTION_SEND_CONTROL_CHANGES) == 0)
  403. continue;
  404. if (status == MIDI_STATUS_POLYPHONIC_AFTERTOUCH && (pData->options & PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH) == 0)
  405. continue;
  406. if (status == MIDI_STATUS_PITCH_WHEEL_CONTROL && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) == 0)
  407. continue;
  408. // Fix bad note-off
  409. if (status == MIDI_STATUS_NOTE_ON && midiData[2] == 0)
  410. status = MIDI_STATUS_NOTE_OFF;
  411. // put back channel in data
  412. uint8_t midiData2[midiEvent.size];
  413. midiData2[0] = uint8_t(status | (event.channel & MIDI_CHANNEL_BIT));
  414. std::memcpy(midiData2+1, midiData+1, static_cast<std::size_t>(midiEvent.size-1));
  415. const MidiMessage midiMessage(midiData2, static_cast<int>(midiEvent.size), 0.0);
  416. fSynth.handleMidiEvent(midiMessage);
  417. if (status == MIDI_STATUS_NOTE_ON)
  418. pData->postponeRtEvent(kPluginPostRtEventNoteOn, event.channel, midiData[1], midiData[2]);
  419. else if (status == MIDI_STATUS_NOTE_OFF)
  420. pData->postponeRtEvent(kPluginPostRtEventNoteOff, event.channel, midiData[1], 0.0f);
  421. } break;
  422. }
  423. }
  424. pData->postRtEvents.trySplice();
  425. if (frames > timeOffset)
  426. processSingle(audioOutBuffer, frames - timeOffset, timeOffset);
  427. } // End of Event Input and Processing
  428. // --------------------------------------------------------------------------------------------------------
  429. // Parameter outputs
  430. fNumVoices = fSynth.numVoicesUsed();
  431. }
  432. bool processSingle(AudioSampleBuffer& audioOutBuffer, const uint32_t frames, const uint32_t timeOffset)
  433. {
  434. CARLA_SAFE_ASSERT_RETURN(frames > 0, false);
  435. // --------------------------------------------------------------------------------------------------------
  436. // Try lock, silence otherwise
  437. #ifndef STOAT_TEST_BUILD
  438. if (pData->engine->isOffline())
  439. {
  440. pData->singleMutex.lock();
  441. }
  442. else
  443. #endif
  444. if (! pData->singleMutex.tryLock())
  445. {
  446. audioOutBuffer.clear(timeOffset, frames);
  447. return false;
  448. }
  449. // --------------------------------------------------------------------------------------------------------
  450. // Run plugin
  451. fSynth.renderVoices(audioOutBuffer, timeOffset, frames);
  452. #ifndef BUILD_BRIDGE
  453. // --------------------------------------------------------------------------------------------------------
  454. // Post-processing (dry/wet, volume and balance)
  455. {
  456. const bool doVolume = carla_isNotEqual(pData->postProc.volume, 1.0f);
  457. const bool doBalance = carla_isNotEqual(pData->postProc.balanceLeft, -1.0f) || carla_isNotEqual(pData->postProc.balanceRight, 1.0f);
  458. float* outBufferL = audioOutBuffer.getWritePointer(0, timeOffset);
  459. float* outBufferR = audioOutBuffer.getWritePointer(1, timeOffset);
  460. #if 0
  461. if (doBalance)
  462. {
  463. float oldBufLeft[frames];
  464. // there was a loop here
  465. {
  466. if (i % 2 == 0)
  467. carla_copyFloats(oldBufLeft, outBuffer[i], frames);
  468. float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
  469. float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;
  470. for (uint32_t k=0; k < frames; ++k)
  471. {
  472. if (i % 2 == 0)
  473. {
  474. // left
  475. outBuffer[i][k] = oldBufLeft[k] * (1.0f - balRangeL);
  476. outBuffer[i][k] += outBuffer[i+1][k] * (1.0f - balRangeR);
  477. }
  478. else
  479. {
  480. // right
  481. outBuffer[i][k] = outBuffer[i][k] * balRangeR;
  482. outBuffer[i][k] += oldBufLeft[k] * balRangeL;
  483. }
  484. }
  485. }
  486. }
  487. #endif
  488. if (doVolume)
  489. {
  490. const float volume = pData->postProc.volume;
  491. for (uint32_t k=0; k < frames; ++k)
  492. {
  493. *outBufferL++ *= volume;
  494. *outBufferR++ *= volume;
  495. }
  496. }
  497. } // End of Post-processing
  498. #endif
  499. // --------------------------------------------------------------------------------------------------------
  500. pData->singleMutex.unlock();
  501. return true;
  502. }
  503. void sampleRateChanged(const double newSampleRate) override
  504. {
  505. fSynth.setCurrentPlaybackSampleRate(newSampleRate);
  506. }
  507. // -------------------------------------------------------------------
  508. // Plugin buffers
  509. // nothing
  510. // -------------------------------------------------------------------
  511. bool init(const char* const filename, const char* const name, const char* const label, const uint options)
  512. {
  513. CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);
  514. // ---------------------------------------------------------------
  515. // first checks
  516. if (pData->client != nullptr)
  517. {
  518. pData->engine->setLastError("Plugin client is already registered");
  519. return false;
  520. }
  521. if (filename == nullptr || filename[0] == '\0')
  522. {
  523. pData->engine->setLastError("null filename");
  524. return false;
  525. }
  526. for (int i = 128; --i >=0;)
  527. fSynth.addVoice(new sfzero::Voice());
  528. // ---------------------------------------------------------------
  529. // Init SFZero stuff
  530. fSynth.setCurrentPlaybackSampleRate(pData->engine->getSampleRate());
  531. File file(filename);
  532. sfzero::Sound* const sound = new sfzero::Sound(file);
  533. sfzero::Sound::LoadingIdleCallback cb = {
  534. loadingIdleCallbackFunction,
  535. pData->engine,
  536. };
  537. sound->loadRegions();
  538. sound->loadSamples(cb);
  539. if (fSynth.addSound(sound) == nullptr)
  540. {
  541. pData->engine->setLastError("Failed to allocate SFZ sounds in memory");
  542. return false;
  543. }
  544. const String dump = sound->dump();
  545. carla_stdout("SFZero sound information:");
  546. std::puts(dump.toRawUTF8());
  547. // ---------------------------------------------------------------
  548. const String basename(File(filename).getFileNameWithoutExtension());
  549. CarlaString label2(label != nullptr ? label : basename.toRawUTF8());
  550. fLabel = label2.dup();
  551. fRealName = carla_strdup(basename.toRawUTF8());
  552. pData->filename = carla_strdup(filename);
  553. if (name != nullptr && name[0] != '\0')
  554. pData->name = pData->engine->getUniquePluginName(name);
  555. else if (fRealName[0] != '\0')
  556. pData->name = pData->engine->getUniquePluginName(fRealName);
  557. else
  558. pData->name = pData->engine->getUniquePluginName(fLabel);
  559. // ---------------------------------------------------------------
  560. // register client
  561. pData->client = pData->engine->addClient(this);
  562. if (pData->client == nullptr || ! pData->client->isOk())
  563. {
  564. pData->engine->setLastError("Failed to register plugin client");
  565. return false;
  566. }
  567. // ---------------------------------------------------------------
  568. // set default options
  569. pData->options = 0x0;
  570. pData->options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES;
  571. pData->options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
  572. pData->options |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH;
  573. pData->options |= PLUGIN_OPTION_SEND_PITCHBEND;
  574. pData->options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;
  575. return true;
  576. (void)options;
  577. }
  578. // -------------------------------------------------------------------
  579. private:
  580. sfzero::Synth fSynth;
  581. float fNumVoices;
  582. const char* fLabel;
  583. const char* fRealName;
  584. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginSFZero)
  585. };
  586. // -------------------------------------------------------------------------------------------------------------------
  587. CarlaPlugin* CarlaPlugin::newSFZero(const Initializer& init)
  588. {
  589. carla_debug("CarlaPluginSFZero::newSFZero({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})",
  590. init.engine, init.filename, init.name, init.label, init.uniqueId);
  591. // -------------------------------------------------------------------
  592. // Check if file exists
  593. if (! File(init.filename).existsAsFile())
  594. {
  595. init.engine->setLastError("Requested file is not valid or does not exist");
  596. return nullptr;
  597. }
  598. CarlaPluginSFZero* const plugin(new CarlaPluginSFZero(init.engine, init.id));
  599. if (! plugin->init(init.filename, init.name, init.label, init.options))
  600. {
  601. delete plugin;
  602. return nullptr;
  603. }
  604. return plugin;
  605. }
  606. // -------------------------------------------------------------------------------------------------------------------
  607. CARLA_BACKEND_END_NAMESPACE