@@ -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+
496512bool 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
536566std::string EarSceneMasterVst::vstName = admplug::EARPluginSuite::SCENEMASTER_PLUGIN_NAME;
0 commit comments