Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT,BREAKING] Serialize plugin version #458

Merged
merged 3 commits into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading