Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
VST3Wrapper Class Reference

#include <VST3Wrapper.h>

Collaboration diagram for VST3Wrapper:
[legend]

Public Member Functions

 VST3Wrapper (VST3::Hosting::Module &module, VST3::UID effectUID)
 
 ~VST3Wrapper ()
 
 VST3Wrapper (const VST3Wrapper &)=delete
 
 VST3Wrapper (VST3Wrapper &&)=delete
 
VST3Wrapperoperator= (const VST3Wrapper &)=delete
 
VST3Wrapperoperator= (VST3Wrapper &&)=delete
 
VST3::Hosting::Module & GetModule () const
 
bool IsActive () const noexcept
 
void FetchSettings (EffectSettings &)
 Fetch state from settings object, may change internal runtime data. More...
 
void StoreSettings (EffectSettings &) const
 Saves current state inside settings object, clears all runtime data. More...
 
bool LoadPreset (Steinberg::IBStream *fileStream)
 
bool SavePreset (Steinberg::IBStream *fileStream) const
 
bool Initialize (EffectSettings &settings, Steinberg::Vst::SampleRate sampleRate, Steinberg::int32 processMode, Steinberg::int32 maxSamplesPerBlock)
 Initializes effect for processing using settings. More...
 
void Finalize (EffectSettings *settings)
 
void ProcessBlockStart (const EffectSettings &settings)
 Prepares effect to process next block with changes written to the settings object. More...
 
void FlushParameters (EffectSettings &settings, bool *hasChanges=nullptr)
 
size_t Process (const float *const *inBlock, float *const *outBlock, size_t blockLen)
 
void SuspendProcessing ()
 
void ResumeProcessing ()
 
void BeginParameterEdit (EffectSettingsAccess &access)
 
void EndParameterEdit ()
 
Steinberg::int32 GetLatencySamples () const
 

Static Public Member Functions

static EffectSettings MakeSettings ()
 
static void LoadSettings (const CommandParameters &parms, EffectSettings &settings)
 
static void SaveSettings (const EffectSettings &settings, CommandParameters &parms)
 
static OptionalMessage LoadUserPreset (const EffectDefinitionInterface &effect, const RegistryPath &name, EffectSettings &settings)
 
static void SaveUserPreset (const EffectDefinitionInterface &effect, const RegistryPath &name, const EffectSettings &settings)
 
static void CopySettingsContents (const EffectSettings &src, EffectSettings &dst)
 

Public Attributes

Steinberg::IPtr< Steinberg::Vst::IAudioProcessor > mAudioProcessor
 
Steinberg::Vst::ProcessSetup mSetup
 
Steinberg::IPtr< Steinberg::Vst::IComponent > mEffectComponent
 
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
 
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mComponentConnectionProxy
 
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mControllerConnectionProxy
 
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
 
