Skip to content

Commit

Permalink
[ENHANCEMENT,BREAKING] Serialize plugin version (#458)
Browse files Browse the repository at this point in the history
* Put version in serialized state

* Add header to serialized state
  • Loading branch information
sdatkinson authored Apr 6, 2024
1 parent 3dba2cd commit 3c05ec1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ void NeuralAmpModeler::OnIdle()

bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const
{
// If this isn't here when unserializing, then we know we're dealing with something before v0.8.0.
WDL_String header("###NeuralAmpModeler###"); // Don't change this!
chunk.PutStr(header.Get());
// Plugin version, so we can load legacy serialized states in the future!
WDL_String version(PLUG_VERSION_STR);
chunk.PutStr(version.Get());
// Model directory (don't serialize the model itself; we'll just load it again
// when we unserialize)
chunk.PutStr(mNAMPath.Get());
Expand All @@ -400,7 +406,19 @@ bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const

int NeuralAmpModeler::UnserializeState(const IByteChunk& chunk, int startPos)
{
WDL_String dir;
WDL_String header;
startPos = chunk.GetStr(header, startPos);
// TODO: Handle legacy plugin serialized states.
//if strncmp (header.Get(), "###NeuralAmpModeler###")
//{
// return UnserializeStateLegacy(header, startPos); // (We'll assume 0.7.9).
//}
WDL_String version;
startPos = chunk.GetStr(version, startPos);
// Version-specific loading here if needed.
// ...

// Current version loading:
startPos = chunk.GetStr(mNAMPath, startPos);
startPos = chunk.GetStr(mIRPath, startPos);
int retcode = UnserializeParams(chunk, startPos);
Expand Down

0 comments on commit 3c05ec1

Please sign in to comment.