The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

2034 lines
72KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #include "../../juce_core/system/juce_TargetPlatform.h"
  18. #include "../utility/juce_CheckSettingMacros.h"
  19. #if JucePlugin_Build_VST
  20. #ifdef _MSC_VER
  21. #pragma warning (disable : 4996 4100)
  22. #endif
  23. #include "../utility/juce_IncludeSystemHeaders.h"
  24. #ifdef PRAGMA_ALIGN_SUPPORTED
  25. #undef PRAGMA_ALIGN_SUPPORTED
  26. #define PRAGMA_ALIGN_SUPPORTED 1
  27. #endif
  28. #ifndef _MSC_VER
  29. #define __cdecl
  30. #endif
  31. #ifdef __clang__
  32. #pragma clang diagnostic push
  33. #pragma clang diagnostic ignored "-Wconversion"
  34. #pragma clang diagnostic ignored "-Wshadow"
  35. #pragma clang diagnostic ignored "-Wdeprecated-register"
  36. #pragma clang diagnostic ignored "-Wunused-parameter"
  37. #pragma clang diagnostic ignored "-Wdeprecated-writable-strings"
  38. #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
  39. #endif
  40. #ifdef _MSC_VER
  41. #pragma warning (push)
  42. #pragma warning (disable : 4458)
  43. #endif
  44. /* These files come with the Steinberg VST SDK - to get them, you'll need to
  45. visit the Steinberg website and agree to whatever is currently required to
  46. get them. The best version to get is the VST3 SDK, which also contains
  47. the older VST2.4 files.
  48. Then, you'll need to make sure your include path contains your "VST SDK3"
  49. directory (or whatever you've named it on your machine). The Projucer has
  50. a special box for setting this path.
  51. */
  52. #include <public.sdk/source/vst2.x/audioeffectx.h>
  53. #include <public.sdk/source/vst2.x/aeffeditor.h>
  54. #include <public.sdk/source/vst2.x/audioeffectx.cpp>
  55. #include <public.sdk/source/vst2.x/audioeffect.cpp>
  56. #if ! VST_2_4_EXTENSIONS
  57. #error "It looks like you're trying to include an out-of-date VSTSDK version - make sure you have at least version 2.4"
  58. #endif
  59. #ifndef JUCE_VST3_CAN_REPLACE_VST2
  60. #define JUCE_VST3_CAN_REPLACE_VST2 1
  61. #endif
  62. #if JucePlugin_Build_VST3 && JUCE_VST3_CAN_REPLACE_VST2
  63. #include <pluginterfaces/base/funknown.h>
  64. namespace juce { extern Steinberg::FUID getJuceVST3ComponentIID(); }
  65. #endif
  66. #ifdef _MSC_VER
  67. #pragma warning (pop)
  68. #endif
  69. #ifdef __clang__
  70. #pragma clang diagnostic pop
  71. #endif
  72. //==============================================================================
  73. #ifdef _MSC_VER
  74. #pragma pack (push, 8)
  75. #endif
  76. #include "../utility/juce_IncludeModuleHeaders.h"
  77. #include "../utility/juce_FakeMouseMoveGenerator.h"
  78. #include "../utility/juce_WindowsHooks.h"
  79. #include "../utility/juce_PluginBusUtilities.h"
  80. #ifdef _MSC_VER
  81. #pragma pack (pop)
  82. #endif
  83. #undef MemoryBlock
  84. class JuceVSTWrapper;
  85. static bool recursionCheck = false;
  86. JUCE_DEFINE_WRAPPER_TYPE (wrapperType_VST);
  87. namespace juce
  88. {
  89. #if JUCE_MAC
  90. extern JUCE_API void initialiseMacVST();
  91. extern JUCE_API void* attachComponentToWindowRefVST (Component*, void* parent, bool isNSView);
  92. extern JUCE_API void detachComponentFromWindowRefVST (Component*, void* window, bool isNSView);
  93. extern JUCE_API void setNativeHostWindowSizeVST (void* window, Component*, int newWidth, int newHeight, bool isNSView);
  94. extern JUCE_API void checkWindowVisibilityVST (void* window, Component*, bool isNSView);
  95. extern JUCE_API bool forwardCurrentKeyEventToHostVST (Component*, bool isNSView);
  96. #if ! JUCE_64BIT
  97. extern JUCE_API void updateEditorCompBoundsVST (Component*);
  98. #endif
  99. #endif
  100. #if JUCE_LINUX
  101. extern Display* display;
  102. #endif
  103. }
  104. //==============================================================================
  105. #if JUCE_WINDOWS
  106. namespace
  107. {
  108. // Returns the actual container window, unlike GetParent, which can also return a separate owner window.
  109. static HWND getWindowParent (HWND w) noexcept { return GetAncestor (w, GA_PARENT); }
  110. static HWND findMDIParentOf (HWND w)
  111. {
  112. const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME);
  113. while (w != 0)
  114. {
  115. HWND parent = getWindowParent (w);
  116. if (parent == 0)
  117. break;
  118. TCHAR windowType[32] = { 0 };
  119. GetClassName (parent, windowType, 31);
  120. if (String (windowType).equalsIgnoreCase ("MDIClient"))
  121. return parent;
  122. RECT windowPos, parentPos;
  123. GetWindowRect (w, &windowPos);
  124. GetWindowRect (parent, &parentPos);
  125. const int dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left);
  126. const int dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top);
  127. if (dw > 100 || dh > 100)
  128. break;
  129. w = parent;
  130. if (dw == 2 * frameThickness)
  131. break;
  132. }
  133. return w;
  134. }
  135. static bool messageThreadIsDefinitelyCorrect = false;
  136. }
  137. //==============================================================================
  138. #elif JUCE_LINUX
  139. class SharedMessageThread : public Thread
  140. {
  141. public:
  142. SharedMessageThread()
  143. : Thread ("VstMessageThread"),
  144. initialised (false)
  145. {
  146. startThread (7);
  147. while (! initialised)
  148. sleep (1);
  149. }
  150. ~SharedMessageThread()
  151. {
  152. signalThreadShouldExit();
  153. JUCEApplicationBase::quit();
  154. waitForThreadToExit (5000);
  155. clearSingletonInstance();
  156. }
  157. void run() override
  158. {
  159. initialiseJuce_GUI();
  160. initialised = true;
  161. MessageManager::getInstance()->setCurrentThreadAsMessageThread();
  162. while ((! threadShouldExit()) && MessageManager::getInstance()->runDispatchLoopUntil (250))
  163. {}
  164. }
  165. juce_DeclareSingleton (SharedMessageThread, false)
  166. private:
  167. bool initialised;
  168. };
  169. juce_ImplementSingleton (SharedMessageThread)
  170. #endif
  171. static Array<void*> activePlugins;
  172. //==============================================================================
  173. /**
  174. This is an AudioEffectX object that holds and wraps our AudioProcessor...
  175. */
  176. class JuceVSTWrapper : public AudioEffectX,
  177. public AudioProcessorListener,
  178. public AudioPlayHead,
  179. private Timer,
  180. private AsyncUpdater
  181. {
  182. private:
  183. //==============================================================================
  184. template <typename FloatType>
  185. struct VstTempBuffers
  186. {
  187. VstTempBuffers() {}
  188. ~VstTempBuffers() { release(); }
  189. void release() noexcept
  190. {
  191. for (int i = tempChannels.size(); --i >= 0;)
  192. delete[] (tempChannels.getUnchecked(i));
  193. tempChannels.clear();
  194. }
  195. HeapBlock<FloatType*> channels;
  196. Array<FloatType*> tempChannels; // see note in processReplacing()
  197. juce::AudioBuffer<FloatType> processTempBuffer;
  198. };
  199. public:
  200. //==============================================================================
  201. JuceVSTWrapper (audioMasterCallback audioMasterCB, AudioProcessor* const af)
  202. : AudioEffectX (audioMasterCB, af->getNumPrograms(), af->getNumParameters()),
  203. filter (af),
  204. busUtils (*filter, true, 64),
  205. chunkMemoryTime (0),
  206. isProcessing (false),
  207. isBypassed (false),
  208. hasShutdown (false),
  209. isInSizeWindow (false),
  210. firstProcessCallback (true),
  211. shouldDeleteEditor (false),
  212. #if JUCE_64BIT
  213. useNSView (true),
  214. #else
  215. useNSView (false),
  216. #endif
  217. hostWindow (0)
  218. {
  219. busUtils.init();
  220. // VST-2 does not support disabling buses: so always enable all of them
  221. if (busUtils.hasDynamicInBuses() || busUtils.hasDynamicOutBuses())
  222. busUtils.enableAllBuses();
  223. {
  224. // Using the legacy Projucer field? Then keep the maximum number of channels
  225. // as the default plug-in layout. Otherwise, leave it up to the user
  226. // which default layout the prefer.
  227. #ifndef JucePlugin_PreferredChannelConfigurations
  228. PluginBusUtilities::ScopedBusRestorer busRestorer (busUtils);
  229. #endif
  230. findMaxTotalChannels (maxNumInChannels, maxNumOutChannels);
  231. bool success = setBusArrangementFromTotalChannelNum (maxNumInChannels, maxNumOutChannels);
  232. ignoreUnused (success);
  233. // please file a bug if you hit this assertsion!
  234. jassert (maxNumInChannels == busUtils.findTotalNumChannels (true) && success
  235. && maxNumOutChannels == busUtils.findTotalNumChannels (false));
  236. }
  237. filter->setRateAndBufferSizeDetails (0, 0);
  238. filter->setPlayHead (this);
  239. filter->addListener (this);
  240. cEffect.flags |= effFlagsHasEditor;
  241. cEffect.version = convertHexVersionToDecimal (JucePlugin_VersionCode);
  242. setUniqueID ((int) (JucePlugin_VSTUniqueID));
  243. setNumInputs (maxNumInChannels);
  244. setNumOutputs (maxNumOutChannels);
  245. canProcessReplacing (true);
  246. canDoubleReplacing (filter->supportsDoublePrecisionProcessing());
  247. isSynth ((JucePlugin_IsSynth) != 0);
  248. setInitialDelay (filter->getLatencySamples());
  249. programsAreChunks (true);
  250. // NB: For reasons best known to themselves, some hosts fail to load/save plugin
  251. // state correctly if the plugin doesn't report that it has at least 1 program.
  252. jassert (af->getNumPrograms() > 0);
  253. activePlugins.add (this);
  254. }
  255. ~JuceVSTWrapper()
  256. {
  257. JUCE_AUTORELEASEPOOL
  258. {
  259. {
  260. #if JUCE_LINUX
  261. MessageManagerLock mmLock;
  262. #endif
  263. stopTimer();
  264. deleteEditor (false);
  265. hasShutdown = true;
  266. delete filter;
  267. filter = nullptr;
  268. jassert (editorComp == 0);
  269. deleteTempChannels();
  270. jassert (activePlugins.contains (this));
  271. activePlugins.removeFirstMatchingValue (this);
  272. }
  273. if (activePlugins.size() == 0)
  274. {
  275. #if JUCE_LINUX
  276. SharedMessageThread::deleteInstance();
  277. #endif
  278. shutdownJuce_GUI();
  279. #if JUCE_WINDOWS
  280. messageThreadIsDefinitelyCorrect = false;
  281. #endif
  282. }
  283. }
  284. }
  285. void open() override
  286. {
  287. // Note: most hosts call this on the UI thread, but wavelab doesn't, so be careful in here.
  288. if (filter->hasEditor())
  289. cEffect.flags |= effFlagsHasEditor;
  290. else
  291. cEffect.flags &= ~effFlagsHasEditor;
  292. }
  293. void close() override
  294. {
  295. // Note: most hosts call this on the UI thread, but wavelab doesn't, so be careful in here.
  296. stopTimer();
  297. if (MessageManager::getInstance()->isThisTheMessageThread())
  298. deleteEditor (false);
  299. }
  300. //==============================================================================
  301. bool getEffectName (char* name) override
  302. {
  303. String (JucePlugin_Name).copyToUTF8 (name, 64);
  304. return true;
  305. }
  306. bool getVendorString (char* text) override
  307. {
  308. String (JucePlugin_Manufacturer).copyToUTF8 (text, 64);
  309. return true;
  310. }
  311. bool getProductString (char* text) override { return getEffectName (text); }
  312. VstInt32 getVendorVersion() override { return convertHexVersionToDecimal (JucePlugin_VersionCode); }
  313. VstPlugCategory getPlugCategory() override { return JucePlugin_VSTCategory; }
  314. bool keysRequired() { return (JucePlugin_EditorRequiresKeyboardFocus) != 0; }
  315. VstInt32 canDo (char* text) override
  316. {
  317. if (strcmp (text, "receiveVstEvents") == 0
  318. || strcmp (text, "receiveVstMidiEvent") == 0
  319. || strcmp (text, "receiveVstMidiEvents") == 0)
  320. {
  321. #if JucePlugin_WantsMidiInput
  322. return 1;
  323. #else
  324. return -1;
  325. #endif
  326. }
  327. if (strcmp (text, "sendVstEvents") == 0
  328. || strcmp (text, "sendVstMidiEvent") == 0
  329. || strcmp (text, "sendVstMidiEvents") == 0)
  330. {
  331. #if JucePlugin_ProducesMidiOutput
  332. return 1;
  333. #else
  334. return -1;
  335. #endif
  336. }
  337. if (strcmp (text, "receiveVstTimeInfo") == 0
  338. || strcmp (text, "conformsToWindowRules") == 0
  339. || strcmp (text, "bypass") == 0)
  340. {
  341. return 1;
  342. }
  343. // This tells Wavelab to use the UI thread to invoke open/close,
  344. // like all other hosts do.
  345. if (strcmp (text, "openCloseAnyThread") == 0)
  346. return -1;
  347. if (strcmp (text, "MPE") == 0)
  348. return filter->supportsMPE() ? 1 : 0;
  349. #if JUCE_MAC
  350. if (strcmp (text, "hasCockosViewAsConfig") == 0)
  351. {
  352. useNSView = true;
  353. return (VstInt32) 0xbeef0000;
  354. }
  355. #endif
  356. return 0;
  357. }
  358. VstIntPtr vendorSpecific (VstInt32 lArg, VstIntPtr lArg2, void* ptrArg, float floatArg) override
  359. {
  360. ignoreUnused (lArg, lArg2, ptrArg, floatArg);
  361. #if JucePlugin_Build_VST3 && JUCE_VST3_CAN_REPLACE_VST2
  362. if ((lArg == 'stCA' || lArg == 'stCa') && lArg2 == 'FUID' && ptrArg != nullptr)
  363. {
  364. memcpy (ptrArg, getJuceVST3ComponentIID(), 16);
  365. return 1;
  366. }
  367. #endif
  368. return 0;
  369. }
  370. bool setBypass (bool b) override
  371. {
  372. isBypassed = b;
  373. return true;
  374. }
  375. VstInt32 getGetTailSize() override
  376. {
  377. if (filter != nullptr)
  378. return (VstInt32) (filter->getTailLengthSeconds() * getSampleRate());
  379. return 0;
  380. }
  381. //==============================================================================
  382. VstInt32 processEvents (VstEvents* events) override
  383. {
  384. #if JucePlugin_WantsMidiInput
  385. VSTMidiEventList::addEventsToMidiBuffer (events, midiEvents);
  386. return 1;
  387. #else
  388. ignoreUnused (events);
  389. return 0;
  390. #endif
  391. }
  392. template <typename FloatType>
  393. void internalProcessReplacing (FloatType** inputs, FloatType** outputs,
  394. VstInt32 numSamples, VstTempBuffers<FloatType>& tmpBuffers)
  395. {
  396. if (firstProcessCallback)
  397. {
  398. firstProcessCallback = false;
  399. // if this fails, the host hasn't called resume() before processing
  400. jassert (isProcessing);
  401. // (tragically, some hosts actually need this, although it's stupid to have
  402. // to do it here..)
  403. if (! isProcessing)
  404. resume();
  405. filter->setNonRealtime (getCurrentProcessLevel() == 4 /* kVstProcessLevelOffline */);
  406. }
  407. #if JUCE_DEBUG && ! JucePlugin_ProducesMidiOutput
  408. const int numMidiEventsComingIn = midiEvents.getNumEvents();
  409. #endif
  410. jassert (activePlugins.contains (this));
  411. {
  412. const int numIn = filter->getTotalNumInputChannels();
  413. const int numOut = filter->getTotalNumOutputChannels();
  414. const ScopedLock sl (filter->getCallbackLock());
  415. if (filter->isSuspended())
  416. {
  417. for (int i = 0; i < numOut; ++i)
  418. FloatVectorOperations::clear (outputs[i], numSamples);
  419. }
  420. else
  421. {
  422. int i;
  423. for (i = 0; i < numOut; ++i)
  424. {
  425. FloatType* chan = tmpBuffers.tempChannels.getUnchecked(i);
  426. if (chan == nullptr)
  427. {
  428. chan = outputs[i];
  429. // if some output channels are disabled, some hosts supply the same buffer
  430. // for multiple channels - this buggers up our method of copying the
  431. // inputs over the outputs, so we need to create unique temp buffers in this case..
  432. for (int j = i; --j >= 0;)
  433. {
  434. if (outputs[j] == chan)
  435. {
  436. chan = new FloatType [blockSize * 2];
  437. tmpBuffers.tempChannels.set (i, chan);
  438. break;
  439. }
  440. }
  441. }
  442. if (i < numIn)
  443. {
  444. if (chan != inputs[i])
  445. memcpy (chan, inputs[i], sizeof (FloatType) * (size_t) numSamples);
  446. }
  447. else
  448. {
  449. FloatVectorOperations::clear (chan, numSamples);
  450. }
  451. tmpBuffers.channels[i] = chan;
  452. }
  453. for (; i < numIn; ++i)
  454. tmpBuffers.channels[i] = inputs[i];
  455. {
  456. const int numChannels = jmax (numIn, numOut);
  457. AudioBuffer<FloatType> chans (tmpBuffers.channels, numChannels, numSamples);
  458. if (isBypassed)
  459. filter->processBlockBypassed (chans, midiEvents);
  460. else
  461. filter->processBlock (chans, midiEvents);
  462. }
  463. // copy back any temp channels that may have been used..
  464. for (i = 0; i < numOut; ++i)
  465. if (const FloatType* const chan = tmpBuffers.tempChannels.getUnchecked(i))
  466. memcpy (outputs[i], chan, sizeof (FloatType) * (size_t) numSamples);
  467. }
  468. }
  469. if (! midiEvents.isEmpty())
  470. {
  471. #if JucePlugin_ProducesMidiOutput
  472. const int numEvents = midiEvents.getNumEvents();
  473. outgoingEvents.ensureSize (numEvents);
  474. outgoingEvents.clear();
  475. const juce::uint8* midiEventData;
  476. int midiEventSize, midiEventPosition;
  477. MidiBuffer::Iterator i (midiEvents);
  478. while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition))
  479. {
  480. jassert (midiEventPosition >= 0 && midiEventPosition < numSamples);
  481. outgoingEvents.addEvent (midiEventData, midiEventSize, midiEventPosition);
  482. }
  483. sendVstEventsToHost (outgoingEvents.events);
  484. #elif JUCE_DEBUG
  485. /* This assertion is caused when you've added some events to the
  486. midiMessages array in your processBlock() method, which usually means
  487. that you're trying to send them somewhere. But in this case they're
  488. getting thrown away.
  489. If your plugin does want to send midi messages, you'll need to set
  490. the JucePlugin_ProducesMidiOutput macro to 1 in your
  491. JucePluginCharacteristics.h file.
  492. If you don't want to produce any midi output, then you should clear the
  493. midiMessages array at the end of your processBlock() method, to
  494. indicate that you don't want any of the events to be passed through
  495. to the output.
  496. */
  497. jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn);
  498. #endif
  499. midiEvents.clear();
  500. }
  501. }
  502. void processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames) override
  503. {
  504. jassert (! filter->isUsingDoublePrecision());
  505. internalProcessReplacing (inputs, outputs, sampleFrames, floatTempBuffers);
  506. }
  507. void processDoubleReplacing (double** inputs, double** outputs, VstInt32 sampleFrames) override
  508. {
  509. jassert (filter->isUsingDoublePrecision());
  510. internalProcessReplacing (inputs, outputs, sampleFrames, doubleTempBuffers);
  511. }
  512. //==============================================================================
  513. VstInt32 startProcess() override { return 0; }
  514. VstInt32 stopProcess() override { return 0; }
  515. //==============================================================================
  516. bool setProcessPrecision (VstInt32 vstPrecision) override
  517. {
  518. if (! isProcessing)
  519. {
  520. if (filter != nullptr)
  521. {
  522. filter->setProcessingPrecision (vstPrecision == kVstProcessPrecision64 && filter->supportsDoublePrecisionProcessing()
  523. ? AudioProcessor::doublePrecision
  524. : AudioProcessor::singlePrecision);
  525. return true;
  526. }
  527. }
  528. return false;
  529. }
  530. void resume() override
  531. {
  532. if (filter != nullptr)
  533. {
  534. isProcessing = true;
  535. floatTempBuffers .channels.calloc ((size_t) (cEffect.numInputs + cEffect.numOutputs));
  536. doubleTempBuffers.channels.calloc ((size_t) (cEffect.numInputs + cEffect.numOutputs));
  537. const double currentRate = getSampleRate();
  538. const int currentBlockSize = getBlockSize();
  539. firstProcessCallback = true;
  540. filter->setNonRealtime (getCurrentProcessLevel() == 4 /* kVstProcessLevelOffline */);
  541. filter->setRateAndBufferSizeDetails (currentRate, currentBlockSize);
  542. deleteTempChannels();
  543. filter->prepareToPlay (currentRate, currentBlockSize);
  544. midiEvents.ensureSize (2048);
  545. midiEvents.clear();
  546. setInitialDelay (filter->getLatencySamples());
  547. AudioEffectX::resume();
  548. #if JucePlugin_ProducesMidiOutput
  549. outgoingEvents.ensureSize (512);
  550. #endif
  551. }
  552. }
  553. void suspend() override
  554. {
  555. if (filter != nullptr)
  556. {
  557. AudioEffectX::suspend();
  558. filter->releaseResources();
  559. outgoingEvents.freeEvents();
  560. isProcessing = false;
  561. floatTempBuffers.channels.free();
  562. doubleTempBuffers.channels.free();
  563. deleteTempChannels();
  564. }
  565. }
  566. bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) override
  567. {
  568. const VstTimeInfo* const ti = getTimeInfo (kVstPpqPosValid | kVstTempoValid | kVstBarsValid | kVstCyclePosValid
  569. | kVstTimeSigValid | kVstSmpteValid | kVstClockValid);
  570. if (ti == nullptr || ti->sampleRate <= 0)
  571. return false;
  572. info.bpm = (ti->flags & kVstTempoValid) != 0 ? ti->tempo : 0.0;
  573. if ((ti->flags & kVstTimeSigValid) != 0)
  574. {
  575. info.timeSigNumerator = ti->timeSigNumerator;
  576. info.timeSigDenominator = ti->timeSigDenominator;
  577. }
  578. else
  579. {
  580. info.timeSigNumerator = 4;
  581. info.timeSigDenominator = 4;
  582. }
  583. info.timeInSamples = (int64) (ti->samplePos + 0.5);
  584. info.timeInSeconds = ti->samplePos / ti->sampleRate;
  585. info.ppqPosition = (ti->flags & kVstPpqPosValid) != 0 ? ti->ppqPos : 0.0;
  586. info.ppqPositionOfLastBarStart = (ti->flags & kVstBarsValid) != 0 ? ti->barStartPos : 0.0;
  587. if ((ti->flags & kVstSmpteValid) != 0)
  588. {
  589. AudioPlayHead::FrameRateType rate = AudioPlayHead::fpsUnknown;
  590. double fps = 1.0;
  591. switch (ti->smpteFrameRate)
  592. {
  593. case kVstSmpte24fps: rate = AudioPlayHead::fps24; fps = 24.0; break;
  594. case kVstSmpte25fps: rate = AudioPlayHead::fps25; fps = 25.0; break;
  595. case kVstSmpte2997fps: rate = AudioPlayHead::fps2997; fps = 29.97; break;
  596. case kVstSmpte30fps: rate = AudioPlayHead::fps30; fps = 30.0; break;
  597. case kVstSmpte2997dfps: rate = AudioPlayHead::fps2997drop; fps = 29.97; break;
  598. case kVstSmpte30dfps: rate = AudioPlayHead::fps30drop; fps = 30.0; break;
  599. case kVstSmpteFilm16mm:
  600. case kVstSmpteFilm35mm: fps = 24.0; break;
  601. case kVstSmpte239fps: fps = 23.976; break;
  602. case kVstSmpte249fps: fps = 24.976; break;
  603. case kVstSmpte599fps: fps = 59.94; break;
  604. case kVstSmpte60fps: fps = 60; break;
  605. default: jassertfalse; // unknown frame-rate..
  606. }
  607. info.frameRate = rate;
  608. info.editOriginTime = ti->smpteOffset / (80.0 * fps);
  609. }
  610. else
  611. {
  612. info.frameRate = AudioPlayHead::fpsUnknown;
  613. info.editOriginTime = 0;
  614. }
  615. info.isRecording = (ti->flags & kVstTransportRecording) != 0;
  616. info.isPlaying = (ti->flags & (kVstTransportRecording | kVstTransportPlaying)) != 0;
  617. info.isLooping = (ti->flags & kVstTransportCycleActive) != 0;
  618. if ((ti->flags & kVstCyclePosValid) != 0)
  619. {
  620. info.ppqLoopStart = ti->cycleStartPos;
  621. info.ppqLoopEnd = ti->cycleEndPos;
  622. }
  623. else
  624. {
  625. info.ppqLoopStart = 0;
  626. info.ppqLoopEnd = 0;
  627. }
  628. return true;
  629. }
  630. //==============================================================================
  631. VstInt32 getProgram() override
  632. {
  633. return filter != nullptr ? filter->getCurrentProgram() : 0;
  634. }
  635. void setProgram (VstInt32 program) override
  636. {
  637. if (filter != nullptr)
  638. filter->setCurrentProgram (program);
  639. }
  640. void setProgramName (char* name) override
  641. {
  642. if (filter != nullptr)
  643. filter->changeProgramName (filter->getCurrentProgram(), name);
  644. }
  645. void getProgramName (char* name) override
  646. {
  647. if (filter != nullptr)
  648. filter->getProgramName (filter->getCurrentProgram()).copyToUTF8 (name, 24);
  649. }
  650. bool getProgramNameIndexed (VstInt32 /*category*/, VstInt32 index, char* text) override
  651. {
  652. if (filter != nullptr && isPositiveAndBelow (index, filter->getNumPrograms()))
  653. {
  654. filter->getProgramName (index).copyToUTF8 (text, 24);
  655. return true;
  656. }
  657. return false;
  658. }
  659. //==============================================================================
  660. float getParameter (VstInt32 index) override
  661. {
  662. if (filter == nullptr)
  663. return 0.0f;
  664. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  665. return filter->getParameter (index);
  666. }
  667. void setParameter (VstInt32 index, float value) override
  668. {
  669. if (filter != nullptr)
  670. {
  671. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  672. filter->setParameter (index, value);
  673. }
  674. }
  675. void getParameterDisplay (VstInt32 index, char* text) override
  676. {
  677. if (filter != nullptr)
  678. {
  679. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  680. filter->getParameterText (index, 24).copyToUTF8 (text, 24); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
  681. }
  682. }
  683. bool string2parameter (VstInt32 index, char* text) override
  684. {
  685. if (filter != nullptr)
  686. {
  687. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  688. if (AudioProcessorParameter* p = filter->getParameters()[index])
  689. {
  690. filter->setParameter (index, p->getValueForText (String::fromUTF8 (text)));
  691. return true;
  692. }
  693. }
  694. return false;
  695. }
  696. void getParameterName (VstInt32 index, char* text) override
  697. {
  698. if (filter != nullptr)
  699. {
  700. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  701. filter->getParameterName (index, 16).copyToUTF8 (text, 16); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
  702. }
  703. }
  704. void getParameterLabel (VstInt32 index, char* text) override
  705. {
  706. if (filter != nullptr)
  707. {
  708. jassert (isPositiveAndBelow (index, filter->getNumParameters()));
  709. filter->getParameterLabel (index).copyToUTF8 (text, 24); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
  710. }
  711. }
  712. void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) override
  713. {
  714. if (audioMaster != nullptr)
  715. audioMaster (&cEffect, audioMasterAutomate, index, 0, 0, newValue);
  716. }
  717. void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) override { beginEdit (index); }
  718. void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) override { endEdit (index); }
  719. void audioProcessorChanged (AudioProcessor*) override
  720. {
  721. setInitialDelay (filter->getLatencySamples());
  722. updateDisplay();
  723. triggerAsyncUpdate();
  724. }
  725. void handleAsyncUpdate() override
  726. {
  727. ioChanged();
  728. }
  729. bool canParameterBeAutomated (VstInt32 index) override
  730. {
  731. return filter != nullptr && filter->isParameterAutomatable ((int) index);
  732. }
  733. bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput,
  734. VstSpeakerArrangement* pluginOutput) override
  735. {
  736. const int numIns = busUtils.getBusCount (true);
  737. const int numOuts = busUtils.getBusCount (false);;
  738. if (pluginInput != nullptr && numIns == 0)
  739. return false;
  740. if (pluginOutput != nullptr && numOuts == 0)
  741. return false;
  742. if (numIns > 1 || numOuts > 1)
  743. {
  744. int newNumInChannels = (pluginInput != nullptr && pluginInput-> numChannels >= 0) ? pluginInput-> numChannels
  745. : busUtils.findTotalNumChannels (true);
  746. int newNumOutChannels = (pluginOutput != nullptr && pluginOutput->numChannels >= 0) ? pluginOutput->numChannels
  747. : busUtils.findTotalNumChannels (false);
  748. newNumInChannels = jmin (newNumInChannels, maxNumInChannels);
  749. newNumOutChannels = jmin (newNumOutChannels, maxNumOutChannels);
  750. if (! setBusArrangementFromTotalChannelNum (newNumInChannels, newNumOutChannels))
  751. return false;
  752. }
  753. else
  754. {
  755. PluginBusUtilities::ScopedBusRestorer busRestorer (busUtils);
  756. AudioChannelSet inLayoutType;
  757. if (pluginInput != nullptr && pluginInput-> numChannels >= 0)
  758. {
  759. inLayoutType = SpeakerMappings::vstArrangementTypeToChannelSet (*pluginInput);
  760. if (busUtils.getChannelSet (true, 0) != inLayoutType)
  761. if (! filter->setPreferredBusArrangement (true, 0, inLayoutType))
  762. return false;
  763. }
  764. if (pluginOutput != nullptr && pluginOutput->numChannels >= 0)
  765. {
  766. AudioChannelSet newType = SpeakerMappings::vstArrangementTypeToChannelSet (*pluginOutput);
  767. if (busUtils.getChannelSet (false, 0) != newType)
  768. if (! filter->setPreferredBusArrangement (false, 0, newType))
  769. return false;
  770. // re-check the input
  771. if ((! inLayoutType.isDisabled()) && busUtils.getChannelSet (true, 0) != inLayoutType)
  772. return false;
  773. busRestorer.release();
  774. }
  775. }
  776. filter->setRateAndBufferSizeDetails(0, 0);
  777. return true;
  778. }
  779. bool getSpeakerArrangement (VstSpeakerArrangement** pluginInput, VstSpeakerArrangement** pluginOutput) override
  780. {
  781. *pluginInput = 0;
  782. *pluginOutput = 0;
  783. if (! AudioEffectX::allocateArrangement (pluginInput, busUtils.findTotalNumChannels (true)))
  784. return false;
  785. if (! AudioEffectX::allocateArrangement (pluginOutput, busUtils.findTotalNumChannels (false)))
  786. {
  787. AudioEffectX::deallocateArrangement (pluginInput);
  788. *pluginInput = 0;
  789. return false;
  790. }
  791. if (pluginHasSidechainsOrAuxs())
  792. {
  793. int numIns = busUtils.findTotalNumChannels (true);
  794. int numOuts = busUtils.findTotalNumChannels (false);
  795. AudioChannelSet layout = AudioChannelSet::canonicalChannelSet (numIns);
  796. SpeakerMappings::channelSetToVstArrangement (layout, **pluginInput);
  797. layout = AudioChannelSet::canonicalChannelSet (numOuts);
  798. SpeakerMappings::channelSetToVstArrangement (layout, **pluginOutput);
  799. }
  800. else
  801. {
  802. SpeakerMappings::channelSetToVstArrangement (busUtils.getChannelSet (true, 0), **pluginInput);
  803. SpeakerMappings::channelSetToVstArrangement (busUtils.getChannelSet (false, 0), **pluginOutput);
  804. }
  805. return true;
  806. }
  807. bool getInputProperties (VstInt32 index, VstPinProperties* properties) override
  808. {
  809. return filter != nullptr
  810. && getPinProperties (*properties, true, (int) index);
  811. }
  812. bool getOutputProperties (VstInt32 index, VstPinProperties* properties) override
  813. {
  814. return filter != nullptr
  815. && getPinProperties (*properties, false, (int) index);
  816. }
  817. bool getPinProperties (VstPinProperties& properties, bool direction, int index) const
  818. {
  819. // fill with default
  820. properties.flags = kVstPinUseSpeaker;
  821. properties.label[0] = 0;
  822. properties.shortLabel[0] = 0;
  823. properties.arrangementType = kSpeakerArrEmpty;
  824. // index refers to the absolute index when combining all channels of every bus
  825. if (index >= (direction ? cEffect.numInputs : cEffect.numOutputs))
  826. return false;
  827. const int n = busUtils.getBusCount(direction);
  828. int busIdx;
  829. for (busIdx = 0; busIdx < n; ++busIdx)
  830. {
  831. const int numChans = busUtils.getNumChannels (direction, busIdx);
  832. if (index < numChans)
  833. break;
  834. index -= numChans;
  835. }
  836. if (busIdx >= n)
  837. return true;
  838. const AudioProcessor::AudioProcessorBus& busInfo = busUtils.getFilterBus (direction).getReference (busIdx);
  839. #ifdef JucePlugin_PreferredChannelConfigurations
  840. String abbvChannelName = String (index);
  841. #else
  842. String abbvChannelName = AudioChannelSet::getAbbreviatedChannelTypeName (busInfo.channels.getTypeOfChannel(index));
  843. #endif
  844. String channelName = busInfo.name + String (" ") + abbvChannelName;
  845. channelName.copyToUTF8 (properties.label, (size_t) (kVstMaxLabelLen - 1));
  846. channelName.copyToUTF8 (properties.shortLabel, (size_t) (kVstMaxShortLabelLen - 1));
  847. properties.flags = kVstPinUseSpeaker | kVstPinIsActive;
  848. properties.arrangementType = SpeakerMappings::channelSetToVstArrangementType (busInfo.channels);
  849. if (properties.arrangementType == kSpeakerArrEmpty)
  850. properties.flags &= ~kVstPinIsActive;
  851. if (busInfo.channels.size() == 2)
  852. properties.flags |= kVstPinIsStereo;
  853. return true;
  854. }
  855. //==============================================================================
  856. struct SpeakerMappings : private AudioChannelSet // (inheritance only to give easier access to items in the namespace)
  857. {
  858. struct Mapping
  859. {
  860. VstInt32 vst2;
  861. ChannelType channels[13];
  862. bool matches (const Array<ChannelType>& chans) const noexcept
  863. {
  864. const int n = sizeof (channels) / sizeof (ChannelType);
  865. for (int i = 0; i < n; ++i)
  866. {
  867. if (channels[i] == unknown) return (i == chans.size());
  868. if (i == chans.size()) return (channels[i] == unknown);
  869. if (channels[i] != chans.getUnchecked(i))
  870. return false;
  871. }
  872. return true;
  873. }
  874. };
  875. static AudioChannelSet vstArrangementTypeToChannelSet (const VstSpeakerArrangement& arr)
  876. {
  877. for (const Mapping* m = getMappings(); m->vst2 != kSpeakerArrEmpty; ++m)
  878. {
  879. if (m->vst2 == arr.type)
  880. {
  881. AudioChannelSet s;
  882. for (int i = 0; m->channels[i] != 0; ++i)
  883. s.addChannel (m->channels[i]);
  884. return s;
  885. }
  886. }
  887. return AudioChannelSet::discreteChannels (arr.numChannels);
  888. }
  889. static VstInt32 channelSetToVstArrangementType (AudioChannelSet channels)
  890. {
  891. Array<AudioChannelSet::ChannelType> chans (channels.getChannelTypes());
  892. if (channels == AudioChannelSet::disabled())
  893. return kSpeakerArrEmpty;
  894. for (const Mapping* m = getMappings(); m->vst2 != kSpeakerArrEmpty; ++m)
  895. if (m->matches (chans))
  896. return m->vst2;
  897. return kSpeakerArrUserDefined;
  898. }
  899. static void channelSetToVstArrangement (const AudioChannelSet& channels, VstSpeakerArrangement& result)
  900. {
  901. result.type = channelSetToVstArrangementType (channels);
  902. result.numChannels = channels.size();
  903. for (int i = 0; i < result.numChannels; ++i)
  904. {
  905. VstSpeakerProperties& speaker = result.speakers[i];
  906. zeromem (&speaker, sizeof (VstSpeakerProperties));
  907. speaker.type = getSpeakerType (channels.getTypeOfChannel (i));
  908. }
  909. }
  910. static const Mapping* getMappings() noexcept
  911. {
  912. static const Mapping mappings[] =
  913. {
  914. { kSpeakerArrMono, { centre, unknown } },
  915. { kSpeakerArrStereo, { left, right, unknown } },
  916. { kSpeakerArrStereoSurround, { leftSurround, rightSurround, unknown } },
  917. { kSpeakerArrStereoCenter, { leftCentre, rightCentre, unknown } },
  918. { kSpeakerArrStereoSide, { leftRearSurround, rightRearSurround, unknown } },
  919. { kSpeakerArrStereoCLfe, { centre, subbass, unknown } },
  920. { kSpeakerArr30Cine, { left, right, centre, unknown } },
  921. { kSpeakerArr30Music, { left, right, surround, unknown } },
  922. { kSpeakerArr31Cine, { left, right, centre, subbass, unknown } },
  923. { kSpeakerArr31Music, { left, right, subbass, surround, unknown } },
  924. { kSpeakerArr40Cine, { left, right, centre, surround, unknown } },
  925. { kSpeakerArr40Music, { left, right, leftSurround, rightSurround, unknown } },
  926. { kSpeakerArr41Cine, { left, right, centre, subbass, surround, unknown } },
  927. { kSpeakerArr41Music, { left, right, subbass, leftSurround, rightSurround, unknown } },
  928. { kSpeakerArr50, { left, right, centre, leftSurround, rightSurround, unknown } },
  929. { kSpeakerArr51, { left, right, centre, subbass, leftSurround, rightSurround, unknown } },
  930. { kSpeakerArr60Cine, { left, right, centre, leftSurround, rightSurround, surround, unknown } },
  931. { kSpeakerArr60Music, { left, right, leftSurround, rightSurround, leftRearSurround, rightRearSurround, unknown } },
  932. { kSpeakerArr61Cine, { left, right, centre, subbass, leftSurround, rightSurround, surround, unknown } },
  933. { kSpeakerArr61Music, { left, right, subbass, leftSurround, rightSurround, leftRearSurround, rightRearSurround, unknown } },
  934. { kSpeakerArr70Cine, { left, right, centre, leftSurround, rightSurround, topFrontLeft, topFrontRight, unknown } },
  935. { kSpeakerArr70Music, { left, right, centre, leftSurround, rightSurround, leftRearSurround, rightRearSurround, unknown } },
  936. { kSpeakerArr71Cine, { left, right, centre, subbass, leftSurround, rightSurround, topFrontLeft, topFrontRight, unknown } },
  937. { kSpeakerArr71Music, { left, right, centre, subbass, leftSurround, rightSurround, leftRearSurround, rightRearSurround, unknown } },
  938. { kSpeakerArr80Cine, { left, right, centre, leftSurround, rightSurround, topFrontLeft, topFrontRight, surround, unknown } },
  939. { kSpeakerArr80Music, { left, right, centre, leftSurround, rightSurround, surround, leftRearSurround, rightRearSurround, unknown } },
  940. { kSpeakerArr81Cine, { left, right, centre, subbass, leftSurround, rightSurround, topFrontLeft, topFrontRight, surround, unknown } },
  941. { kSpeakerArr81Music, { left, right, centre, subbass, leftSurround, rightSurround, surround, leftRearSurround, rightRearSurround, unknown } },
  942. { kSpeakerArr102, { left, right, centre, subbass, leftSurround, rightSurround, topFrontLeft, topFrontCentre, topFrontRight, topRearLeft, topRearRight, subbass2, unknown } },
  943. { kSpeakerArrEmpty, { unknown } }
  944. };
  945. return mappings;
  946. }
  947. static inline VstInt32 getSpeakerType (AudioChannelSet::ChannelType type) noexcept
  948. {
  949. switch (type)
  950. {
  951. case AudioChannelSet::left: return kSpeakerL;
  952. case AudioChannelSet::right: return kSpeakerR;
  953. case AudioChannelSet::centre: return kSpeakerC;
  954. case AudioChannelSet::subbass: return kSpeakerLfe;
  955. case AudioChannelSet::leftSurround: return kSpeakerLs;
  956. case AudioChannelSet::rightSurround: return kSpeakerRs;
  957. case AudioChannelSet::leftCentre: return kSpeakerLc;
  958. case AudioChannelSet::rightCentre: return kSpeakerRc;
  959. case AudioChannelSet::surround: return kSpeakerS;
  960. case AudioChannelSet::leftRearSurround: return kSpeakerSl;
  961. case AudioChannelSet::rightRearSurround: return kSpeakerSr;
  962. case AudioChannelSet::topMiddle: return kSpeakerTm;
  963. case AudioChannelSet::topFrontLeft: return kSpeakerTfl;
  964. case AudioChannelSet::topFrontCentre: return kSpeakerTfc;
  965. case AudioChannelSet::topFrontRight: return kSpeakerTfr;
  966. case AudioChannelSet::topRearLeft: return kSpeakerTrl;
  967. case AudioChannelSet::topRearCentre: return kSpeakerTrc;
  968. case AudioChannelSet::topRearRight: return kSpeakerTrr;
  969. case AudioChannelSet::subbass2: return kSpeakerLfe2;
  970. default: break;
  971. }
  972. return 0;
  973. }
  974. static inline AudioChannelSet::ChannelType getChannelType (VstInt32 type) noexcept
  975. {
  976. switch (type)
  977. {
  978. case kSpeakerL: return AudioChannelSet::left;
  979. case kSpeakerR: return AudioChannelSet::right;
  980. case kSpeakerC: return AudioChannelSet::centre;
  981. case kSpeakerLfe: return AudioChannelSet::subbass;
  982. case kSpeakerLs: return AudioChannelSet::leftSurround;
  983. case kSpeakerRs: return AudioChannelSet::rightSurround;
  984. case kSpeakerLc: return AudioChannelSet::leftCentre;
  985. case kSpeakerRc: return AudioChannelSet::rightCentre;
  986. case kSpeakerS: return AudioChannelSet::surround;
  987. case kSpeakerSl: return AudioChannelSet::leftRearSurround;
  988. case kSpeakerSr: return AudioChannelSet::rightRearSurround;
  989. case kSpeakerTm: return AudioChannelSet::topMiddle;
  990. case kSpeakerTfl: return AudioChannelSet::topFrontLeft;
  991. case kSpeakerTfc: return AudioChannelSet::topFrontCentre;
  992. case kSpeakerTfr: return AudioChannelSet::topFrontRight;
  993. case kSpeakerTrl: return AudioChannelSet::topRearLeft;
  994. case kSpeakerTrc: return AudioChannelSet::topRearCentre;
  995. case kSpeakerTrr: return AudioChannelSet::topRearRight;
  996. case kSpeakerLfe2: return AudioChannelSet::subbass2;
  997. default: break;
  998. }
  999. return AudioChannelSet::unknown;
  1000. }
  1001. };
  1002. //==============================================================================
  1003. VstInt32 getChunk (void** data, bool onlyStoreCurrentProgramData) override
  1004. {
  1005. if (filter == nullptr)
  1006. return 0;
  1007. chunkMemory.reset();
  1008. if (onlyStoreCurrentProgramData)
  1009. filter->getCurrentProgramStateInformation (chunkMemory);
  1010. else
  1011. filter->getStateInformation (chunkMemory);
  1012. *data = (void*) chunkMemory.getData();
  1013. // because the chunk is only needed temporarily by the host (or at least you'd
  1014. // hope so) we'll give it a while and then free it in the timer callback.
  1015. chunkMemoryTime = juce::Time::getApproximateMillisecondCounter();
  1016. return (VstInt32) chunkMemory.getSize();
  1017. }
  1018. VstInt32 setChunk (void* data, VstInt32 byteSize, bool onlyRestoreCurrentProgramData) override
  1019. {
  1020. if (filter != nullptr)
  1021. {
  1022. chunkMemory.reset();
  1023. chunkMemoryTime = 0;
  1024. if (byteSize > 0 && data != nullptr)
  1025. {
  1026. if (onlyRestoreCurrentProgramData)
  1027. filter->setCurrentProgramStateInformation (data, byteSize);
  1028. else
  1029. filter->setStateInformation (data, byteSize);
  1030. }
  1031. }
  1032. return 0;
  1033. }
  1034. void timerCallback() override
  1035. {
  1036. if (shouldDeleteEditor)
  1037. {
  1038. shouldDeleteEditor = false;
  1039. deleteEditor (true);
  1040. }
  1041. if (chunkMemoryTime > 0
  1042. && chunkMemoryTime < juce::Time::getApproximateMillisecondCounter() - 2000
  1043. && ! recursionCheck)
  1044. {
  1045. chunkMemory.reset();
  1046. chunkMemoryTime = 0;
  1047. }
  1048. #if JUCE_MAC
  1049. if (hostWindow != 0)
  1050. checkWindowVisibilityVST (hostWindow, editorComp, useNSView);
  1051. #endif
  1052. }
  1053. void doIdleCallback()
  1054. {
  1055. // (wavelab calls this on a separate thread and causes a deadlock)..
  1056. if (MessageManager::getInstance()->isThisTheMessageThread()
  1057. && ! recursionCheck)
  1058. {
  1059. ScopedValueSetter<bool> svs (recursionCheck, true, false);
  1060. JUCE_AUTORELEASEPOOL
  1061. {
  1062. Timer::callPendingTimersSynchronously();
  1063. for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
  1064. if (ComponentPeer* p = ComponentPeer::getPeer(i))
  1065. p->performAnyPendingRepaintsNow();
  1066. }
  1067. }
  1068. }
  1069. void createEditorComp()
  1070. {
  1071. if (hasShutdown || filter == nullptr)
  1072. return;
  1073. if (editorComp == nullptr)
  1074. {
  1075. if (AudioProcessorEditor* const ed = filter->createEditorIfNeeded())
  1076. {
  1077. cEffect.flags |= effFlagsHasEditor;
  1078. ed->setOpaque (true);
  1079. ed->setVisible (true);
  1080. editorComp = new EditorCompWrapper (*this, ed);
  1081. }
  1082. else
  1083. {
  1084. cEffect.flags &= ~effFlagsHasEditor;
  1085. }
  1086. }
  1087. shouldDeleteEditor = false;
  1088. }
  1089. void deleteEditor (bool canDeleteLaterIfModal)
  1090. {
  1091. JUCE_AUTORELEASEPOOL
  1092. {
  1093. PopupMenu::dismissAllActiveMenus();
  1094. jassert (! recursionCheck);
  1095. ScopedValueSetter<bool> svs (recursionCheck, true, false);
  1096. if (editorComp != nullptr)
  1097. {
  1098. if (Component* const modalComponent = Component::getCurrentlyModalComponent())
  1099. {
  1100. modalComponent->exitModalState (0);
  1101. if (canDeleteLaterIfModal)
  1102. {
  1103. shouldDeleteEditor = true;
  1104. return;
  1105. }
  1106. }
  1107. #if JUCE_MAC
  1108. if (hostWindow != 0)
  1109. {
  1110. detachComponentFromWindowRefVST (editorComp, hostWindow, useNSView);
  1111. hostWindow = 0;
  1112. }
  1113. #endif
  1114. filter->editorBeingDeleted (editorComp->getEditorComp());
  1115. editorComp = nullptr;
  1116. // there's some kind of component currently modal, but the host
  1117. // is trying to delete our plugin. You should try to avoid this happening..
  1118. jassert (Component::getCurrentlyModalComponent() == nullptr);
  1119. }
  1120. #if JUCE_LINUX
  1121. hostWindow = 0;
  1122. #endif
  1123. }
  1124. }
  1125. VstIntPtr dispatcher (VstInt32 opCode, VstInt32 index, VstIntPtr value, void* ptr, float opt) override
  1126. {
  1127. if (hasShutdown)
  1128. return 0;
  1129. if (opCode == effEditIdle)
  1130. {
  1131. doIdleCallback();
  1132. return 0;
  1133. }
  1134. else if (opCode == effEditOpen)
  1135. {
  1136. checkWhetherMessageThreadIsCorrect();
  1137. const MessageManagerLock mmLock;
  1138. jassert (! recursionCheck);
  1139. startTimer (1000 / 4); // performs misc housekeeping chores
  1140. deleteEditor (true);
  1141. createEditorComp();
  1142. if (editorComp != nullptr)
  1143. {
  1144. editorComp->setOpaque (true);
  1145. editorComp->setVisible (false);
  1146. #if JUCE_WINDOWS
  1147. editorComp->addToDesktop (0, ptr);
  1148. hostWindow = (HWND) ptr;
  1149. #elif JUCE_LINUX
  1150. editorComp->addToDesktop (0, ptr);
  1151. hostWindow = (Window) ptr;
  1152. Window editorWnd = (Window) editorComp->getWindowHandle();
  1153. XReparentWindow (display, editorWnd, hostWindow, 0, 0);
  1154. #else
  1155. hostWindow = attachComponentToWindowRefVST (editorComp, ptr, useNSView);
  1156. #endif
  1157. editorComp->setVisible (true);
  1158. return 1;
  1159. }
  1160. }
  1161. else if (opCode == effEditClose)
  1162. {
  1163. checkWhetherMessageThreadIsCorrect();
  1164. const MessageManagerLock mmLock;
  1165. deleteEditor (true);
  1166. return 0;
  1167. }
  1168. else if (opCode == effEditGetRect)
  1169. {
  1170. checkWhetherMessageThreadIsCorrect();
  1171. const MessageManagerLock mmLock;
  1172. createEditorComp();
  1173. if (editorComp != nullptr)
  1174. {
  1175. editorSize.left = 0;
  1176. editorSize.top = 0;
  1177. editorSize.right = (VstInt16) editorComp->getWidth();
  1178. editorSize.bottom = (VstInt16) editorComp->getHeight();
  1179. *((ERect**) ptr) = &editorSize;
  1180. return (VstIntPtr) (pointer_sized_int) &editorSize;
  1181. }
  1182. return 0;
  1183. }
  1184. return AudioEffectX::dispatcher (opCode, index, value, ptr, opt);
  1185. }
  1186. void resizeHostWindow (int newWidth, int newHeight)
  1187. {
  1188. if (editorComp != nullptr)
  1189. {
  1190. bool sizeWasSuccessful = false;
  1191. if (canHostDo (const_cast<char*> ("sizeWindow")))
  1192. {
  1193. isInSizeWindow = true;
  1194. sizeWasSuccessful = sizeWindow (newWidth, newHeight);
  1195. isInSizeWindow = false;
  1196. }
  1197. if (! sizeWasSuccessful)
  1198. {
  1199. // some hosts don't support the sizeWindow call, so do it manually..
  1200. #if JUCE_MAC
  1201. setNativeHostWindowSizeVST (hostWindow, editorComp, newWidth, newHeight, useNSView);
  1202. #elif JUCE_LINUX
  1203. // (Currently, all linux hosts support sizeWindow, so this should never need to happen)
  1204. editorComp->setSize (newWidth, newHeight);
  1205. #else
  1206. int dw = 0;
  1207. int dh = 0;
  1208. const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME);
  1209. HWND w = (HWND) editorComp->getWindowHandle();
  1210. while (w != 0)
  1211. {
  1212. HWND parent = getWindowParent (w);
  1213. if (parent == 0)
  1214. break;
  1215. TCHAR windowType [32] = { 0 };
  1216. GetClassName (parent, windowType, 31);
  1217. if (String (windowType).equalsIgnoreCase ("MDIClient"))
  1218. break;
  1219. RECT windowPos, parentPos;
  1220. GetWindowRect (w, &windowPos);
  1221. GetWindowRect (parent, &parentPos);
  1222. SetWindowPos (w, 0, 0, 0, newWidth + dw, newHeight + dh,
  1223. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  1224. dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left);
  1225. dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top);
  1226. w = parent;
  1227. if (dw == 2 * frameThickness)
  1228. break;
  1229. if (dw > 100 || dh > 100)
  1230. w = 0;
  1231. }
  1232. if (w != 0)
  1233. SetWindowPos (w, 0, 0, 0, newWidth + dw, newHeight + dh,
  1234. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  1235. #endif
  1236. }
  1237. if (ComponentPeer* peer = editorComp->getPeer())
  1238. {
  1239. peer->handleMovedOrResized();
  1240. peer->getComponent().repaint();
  1241. }
  1242. }
  1243. }
  1244. //==============================================================================
  1245. // A component to hold the AudioProcessorEditor, and cope with some housekeeping
  1246. // chores when it changes or repaints.
  1247. class EditorCompWrapper : public Component
  1248. {
  1249. public:
  1250. EditorCompWrapper (JuceVSTWrapper& w, AudioProcessorEditor* editor)
  1251. : wrapper (w)
  1252. {
  1253. setOpaque (true);
  1254. editor->setOpaque (true);
  1255. setBounds (editor->getBounds());
  1256. editor->setTopLeftPosition (0, 0);
  1257. addAndMakeVisible (editor);
  1258. #if JUCE_WINDOWS
  1259. if (! getHostType().isReceptor())
  1260. addMouseListener (this, true);
  1261. #endif
  1262. ignoreUnused (fakeMouseGenerator);
  1263. }
  1264. ~EditorCompWrapper()
  1265. {
  1266. deleteAllChildren(); // note that we can't use a ScopedPointer because the editor may
  1267. // have been transferred to another parent which takes over ownership.
  1268. }
  1269. void paint (Graphics&) override {}
  1270. #if JUCE_MAC
  1271. bool keyPressed (const KeyPress&) override
  1272. {
  1273. // If we have an unused keypress, move the key-focus to a host window
  1274. // and re-inject the event..
  1275. return forwardCurrentKeyEventToHostVST (this, wrapper.useNSView);
  1276. }
  1277. #endif
  1278. AudioProcessorEditor* getEditorComp() const
  1279. {
  1280. return dynamic_cast<AudioProcessorEditor*> (getChildComponent(0));
  1281. }
  1282. void resized() override
  1283. {
  1284. if (Component* const editorChildComp = getChildComponent(0))
  1285. editorChildComp->setBounds (getLocalBounds());
  1286. #if JUCE_MAC && ! JUCE_64BIT
  1287. if (! wrapper.useNSView)
  1288. updateEditorCompBoundsVST (this);
  1289. #endif
  1290. }
  1291. void childBoundsChanged (Component* child) override
  1292. {
  1293. if (! wrapper.isInSizeWindow)
  1294. {
  1295. child->setTopLeftPosition (0, 0);
  1296. const int cw = child->getWidth();
  1297. const int ch = child->getHeight();
  1298. #if JUCE_MAC
  1299. if (wrapper.useNSView)
  1300. setTopLeftPosition (0, getHeight() - ch);
  1301. #endif
  1302. wrapper.resizeHostWindow (cw, ch);
  1303. #if ! JUCE_LINUX // setSize() on linux causes renoise and energyxt to fail.
  1304. setSize (cw, ch);
  1305. #else
  1306. XResizeWindow (display, (Window) getWindowHandle(), (unsigned int) cw, (unsigned int) ch);
  1307. #endif
  1308. #if JUCE_MAC
  1309. wrapper.resizeHostWindow (cw, ch); // (doing this a second time seems to be necessary in tracktion)
  1310. #endif
  1311. }
  1312. }
  1313. #if JUCE_WINDOWS
  1314. void mouseDown (const MouseEvent&) override
  1315. {
  1316. broughtToFront();
  1317. }
  1318. void broughtToFront() override
  1319. {
  1320. // for hosts like nuendo, need to also pop the MDI container to the
  1321. // front when our comp is clicked on.
  1322. if (! isCurrentlyBlockedByAnotherModalComponent())
  1323. if (HWND parent = findMDIParentOf ((HWND) getWindowHandle()))
  1324. SetWindowPos (parent, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  1325. }
  1326. #endif
  1327. private:
  1328. //==============================================================================
  1329. JuceVSTWrapper& wrapper;
  1330. FakeMouseMoveGenerator fakeMouseGenerator;
  1331. #if JUCE_WINDOWS
  1332. WindowsHooks hooks;
  1333. #endif
  1334. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EditorCompWrapper)
  1335. };
  1336. //==============================================================================
  1337. private:
  1338. AudioProcessor* filter;
  1339. PluginBusUtilities busUtils;
  1340. juce::MemoryBlock chunkMemory;
  1341. juce::uint32 chunkMemoryTime;
  1342. ScopedPointer<EditorCompWrapper> editorComp;
  1343. ERect editorSize;
  1344. MidiBuffer midiEvents;
  1345. VSTMidiEventList outgoingEvents;
  1346. bool isProcessing, isBypassed, hasShutdown, isInSizeWindow, firstProcessCallback;
  1347. bool shouldDeleteEditor, useNSView;
  1348. VstTempBuffers<float> floatTempBuffers;
  1349. VstTempBuffers<double> doubleTempBuffers;
  1350. int maxNumInChannels, maxNumOutChannels;
  1351. #if JUCE_MAC
  1352. void* hostWindow;
  1353. #elif JUCE_LINUX
  1354. Window hostWindow;
  1355. #else
  1356. HWND hostWindow;
  1357. #endif
  1358. static inline VstInt32 convertHexVersionToDecimal (const unsigned int hexVersion)
  1359. {
  1360. #if JUCE_VST_RETURN_HEX_VERSION_NUMBER_DIRECTLY
  1361. return (VstInt32) hexVersion;
  1362. #else
  1363. return (VstInt32) (((hexVersion >> 24) & 0xff) * 1000
  1364. + ((hexVersion >> 16) & 0xff) * 100
  1365. + ((hexVersion >> 8) & 0xff) * 10
  1366. + (hexVersion & 0xff));
  1367. #endif
  1368. }
  1369. //==============================================================================
  1370. #if JUCE_WINDOWS
  1371. // Workarounds for hosts which attempt to open editor windows on a non-GUI thread.. (Grrrr...)
  1372. static void checkWhetherMessageThreadIsCorrect()
  1373. {
  1374. const PluginHostType host (getHostType());
  1375. if (host.isWavelab() || host.isCubaseBridged() || host.isPremiere())
  1376. {
  1377. if (! messageThreadIsDefinitelyCorrect)
  1378. {
  1379. MessageManager::getInstance()->setCurrentThreadAsMessageThread();
  1380. struct MessageThreadCallback : public CallbackMessage
  1381. {
  1382. MessageThreadCallback (bool& tr) : triggered (tr) {}
  1383. void messageCallback() override { triggered = true; }
  1384. bool& triggered;
  1385. };
  1386. (new MessageThreadCallback (messageThreadIsDefinitelyCorrect))->post();
  1387. }
  1388. }
  1389. }
  1390. #else
  1391. static void checkWhetherMessageThreadIsCorrect() {}
  1392. #endif
  1393. //==============================================================================
  1394. template <typename FloatType>
  1395. void deleteTempChannels (VstTempBuffers<FloatType>& tmpBuffers)
  1396. {
  1397. tmpBuffers.release();
  1398. if (filter != nullptr)
  1399. {
  1400. int numChannels = cEffect.numInputs + cEffect.numOutputs;
  1401. tmpBuffers.tempChannels.insertMultiple (0, nullptr, numChannels);
  1402. }
  1403. }
  1404. void deleteTempChannels()
  1405. {
  1406. deleteTempChannels (floatTempBuffers);
  1407. deleteTempChannels (doubleTempBuffers);
  1408. }
  1409. //==============================================================================
  1410. void findMaxTotalChannels (int& maxTotalIns, int& maxTotalOuts)
  1411. {
  1412. setMaxChannelsOnAllBuses (true);
  1413. setMaxChannelsOnAllBuses (false);
  1414. maxTotalIns = busUtils.findTotalNumChannels (true);
  1415. maxTotalOuts = busUtils.findTotalNumChannels (false);
  1416. }
  1417. void setMaxChannelsOnAllBuses (bool isInput)
  1418. {
  1419. const int n = busUtils.getBusCount (isInput);
  1420. for (int i = 0; i < n; ++i)
  1421. {
  1422. int ch = busUtils.findMaxNumberOfChannelsForBus (isInput, i);
  1423. if (ch == -1)
  1424. {
  1425. // VST-2 requires a maximum number of channels. If you are hitting this assertion
  1426. // then make sure that your setPreferredBusArrangement only accepts layouts
  1427. // up to a maximum number of channels
  1428. jassertfalse;
  1429. // do something sensible if the above assertions was hit
  1430. ch = busUtils.getDefaultLayoutForBus (isInput, i).size();
  1431. }
  1432. AudioChannelSet set =
  1433. busUtils.getDefaultLayoutForChannelNumAndBus (isInput, i, ch);
  1434. bool success = filter->setPreferredBusArrangement (isInput, i, set);
  1435. ignoreUnused (success);
  1436. // If you are hitting this assertsion then please file bug!
  1437. jassert ((! set.isDisabled()) && success);
  1438. }
  1439. }
  1440. //==============================================================================
  1441. void resetAuxChannelsToDefaultLayout (bool isInput) const
  1442. {
  1443. // set side-chain and aux channels to their default layout
  1444. for (int busIdx = 1; busIdx < busUtils.getBusCount (isInput); ++busIdx)
  1445. {
  1446. bool success = filter->setPreferredBusArrangement (isInput, busIdx, busUtils.getDefaultLayoutForBus (isInput, busIdx));
  1447. // VST 2 only supports a static channel layout on aux/sidechain channels
  1448. // You must at least support the default layout regardless of the layout of the main bus.
  1449. // If this is a problem for your plug-in, then consider using VST-3.
  1450. jassert (success);
  1451. ignoreUnused (success);
  1452. }
  1453. }
  1454. bool setBusArrangementFromTotalChannelNum (const int numInChannels, const int numOutChannels)
  1455. {
  1456. PluginBusUtilities::ScopedBusRestorer busRestorer (busUtils);
  1457. const int numIns = busUtils.getBusCount (true);
  1458. const int numOuts = busUtils.getBusCount (false);
  1459. const int n = numIns + numOuts;
  1460. HeapBlock<int> config (static_cast<size_t> (n), true);
  1461. HeapBlock<int> maxChans (static_cast<size_t> (n), true);
  1462. for (int i = 0; i < numIns; ++i)
  1463. maxChans[i] = busUtils.findMaxNumberOfChannelsForBus (true, i, numInChannels);
  1464. for (int i = 0; i < numOuts; ++i)
  1465. maxChans[i + numIns] = busUtils.findMaxNumberOfChannelsForBus (false, i, numOutChannels);
  1466. const int* inConfig = config.getData();
  1467. const int* outConfig = config.getData() + numIns;
  1468. #if JUCE_DEBUG
  1469. bool firstMatch = true;
  1470. AudioProcessor::AudioBusArrangement saveFirstMatch;
  1471. #endif
  1472. for (int i = 0; i < n;)
  1473. {
  1474. if (sumOfConfig (inConfig, numIns) == numInChannels
  1475. && sumOfConfig (outConfig, numOuts) == numOutChannels)
  1476. {
  1477. if (applyConfiguration (inConfig, outConfig))
  1478. {
  1479. #if JUCE_DEBUG
  1480. if (! firstMatch)
  1481. {
  1482. // Unfortunately, VST-2 requires that there is a unique plug-in bus
  1483. // arrangement for every x,y pair where x,y is the total number of
  1484. // input, output channels respectively.
  1485. jassertfalse;
  1486. busUtils.restoreBusArrangement (saveFirstMatch);
  1487. return true;
  1488. }
  1489. saveFirstMatch = filter->busArrangement;
  1490. firstMatch = false;
  1491. #else
  1492. busRestorer.release();
  1493. return true;
  1494. #endif
  1495. }
  1496. }
  1497. for (i = 0; i < n; ++i)
  1498. if ((config[i] = (config[i] + 1) % maxChans[i]) > 0)
  1499. break;
  1500. }
  1501. #if JUCE_DEBUG
  1502. if (! firstMatch)
  1503. {
  1504. busRestorer.release();
  1505. busUtils.restoreBusArrangement (saveFirstMatch);
  1506. return true;
  1507. }
  1508. #endif
  1509. return false;
  1510. }
  1511. bool setBusConfiguration (bool isInput, const int config[], const int n)
  1512. {
  1513. Array<AudioProcessor::AudioProcessorBus>& busArray = isInput ? filter->busArrangement.inputBuses
  1514. : filter->busArrangement.outputBuses;
  1515. int idx;
  1516. for (idx = 0; idx < n; ++idx)
  1517. {
  1518. if (busArray.getReference (idx).channels.size() == (config [idx] + 1))
  1519. continue;
  1520. AudioChannelSet set;
  1521. if ((set = busUtils.getDefaultLayoutForChannelNumAndBus (isInput, idx, config [idx] + 1)).isDisabled())
  1522. break;
  1523. if (! filter->setPreferredBusArrangement (isInput, idx, set))
  1524. break;
  1525. }
  1526. return (idx >= n);
  1527. }
  1528. bool configurationMatches (bool isInput, const int config[], const int n)
  1529. {
  1530. Array<AudioProcessor::AudioProcessorBus>& busArray = isInput ? filter->busArrangement.inputBuses
  1531. : filter->busArrangement.outputBuses;
  1532. int idx;
  1533. for (idx = 0; idx < n; ++idx)
  1534. if (busArray.getReference (idx).channels.size() != (config [idx] + 1))
  1535. break;
  1536. return (idx >= n);
  1537. }
  1538. bool applyConfiguration (const int inConfig[], const int outConfig[])
  1539. {
  1540. const int numIns = busUtils.getBusCount (true);
  1541. const int numOuts = busUtils.getBusCount (false);
  1542. if (! setBusConfiguration (true, inConfig, numIns))
  1543. return false;
  1544. if (! setBusConfiguration (false, outConfig, numOuts))
  1545. return false;
  1546. // re-check configuration
  1547. if (configurationMatches (true, inConfig, numIns) && configurationMatches (false, outConfig, numOuts))
  1548. return true;
  1549. return false;
  1550. }
  1551. //==============================================================================
  1552. bool pluginHasSidechainsOrAuxs() const { return (busUtils.getBusCount (true) > 1 || busUtils.getBusCount (false) > 1); }
  1553. static int sumOfConfig (const int config[], int num) noexcept
  1554. {
  1555. int retval = 0;
  1556. for (int i = 0; i < num; ++i)
  1557. retval += (config [i] + 1);
  1558. return retval;
  1559. }
  1560. //==============================================================================
  1561. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceVSTWrapper)
  1562. };
  1563. //==============================================================================
  1564. namespace
  1565. {
  1566. AEffect* pluginEntryPoint (audioMasterCallback audioMaster)
  1567. {
  1568. JUCE_AUTORELEASEPOOL
  1569. {
  1570. initialiseJuce_GUI();
  1571. try
  1572. {
  1573. if (audioMaster (0, audioMasterVersion, 0, 0, 0, 0) != 0)
  1574. {
  1575. #if JUCE_LINUX
  1576. MessageManagerLock mmLock;
  1577. #endif
  1578. AudioProcessor* const filter = createPluginFilterOfType (AudioProcessor::wrapperType_VST);
  1579. JuceVSTWrapper* const wrapper = new JuceVSTWrapper (audioMaster, filter);
  1580. return wrapper->getAeffect();
  1581. }
  1582. }
  1583. catch (...)
  1584. {}
  1585. }
  1586. return nullptr;
  1587. }
  1588. }
  1589. #if ! JUCE_WINDOWS
  1590. #define JUCE_EXPORTED_FUNCTION extern "C" __attribute__ ((visibility("default")))
  1591. #endif
  1592. //==============================================================================
  1593. // Mac startup code..
  1594. #if JUCE_MAC
  1595. JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster);
  1596. JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster)
  1597. {
  1598. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1599. initialiseMacVST();
  1600. return pluginEntryPoint (audioMaster);
  1601. }
  1602. JUCE_EXPORTED_FUNCTION AEffect* main_macho (audioMasterCallback audioMaster);
  1603. JUCE_EXPORTED_FUNCTION AEffect* main_macho (audioMasterCallback audioMaster)
  1604. {
  1605. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1606. initialiseMacVST();
  1607. return pluginEntryPoint (audioMaster);
  1608. }
  1609. //==============================================================================
  1610. // Linux startup code..
  1611. #elif JUCE_LINUX
  1612. JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster);
  1613. JUCE_EXPORTED_FUNCTION AEffect* VSTPluginMain (audioMasterCallback audioMaster)
  1614. {
  1615. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1616. SharedMessageThread::getInstance();
  1617. return pluginEntryPoint (audioMaster);
  1618. }
  1619. JUCE_EXPORTED_FUNCTION AEffect* main_plugin (audioMasterCallback audioMaster) asm ("main");
  1620. JUCE_EXPORTED_FUNCTION AEffect* main_plugin (audioMasterCallback audioMaster)
  1621. {
  1622. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1623. return VSTPluginMain (audioMaster);
  1624. }
  1625. // don't put initialiseJuce_GUI or shutdownJuce_GUI in these... it will crash!
  1626. __attribute__((constructor)) void myPluginInit() {}
  1627. __attribute__((destructor)) void myPluginFini() {}
  1628. //==============================================================================
  1629. // Win32 startup code..
  1630. #else
  1631. extern "C" __declspec (dllexport) AEffect* VSTPluginMain (audioMasterCallback audioMaster)
  1632. {
  1633. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1634. return pluginEntryPoint (audioMaster);
  1635. }
  1636. #ifndef JUCE_64BIT // (can't compile this on win64, but it's not needed anyway with VST2.4)
  1637. extern "C" __declspec (dllexport) int main (audioMasterCallback audioMaster)
  1638. {
  1639. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_VST);
  1640. return (int) pluginEntryPoint (audioMaster);
  1641. }
  1642. #endif
  1643. #endif
  1644. #endif