std::function< void(Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> ParamChangedHandler
 

Private Member Functions

void ConsumeChanges (const EffectSettings &settings)
 

Private Attributes

EffectSettings mDefaultSettings
 
VST3::Hosting::Module & mModule
 
bool mActive {false}
 
const VST3::UID mEffectUID
 
std::vector< std::pair< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > > mParameters
 
std::unique_ptr< SingleInputParameterValue[]> mParameterQueues
 

Detailed Description

Definition at line 53 of file VST3Wrapper.h.

Constructor & Destructor Documentation

◆ VST3Wrapper() [1/3]

VST3Wrapper::VST3Wrapper ( VST3::Hosting::Module &  module,
VST3::UID  effectUID 
)

Definition at line 380 of file VST3Wrapper.cpp.

381 : mEffectUID(std::move(effectUID))
382 , mModule{ module }
383{
384 using namespace Steinberg;
385
386 //Preinitialize with some default values in case if parameters
387 //flush happens before processing initialized
388 mSetup.maxSamplesPerBlock = 512;
389 mSetup.processMode = Vst::kOffline;
390 mSetup.symbolicSampleSize = Vst::kSample32;
391 mSetup.sampleRate = 44100.0;
392
393 const auto& pluginFactory = module.getFactory();
394
395 auto effectComponent = pluginFactory.createInstance<Vst::IComponent>(mEffectUID);
396 if(!effectComponent)
397 throw std::runtime_error("Cannot create VST3 effect component");
398 if(effectComponent->initialize(&AudacityVst3HostApplication::Get()) != kResultOk)
399 throw std::runtime_error("Cannot initialize VST3 effect component");
400
401 auto audioProcessor = FUnknownPtr<Vst::IAudioProcessor>(effectComponent);
402 if(!audioProcessor)
403 //It's stated that "This interface must always be supported by audio processing plug-ins."
404 throw std::runtime_error("VST3 plugin does not provide audio processor interface");
405
406 if(audioProcessor->canProcessSampleSize(Vst::kSample32) != kResultTrue)
407 throw std::runtime_error("32-bit sample size not supported");
408
409 mEffectComponent = effectComponent;
410 mAudioProcessor = audioProcessor;
411
413 throw std::runtime_error("bus configuration not supported");
414
415 auto editController = FUnknownPtr<Vst::IEditController>(mEffectComponent);
416 if(editController.get() == nullptr)
417 {
418 TUID controllerCID;
419
420 if (mEffectComponent->getControllerClassId (controllerCID) == kResultTrue)
421 editController = pluginFactory.createInstance<Vst::IEditController>(VST3::UID(controllerCID));
422 }
423
424 if(editController.get() == nullptr)
425 throw std::runtime_error("Failed to instantiate edit controller");
426
427 mEditController = editController;
429
430 mComponentHandler = owned(safenew ComponentHandler(*this));
431 mEditController->setComponentHandler(mComponentHandler);
432
433 const auto componentConnectionPoint = FUnknownPtr<Vst::IConnectionPoint>{ mEffectComponent };
434 const auto controllerConnectionPoint = FUnknownPtr<Vst::IConnectionPoint>{ mEditController };
435
436 if (componentConnectionPoint && controllerConnectionPoint)
437 {
438 mComponentConnectionProxy = owned(safenew internal::ConnectionProxy(componentConnectionPoint));
439 mControllerConnectionProxy = owned(safenew internal::ConnectionProxy(controllerConnectionPoint));
440
441 mComponentConnectionProxy->connect(controllerConnectionPoint);
442 mControllerConnectionProxy->connect(componentConnectionPoint);
443 }
444
445 mParameterQueues = std::make_unique<SingleInputParameterValue[]>(mEditController->getParameterCount());
446 mParameters.reserve(mEditController->getParameterCount());
447
448 Steinberg::MemoryStream stateStream;
449 if(mEffectComponent->getState(&stateStream) == kResultOk)
450 {
451 int64 unused;
452 stateStream.seek(0, IBStream::kIBSeekSet, &unused);
453 mEditController->setComponentState(&stateStream);
454 }
455
458
459
460 static_cast<ComponentHandler*>(mComponentHandler.get())
461 ->LoadCurrentParamValues();
462}
#define safenew
Definition: MemoryX.h:10
tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result) SMTG_OVERRIDE
static EffectSettings MakeSettings()
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mControllerConnectionProxy
Definition: VST3Wrapper.h:63
Steinberg::IPtr< Steinberg::Vst::IEditController > mEditController
Definition: VST3Wrapper.h:61
Steinberg::IPtr< Steinberg::Vst::IComponent > mEffectComponent
Definition: VST3Wrapper.h:60
Steinberg::IPtr< Steinberg::Vst::IComponentHandler > mComponentHandler
Definition: VST3Wrapper.h:64
std::unique_ptr< SingleInputParameterValue[]> mParameterQueues
Definition: VST3Wrapper.h:141
VST3::Hosting::Module & mModule
Definition: VST3Wrapper.h:56
void StoreSettings(EffectSettings &) const
Saves current state inside settings object, clears all runtime data.
Steinberg::IPtr< Steinberg::Vst::IConnectionPoint > mComponentConnectionProxy
Definition: VST3Wrapper.h:62
Steinberg::IPtr< Steinberg::Vst::IAudioProcessor > mAudioProcessor
Definition: VST3Wrapper.h:58
Steinberg::Vst::ProcessSetup mSetup
Definition: VST3Wrapper.h:59
std::vector< std::pair< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > > mParameters
Definition: VST3Wrapper.h:136
const VST3::UID mEffectUID
Definition: VST3Wrapper.h:134
EffectSettings mDefaultSettings
Definition: VST3Wrapper.h:55
Host's proxy object between connection points.
bool SetupProcessing(Steinberg::Vst::IComponent &component, Steinberg::Vst::ProcessSetup &setup)

