MCPcopy Create free account
hub / github.com/audacity/audacity / LoadPreset

Method LoadPreset

libraries/lib-vst3/VST3Wrapper.cpp:652–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

650}
651
652void VST3Wrapper::LoadPreset(const wxString& presetId)
653{
654 using namespace Steinberg;
655
656 auto cache = GetCache(mEffectClassInfo.ID());
657
658 if(cache->rootUnitProgramChangeParameterID != Vst::kNoParamId &&
659 cache->rootUnitProgramCount > 0)
660 {
661 Vst::UnitID unitId;
662 int32 programIndex;
663 if(VST3Utils::ParseFactoryPresetID(presetId, unitId, programIndex) &&
664 programIndex >= 0 && programIndex < cache->rootUnitProgramCount)
665 {
666 auto paramValueNormalized = static_cast<Vst::ParamValue>(programIndex);
667 if(cache->rootUnitProgramCount > 1)
668 paramValueNormalized /= static_cast<Vst::ParamValue>(cache->rootUnitProgramCount - 1);
669
670 mEditController->setParamNormalized(
671 cache->rootUnitProgramChangeParameterID,
672 paramValueNormalized);
673
674 if(mComponentHandler)
675 {
676 mComponentHandler->beginEdit(cache->rootUnitProgramChangeParameterID);
677 auto commit = finally([&] { mComponentHandler->endEdit(cache->rootUnitProgramChangeParameterID); });
678 mComponentHandler->performEdit(
679 cache->rootUnitProgramChangeParameterID,
680 paramValueNormalized);
681 }
682
683 return;
684 }
685 }
686
687 auto fileStream = owned(Vst::FileStream::open(presetId.c_str(), "rb"));
688 if(!fileStream)
689 throw FileException(FileException::Cause::Open, presetId);
690
691 if(!LoadPresetFromStream(fileStream))
692 {
693 throw SimpleMessageBoxException(
694 ExceptionType::BadEnvironment,
695 XO("Unable to apply VST3 preset file %s").Format(presetId),
696 XO("Error"));
697 }
698}
699
700void VST3Wrapper::SavePresetToFile(const wxString& filepath) const
701{

Callers

nothing calls this directly

Calls 9

GetCacheFunction · 0.85
finallyFunction · 0.85
FileExceptionFunction · 0.85
beginEditMethod · 0.80
endEditMethod · 0.80
performEditMethod · 0.80
IDMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected