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.

1700 lines
73KB

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