References AudacityVst3HostApplication::Get(), MakeSettings(), mAudioProcessor, mComponentConnectionProxy, mComponentHandler, mControllerConnectionProxy, mDefaultSettings, mEditController, mEffectComponent, mEffectUID, mParameterQueues, mParameters, mSetup, safenew, Steinberg::MemoryStream::seek(), anonymous_namespace{VST3Wrapper.cpp}::SetupProcessing(), and StoreSettings().

Here is the call graph for this function:

◆ ~VST3Wrapper()

VST3Wrapper::~VST3Wrapper ( )

Definition at line 464 of file VST3Wrapper.cpp.

465{
466 using namespace Steinberg;
467
469 mComponentConnectionProxy->disconnect(FUnknownPtr<Vst::IConnectionPoint>(mEditController));
471 mControllerConnectionProxy->disconnect(FUnknownPtr<Vst::IConnectionPoint>(mEffectComponent));
472
474 {
475 mEditController->setComponentHandler(nullptr);
476 mEditController->terminate();
477 }
479 mEffectComponent->terminate();
480}

References mComponentConnectionProxy, mControllerConnectionProxy, mEditController, and mEffectComponent.

◆ VST3Wrapper() [2/3]

VST3Wrapper::VST3Wrapper ( const VST3Wrapper )
delete

◆ VST3Wrapper() [3/3]

VST3Wrapper::VST3Wrapper ( VST3Wrapper &&  )
delete

Member Function Documentation

◆ BeginParameterEdit()

void VST3Wrapper::BeginParameterEdit ( EffectSettingsAccess access)

Definition at line 782 of file VST3Wrapper.cpp.

783{
784 static_cast<ComponentHandler*>(mComponentHandler.get())->SetAccess(&access);
785}

References mComponentHandler.

Referenced by VST3UIValidator::VST3UIValidator().

Here is the caller graph for this function:

◆ ConsumeChanges()

void VST3Wrapper::ConsumeChanges ( const EffectSettings settings)
private

Definition at line 629 of file VST3Wrapper.cpp.

630{
631 const auto& vst3settings = GetSettings(settings);
632 for(auto& p : vst3settings.parameterChanges)
633 {
634 auto it = std::find_if(mParameters.begin(), mParameters.end(), [&p](const auto& v) { return v.first == p.first; });
635 if(it != mParameters.end())
636 it->second = p.second;
637 else
638 mParameters.push_back(p);
639 }
640}
static Settings & settings()
Definition: TrackInfo.cpp:87
const VST3EffectSettings & GetSettings(const EffectSettings &settings)
Definition: VST3Wrapper.cpp:87

References anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), mParameters, and settings().

Referenced by Finalize(), FlushParameters(), Initialize(), and ProcessBlockStart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopySettingsContents()

void VST3Wrapper::CopySettingsContents ( const EffectSettings src,
EffectSettings dst 
)
static

Definition at line 869 of file VST3Wrapper.cpp.

870{
871 auto& from = GetSettings(*const_cast<EffectSettings*>(&src));
872 auto& to = GetSettings(dst);
873
874 //Don't allocate in worker
875 std::swap(from.parameterChanges, to.parameterChanges);
876}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:752
Externalized state of a plug-in.

References anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by VST3Effect::CopySettingsContents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EndParameterEdit()

void VST3Wrapper::EndParameterEdit ( )

Definition at line 787 of file VST3Wrapper.cpp.

788{
789 auto componentHandler = static_cast<ComponentHandler*>(mComponentHandler.get());
790 componentHandler->SetAccess(nullptr);
791}

References mComponentHandler.

Referenced by VST3UIValidator::OnClose().

Here is the caller graph for this function:

◆ FetchSettings()

void VST3Wrapper::FetchSettings ( EffectSettings settings)

Fetch state from settings object, may change internal runtime data.

Definition at line 487 of file VST3Wrapper.cpp.

