Skip to content

Commit 1c9b87a

Browse files
committed
Fix DS width not considered on finding input channels
1 parent 31b4d61 commit 1c9b87a

File tree

5 files changed

+55
-17
lines changed

5 files changed

+55
-17
lines changed

reaper-adm-extension/src/reaper_adm/exportaction_admsource-earvst.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,11 @@ std::vector<std::shared_ptr<PluginInstance>> EarVstExportSources::getEarInputPlu
366366
if(EarInputVst::isInputPlugin(api, trk, vstPos)) {
367367
auto pluginInst = std::make_shared<EarInputVst>(trk, vstPos, api);
368368
auto pluginTrackMapping = pluginInst->getTrackMapping();
369-
if(pluginTrackMapping == trackMapping) {
369+
auto pluginWidth = pluginInst->getWidth();
370+
auto pluginStartCh = pluginTrackMapping;
371+
auto pluginEndCh = pluginTrackMapping + pluginWidth - 1;
372+
373+
if(trackMapping >= pluginStartCh && trackMapping <= pluginEndCh) {
370374
insts.push_back(std::make_shared<PluginInstance>(trk, vstPos, api));
371375
}
372376
}
@@ -479,20 +483,32 @@ bool EarInputVst::vstPosIsObjectVst(ReaperAPI const& api, MediaTrack *trk, int v
479483
return (strcmp(name, getObjectVstCompName()) == 0);
480484
}
481485

482-
bool EarInputVst::isInputPlugin(char * vstName)
486+
bool EarInputVst::isObjectPlugin(std::string vstNameStr)
483487
{
484-
auto vstNameStr = std::string(vstName);
485488
// Name only
486489
if(vstNameStr == objectVstName) return true;
490+
// Comparison name (includes VST3: and ends with company name and channel count)
491+
getObjectVstCompName(); // need to ensure generated
492+
if (strncmp (vstNameStr.c_str(), getObjectVstCompName(), objectVstCompNameLen) == 0) return true;
493+
return false;
494+
}
495+
496+
bool EarInputVst::isDirectSpeakersPlugin(std::string vstNameStr)
497+
{
498+
// Name only
487499
if(vstNameStr == directSpeakersVstName) return true;
488500
// Comparison name (includes VST3: and ends with company name and channel count)
489501
getDirectSpeakersVstCompName(); // need to ensure generated
490-
if (strncmp (vstName, getDirectSpeakersVstCompName(), directSpeakersVstCompNameLen) == 0) return true;
491-
getObjectVstCompName(); // need to ensure generated
492-
if (strncmp (vstName, getObjectVstCompName(), objectVstCompNameLen) == 0) return true;
502+
if (strncmp (vstNameStr.c_str(), getDirectSpeakersVstCompName(), directSpeakersVstCompNameLen) == 0) return true;
493503
return false;
494504
}
495505

506+
bool EarInputVst::isInputPlugin(char * vstName)
507+
{
508+
auto vstNameStr = std::string(vstName);
509+
return isObjectPlugin(vstNameStr) || isDirectSpeakersPlugin(vstNameStr);
510+
}
511+
496512
bool EarInputVst::isInputPlugin(ReaperAPI const& api, MediaTrack *trk, int vstPos) {
497513
if(vstPosIsObjectVst(api, trk, vstPos)) return true;
498514
if(vstPosIsDirectSpeakersVst(api, trk, vstPos)) return true;
@@ -531,6 +547,20 @@ int EarInputVst::getTrackMapping()
531547
return *optVal;
532548
}
533549

550+
int EarInputVst::getWidth()
551+
{
552+
if(isObjectPlugin(name)) return 1;
553+
if(!isDirectSpeakersPlugin(name)) return 0;
554+
555+
assert(paramSpeakerLayout);
556+
auto speakerLayout = getParameterWithConvertToInt(*paramSpeakerLayout);
557+
assert(speakerLayout.has_value());
558+
559+
int trackWidth = speakerLayout.has_value()? EARPluginSuite::countChannelsInSpeakerLayout(*speakerLayout) : 0;
560+
561+
return trackWidth;
562+
}
563+
534564
// EarSceneMasterVst
535565

536566
std::string EarSceneMasterVst::vstName = admplug::EARPluginSuite::SCENEMASTER_PLUGIN_NAME;

reaper-adm-extension/src/reaper_adm/exportaction_admsource-earvst.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class EarInputVst : public PluginInstance
6060
~EarInputVst() {};
6161

6262
int getTrackMapping();
63-
// TODO: Probably gonna need a "getWidth" (or similar) method too at some point
63+
int getWidth();
6464

6565
// Statics
6666

@@ -78,11 +78,15 @@ class EarInputVst : public PluginInstance
7878
static std::vector<int> trackObjectVstIndexes(ReaperAPI const& api, MediaTrack *trk);
7979
static bool vstPosIsObjectVst(ReaperAPI const& api, MediaTrack *trk, int vstPos);
8080

81+
static bool isObjectPlugin(std::string vstNameStr);
82+
static bool isDirectSpeakersPlugin(std::string vstNameStr);
8183
static bool isInputPlugin(char* vstName);
8284
static bool isInputPlugin(ReaperAPI const& api, MediaTrack *trk, int vstPos);
8385

8486
private:
87+
// TODO: Fix hard-coded values - pull from plugin suite
8588
std::unique_ptr<PluginParameter> paramTrackMapping{ createPluginParameter(0, { -1.0, 63.0 }) };
89+
std::unique_ptr<PluginParameter> paramSpeakerLayout{ createPluginParameter(1, { -1.0, 13.0 }) };
8690

8791
// Statics
8892

reaper-adm-extension/src/reaper_adm/exportaction_pcmsink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PCM_sink_adm::PCM_sink_adm(std::shared_ptr<ReaperAPI> api, const char *fn, void
6868
// Check other errors (warnings/infos are fine... we can continue with those)
6969
auto errors = admExportHandler->generateExportErrorStrings();
7070
if(errors.size() > 0) {
71-
auto op = std::string("Can not render to the following issues:\r\n");
71+
auto op = std::string("Can not render due to the following issues:\r\n");
7272
for(auto& error : errors) {
7373
op.append("\r\n");
7474
op.append(error);

reaper-adm-extension/src/reaper_adm/pluginsuite_ear.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,6 @@ namespace {
135135
return pfData->relatedChannelFormats.size();
136136
}
137137

138-
int countChannelsInSpeakerLayout(int slIndex) {
139-
auto pfId = getPackFormatIdFromSpeakerLayoutIndex(slIndex);
140-
if(pfId.has_value()) {
141-
return countChannelsInPackFormat(*pfId);
142-
}
143-
return 0;
144-
}
145-
146138
std::vector<int> determineUsedObjectTrackMappingValues(PluginInstance& plugin) {
147139
auto param = createPluginParameter(static_cast<int>(EarObjectParameters::TRACK_MAPPING), { TRACK_MAPPING_MIN, TRACK_MAPPING_MAX });
148140
auto trackMapping = plugin.getParameterWithConvertToInt(*(param.get()));
@@ -163,7 +155,7 @@ namespace {
163155
auto speakerLayoutParam = createPluginParameter(static_cast<int>(EarDirectSpeakersParameters::SPEAKER_LAYOUT), { SPEAKER_LAYOUT_MIN, SPEAKER_LAYOUT_MAX });
164156
auto speakerLayout = plugin.getParameterWithConvertToInt(*(speakerLayoutParam.get()));
165157
assert(speakerLayout.has_value());
166-
int trackWidth = speakerLayout.has_value()? countChannelsInSpeakerLayout(*speakerLayout) : 0;
158+
int trackWidth = speakerLayout.has_value()? EARPluginSuite::countChannelsInSpeakerLayout(*speakerLayout) : 0;
167159
if(trackWidth <= 0) trackWidth = 1; // Track mapping is single channel by default.
168160

169161
if(trackMapping.has_value() && *trackMapping >= 0) {
@@ -400,6 +392,15 @@ bool admplug::EARPluginSuite::representAdmStructureWithGroups(ReaperAPI const &
400392
return false; // Scene master does this!
401393
}
402394

395+
int admplug::EARPluginSuite::countChannelsInSpeakerLayout(int slIndex)
396+
{
397+
auto pfId = getPackFormatIdFromSpeakerLayoutIndex(slIndex);
398+
if(pfId.has_value()) {
399+
return countChannelsInPackFormat(*pfId);
400+
}
401+
return 0;
402+
}
403+
403404
std::vector<std::unique_ptr<PluginParameter>> const& EARPluginSuite::automatedObjectPluginParameters()
404405
{
405406
auto static parameters = createAutomatedObjectPluginParameters();

reaper-adm-extension/src/reaper_adm/pluginsuite_ear.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ namespace admplug {
3737
static const char* DIRECTSPEAKERS_METADATA_PLUGIN_NAME;
3838
static const char* SCENEMASTER_PLUGIN_NAME;
3939
static const char* RENDERER_PLUGIN_NAME;
40+
41+
static int countChannelsInSpeakerLayout(int slIndex);
42+
4043
private:
4144
std::vector<std::unique_ptr<PluginParameter>> const & automatedObjectPluginParameters();
4245
std::vector<std::unique_ptr<TrackParameter>> const & trackParameters();

0 commit comments

Comments
 (0)