View Single Post
Old 03-26-2010, 09:33 AM   #8
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

works fine here too (win). I see you manage "text params", here I separate true param chunks and, say, 'unrelated raw data' (such as text) with a fake control (i.e. a control that doesn't have a VST param), eg, typivcally, to restore a file path, after OnParamReset():

Code:
int PlugExample::UnserializeState(ByteChunk* pChunk, int startPos) 
{ 
  IMutexLock lock(this);

//from IPlugBase --->
  int i, n = mParams.GetSize(), pos = startPos;
  for (i = 0; i < n && pos >= 0; ++i) {
    IParam* pParam = mParams.Get(i);
    double v = 0.0;
    Trace(TRACELOC, "%d %s", i, pParam->GetNameForHost());
    pos = pChunk->Get(&v, pos);
    pParam->Set(v);
  }
  OnParamReset();
//<---

#ifdef FX_REA_CONTROL
  // load the path
  WDL_String filename;
  pos = pChunk->GetStr(&filename, pos);
  ((IFileSelectorControl*)m_gfx->GetControl(m_fileGfxIdx))->SetLastSelectedFileFromPlug(filename.Get());
#endif
  return pos;
}
HTH
Jeffos is offline   Reply With Quote