488{
489 //TODO: perform version check
490 {
491 auto componentHandler = static_cast<ComponentHandler*>(mComponentHandler.get());
492 componentHandler->ResetCache();
493 componentHandler->BeginStateChange(settings);
494 auto cleanup = finally([&] { componentHandler->EndStateChange(); });
495
496 //Restore state
497 const auto* vst3settings = &GetSettings(settings);
498 if(!vst3settings->processorState.has_value())
499 vst3settings = &GetSettings(mDefaultSettings);
500
501 if(vst3settings->processorState.has_value())
502 {
503 auto processorState = PresetsBufferStream::fromString(*vst3settings->processorState);
504 processorState->seek(0, Steinberg::IBStream::kIBSeekSet);
505 if(mEffectComponent->setState(processorState) == Steinberg::kResultOk)
506 {
507 processorState->seek(0, Steinberg::IBStream::kIBSeekSet);
508 if(mEditController->setComponentState(processorState) == Steinberg::kResultOk)
509 {
510 if(vst3settings->controllerState.has_value())
511 {
512 auto controllerState = PresetsBufferStream::fromString(*vst3settings->controllerState);
513 controllerState->seek(0, Steinberg::IBStream::kIBSeekSet);
514 mEditController->setState(controllerState);
515 }
516 }
517 }
518 }
519 }
520 //restore parameters if present
521 auto& vst3setting = GetSettings(settings);
522 for(auto& p : vst3setting.parameterChanges)
523 mEditController->setParamNormalized(p.first, p.second);
524}
static Steinberg::IPtr< PresetsBufferStream > fromString(const wxString &str)
Definition: VST3Utils.cpp:80

References PresetsBufferStream::fromString(), anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), mComponentHandler, mDefaultSettings, mEditController, mEffectComponent, and settings().

Referenced by Initialize(), and VST3UIValidator::UpdateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Finalize()

void VST3Wrapper::Finalize ( EffectSettings settings)

Frees up resources allocated for processing, should be called after processing is complete. Optionally settings object may be passed to update runtime data with current internal state.

Definition at line 607 of file VST3Wrapper.cpp.

608{
609 //Could be FlushParameters but processor is already configured
610 //If no calls to process were performed deliver changes here
611 if(settings != nullptr)
612 {
614 Process(nullptr, nullptr, 0);
615 }
616 mAudioProcessor->setProcessing(false);
617 mEffectComponent->setActive(false);
618 mActive = false;
619
620 if(settings != nullptr)
622}
size_t Process(const float *const *inBlock, float *const *outBlock, size_t blockLen)
void ConsumeChanges(const EffectSettings &settings)

References ConsumeChanges(), mActive, mAudioProcessor, mEffectComponent, Process(), settings(), and StoreSettings().

Here is the call graph for this function:

◆ FlushParameters()

void VST3Wrapper::FlushParameters ( EffectSettings settings,
bool *  hasChanges = nullptr 
)
Parameters
hasChangesoptional output variable, set to true if flushing has changed the DSP model state

Definition at line 651 of file VST3Wrapper.cpp.

652{
653 if(!mActive)
654 {
655 auto componentHandler = static_cast<ComponentHandler*>(mComponentHandler.get());
656 componentHandler->FlushCache(settings);
657
658 const auto doProcessing = !GetSettings(settings).parameterChanges.empty();
659
660 if(hasChanges != nullptr)
661 *hasChanges = doProcessing;
662
663 if(!doProcessing)
664 return;
665
667 mActive = true;
668 if(mEffectComponent->setActive(true) == Steinberg::kResultOk)
669 {
671 if(mAudioProcessor->setProcessing(true) != Steinberg::kResultFalse)
672 {
673 Process(nullptr, nullptr, 0);
674 mAudioProcessor->setProcessing(false);
675 }
676 }
677 mEffectComponent->setActive(false);
678 mActive = false;
679 }
680 else if(hasChanges != nullptr)
681 *hasChanges = false;
682}
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > parameterChanges
Holds the parameter that has been changed since last processing pass.
Definition: VST3Wrapper.cpp:40

References ConsumeChanges(), anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), mActive, mAudioProcessor, mComponentHandler, mEffectComponent, mSetup, anonymous_namespace{VST3Wrapper.cpp}::VST3EffectSettings::parameterChanges, Process(), settings(), and anonymous_namespace{VST3Wrapper.cpp}::SetupProcessing().

Referenced by VST3UIValidator::OnClose(), VST3UIValidator::OnIdle(), and VST3UIValidator::ValidateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLatencySamples()

Steinberg::int32 VST3Wrapper::GetLatencySamples ( ) const

Definition at line 795 of file VST3Wrapper.cpp.

796{
797 return mAudioProcessor->getLatencySamples();
798}

