iffyloop / EasyVst

Easy-to-use VST3 wrapper for hosting VST3 plugins without JUCE or other frameworks
Other
57 stars 6 forks source link

_vstPlug=>getState/setState #3

Closed syntaro closed 1 year ago

syntaro commented 1 year ago

Hello, I tried [Save. Load] Plugin Status, But It seems not worked. on KORG M1, Steinberg HalionSonic etc,, What was wrong with me?

Thank you. `

BOOL EasyVst::savePluginState(const char utfPath) { Steinberg::IBStream processState = NULL, controlState = NULL; BOOL success = FALSE; try { std::string path2 = utfPath; path2 += "-ctrl"; processState = FileStream::open(utfPath, "w"); controlState = FileStream::open(path2.c_str(), "w"); _vstComponent->getState(processState); _editController->getState(controlState); success = TRUE; } catch (...) { } if (processState != NULL) processState->release(); if (controlState != NULL) controlState->release(); return success; } BOOL EasyVst::loadPluginState(const char utfPath) { Steinberg::IBStream processState = NULL, controlState = NULL; BOOL success = FALSE; try { std::string path2 = utfPath; path2 += "-ctrl"; processState = FileStream::open(utfPath, "r"); controlState = FileStream::open(path2.c_str(), "r"); if (processState != NULL) { _vstComponent->setState(processState); _editController->setComponentState(processState); } if (controlState != NULL) { _editController->setState(controlState); } success = TRUE; } catch (...) { } if (processState != NULL) processState->release(); if (controlState != NULL) controlState->release(); return success; }

`

syntaro commented 1 year ago

I did [google search]. And got it. Thank you EasyVst Owner. ` BOOL EasyVst::savePluginState(const char utfPath) { Steinberg::IBStream file = NULL; BOOL success = FALSE; try { std::string path2 = utfPath; path2 += "-ctrl"; file = FileStream::open(utfPath, "wb"); FUID uid; _vstComponent->getControllerClassId((char*)&uid); success = Steinberg::Vst::PresetFile::savePreset( file, uid, _vstComponent, _editController ); } catch (...) { } if (file != NULL) file->release(); return success; }

BOOL EasyVst::loadPluginState(const char utfPath) { Steinberg::IBStream file = NULL; BOOL success = FALSE; try { file = FileStream::open(utfPath, "rb"); FUID uid; _vstComponent->getControllerClassId((char*)&uid); success = Steinberg::Vst::PresetFile::loadPreset( file, uid, _vstComponent, _editController ); } catch (...) { } if (file != NULL) file->release(); return success; } `