| 405 | IMPLEMENT_FUNKNOWN_METHODS(SingleInputParameterValue, Steinberg::Vst::IParamValueQueue, Steinberg::Vst::IParamValueQueue::iid); |
| 406 | |
| 407 | VST3Wrapper::VST3Wrapper(VST3::Hosting::Module& module, const VST3::Hosting::ClassInfo& effectClassInfo) |
| 408 | : mModule{ module } |
| 409 | , mEffectClassInfo { effectClassInfo } |
| 410 | { |
| 411 | using namespace Steinberg; |
| 412 | |
| 413 | const auto& pluginFactory = module.getFactory(); |
| 414 | |
| 415 | auto effectComponent = pluginFactory.createInstance<Vst::IComponent>(effectClassInfo.ID()); |
| 416 | if(!effectComponent) |
| 417 | throw std::runtime_error("Cannot create VST3 effect component"); |
| 418 | if(effectComponent->initialize(&AudacityVst3HostApplication::Get()) != kResultOk) |
| 419 | throw std::runtime_error("Cannot initialize VST3 effect component"); |
| 420 | |
| 421 | auto audioProcessor = FUnknownPtr<Vst::IAudioProcessor>(effectComponent); |
| 422 | if(!audioProcessor) |
| 423 | //It's stated that "This interface must always be supported by audio processing plug-ins." |
| 424 | throw std::runtime_error("VST3 plugin does not provide audio processor interface"); |
| 425 | |
| 426 | if(audioProcessor->canProcessSampleSize(Vst::kSample32) != kResultTrue) |
| 427 | throw std::runtime_error("32-bit sample size not supported"); |
| 428 | |
| 429 | mEffectComponent = effectComponent; |
| 430 | mAudioProcessor = audioProcessor; |
| 431 | |
| 432 | auto editController = FUnknownPtr<Vst::IEditController>(mEffectComponent); |
| 433 | if(editController.get() == nullptr) |
| 434 | { |
| 435 | TUID controllerCID; |
| 436 | |
| 437 | if (mEffectComponent->getControllerClassId (controllerCID) == kResultTrue) |
| 438 | editController = pluginFactory.createInstance<Vst::IEditController>(VST3::UID(controllerCID)); |
| 439 | } |
| 440 | |
| 441 | if(editController.get() == nullptr) |
| 442 | throw std::runtime_error("Failed to instantiate edit controller"); |
| 443 | |
| 444 | mEditController = editController; |
| 445 | |
| 446 | mEditController->initialize(&AudacityVst3HostApplication::Get()); |
| 447 | |
| 448 | mComponentHandler = owned(safenew ComponentHandler(*this)); |
| 449 | mEditController->setComponentHandler(mComponentHandler); |
| 450 | |
| 451 | const auto componentConnectionPoint = FUnknownPtr<Vst::IConnectionPoint>{ mEffectComponent }; |
| 452 | const auto controllerConnectionPoint = FUnknownPtr<Vst::IConnectionPoint>{ mEditController }; |
| 453 | |
| 454 | if (componentConnectionPoint && controllerConnectionPoint) |
| 455 | { |
| 456 | mComponentConnectionProxy = owned(safenew internal::ConnectionProxy(componentConnectionPoint)); |
| 457 | mControllerConnectionProxy = owned(safenew internal::ConnectionProxy(controllerConnectionPoint)); |
| 458 | |
| 459 | mComponentConnectionProxy->connect(controllerConnectionPoint); |
| 460 | mControllerConnectionProxy->connect(componentConnectionPoint); |
| 461 | } |
| 462 | |
| 463 | if(GetCache(mEffectClassInfo.ID()) == nullptr) |
| 464 | { |
nothing calls this directly
no test coverage detected