References mAudioProcessor.

◆ GetModule()

VST3::Hosting::Module & VST3Wrapper::GetModule ( ) const
inline

Definition at line 74 of file VST3Wrapper.h.

74{ return mModule; }

References mModule.

◆ Initialize()

bool VST3Wrapper::Initialize ( EffectSettings settings,
Steinberg::Vst::SampleRate  sampleRate,
Steinberg::int32  processMode,
Steinberg::int32  maxSamplesPerBlock 
)

Initializes effect for processing using settings.

Definition at line 574 of file VST3Wrapper.cpp.

575{
576 using namespace Steinberg;
577
578 Vst::ProcessSetup setup = {
579 processMode,
580 Vst::kSample32,
581 maxSamplesPerBlock,
582 sampleRate
583 };
584
585 if(!SetupProcessing(*mEffectComponent.get(), setup))
586 return false;
587
588 mSetup = setup;
589
591
592 if(mEffectComponent->setActive(true) == kResultOk)
593 {
594 if(mAudioProcessor->setProcessing(true) != kResultFalse)
595 {
596 mActive = true;
598 //make zero-flush, to make sure parameters are delivered to the processor...
599 Process(nullptr, nullptr, 0);
601 return true;
602 }
603 }
604 return false;
605}
void FetchSettings(EffectSettings &)
Fetch state from settings object, may change internal runtime data.

References ConsumeChanges(), FetchSettings(), mActive, mAudioProcessor, mEffectComponent, mSetup, Process(), settings(), anonymous_namespace{VST3Wrapper.cpp}::SetupProcessing(), and StoreSettings().

Here is the call graph for this function:

◆ IsActive()

bool VST3Wrapper::IsActive ( ) const
noexcept

Definition at line 482 of file VST3Wrapper.cpp.

483{
484 return mActive;
485}

References mActive.

Referenced by VST3UIValidator::OnIdle(), and anonymous_namespace{VST3Wrapper.cpp}::ComponentHandler::performEdit().

Here is the caller graph for this function:

◆ LoadPreset()

bool VST3Wrapper::LoadPreset ( Steinberg::IBStream *  fileStream)

Definition at line 546 of file VST3Wrapper.cpp.

547{
548 using namespace Steinberg;
549
550 return Vst::PresetFile::loadPreset
551 (
552 fileStream,
553 FUID::fromTUID(mEffectUID.data()),
554 mEffectComponent.get(),
555 mEditController.get()
556 );
557}

References mEditController, mEffectComponent, and mEffectUID.

◆ LoadSettings()

void VST3Wrapper::LoadSettings ( const CommandParameters parms,
EffectSettings settings 
)
static

Definition at line 805 of file VST3Wrapper.cpp.

806{
807 VST3EffectSettings vst3settings;
808
809 if(parms.HasEntry(processorStateKey))
810 {
811 vst3settings.processorState = parms.Read(processorStateKey);
813 vst3settings.controllerState = parms.Read(controllerStateKey);
814 }
815 if(parms.HasEntry(parametersKey))
816 vst3settings.parameterChanges = ParametersFromString(parms.Read(parametersKey));
817
818 std::swap(vst3settings, GetSettings(settings));
819}
virtual bool HasEntry(const wxString &strName) const override
std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > ParametersFromString(const wxString &str)
Definition: VST3Wrapper.cpp:48

