//----------------------------------------------------------------------------- tresult PLUGIN_API HostCheckerProcessor::setState (IBStream* state) { FUnknownPtr<IStreamAttributes> stream (state); if (stream) { IAttributeList* list = stream->getAttributes (); if (list) { addLogEvent (kLogIdIAttributeListInSetStateSupported); } } float saved = 0.f; if (state->read (&saved, sizeof (float)) != kResultOk) { return kResultFalse; } #if BYTEORDER == kBigEndian SWAP_32 (toSave) #endif if (saved != 12345.67f) { ASSERT (false) } return kResultOk; }
//------------------------------------------------------------------------ tresult PLUGIN_API VSTGUIEditor::setFrame (IPlugFrame* frame) { if (frame) { FUnknownPtr<IPlugFrameIdle> frameIdle (frame); if (frameIdle) frameIdle->addIdleHandler (this); } else if (plugFrame) { FUnknownPtr<IPlugFrameIdle> frameIdle (plugFrame); if (frameIdle) frameIdle->removeIdleHandler (this); } return EditorView::setFrame (frame); }
//------------------------------------------------------------------------ void PLUGIN_API TestAnimationController::update (FUnknown* changedUnknown, int32 message) { if (message == kChanged) { FUnknownPtr<Parameter> parameter (changedUnknown); if (parameter && animationView && animationView->getFrame ()) { Animation::InterpolationTimingFunction* timingFunction = new Animation::InterpolationTimingFunction (200); timingFunction->addPoint (0.5f, 0.2f); int32 value = parameter->toPlain (parameter->getNormalized ()); if (value) { animationView->getFrame ()->getAnimator ()->addAnimation (animationView, "SizeAnimation", new Animation::ViewSizeAnimation (originalRect), timingFunction); } else { CRect r (originalRect); r.bottom += 300; r.right += 80; animationView->getFrame ()->getAnimator ()->addAnimation (animationView, "SizeAnimation", new Animation::ViewSizeAnimation (r), timingFunction); } } } }
//------------------------------------------------------------------------ tresult PLUGIN_API AGain::setState (IBStream* state) { // called when we load a preset, the model has to be reloaded float savedGain = 0.f; if (state->read (&savedGain, sizeof (float)) != kResultOk) { return kResultFalse; } float savedGainReduction = 0.f; if (state->read (&savedGainReduction, sizeof (float)) != kResultOk) { return kResultFalse; } int32 savedBypass = 0; if (state->read (&savedBypass, sizeof (int32)) != kResultOk) { return kResultFalse; } #if BYTEORDER == kBigEndian SWAP_32 (savedGain) SWAP_32 (savedGainReduction) SWAP_32 (savedBypass) #endif fGain = savedGain; fGainReduction = savedGainReduction; bBypass = savedBypass > 0; // Example of using the IStreamAttributes interface FUnknownPtr<IStreamAttributes> stream (state); if (stream) { IAttributeList* list = stream->getAttributes (); if (list) { // get the current type (project/Default..) of this state String128 string; if (list->getString (PresetAttributes::kStateType, string, 128 * sizeof (TChar)) == kResultTrue) { UString128 tmp (string); char ascii[128]; tmp.toAscii (ascii, 128); if (!strncmp (ascii, StateType::kProject, strlen (StateType::kProject))) { // we are in project loading context... } } // get the full file path of this state TChar fullPath[1024]; if (list->getString (PresetAttributes::kFilePathStringType, fullPath, 1024 * sizeof (TChar)) == kResultTrue) { // here we have the full path ... } } } return kResultOk; }