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.

1675 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_AAX && (JUCE_INCLUDED_AAX_IN_MM || defined (_WIN32) || defined (_WIN64))
  20. #include "../utility/juce_IncludeSystemHeaders.h"
  21. #include "../utility/juce_IncludeModuleHeaders.h"
  22. #include "../utility/juce_WindowsHooks.h"
  23. #include "../utility/juce_PluginBusUtilities.h"
  24. #ifdef __clang__
  25. #pragma clang diagnostic push
  26. #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
  27. #pragma clang diagnostic ignored "-Wsign-conversion"
  28. #endif
  29. #ifdef _MSC_VER
  30. #pragma warning (push)
  31. #pragma warning (disable : 4127 4512)
  32. #endif
  33. #include <AAX_Exports.cpp>
  34. #include <AAX_ICollection.h>
  35. #include <AAX_IComponentDescriptor.h>
  36. #include <AAX_IEffectDescriptor.h>
  37. #include <AAX_IPropertyMap.h>
  38. #include <AAX_CEffectParameters.h>
  39. #include <AAX_Errors.h>
  40. #include <AAX_CBinaryTaperDelegate.h>
  41. #include <AAX_CBinaryDisplayDelegate.h>
  42. #include <AAX_CLinearTaperDelegate.h>
  43. #include <AAX_CNumberDisplayDelegate.h>
  44. #include <AAX_CEffectGUI.h>
  45. #include <AAX_IViewContainer.h>
  46. #include <AAX_ITransport.h>
  47. #include <AAX_IMIDINode.h>
  48. #include <AAX_UtilsNative.h>
  49. #include <AAX_Enums.h>
  50. #ifdef _MSC_VER
  51. #pragma warning (pop)
  52. #endif
  53. #ifdef __clang__
  54. #pragma clang diagnostic pop
  55. #endif
  56. #if JUCE_WINDOWS
  57. #ifndef JucePlugin_AAXLibs_path
  58. #error "You need to define the JucePlugin_AAXLibs_path macro. (This is best done via the Projucer)"
  59. #endif
  60. #if JUCE_64BIT
  61. #define JUCE_AAX_LIB "AAXLibrary_x64"
  62. #else
  63. #define JUCE_AAX_LIB "AAXLibrary"
  64. #endif
  65. #if JUCE_DEBUG
  66. #define JUCE_AAX_LIB_PATH "\\Debug\\"
  67. #define JUCE_AAX_LIB_SUFFIX "_D"
  68. #else
  69. #define JUCE_AAX_LIB_PATH "\\Release\\"
  70. #define JUCE_AAX_LIB_SUFFIX ""
  71. #endif
  72. #pragma comment(lib, JucePlugin_AAXLibs_path JUCE_AAX_LIB_PATH JUCE_AAX_LIB JUCE_AAX_LIB_SUFFIX ".lib")
  73. #endif
  74. #undef check
  75. const int32_t juceChunkType = 'juce';
  76. const int maxAAXChannels = 8;
  77. JUCE_DEFINE_WRAPPER_TYPE (wrapperType_AAX);
  78. //==============================================================================
  79. struct AAXClasses
  80. {
  81. static int32 getAAXParamHash (AAX_CParamID paramID) noexcept
  82. {
  83. int32 result = 0;
  84. while (*paramID != 0)
  85. result = (31 * result) + (*paramID++);
  86. return result;
  87. }
  88. static void check (AAX_Result result)
  89. {
  90. jassert (result == AAX_SUCCESS); ignoreUnused (result);
  91. }
  92. static bool isBypassParam (AAX_CParamID paramID) noexcept
  93. {
  94. return AAX::IsParameterIDEqual (paramID, cDefaultMasterBypassID) != 0;
  95. }
  96. // maps a channel index of an AAX format to an index of a juce format
  97. struct AAXChannelStreamOrder
  98. {
  99. AAX_EStemFormat aaxStemFormat;
  100. AudioChannelSet::ChannelType speakerOrder[8];
  101. };
  102. static AAXChannelStreamOrder aaxChannelOrder[];
  103. static AAX_EStemFormat aaxFormats[AAX_eStemFormatNum];
  104. static AAX_EStemFormat getFormatForAudioChannelSet (const AudioChannelSet& set, bool ignoreLayout) noexcept
  105. {
  106. // if the plug-in ignores layout, it is ok to convert between formats only by their numchannnels
  107. if (ignoreLayout)
  108. {
  109. switch (set.size())
  110. {
  111. case 0: return AAX_eStemFormat_None;
  112. case 1: return AAX_eStemFormat_Mono;
  113. case 2: return AAX_eStemFormat_Stereo;
  114. case 3: return AAX_eStemFormat_LCR;
  115. case 4: return AAX_eStemFormat_Quad;
  116. case 5: return AAX_eStemFormat_5_0;
  117. case 6: return AAX_eStemFormat_5_1;
  118. case 7: return AAX_eStemFormat_7_0_DTS;
  119. case 8: return AAX_eStemFormat_7_1_DTS;
  120. default:
  121. break;
  122. }
  123. return AAX_eStemFormat_INT32_MAX;
  124. }
  125. if (set == AudioChannelSet::disabled()) return AAX_eStemFormat_None;
  126. if (set == AudioChannelSet::mono()) return AAX_eStemFormat_Mono;
  127. if (set == AudioChannelSet::stereo()) return AAX_eStemFormat_Stereo;
  128. if (set == AudioChannelSet::createLCR()) return AAX_eStemFormat_LCR;
  129. if (set == AudioChannelSet::createLCRS()) return AAX_eStemFormat_LCRS;
  130. if (set == AudioChannelSet::quadraphonic()) return AAX_eStemFormat_Quad;
  131. if (set == AudioChannelSet::create5point0()) return AAX_eStemFormat_5_0;
  132. if (set == AudioChannelSet::create5point1()) return AAX_eStemFormat_5_1;
  133. if (set == AudioChannelSet::create6point0()) return AAX_eStemFormat_6_0;
  134. if (set == AudioChannelSet::create6point1()) return AAX_eStemFormat_6_1;
  135. if (set == AudioChannelSet::create7point0()) return AAX_eStemFormat_7_0_DTS;
  136. if (set == AudioChannelSet::create7point1()) return AAX_eStemFormat_7_1_DTS;
  137. if (set == AudioChannelSet::createFront7point0()) return AAX_eStemFormat_7_0_SDDS;
  138. if (set == AudioChannelSet::createFront7point1()) return AAX_eStemFormat_7_1_SDDS;
  139. return AAX_eStemFormat_INT32_MAX;
  140. }
  141. static AudioChannelSet channelSetFromStemFormat (AAX_EStemFormat format, bool ignoreLayout) noexcept
  142. {
  143. if (! ignoreLayout)
  144. {
  145. switch (format)
  146. {
  147. case AAX_eStemFormat_None: return AudioChannelSet::disabled();
  148. case AAX_eStemFormat_Mono: return AudioChannelSet::mono();
  149. case AAX_eStemFormat_Stereo: return AudioChannelSet::stereo();
  150. case AAX_eStemFormat_LCR: return AudioChannelSet::createLCR();
  151. case AAX_eStemFormat_LCRS: return AudioChannelSet::createLCRS();
  152. case AAX_eStemFormat_Quad: return AudioChannelSet::quadraphonic();
  153. case AAX_eStemFormat_5_0: return AudioChannelSet::create5point0();
  154. case AAX_eStemFormat_5_1: return AudioChannelSet::create5point1();
  155. case AAX_eStemFormat_6_0: return AudioChannelSet::create6point0();
  156. case AAX_eStemFormat_6_1: return AudioChannelSet::create6point1();
  157. case AAX_eStemFormat_7_0_SDDS: return AudioChannelSet::createFront7point0();
  158. case AAX_eStemFormat_7_0_DTS: return AudioChannelSet::create7point0();
  159. case AAX_eStemFormat_7_1_SDDS: return AudioChannelSet::createFront7point1();
  160. case AAX_eStemFormat_7_1_DTS: return AudioChannelSet::create7point1();
  161. default:
  162. break;
  163. }
  164. return AudioChannelSet::disabled();
  165. }
  166. return AudioChannelSet::discreteChannels (jmax (0, static_cast<int> (AAX_STEM_FORMAT_CHANNEL_COUNT (format))));
  167. }
  168. static const char* getSpeakerArrangementString (AAX_EStemFormat format) noexcept
  169. {
  170. switch (format)
  171. {
  172. case AAX_eStemFormat_Mono: return "M";
  173. case AAX_eStemFormat_Stereo: return "L R";
  174. case AAX_eStemFormat_LCR: return "L C R";
  175. case AAX_eStemFormat_LCRS: return "L C R S";
  176. case AAX_eStemFormat_Quad: return "L R Ls Rs";
  177. case AAX_eStemFormat_5_0: return "L C R Ls Rs";
  178. case AAX_eStemFormat_5_1: return "L C R Ls Rs LFE";
  179. case AAX_eStemFormat_6_0: return "L C R Ls Cs Rs";
  180. case AAX_eStemFormat_6_1: return "L C R Ls Cs Rs LFE";
  181. case AAX_eStemFormat_7_0_SDDS: return "L Lc C Rc R Ls Rs";
  182. case AAX_eStemFormat_7_1_SDDS: return "L Lc C Rc R Ls Rs LFE";
  183. case AAX_eStemFormat_7_0_DTS: return "L C R Lss Rss Lsr Rsr";
  184. case AAX_eStemFormat_7_1_DTS: return "L C R Lss Rss Lsr Rsr LFE";
  185. default: break;
  186. }
  187. return nullptr;
  188. }
  189. static Colour getColourFromHighlightEnum (AAX_EHighlightColor colour) noexcept
  190. {
  191. switch (colour)
  192. {
  193. case AAX_eHighlightColor_Red: return Colours::red;
  194. case AAX_eHighlightColor_Blue: return Colours::blue;
  195. case AAX_eHighlightColor_Green: return Colours::green;
  196. case AAX_eHighlightColor_Yellow: return Colours::yellow;
  197. default: jassertfalse; break;
  198. }
  199. return Colours::black;
  200. }
  201. static int juceChannelIndexToAax (int juceIndex, const AudioChannelSet& channelSet)
  202. {
  203. AAX_EStemFormat currentLayout = getFormatForAudioChannelSet (channelSet, false);
  204. int layoutIndex;
  205. for (layoutIndex = 0; aaxChannelOrder[layoutIndex].aaxStemFormat != currentLayout; ++layoutIndex)
  206. if (aaxChannelOrder[layoutIndex].aaxStemFormat == 0) return juceIndex;
  207. const AAXChannelStreamOrder& channelOrder = aaxChannelOrder[layoutIndex];
  208. const AudioChannelSet::ChannelType channelType = channelSet.getTypeOfChannel (static_cast<int> (juceIndex));
  209. for (int i = 0; i < 8 && channelOrder.speakerOrder[i] != 0; ++i)
  210. if (channelOrder.speakerOrder[i] == channelType)
  211. return i;
  212. return juceIndex;
  213. }
  214. //==============================================================================
  215. class JuceAAX_Processor;
  216. struct PluginInstanceInfo
  217. {
  218. PluginInstanceInfo (JuceAAX_Processor& p) : parameters (p) {}
  219. JuceAAX_Processor& parameters;
  220. JUCE_DECLARE_NON_COPYABLE (PluginInstanceInfo)
  221. };
  222. //==============================================================================
  223. struct JUCEAlgorithmContext
  224. {
  225. float** inputChannels;
  226. float** outputChannels;
  227. int32_t* bufferSize;
  228. int32_t* bypass;
  229. #if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
  230. AAX_IMIDINode* midiNodeIn;
  231. #endif
  232. #if JucePlugin_ProducesMidiOutput || JucePlugin_IsSynth || JucePlugin_IsMidiEffect
  233. AAX_IMIDINode* midiNodeOut;
  234. #endif
  235. PluginInstanceInfo* pluginInstance;
  236. int32_t* isPrepared;
  237. int32_t* sideChainBuffers;
  238. };
  239. struct JUCEAlgorithmIDs
  240. {
  241. enum
  242. {
  243. inputChannels = AAX_FIELD_INDEX (JUCEAlgorithmContext, inputChannels),
  244. outputChannels = AAX_FIELD_INDEX (JUCEAlgorithmContext, outputChannels),
  245. bufferSize = AAX_FIELD_INDEX (JUCEAlgorithmContext, bufferSize),
  246. bypass = AAX_FIELD_INDEX (JUCEAlgorithmContext, bypass),
  247. #if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
  248. midiNodeIn = AAX_FIELD_INDEX (JUCEAlgorithmContext, midiNodeIn),
  249. #endif
  250. #if JucePlugin_ProducesMidiOutput || JucePlugin_IsSynth || JucePlugin_IsMidiEffect
  251. midiNodeOut = AAX_FIELD_INDEX (JUCEAlgorithmContext, midiNodeOut),
  252. #endif
  253. pluginInstance = AAX_FIELD_INDEX (JUCEAlgorithmContext, pluginInstance),
  254. preparedFlag = AAX_FIELD_INDEX (JUCEAlgorithmContext, isPrepared),
  255. sideChainBuffers = AAX_FIELD_INDEX (JUCEAlgorithmContext, sideChainBuffers)
  256. };
  257. };
  258. #if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
  259. static AAX_IMIDINode* getMidiNodeIn (const JUCEAlgorithmContext& c) noexcept { return c.midiNodeIn; }
  260. #else
  261. static AAX_IMIDINode* getMidiNodeIn (const JUCEAlgorithmContext&) noexcept { return nullptr; }
  262. #endif
  263. #if JucePlugin_ProducesMidiOutput || JucePlugin_IsSynth || JucePlugin_IsMidiEffect
  264. AAX_IMIDINode* midiNodeOut;
  265. static AAX_IMIDINode* getMidiNodeOut (const JUCEAlgorithmContext& c) noexcept { return c.midiNodeOut; }
  266. #else
  267. static AAX_IMIDINode* getMidiNodeOut (const JUCEAlgorithmContext&) noexcept { return nullptr; }
  268. #endif
  269. //==============================================================================
  270. class JuceAAX_GUI : public AAX_CEffectGUI
  271. {
  272. public:
  273. JuceAAX_GUI() {}
  274. ~JuceAAX_GUI() { DeleteViewContainer(); }
  275. static AAX_IEffectGUI* AAX_CALLBACK Create() { return new JuceAAX_GUI(); }
  276. void CreateViewContents() override
  277. {
  278. if (component == nullptr)
  279. {
  280. if (JuceAAX_Processor* params = dynamic_cast<JuceAAX_Processor*> (GetEffectParameters()))
  281. component = new ContentWrapperComponent (*this, params->getPluginInstance());
  282. else
  283. jassertfalse;
  284. }
  285. }
  286. void CreateViewContainer() override
  287. {
  288. CreateViewContents();
  289. if (void* nativeViewToAttachTo = GetViewContainerPtr())
  290. {
  291. #if JUCE_MAC
  292. if (GetViewContainerType() == AAX_eViewContainer_Type_NSView)
  293. #else
  294. if (GetViewContainerType() == AAX_eViewContainer_Type_HWND)
  295. #endif
  296. {
  297. component->setVisible (true);
  298. component->addToDesktop (0, nativeViewToAttachTo);
  299. }
  300. }
  301. }
  302. void DeleteViewContainer() override
  303. {
  304. if (component != nullptr)
  305. {
  306. JUCE_AUTORELEASEPOOL
  307. {
  308. component->removeFromDesktop();
  309. component = nullptr;
  310. }
  311. }
  312. }
  313. AAX_Result GetViewSize (AAX_Point* viewSize) const override
  314. {
  315. if (component != nullptr)
  316. {
  317. viewSize->horz = (float) component->getWidth();
  318. viewSize->vert = (float) component->getHeight();
  319. return AAX_SUCCESS;
  320. }
  321. return AAX_ERROR_NULL_OBJECT;
  322. }
  323. AAX_Result ParameterUpdated (AAX_CParamID) override
  324. {
  325. return AAX_SUCCESS;
  326. }
  327. AAX_Result SetControlHighlightInfo (AAX_CParamID paramID, AAX_CBoolean isHighlighted, AAX_EHighlightColor colour) override
  328. {
  329. if (component != nullptr && component->pluginEditor != nullptr)
  330. {
  331. if (! isBypassParam (paramID))
  332. {
  333. AudioProcessorEditor::ParameterControlHighlightInfo info;
  334. info.parameterIndex = getParamIndexFromID (paramID);
  335. info.isHighlighted = (isHighlighted != 0);
  336. info.suggestedColour = getColourFromHighlightEnum (colour);
  337. component->pluginEditor->setControlHighlight (info);
  338. }
  339. return AAX_SUCCESS;
  340. }
  341. return AAX_ERROR_NULL_OBJECT;
  342. }
  343. private:
  344. //==============================================================================
  345. inline int getParamIndexFromID (AAX_CParamID paramID) const noexcept
  346. {
  347. if (const JuceAAX_Processor* params = dynamic_cast<const JuceAAX_Processor*> (GetEffectParameters()))
  348. return params->getParamIndexFromID (paramID);
  349. return -1;
  350. }
  351. inline AAX_CParamID getAAXParamIDFromJuceIndex (int index) const noexcept
  352. {
  353. if (const JuceAAX_Processor* params = dynamic_cast<const JuceAAX_Processor*> (GetEffectParameters()))
  354. return params->getAAXParamIDFromJuceIndex (index);
  355. return nullptr;
  356. }
  357. //==============================================================================
  358. struct ContentWrapperComponent : public Component
  359. {
  360. ContentWrapperComponent (JuceAAX_GUI& gui, AudioProcessor& plugin)
  361. : owner (gui)
  362. {
  363. setOpaque (true);
  364. setBroughtToFrontOnMouseClick (true);
  365. addAndMakeVisible (pluginEditor = plugin.createEditorIfNeeded());
  366. if (pluginEditor != nullptr)
  367. {
  368. setBounds (pluginEditor->getLocalBounds());
  369. pluginEditor->addMouseListener (this, true);
  370. }
  371. }
  372. ~ContentWrapperComponent()
  373. {
  374. if (pluginEditor != nullptr)
  375. {
  376. PopupMenu::dismissAllActiveMenus();
  377. pluginEditor->removeMouseListener (this);
  378. pluginEditor->processor.editorBeingDeleted (pluginEditor);
  379. }
  380. }
  381. void paint (Graphics& g) override
  382. {
  383. g.fillAll (Colours::black);
  384. }
  385. template <typename MethodType>
  386. void callMouseMethod (const MouseEvent& e, MethodType method)
  387. {
  388. if (AAX_IViewContainer* vc = owner.GetViewContainer())
  389. {
  390. const int parameterIndex = pluginEditor->getControlParameterIndex (*e.eventComponent);
  391. if (AAX_CParamID aaxParamID = owner.getAAXParamIDFromJuceIndex (parameterIndex))
  392. {
  393. uint32_t mods = 0;
  394. vc->GetModifiers (&mods);
  395. (vc->*method) (aaxParamID, mods);
  396. }
  397. }
  398. }
  399. void mouseDown (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseDown); }
  400. void mouseUp (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseUp); }
  401. void mouseDrag (const MouseEvent& e) override { callMouseMethod (e, &AAX_IViewContainer::HandleParameterMouseDrag); }
  402. void childBoundsChanged (Component*) override
  403. {
  404. if (pluginEditor != nullptr)
  405. {
  406. const int w = pluginEditor->getWidth();
  407. const int h = pluginEditor->getHeight();
  408. setSize (w, h);
  409. AAX_Point newSize ((float) h, (float) w);
  410. owner.GetViewContainer()->SetViewSize (newSize);
  411. }
  412. }
  413. ScopedPointer<AudioProcessorEditor> pluginEditor;
  414. JuceAAX_GUI& owner;
  415. #if JUCE_WINDOWS
  416. WindowsHooks hooks;
  417. #endif
  418. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentWrapperComponent)
  419. };
  420. ScopedPointer<ContentWrapperComponent> component;
  421. ScopedJuceInitialiser_GUI libraryInitialiser;
  422. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceAAX_GUI)
  423. };
  424. //==============================================================================
  425. class JuceAAX_Processor : public AAX_CEffectParameters,
  426. public juce::AudioPlayHead,
  427. public AudioProcessorListener
  428. {
  429. public:
  430. JuceAAX_Processor() : pluginInstance (createPluginFilterOfType (AudioProcessor::wrapperType_AAX)),
  431. isPrepared (false), busUtils (*pluginInstance, false, maxAAXChannels),
  432. sampleRate (0), lastBufferSize (1024), maxBufferSize (1024),
  433. hasSidechain (false)
  434. {
  435. pluginInstance->setPlayHead (this);
  436. pluginInstance->addListener (this);
  437. busUtils.init();
  438. AAX_CEffectParameters::GetNumberOfChunks (&juceChunkIndex);
  439. }
  440. static AAX_CEffectParameters* AAX_CALLBACK Create()
  441. {
  442. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_AAX);
  443. return new JuceAAX_Processor();
  444. }
  445. AAX_Result Uninitialize() override
  446. {
  447. if (isPrepared && pluginInstance != nullptr)
  448. {
  449. isPrepared = false;
  450. pluginInstance->releaseResources();
  451. }
  452. return AAX_CEffectParameters::Uninitialize();
  453. }
  454. AAX_Result EffectInit() override
  455. {
  456. AAX_Result err;
  457. check (Controller()->GetSampleRate (&sampleRate));
  458. if ((err = preparePlugin()) != AAX_SUCCESS)
  459. return err;
  460. addBypassParameter();
  461. addAudioProcessorParameters();
  462. return AAX_SUCCESS;
  463. }
  464. AAX_Result GetNumberOfChunks (int32_t* numChunks) const override
  465. {
  466. // The juceChunk is the last chunk.
  467. *numChunks = juceChunkIndex + 1;
  468. return AAX_SUCCESS;
  469. }
  470. AAX_Result GetChunkIDFromIndex (int32_t index, AAX_CTypeID* chunkID) const override
  471. {
  472. if (index != juceChunkIndex)
  473. return AAX_CEffectParameters::GetChunkIDFromIndex (index, chunkID);
  474. *chunkID = juceChunkType;
  475. return AAX_SUCCESS;
  476. }
  477. juce::MemoryBlock& getTemporaryChunkMemory() const
  478. {
  479. ScopedLock sl (perThreadDataLock);
  480. const Thread::ThreadID currentThread = Thread::getCurrentThreadId();
  481. if (ChunkMemoryBlock::Ptr m = perThreadFilterData [currentThread])
  482. return m->data;
  483. ChunkMemoryBlock::Ptr m (new ChunkMemoryBlock());
  484. perThreadFilterData.set (currentThread, m);
  485. return m->data;
  486. }
  487. AAX_Result GetChunkSize (AAX_CTypeID chunkID, uint32_t* oSize) const override
  488. {
  489. if (chunkID != juceChunkType)
  490. return AAX_CEffectParameters::GetChunkSize (chunkID, oSize);
  491. juce::MemoryBlock& tempFilterData = getTemporaryChunkMemory();
  492. tempFilterData.reset();
  493. pluginInstance->getStateInformation (tempFilterData);
  494. *oSize = (uint32_t) tempFilterData.getSize();
  495. return AAX_SUCCESS;
  496. }
  497. AAX_Result GetChunk (AAX_CTypeID chunkID, AAX_SPlugInChunk* oChunk) const override
  498. {
  499. if (chunkID != juceChunkType)
  500. return AAX_CEffectParameters::GetChunk (chunkID, oChunk);
  501. juce::MemoryBlock& tempFilterData = getTemporaryChunkMemory();
  502. if (tempFilterData.getSize() == 0)
  503. return 20700 /*AAX_ERROR_PLUGIN_API_INVALID_THREAD*/;
  504. oChunk->fSize = (int32_t) tempFilterData.getSize();
  505. tempFilterData.copyTo (oChunk->fData, 0, tempFilterData.getSize());
  506. tempFilterData.reset();
  507. return AAX_SUCCESS;
  508. }
  509. AAX_Result SetChunk (AAX_CTypeID chunkID, const AAX_SPlugInChunk* chunk) override
  510. {
  511. if (chunkID != juceChunkType)
  512. return AAX_CEffectParameters::SetChunk (chunkID, chunk);
  513. pluginInstance->setStateInformation ((void*) chunk->fData, chunk->fSize);
  514. // Notify Pro Tools that the parameters were updated.
  515. // Without it a bug happens in these circumstances:
  516. // * A preset is saved with the RTAS version of the plugin (".tfx" preset format).
  517. // * The preset is loaded in PT 10 using the AAX version.
  518. // * The session is then saved, and closed.
  519. // * The saved session is loaded, but acting as if the preset was never loaded.
  520. const int numParameters = pluginInstance->getNumParameters();
  521. for (int i = 0; i < numParameters; ++i)
  522. SetParameterNormalizedValue (getAAXParamIDFromJuceIndex (i), (double) pluginInstance->getParameter(i));
  523. return AAX_SUCCESS;
  524. }
  525. AAX_Result ResetFieldData (AAX_CFieldIndex fieldIndex, void* data, uint32_t dataSize) const override
  526. {
  527. switch (fieldIndex)
  528. {
  529. case JUCEAlgorithmIDs::pluginInstance:
  530. {
  531. const size_t numObjects = dataSize / sizeof (PluginInstanceInfo);
  532. PluginInstanceInfo* const objects = static_cast<PluginInstanceInfo*> (data);
  533. jassert (numObjects == 1); // not sure how to handle more than one..
  534. for (size_t i = 0; i < numObjects; ++i)
  535. new (objects + i) PluginInstanceInfo (const_cast<JuceAAX_Processor&> (*this));
  536. break;
  537. }
  538. case JUCEAlgorithmIDs::preparedFlag:
  539. {
  540. const_cast<JuceAAX_Processor*>(this)->preparePlugin();
  541. const size_t numObjects = dataSize / sizeof (uint32_t);
  542. uint32_t* const objects = static_cast<uint32_t*> (data);
  543. for (size_t i = 0; i < numObjects; ++i)
  544. new (objects + i) uint32_t (1);
  545. break;
  546. }
  547. }
  548. return AAX_SUCCESS;
  549. }
  550. AAX_Result UpdateParameterNormalizedValue (AAX_CParamID paramID, double value, AAX_EUpdateSource source) override
  551. {
  552. AAX_Result result = AAX_CEffectParameters::UpdateParameterNormalizedValue (paramID, value, source);
  553. if (! isBypassParam (paramID))
  554. pluginInstance->setParameter (getParamIndexFromID (paramID), (float) value);
  555. return result;
  556. }
  557. AAX_Result GetParameterValueFromString (AAX_CParamID paramID, double* result, const AAX_IString& text) const override
  558. {
  559. if (isBypassParam (paramID))
  560. {
  561. *result = (text.Get()[0] == 'B') ? 1 : 0;
  562. return AAX_SUCCESS;
  563. }
  564. if (AudioProcessorParameter* param = pluginInstance->getParameters() [getParamIndexFromID (paramID)])
  565. {
  566. *result = param->getValueForText (text.Get());
  567. return AAX_SUCCESS;
  568. }
  569. return AAX_CEffectParameters::GetParameterValueFromString (paramID, result, text);
  570. }
  571. AAX_Result GetParameterStringFromValue (AAX_CParamID paramID, double value, AAX_IString* result, int32_t maxLen) const override
  572. {
  573. if (isBypassParam (paramID))
  574. {
  575. result->Set (value == 0 ? "Off" : (maxLen >= 8 ? "Bypassed" : "Byp"));
  576. }
  577. else
  578. {
  579. const int paramIndex = getParamIndexFromID (paramID);
  580. juce::String text;
  581. if (AudioProcessorParameter* param = pluginInstance->getParameters() [paramIndex])
  582. text = param->getText ((float) value, maxLen);
  583. else
  584. text = pluginInstance->getParameterText (paramIndex, maxLen);
  585. result->Set (text.toRawUTF8());
  586. }
  587. return AAX_SUCCESS;
  588. }
  589. AAX_Result GetParameterNumberofSteps (AAX_CParamID paramID, int32_t* result) const
  590. {
  591. if (isBypassParam (paramID))
  592. *result = 2;
  593. else
  594. *result = pluginInstance->getParameterNumSteps (getParamIndexFromID (paramID));
  595. return AAX_SUCCESS;
  596. }
  597. AAX_Result GetParameterNormalizedValue (AAX_CParamID paramID, double* result) const override
  598. {
  599. if (isBypassParam (paramID))
  600. return AAX_CEffectParameters::GetParameterNormalizedValue (paramID, result);
  601. *result = pluginInstance->getParameter (getParamIndexFromID (paramID));
  602. return AAX_SUCCESS;
  603. }
  604. AAX_Result SetParameterNormalizedValue (AAX_CParamID paramID, double newValue) override
  605. {
  606. if (isBypassParam (paramID))
  607. return AAX_CEffectParameters::SetParameterNormalizedValue (paramID, newValue);
  608. if (AAX_IParameter* p = const_cast<AAX_IParameter*> (mParameterManager.GetParameterByID (paramID)))
  609. p->SetValueWithFloat ((float) newValue);
  610. pluginInstance->setParameter (getParamIndexFromID (paramID), (float) newValue);
  611. return AAX_SUCCESS;
  612. }
  613. AAX_Result SetParameterNormalizedRelative (AAX_CParamID paramID, double newDeltaValue) override
  614. {
  615. if (isBypassParam (paramID))
  616. return AAX_CEffectParameters::SetParameterNormalizedRelative (paramID, newDeltaValue);
  617. const int paramIndex = getParamIndexFromID (paramID);
  618. const float newValue = pluginInstance->getParameter (paramIndex) + (float) newDeltaValue;
  619. pluginInstance->setParameter (paramIndex, jlimit (0.0f, 1.0f, newValue));
  620. if (AAX_IParameter* p = const_cast<AAX_IParameter*> (mParameterManager.GetParameterByID (paramID)))
  621. p->SetValueWithFloat (newValue);
  622. return AAX_SUCCESS;
  623. }
  624. AAX_Result GetParameterNameOfLength (AAX_CParamID paramID, AAX_IString* result, int32_t maxLen) const override
  625. {
  626. if (isBypassParam (paramID))
  627. result->Set (maxLen >= 13 ? "Master Bypass"
  628. : (maxLen >= 8 ? "Mast Byp"
  629. : (maxLen >= 6 ? "MstByp" : "MByp")));
  630. else
  631. result->Set (pluginInstance->getParameterName (getParamIndexFromID (paramID), maxLen).toRawUTF8());
  632. return AAX_SUCCESS;
  633. }
  634. AAX_Result GetParameterName (AAX_CParamID paramID, AAX_IString* result) const override
  635. {
  636. if (isBypassParam (paramID))
  637. result->Set ("Master Bypass");
  638. else
  639. result->Set (pluginInstance->getParameterName (getParamIndexFromID (paramID), 31).toRawUTF8());
  640. return AAX_SUCCESS;
  641. }
  642. AAX_Result GetParameterDefaultNormalizedValue (AAX_CParamID paramID, double* result) const override
  643. {
  644. if (! isBypassParam (paramID))
  645. {
  646. *result = (double) pluginInstance->getParameterDefaultValue (getParamIndexFromID (paramID));
  647. jassert (*result >= 0 && *result <= 1.0f);
  648. }
  649. return AAX_SUCCESS;
  650. }
  651. AudioProcessor& getPluginInstance() const noexcept { return *pluginInstance; }
  652. bool getCurrentPosition (juce::AudioPlayHead::CurrentPositionInfo& info) override
  653. {
  654. const AAX_ITransport& transport = *Transport();
  655. info.bpm = 0.0;
  656. check (transport.GetCurrentTempo (&info.bpm));
  657. int32_t num = 4, den = 4;
  658. transport.GetCurrentMeter (&num, &den);
  659. info.timeSigNumerator = (int) num;
  660. info.timeSigDenominator = (int) den;
  661. info.timeInSamples = 0;
  662. if (transport.IsTransportPlaying (&info.isPlaying) != AAX_SUCCESS)
  663. info.isPlaying = false;
  664. if (info.isPlaying
  665. || transport.GetTimelineSelectionStartPosition (&info.timeInSamples) != AAX_SUCCESS)
  666. check (transport.GetCurrentNativeSampleLocation (&info.timeInSamples));
  667. info.timeInSeconds = info.timeInSamples / sampleRate;
  668. int64_t ticks = 0;
  669. check (transport.GetCurrentTickPosition (&ticks));
  670. info.ppqPosition = ticks / 960000.0;
  671. info.isLooping = false;
  672. int64_t loopStartTick = 0, loopEndTick = 0;
  673. check (transport.GetCurrentLoopPosition (&info.isLooping, &loopStartTick, &loopEndTick));
  674. info.ppqLoopStart = loopStartTick / 960000.0;
  675. info.ppqLoopEnd = loopEndTick / 960000.0;
  676. info.editOriginTime = 0;
  677. info.frameRate = AudioPlayHead::fpsUnknown;
  678. AAX_EFrameRate frameRate;
  679. int32_t offset;
  680. if (transport.GetTimeCodeInfo (&frameRate, &offset) == AAX_SUCCESS)
  681. {
  682. double framesPerSec = 24.0;
  683. switch (frameRate)
  684. {
  685. case AAX_eFrameRate_Undeclared: break;
  686. case AAX_eFrameRate_24Frame: info.frameRate = AudioPlayHead::fps24; break;
  687. case AAX_eFrameRate_25Frame: info.frameRate = AudioPlayHead::fps25; framesPerSec = 25.0; break;
  688. case AAX_eFrameRate_2997NonDrop: info.frameRate = AudioPlayHead::fps2997; framesPerSec = 29.97002997; break;
  689. case AAX_eFrameRate_2997DropFrame: info.frameRate = AudioPlayHead::fps2997drop; framesPerSec = 29.97002997; break;
  690. case AAX_eFrameRate_30NonDrop: info.frameRate = AudioPlayHead::fps30; framesPerSec = 30.0; break;
  691. case AAX_eFrameRate_30DropFrame: info.frameRate = AudioPlayHead::fps30drop; framesPerSec = 30.0; break;
  692. case AAX_eFrameRate_23976: info.frameRate = AudioPlayHead::fps24; framesPerSec = 23.976; break;
  693. default: break;
  694. }
  695. info.editOriginTime = offset / framesPerSec;
  696. }
  697. // No way to get these: (?)
  698. info.isRecording = false;
  699. info.ppqPositionOfLastBarStart = 0;
  700. return true;
  701. }
  702. void audioProcessorParameterChanged (AudioProcessor* /*processor*/, int parameterIndex, float newValue) override
  703. {
  704. SetParameterNormalizedValue (getAAXParamIDFromJuceIndex (parameterIndex), (double) newValue);
  705. }
  706. void audioProcessorChanged (AudioProcessor* processor) override
  707. {
  708. ++mNumPlugInChanges;
  709. check (Controller()->SetSignalLatency (processor->getLatencySamples()));
  710. }
  711. void audioProcessorParameterChangeGestureBegin (AudioProcessor* /*processor*/, int parameterIndex) override
  712. {
  713. TouchParameter (getAAXParamIDFromJuceIndex (parameterIndex));
  714. }
  715. void audioProcessorParameterChangeGestureEnd (AudioProcessor* /*processor*/, int parameterIndex) override
  716. {
  717. ReleaseParameter (getAAXParamIDFromJuceIndex (parameterIndex));
  718. }
  719. AAX_Result NotificationReceived (AAX_CTypeID type, const void* data, uint32_t size) override
  720. {
  721. if (type == AAX_eNotificationEvent_EnteringOfflineMode) pluginInstance->setNonRealtime (true);
  722. if (type == AAX_eNotificationEvent_ExitingOfflineMode) pluginInstance->setNonRealtime (false);
  723. return AAX_CEffectParameters::NotificationReceived (type, data, size);
  724. }
  725. const float* getAudioBufferForInput (const float* const* inputs, const int sidechain, const int mainNumIns, int idx) const noexcept
  726. {
  727. jassert (idx < (mainNumIns + 1));
  728. if (idx < mainNumIns)
  729. return inputs[inputLayoutMap[idx]];
  730. return (sidechain != -1 ? inputs[sidechain] : sideChainBuffer.getData());
  731. }
  732. void process (const float* const* inputs, float* const* outputs, const int sideChainBufferIdx,
  733. const int bufferSize, const bool bypass,
  734. AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut)
  735. {
  736. const int numIns = pluginInstance->getTotalNumInputChannels();
  737. const int numOuts = pluginInstance->getTotalNumOutputChannels();
  738. if (pluginInstance->isSuspended())
  739. {
  740. for (int i = 0; i < numOuts; ++i)
  741. FloatVectorOperations::clear (outputs[i], bufferSize);
  742. }
  743. else
  744. {
  745. const int mainNumIns = numIns > 0 ? pluginInstance->busArrangement.inputBuses.getReference (0).channels.size() : 0;
  746. const int sidechain = busUtils.getNumEnabledBuses (true) >= 2 ? sideChainBufferIdx : -1;
  747. const int numChans = jmax (numIns, numOuts);
  748. if (numChans == 0) return;
  749. if (channelList.size() <= numChans)
  750. channelList.insertMultiple (-1, nullptr, 1 + numChans - channelList.size());
  751. float** channels = channelList.getRawDataPointer();
  752. if (numOuts >= numIns)
  753. {
  754. for (int i = 0; i < numOuts; ++i)
  755. channels[i] = outputs[outputLayoutMap[i]];
  756. for (int i = 0; i < numIns; ++i)
  757. memcpy (channels[i], getAudioBufferForInput (inputs, sidechain, mainNumIns, i), (size_t) bufferSize * sizeof (float));
  758. process (channels, numOuts, bufferSize, bypass, midiNodeIn, midiNodesOut);
  759. }
  760. else
  761. {
  762. for (int i = 0; i < numOuts; ++i)
  763. channels[i] = outputs[outputLayoutMap[i]];
  764. for (int i = 0; i < numOuts; ++i)
  765. memcpy (channels[i], getAudioBufferForInput (inputs, sidechain, mainNumIns, i), (size_t) bufferSize * sizeof (float));
  766. for (int i = numOuts; i < numIns; ++i)
  767. channels[i] = const_cast<float*> (getAudioBufferForInput (inputs, sidechain, mainNumIns, i));
  768. process (channels, numIns, bufferSize, bypass, midiNodeIn, midiNodesOut);
  769. }
  770. }
  771. }
  772. bool supportsSidechain() const noexcept { return hasSidechain; };
  773. private:
  774. friend class JuceAAX_GUI;
  775. void process (float* const* channels, const int numChans, const int bufferSize,
  776. const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut)
  777. {
  778. AudioSampleBuffer buffer (channels, numChans, bufferSize);
  779. midiBuffer.clear();
  780. ignoreUnused (midiNodeIn, midiNodesOut);
  781. #if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
  782. {
  783. AAX_CMidiStream* const midiStream = midiNodeIn->GetNodeBuffer();
  784. const uint32_t numMidiEvents = midiStream->mBufferSize;
  785. for (uint32_t i = 0; i < numMidiEvents; ++i)
  786. {
  787. const AAX_CMidiPacket& m = midiStream->mBuffer[i];
  788. jassert ((int) m.mTimestamp < bufferSize);
  789. midiBuffer.addEvent (m.mData, (int) m.mLength,
  790. jlimit (0, (int) bufferSize - 1, (int) m.mTimestamp));
  791. }
  792. }
  793. #endif
  794. {
  795. if (lastBufferSize != bufferSize)
  796. {
  797. lastBufferSize = bufferSize;
  798. pluginInstance->setRateAndBufferSizeDetails (sampleRate, bufferSize);
  799. if (bufferSize > maxBufferSize)
  800. {
  801. // we only call prepareToPlay here if the new buffer size is larger than
  802. // the one used last time prepareToPlay was called.
  803. // currently, this should never actually happen, because as of Pro Tools 12,
  804. // the maximum possible value is 1024, and we call prepareToPlay with that
  805. // value during initialisation.
  806. pluginInstance->prepareToPlay (sampleRate, bufferSize);
  807. maxBufferSize = bufferSize;
  808. sideChainBuffer.realloc (static_cast<size_t> (maxBufferSize));
  809. }
  810. }
  811. const ScopedLock sl (pluginInstance->getCallbackLock());
  812. if (bypass)
  813. pluginInstance->processBlockBypassed (buffer, midiBuffer);
  814. else
  815. pluginInstance->processBlock (buffer, midiBuffer);
  816. }
  817. #if JucePlugin_ProducesMidiOutput || JucePlugin_IsMidiEffect
  818. {
  819. const juce::uint8* midiEventData;
  820. int midiEventSize, midiEventPosition;
  821. MidiBuffer::Iterator i (midiBuffer);
  822. AAX_CMidiPacket packet;
  823. packet.mIsImmediate = false;
  824. while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition))
  825. {
  826. jassert (isPositiveAndBelow (midiEventPosition, bufferSize));
  827. if (midiEventSize <= 4)
  828. {
  829. packet.mTimestamp = (uint32_t) midiEventPosition;
  830. packet.mLength = (uint32_t) midiEventSize;
  831. memcpy (packet.mData, midiEventData, (size_t) midiEventSize);
  832. check (midiNodesOut->PostMIDIPacket (&packet));
  833. }
  834. }
  835. }
  836. #endif
  837. }
  838. void addBypassParameter()
  839. {
  840. AAX_IParameter* masterBypass = new AAX_CParameter<bool> (cDefaultMasterBypassID,
  841. AAX_CString ("Master Bypass"),
  842. false,
  843. AAX_CBinaryTaperDelegate<bool>(),
  844. AAX_CBinaryDisplayDelegate<bool> ("bypass", "on"),
  845. true);
  846. masterBypass->SetNumberOfSteps (2);
  847. masterBypass->SetType (AAX_eParameterType_Discrete);
  848. mParameterManager.AddParameter (masterBypass);
  849. mPacketDispatcher.RegisterPacket (cDefaultMasterBypassID, JUCEAlgorithmIDs::bypass);
  850. }
  851. void addAudioProcessorParameters()
  852. {
  853. AudioProcessor& audioProcessor = getPluginInstance();
  854. const int numParameters = audioProcessor.getNumParameters();
  855. #if JUCE_FORCE_USE_LEGACY_PARAM_IDS
  856. const bool usingManagedParameters = false;
  857. #else
  858. const bool usingManagedParameters = (audioProcessor.getParameters().size() == numParameters);
  859. #endif
  860. for (int parameterIndex = 0; parameterIndex < numParameters; ++parameterIndex)
  861. {
  862. aaxParamIDs.add (usingManagedParameters ? audioProcessor.getParameterID (parameterIndex)
  863. : String (parameterIndex));
  864. AAX_CString paramName (audioProcessor.getParameterName (parameterIndex, 31).toRawUTF8());
  865. AAX_CParamID paramID = aaxParamIDs.getReference (parameterIndex).getCharPointer();
  866. paramMap.set (AAXClasses::getAAXParamHash (paramID), parameterIndex);
  867. AAX_IParameter* parameter
  868. = new AAX_CParameter<float> (paramID,
  869. paramName,
  870. audioProcessor.getParameterDefaultValue (parameterIndex),
  871. AAX_CLinearTaperDelegate<float, 0>(),
  872. AAX_CNumberDisplayDelegate<float, 3>(),
  873. audioProcessor.isParameterAutomatable (parameterIndex));
  874. parameter->AddShortenedName (audioProcessor.getParameterName (parameterIndex, 4).toRawUTF8());
  875. const int parameterNumSteps = audioProcessor.getParameterNumSteps (parameterIndex);
  876. parameter->SetNumberOfSteps ((uint32_t) parameterNumSteps);
  877. parameter->SetType (parameterNumSteps > 1000 ? AAX_eParameterType_Continuous
  878. : AAX_eParameterType_Discrete);
  879. parameter->SetOrientation (audioProcessor.isParameterOrientationInverted (parameterIndex)
  880. ? (AAX_eParameterOrientation_RightMinLeftMax | AAX_eParameterOrientation_TopMinBottomMax
  881. | AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryRightMinLeftMax)
  882. : (AAX_eParameterOrientation_LeftMinRightMax | AAX_eParameterOrientation_BottomMinTopMax
  883. | AAX_eParameterOrientation_RotarySingleDotMode | AAX_eParameterOrientation_RotaryLeftMinRightMax));
  884. mParameterManager.AddParameter (parameter);
  885. }
  886. }
  887. AAX_Result preparePlugin()
  888. {
  889. AudioProcessor& audioProcessor = getPluginInstance();
  890. bool hasSomethingChanged = false;
  891. #if JucePlugin_IsMidiEffect
  892. // MIDI effect plug-ins do not support any audio channels
  893. jassert (audioProcessor.busArrangement.getTotalNumInputChannels() == 0
  894. && audioProcessor.busArrangement.getTotalNumOutputChannels() == 0);
  895. #else
  896. AAX_EStemFormat inputStemFormat = AAX_eStemFormat_None;
  897. check (Controller()->GetInputStemFormat (&inputStemFormat));
  898. AAX_EStemFormat outputStemFormat = AAX_eStemFormat_None;
  899. check (Controller()->GetOutputStemFormat (&outputStemFormat));
  900. const AudioChannelSet inputSet = channelSetFromStemFormat (inputStemFormat, busUtils.busIgnoresLayout (true, 0));
  901. const AudioChannelSet outputSet = channelSetFromStemFormat (outputStemFormat, busUtils.busIgnoresLayout (false, 0));
  902. if ( (inputSet == AudioChannelSet::disabled() && inputStemFormat != AAX_eStemFormat_None)
  903. || (outputSet == AudioChannelSet::disabled() && outputStemFormat != AAX_eStemFormat_None))
  904. {
  905. if (isPrepared)
  906. {
  907. isPrepared = false;
  908. audioProcessor.releaseResources();
  909. }
  910. return AAX_ERROR_UNIMPLEMENTED;
  911. }
  912. bool success = true;
  913. if (busUtils.getBusCount (true) > 0)
  914. success = setPreferredBusArrangement (busUtils, true, 0, inputSet, hasSomethingChanged);
  915. if (success && busUtils.getBusCount (false) > 0)
  916. success = setPreferredBusArrangement (busUtils, false, 0, outputSet, hasSomethingChanged);
  917. // This should never happen as the plugin reported that this layout is supported
  918. jassert (success);
  919. hasSidechain = enableAuxBusesForCurrentFormat (busUtils, inputSet, outputSet, hasSomethingChanged);
  920. if (hasSidechain && hasSomethingChanged)
  921. sideChainBuffer.realloc (static_cast<size_t> (maxBufferSize));
  922. // recheck the format
  923. if ( (busUtils.getBusCount (true) > 0 && busUtils.getChannelSet (true, 0) != inputSet)
  924. || (busUtils.getBusCount (false) > 0 && busUtils.getChannelSet (false, 0) != outputSet)
  925. || (hasSidechain && busUtils.getNumChannels(true, 1) != 1))
  926. {
  927. if (isPrepared)
  928. {
  929. isPrepared = false;
  930. audioProcessor.releaseResources();
  931. }
  932. return AAX_ERROR_UNIMPLEMENTED;
  933. }
  934. if (hasSomethingChanged)
  935. {
  936. rebuildChannelMapArrays (true);
  937. rebuildChannelMapArrays (false);
  938. }
  939. #endif
  940. hasSomethingChanged = (sampleRate != audioProcessor.getSampleRate()
  941. || maxBufferSize != lastBufferSize
  942. || hasSomethingChanged);
  943. if (hasSomethingChanged || (! isPrepared))
  944. {
  945. if (isPrepared)
  946. {
  947. isPrepared = false;
  948. audioProcessor.releaseResources();
  949. }
  950. audioProcessor.setRateAndBufferSizeDetails (sampleRate, lastBufferSize);
  951. audioProcessor.prepareToPlay (sampleRate, lastBufferSize);
  952. maxBufferSize = lastBufferSize;
  953. }
  954. check (Controller()->SetSignalLatency (audioProcessor.getLatencySamples()));
  955. isPrepared = true;
  956. return AAX_SUCCESS;
  957. }
  958. void rebuildChannelMapArrays (bool isInput)
  959. {
  960. Array<int>& layoutMap = isInput ? inputLayoutMap : outputLayoutMap;
  961. layoutMap.clear();
  962. const int n = isInput ? jmin (busUtils.getBusCount (true), 1) : busUtils.getBusCount (false);
  963. int chOffset = 0;
  964. for (int busIdx = 0; busIdx < n; ++busIdx)
  965. {
  966. const AudioChannelSet channelFormat = busUtils.getChannelSet (isInput, busIdx);
  967. if (channelFormat != AudioChannelSet::disabled())
  968. {
  969. const int numChannels = channelFormat.size();
  970. for (int ch = 0; ch < numChannels; ++ch)
  971. layoutMap.add (juceChannelIndexToAax (ch, channelFormat) + chOffset);
  972. chOffset += numChannels;
  973. }
  974. }
  975. }
  976. //==============================================================================
  977. inline int getParamIndexFromID (AAX_CParamID paramID) const noexcept
  978. {
  979. return paramMap [AAXClasses::getAAXParamHash (paramID)];
  980. }
  981. inline AAX_CParamID getAAXParamIDFromJuceIndex (int index) const noexcept
  982. {
  983. if (! isPositiveAndBelow (index, aaxParamIDs.size())) return nullptr;
  984. return aaxParamIDs.getReference (index).getCharPointer();
  985. }
  986. //==============================================================================
  987. ScopedJuceInitialiser_GUI libraryInitialiser;
  988. ScopedPointer<AudioProcessor> pluginInstance;
  989. bool isPrepared;
  990. PluginBusUtilities busUtils;
  991. MidiBuffer midiBuffer;
  992. Array<float*> channelList;
  993. int32_t juceChunkIndex;
  994. AAX_CSampleRate sampleRate;
  995. int lastBufferSize, maxBufferSize;
  996. bool hasSidechain;
  997. HeapBlock<float> sideChainBuffer;
  998. Array<int> inputLayoutMap, outputLayoutMap;
  999. Array<String> aaxParamIDs;
  1000. HashMap<int32, int> paramMap;
  1001. struct ChunkMemoryBlock : public ReferenceCountedObject
  1002. {
  1003. juce::MemoryBlock data;
  1004. typedef ReferenceCountedObjectPtr<ChunkMemoryBlock> Ptr;
  1005. };
  1006. // temporary filter data is generated in GetChunkSize
  1007. // and the size of the data returned. To avoid generating
  1008. // it again in GetChunk, we need to store it somewhere.
  1009. // However, as GetChunkSize and GetChunk can be called
  1010. // on different threads, we store it in thread dependant storage
  1011. // in a hash map with the thread id as a key.
  1012. mutable HashMap<Thread::ThreadID, ChunkMemoryBlock::Ptr> perThreadFilterData;
  1013. CriticalSection perThreadDataLock;
  1014. JUCE_DECLARE_NON_COPYABLE (JuceAAX_Processor)
  1015. };
  1016. //==============================================================================
  1017. struct AAXFormatConfiguration
  1018. {
  1019. AAXFormatConfiguration() noexcept
  1020. : inputFormat (AAX_eStemFormat_None), outputFormat (AAX_eStemFormat_None) {}
  1021. AAXFormatConfiguration (AAX_EStemFormat inFormat, AAX_EStemFormat outFormat) noexcept
  1022. : inputFormat (inFormat), outputFormat (outFormat) {}
  1023. AAX_EStemFormat inputFormat, outputFormat;
  1024. bool operator== (const AAXFormatConfiguration other) const noexcept { return (inputFormat == other.inputFormat) && (outputFormat == other.outputFormat); }
  1025. bool operator< (const AAXFormatConfiguration other) const noexcept
  1026. {
  1027. return (inputFormat == other.inputFormat) ? (outputFormat < other.outputFormat) : (inputFormat < other.inputFormat);
  1028. }
  1029. };
  1030. //==============================================================================
  1031. static void AAX_CALLBACK algorithmProcessCallback (JUCEAlgorithmContext* const instancesBegin[],
  1032. const void* const instancesEnd)
  1033. {
  1034. for (JUCEAlgorithmContext* const* iter = instancesBegin; iter < instancesEnd; ++iter)
  1035. {
  1036. const JUCEAlgorithmContext& i = **iter;
  1037. int sideChainBufferIdx = i.pluginInstance->parameters.supportsSidechain() && i.sideChainBuffers != nullptr
  1038. ? static_cast<int> (*i.sideChainBuffers)
  1039. : -1;
  1040. // sidechain index of zero is an invalid index
  1041. if (sideChainBufferIdx <= 0)
  1042. sideChainBufferIdx = -1;
  1043. i.pluginInstance->parameters.process (i.inputChannels, i.outputChannels, sideChainBufferIdx,
  1044. *(i.bufferSize), *(i.bypass) != 0,
  1045. getMidiNodeIn(i), getMidiNodeOut(i));
  1046. }
  1047. }
  1048. static bool enableAuxBusesForCurrentFormat (PluginBusUtilities& busUtils, const AudioChannelSet& inputLayout,
  1049. const AudioChannelSet& outputLayout,
  1050. bool& hasSomethingChanged)
  1051. {
  1052. const int numOutBuses = busUtils.getBusCount (false);
  1053. const int numInputBuses = busUtils.getBusCount(true);
  1054. if (numOutBuses > 1)
  1055. {
  1056. PluginBusUtilities::ScopedBusRestorer layoutRestorer (busUtils);
  1057. // enable all possible output buses
  1058. for (int busIdx = 1; busIdx < busUtils.getBusCount (false); ++busIdx)
  1059. {
  1060. AudioChannelSet layout = busUtils.getChannelSet (false, busIdx);
  1061. // bus disabled by default? try to enable it with the default layout
  1062. if (layout == AudioChannelSet::disabled())
  1063. {
  1064. layout = busUtils.getDefaultLayoutForBus (false, busIdx);
  1065. setPreferredBusArrangement (busUtils, false, busIdx, layout, hasSomethingChanged);
  1066. }
  1067. }
  1068. // changing output buses may have changed main bus layout
  1069. bool success = true;
  1070. if (numInputBuses > 0)
  1071. success = setPreferredBusArrangement (busUtils, true, 0, inputLayout, hasSomethingChanged);
  1072. if (success)
  1073. success = setPreferredBusArrangement (busUtils, false, 0, outputLayout, hasSomethingChanged);
  1074. // was the above successful
  1075. if (success && (numInputBuses == 0 || busUtils.getChannelSet (true, 0) == inputLayout)
  1076. && busUtils.getChannelSet (false, 0) == outputLayout)
  1077. layoutRestorer.release();
  1078. else
  1079. hasSomethingChanged = true;
  1080. }
  1081. // does the plug-in have side-chain support? Check the following:
  1082. // 1) does it have an input bus with index = 1 which supports mono
  1083. // 2) can all other input buses be disabled
  1084. // 3) does the format of the main buses not change when enabling the first bus
  1085. if (numInputBuses > 1)
  1086. {
  1087. bool success = true;
  1088. bool hasSidechain = false;
  1089. const AudioChannelSet set = busUtils.getDefaultLayoutForChannelNumAndBus (true, 1, 1);
  1090. if (! set.isDisabled())
  1091. hasSidechain = setPreferredBusArrangement (busUtils, true, 1, set, hasSomethingChanged);
  1092. if (! hasSidechain)
  1093. success = setPreferredBusArrangement (busUtils, true, 1,
  1094. AudioChannelSet::disabled(),
  1095. hasSomethingChanged);
  1096. // AAX requires your processor's first sidechain to be either mono or that
  1097. // it can be disabled
  1098. jassert(success);
  1099. // disable all other input buses
  1100. for (int busIdx = 2; busIdx < numInputBuses; ++busIdx)
  1101. {
  1102. success = setPreferredBusArrangement (busUtils, true, busIdx,
  1103. AudioChannelSet::disabled(),
  1104. hasSomethingChanged);
  1105. // AAX can only have a single side-chain input. Therefore, your processor must either
  1106. // only have a single side-chain input or allow disabling all other side-chains
  1107. jassert (success);
  1108. }
  1109. if (hasSidechain)
  1110. {
  1111. if (busUtils.getBusCount (false) == 0 || busUtils.getBusCount (true) == 0 ||
  1112. (busUtils.getChannelSet (true, 0) == inputLayout && busUtils.getChannelSet (false, 0) == outputLayout))
  1113. return true;
  1114. // restore the old layout
  1115. if (busUtils.getBusCount(true) > 0)
  1116. setPreferredBusArrangement (busUtils, true, 0, inputLayout, hasSomethingChanged);
  1117. if (busUtils.getBusCount (false) > 0)
  1118. setPreferredBusArrangement (busUtils, false, 0, outputLayout, hasSomethingChanged);
  1119. }
  1120. }
  1121. return false;
  1122. }
  1123. // wrap setPreferredBusArrangement calls with this to prevent excessive calls to the plug-in
  1124. static bool setPreferredBusArrangement (PluginBusUtilities& busUtils, bool isInput, int busIdx,
  1125. const AudioChannelSet& layout,
  1126. bool& didChangePlugin)
  1127. {
  1128. // no need to do anything
  1129. if (busUtils.getChannelSet (isInput, busIdx) == layout)
  1130. return true;
  1131. didChangePlugin = true;
  1132. return busUtils.processor.setPreferredBusArrangement (isInput, busIdx, layout);
  1133. }
  1134. //==============================================================================
  1135. static void createDescriptor (AAX_IComponentDescriptor& desc, int configIndex, PluginBusUtilities& busUtils,
  1136. const AudioChannelSet& inputLayout, const AudioChannelSet& outputLayout,
  1137. const AAX_EStemFormat aaxInputFormat, const AAX_EStemFormat aaxOutputFormat)
  1138. {
  1139. check (desc.AddAudioIn (JUCEAlgorithmIDs::inputChannels));
  1140. check (desc.AddAudioOut (JUCEAlgorithmIDs::outputChannels));
  1141. check (desc.AddAudioBufferLength (JUCEAlgorithmIDs::bufferSize));
  1142. check (desc.AddDataInPort (JUCEAlgorithmIDs::bypass, sizeof (int32_t)));
  1143. #if JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect
  1144. check (desc.AddMIDINode (JUCEAlgorithmIDs::midiNodeIn, AAX_eMIDINodeType_LocalInput,
  1145. JucePlugin_Name, 0xffff));
  1146. #endif
  1147. #if JucePlugin_ProducesMidiOutput || JucePlugin_IsSynth || JucePlugin_IsMidiEffect
  1148. check (desc.AddMIDINode (JUCEAlgorithmIDs::midiNodeOut, AAX_eMIDINodeType_LocalOutput,
  1149. JucePlugin_Name " Out", 0xffff));
  1150. #endif
  1151. check (desc.AddPrivateData (JUCEAlgorithmIDs::pluginInstance, sizeof (PluginInstanceInfo)));
  1152. check (desc.AddPrivateData (JUCEAlgorithmIDs::preparedFlag, sizeof (int32_t)));
  1153. // Create a property map
  1154. AAX_IPropertyMap* const properties = desc.NewPropertyMap();
  1155. jassert (properties != nullptr);
  1156. properties->AddProperty (AAX_eProperty_ManufacturerID, JucePlugin_AAXManufacturerCode);
  1157. properties->AddProperty (AAX_eProperty_ProductID, JucePlugin_AAXProductId);
  1158. #if JucePlugin_AAXDisableBypass
  1159. properties->AddProperty (AAX_eProperty_CanBypass, false);
  1160. #else
  1161. properties->AddProperty (AAX_eProperty_CanBypass, true);
  1162. #endif
  1163. properties->AddProperty (AAX_eProperty_InputStemFormat, static_cast<AAX_CPropertyValue> (aaxInputFormat));
  1164. properties->AddProperty (AAX_eProperty_OutputStemFormat, static_cast<AAX_CPropertyValue> (aaxOutputFormat));
  1165. // This value needs to match the RTAS wrapper's Type ID, so that
  1166. // the host knows that the RTAS/AAX plugins are equivalent.
  1167. properties->AddProperty (AAX_eProperty_PlugInID_Native, 'jcaa' + configIndex);
  1168. #if ! JucePlugin_AAXDisableAudioSuite
  1169. properties->AddProperty (AAX_eProperty_PlugInID_AudioSuite, 'jyaa' + configIndex);
  1170. #endif
  1171. #if JucePlugin_AAXDisableMultiMono
  1172. properties->AddProperty (AAX_eProperty_Constraint_MultiMonoSupport, false);
  1173. #else
  1174. properties->AddProperty (AAX_eProperty_Constraint_MultiMonoSupport, true);
  1175. #endif
  1176. #if JucePlugin_AAXDisableDynamicProcessing
  1177. properties->AddProperty (AAX_eProperty_Constraint_AlwaysProcess, true);
  1178. #endif
  1179. #if JucePlugin_AAXDisableSaveRestore
  1180. properties->AddProperty (AAX_eProperty_SupportsSaveRestore, false);
  1181. #endif
  1182. bool ignore;
  1183. if (enableAuxBusesForCurrentFormat (busUtils, inputLayout, outputLayout, ignore))
  1184. {
  1185. check (desc.AddSideChainIn (JUCEAlgorithmIDs::sideChainBuffers));
  1186. properties->AddProperty (AAX_eProperty_SupportsSideChainInput, true);
  1187. }
  1188. // add the output buses
  1189. // This is incrdibly dumb: the output bus format must be well defined
  1190. // for every main bus in/out format pair. This means that there cannot
  1191. // be two configurations with different aux formats but
  1192. // identical main bus in/out formats.
  1193. for (int busIdx = 1; busIdx < busUtils.getBusCount (false); ++busIdx)
  1194. {
  1195. AudioChannelSet outBusLayout = busUtils.getChannelSet (false, busIdx);
  1196. if (outBusLayout != AudioChannelSet::disabled())
  1197. {
  1198. AAX_EStemFormat auxFormat = getFormatForAudioChannelSet (outBusLayout, busUtils.busIgnoresLayout (false, busIdx));
  1199. if (auxFormat != AAX_eStemFormat_INT32_MAX && auxFormat != AAX_eStemFormat_None)
  1200. {
  1201. const String& name = busUtils.processor.busArrangement.outputBuses.getReference (busIdx).name;
  1202. check (desc.AddAuxOutputStem (0, static_cast<int32_t> (auxFormat), name.toRawUTF8()));
  1203. }
  1204. }
  1205. }
  1206. // this assertion should be covered by the assertions above
  1207. // if not please report a bug
  1208. jassert (busUtils.getNumEnabledBuses (true) <= 2);
  1209. check (desc.AddProcessProc_Native (algorithmProcessCallback, properties));
  1210. }
  1211. static void getPlugInDescription (AAX_IEffectDescriptor& descriptor)
  1212. {
  1213. JUCE_DECLARE_WRAPPER_TYPE (wrapperType_AAX);
  1214. ScopedPointer<AudioProcessor> plugin = createPluginFilterOfType (AudioProcessor::wrapperType_AAX);
  1215. PluginBusUtilities busUtils (*plugin, false, maxAAXChannels);
  1216. busUtils.init();
  1217. // AAX requires your default layout to be non-discrete!
  1218. // For example, your default layout must be mono, stereo, quadrophonic
  1219. // and not AudioChannelSet::discreteChannels (2) etc.
  1220. jassert (busUtils.checkBusFormatsAreNotDiscrete());
  1221. descriptor.AddName (JucePlugin_Desc);
  1222. descriptor.AddName (JucePlugin_Name);
  1223. descriptor.AddCategory (JucePlugin_AAXCategory);
  1224. #ifdef JucePlugin_AAXPageTableFile
  1225. // optional page table setting - define this macro in your project if you want
  1226. // to set this value - see Avid documentation for details about its format.
  1227. descriptor.AddResourceInfo (AAX_eResourceType_PageTable, JucePlugin_AAXPageTableFile);
  1228. #endif
  1229. check (descriptor.AddProcPtr ((void*) JuceAAX_GUI::Create, kAAX_ProcPtrID_Create_EffectGUI));
  1230. check (descriptor.AddProcPtr ((void*) JuceAAX_Processor::Create, kAAX_ProcPtrID_Create_EffectParameters));
  1231. #if JucePlugin_IsMidiEffect
  1232. // MIDI effect plug-ins do not support any audio channels
  1233. jassert (getBusCount (true) == 0 && getBusCount (false) == 0);
  1234. if (AAX_IComponentDescriptor* const desc = descriptor.NewComponentDescriptor())
  1235. {
  1236. createDescriptor (*desc, 0, busUtils,
  1237. AudioChannelSet::disabled(), AudioChannelSet::disabled(),
  1238. AAX_eStemFormat_Mono, AAX_eStemFormat_Mono);
  1239. check (descriptor.AddComponent (desc));
  1240. }
  1241. #else
  1242. int configIndex = 0;
  1243. const int numIns = busUtils.getBusCount (true) > 0 ? AAX_eStemFormatNum : 0;
  1244. const int numOuts = busUtils.getBusCount (false) > 0 ? AAX_eStemFormatNum : 0;
  1245. for (int inIdx = 0; inIdx < jmax (numIns, 1); ++inIdx)
  1246. {
  1247. AAX_EStemFormat aaxInFormat = numIns > 0 ? aaxFormats[inIdx] : AAX_eStemFormat_None;
  1248. AudioChannelSet inLayout = channelSetFromStemFormat (aaxInFormat, false);
  1249. for (int outIdx = 0; outIdx < jmax (numOuts, 1); ++outIdx)
  1250. {
  1251. AAX_EStemFormat aaxOutFormat = numOuts > 0 ? aaxFormats[outIdx] : AAX_eStemFormat_None;
  1252. AudioChannelSet outLayout = channelSetFromStemFormat (aaxOutFormat, false);
  1253. bool success = true;
  1254. if (numIns > 0)
  1255. success = busUtils.processor.setPreferredBusArrangement (true, 0, inLayout);
  1256. if (numOuts > 0 && success)
  1257. success = busUtils.processor.setPreferredBusArrangement (false, 0, outLayout);
  1258. if (! success)
  1259. continue;
  1260. // if we can't set both in AND out formats simultaneously then ignore this format!
  1261. if (numIns > 0 && numOuts > 0 && (inLayout != busUtils.getChannelSet (true, 0) || (outLayout != busUtils.getChannelSet (false, 0))))
  1262. continue;
  1263. // AAX requires a single input if this plug-in is a synth
  1264. #if JucePlugin_IsSynth
  1265. if (numIns == 0)
  1266. aaxInFormat = aaxOutFormat;
  1267. #endif
  1268. if (aaxInFormat == AAX_eStemFormat_None && aaxOutFormat == AAX_eStemFormat_None)
  1269. continue;
  1270. if (AAX_IComponentDescriptor* const desc = descriptor.NewComponentDescriptor())
  1271. {
  1272. createDescriptor (*desc, configIndex++, busUtils, inLayout, outLayout, aaxInFormat, aaxOutFormat);
  1273. check (descriptor.AddComponent (desc));
  1274. }
  1275. }
  1276. }
  1277. // You don't have any supported layouts
  1278. jassert (configIndex > 0);
  1279. #endif
  1280. }
  1281. };
  1282. //==============================================================================
  1283. AAX_EStemFormat AAXClasses::aaxFormats[] =
  1284. {
  1285. AAX_eStemFormat_Mono,
  1286. AAX_eStemFormat_Stereo,
  1287. AAX_eStemFormat_LCR,
  1288. AAX_eStemFormat_LCRS,
  1289. AAX_eStemFormat_Quad,
  1290. AAX_eStemFormat_5_0,
  1291. AAX_eStemFormat_5_1,
  1292. AAX_eStemFormat_6_0,
  1293. AAX_eStemFormat_6_1,
  1294. AAX_eStemFormat_7_0_SDDS,
  1295. AAX_eStemFormat_7_1_SDDS,
  1296. AAX_eStemFormat_7_0_DTS,
  1297. AAX_eStemFormat_7_1_DTS
  1298. };
  1299. AAXClasses::AAXChannelStreamOrder AAXClasses::aaxChannelOrder[] =
  1300. {
  1301. {AAX_eStemFormat_Mono, {AudioChannelSet::centre, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1302. {AAX_eStemFormat_Stereo, {AudioChannelSet::left, AudioChannelSet::right, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1303. {AAX_eStemFormat_LCR, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1304. {AAX_eStemFormat_LCRS, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::surround, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1305. {AAX_eStemFormat_Quad, {AudioChannelSet::left, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1306. {AAX_eStemFormat_5_0, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1307. {AAX_eStemFormat_5_1, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::subbass, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1308. {AAX_eStemFormat_6_0, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::surround, AudioChannelSet::rightSurround, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1309. {AAX_eStemFormat_6_1, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::surround, AudioChannelSet::rightSurround, AudioChannelSet::subbass, AudioChannelSet::unknown}},
  1310. {AAX_eStemFormat_7_0_SDDS, {AudioChannelSet::left, AudioChannelSet::leftCentre, AudioChannelSet::centre, AudioChannelSet::rightCentre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::unknown}},
  1311. {AAX_eStemFormat_7_0_DTS, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftRearSurround, AudioChannelSet::rightRearSurround, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::unknown}},
  1312. {AAX_eStemFormat_7_1_SDDS, {AudioChannelSet::left, AudioChannelSet::leftCentre, AudioChannelSet::centre, AudioChannelSet::rightCentre, AudioChannelSet::right, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::subbass}},
  1313. {AAX_eStemFormat_7_1_DTS, {AudioChannelSet::left, AudioChannelSet::centre, AudioChannelSet::right, AudioChannelSet::leftRearSurround, AudioChannelSet::rightRearSurround, AudioChannelSet::leftSurround, AudioChannelSet::rightSurround, AudioChannelSet::subbass}},
  1314. {AAX_eStemFormat_None, {AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown, AudioChannelSet::unknown}},
  1315. };
  1316. //==============================================================================
  1317. AAX_Result JUCE_CDECL GetEffectDescriptions (AAX_ICollection*);
  1318. AAX_Result JUCE_CDECL GetEffectDescriptions (AAX_ICollection* collection)
  1319. {
  1320. ScopedJuceInitialiser_GUI libraryInitialiser;
  1321. if (AAX_IEffectDescriptor* const descriptor = collection->NewDescriptor())
  1322. {
  1323. AAXClasses::getPlugInDescription (*descriptor);
  1324. collection->AddEffect (JUCE_STRINGIFY (JucePlugin_AAXIdentifier), descriptor);
  1325. collection->SetManufacturerName (JucePlugin_Manufacturer);
  1326. collection->AddPackageName (JucePlugin_Desc);
  1327. collection->AddPackageName (JucePlugin_Name);
  1328. collection->SetPackageVersion (JucePlugin_VersionCode);
  1329. return AAX_SUCCESS;
  1330. }
  1331. return AAX_ERROR_NULL_OBJECT;
  1332. }
  1333. #endif