References anonymous_namespace{VST3Wrapper.cpp}::controllerStateKey, anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), CommandParameters::HasEntry(), anonymous_namespace{VST3Wrapper.cpp}::ParametersFromString(), anonymous_namespace{VST3Wrapper.cpp}::parametersKey, anonymous_namespace{VST3Wrapper.cpp}::processorStateKey, settings(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by VST3Effect::LoadSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadUserPreset()

OptionalMessage VST3Wrapper::LoadUserPreset ( const EffectDefinitionInterface effect,
const RegistryPath name,
EffectSettings settings 
)
static

Definition at line 833 of file VST3Wrapper.cpp.

835{
836 VST3EffectSettings vst3settings;
837
838 wxString processorStateStr;
839 if(GetConfig(effect, PluginSettings::Private, name, processorStateKey, processorStateStr, wxEmptyString))
840 {
841 vst3settings.processorState = processorStateStr;
842 wxString controllerStateStr;
843 if(GetConfig(effect, PluginSettings::Private, name, controllerStateKey, controllerStateStr, wxEmptyString))
844 vst3settings.controllerState = controllerStateStr;
845 }
846 wxString parametersStr;
847 if(GetConfig(effect, PluginSettings::Private, name, parametersKey, parametersStr, wxEmptyString))
848 vst3settings.parameterChanges = ParametersFromString(parametersStr);
849
850 std::swap(vst3settings, GetSettings(settings));
851 return { nullptr };
852}
const TranslatableString name
Definition: Distortion.cpp:74
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References anonymous_namespace{VST3Wrapper.cpp}::controllerStateKey, PluginSettings::GetConfig(), anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), name, anonymous_namespace{VST3Wrapper.cpp}::ParametersFromString(), anonymous_namespace{VST3Wrapper.cpp}::parametersKey, PluginSettings::Private, anonymous_namespace{VST3Wrapper.cpp}::processorStateKey, settings(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by VST3Effect::LoadUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeSettings()

EffectSettings VST3Wrapper::MakeSettings ( )
static

Definition at line 800 of file VST3Wrapper.cpp.

801{
802 return EffectSettings::Make<VST3EffectSettings>();
803}

Referenced by VST3Effect::MakeSettings(), and VST3Wrapper().

Here is the caller graph for this function:

◆ operator=() [1/2]

VST3Wrapper & VST3Wrapper::operator= ( const VST3Wrapper )
delete

◆ operator=() [2/2]

VST3Wrapper & VST3Wrapper::operator= ( VST3Wrapper &&  )
delete

◆ Process()

size_t VST3Wrapper::Process ( const float *const *  inBlock,
float *const *  outBlock,
size_t  blockLen 
)

Definition at line 684 of file VST3Wrapper.cpp.

685{
686 using namespace Steinberg;
687
688 InputParameterChanges inputParameterChanges(mParameters, mParameterQueues.get());
689 mParameters.clear();
690
691 Vst::ProcessData data;
692 data.processMode = mSetup.processMode;
693 data.symbolicSampleSize = mSetup.symbolicSampleSize;
694 data.inputParameterChanges = &inputParameterChanges;
695
696 static_assert(std::numeric_limits<decltype(blockLen)>::max()
697 >= std::numeric_limits<decltype(data.numSamples)>::max());
698
699 data.numSamples = static_cast<decltype(data.numSamples)>(std::min(
700 blockLen,
701 static_cast<decltype(blockLen)>(mSetup.maxSamplesPerBlock)
702 ));
703
704 data.numInputs = inBlock == nullptr ? 0 : mEffectComponent->getBusCount(Vst::kAudio, Vst::kInput);
705 data.numOutputs = outBlock == nullptr ? 0 : mEffectComponent->getBusCount(Vst::kAudio, Vst::kOutput);
706
707 if(data.numInputs > 0)
708 {
709 int inputBlocksOffset {0};
710
711 data.inputs = static_cast<Vst::AudioBusBuffers*>(
712 alloca(sizeof(Vst::AudioBusBuffers) * data.numInputs));
713
714 for(int busIndex = 0; busIndex < data.numInputs; ++busIndex)
715 {
716 Vst::BusInfo busInfo { };
717 if(mEffectComponent->getBusInfo(Vst::kAudio, Vst::kInput, busIndex, busInfo) != kResultOk)
718 {
719 return 0;
720 }
721 if(busInfo.busType == Vst::kMain)
722 {
723 data.inputs[busIndex].numChannels = busInfo.channelCount;
724 data.inputs[busIndex].channelBuffers32 = const_cast<float**>(inBlock + inputBlocksOffset);
725 inputBlocksOffset += busInfo.channelCount;
726 }
727 else
728 {
729 //aux is not yet supported
730 data.inputs[busIndex].numChannels = 0;
731 data.inputs[busIndex].channelBuffers32 = nullptr;
732 }
733 data.inputs[busIndex].silenceFlags = 0UL;
734 }
735 }
736 if(data.numOutputs > 0)
737 {
738 int outputBlocksOffset {0};
739
740 data.outputs = static_cast<Vst::AudioBusBuffers*>(
741 alloca(sizeof(Vst::AudioBusBuffers) * data.numOutputs));
742 for(int busIndex = 0; busIndex < data.numOutputs; ++busIndex)
743 {
744 Vst::BusInfo busInfo { };
745 if(mEffectComponent->getBusInfo(Vst::kAudio, Vst::kOutput, busIndex, busInfo) != kResultOk)
746 {
747 return 0;
748 }
749 if(busInfo.busType == Vst::kMain)
750 {
751 data.outputs[busIndex].numChannels = busInfo.channelCount;
752 data.outputs[busIndex].channelBuffers32 = const_cast<float**>(outBlock + outputBlocksOffset);
753 outputBlocksOffset += busInfo.channelCount;
754 }
755 else
756 {
757 //aux is not yet supported
758 data.outputs[busIndex].numChannels = 0;
759 data.outputs[busIndex].channelBuffers32 = nullptr;
760 }
761 data.outputs[busIndex].silenceFlags = 0UL;
762 }
763 }
764
765 const auto processResult = mAudioProcessor->process(data);
766
767 return processResult == kResultOk ?
768 data.numSamples : 0;
769}
int min(int a, int b)

References mAudioProcessor, mEffectComponent, min(), mParameterQueues, mParameters, and mSetup.

Referenced by Finalize(), FlushParameters(), and Initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessBlockStart()

void VST3Wrapper::ProcessBlockStart ( const EffectSettings settings)

Prepares effect to process next block with changes written to the settings object.

Definition at line 624 of file VST3Wrapper.cpp.

625{
627}

References ConsumeChanges(), and settings().

Here is the call graph for this function:

◆ ResumeProcessing()

void VST3Wrapper::ResumeProcessing ( )

Definition at line 777 of file VST3Wrapper.cpp.

778{
779 mAudioProcessor->setProcessing(true);
780}

References mAudioProcessor.

◆ SavePreset()

bool VST3Wrapper::SavePreset ( Steinberg::IBStream *  fileStream) const

Definition at line 560 of file VST3Wrapper.cpp.

561{
562 using namespace Steinberg;
563
564 return Vst::PresetFile::savePreset
565 (
566 fileStream,
567 FUID::fromTUID(mEffectUID.data()),
568 mEffectComponent.get(),
569
570 mEditController.get()
571 );
572}

References mEditController, mEffectComponent, and mEffectUID.

◆ SaveSettings()

void VST3Wrapper::SaveSettings ( const EffectSettings settings,
CommandParameters parms 
)
static

Definition at line 821 of file VST3Wrapper.cpp.

822{
823 const auto& vst3settings = GetSettings(settings);
824
825 if(vst3settings.processorState.has_value())
826 parms.Write(processorStateKey, *vst3settings.processorState);
827 if(vst3settings.controllerState.has_value())
828 parms.Write(controllerStateKey, *vst3settings.controllerState);
829 if(!vst3settings.parameterChanges.empty())
830 parms.Write(parametersKey, ParametersToString(vst3settings.parameterChanges));
831}
wxString ParametersToString(const std::map< Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue > &params)
Definition: VST3Wrapper.cpp:71

References anonymous_namespace{VST3Wrapper.cpp}::controllerStateKey, anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), anonymous_namespace{VST3Wrapper.cpp}::parametersKey, anonymous_namespace{VST3Wrapper.cpp}::ParametersToString(), anonymous_namespace{VST3Wrapper.cpp}::processorStateKey, and settings().

