@@ -118,6 +118,42 @@ static const String& getPluginURI()
118
118
return pluginURI;
119
119
}
120
120
121
+ /* * Queries all available plugin audio ports */
122
+ void findMaxTotalChannels (AudioProcessor* const filter, int & maxTotalIns, int & maxTotalOuts)
123
+ {
124
+ filter->enableAllBuses ();
125
+
126
+ #ifdef JucePlugin_PreferredChannelConfigurations
127
+ int configs[][2 ] = { JucePlugin_PreferredChannelConfigurations };
128
+ maxTotalIns = maxTotalOuts = 0 ;
129
+
130
+ for (auto & config : configs)
131
+ {
132
+ maxTotalIns = jmax (maxTotalIns, config[0 ]);
133
+ maxTotalOuts = jmax (maxTotalOuts, config[1 ]);
134
+ }
135
+ #else
136
+ auto numInputBuses = filter->getBusCount (true );
137
+ auto numOutputBuses = filter->getBusCount (false );
138
+
139
+ if (numInputBuses > 1 || numOutputBuses > 1 )
140
+ {
141
+ maxTotalIns = maxTotalOuts = 0 ;
142
+
143
+ for (int i = 0 ; i < numInputBuses; ++i)
144
+ maxTotalIns += filter->getChannelCountOfBus (true , i);
145
+
146
+ for (int i = 0 ; i < numOutputBuses; ++i)
147
+ maxTotalOuts += filter->getChannelCountOfBus (false , i);
148
+ }
149
+ else
150
+ {
151
+ maxTotalIns = numInputBuses > 0 ? filter->getBus (true , 0 )->getMaxSupportedChannels (64 ) : 0 ;
152
+ maxTotalOuts = numOutputBuses > 0 ? filter->getBus (false , 0 )->getMaxSupportedChannels (64 ) : 0 ;
153
+ }
154
+ #endif
155
+ }
156
+
121
157
static Array<String> usedSymbols;
122
158
123
159
/* * Converts a parameter name to an LV2 compatible symbol. */
@@ -507,7 +543,10 @@ const String makePresetsFile (AudioProcessor* const filter)
507
543
void createLv2Files (const char * basename)
508
544
{
509
545
const ScopedJuceInitialiser_GUI juceInitialiser;
510
- ScopedPointer<AudioProcessor> filter (createPluginFilterOfType (AudioProcessor::wrapperType_LV2));
546
+ ScopedPointer<AudioProcessor> filter (createPluginFilterOfType (AudioProcessor::wrapperType_LV2));
547
+
548
+ int maxNumInputChannels, maxNumOutputChannels;
549
+ findMaxTotalChannels (filter, maxNumInputChannels, maxNumOutputChannels);
511
550
512
551
String binary (basename);
513
552
String binaryTTL (binary + " .ttl" );
@@ -520,7 +559,7 @@ void createLv2Files(const char* basename)
520
559
521
560
std::cout << " Writing " << binary << " .ttl..." ; std::cout.flush ();
522
561
std::fstream plugin (binaryTTL.toUTF8 (), std::ios::out);
523
- plugin << makePluginFile (filter, filter-> getTotalNumInputChannels (), filter-> getTotalNumOutputChannels () ) << std::endl;
562
+ plugin << makePluginFile (filter, maxNumInputChannels, maxNumOutputChannels ) << std::endl;
524
563
plugin.close ();
525
564
std::cout << " done!" << std::endl;
526
565
@@ -1153,10 +1192,7 @@ class JuceLv2Wrapper : public AudioPlayHead
1153
1192
}
1154
1193
jassert (filter != nullptr );
1155
1194
1156
- // LV2 does not support disabling buses: so always enable all of them
1157
- filter->enableAllBuses ();
1158
-
1159
- findMaxTotalChannels (numInChans, numOutChans);
1195
+ findMaxTotalChannels (filter, numInChans, numOutChans);
1160
1196
1161
1197
// You must at least have some channels
1162
1198
jassert (filter->isMidiEffect () || (numInChans > 0 || numOutChans > 0 ));
@@ -1276,40 +1312,6 @@ class JuceLv2Wrapper : public AudioPlayHead
1276
1312
lastControlValues.clear ();
1277
1313
}
1278
1314
1279
- // ==============================================================================
1280
- void findMaxTotalChannels (int & maxTotalIns, int & maxTotalOuts)
1281
- {
1282
- #ifdef JucePlugin_PreferredChannelConfigurations
1283
- int configs[][2 ] = { JucePlugin_PreferredChannelConfigurations };
1284
- maxTotalIns = maxTotalOuts = 0 ;
1285
-
1286
- for (auto & config : configs)
1287
- {
1288
- maxTotalIns = jmax (maxTotalIns, config[0 ]);
1289
- maxTotalOuts = jmax (maxTotalOuts, config[1 ]);
1290
- }
1291
- #else
1292
- auto numInputBuses = filter->getBusCount (true );
1293
- auto numOutputBuses = filter->getBusCount (false );
1294
-
1295
- if (numInputBuses > 1 || numOutputBuses > 1 )
1296
- {
1297
- maxTotalIns = maxTotalOuts = 0 ;
1298
-
1299
- for (int i = 0 ; i < numInputBuses; ++i)
1300
- maxTotalIns += filter->getChannelCountOfBus (true , i);
1301
-
1302
- for (int i = 0 ; i < numOutputBuses; ++i)
1303
- maxTotalOuts += filter->getChannelCountOfBus (false , i);
1304
- }
1305
- else
1306
- {
1307
- maxTotalIns = numInputBuses > 0 ? filter->getBus (true , 0 )->getMaxSupportedChannels (64 ) : 0 ;
1308
- maxTotalOuts = numOutputBuses > 0 ? filter->getBus (false , 0 )->getMaxSupportedChannels (64 ) : 0 ;
1309
- }
1310
- #endif
1311
- }
1312
-
1313
1315
// ==============================================================================
1314
1316
// LV2 core calls
1315
1317
0 commit comments