LMMS
Loading...
Searching...
No Matches
juce_VSTCommon.h
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
29//==============================================================================
34struct SpeakerMappings : private AudioChannelSet // (inheritance only to give easier access to items in the namespace)
35{
37 struct Mapping
38 {
41
42 bool matches (const Array<ChannelType>& chans) const noexcept
43 {
44 auto n = static_cast<int> (sizeof (channels) / sizeof (ChannelType));
45
46 for (int i = 0; i < n; ++i)
47 {
48 if (channels[i] == unknown) return (i == chans.size());
49 if (i == chans.size()) return (channels[i] == unknown);
50
51 if (channels[i] != chans.getUnchecked (i))
52 return false;
53 }
54
55 return true;
56 }
57 };
58
59 static AudioChannelSet vstArrangementTypeToChannelSet (int32 arr, int fallbackNumChannels)
60 {
78
79 for (const Mapping* m = getMappings(); m->vst2 != Vst2::vstSpeakerConfigTypeEmpty; ++m)
80 {
81 if (m->vst2 == arr)
82 {
84
85 for (int i = 0; m->channels[i] != 0; ++i)
86 s.addChannel (m->channels[i]);
87
88 return s;
89 }
90 }
91
92 return AudioChannelSet::discreteChannels (fallbackNumChannels);
93 }
94
99
101 {
119
122
123 auto chans = channels.getChannelTypes();
124
125 for (auto* m = getMappings(); m->vst2 != Vst2::vstSpeakerConfigTypeEmpty; ++m)
126 if (m->matches (chans))
127 return m->vst2;
128
130 }
131
133 {
135 result.numberOfChannels = channels.size();
136
137 for (int i = 0; i < result.numberOfChannels; ++i)
138 {
139 auto& speaker = result.speakers[i];
140
141 zeromem (&speaker, sizeof (Vst2::VstIndividualSpeakerInfo));
142 speaker.type = getSpeakerType (channels.getTypeOfChannel (i));
143 }
144 }
145
148 {
149 public:
154
156 {
157 operator= (vstConfig);
158 }
159
161 {
162 operator= (other.get());
163 }
164
166 : storage (std::move (other.storage))
167 {
168 other.clear();
169 }
170
172 {
173 auto numberOfChannels = channels.size();
174 Vst2::VstSpeakerConfiguration& dst = *allocate (numberOfChannels);
175
177 dst.numberOfChannels = numberOfChannels;
178
179 for (int i = 0; i < dst.numberOfChannels; ++i)
180 {
182
183 zeromem (&speaker, sizeof (Vst2::VstIndividualSpeakerInfo));
184 speaker.type = getSpeakerType (channels.getTypeOfChannel (i));
185 }
186 }
187
188 VstSpeakerConfigurationHolder& operator= (const VstSpeakerConfigurationHolder& vstConfig) { return operator=(vstConfig.get()); }
190 {
192
193 dst.type = vstConfig.type;
194 dst.numberOfChannels = vstConfig.numberOfChannels;
195
196 for (int i = 0; i < dst.numberOfChannels; ++i)
197 dst.speakers[i] = vstConfig.speakers[i];
198
199 return *this;
200 }
201
203 {
204 storage = std::move (vstConfig.storage);
205 vstConfig.clear();
206
207 return *this;
208 }
209
210 const Vst2::VstSpeakerConfiguration& get() const { return *storage.get(); }
211
212 private:
214
216
218 {
219 auto arrangementSize = (size_t) (jmax (8, numChannels) - 8) * sizeof (Vst2::VstIndividualSpeakerInfo)
221
222 storage.malloc (1, arrangementSize);
223 return storage.get();
224 }
225
226 void clear()
227 {
229
231 dst.numberOfChannels = 0;
232 }
233 };
234
236 {
237 static const Mapping mappings[] =
238 {
269 };
270
271 return mappings;
272 }
273
275 {
276 static const std::map<AudioChannelSet::ChannelType, int32> speakerTypeMap =
277 {
297 };
298
299 if (speakerTypeMap.find (type) == speakerTypeMap.end())
300 return 0;
301
302 return speakerTypeMap.at (type);
303 }
304};
305
306} // namespace juce
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition juce_Array.h:56
static AudioChannelSet JUCE_CALLTYPE create7point1()
Definition juce_AudioChannelSet.cpp:464
static AudioChannelSet JUCE_CALLTYPE quadraphonic()
Definition juce_AudioChannelSet.cpp:466
static AudioChannelSet JUCE_CALLTYPE create5point0()
Definition juce_AudioChannelSet.cpp:456
static AudioChannelSet JUCE_CALLTYPE create6point0()
Definition juce_AudioChannelSet.cpp:458
static AudioChannelSet JUCE_CALLTYPE create6point1Music()
Definition juce_AudioChannelSet.cpp:461
static AudioChannelSet JUCE_CALLTYPE disabled()
Definition juce_AudioChannelSet.cpp:450
static AudioChannelSet JUCE_CALLTYPE mono()
Definition juce_AudioChannelSet.cpp:451
BigInteger channels
Definition juce_AudioChannelSet.h:515
static AudioChannelSet JUCE_CALLTYPE createLRS()
Definition juce_AudioChannelSet.cpp:454
static AudioChannelSet JUCE_CALLTYPE stereo()
Definition juce_AudioChannelSet.cpp:452
ChannelType
Definition juce_AudioChannelSet.h:317
@ topFrontRight
Definition juce_AudioChannelSet.h:338
@ topFrontLeft
Definition juce_AudioChannelSet.h:336
@ right
Definition juce_AudioChannelSet.h:322
@ leftSurround
Definition juce_AudioChannelSet.h:327
@ topRearLeft
Definition juce_AudioChannelSet.h:339
@ surround
Definition juce_AudioChannelSet.h:332
@ unknown
Definition juce_AudioChannelSet.h:318
@ centre
Definition juce_AudioChannelSet.h:323
@ rightSurroundRear
Definition juce_AudioChannelSet.h:344
@ rightSurround
Definition juce_AudioChannelSet.h:328
@ topRearCentre
Definition juce_AudioChannelSet.h:340
@ topMiddle
Definition juce_AudioChannelSet.h:335
@ topFrontCentre
Definition juce_AudioChannelSet.h:337
@ topRearRight
Definition juce_AudioChannelSet.h:341
@ LFE2
Definition juce_AudioChannelSet.h:342
@ rightCentre
Definition juce_AudioChannelSet.h:330
@ leftCentre
Definition juce_AudioChannelSet.h:329
@ leftSurroundRear
Definition juce_AudioChannelSet.h:343
@ left
Definition juce_AudioChannelSet.h:321
@ LFE
Definition juce_AudioChannelSet.h:326
static AudioChannelSet JUCE_CALLTYPE create6point1()
Definition juce_AudioChannelSet.cpp:459
static AudioChannelSet JUCE_CALLTYPE create5point1()
Definition juce_AudioChannelSet.cpp:457
static AudioChannelSet JUCE_CALLTYPE create7point0SDDS()
Definition juce_AudioChannelSet.cpp:463
static AudioChannelSet JUCE_CALLTYPE create6point0Music()
Definition juce_AudioChannelSet.cpp:460
static AudioChannelSet JUCE_CALLTYPE create7point1SDDS()
Definition juce_AudioChannelSet.cpp:465
static AudioChannelSet JUCE_CALLTYPE create7point0()
Definition juce_AudioChannelSet.cpp:462
static AudioChannelSet JUCE_CALLTYPE createLCRS()
Definition juce_AudioChannelSet.cpp:455
static AudioChannelSet JUCE_CALLTYPE discreteChannels(int numChannels)
Definition juce_AudioChannelSet.cpp:504
static AudioChannelSet JUCE_CALLTYPE createLCR()
Definition juce_AudioChannelSet.cpp:453
Definition juce_HeapBlock.h:87
Vst2::VstSpeakerConfiguration * allocate(int numChannels)
Definition juce_VSTCommon.h:217
HeapBlock< Vst2::VstSpeakerConfiguration > storage
Definition juce_VSTCommon.h:215
VstSpeakerConfigurationHolder(const VstSpeakerConfigurationHolder &other)
Definition juce_VSTCommon.h:160
VstSpeakerConfigurationHolder(VstSpeakerConfigurationHolder &&other)
Definition juce_VSTCommon.h:165
VstSpeakerConfigurationHolder(const AudioChannelSet &channels)
Definition juce_VSTCommon.h:171
VstSpeakerConfigurationHolder(const Vst2::VstSpeakerConfiguration &vstConfig)
Definition juce_VSTCommon.h:155
void clear()
Definition juce_VSTCommon.h:226
VstSpeakerConfigurationHolder()
Definition juce_VSTCommon.h:150
VstSpeakerConfigurationHolder & operator=(const VstSpeakerConfigurationHolder &vstConfig)
Definition juce_VSTCommon.h:188
const Vst2::VstSpeakerConfiguration & get() const
Definition juce_VSTCommon.h:210
unsigned * m
Definition inflate.c:1559
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition juce_LeakedObjectDetector.h:138
Definition juce_VSTMidiEventList.h:29
@ vstSpeakerConfigTypeLRCLfeLsRsCsSlSr
Definition juce_VSTMidiEventList.h:489
@ vstSpeakerConfigTypeLsRs
Definition juce_VSTMidiEventList.h:464
@ vstSpeakerConfigTypeLRLfeS
Definition juce_VSTMidiEventList.h:471
@ vstSpeakerConfigTypeLRCLfeLsRsTflTfcTfrTrlTrrLfe2
Definition juce_VSTMidiEventList.h:490
@ vstSpeakerConfigTypeLRCLfeS
Definition juce_VSTMidiEventList.h:474
@ vstSpeakerConfigTypeLRCLsRs
Definition juce_VSTMidiEventList.h:476
@ vstSpeakerConfigTypeLRCLsRsLcRcCs
Definition juce_VSTMidiEventList.h:486
@ vstSpeakerConfigTypeLRCLsRsCsSlSr
Definition juce_VSTMidiEventList.h:487
@ vstSpeakerConfigTypeLRLfeLsRsSlSr
Definition juce_VSTMidiEventList.h:481
@ vstSpeakerConfigTypeLRLsRs
Definition juce_VSTMidiEventList.h:473
@ vstSpeakerConfigTypeLcRc
Definition juce_VSTMidiEventList.h:465
@ vstSpeakerConfigTypeLRS
Definition juce_VSTMidiEventList.h:469
@ vstSpeakerConfigTypeLRC
Definition juce_VSTMidiEventList.h:468
@ vstSpeakerConfigTypeLRCLfeLsRsCs
Definition juce_VSTMidiEventList.h:480
@ vstSpeakerConfigTypeUser
Definition juce_VSTMidiEventList.h:460
@ vstSpeakerConfigTypeSlSr
Definition juce_VSTMidiEventList.h:466
@ vstSpeakerConfigTypeCLfe
Definition juce_VSTMidiEventList.h:467
@ vstSpeakerConfigTypeLRCLfe
Definition juce_VSTMidiEventList.h:470
@ vstSpeakerConfigTypeLRCLsRsLcRc
Definition juce_VSTMidiEventList.h:482
@ vstSpeakerConfigTypeMono
Definition juce_VSTMidiEventList.h:462
@ vstSpeakerConfigTypeLRLsRsSlSr
Definition juce_VSTMidiEventList.h:479
@ vstSpeakerConfigTypeLRCLfeLsRsLcRcCs
Definition juce_VSTMidiEventList.h:488
@ vstSpeakerConfigTypeLRCLsRsSlSr
Definition juce_VSTMidiEventList.h:483
@ vstSpeakerConfigTypeLRCLfeLsRs
Definition juce_VSTMidiEventList.h:477
@ vstSpeakerConfigTypeLRCLsRsCs
Definition juce_VSTMidiEventList.h:478
@ vstSpeakerConfigTypeLRCS
Definition juce_VSTMidiEventList.h:472
@ vstSpeakerConfigTypeLR
Definition juce_VSTMidiEventList.h:463
@ vstSpeakerConfigTypeLRLfeLsRs
Definition juce_VSTMidiEventList.h:475
@ vstSpeakerConfigTypeLRCLfeLsRsSlSr
Definition juce_VSTMidiEventList.h:485
@ vstSpeakerConfigTypeEmpty
Definition juce_VSTMidiEventList.h:461
@ vstSpeakerConfigTypeLRCLfeLsRsLcRc
Definition juce_VSTMidiEventList.h:484
@ vstIndividualSpeakerTypeLFE
Definition juce_VSTMidiEventList.h:428
@ vstIndividualSpeakerTypeCentre
Definition juce_VSTMidiEventList.h:427
@ vstIndividualSpeakerTypeLeftCentre
Definition juce_VSTMidiEventList.h:431
@ vstIndividualSpeakerTypeRight
Definition juce_VSTMidiEventList.h:426
@ vstIndividualSpeakerTypeTopRearCentre
Definition juce_VSTMidiEventList.h:442
@ vstIndividualSpeakerTypeTopFrontCentre
Definition juce_VSTMidiEventList.h:439
@ vstIndividualSpeakerTypeTopRearLeft
Definition juce_VSTMidiEventList.h:441
@ vstIndividualSpeakerTypeLFE2
Definition juce_VSTMidiEventList.h:444
@ vstIndividualSpeakerTypeSurround
Definition juce_VSTMidiEventList.h:433
@ vstIndividualSpeakerTypeLeftSurround
Definition juce_VSTMidiEventList.h:429
@ vstIndividualSpeakerTypeTopMiddle
Definition juce_VSTMidiEventList.h:437
@ vstIndividualSpeakerTypeLeft
Definition juce_VSTMidiEventList.h:425
@ vstIndividualSpeakerTypeTopFrontLeft
Definition juce_VSTMidiEventList.h:438
@ vstIndividualSpeakerTypeRightRearSurround
Definition juce_VSTMidiEventList.h:436
@ vstIndividualSpeakerTypeTopFrontRight
Definition juce_VSTMidiEventList.h:440
@ vstIndividualSpeakerTypeLeftRearSurround
Definition juce_VSTMidiEventList.h:435
@ vstIndividualSpeakerTypeTopRearRight
Definition juce_VSTMidiEventList.h:443
@ vstIndividualSpeakerTypeRightCentre
Definition juce_VSTMidiEventList.h:432
@ vstIndividualSpeakerTypeRightSurround
Definition juce_VSTMidiEventList.h:430
Definition carla_juce.cpp:31
signed int int32
Definition juce_MathsFunctions.h:43
void zeromem(void *memory, size_t numBytes) noexcept
Definition juce_Memory.h:28
Definition juce_Uuid.h:141
Definition juce_VSTMidiEventList.h:411
int32 type
Definition juce_VSTMidiEventList.h:417
Definition juce_VSTMidiEventList.h:452
int32 numberOfChannels
Definition juce_VSTMidiEventList.h:454
int32 type
Definition juce_VSTMidiEventList.h:453
VstIndividualSpeakerInfo speakers[8]
Definition juce_VSTMidiEventList.h:455
Definition juce_VSTInterface.h:451
Definition juce_VSTCommon.h:38
int32 vst2
Definition juce_VSTCommon.h:39
ChannelType channels[13]
Definition juce_VSTCommon.h:40
bool matches(const Array< ChannelType > &chans) const noexcept
Definition juce_VSTCommon.h:42
Definition juce_VSTCommon.h:35
static AudioChannelSet vstArrangementTypeToChannelSet(const Vst2::VstSpeakerConfiguration &arr)
Definition juce_VSTCommon.h:95
static const Mapping * getMappings() noexcept
Definition juce_VSTCommon.h:235
static void channelSetToVstArrangement(const AudioChannelSet &channels, Vst2::VstSpeakerConfiguration &result)
Definition juce_VSTCommon.h:132
static AudioChannelSet vstArrangementTypeToChannelSet(int32 arr, int fallbackNumChannels)
Definition juce_VSTCommon.h:59
static int32 channelSetToVstArrangementType(AudioChannelSet channels)
Definition juce_VSTCommon.h:100
static int32 getSpeakerType(AudioChannelSet::ChannelType type) noexcept
Definition juce_VSTCommon.h:274
int n
Definition crypt.c:458
int result
Definition process.c:1455