Referenced by VST3Effect::SaveSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveUserPreset()

void VST3Wrapper::SaveUserPreset ( const EffectDefinitionInterface effect,
const RegistryPath name,
const EffectSettings settings 
)
static

Definition at line 854 of file VST3Wrapper.cpp.

855{
856 using namespace Steinberg;
857
858 const auto& vst3settings = GetSettings(settings);
859 if(vst3settings.processorState.has_value())
860 {
861 SetConfig(effect, PluginSettings::Private, name, processorStateKey, *vst3settings.processorState);
862 if(vst3settings.controllerState.has_value())
863 SetConfig(effect, PluginSettings::Private, name, controllerStateKey, *vst3settings.controllerState);
864 }
865 if(!vst3settings.parameterChanges.empty())
866 SetConfig(effect, PluginSettings::Private, name, parametersKey, ParametersToString(vst3settings.parameterChanges));
867}
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References anonymous_namespace{VST3Wrapper.cpp}::controllerStateKey, anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), name, anonymous_namespace{VST3Wrapper.cpp}::parametersKey, anonymous_namespace{VST3Wrapper.cpp}::ParametersToString(), PluginSettings::Private, anonymous_namespace{VST3Wrapper.cpp}::processorStateKey, PluginSettings::SetConfig(), and settings().

