JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_AAXClientExtensions.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
30{
31public:
33 {
34 std::array<size_t, 4> indices{};
35
36 for (size_t i = 0; i < letters.size(); ++i)
37 {
38 if (const auto index = findIndexOfChar (letters[i]))
39 indices[i] = *index;
40 else
41 return std::nullopt;
42 }
43
44 return AAXPluginId { std::move (indices) };
45 }
46
47 std::optional<AAXPluginId> withIncrementedLetter (size_t index, size_t increment) const
48 {
49 if (indices.size() <= index)
50 return std::nullopt;
51
52 auto copy = *this;
53 copy.indices[index] += increment;
54
55 if ((size_t) std::size (validChars) <= copy.indices[index])
56 return std::nullopt;
57
58 return copy;
59 }
60
61 int32 getPluginId() const
62 {
63 int32 result = 0;
64
65 for (size_t i = 0; i < indices.size(); ++i)
66 result |= static_cast<int32> (validChars[indices[i]]) << (8 * (indices.size() - 1 - i));
67
68 return result;
69 }
70
71 static std::optional<size_t> findIndexOfChar (char c)
72 {
73 const auto ptr = std::find (std::begin (validChars), std::end (validChars), c);
74 return ptr != std::end (validChars) ? std::make_optional (std::distance (std::begin (validChars), ptr))
75 : std::nullopt;
76 }
77
78private:
79 static inline constexpr char validChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
80
82 : indices (std::move (indicesIn))
83 {}
84
86};
87
88static const AudioChannelSet channelSets[] { AudioChannelSet::disabled(),
123
126 bool idForAudioSuite) const
127{
128 auto pluginId = [&]
129 {
130 auto opt = idForAudioSuite ? AAXPluginId::create ({ 'j', 'y', 'a', 'a' })
131 : AAXPluginId::create ({ 'j', 'c', 'a', 'a' });
132 jassert (opt.has_value());
133 return *opt;
134 }();
135
136 for (const auto& [channelSet, indexToModify] : { std::tuple (&mainInputLayout, (size_t) 2),
137 std::tuple (&mainOutputLayout, (size_t) 3) })
138 {
139 const auto increment = (size_t) std::distance (std::begin (channelSets),
140 std::find (std::begin (channelSets),
141 std::end (channelSets),
142 *channelSet));
143
144 if (auto modifiedPluginIdOpt = pluginId.withIncrementedLetter (indexToModify, increment);
145 increment < (size_t) std::size (channelSets) && modifiedPluginIdOpt.has_value())
146 {
148 }
149 else
150 {
152 }
153 }
154
155 return pluginId.getPluginId();
156}
157
159{
160 #ifdef JucePlugin_AAXPageTableFile
161 JUCE_COMPILER_WARNING ("JucePlugin_AAXPageTableFile is deprecated, instead implement AAXClientExtensions::getPageFileName()")
163 #else
164 return {};
165 #endif
166}
167
168//==============================================================================
169//==============================================================================
170#if JUCE_UNIT_TESTS
171
172static std::array<char, 4> toCharArray (int32 identifier)
173{
174 std::array<char, 4> result;
175
176 for (size_t i = 0; i < result.size(); ++i)
177 result[i] = static_cast<char> ((identifier >> (i * 8)) & 0xff);
178
179 return result;
180}
181
183{
184 const auto chars = toCharArray (pluginId);
185
186 return std::all_of (std::begin (chars),
187 std::end (chars),
188 [] (const auto& c)
189 {
190 return AAXPluginId::findIndexOfChar (c).has_value();
191 });
192}
193
194static int32 getPluginIDForMainBusConfigJuce705 (const AudioChannelSet& mainInputLayout,
195 const AudioChannelSet& mainOutputLayout,
196 bool idForAudioSuite)
197{
198 int uniqueFormatId = 0;
199
200 for (int dir = 0; dir < 2; ++dir)
201 {
202 const bool isInput = (dir == 0);
203 auto& set = (isInput ? mainInputLayout : mainOutputLayout);
204 int aaxFormatIndex = 0;
205
206 const AudioChannelSet sets[]
207 {
243 };
244
245 const auto index = (int) std::distance (std::begin (sets), std::find (std::begin (sets), std::end (sets), set));
246
247 if (index != (int) std::size (sets))
248 aaxFormatIndex = index;
249 else
251
253 }
254
255 return (idForAudioSuite ? 0x6a796161 /* 'jyaa' */ : 0x6a636161 /* 'jcaa' */) + uniqueFormatId;
256}
257
258class AAXClientExtensionsTests final : public UnitTest
259{
260public:
262 : UnitTest ("AAXClientExtensionsTests", UnitTestCategories::audioProcessors)
263 {}
264
265 void runTest() override
266 {
267 AAXClientExtensions extensions;
268
269 beginTest ("Previously valid PluginIds should be unchanged");
270 {
271 for (const auto& input : channelSets)
272 for (const auto& output : channelSets)
273 for (const auto idForAudioSuite : { false, true })
275 expect (extensions.getPluginIDForMainBusConfig (input, output, idForAudioSuite) == oldId);
276 }
277
278 beginTest ("Valid, unique PluginIds should be generated for all configurations");
279 {
281
282 for (const auto& input : channelSets)
283 for (const auto& output : channelSets)
284 for (const auto idForAudioSuite : { false, true })
285 pluginIds.insert (extensions.getPluginIDForMainBusConfig (input, output, idForAudioSuite));
286
287 for (auto identifier : pluginIds)
288 expect (isValidAAXPluginId (identifier));
289
290 expect (pluginIds.size() == square (std::size (channelSets)) * 2);
291 }
292 }
293};
294
296
297#endif
298
299} // namespace juce
T all_of(T... args)
T begin(T... args)
Represents a set of audio channel types.
static AudioChannelSet JUCE_CALLTYPE create7point1()
Creates a set for a DTS 7.1 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE quadraphonic()
Creates a set for quadraphonic surround setup (left, right, leftSurround, rightSurround)
static AudioChannelSet JUCE_CALLTYPE create5point0point2()
Creates a set for a 5.0.2 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create5point0()
Creates a set for a 5.0 surround setup (left, right, centre, leftSurround, rightSurround).
static AudioChannelSet JUCE_CALLTYPE create9point0point4()
Creates a set for a 9.0.4 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create6point0()
Creates a set for a 6.0 Cine surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create5point0point4()
Creates a set for a 5.0.4 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create5point1point4()
Creates a set for a 5.1.4 surround setup (left, right, centre, LFE, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE disabled()
Creates a zero-channel set which can be used to indicate that a bus is disabled.
static AudioChannelSet JUCE_CALLTYPE mono()
Creates a one-channel mono set (centre).
static AudioChannelSet JUCE_CALLTYPE create7point0point4()
Creates a set for Dolby Atmos 7.0.4 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE stereo()
Creates a set containing a stereo set (left, right).
static AudioChannelSet JUCE_CALLTYPE create6point1()
Creates a set for a 6.1 Cine surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create9point1point4()
Creates a set for a 9.1.4 surround setup (left, right, centre, LFE, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create9point0point6()
Creates a set for a 9.0.6 surround setup (left, right, centre, LFE, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create5point1()
Creates a set for a 5.1 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create7point0SDDS()
Creates a set for a SDDS 7.0 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create5point1point2()
Creates a set for a 5.1.2 surround setup (left, right, centre, LFE, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create9point1point6()
Creates a set for a 9.1.6 surround setup (left, right, centre, LFE, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create7point0point2()
Creates a set for Dolby Atmos 7.0.2 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create7point1SDDS()
Creates a set for a 7.1 surround setup (left, right, centre, leftSurround, rightSurround,...
static AudioChannelSet JUCE_CALLTYPE create7point0()
Creates a set for a DTS 7.0 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE ambisonic(int order=1)
Creates a set for ACN, SN3D normalised ambisonic surround setups with a given order.
static AudioChannelSet JUCE_CALLTYPE createLCRS()
Creates a set containing an LCRS set (left, right, centre, surround).
static AudioChannelSet JUCE_CALLTYPE create7point1point2()
Creates a set for Dolby Atmos 7.1.2 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create7point0point6()
Creates a set for 7.0.6 surround setup (left, right, centre, leftSurroundSide, rightSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE create7point1point6()
Creates a set for Dolby Atmos 7.1.6 surround setup (left, right, centre, leftSurroundSide,...
static AudioChannelSet JUCE_CALLTYPE createLCR()
Creates a set containing an LCR set (left, right, centre).
static AudioChannelSet JUCE_CALLTYPE create7point1point4()
Creates a set for Dolby Atmos 7.1.4 surround setup (left, right, centre, leftSurroundSide,...
The JUCE String class!
Definition juce_String.h:53
T distance(T... args)
T end(T... args)
T find(T... args)
T insert(T... args)
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_COMPILER_WARNING(message)
This macro allows you to emit a custom compiler warning message.
#define jassertfalse
This will always cause an assertion failure.
typedef int
T make_optional(T... args)
JUCE Namespace.
signed int int32
A platform-independent 32-bit signed integer type.
constexpr NumericType square(NumericType n) noexcept
Returns the square of its argument.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
T size(T... args)
virtual int32 getPluginIDForMainBusConfig(const AudioChannelSet &mainInputLayout, const AudioChannelSet &mainOutputLayout, bool idForAudioSuite) const
AAX plug-ins need to report a unique "plug-in id" for every audio layout configuration that your Audi...
virtual String getPageFileName() const
Returns an optional filename (including extension) for a page file to be used.
typedef size_t