| 650 | } |
| 651 | |
| 652 | void 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 | |
| 700 | void VST3Wrapper::SavePresetToFile(const wxString& filepath) const |
| 701 | { |
nothing calls this directly
no test coverage detected