Referenced by VST3Effect::SaveUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StoreSettings()

void VST3Wrapper::StoreSettings ( EffectSettings settings) const

Saves current state inside settings object, clears all runtime data.

Definition at line 526 of file VST3Wrapper.cpp.

527{
528 using namespace Steinberg;
529
530 VST3EffectSettings vst3settings;
531
532 {
533 PresetsBufferStream processorState;
534 if(mEffectComponent->getState(&processorState) == kResultOk)
535 vst3settings.processorState = processorState.toString();
536 }
537 {
538 PresetsBufferStream controllerState;
539 if(mEditController->getState(&controllerState) == kResultOk)
540 vst3settings.controllerState = controllerState.toString();
541 }
542
543 std::swap(vst3settings, GetSettings(settings));
544}
wxString toString() const
Definition: VST3Utils.cpp:94

References anonymous_namespace{VST3Wrapper.cpp}::GetSettings(), mEditController, mEffectComponent, settings(), anonymous_namespace{NoteTrack.cpp}::swap(), and PresetsBufferStream::toString().

Referenced by Finalize(), Initialize(), VST3UIValidator::OnClose(), VST3UIValidator::OnIdle(), VST3UIValidator::ValidateUI(), and VST3Wrapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SuspendProcessing()

void VST3Wrapper::SuspendProcessing ( )

Definition at line 772 of file VST3Wrapper.cpp.

773{
774 mAudioProcessor->setProcessing(false);
775}

References mAudioProcessor.

Member Data Documentation

◆ mActive

bool VST3Wrapper::mActive {false}
private

Definition at line 133 of file VST3Wrapper.h.

Referenced by Finalize(), FlushParameters(), Initialize(), and IsActive().

◆ mAudioProcessor

Steinberg::IPtr<Steinberg::Vst::IAudioProcessor> VST3Wrapper::mAudioProcessor

◆ mComponentConnectionProxy

Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> VST3Wrapper::mComponentConnectionProxy

Definition at line 62 of file VST3Wrapper.h.

Referenced by VST3Wrapper(), and ~VST3Wrapper().

◆ mComponentHandler

Steinberg::IPtr<Steinberg::Vst::IComponentHandler> VST3Wrapper::mComponentHandler

◆ mControllerConnectionProxy

Steinberg::IPtr<Steinberg::Vst::IConnectionPoint> VST3Wrapper::mControllerConnectionProxy

Definition at line 63 of file VST3Wrapper.h.

Referenced by VST3Wrapper(), and ~VST3Wrapper().

◆ mDefaultSettings

EffectSettings VST3Wrapper::mDefaultSettings
private

Definition at line 55 of file VST3Wrapper.h.

Referenced by FetchSettings(), and VST3Wrapper().

◆ mEditController

Steinberg::IPtr<Steinberg::Vst::IEditController> VST3Wrapper::mEditController

◆ mEffectComponent

Steinberg::IPtr<Steinberg::Vst::IComponent> VST3Wrapper::mEffectComponent

◆ mEffectUID

const VST3::UID VST3Wrapper::mEffectUID
private

Definition at line 134 of file VST3Wrapper.h.

Referenced by LoadPreset(), SavePreset(), and VST3Wrapper().

◆ mModule

VST3::Hosting::Module& VST3Wrapper::mModule
private

Definition at line 56 of file VST3Wrapper.h.

Referenced by GetModule().

◆ mParameterQueues

std::unique_ptr<SingleInputParameterValue[]> VST3Wrapper::mParameterQueues
private

Definition at line 141 of file VST3Wrapper.h.

Referenced by Process(), and VST3Wrapper().

◆ mParameters

std::vector<std::pair<Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue> > VST3Wrapper::mParameters
private

Definition at line 136 of file VST3Wrapper.h.

Referenced by ConsumeChanges(), Process(), and VST3Wrapper().

◆ mSetup

Steinberg::Vst::ProcessSetup VST3Wrapper::mSetup

◆ ParamChangedHandler

std::function<void (Steinberg::Vst::ParamID, Steinberg::Vst::ParamValue)> VST3Wrapper::ParamChangedHandler

The documentation for this class was generated from the following files: